Tropykus Protocol
  • Tropykus Overview
  • Core Smart Contracts
  • Tropykus JS
Powered by GitBook
On this page
  • Core Smart Contracts
  • Smart Contracts ABIs

Core Smart Contracts

PreviousTropykus OverviewNextTropykus JS

Last updated 10 months ago

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

  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

Contract
Rootstock Testnet
Rootstock Mainnet

DOC

0xcb46c0ddc60d18efeb0e586c17af6ea36452dae0

0xe700691da7b9851f2f35f8b8182c69c53ccad9db

BPRO

0x4da7997a819bb46b6758b9102234c289dd2ad3bf

0x440cd83c160de5c96ddb20246815ea44c7abbca8

Unitroller

0xb1bec5376929b4e0235f1353819dba92c4b0c6bb

0x962308fEf8edFaDD705384840e7701F8f39eD0c0

kDOC

0x71e6b108d823c2786f8ef63a3e0589576b4f3914

0x544eb90e766b405134b3b3f62b6b4c23fcd5fda2

kBPRO

0x844a99Ba756539Aee698ce2915d678bA0FeE4d9d

0x405062731d8656af5950ef952be9fa110878036b

kRBTC

0x5b35072cd6110606c8421e013304110fa04a32a3

0x0aeadb9d4c6a80462a47e87e76e487fa8b9a37d7

kUSDRIF

0xfbee4444493194468df1de7450a37d840eb8b555

0xDdf3CE45fcf080DF61ee61dac5Ddefef7ED4F46C


Smart Contracts ABIs

ERC20

Unitroller

CToken (kDOC, kBPRO)

CRBTC (kRBTC)

https://github.com/Tropykus/protocol-rsk
5KB
ERC20.json
ERC20 ABI
46KB
Unitroller.json
Unitroller ABI
34KB
CErc20Immutable.json
31KB
CRBTC.json
CRBTC ABI