Deployment
Amplify protocol

Development Environment

    solidity ^0.5.16
    nodejs 12+

Installation

1
yarn
Copied!

Solc Installation

1
sudo -H pip3 install solc-select
2
solc-select install 0.5.16
3
solc-select use 0.5.16
Copied!

Compilation

1
npx saddle compile
Copied!

Deployment

The bellow instruction uses rinkeby ntework. When deploying to production, follow the same instruction but change to mainnet

Prepare Environment

    1.
    Ensure your deployment wallet has ETH to pay gas fee.
    2.
    Create ~/.ethereum/rinkeby file with Ethereum wallet private key as content.
    There will be several variables needed during deployment, we can set them via ENV vars instead of copying them all over, but you can also set them in each.
    3.
    Assign variables in your terminal (using bash):
      1.
      ETHSCAN_API_KEY={key} - API key from Etherescan.io
      2.
      ADMIN_ADDRESS={address} - administrator's address for cTokens and Timelock
      3.
      OPERATOR_ADDRESS={address} - operator address for GovernorAlpha
      4.
      AMPT_RECIPIENT={address} - initial AMPT token recipient address

Deploy AMPT token

AMPT

    1.
    Deploy
    1
    npx saddle deploy AMPT "$AMPT_RECIPIENT" -n rinkeby
    Copied!
    2.
    Assign variable using the address from the previous deployment command
    1
    AMPT={address}
    Copied!
    3.
    Verify on Etherscan.io
    1
    npx saddle verify "$ETHSCAN_API_KEY" "$AMPT" AMPT "$AMPT_RECIPIENT" -n rinkeby
    Copied!

Deploy Ampttroller

    1.
    Update getAmptAddress function Inside Ampttroller.sol insert
    1
    function getAmptAddress() public view returns (address) {
    2
    return /*{AMPT token contract address}*/;
    3
    }
    Copied!
    2.
    Recompile & deploy
    1
    npx saddle compile && npx saddle deploy Ampttroller -n rinkeby
    Copied!
    3.
    Assign variable using the address from the previous deployment command
    1
    AMPTTROLLER={address}
    Copied!
    4.
    Verify on Etherscan.io
    1
    npx saddle verify "$ETHSCAN_API_KEY" "$AMPTTROLLER" Ampttroller -n rinkeby
    Copied!

Transfer some AMPT to Ampttroller

Transfer AMPT which will be distributed as a reward to Ampttroller address.

Deploy FaucetToken tokens

WTBC

    1.
    Deploy
    1
    npx saddle deploy FaucetToken 100000000000000000000000000 "WBTC" 18 "WBTC" -n rinkeby
    Copied!
    2.
    Assign variable using the address from the previous deployment command
    1
    WBTC={address}
    Copied!
    3.
    Verify on Etherscan.io
    1
    npx saddle verify "$ETHSCAN_API_KEY" "$WBTC" FaucetToken 100000000000000000000000000 "WBTC" 18 "WBTC" -n rinkeby
    Copied!

USDT

    1.
    Deploy
    1
    npx saddle deploy FaucetToken 100000000000000000000000000 "USDT" 18 "USDT" -n rinkeby
    Copied!
    2.
    Assign variable using the address from the previous deployment command
    1
    USDT={address}
    Copied!
    3.
    Verify on Etherscan.io
    1
    npx saddle verify "$ETHSCAN_API_KEY" "$USDT" FaucetToken 100000000000000000000000000 "USDT" 18 "USDT" -n rinkeby
    Copied!

USDC

    1.
    Deploy
    1
    npx saddle deploy FaucetToken 100000000000000000000000000 "USDC" 18 "USDC" -n rinkeby
    Copied!
    2.
    Assign variable using the address from the previous deployment command
    1
    USDC={address}
    Copied!
    3.
    Verify on Etherscan.io
    1
    npx saddle verify "$ETHSCAN_API_KEY" "$USDC" FaucetToken 100000000000000000000000000 "USDC" 18 "USDC" -n rinkeby
    Copied!

DAI

    1.
    Deploy
    1
    npx saddle deploy FaucetToken 100000000000000000000000000 "DAI" 18 "DAI" -n rinkeby
    Copied!
    2.
    Assign variable using the address from the previous deployment command
    1
    DAI={address}
    Copied!
    3.
    Verify on Etherscan.io
    1
    npx saddle verify "$ETHSCAN_API_KEY" "$DAI" FaucetToken 100000000000000000000000000 "DAI" 18 "DAI" -n rinkeby
    Copied!

Deploy InterestRate

InterestRate contract is the implementation of interest rate calculation model. For example: the base interest rate is 5%, and the multipler interest rate is 12%.
    1.
    Deploy
    1
    npx saddle deploy WhitePaperInterestRateModel 50000000000000000 120000000000000000 -n rinkeby
    Copied!
    2.
    Assign variable using the address from the previous deployment command
    1
    INTEREST_RATE={address}
    Copied!
    3.
    Verify on Etherscan.io
    1
    npx saddle verify "$ETHSCAN_API_KEY" "$INTEREST_RATE" WhitePaperInterestRateModel 50000000000000000 120000000000000000 -n rinkeby
    Copied!

Deploy cTokens

Ctoken is the proof of deposit.

cETH

    1.
    Deploy
    1
    npx saddle deploy CEther "$AMPTTROLLER" "$INTEREST_RATE" "2000000000000000000" "AMPLIFY cETH" "cETH" "8" "$ADMIN_ADDRESS" -n rinkeby
    Copied!
    2.
    Add environment variable
    1
    CETH={address}
    Copied!

cWBTC

Deploy
1
npx saddle -n rinkeby script token:deploy '{
2
"underlying": "'"$WBTC"'",
3
"ampttroller": "'"$AMPTTROLLER"'",
4
"interestRateModel": "'"$INTEREST_RATE"'",
5
"initialExchangeRateMantissa": "2.0e18",
6
"name": "AMPLIFY WBTC",
7
"symbol": "cWBTC",
8
"decimals": "8",
9
"admin": "'"$ADMIN_ADDRESS"'"
10
}'
Copied!

cUSDT

Deploy
1
npx saddle -n rinkeby script token:deploy '{
2
"underlying": "'"$USDT"'",
3
"ampttroller": "'"$AMPTTROLLER"'",
4
"interestRateModel": "'"$INTEREST_RATE"'",
5
"initialExchangeRateMantissa": "2.0e18",
6
"name": "AMPLIFY USDT",
7
"symbol": "cUSDT",
8
"decimals": "8",
9
"admin": "'"$ADMIN_ADDRESS"'"
10
}'
Copied!

cUSDC

Deploy
1
npx saddle -n rinkeby script token:deploy '{
2
"underlying": "'"$USDC"'",
3
"ampttroller": "'"$AMPTTROLLER"'",
4
"interestRateModel": "'"$INTEREST_RATE"'",
5
"initialExchangeRateMantissa": "2.0e18",
6
"name": "AMPLIFY USDC",
7
"symbol": "cUSDC",
8
"decimals": "8",
9
"admin": "'"$ADMIN_ADDRESS"'"
10
}'
Copied!

cDAI

Deploy
1
npx saddle -n rinkeby script token:deploy '{
2
"underlying": "'"$DAI"'",
3
"ampttroller": "'"$AMPTTROLLER"'",
4
"interestRateModel": "'"$INTEREST_RATE"'",
5
"initialExchangeRateMantissa": "2.0e18",
6
"name": "AMPLIFY DAI",
7
"symbol": "cDAI",
8
"decimals": "8",
9
"admin": "'"$ADMIN_ADDRESS"'"
10
}'
Copied!

cAMPT

Deploy
1
npx saddle -n rinkeby script token:deploy '{
2
"underlying": "'"$AMPT"'",
3
"ampttroller": "'"$AMPTTROLLER"'",
4
"interestRateModel": "'"$INTEREST_RATE"'",
5
"initialExchangeRateMantissa": "2.0e18",
6
"name": "AMPLIFY AMPT",
7
"symbol": "cAMPT",
8
"decimals": "8",
9
"admin": "'"$ADMIN_ADDRESS"'"
10
}'
Copied!

Deploy PriceOracle

We use the Oracle anchored by uniswap in mainnet, first obtain the token price from Coinbase or other exchanges, submit it to the smart contract, and use the price of uniswap as the verification. See in the project: amplify-open-oracle

Deploy SimplePriceOracle

Simpleprice Oracle can be released for testing. It can be launched in the early stage in order to avoid Oracle attack.
    1.
    Deploy
    1
    npx saddle deploy SimplePriceOracle -n rinkeby
    Copied!
    2.
    Add environmemnt variable
    1
    SIMPLE_PRICE_ORACLE={address}
    Copied!
    3.
    Verify on Etherscan.io
    1
    npx saddle verify "$ETHSCAN_API_KEY" "$SIMPLE_PRICE_ORACLE" SimplePriceOracle -n rinkeby
    Copied!

Set price for each cToken

If using SimplePriceOracle, each cToken listed must has it's corresponding token price set via SimplePriceOracle contract.
Call setUnderlyingPrice method using Etherscan.io for each cToken:
Parameter
Type
Comments
Example
cToken
address
cToken contract address
0xd3569eC8AF83Bed92b369b83B90Ff17e27d1cdC2
underlyingPriceMantissa
uint
Price for cToken corresponding token, in USD, the value need to be multiplied with 1e18, for example, 1 USD should be 1000000000000000000
1000000000000000000

Configure Oracle address and markets.

These are Ampttroller contract methods.
    1.
    _setPriceOracle - set Price Oracle address
    2.
    _setMaxAssets - set maxAssets with value 20
    3.
    _supportMarket - set supported markets to add cTokens to the token list.
    Call this method for each cToken.
    4.
    _addAmptMarkets - add markets (cTokens) that reward with Ampt to the token list.
    5.
    _setCollateralFactor - set collateral factor for each market (cToken). Call this method for each cToken.
    6.
    _setAmptRate - set the amount of distributed AMPT Tokens for one block the value needs to be multiplied with 1e18
    7.
    refreshAmptSpeeds - trigger the update for tokens speeds

Deploy AmplifyLens

AmplifyLens is used for data calculation and query
    1.
    Deploy
    1
    npx saddle deploy AmplifyLens -n rinkeby
    Copied!
    2.
    Set variable
    1
    AMPLIFY_LENS={address}
    Copied!
    3.
    Verify on Etherscan.io
    1
    npx saddle verify "$ETHSCAN_API_KEY" "$AMPLIFY_LENS" AmplifyLens -n rinkeby
    Copied!

Deploy Maximillion

    1.
    Deploy
    1
    npx saddle deploy Maximillion "$CETH" -n rinkeby
    Copied!
    2.
    Add variable
    1
    MAXMILLION={address}
    Copied!
    3.
    Verify on Etherscan.io
    1
    npx saddle verify "$ETHSCAN_API_KEY" "$MAXMILLION" Maximillion "$CETH" -n rinkeby
    Copied!

Deploy Timelock Contract

Timelock is the contract for decentralized governance
    1.
    Deploy
    1
    npx saddle deploy Timelock "$ADMIN_ADDRESS" 600 -n rinkeby
    Copied!
    2.
    Set variable
    1
    TIMELOCK={address}
    Copied!
    3.
    Verify on Etherscan.io
    1
    npx saddle verify "$ETHSCAN_API_KEY" "$TIMELOCK" Timelock "$ADMIN_ADDRESS" 600 -n rinkeby
    Copied!

Deploy GvernorAlpha Contract

GvernorAlpha is the contract of vote.
    1.
    Deploy
    1
    npx saddle deploy GovernorAlpha "$TIMELOCK" "$AMPT" "$OPERATOR_ADDRESS" -n rinkeby
    Copied!
    2.
    Set variable
    1
    GOVERNOR_ALPHA={address}
    Copied!
    3.
    Verify on Etherscan.io
    1
    npx saddle verify "$ETHSCAN_API_KEY" "$GOVERNOR_ALPHA" GovernorAlpha "$TIMELOCK" "$AMPT" "$OPERATOR_ADDRESS" -n rinkeby
    Copied!

Set Timelock as the administrator of each governed contract

    This step is to set TimeLock contract as administrator for all contracts deployed
    At the early stage, setting admin when deploying contracts with a privately > owned account, will be easier for debugging and adjusting
    Change admin to TimeLock at the mature stage to make everything more decentralized
    1.
    _setPendingAdmin - as an administrator, call this method in each governed contract to set the timelock contract as pendingAdmin.
    2.
    By calling queueTransaction and executeTransaction methods of timelock, let timelock contract invoke _acceptAdmin method of governed contracts so that a new administrator of governed contracts can be set.

Set GovernorAlpha as the administrator of Timelock

Same as above step, use private address as admin at early stage.
    1.
    Use queueTransaction and executetransaction methods of the Timelock contract to invoke TimeLock contract's setPendingAdmin method.
    2.
    Invoke _acceptAdmin method of GovernorAlpha contract so that it will be an admin for TimeLock contract.
Last modified 4mo ago