Tinlake Deploy

Contains the scripts to deploy the Tinlake contracts to Ethereum mainnet or a testnet.

Requirements

  1. Tinlake is build and developed with dapp.tools from DappHub. The deployments happens with bash scripts and the command-line tool seth.
  2. On MacOS, install coreutils brew install coreutils (this package cotains realpath, a dependency used in the scripts).
  3. On Linux, install jq, e. g. with apt-get install jq
  4. Init/update git submodules: git submodule update

Deploy Config File

For a deployment config file needs to be defined.

Required Parameters

{
  "ETH_RPC_URL": "<<RPC URL>>",
  "ETH_FROM": "<<ADDRESS>>",
  "TINLAKE_CURRENCY": "<<ADDRESS>>",
  "MAIN_DEPLOYER": "<<ADDRESS>>",
  "SENIOR_INTEREST_RATE": "<<NUMBER>>",
  "MAX_RESERVE": "<<NUMBER>>",
  "MAX_SENIOR_RATIO": "<<NUMBER>>",
  "MIN_SENIOR_RATIO": "<<NUMBER>>",
  "CHALLENGE_TIME": "<<NUMBER>>",
  "DISCOUNT_RATE": "<<NUMBER>>",
}

TINLAKE_CURRENCY defines the stablecoin for the Tinlake. For example on mainnet this could be the DAI stablecoin or any other ERC20 contract. MAIN_DEPLOYER is a contract which deploys our factories with the create2 opcode. The other parameters are default config parameters from seth SENIOR_INTEREST_RATE MAX_RESERVE should follow ONE as 10^18 MAX_SENIOR_RATIO should follow ONE as 10^27 MIN_SENIOR_RATIO should follow ONE as 10^27 CHALLENGE_TIME should be in seconds DISCOUNT_RATE FEED_MAX_DAYS

NFT Feed

It is possible to use the NFT Feed or the NAV Feed

To use the NAV Feed, set FEED to nav

{
 "FEED": "nav"
}

Otherwise, the FEED will default to the NFT Feed

Optional Parameters

{
  "ETH_GAS": "<<NUMBER>>",
  "ETH_GAS_PRICE": "<<NUMBER>>",
  "ETH_KEYSTORE": "<<DIR PATH>>",
  "ETH_PASSWORD": "<<FILE PATH>>",
}

The config file can contain addresses for Fabs.

Deploy Contracts

Build Contracts

./bin/util/build_contracts.sh

Deploy Contracts

For deploying the contracts execute the following script.

./bin/deploy.sh <<Optional: Path to config file>>

The default filepath of the configfile is: ./config_$(seth chain).json seth chain returns the name of the current chain based on the provided

Local Test Deployment of Contracts

1. Set env variables

Adjust .env-example.sh, and run source env-example.sh.

2. Build contracts

./bin/util/build_contracts.sh

3. Start your own local testnet. Run in a seperated terminal

dapp testnet

4. Generate Test Config File

./bin/test/setup_local_config.sh

This should generate a file at ./bin/config_unknown.json. Modify that file if needed.

5. Run deploy script

./bin/deploy.sh

Docker-based Test Deployment of Contracts

1. Build the docker image

docker build -t centrifugeio/tinlake-deploy:latest .

2. Run a docker container

docker run --rm -p 8545:8545 centrifugeio/tinlake-deploy:latest

Util Scripts

Create Main Deployer

dapp create MainDeployer