Core Smart Contracts

Core Smart Contracts

Contract Overview

Tropykus Finance utilizes several key smart contracts, including:

  • cToken.sol: Handles deposits, withdrawals, interests, and liquidations for lenders and borrowers on the markets.

  • Unitroller: Handles the administrative and share logic of the protocol

Interacting with Contracts

Setting Up

  1. Clone the repository: Clone the repository from Github https://github.com/Tropykus/protocol-rsk

  2. Environment Setup: Ensure you have Node.js installed and set up the Truffle Suite or Hardhat for compiling and deploying smart contracts.

  3. Install Dependencies: Run npm installto handle upgrades and secure your smart contracts.

Interaction with the protocol

// 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


WARNING for SAFE multisig

Deprecated markets and functions

The following markets have been deprecated an isolated

Contract
Rootstock Testnet
Rootstock Mainnet

kSAT

0x13f3a4013e77a65b0cd941b8b0e1687e8f3a0e1d

0xd2ec53e8dd00d204d3d9313af5474eb9f5188ef6

kUSDT

0x5539d6d48a2147cb824c5c45baaa01e7e1a2694f

0xedaefc6b596ed38d712100976969975a37c84464

kRIF

0x23b60e2193057b4b2823973b7478489a076de84f

0x3134b7fbfca5db217eca523eab1941452cf35163

Deprecated functions

The function getSupplierSnapshotStored(address) from the CToken.sol smart contract has been deprecated and MUST NOT BE USED


Smart Contracts ABIs

ERC20

5KB
Open
ERC20 ABI

Unitroller

Unitroller ABI

CToken (kDOC, kBPRO)

CRBTC (kRBTC)

31KB
Open
CRBTC ABI

Last updated