New token deployment info (relevant to admin only) - percent-finance/percent-dev GitHub Wiki

This page is relevant to users who have access to admin account only (i.e. for multi-signer only).

Overview

To deploy a new pToken, we need to:

  1. Deploy a pToken contract.
  2. Config Chainlink oracle proxy.
  3. Add the pToken to the money market.
  4. Config collateral factor.
  5. Config reserve factor.
  6. (Optional) Enable PCT incentive for the market.
  7. (Optional) Config PCT distribution rate.

1. Deploy a pToken contract

Note: This can be done by any account without having to go through timelock.

  • The contract to deploy is called CErc20Delegator.
  • Compiler Version: v0.5.16+commit.9c3226ce
  • Optimization Enabled: Yes with 200 runs
  • Constructor
    • underlying_: The address of the underlying asset
    • comptroller_: The address of the Comptroller. Percent’s comptroller address is 0xf47dD16553A934064509C40DC5466BBfB999528B
    • interestRateModel_: The address of the interest rate model. Percent’s jump rate model address is 0x3F7C656C0C3F547Cb18D7a15318e98Ae44Ed8cbc
    • initialExchangeRateMantissa_: The initial exchange rate, scaled by 1e18. The rate can be calculated by this formula:
      • rate = 2 * 10^8 * 10^
      • E.g. If the decimals of underlying asset is 18, then the rate will be 2 * 10^8 * 10^18 = 2e26
    • name_: ERC-20 name of this token.
    • symbol_: ERC-20 symbol of this token.
    • decimals_: ERC-20 decimal precision of this token. It is always 8.
    • admin_: Address of the administrator of this token. Percent’s timelock address is 0x79FAee4B277d07CE23E2387EF67ef45acC62f156
    • implementation_: The address of the implementation the contract delegates to. Percent’s CErc20Delegate address is 0xfb770c8822761790A5f41867654911c2A6261300
    • becomeImplementationData: The encoded args for becomeImplementation. This value is unused, so it can simply be 0x0.
  • Constructor example (using pCOMP as example):
    • underlying_: 0xc00e94Cb662C3520282E6f5717214004A7f26888
    • comptroller_: 0xf47dD16553A934064509C40DC5466BBfB999528B
    • interestRateModel_: 0x3F7C656C0C3F547Cb18D7a15318e98Ae44Ed8cbc
    • initialExchangeRateMantissa_: 200000000000000000000000000
    • name_: Percent Compound
    • symbol_: pCOMP
    • decimals_: 8
    • admin_: 0x79FAee4B277d07CE23E2387EF67ef45acC62f156
    • implementation_: 0xfb770c8822761790A5f41867654911c2A6261300
    • becomeImplementationData: 0x0
    • Remix deployment example:

pToken-contract-deployment

2. Config Chainlink oracle proxy

  • What we need to do is to call setTokenConfigs in the ChainlinkPriceOracleProxy contract (through multi-sig and timelock)
  • setTokenConfigs params:
    • cTokenAddress: Address of the newly deployed pToken.
    • chainlinkAggregatorAddress: ChainLink Flux Aggregator contract address (can be found here: https://docs.chain.link/docs/reference-contracts)
    • chainlinkPriceBase: Price feed base unit. 0: invalid, 1: USD, 2: ETH
    • underlyingTokenDecimals: Decimals of the underlying token.
  • setTokenConfigs example (this function can config multiple pTokens at the same time, we are using pCOMP and pUNI as example):
    • cTokenAddress: ["0x3Fe0359A4DcbE9c943bbc22bAc0ec5565620E30c","0x3871751b7e472e3Fbb107316A77c3f43Ee1B8236"]
    • chainlinkAggregatorAddress: ["0x150631a2e822d3ed7D46df9A270ce7134a16De89","0x5977D45bA0A1fFC3740506D07F5693BBc45DF3c7"]
    • chainlinkPriceBase: [1,2]
    • underlyingTokenDecimals: [18,18]

3. Add the pToken to the money market

  • What we need to do is to call _supportMarket in Unitroller (Comptroller) contract (through multi-sig and timelock)
  • _supportMarket params:
    • cToken: Address of the newly deployed pToken
  • _supportMarket example (using pCOMP as example):
    • cToken: 0x3Fe0359A4DcbE9c943bbc22bAc0ec5565620E30c

4. Config collateral factor

  • What we need to do is to call _setCollateralFactor in Unitroller (Comptroller) contract (through multi-sig and timelock)
  • _setCollateralFactor params:
    • cToken: The market to set the factor on.
    • newCollateralFactorMantissa: The new collateral factor, scaled by 1e18.
  • _setCollateralFactor example (using pCOMP with 60% collateral factor as example):
    • cToken: 0x3Fe0359A4DcbE9c943bbc22bAc0ec5565620E30c
    • newCollateralFactorMantissa: 600000000000000000

5. Config reserve factor

  • What we need to do is to call _setReserveFactor in the pToken contract (through multi-sig and timelock)
  • _setReserveFactor params:
    • newReserveFactorMantissa: The new reserve factor, scaled by 1e18.
  • _setReserveFactor example (using pCOMP with 40% reserve factor as example):
    • newReserveFactorMantissa: 400000000000000000

6. (Optional) Enable PCT incentive for the market

Note: Call this only if we want to incentivize this market. Note: The market will be incentivized only if the compRate is positive.

  • What we need to do is to call _addCompMarkets in Unitroller (Comptroller) contract (through multi-sig and timelock)
  • _addCompMarkets params:
    • cTokens: The addresses of the markets to add
  • _addCompMarkets example (this function can add multiple pTokens at the same time, we are using pCOMP and pUNI as example):
    • cTokens: ["0x3Fe0359A4DcbE9c943bbc22bAc0ec5565620E30c","0x3871751b7e472e3Fbb107316A77c3f43Ee1B8236"]

7. (Optional) Config PCT distribution rate

Note: Please make sure the contract has enough PCT to distribute.

  • What we need to do is to call _setCompRate in Unitroller (Comptroller) contract (through multi-sig and timelock)
  • _setCompRate params:
    • compRate_: The amount of PCT wei per block to distribute.
  • _setCompRate example (this example assumes we want to distribute 1 PCT to supplier/borrower per block (i.e. Total distribution rate being 2 PCT per block)):
    • compRate_: 1000000000000000000