Curvance
  • Protocol Overview
    • Click Less, Earn More
    • Protocol Architecture
    • Asset Types
    • Liquidity Markets
      • Borrowing
      • Liquidations
      • Interest Rates
      • Oracles
      • Collateral Caps
      • Bad Debt Socialization
    • Application Specific Sequencing
    • New Age Liquidity Mining
      • Protocols
    • How Are New Assets Integrated
    • Plugin System
    • Universal Account Balance
    • Token Approval Management
    • Lending Risks
  • Security
    • Security and Audits
  • Miscellaneous
    • RPCs and Testnet Stability
    • Glossary
    • TL;DR
      • Customer Types and Benefits
    • Brand Assets
    • Weblinks
    • Disclaimer
    • Frequently Asked Questions
  • Developer Docs
    • Overview
    • Quick Start Guides
      • Atlas Fastlane Auctions (coming soon)
      • Plugin Integration
        • List of Delegable Actions
      • Loans & Collateral
        • Lend Assets
        • Deposit into pTokens
        • Withdraw Loans
        • Withdraw pTokens
      • Borrowing & Repayment
        • Borrow
        • Repaying Debt
      • Leverage
        • Leveraging
        • Deleveraging
    • Lending Protocol
      • Market Manager
      • Position Tokens (pToken)
      • Earn Tokens (eTokens)
      • Dynamic Interest Rate Model
      • Universal Balance
    • Position Management
      • Leverage
      • Deleverage / Fold
    • Dynamic Liquidation Engine (DLE)
      • OEV Liquidation System
      • Bad Debt Socialization
    • Plugin & Delegation System
      • Transfer Lock Mechanism
      • Delegable Actions
    • Cross-Chain Functionality
      • Messaging Hub
      • Fee Manager
      • Reward Manager
    • Auxiliary Functionality
Powered by GitBook
On this page
  • Depositing USDC for Lending (eUSDC)
  • The Universal Balance System: A Simplified Interface
Export as PDF
  1. Developer Docs
  2. Quick Start Guides
  3. Loans & Collateral

Lend Assets

PreviousLoans & CollateralNextDeposit into pTokens

Last updated 6 days ago

For a detailed explanation of eTokens, check out this article:

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:

Type
Name
Instruction

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:

  1. Your USDC tokens are transferred to the eToken contract.

  2. You receive eUSDC tokens representing your lending position.

  3. Your USDC becomes available for borrowers to borrow (subject to their collateral).

  4. As borrowers pay interest, the exchange rate between eUSDC and USDC increases.

  5. 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():

Type
Parameter
Description

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:

Type
Name
Description

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:

Earn Tokens (eTokens)