SIP 17: Bytes4 to Bytes32 currencyKeys Source

AuthorJackson Chan, Clinton Ennis

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


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.


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.


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.

``` // Users can specify their preferred currency, in which case all synths they receive // 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)
        preferredCurrency[account] = currencyKey;

Test Cases


Copyright and related rights waived via CC0.