-
Notifications
You must be signed in to change notification settings - Fork 601
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
317 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
pragma solidity ^0.5.16; | ||
|
||
import "../BaseMigration.sol"; | ||
import "../AddressResolver.sol"; | ||
import "../ProxyERC20.sol"; | ||
import "../TokenState.sol"; | ||
import "../RewardsDistribution.sol"; | ||
|
||
interface ISynthetixNamedContract { | ||
// solhint-disable func-name-mixedcase | ||
function CONTRACT_NAME() external view returns (bytes32); | ||
} | ||
|
||
// solhint-disable contract-name-camelcase | ||
contract Migration_AcrabOptimismPatch1 is BaseMigration { | ||
// https://explorer.optimism.io/address/0x6d4a64C57612841c2C6745dB2a4E4db34F002D20; | ||
address public constant OWNER = 0x6d4a64C57612841c2C6745dB2a4E4db34F002D20; | ||
|
||
// ---------------------------- | ||
// EXISTING SYNTHETIX CONTRACTS | ||
// ---------------------------- | ||
|
||
// https://explorer.optimism.io/address/0x95A6a3f44a70172E7d50a9e28c85Dfd712756B8C | ||
AddressResolver public constant addressresolver_i = AddressResolver(0x95A6a3f44a70172E7d50a9e28c85Dfd712756B8C); | ||
// https://explorer.optimism.io/address/0x8700dAec35aF8Ff88c16BdF0418774CB3D7599B4 | ||
ProxyERC20 public constant proxysynthetix_i = ProxyERC20(0x8700dAec35aF8Ff88c16BdF0418774CB3D7599B4); | ||
// https://explorer.optimism.io/address/0xB9c6CA25452E7f6D0D3340CE1e9B573421afc2eE | ||
TokenState public constant tokenstatesynthetix_i = TokenState(0xB9c6CA25452E7f6D0D3340CE1e9B573421afc2eE); | ||
// https://explorer.optimism.io/address/0x5d9187630E99dBce4BcAB8733B76757f7F44aA2e | ||
RewardsDistribution public constant rewardsdistribution_i = | ||
RewardsDistribution(0x5d9187630E99dBce4BcAB8733B76757f7F44aA2e); | ||
|
||
// ---------------------------------- | ||
// NEW CONTRACTS DEPLOYED TO BE ADDED | ||
// ---------------------------------- | ||
|
||
// https://explorer.optimism.io/address/0x3f2A1F997Ef089798d19473D96be484Aeb3E4ECf | ||
address public constant new_Synthetix_contract = 0x3f2A1F997Ef089798d19473D96be484Aeb3E4ECf; | ||
|
||
constructor() public BaseMigration(OWNER) {} | ||
|
||
function contractsRequiringOwnership() public pure returns (address[] memory contracts) { | ||
contracts = new address[](4); | ||
contracts[0] = address(addressresolver_i); | ||
contracts[1] = address(proxysynthetix_i); | ||
contracts[2] = address(tokenstatesynthetix_i); | ||
contracts[3] = address(rewardsdistribution_i); | ||
} | ||
|
||
function migrate() external onlyOwner { | ||
// ACCEPT OWNERSHIP for all contracts that require ownership to make changes | ||
acceptAll(); | ||
|
||
// MIGRATION | ||
// Import all new contracts into the address resolver; | ||
addressresolver_importAddresses_0(); | ||
// Import all new contracts into the address resolver; | ||
addressresolver_importAddresses_1(); | ||
// Rebuild the resolver caches in all MixinResolver contracts - batch 1; | ||
addressresolver_rebuildCaches_2(); | ||
// Ensure the SNX proxy has the correct Synthetix target set; | ||
proxysynthetix_i.setTarget(Proxyable(new_Synthetix_contract)); | ||
// Ensure the Synthetix contract can write to its TokenState contract; | ||
tokenstatesynthetix_i.setAssociatedContract(new_Synthetix_contract); | ||
// Ensure the RewardsDistribution has Synthetix set as its authority for distribution; | ||
rewardsdistribution_i.setAuthority(new_Synthetix_contract); | ||
|
||
// NOMINATE OWNERSHIP back to owner for aforementioned contracts | ||
nominateAll(); | ||
} | ||
|
||
function acceptAll() internal { | ||
address[] memory contracts = contractsRequiringOwnership(); | ||
for (uint i = 0; i < contracts.length; i++) { | ||
Owned(contracts[i]).acceptOwnership(); | ||
} | ||
} | ||
|
||
function nominateAll() internal { | ||
address[] memory contracts = contractsRequiringOwnership(); | ||
for (uint i = 0; i < contracts.length; i++) { | ||
returnOwnership(contracts[i]); | ||
} | ||
} | ||
|
||
function addressresolver_importAddresses_0() internal { | ||
bytes32[] memory addressresolver_importAddresses_names_0_0 = new bytes32[](1); | ||
addressresolver_importAddresses_names_0_0[0] = bytes32("Synthetix"); | ||
address[] memory addressresolver_importAddresses_destinations_0_1 = new address[](1); | ||
addressresolver_importAddresses_destinations_0_1[0] = address(new_Synthetix_contract); | ||
addressresolver_i.importAddresses( | ||
addressresolver_importAddresses_names_0_0, | ||
addressresolver_importAddresses_destinations_0_1 | ||
); | ||
} | ||
|
||
function addressresolver_importAddresses_1() internal { | ||
bytes32[] memory addressresolver_importAddresses_names_1_0 = new bytes32[](1); | ||
addressresolver_importAddresses_names_1_0[0] = bytes32("Synthetix"); | ||
address[] memory addressresolver_importAddresses_destinations_1_1 = new address[](1); | ||
addressresolver_importAddresses_destinations_1_1[0] = address(new_Synthetix_contract); | ||
addressresolver_i.importAddresses( | ||
addressresolver_importAddresses_names_1_0, | ||
addressresolver_importAddresses_destinations_1_1 | ||
); | ||
} | ||
|
||
function addressresolver_rebuildCaches_2() internal { | ||
MixinResolver[] memory addressresolver_rebuildCaches_destinations_2_0 = new MixinResolver[](9); | ||
addressresolver_rebuildCaches_destinations_2_0[0] = MixinResolver(0x5Fc9B8d2B7766f061bD84a41255fD1A76Fd1FAa2); | ||
addressresolver_rebuildCaches_destinations_2_0[1] = MixinResolver(0xB589Af3f2e3377A9a57da74bE1b6598926479505); | ||
addressresolver_rebuildCaches_destinations_2_0[2] = MixinResolver(0xF4EebDD0704021eF2a6Bbe993fdf93030Cd784b4); | ||
addressresolver_rebuildCaches_destinations_2_0[3] = MixinResolver(0x24b4b6703a2eE7bA75a4Fc859B606F0bbaeef4EA); | ||
addressresolver_rebuildCaches_destinations_2_0[4] = MixinResolver(0xb4E0FA941376e101C29A9FA5A9C6a95489aA34cD); | ||
addressresolver_rebuildCaches_destinations_2_0[5] = MixinResolver(0x2DcAD1A019fba8301b77810Ae14007cc88ED004B); | ||
addressresolver_rebuildCaches_destinations_2_0[6] = MixinResolver(0x136b1EC699c62b0606854056f02dC7Bb80482d63); | ||
addressresolver_rebuildCaches_destinations_2_0[7] = MixinResolver(0xA6bc30d854c2647574921c4AF442008DB7d32ad5); | ||
addressresolver_rebuildCaches_destinations_2_0[8] = MixinResolver(new_Synthetix_contract); | ||
addressresolver_i.rebuildCaches(addressresolver_rebuildCaches_destinations_2_0); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
pragma solidity ^0.5.16; | ||
|
||
import "../BaseMigration.sol"; | ||
import "../AddressResolver.sol"; | ||
import "../Proxy.sol"; | ||
import "../legacy/LegacyTokenState.sol"; | ||
import "../RewardEscrow.sol"; | ||
import "../RewardsDistribution.sol"; | ||
|
||
interface ISynthetixNamedContract { | ||
// solhint-disable func-name-mixedcase | ||
function CONTRACT_NAME() external view returns (bytes32); | ||
} | ||
|
||
// solhint-disable contract-name-camelcase | ||
contract Migration_AcrabPatch1 is BaseMigration { | ||
// https://etherscan.io/address/0xEb3107117FEAd7de89Cd14D463D340A2E6917769; | ||
address public constant OWNER = 0xEb3107117FEAd7de89Cd14D463D340A2E6917769; | ||
|
||
// ---------------------------- | ||
// EXISTING SYNTHETIX CONTRACTS | ||
// ---------------------------- | ||
|
||
// https://etherscan.io/address/0x823bE81bbF96BEc0e25CA13170F5AaCb5B79ba83 | ||
AddressResolver public constant addressresolver_i = AddressResolver(0x823bE81bbF96BEc0e25CA13170F5AaCb5B79ba83); | ||
// https://etherscan.io/address/0xC011a73ee8576Fb46F5E1c5751cA3B9Fe0af2a6F | ||
Proxy public constant proxysynthetix_i = Proxy(0xC011a73ee8576Fb46F5E1c5751cA3B9Fe0af2a6F); | ||
// https://etherscan.io/address/0x5b1b5fEa1b99D83aD479dF0C222F0492385381dD | ||
LegacyTokenState public constant tokenstatesynthetix_i = LegacyTokenState(0x5b1b5fEa1b99D83aD479dF0C222F0492385381dD); | ||
// https://etherscan.io/address/0xb671F2210B1F6621A2607EA63E6B2DC3e2464d1F | ||
RewardEscrow public constant rewardescrow_i = RewardEscrow(0xb671F2210B1F6621A2607EA63E6B2DC3e2464d1F); | ||
// https://etherscan.io/address/0x94433f0DA8B5bfb473Ea8cd7ad10D9c8aef4aB7b | ||
RewardsDistribution public constant rewardsdistribution_i = | ||
RewardsDistribution(0x94433f0DA8B5bfb473Ea8cd7ad10D9c8aef4aB7b); | ||
|
||
// ---------------------------------- | ||
// NEW CONTRACTS DEPLOYED TO BE ADDED | ||
// ---------------------------------- | ||
|
||
// https://etherscan.io/address/0xc5f0b4194455e0C175ab68C501400e46C7203504 | ||
address public constant new_Synthetix_contract = 0xc5f0b4194455e0C175ab68C501400e46C7203504; | ||
|
||
constructor() public BaseMigration(OWNER) {} | ||
|
||
function contractsRequiringOwnership() public pure returns (address[] memory contracts) { | ||
contracts = new address[](5); | ||
contracts[0] = address(addressresolver_i); | ||
contracts[1] = address(proxysynthetix_i); | ||
contracts[2] = address(tokenstatesynthetix_i); | ||
contracts[3] = address(rewardescrow_i); | ||
contracts[4] = address(rewardsdistribution_i); | ||
} | ||
|
||
function migrate() external onlyOwner { | ||
// ACCEPT OWNERSHIP for all contracts that require ownership to make changes | ||
acceptAll(); | ||
|
||
// MIGRATION | ||
// Import all new contracts into the address resolver; | ||
addressresolver_importAddresses_0(); | ||
// Rebuild the resolver caches in all MixinResolver contracts - batch 1; | ||
addressresolver_rebuildCaches_1(); | ||
// Rebuild the resolver caches in all MixinResolver contracts - batch 2; | ||
addressresolver_rebuildCaches_2(); | ||
// Ensure the SNX proxy has the correct Synthetix target set; | ||
proxysynthetix_i.setTarget(Proxyable(new_Synthetix_contract)); | ||
// Ensure the Synthetix contract can write to its TokenState contract; | ||
tokenstatesynthetix_i.setAssociatedContract(new_Synthetix_contract); | ||
// Ensure the legacy RewardEscrow contract is connected to the Synthetix contract; | ||
rewardescrow_i.setSynthetix(ISynthetix(new_Synthetix_contract)); | ||
// Ensure the RewardsDistribution has Synthetix set as its authority for distribution; | ||
rewardsdistribution_i.setAuthority(new_Synthetix_contract); | ||
|
||
// NOMINATE OWNERSHIP back to owner for aforementioned contracts | ||
nominateAll(); | ||
} | ||
|
||
function acceptAll() internal { | ||
address[] memory contracts = contractsRequiringOwnership(); | ||
for (uint i = 0; i < contracts.length; i++) { | ||
Owned(contracts[i]).acceptOwnership(); | ||
} | ||
} | ||
|
||
function nominateAll() internal { | ||
address[] memory contracts = contractsRequiringOwnership(); | ||
for (uint i = 0; i < contracts.length; i++) { | ||
returnOwnership(contracts[i]); | ||
} | ||
} | ||
|
||
function addressresolver_importAddresses_0() internal { | ||
bytes32[] memory addressresolver_importAddresses_names_0_0 = new bytes32[](1); | ||
addressresolver_importAddresses_names_0_0[0] = bytes32("Synthetix"); | ||
address[] memory addressresolver_importAddresses_destinations_0_1 = new address[](1); | ||
addressresolver_importAddresses_destinations_0_1[0] = address(new_Synthetix_contract); | ||
addressresolver_i.importAddresses( | ||
addressresolver_importAddresses_names_0_0, | ||
addressresolver_importAddresses_destinations_0_1 | ||
); | ||
} | ||
|
||
function addressresolver_rebuildCaches_1() internal { | ||
MixinResolver[] memory addressresolver_rebuildCaches_destinations_1_0 = new MixinResolver[](20); | ||
addressresolver_rebuildCaches_destinations_1_0[0] = MixinResolver(0xFAd53Cc9480634563E8ec71E8e693Ffd07981d38); | ||
addressresolver_rebuildCaches_destinations_1_0[1] = MixinResolver(0x8e9757479D5ad4E7f9d951B60d39F5220b893d6c); | ||
addressresolver_rebuildCaches_destinations_1_0[2] = MixinResolver(0xf79603a71144e415730C1A6f57F366E4Ea962C00); | ||
addressresolver_rebuildCaches_destinations_1_0[3] = MixinResolver(0xaeA0065E146FD75Dc24465961a583827284D405a); | ||
addressresolver_rebuildCaches_destinations_1_0[4] = MixinResolver(0xab4688E54A216aB3813438D30603Bf855648AF8d); | ||
addressresolver_rebuildCaches_destinations_1_0[5] = MixinResolver(0x62922670313bf6b41C580143d1f6C173C5C20019); | ||
addressresolver_rebuildCaches_destinations_1_0[6] = MixinResolver(0x39Ea01a0298C315d149a490E34B59Dbf2EC7e48F); | ||
addressresolver_rebuildCaches_destinations_1_0[7] = MixinResolver(0x94f864e55c77E07C2C7BF7bFBc334b7a8123442A); | ||
addressresolver_rebuildCaches_destinations_1_0[8] = MixinResolver(new_Synthetix_contract); | ||
addressresolver_rebuildCaches_destinations_1_0[9] = MixinResolver(0x83105D7CDd2fd9b8185BFF1cb56bB1595a618618); | ||
addressresolver_rebuildCaches_destinations_1_0[10] = MixinResolver(0xd1cad1A569E70d2Df4C8ed43d3cC93DBE16285dE); | ||
addressresolver_rebuildCaches_destinations_1_0[11] = MixinResolver(0x10A5F7D9D65bCc2734763444D4940a31b109275f); | ||
addressresolver_rebuildCaches_destinations_1_0[12] = MixinResolver(0xa8E31E3C38aDD6052A9407298FAEB8fD393A6cF9); | ||
addressresolver_rebuildCaches_destinations_1_0[13] = MixinResolver(0xE1cc2332852B2Ac0dA59A1f9D3051829f4eF3c1C); | ||
addressresolver_rebuildCaches_destinations_1_0[14] = MixinResolver(0xfb020CA7f4e8C4a5bBBe060f59a249c6275d2b69); | ||
addressresolver_rebuildCaches_destinations_1_0[15] = MixinResolver(0xdc883b9d9Ee16f74bE08826E68dF4C9D9d26e8bD); | ||
addressresolver_rebuildCaches_destinations_1_0[16] = MixinResolver(0xBb5b03E920cF702De5A3bA9Fc1445aF4B3919c88); | ||
addressresolver_rebuildCaches_destinations_1_0[17] = MixinResolver(0xdAe6C79c46aB3B280Ca28259000695529cbD1339); | ||
addressresolver_rebuildCaches_destinations_1_0[18] = MixinResolver(0x1cB004a8e84a5CE95C1fF895EE603BaC8EC506c7); | ||
addressresolver_rebuildCaches_destinations_1_0[19] = MixinResolver(0x5D4C724BFe3a228Ff0E29125Ac1571FE093700a4); | ||
addressresolver_i.rebuildCaches(addressresolver_rebuildCaches_destinations_1_0); | ||
} | ||
|
||
function addressresolver_rebuildCaches_2() internal { | ||
MixinResolver[] memory addressresolver_rebuildCaches_destinations_2_0 = new MixinResolver[](2); | ||
addressresolver_rebuildCaches_destinations_2_0[0] = MixinResolver(0x07C1E81C345A7c58d7c24072EFc5D929BD0647AD); | ||
addressresolver_rebuildCaches_destinations_2_0[1] = MixinResolver(0x7A3d898b717e50a96fd8b232E9d15F0A547A7eeb); | ||
addressresolver_i.rebuildCaches(addressresolver_rebuildCaches_destinations_2_0); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters