Skip to content

StableTechnologies/TezFin

Repository files navigation

TezFin

This project is the implementation of Compound Protocol on Tezos chain using SmartPy language.

The diagram demonstrates relations between contracts

The platform consists of the following contracts

  • Governance - admin contract that has the ability to change parameters in Comptroller and ꜰTokens. The first version of Tezfin has a centralized Governance that works as an admin proxy
  • Comptroller - the risk management layer. It determines how much collateral a user is required to maintain, and whether (and by how much) a user can be liquidated. Each time a user interacts with a ꜰToken, the Comptroller is asked to approve or deny the transaction
    • Price oracle - third-party contract that provides price data. Used by Comptroller for liquidity calculation
  • ꜰToken - Tezfin market for the underlying token
    • Interest Rate Model - specifies rules of acquiring interest rate and borrow rate
    • Underlying token - the contract of the actual asset. Tezfin supports both FA1.2 and FA2 tokens

For the detailed description please refer to the wiki pages.

Project Structure

SmartPy CLI is required to interact with contracts. For installation please refer to https://smartpy.io/cli/

Code is organized in the following structure

Run Contract Unit Tests

To run tests use SmartPy CLI from the core project directory. Create a folder for test outputs. Example:

mkdir TezFinTest
cd TezFin
~/smartpy-cli/SmartPy.sh test contracts/tests/CTokenTest.py ../TezFinTest/ --html

After executing the previous command, an HTML report will be generated in "../TezFinTest/CToken_Tests/log.html"

The following script does the same as above, but for all test files at once.

cd TezFin
./contracts/tests/run_tests.sh ~/smartpy-cli/SmartPy.sh

Run Contract E2E Tests

To run e2e tests use the following command, you will need latest smartpy cli installed.

cd TezFin
./e2e/shell_scripts/deploy_all_contracts.sh ~/smartpy-cli/SmartPy.sh

Compile & Deploy Contracts

To compile and deploy all contracts at once:

  1. Configure parameters for contracts compilation in Config.json. Reffer to Compilation arguments
  2. Configure deployment parameters in config.json
  3. Install deployment dependencies
cd deploy/deploy_script
npm install
  1. Run deployment script
./deploy/shell_scripts/deploy_all_contracts.sh ~/smartpy-cli/SmartPy.sh

To deploy a specific contract run the corresponding script in shell_scripts

Build and Run UI

  1. Build Util
cd src/util
npm install
  1. Build UI
cd src/ui
npm install
  1. Run
cd src/ui
npm start