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)
      • Orderflow Auction 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
  • Introduction to eTokens in Curvance
  • Understanding eUSDC
  • Setting Up Your Development Environment
  • Monitoring Your Debt Position
  • Understanding Market Conditions
  • Risk Considerations
Export as PDF
  1. Developer Docs
  2. Quick Start Guides

Borrowing & Repayment

PreviousWithdraw pTokensNextBorrow

Last updated 15 days ago

Introduction to eTokens in Curvance

In Curvance's lending ecosystem, eTokens represent debt positions. Each eToken corresponds to a specific underlying asset - for example, eUSDC represents borrowed USDC. When you borrow an asset from Curvance, you're interacting with an eToken contract that tracks your debt.

For an in depth explanation of eTokens, check out this guide here:

Understanding eUSDC

eUSDC is the debt token representing borrowed USDC in Curvance. When you borrow USDC, you're effectively taking on eUSDC debt. Key characteristics include:

  • Underlying Asset: USDC (USD Coin) stablecoin with 6 decimal places.

  • Interest Accrual: Interest accumulates continuously based on market conditions, increasing your debt over time.

  • Exchange Rate: The relationship between eUSDC and USDC changes as interest accrues.

  • Dynamic Interest: Rates adjust automatically based on utilization ratio in the USDC lending market.

Curvance implements a 20-minute minimum hold period for collateral, which means your collateral must remain in the system for at least 20 minutes. This enhances security by preventing certain types of exploits and flash loan attacks.

Setting Up Your Development Environment

Before interacting with eUSDC, you'll need to set up your environment with ethers.js v5.7.3. You'll need contract ABIs for interaction, but we'll keep it simple here - you can obtain the full ABIs from Curvance documentation.

const { ethers } = require('ethers');

const provider = new ethers.providers.JsonRpcProvider('YOUR_RPC_URL');
const wallet = new ethers.Wallet('YOUR_PRIVATE_KEY', provider);

// You'll need to obtain the complete ABIs from Curvance documentation
const eUSDCAddress = '0x...';        // eUSDC contract address
const USDCAddress = '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'; // USDC address

// Initialize contract instances with appropriate ABIs
const eUSDC = new ethers.Contract(eUSDCAddress, ETokenABI, wallet);
const USDC = new ethers.Contract(USDCAddress, USDCABI, wallet);

Monitoring Your Debt Position

As interest accrues on your debt, it's important to monitor your position regularly. Curvance provides several functions to help you track your debt balance.The debtBalanceWithUpdateSafe function fetches your current debt balance with the latest interest applied:

async function checkDebtBalance() {
  const debtBalance = await eUSDC.debtBalanceWithUpdateSafe(wallet.address);
  const USDCDecimals = await USDC.decimals();
  
  console.log(`Current USDC debt: ${ethers.utils.formatUnits(debtBalance, USDCDecimals)}`);
  return debtBalance;
}

The debt balance will increase over time as interest accrues. If your debt grows too large relative to your collateral, you risk liquidation. Maintaining a healthy collateralization ratio is essential for using Curvance safely.

Understanding Market Conditions

The interest rate for eUSDC debt depends on market supply and demand. You can check current market conditions to make informed borrowing decisions:

async function checkEUSDCMarketInfo() {
  // Get the current exchange rate (how much USDC each unit of eUSDC is worth)
  const exchangeRate = await eUSDC.exchangeRateWithUpdateSafe();
  console.log(`Current exchange rate: ${ethers.utils.formatUnits(exchangeRate, 18)}`); // In WAD format
  
  // Get total outstanding borrows in the market
  const totalBorrows = await eUSDC.totalBorrowsWithUpdateSafe();
  const USDCDecimals = await USDC.decimals();
  console.log(`Total USDC borrowed: ${ethers.utils.formatUnits(totalBorrows, USDCDecimals)}`);
  
  return { exchangeRate, totalBorrows };
}

Higher utilization (more borrowing relative to available supply) generally leads to higher interest rates. Monitoring these metrics can help you anticipate changes in borrowing costs.

Risk Considerations

When borrowing through eUSDC, be aware of these risks:

  • Liquidation Risk: If your collateral value falls or your debt increases (through interest accrual), you may face liquidation if your position drops below the required collateralization ratio.

  • Interest Rate Volatility: Rates can change based on market conditions, potentially increasing your debt faster than anticipated.

  • Protocol Risk: Smart contract vulnerabilities or governance decisions could affect your borrowing position.

  • Market Risk: The value of your collateral might decrease relative to your borrowed USDC.

To mitigate these risks, consider maintaining a higher collateralization ratio than the minimum required, and regularly monitor your position's health.

Earn Tokens (eTokens)