Lend Assets
Depositing USDC for Lending (eUSDC)
To deposit USDC into eUSDC directly, you may use the mint()
function present in all eToken contracts using the following arguments:
uint256
amount
The amount in shares to.
Below is a full implementation:
// Get the eUSDC contract with signer
const eUSDC = new ethers.Contract(ADDRESSES.EUSDC, ETOKEN_ABI, signer);
// Get the USDC contract with signer
const usdc = new ethers.Contract(ADDRESSES.USDC, ERC20_ABI, signer);
// Format amount (USDC has 6 decimals)
const depositAmount = ethers.utils.parseUnits("1000", 6); // 1000 USDC
// Approve eUSDC to spend USDC
await usdc.approve(ADDRESSES.EUSDC, depositAmount);
// Deposit USDC for lending
await eUSDC.mint(depositAmount);
When you deposit USDC into eUSDC:
Your USDC tokens are transferred to the eToken contract.
You receive eUSDC tokens representing your lending position.
Your USDC becomes available for borrowers to borrow (subject to their collateral).
As borrowers pay interest, the exchange rate between eUSDC and USDC increases.
When you redeem your eUSDC tokens later, you receive your original USDC plus accrued interest.
Using mintFor
If your app requires users to mint pTokens to another contract, you can use the mintFor()
function in the eToken contract using the following function arguments:
Calling mintFor():
uint256
amount
The amount of the underlying asset to deposit.
address
recipient
The account that should receive the eTokens.
The Universal Balance System: A Simplified Interface
Curvance offers a Universal Balance system that provides a simplified way to manage deposits by calling deposit()
in the UniversalBalance contract using the following function arguments:
uint256
amount
The amount of underlying token to be deposited.
bool
willLend
Whether the deposited underlying tokens should be lent out inside Curvance Protocol.
Implementation snippet:
const universalBalance = new ethers.Contract(
UNIVERSAL_BALANCE_ADDRESS,
UNIVERSAL_BALANCE_ABI,
signer
);
// Approve Universal Balance to spend USDC
await usdc.approve(UNIVERSAL_BALANCE_ADDRESS, depositAmount);
// Deposit to Universal Balance
// If willLend is true, funds are deposited into eUSDC
// If willLend is false, funds are held in the Universal Balance without being lent
await universalBalance.deposit(depositAmount, willLend);
For native gas tokens, Curvance provides a specialized Universal Balance Native contract:
const universalBalanceNative = new ethers.Contract(
UNIVERSAL_BALANCE_NATIVE_ADDRESS,
UNIVERSAL_BALANCE_NATIVE_ABI,
signer
);
// Deposit ETH - if isLent is true, ETH is wrapped and lent as WETH
await universalBalanceNative.depositNative(isLent, {
value: ethers.utils.parseEther("1.0") // 1 ETH
});
Alternatively, if your app requires depositing for another address, you may use the depositFor()
and depositNativeFor()
functions in their respective contracts.
Depositing for Multiple Users in One Transaction
If you have many users to loan assets for, you may use the multiDepositFor()
function which deposits underlying token into recipients Universal Balance accounts, either to be held or lent out.
multiDepositFor() can be called with the following arguments:
Last updated