Skip to content

Commit

Permalink
Merge branch 'master' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
barrasso committed Aug 26, 2024
2 parents 987f18e + 7e483a0 commit cd66f93
Show file tree
Hide file tree
Showing 8 changed files with 317 additions and 30 deletions.
121 changes: 121 additions & 0 deletions contracts/migrations/Migration_AcrabOptimismPatch1.sol
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);
}
}
134 changes: 134 additions & 0 deletions contracts/migrations/Migration_AcrabPatch1.sol
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);
}
}
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "synthetix",
"version": "2.101.2",
"version": "2.101.3",
"license": "MIT",
"author": "Synthetix",
"description": "The smart contracts which make up the Synthetix system. (synthetix.io)",
Expand Down
24 changes: 12 additions & 12 deletions publish/deployed/mainnet-ovm/deployment.json

Large diffs are not rendered by default.

20 changes: 18 additions & 2 deletions publish/deployed/mainnet-ovm/versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -5921,8 +5921,9 @@
},
"Synthetix": {
"address": "0x5A41F634958dB9183e9d0d1Cd8Dee439B6ABb3BF",
"status": "current",
"keccak256": "0xc74c72f453dbf6b9fa32ba686c5f45b62f906b77beba50e2e5b21606a483e38d"
"status": "replaced",
"keccak256": "0xc74c72f453dbf6b9fa32ba686c5f45b62f906b77beba50e2e5b21606a483e38d",
"replaced_in": "v2.101.3"
}
}
},
Expand Down Expand Up @@ -5950,5 +5951,20 @@
"keccak256": "0xc9560e9672c3dff5c5bea2a78274b3e808bd6cdf338cc4091df5a59c58990f6e"
}
}
},
"v2.101.3": {
"tag": "v2.101.3",
"fulltag": "v2.101.3",
"release": "Acrab",
"network": "mainnet",
"date": "2024-08-26T10:37:17-04:00",
"commit": "b888832c963a9fbfe92d50ada2a2452d161fe5c6",
"contracts": {
"Synthetix": {
"address": "0x3f2A1F997Ef089798d19473D96be484Aeb3E4ECf",
"status": "current",
"keccak256": "0x9023d9e36b889055353a27eb9c00ac211202574ac8569730d9e3577f3f2c3727"
}
}
}
}
22 changes: 11 additions & 11 deletions publish/deployed/mainnet/deployment.json

Large diffs are not rendered by default.

20 changes: 18 additions & 2 deletions publish/deployed/mainnet/versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -4778,8 +4778,9 @@
"contracts": {
"Synthetix": {
"address": "0xd711709eFc452152B7ad11DbD01ed4B69c9421B3",
"status": "current",
"keccak256": "0xa4adacf15426be1f1af675a149af5c8d6deec9f8d3ee1dab54b105d3c25c55f3"
"status": "replaced",
"keccak256": "0xa4adacf15426be1f1af675a149af5c8d6deec9f8d3ee1dab54b105d3c25c55f3",
"replaced_in": "v2.101.3"
},
"RewardEscrowV2": {
"address": "0xFAd53Cc9480634563E8ec71E8e693Ffd07981d38",
Expand Down Expand Up @@ -4812,5 +4813,20 @@
"keccak256": "0xc9560e9672c3dff5c5bea2a78274b3e808bd6cdf338cc4091df5a59c58990f6e"
}
}
},
"v2.101.3": {
"tag": "v2.101.3",
"fulltag": "v2.101.3",
"release": "Acrab",
"network": "mainnet",
"date": "2024-08-26T10:37:17-04:00",
"commit": "b888832c963a9fbfe92d50ada2a2452d161fe5c6",
"contracts": {
"Synthetix": {
"address": "0xc5f0b4194455e0C175ab68C501400e46C7203504",
"status": "current",
"keccak256": "0xf5af266ffe444334cd8903b556e23be15b0644f532a083013f03af8d92d9dbfd"
}
}
}
}

0 comments on commit cd66f93

Please sign in to comment.