[Proposal] Mento Upgrade MU04: Phase out V1, fully transition to V2 and update StableToken

Overview

Hello everyone!

For the last year, the Mento Labs Team has been working on rolling out Mento V2 (Multi-Collateral-Mento). The updated version of the Mento protocol was rolled out slowly in multiple steps and in parallel with Mento V1, which is still active. After extensive testing, it is time to deprecate V1 and fully move to Mento V2.

This post outlines the transactions that will be part of the deprecation of V1 as well as the transition to Mento V2. We also updated the StableToken implementation to a more modern ERC20 implementation with reduced gas costs.

As with previous proposals, the Celo community can verify them. In preparation for the upcoming CGP, we have done the following:

  • Tested the proposal on Baklava and Alfajores
  • Simulated the proposal on top of a fork of Celo Mainnet, in addition to running tests against the fork

The transactions in the upcoming CGP will be broken down into the following sections, noted here with transaction indices in brackets:

  1. Update StableToken implementations (0-7)
  2. Deprecate Mento V1 Exchange contracts (8-14)
  3. Configure Reserve (15-28)
  4. Configure trading limits (29-37)

Before we dive deep into each section and transaction, we recommend you have celocli set up to follow along. For the tech-savvy, you can find everything we are describing here in our deployment tooling repository as code. To verify the addresses in the proposal are correct, please refer to the Appendix at the bottom for some handy tips.

1. Update StableToken implementations

This includes the transactions to point the existing StableTokenProxies for cUSD, cEUR, cBRL, and eXOF to the newly updated StableToken implementation and setting new StableTokenV2-specific parameters.

TX#0 update the implementation for the cUSD Proxy _setImplementation()

  • Verify StableTokenProxy address
  • Verify the StableTokenV2 implementation address

TX#1 update the implementation for the cEUR Proxy _setImplementation()

  • Verify StableTokenEURProxy address
  • Verify the StableTokenV2 implementation address

TX#2 update the implementation for the cBRL Proxy _setImplementation()

  • Verify StableTokenBRLProxy address
  • Verify the StableTokenV2 implementation address

TX#3 update the implementation for the eXOF Proxy _setImplementation()

  • Verify StableTokenXOFProxy address
  • Verify the StableTokenV2 implementation address

TX#4 configure new StableTokenV2 parameters for cUSD initializeV2()

  • Verify StableTokenProxy address
  • Verify BrokerProxy address
  • Verify Validators address
  • Verify Exchange address is the zero address

TX#5 configure new StableTokenV2 parameters for cEUR initializeV2()

  • Verify StableTokenEURProxy address
  • Verify BrokerProxy address
  • Verify Validators address
  • Verify Exchange address is the zero address

TX#6 configure new StableTokenV2 parameters for cBRL initializeV2()

  • Verify StableTokenBRLProxy address
  • Verify BrokerProxy address
  • Verify Validators address
  • Verify Exchange address is the zero address

TX#7 configure new StableTokenV2 parameters for eXOF initializeV2()

  • Verify StableTokenXOFProxy address
  • Verify BrokerProxy address
  • Verify Validators address
  • Verify Exchange address is the zero address

2. Deprecate Mento V1 Exchange contracts

This includes freezing the Exchange, ExchangeEUR, ExchangeBRL, and GrandaMento contracts and updating their Celo registry entries.

TX#8 freeze Exchange contract freeze()

  • Verify FreezerProxy address
  • Verify ExchangeProxy address

TX#9 freeze ExchangeEUR contract freeze()

  • Verify FreezerProxy address
  • Verify ExchangeEURProxy address

TX#10 freeze ExchangeBRL contract freeze()

  • Verify FreezerProxy address
  • Verify ExchangeBRLProxy address

TX#11 update Exchange registry entry setAddressFor()

  • Verify Registry address
  • Verify string is “Exchange”
  • Verify address is zero address

TX#12 update ExchangeEUR registry entry setAddressFor()

  • Verify Registry address
  • Verify string is “ExchangeEUR”
  • Verify address is zero address

TX#13 update ExchangeBRL registry entry setAddressFor()

  • Verify Registry address
  • Verify string is “ExchangeBRL”
  • Verify address is zero address

TX#14 update GrandaMento registry entry setAddressFor()

  • Verify Registry address
  • Verify string is “GrandaMento”
  • Verify address is zero address

3. Configure Reserve

As part of the Mento V2 upgrade, the Mento team introduced an updated reserve implementation. This new implementation was used for the partial reserve introduced to initially limit the reserve funds that Mento V2 had control over. Meanwhile, the main reserve was still using the old reserve implementation. Since we are now fully transitioning to MentoV2, we are deprecating the partial reserve and updating the implementation of the main reserve.

Spending rights of old Exchange contracts will also be removed from the Reserve as part of the V1 deprecation.

TX#15 update reserve implementation in the ReserveProxy _setImplementation()

  • Verify ReserveProxy address
  • Verify the new Reserve implementation address

TX#16 remove ExchangeBRL from reserve exchange spender list removeExchangeSpender()

  • Verify ReserveProxy address
  • Verify ExchangeBRLProxy address
  • Verify index in the exchange spender list is 2

TX#17 remove GrandaMento from reserve exchange spender list removeExchangeSpender()

  • Verify ReserveProxy address
  • Verify GrandaMentoProxy address
  • Verify index in the exchange spender list is 1

TX#18 remove ExchangeEUR from reserve exchange spender list removeExchangeSpender()

  • Verify ReserveProxy address
  • Verify ExchangeEURProxy address
  • Verify index in the exchange spender list is 0

TX#19 add Broker to reserve exchange spender list addExchangeSpender()

  • Verify ReserveProxy address
  • Verify BrokerProxy address

TX#20 add CELO to the new reserve collateral asset list addCollateralAsset()

  • Verify ReserveProxy address
  • Verify the CELO token address

TX#21 add axlUSDC to the new reserve collateral asset list addCollateralAsset()

  • Verify ReserveProxy address
  • Verify the axlUSDC token address

TX#22 add axlEUROC to the new reserve collateral asset list addCollateralAsset()

  • Verify ReserveProxy address
  • Verify the axlEUROC token address

TX#23 configure daily spending ratio for collateral assets ****setDailySpendingRatioForCollateralAssets**()**

  • Verify ReserveProxy address
  • Verify collateral assets: [Celo, axlUSDC, axlEUROC]
  • Verify spending ratios: [2e23 = 20%, 100% = 1e24, 100% = 1e24]

TX#24 add eXOF to reserve token list addToken()

  • Verify ReserveProxy address
  • Verify StableTokenXOFProxy address

TX#25 Remove old ****reserve multi-sig from reserve spender list removeSpender()

  • Verify ReserveProxy address
  • Verify old reserve multi-sig address

TX#26 add new ****reserve multi-sig to reserve spender list addSpender() also used for the partial reserve (Proposal: MU01-Phase1 MultiCollateral Mento)

  • Verify ReserveProxy address
  • Verify new reserve multi-sig address

TX#27 update reserve in Broker to use main reserve setReserve()

  • Verify BrokerProxy address
  • Verify ReserveProxy address

TX#28 update reserve in BiPoolManager to use main reserve setReserve()

  • Verify BiPoolManagerProxy address
  • Verify ReserveProxy address

3. Configure trading limits

As part of fully transitioning to Mento V2, we are increasing the TradingLimits to support larger trading volumes.

In this section, the output of celocli can be too verbose when dealing with arguments and structs, so it’s recommended to ignore args and numbered fields and to focus instead on params and named fields.

The TradingLimit.Config structure is documented here: https://docs.mento.org/mento/developers/smart-contracts/tradinglimits

TX#29 - configure trading limits on cUSD for the cUSD/CELO exchange configureTradingLimit()

  • Verify BrokerProxy address
  • Verify the arguments:
    • exchangeId: the deterministic id of the cUSD/CELO exchange
    • token: which asset in the pair to target, in this case, the cUSD token address
    • config: the trading limit configuration

TX#30 - configure trading limits on cEUR for the cEUR/CELO exchange configureTradingLimit()

  • Verify BrokerProxy address
  • Verify the arguments:
    • exchangeId: the deterministic id of the cEUR/CELO exchange
    • token: which asset in the pair to target, in this case, the cEUR token address
    • config: the trading limit configuration

TX#31 - configure trading limits on cBRL for the cBRL/CELO exchange configureTradingLimit()

  • Verify BrokerProxy address
  • Verify the arguments:
    • exchangeId: the deterministic id of the cBRL/CELO exchange
    • token: which asset in the pair to target, in this case, the cBRL token address
    • config: the trading limit configuration

TX#32 - configure trading limits on cUSD for the cUSD/USDC exchange configureTradingLimit()

  • Verify BrokerProxy address
  • Verify the arguments:
    • exchangeId: the deterministic id of the cUSD/USDC exchange
    • token: which asset in the pair to target, in this case, the cUSD token address
    • config: the trading limit configuration

TX#33 - configure trading limits on cEUR for the cEUR/USDC exchange configureTradingLimit()

  • Verify BrokerProxy address
  • Verify the arguments:
    • exchangeId: the deterministic id of the cEUR/USDC exchange
    • token: which asset in the pair to target, in this case, the cEUR token address
    • config: the trading limit configuration

TX#34 - configure trading limits on cBRL for the cBRL/USDC exchange configureTradingLimit()

  • Verify BrokerProxy address
  • Verify the arguments:
    • exchangeId: the deterministic id of the cBRL/USDC exchange
    • token: which asset in the pair to target, in this case, the cBRL token address
    • config: the trading limit configuration

TX#35 - configure trading limits on cEUR for the cEUR/EUROC exchange configureTradingLimit()

  • Verify BrokerProxy address
  • Verify the arguments:
    • exchangeId: the deterministic id of the cEUR/EUROC exchange
    • token: which asset in the pair to target, in this case, the cEUR token address
    • config: the trading limit configuration

TX#36 - Configure trading limits on eXOF for the eXOF/EUROC exchange configureTradingLimit()

  • Verify BrokerProxy address
  • Verify the arguments:
    • exchangeId: the deterministic id of the eXOF/EUROC exchange
    • token: which asset in the pair to target, in this case, the eXOF token address
    • config: the trading limit configuration

TX#37 - Configure trading limits on EUROC for the eXOF/EUROC exchange configureTradingLimit()

  • Verify BrokerProxy address
  • Verify the arguments:
    • exchangeId: the deterministic id of the eXOF/EUROC exchange
    • token: which asset in the pair to target, in this case, the EUROC token address
    • config: the trading limit configuration

Appendix: Verifying an address

Verifying that an address in the CGP is correct requires a few different strategies depending on what that address is (see the mento docs for some additional information). Here are common situations:

  • Is it a rate feed identifier like: address(uint160(keccack256(”USDCEUR”)))
    • Use Keccak-256 Online 2 to compute the keccak
    • Take the last 40 characters (20 bytes) of the keccak and compare with the value
  • Is it a Mento contract?
  • Is it a Core Celo contract?
    • Yes:
      • It’s probably GoldToken which can be verified in the Celo Registry
    • No:
9 Likes

Hi everyone!

The MU04 proposal is out and can be seen by running celocli governance:show --proposalID 144 --node https://forno.celo.org

Please note that due to a bug in the current stable version of celocli, 3.1.2-beta.1 is required to be able to decode this proposal @celo/celocli - npm. The new beta version can be installed by running npm i @celo/celocli@3.1.2-beta.1

3 Likes

Congrats about the approved proposal :raised_hands: