Borrowing & Repayment
Introduction to cTokens in Curvance
In Curvance's lending ecosystem, BorrowableCTokens represent debt positions. Each BorrowableCToken corresponds to a specific underlying asset - for example, cUSDC represents borrowed USDC. When you borrow an asset from Curvance, you're interacting with a cToken contract that tracks your debt.
Understanding cUSDC
cUSDC is the debt token representing borrowed USDC in Curvance. When you borrow USDC, you're effectively taking on cUSDC 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 cUSDC 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 cUSDC, you'll need to set up your environment with ethers.js. You'll need contract ABIs for interaction, but we'll keep it simple here - you can obtain the full ABIs from the Curvance contract repo.
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 the Curvance contracts repo
const cUSDCAddress = '0x...'; // cUSDC contract address
const USDCAddress = '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'; // USDC address
// Initialize contract instances with appropriate ABIs
const cUSDC = new ethers.Contract(eUSDCAddress, BORROWABLECTOKENABI, 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 debtBalanceAtTimestamp in the ProtocolReader function fetches your current debt balance with the latest interest applied:
async function checkDebtBalance() {
const debtBalance =
await protocolReader.debtBalanceAtTimestamp(wallet.address, blockTimestamp);
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 cUSDC debt depends on market supply and demand. You can check current market conditions to make informed borrowing decisions:
async function checkBorrowableCUSDCMarketInfo() {
// Get the current exchange rate (how much USDC each unit of eUSDC is worth)
// Use exchangeRate() or exchangeRate() using a static call to get the most
// up to date exchange rate including all vesting periods.
const exchangeRate = await cUSDC.exchangeRate();
console.log(`Current exchange rate: ${ethers.utils.formatUnits(exchangeRate, 18)}`); // In WAD format
// Get total outstanding borrows in the market
const totalBorrows = await cUSDC.callStatic.marketOutstandingDebt();
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 cUSDC, 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.
Last updated