Contains the scripts to deploy the Tinlake contracts to Ethereum mainnet or a testnet.
- Tinlake is built and developed with dapp.tools from DappHub. The deployments happen with bash scripts and the command-line tool
seth
. ! note: dapp.tools version has to be > 0.28.0. - On MacOS, install coreutils
brew install coreutils
(this package cotainsrealpath
, a dependency used in the scripts). - On Linux, install
jq
, e. g. withapt-get install jq
- Init/update git submodules:
git submodule update
For a deployment, a config file needs to be defined.
{
"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>>",
"MEMBER_ADMIN": "<<ADDRESS>>",
"LEVEL3_ADMIN1": "<<ADDRESS>>",
"LEVEL1_ADMIN1": "<<ADDRESS>>",
"LEVEL1_ADMIN2": "<<ADDRESS>>",
"LEVEL1_ADMIN3": "<<ADDRESS>>",
"LEVEL1_ADMIN4": "<<ADDRESS>>",
"LEVEL1_ADMIN5": "<<ADDRESS>>",
"AO_POOL_ADMIN": "<<ADDRESS>>",
"ORACLE": "<<ADDRESS>>"
}
It is possible to use the Principal NAV Feed or the Creditline NAV Feed
You can either set:
{
"NAV_IMPLEMENTATION": "principal"
}
Or:
{
"NAV_IMPLEMENTATION": "creditline"
}
{
"ETH_GAS": "<<NUMBER>>",
"ETH_GAS_PRICE": "<<NUMBER>>",
"ETH_PRIO_FEE": "<<NUMBER>>",
"ETH_KEYSTORE": "<<DIR PATH>>",
"ETH_PASSWORD": "<<FILE PATH>>",
"GOVERNANCE": "<<ADDRESS>>",
"JUNIOR_TOKEN_NAME": "<<STRING>>",
"JUNIOR_TOKEN_SYMBOL":"<<STRING>>",
"SENIOR_TOKEN_NAME": "<<STRING>>",
"SENIOR_TOKEN_SYMBOL": "<<STRING>>",
}
The config file can contain addresses for Fabs.
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
should follow ONE as 10^27 (ratePerSecond)
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
should follow ONE as 10^27 (ratePerSecond)
SENIOR_TRANCHE_SYMBOL
string not longer then 6 chars
SENIOR_TRANCHE_SYMBOL
string not longer then 6 chars
{
"IS_MKR": true,
"WIRE_CLERK": false,
"MKR_MGR_FAB": "<<ADDRESS>>",
"MKR_DAI": "<<ADDRESS>>",
"MKR_DAI_JOIN": "<<ADDRESS>>",
"MKR_VOW": "<<ADDRESS>>",
"MKR_SPOTTER": "<<ADDRESS>>",
"MKR_VAT": "<<ADDRESS>>",
"MKR_JUG": "<<ADDRESS>>",
"MKR_LIQ": "<<ADDRESS>>",
"MKR_END": "<<ADDRESS>>",
"MKR_MAT_BUFFER": "10000000000000000000000000"
}
make build
For deploying the contracts execute the following script.
make deploy
The default filepath of the configfile is: ./config_$(seth chain).json
seth chain
returns the name of the current chain based on the provided
If a deployment failed inbetween, you can resume the deployment. You can do this by running:
RESUME=1 make deploy
1. Set env variables (Optional)
Adjust .env-example.sh
, and run source env-example.sh
.
2. Build contracts
make build
3. Start your own local testnet. Run in a seperated terminal
dapp testnet
4. Generate Test Config File
make test-config
This should generate a default config file at ./bin/config_unknown.json
. Modify that file if needed.
5. Run deploy script
make deploy
Starts the deploy script with autogenerated default test-config file.
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
Create Main Deployer
dapp create MainDeployer
- add env var with your etherscan API key
export ETHERSCAN_API_KEY=<<YOUR KEY>>
- Make sure you have addresses file This should generate a file at
./addresses_$(seth chain).json
in your deployments folder. The file is autogenerated during the deployment process. - run verification script
make verify