Repaying Debt
Before calling repay()
repay()Setup
import { ethers } from "ethers";
const provider = new ethers.JsonRpcProvider("YOUR_RPC_URL");
const wallet = new ethers.Wallet("YOUR_PRIVATE_KEY", provider);
const cUSDCAddress = "0x...";
const USDCAddress = "0x...";
const protocolReaderAddress = "0x...";
const cUSDC = new ethers.Contract(cUSDCAddress, BORROWABLE_CTOKEN_ABI, wallet);
const USDC = new ethers.Contract(USDCAddress, ERC20_ABI, wallet);
const protocolReader = new ethers.Contract(
protocolReaderAddress,
PROTOCOL_READER_ABI,
provider
);
const marketManager = new ethers.Contract(
await cUSDC.marketManager(),
MARKET_MANAGER_ABI,
provider
);Helper Functions
Repaying Your Own Debt
The repay(0) shortcut
repay(0) shortcutRepaying Debt on Behalf of Others (repayFor)
repayFor)Common error scenarios
Error
Meaning
Last updated
Was this helpful?