Skip to content

Commit dde1112

Browse files
authored
Mainnet deployment v5 (#259)
* mainnet deployment * bill broker update * ran yarn install * notes
1 parent a5f82e6 commit dde1112

File tree

11 files changed

+1603
-20
lines changed

11 files changed

+1603
-20
lines changed

spot-contracts/.openzeppelin/mainnet.json

Lines changed: 916 additions & 0 deletions
Large diffs are not rendered by default.

spot-contracts/.openzeppelin/sepolia.json

Lines changed: 228 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,21 @@
4444
"address": "0xd90FcB328D90B778D1f6719d781045bbbac8F251",
4545
"txHash": "0x8b29769272d41c1032345366209cdcddb8abda7b8c66bfba001162c14671855e",
4646
"kind": "transparent"
47+
},
48+
{
49+
"address": "0x7f75A61c4475d32a50829710AA8d8aCDEbD2c0d4",
50+
"txHash": "0x366889a82d52a5e9496b0c2f7d8becee5ab4d4611c0ddbe11b99124f983be136",
51+
"kind": "transparent"
52+
},
53+
{
54+
"address": "0xc6b4b85FB97695052CA2e6C6401C20a7Ba30605D",
55+
"txHash": "0xb64e64b39d3296e9d6dc0d2098ddb6a97f8582dbfad0543d8ed364f6d8107abb",
56+
"kind": "transparent"
57+
},
58+
{
59+
"address": "0x6D6cBba605F4AF825F4997F1db74AF54e4F01c04",
60+
"txHash": "0x6d23bda7a369524a4918846231c2c6646c092f39c23c823bcde50ee9e1a3d66b",
61+
"kind": "transparent"
4762
}
4863
],
4964
"impls": {
@@ -2715,6 +2730,219 @@
27152730
},
27162731
"namespaces": {}
27172732
}
2733+
},
2734+
"907dd399d33e68e0a7c77c54e1886a30e59ec356c35a0f9c27e96d39644c64d6": {
2735+
"address": "0x058C0F40427A5bBb7eF7169FfF0A12d265317B15",
2736+
"txHash": "0x8909e28358b1ff3b70564f6e6e8d6708e21b718cb04056638b9ef9f3ec5dda78",
2737+
"layout": {
2738+
"solcVersion": "0.8.20",
2739+
"storage": [
2740+
{
2741+
"label": "_initialized",
2742+
"offset": 0,
2743+
"slot": "0",
2744+
"type": "t_uint8",
2745+
"contract": "Initializable",
2746+
"src": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:62",
2747+
"retypedFrom": "bool"
2748+
},
2749+
{
2750+
"label": "_initializing",
2751+
"offset": 1,
2752+
"slot": "0",
2753+
"type": "t_bool",
2754+
"contract": "Initializable",
2755+
"src": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:67"
2756+
},
2757+
{
2758+
"label": "__gap",
2759+
"offset": 0,
2760+
"slot": "1",
2761+
"type": "t_array(t_uint256)50_storage",
2762+
"contract": "ContextUpgradeable",
2763+
"src": "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol:36"
2764+
},
2765+
{
2766+
"label": "_owner",
2767+
"offset": 0,
2768+
"slot": "51",
2769+
"type": "t_address",
2770+
"contract": "OwnableUpgradeable",
2771+
"src": "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol:22"
2772+
},
2773+
{
2774+
"label": "__gap",
2775+
"offset": 0,
2776+
"slot": "52",
2777+
"type": "t_array(t_uint256)49_storage",
2778+
"contract": "OwnableUpgradeable",
2779+
"src": "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol:94"
2780+
},
2781+
{
2782+
"label": "targetSystemRatio",
2783+
"offset": 0,
2784+
"slot": "101",
2785+
"type": "t_uint256",
2786+
"contract": "FeePolicy",
2787+
"src": "contracts/FeePolicy.sol:69"
2788+
},
2789+
{
2790+
"label": "equilibriumDR",
2791+
"offset": 0,
2792+
"slot": "102",
2793+
"type": "t_struct(Range)11656_storage",
2794+
"contract": "FeePolicy",
2795+
"src": "contracts/FeePolicy.sol:74"
2796+
},
2797+
{
2798+
"label": "feeFnDRDown",
2799+
"offset": 0,
2800+
"slot": "104",
2801+
"type": "t_struct(Line)11666_storage",
2802+
"contract": "FeePolicy",
2803+
"src": "contracts/FeePolicy.sol:80"
2804+
},
2805+
{
2806+
"label": "feeFnDRUp",
2807+
"offset": 0,
2808+
"slot": "108",
2809+
"type": "t_struct(Line)11666_storage",
2810+
"contract": "FeePolicy",
2811+
"src": "contracts/FeePolicy.sol:83"
2812+
},
2813+
{
2814+
"label": "perpDebasementLag",
2815+
"offset": 0,
2816+
"slot": "112",
2817+
"type": "t_uint256",
2818+
"contract": "FeePolicy",
2819+
"src": "contracts/FeePolicy.sol:89"
2820+
},
2821+
{
2822+
"label": "perpEnrichmentLag",
2823+
"offset": 0,
2824+
"slot": "113",
2825+
"type": "t_uint256",
2826+
"contract": "FeePolicy",
2827+
"src": "contracts/FeePolicy.sol:92"
2828+
},
2829+
{
2830+
"label": "perpDebasementPercLimits",
2831+
"offset": 0,
2832+
"slot": "114",
2833+
"type": "t_struct(Range)11656_storage",
2834+
"contract": "FeePolicy",
2835+
"src": "contracts/FeePolicy.sol:95"
2836+
},
2837+
{
2838+
"label": "perpEnrichmentPercLimits",
2839+
"offset": 0,
2840+
"slot": "116",
2841+
"type": "t_struct(Range)11656_storage",
2842+
"contract": "FeePolicy",
2843+
"src": "contracts/FeePolicy.sol:98"
2844+
},
2845+
{
2846+
"label": "rebalanceFreqSec",
2847+
"offset": 0,
2848+
"slot": "118",
2849+
"type": "t_uint256",
2850+
"contract": "FeePolicy",
2851+
"src": "contracts/FeePolicy.sol:101"
2852+
},
2853+
{
2854+
"label": "protocolSharePerc",
2855+
"offset": 0,
2856+
"slot": "119",
2857+
"type": "t_uint256",
2858+
"contract": "FeePolicy",
2859+
"src": "contracts/FeePolicy.sol:104"
2860+
},
2861+
{
2862+
"label": "protocolFeeCollector",
2863+
"offset": 0,
2864+
"slot": "120",
2865+
"type": "t_address",
2866+
"contract": "FeePolicy",
2867+
"src": "contracts/FeePolicy.sol:107"
2868+
}
2869+
],
2870+
"types": {
2871+
"t_address": {
2872+
"label": "address",
2873+
"numberOfBytes": "20"
2874+
},
2875+
"t_array(t_uint256)49_storage": {
2876+
"label": "uint256[49]",
2877+
"numberOfBytes": "1568"
2878+
},
2879+
"t_array(t_uint256)50_storage": {
2880+
"label": "uint256[50]",
2881+
"numberOfBytes": "1600"
2882+
},
2883+
"t_bool": {
2884+
"label": "bool",
2885+
"numberOfBytes": "1"
2886+
},
2887+
"t_struct(Line)11666_storage": {
2888+
"label": "struct Line",
2889+
"members": [
2890+
{
2891+
"label": "x1",
2892+
"type": "t_uint256",
2893+
"offset": 0,
2894+
"slot": "0"
2895+
},
2896+
{
2897+
"label": "y1",
2898+
"type": "t_uint256",
2899+
"offset": 0,
2900+
"slot": "1"
2901+
},
2902+
{
2903+
"label": "x2",
2904+
"type": "t_uint256",
2905+
"offset": 0,
2906+
"slot": "2"
2907+
},
2908+
{
2909+
"label": "y2",
2910+
"type": "t_uint256",
2911+
"offset": 0,
2912+
"slot": "3"
2913+
}
2914+
],
2915+
"numberOfBytes": "128"
2916+
},
2917+
"t_struct(Range)11656_storage": {
2918+
"label": "struct Range",
2919+
"members": [
2920+
{
2921+
"label": "lower",
2922+
"type": "t_uint256",
2923+
"offset": 0,
2924+
"slot": "0"
2925+
},
2926+
{
2927+
"label": "upper",
2928+
"type": "t_uint256",
2929+
"offset": 0,
2930+
"slot": "1"
2931+
}
2932+
],
2933+
"numberOfBytes": "64"
2934+
},
2935+
"t_uint256": {
2936+
"label": "uint256",
2937+
"numberOfBytes": "32"
2938+
},
2939+
"t_uint8": {
2940+
"label": "uint8",
2941+
"numberOfBytes": "1"
2942+
}
2943+
},
2944+
"namespaces": {}
2945+
}
27182946
}
27192947
}
27202948
}

spot-contracts/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ The official mainnet addresses are:
88
- Bond issuer: [0x5613Fc36A431c9c2746763B80C1DD89e03593871](https://etherscan.io/address/0x5613Fc36A431c9c2746763B80C1DD89e03593871)
99
- Router: [0xCe2878d1f2901EFaF48cd456E586B470C145d1BC](https://etherscan.io/address/0xCe2878d1f2901EFaF48cd456E586B470C145d1BC)
1010
- RolloverVault: [0x82A91a0D599A45d8E9Af781D67f695d7C72869Bd](https://etherscan.io//address/0x82A91a0D599A45d8E9Af781D67f695d7C72869Bd)
11-
- FeePolicy: [0xE22977381506bF094CB3ed50CB8834E358F7ef6c](https://etherscan.io//address/0xE22977381506bF094CB3ed50CB8834E358F7ef6c)
11+
- FeePolicy: [0x8689Fa9991834Bcf0387b31b7986ac311bAb6ab5](https://etherscan.io//address/0x8689Fa9991834Bcf0387b31b7986ac311bAb6ab5)
1212

1313
## Install
1414

spot-contracts/deployments/mainnet.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"rolloverVault": "0x82A91a0D599A45d8E9Af781D67f695d7C72869Bd",
99
"proxyAdmin": "0x2978B4103985A6668CE345555b0febdE64Fb092F",
1010
"router": "0xCe2878d1f2901EFaF48cd456E586B470C145d1BC",
11-
"feePolicy": "0xE22977381506bF094CB3ed50CB8834E358F7ef6c",
11+
"feePolicy": "0x8689Fa9991834Bcf0387b31b7986ac311bAb6ab5",
1212
"previousIssuers": [
1313
[0, "0x9443b779d4AedF97d2B93D7CDa5fA0BB6312DfF2"],
1414
[1, "0xD64FA63dc5E8fcB743457E47E4d522E11Ff1AD66"],

spot-contracts/hardhat.config.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@ export default {
3838
},
3939
},
4040
mainnet: {
41-
// url: `https://mainnet.infura.io/v3/${process.env.INFURA_SECRET}`,
42-
url: `https://eth-mainnet.g.alchemy.com/v2/${process.env.ALCHEMY_SECRET}`,
41+
url: `https://mainnet.infura.io/v3/${process.env.INFURA_SECRET}`,
42+
// url: `https://eth-mainnet.g.alchemy.com/v2/${process.env.ALCHEMY_SECRET}`,
43+
// url: `https://virtual.mainnet.rpc.tenderly.co/f468fb75-ada0-4833-9f64-f71d51b71190`,
4344
accounts: {
4445
mnemonic: process.env.PROD_MNEMONIC || Wallet.createRandom().mnemonic.phrase,
4546
},

spot-contracts/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"eslint-plugin-promise": "^6.0.0",
5252
"eslint-plugin-unused-imports": "^3.0.0",
5353
"ethereum-waffle": "latest",
54-
"ethers": "^6.6.0",
54+
"ethers": "^6.14.4",
5555
"ethers-v5": "npm:ethers@^5.7.0",
5656
"ganache-cli": "latest",
5757
"hardhat": "^2.23.0",
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# deploy new contracts
2+
yarn hardhat --network mainnet deploy:FeePolicy
3+
# fee policy 0x8689Fa9991834Bcf0387b31b7986ac311bAb6ab5
4+
yarn hardhat --network mainnet transferOwnership "0x8689Fa9991834Bcf0387b31b7986ac311bAb6ab5" \
5+
--new-owner-address "0x57981B1EaFe4b18EC97f8B10859B40207b364662"
6+
7+
# deploy new implementations
8+
yarn hardhat --network mainnet prepare_upgrade PerpetualTranche 0xC1f33e0cf7e40a67375007104B929E49a581bafE
9+
yarn hardhat --network mainnet prepare_upgrade:RolloverVault 0x82A91a0D599A45d8E9Af781D67f695d7C72869Bd
10+
# linked library 0xe0028c40C8A09449852ea4D2e9aa4d25895F285f
11+
12+
# spot v2 check storage layout
13+
yarn hardhat --network mainnet validate_upgrade PerpetualTranche 0xC1f33e0cf7e40a67375007104B929E49a581bafE
14+
yarn hardhat --network mainnet validate_upgrade:RolloverVault 0x82A91a0D599A45d8E9Af781D67f695d7C72869Bd \
15+
--tranche-manager-address 0xe0028c40C8A09449852ea4D2e9aa4d25895F285f
16+
17+
# execute via multisig
18+
# proxyAdmin: 0x2978B4103985A6668CE345555b0febdE64Fb092F
19+
# proxyAdmin.upgrade(0xC1f33e0cf7e40a67375007104B929E49a581bafE, 0x62cbE9F24413485f04FA62F9548C7855ec4a5425)
20+
# proxyAdmin.upgrade(0x82A91a0D599A45d8E9Af781D67f695d7C72869Bd, 0x09e8adfa8D829DaC1c305544A86b53Ed0dDD536a)
21+
22+
yarn hardhat --network mainnet ops:perp:info 0xC1f33e0cf7e40a67375007104B929E49a581bafE
23+
yarn hardhat --network mainnet ops:vault:info 0x82A91a0D599A45d8E9Af781D67f695d7C72869Bd
24+
25+
# emergency rollback
26+
# proxyAdmin.upgrade(0xC1f33e0cf7e40a67375007104B929E49a581bafE, 0x5dc5488b35c34a43fe19ba9de38b63806fab4b23)
27+
# proxyAdmin.upgrade(0x82A91a0D599A45d8E9Af781D67f695d7C72869Bd, 0xa85be82083e032edf32a19028df558484b399196)
28+
29+
# Deployment runbook
30+
# 1) Setup new fee policy, with chosen parameters (sanity check return values)
31+
# 2) Pause everything, SPOT, stAMPL and BillBroker
32+
# 3) Execute upgrade (spot and stampl)
33+
# 4) Set fee policy reference and double check all other parameters on SPOT and STAMPL
34+
# 5) Ops, execute first rebalance

spot-contracts/tasks/upgrade/index.ts

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,31 @@ task("validate_upgrade")
2222
console.log("Success");
2323
});
2424

25+
task("validate_upgrade:RolloverVault")
26+
.addPositionalParam("address", "the address of the deployed proxy contract", undefined, types.string, false)
27+
.addParam("trancheManagerAddress", "the address of the linked tranche manager", "0x", types.string)
28+
.setAction(async function (args: TaskArguments, hre) {
29+
const { address, trancheManagerAddress } = args;
30+
const Factory = await hre.ethers.getContractFactory("RolloverVault", {
31+
libraries: {
32+
TrancheManager: trancheManagerAddress,
33+
},
34+
});
35+
36+
console.log("Trying strict validation");
37+
try {
38+
await hre.upgrades.validateUpgrade(address, Factory);
39+
} catch (e) {
40+
console.log("Strict validation failed. ", e);
41+
console.log("Retrying but allowing variable renames.");
42+
await hre.upgrades.validateUpgrade(address, Factory, {
43+
unsafeAllowRenames: true,
44+
unsafeAllowLinkedLibraries: true,
45+
});
46+
}
47+
console.log("Success");
48+
});
49+
2550
task("prepare_upgrade")
2651
.addPositionalParam("factory", "the name of the factory", undefined, types.string, false)
2752
.addPositionalParam("address", "the address of the deployed proxy contract", undefined, types.string, false)
@@ -122,3 +147,47 @@ task("upgrade:testnet:RolloverVault")
122147
address: newImpl,
123148
});
124149
});
150+
151+
task("prepare_upgrade:RolloverVault")
152+
.addPositionalParam("address", "the address of the deployed proxy contract", undefined, types.string, false)
153+
.addParam("trancheManagerAddress", "the address of the linked tranche manager", "0x", types.string)
154+
.addParam("fromIdx", "the index of sender", 0, types.int)
155+
.setAction(async function (args: TaskArguments, hre) {
156+
const signer = (await hre.ethers.getSigners())[args.fromIdx];
157+
const signerAddress = await signer.getAddress();
158+
console.log("Signer", signerAddress);
159+
160+
let trancheManagerAddress = args.trancheManagerAddress;
161+
if (trancheManagerAddress === "0x") {
162+
const TrancheManager = await hre.ethers.getContractFactory("TrancheManager");
163+
const trancheManager = await TrancheManager.deploy();
164+
trancheManagerAddress = trancheManager.target;
165+
console.log("Deploying linked library TrancheManager", trancheManagerAddress);
166+
}
167+
const Factory = await hre.ethers.getContractFactory("RolloverVault", {
168+
libraries: {
169+
TrancheManager: trancheManagerAddress,
170+
},
171+
});
172+
173+
const { address } = args;
174+
console.log("Proxy", address);
175+
console.log("Current implementation", await getImplementationAddress(hre.ethers.provider, address));
176+
177+
await hre.upgrades.prepareUpgrade(address, Factory, {
178+
unsafeAllowRenames: true,
179+
unsafeAllowLinkedLibraries: true,
180+
});
181+
await sleep(30);
182+
const newImpl = await getImplementationAddress(hre.ethers.provider, address);
183+
console.log("Updated implementation", newImpl);
184+
185+
await sleep(30);
186+
await hre.run("verify:contract", {
187+
address: trancheManagerAddress,
188+
});
189+
await sleep(30);
190+
await hre.run("verify:contract", {
191+
address: newImpl,
192+
});
193+
});

0 commit comments

Comments
 (0)