tropykus is an algorithmic distributed protocol deployed on the RSK network. As such, it's main motivation is to allow users to lend crypto currencies as collateral and to borrow crypto assets based on interest rates set by real-time supply and demand smart contracts. The tropykus Protocol is developed using RSK smart contracts for supplying or borrowing assets. Through the cToken contracts, accounts on the blockchain supply capital (rBTC or ERC-20 tokens) to receive cTokens or borrow assets from the protocol (holding other assets as collateral). The tropykus cToken contracts track these balances and algorithmically set interest rates for borrowers.
You can read the protocol documentation at tropykus.app
We detail a few of the core contracts in the tropykus protocol.
- CToken, CErc20 and CRBTC
- The tropykus cTokens, which are self-contained borrowing and lending contracts. CToken contains the core logic and CErc20 and CRBTC add public interfaces for Erc20 tokens and rBTC, respectively. Each CToken is assigned an interest rate and risk model (see InterestRateModel and Comptroller sections), and allows accounts to *mint* (supply capital), *redeem* (withdraw capital), *borrow* and *repay a borrow*. Each CToken is an ERC-20 compliant token where balances represent ownership of the market.
- Price Oracle Proxy
- This contract controlls the adapters that link the protocol with price oracles.
- Comptroller
- The risk model contract, which validates permissible user actions and disallows actions if they do not fit certain risk parameters. For instance, the Comptroller enforces that each borrowing user must maintain a sufficient collateral balance across all cTokens.
- TROP
- The tropykus Governance Token (TROP). Holders of this token have the ability to govern the protocol via the governor contract.
- Governor Alpha
- The administrator of the tropykus timelock contract. Holders of TROP token may create and vote on proposals which will be queued into the tropykus timelock and then have effects on tropykus cToken and Copmtroller contracts. This contract may be replaced in the future with a beta version.
- InterestRateModel
- Contracts which define interest rate models. These models algorithmically determine interest rates based on the current utilization of a given market (that is, how much of the supplied assets are liquid versus borrowed).
- Careful Math
- Library for safe math operations.
- ErrorReporter
- Library for tracking error codes and failure conditions.
- Exponential
- Library for handling fixed-point decimal numbers.
- SafeToken
- Library for safely handling Erc20 interaction.
To run tropykus, pull the repository from GitHub and install its dependencies. You will need yarn or npm installed.
git clone https://github.com/TruStartUp/tropykus-protocol
cd tropykus-protocol
yarn install --lock-file # or `npm install`
The tropykus Protocol has a simple scenario evaluation tool to test and evaluate scenarios which could occur on the blockchain. We inherited this feature from the original source code and this is primarily used for constructing high-level integration tests. The tool also has a REPL to interact with local the tropykus Protocol (similar to truffle console
).
yarn repl -n development
yarn repl -n rinkeby
> Read CToken cBAT Address
Command: Read CToken cBAT Address
AddressV<val=0xAD53863b864AE703D31b819d29c14cDA93D7c6a6>
You can read more about the scenario runner in the Scenario Docs on steps for using the repl.
Jest contract tests are defined under the tests directory. To run the tests run:
yarn test
There are additional tests under the spec/scenario folder. These are high-level integration tests based on the scenario runner depicted above. The aim of these tests is to be highly literate and have high coverage in the interaction of contracts.
To run code coverage, run:
yarn coverage
To lint the code, run:
yarn lint
tropykus initially developed and tested on:
-
Operating system: macOS, debian 10 (buster), ubuntu LTS.
-
Node.js(LTS 12)
-
npm (optional)
-
ganache-cli (optional)
-
sol-select(optional)
-
node-gyp(optional)
-
[direnv] (https://direnv.net/)
#ubuntu/debian
sudo apt install g++
#ubuntu/debian
sudo apt-get install make
Recomend for GNU SO. Install build-essential package and node-gyp.
#ubuntu/debian
sudo apt-get install build-essential
npm install -g node-gyp
Also recommend seting git pull to default rebase mode.
#ubuntu/debian
git config --global pull.rebase true
To deploy the contracts we use buidler.
Copy the .envrc.example and rename it to .envrc, change the mnemonic, then usedirenv allow
on this dirally rectory.
Finally run yarn deploy [networkName]
to deploy to the selected network
Debug in local ganache-cli with VS Code
#run ganache-cli in a terminal
ganache-cli --gasLimit 20000000 --gasPrice 20000 --defaultBalanceEther 1000000000 --allowUnlimitedContractSize true -v -k "istanbul"
Configure launch.json (VS Code).
In .buil/launch.json (create if is necesary) add the follow:
{
"version": "0.2.0",
"configurations": [
{
"name": "dev",
"request": "launch",
"type": "node",
"runtimeExecutable": "/usr/bin/npx",
"program": "saddle",
"args": [
"test",
],
},
]
}
All contracts are WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE