Core Smart Contracts
Core Smart Contracts
Contract Overview
Interacting with Contracts
// Import the ABI of the lending pool
import { ethers } from 'ethers'
import UnitrollerABI from "./abis/UnitrollerABI.json";
import ERC20ABI from "./abis/ERC20ABI.json";
import CTokenABI from "./abis/CTokenABI.json";
import CRBTCABI from "./abis/CRBTCABI.json";
[signer] = await ethers.getSigners()
const UnitrollerAddress = "0x123...";
const DOCAddress = "0x456....";
const kDOCAddress = "0x789...";
const kRBTCAddress = "0xa01...";
const unitroller = new ethers.Contract(UnitrollerAddress, UnitrollerABI, signer);
const doc = new ethers.Contract(DOCAddress, ERC20ABI, signer);
const kdoc = new ethers.Contract(kDOCAddress, CTokenABI, signer);
const kcrbtc = new ethers.Contract(kRBTCAddress, CRBTCABI, signer);
//Enter markets
await comp.connect(dep).enterMarkets([kdoc.address, krbtc.address])
// Deposit Assets
await doc.connect(dep).approve(kdoc.address, ethers.utils.parseEther('10'))
await kdoc.connect(dep).mint(ethers.utils.parseEther('10'), { gasLimit: 2500000 }) amount in underlying
await krbtc.connect(dep).mint({value: ethers.utils.parseEther('0.1'), gasLimit: 2500000})
// Borrow assets
await kdoc.connect(dep).borrow(ethers.utils.parseEther('2'), { gasLimit: 250000 })
// Check the borrow balance
Number(await kdoc.callStatic.borrowBalanceCurrent(dep.address))/1e18
// Withdraw Assets
await kdoc.connect(dep).redeemUndeem(ethers.utils.parseEther('10'))
// Repay debts
await doc.connect(dep).approve(kdoc.address, ethers.utils.parseEther('1')) 3E+18
await kdoc.connect(dep).repayBorrow(ethers.utils.parseEther('1'),{ gasLimit: 2500000}) amount in underlying Deployed smart contracts
Contract
Rootstock Testnet
Rootstock Mainnet
Deprecated markets and functions
Contract
Rootstock Testnet
Rootstock Mainnet
Deprecated functions
Smart Contracts ABIs
ERC20
Unitroller
CToken (kDOC, kBPRO)
Last updated