SIP-17: Bytes4 to Bytes32 currencyKeys

Author
Discussions-Tohttps://discord.gg/CDTvjHY
StatusImplemented
Created2019-08-29

Simple Summary

Upgrade type of currencyKeys from Bytes4 to Bytes32. The following Synthetix contracts will be upgraded to reflect bytes32 for currencyKeys and synth.currencyKey values.

  • ExchangeRates.sol
  • FeePool.sol
  • PurgeableSynth.sol
  • Synth.sol
  • Synthetix.sol

Abstract

Synthetix wants to create new synths with symbols longer than 4 chars. i.e sATOM, sDEFI This is currently not possible with currencyKeys type defined as Bytes4.

Motivation

The system was originally built with currencyKeys as Bytes4 to save storage space. However the system requirements have changed to require Symbols longer than 4 charactors for Synths like the DeFI index token sDEFI.

Specification

Change all instances of Bytes4 to Bytes32 in Synth.sol, Synthetix.sol, ExchangeRates.sol and FeePool.sol.

  • Upgrade all synth's proxy to ProxyERC20 contract.
  • SynthetixState.sol cannot be upgraded so the preferredCurrency and setPreferredCurrency function will remain as bytes4, but the use of preferredCurrency is deprecated in other contracts.
    // will automatically exchange to that preferred currency upon receipt in their wallet
    mapping(address => bytes4) public preferredCurrency;
     * @notice Set preferred currency for a user
     * @dev Only the associated contract may call this.
     * @param account The account to set the preferred currency for
     * @param currencyKey The new preferred currency
     */
    function setPreferredCurrency(address account, bytes4 currencyKey)
        external
        onlyAssociatedContract
    {
        preferredCurrency[account] = currencyKey;
    }

Test Cases

https://github.com/Synthetixio/synthetix/commit/908028f492187bb85dd519db4435d9c1964f8b4c

Implementation

https://github.com/Synthetixio/synthetix/commit/908028f492187bb85dd519db4435d9c1964f8b4c

Copyright and related rights waived via CC0.