Withdraw Loans
Last updated
Last updated
If you would like your platform to display the amount of underlying tokens the user would receive for redeeming eTokens, you may use the convertToAsset()
function present in all eToken contracts using the following arguments:
uint256
tokens
The number of eToken shares to theoretically convert to underlying assets
Conversely, if you want to let the user choose how much underlying assets to withdraw, you may use the convertToShares()
function:
uint256
amount
The number of underlying tokens to theoretically convert to eTokens
To withdraw USDC from eUSDC directly, you may use the redeem()
function present in all eToken contracts using the following arguments:
uint256
tokens
The number of eTokens to redeem for underlying tokens
address
recipient
The account who will receive the underlying assets
Below is a full implementation, letting the user choose how much underlying to redeem:
If your app requires users to withdraw underlying assets to another address, you can use the redeemFor()
function in the eToken contract using the following function arguments:
Calling redeemFor()
:
uint256
amount
The amount of the eToken shares to redeem.
address
recipient
The account that should receive the underlying assets.
Curvance offers a Universal Balance system that provides a simplified way to manage withdrawals by calling withdraw()
in the UniversalBalance contract using the following function arguments:
uint256
amount
The amount of underlying token to be withdrawn.
bool
forceLentRedemption
Whether the withdrawn underlying tokens should be pulled only from owner's lent position or the full account.
address
recipient
The account who will receive the underlying assets.
Implementation snippet:
For native gas tokens, Curvance provides a specialized Universal Balance Native contract:
Alternatively, if your app requires depositing for another address, you may use the withdrawFor()
and withdrawNativeFor()
functions in their respective contracts.