Skip to content

Commit c23cb6e

Browse files
authored
chore(DelegatedManager): Add Avalanche staging DelegatedManager system deployment [SIM-310] (#43)
* add avax staging DelegatedManager system deployment * add WIP snowtrace verification * complete snowtrace verification * add BatchTradeExtension to deployment
1 parent daf2ec0 commit c23cb6e

File tree

9 files changed

+178
-7
lines changed

9 files changed

+178
-7
lines changed

.env.default

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ ETHERSCAN_API_KEY=<etherscan key>
99
POLYGONSCAN_API_KEY=<polygonscan key>
1010
ARBISCAN_API_KEY=<arbiscan key>
1111
OPTIMISTIC_API_KEY=<optimistic key>
12+
SNOWTRACE_API_KEY=<snowtrace key>
1213

1314
GOERLI_DEPLOY_PRIVATE_KEY=0f3456f7f1ed59aaa29f35f4674a87e754e1055249a2888bdaec3dea49d2e456
1415
MUMBAI_DEPLOY_PRIVATE_KEY=0f3456f7f1ed59aaa29f35f4674a87e754e1055249a2888bdaec3dea49d2e456

avalanche/deploy/001_delegated_manager_system.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
trackFinishedStage,
1414
writeTransactionToOutputs,
1515
getAccounts,
16+
addExtensionToManagerCore,
1617
} from "@utils/index";
1718

1819
import { Account } from "@utils/types";
@@ -68,6 +69,10 @@ const func: DeployFunction = trackFinishedStage(CURRENT_STAGE, async function (b
6869

6970
await initializeManagerCore();
7071

72+
await deployBatchTradeExtension();
73+
74+
await addExtensionToManagerCore(CONTRACT_NAMES.BATCH_TRADE_EXTENSION, bre);
75+
7176
await transferManagerCoreOwnershipToMultisig();
7277

7378
//
@@ -162,6 +167,24 @@ const func: DeployFunction = trackFinishedStage(CURRENT_STAGE, async function (b
162167
}
163168
}
164169

170+
async function deployBatchTradeExtension(): Promise<void> {
171+
const checkBatchTradeExtensionAddress = await getContractAddress(CONTRACT_NAMES.BATCH_TRADE_EXTENSION);
172+
if (checkBatchTradeExtensionAddress === "") {
173+
const constructorArgs = [managerCoreAddress, tradeModuleAddress, ["ZeroExApiAdapterV5"]];
174+
const batchTradeExtensionDeploy = await deploy(
175+
CONTRACT_NAMES.BATCH_TRADE_EXTENSION,
176+
{ from: deployer, args: constructorArgs, log: true }
177+
);
178+
batchTradeExtensionDeploy.receipt && await saveContractDeployment({
179+
name: CONTRACT_NAMES.BATCH_TRADE_EXTENSION,
180+
contractAddress: batchTradeExtensionDeploy.address,
181+
id: batchTradeExtensionDeploy.receipt.transactionHash,
182+
description: `Deployed ${CONTRACT_NAMES.BATCH_TRADE_EXTENSION}`,
183+
constructorArgs,
184+
});
185+
}
186+
}
187+
165188
async function initializeManagerCore(): Promise<void> {
166189
const managerCoreInstance = await instanceGetter.getManagerCore(managerCoreAddress);
167190
if (!await managerCoreInstance.isInitialized()) {

avalanche/deployments/constants/001_delegated_manager_system.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ export const CONTRACT_NAMES = {
44
ISSUANCE_EXTENSION:"IssuanceExtension",
55
STREAMING_FEE_SPLIT_EXTENSION:"StreamingFeeSplitExtension",
66
TRADE_EXTENSION:"TradeExtension",
7+
BATCH_TRADE_EXTENSION:"BatchTradeExtension",
78
};
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
{
2+
"state": {
3+
"network_key": "43114-staging",
4+
"human_friendly_name": "avalanche-mainnet-staging",
5+
"network_id": 43114,
6+
"last_deployment_stage": 2
7+
},
8+
"addresses": {
9+
"ManagerCore": "0x94b8C3B9F32E9E4617536D8888B6026708BD9C75",
10+
"DelegatedManagerFactory": "0xb2812842C176bAf83EcD8e4534A9F4A93e93017E",
11+
"IssuanceExtension": "0xe42464Cbc4C077D1534b5323636C77E829161Ef0",
12+
"StreamingFeeSplitExtension": "0x1116eAAc4FF21606F78218f187c3D2027bbfaf59",
13+
"TradeExtension": "0x2A2Aa751D5Ac7899f66AC8408C64437Efd0671b7",
14+
"BatchTradeExtension": "0x80FFCA5591d271aD19CC2e25Eb45cfAEEA26efAE"
15+
},
16+
"transactions": {
17+
"0": {
18+
"id": "0x50d76c59dfdb2b1dc568dd42bd7363b54d1e2d5c3a3cce150f7d59ca4d6fdf04",
19+
"name": "ManagerCore",
20+
"timestamp": 1652113222660,
21+
"verified": true,
22+
"description": "Deployed ManagerCore",
23+
"contractAddress": "0x94b8C3B9F32E9E4617536D8888B6026708BD9C75",
24+
"constructorArgs": [],
25+
"libraries": {}
26+
},
27+
"1": {
28+
"id": "0x45f51a66881b3b861e623c36dc62a892abea720471a2feb75ee0e9a7c50fb937",
29+
"name": "DelegatedManagerFactory",
30+
"timestamp": 1652113239193,
31+
"verified": true,
32+
"description": "Deployed DelegatedManagerFactory",
33+
"contractAddress": "0xb2812842C176bAf83EcD8e4534A9F4A93e93017E",
34+
"constructorArgs": [
35+
"0x94b8C3B9F32E9E4617536D8888B6026708BD9C75",
36+
"0x14099863F0B6490759f9D8bC5653CF52b7eF38eb",
37+
"0xE99447aBbD5A7730b26D2D16fCcB2086319e4bC3"
38+
],
39+
"libraries": {}
40+
},
41+
"2": {
42+
"id": "0x4a25d44ab0c3afa0ee48cf95874b610659d4c9440dc404a34eaedf03bc9e890a",
43+
"name": "IssuanceExtension",
44+
"timestamp": 1652114934633,
45+
"verified": true,
46+
"description": "Deployed IssuanceExtension",
47+
"contractAddress": "0xe42464Cbc4C077D1534b5323636C77E829161Ef0",
48+
"constructorArgs": [
49+
"0x94b8C3B9F32E9E4617536D8888B6026708BD9C75",
50+
"0x1eAF9C71AaDD5339D088eF36bF383f909a0c9780"
51+
],
52+
"libraries": {}
53+
},
54+
"3": {
55+
"id": "0x8b35e27d56fe8f97ea2b132cab41518432651121e12cd6e5a0df3c6cefb32e91",
56+
"name": "StreamingFeeSplitExtension",
57+
"timestamp": 1652114940917,
58+
"verified": true,
59+
"description": "Deployed StreamingFeeSplitExtension",
60+
"contractAddress": "0x1116eAAc4FF21606F78218f187c3D2027bbfaf59",
61+
"constructorArgs": [
62+
"0x94b8C3B9F32E9E4617536D8888B6026708BD9C75",
63+
"0x4F70287526ea9Ba7e799D616ea86635CdAf0de4F"
64+
],
65+
"libraries": {}
66+
},
67+
"4": {
68+
"id": "0x9888411ce13913dd7da1406dd617248d0daffba54db1f9223df9bbc00e66c41c",
69+
"name": "TradeExtension",
70+
"timestamp": 1652114947252,
71+
"verified": true,
72+
"description": "Deployed TradeExtension",
73+
"contractAddress": "0x2A2Aa751D5Ac7899f66AC8408C64437Efd0671b7",
74+
"constructorArgs": [
75+
"0x94b8C3B9F32E9E4617536D8888B6026708BD9C75",
76+
"0x44279c2cbFaa14D354144895B0c7771c597d6944"
77+
],
78+
"libraries": {}
79+
},
80+
"5": {
81+
"id": "0x05b9a1755cdd0cabb532c103b9b86419f3140427f8b1d645bff1ca40daeb25ec",
82+
"timestamp": 1652114958219,
83+
"description": "Initialized ManagerCore with DelegatedManagerFactory, IssuanceExtension, StreamingFeeSplitExtension, and TradeExtension"
84+
},
85+
"6": {
86+
"id": "0xfe4bd050a2567ce6b4ea5cf3b98cbcedb20a2a678514105f2e78e4e264cc85e1",
87+
"name": "BatchTradeExtension",
88+
"timestamp": 1652213424366,
89+
"verified": true,
90+
"description": "Deployed BatchTradeExtension",
91+
"contractAddress": "0x80FFCA5591d271aD19CC2e25Eb45cfAEEA26efAE",
92+
"constructorArgs": [
93+
"0x94b8C3B9F32E9E4617536D8888B6026708BD9C75",
94+
"0x44279c2cbFaa14D354144895B0c7771c597d6944",
95+
[
96+
"ZeroExApiAdapterV5"
97+
]
98+
],
99+
"libraries": {}
100+
},
101+
"7": {
102+
"id": "0x3beeaf9daa4d44e46d944b62f62296a276ab198f19ce46a998e71c6c92cc9e1c",
103+
"timestamp": 1652213433594,
104+
"description": "Add BatchTradeExtension to ManagerCore"
105+
}
106+
}
107+
}

avalanche/hardhat.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const config: HardhatUserConfig = {
5151
},
5252
},
5353
etherscan: {
54-
apiKey: `${process.env.ETHERSCAN_API_KEY}`,
54+
apiKey: `${process.env.SNOWTRACE_API_KEY}`,
5555
},
5656
// @ts-ignore
5757
typechain: {

avalanche/test/deploys/001_delegated_manager_system.spec.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import {
88
ManagerCore__factory,
99
DelegatedManagerFactory,
1010
DelegatedManagerFactory__factory,
11+
BatchTradeExtension,
12+
BatchTradeExtension__factory,
1113
IssuanceExtension,
1214
IssuanceExtension__factory,
1315
StreamingFeeSplitExtension,
@@ -44,6 +46,7 @@ describe("Delegated Manager System", () => {
4446
let issuanceExtensionInstance: IssuanceExtension;
4547
let streamingFeeSplitExtensionInstance: StreamingFeeSplitExtension;
4648
let tradeExtensionInstance: TradeExtension;
49+
let batchTradeExtensionInstance: BatchTradeExtension;
4750

4851
before(async () => {
4952
[deployer] = await getAccounts();
@@ -64,6 +67,9 @@ describe("Delegated Manager System", () => {
6467

6568
const deployedTradeExtensionContract = await getContractAddress(CONTRACT_NAMES.TRADE_EXTENSION);
6669
tradeExtensionInstance = new TradeExtension__factory(deployer.wallet).attach(deployedTradeExtensionContract);
70+
71+
const deployedBatchTradeExtensionContract = await getContractAddress(CONTRACT_NAMES.BATCH_TRADE_EXTENSION);
72+
batchTradeExtensionInstance = new BatchTradeExtension__factory(deployer.wallet).attach(deployedBatchTradeExtensionContract);
6773
});
6874

6975
addSnapshotBeforeRestoreAfterEach();
@@ -98,6 +104,11 @@ describe("Delegated Manager System", () => {
98104
const validTradeExtension = await managerCoreInstance.isExtension(tradeExtensionInstance.address);
99105
expect(validTradeExtension).to.eq(true);
100106
});
107+
108+
it("should have BatchTradeExtension as valid extension", async () => {
109+
const validBatchTradeExtension = await managerCoreInstance.isExtension(batchTradeExtensionInstance.address);
110+
expect(validBatchTradeExtension).to.eq(true);
111+
});
101112
});
102113

103114
describe("DelegatedManagerFactory", async () => {
@@ -152,4 +163,26 @@ describe("Delegated Manager System", () => {
152163
expect(tradeModule).to.eq(await findDependency(TRADE_MODULE));
153164
});
154165
});
166+
167+
describe("BatchTradeExtension", async () => {
168+
it("should have the correct ManagerCore address", async () => {
169+
const managerCore = await batchTradeExtensionInstance.managerCore();
170+
expect(managerCore).to.eq(managerCoreInstance.address);
171+
});
172+
173+
it("should have the correct TradeModule address", async () => {
174+
const tradeModule = await batchTradeExtensionInstance.tradeModule();
175+
expect(tradeModule).to.eq(await findDependency(TRADE_MODULE));
176+
});
177+
178+
it("should have set the correct integrations length of 1", async () => {
179+
const integrations = await batchTradeExtensionInstance.getIntegrations();
180+
expect(integrations.length).to.eq(1);
181+
});
182+
183+
it("should have ZeroExApiAdapterV5 as a valid integration", async () => {
184+
const validZeroExApiAdapterV5 = await batchTradeExtensionInstance.isIntegration("ZeroExApiAdapterV5");
185+
expect(validZeroExApiAdapterV5).to.eq(true);
186+
});
187+
});
155188
});

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
},
4242
"devDependencies": {
4343
"@nomiclabs/hardhat-ethers": "^2.0.2",
44-
"@nomiclabs/hardhat-etherscan": "^2.1.6",
44+
"@nomiclabs/hardhat-etherscan": "^3.0.3",
4545
"@nomiclabs/hardhat-waffle": "^2.0.1",
4646
"@openzeppelin/contracts": "^3.1.0",
4747
"@truffle/hdwallet-provider": "^1.4.0",

utils/validateEnvVars.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const envVars = [
1010
"POLYGONSCAN_API_KEY",
1111
"ARBISCAN_API_KEY",
1212
"OPTIMISTIC_API_KEY",
13+
"SNOWTRACE_API_KEY",
1314
"GOERLI_DEPLOY_PRIVATE_KEY",
1415
"MUMBAI_DEPLOY_PRIVATE_KEY",
1516
"STAGING_POLYGON_DEPLOY_PRIVATE_KEY",

yarn.lock

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,18 +1133,18 @@
11331133
resolved "https://registry.yarnpkg.com/@nomiclabs/hardhat-ethers/-/hardhat-ethers-2.0.2.tgz#c472abcba0c5185aaa4ad4070146e95213c68511"
11341134
integrity sha512-6quxWe8wwS4X5v3Au8q1jOvXYEPkS1Fh+cME5u6AwNdnI4uERvPlVjlgRWzpnb+Rrt1l/cEqiNRH9GlsBMSDQg==
11351135

1136-
"@nomiclabs/hardhat-etherscan@^2.1.6":
1137-
version "2.1.6"
1138-
resolved "https://registry.yarnpkg.com/@nomiclabs/hardhat-etherscan/-/hardhat-etherscan-2.1.6.tgz#8d1502f42adc6f7b8ef16fb917c0b5a8780cb83a"
1139-
integrity sha512-gCvT5fj8GbXS9+ACS3BzrX0pzYHHZqAHCb+NcipOkl2cy48FakUXlzrCf4P4sTH+Y7W10OgT62ezD1sJ+/NikQ==
1136+
"@nomiclabs/hardhat-etherscan@^3.0.3":
1137+
version "3.0.3"
1138+
resolved "https://registry.yarnpkg.com/@nomiclabs/hardhat-etherscan/-/hardhat-etherscan-3.0.3.tgz#ca54a03351f3de41f9f5240e37bea9d64fa24e64"
1139+
integrity sha512-OfNtUKc/ZwzivmZnnpwWREfaYncXteKHskn3yDnz+fPBZ6wfM4GR+d5RwjREzYFWE+o5iR9ruXhWw/8fejWM9g==
11401140
dependencies:
11411141
"@ethersproject/abi" "^5.1.2"
11421142
"@ethersproject/address" "^5.0.2"
11431143
cbor "^5.0.2"
11441144
debug "^4.1.1"
11451145
fs-extra "^7.0.1"
1146-
node-fetch "^2.6.0"
11471146
semver "^6.3.0"
1147+
undici "^4.14.1"
11481148

11491149
"@nomiclabs/hardhat-waffle@^2.0.1":
11501150
version "2.0.1"
@@ -11318,6 +11318,11 @@ underscore@~1.6.0:
1131811318
resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.6.0.tgz#8b38b10cacdef63337b8b24e4ff86d45aea529a8"
1131911319
integrity sha1-izixDKze9jM3uLJOT/htRa6lKag=
1132011320

11321+
undici@^4.14.1:
11322+
version "4.16.0"
11323+
resolved "https://registry.yarnpkg.com/undici/-/undici-4.16.0.tgz#469bb87b3b918818d3d7843d91a1d08da357d5ff"
11324+
integrity sha512-tkZSECUYi+/T1i4u+4+lwZmQgLXd4BLGlrc7KZPcLIW7Jpq99+Xpc30ONv7nS6F5UNOxp/HBZSSL9MafUrvJbw==
11325+
1132111326
union-value@^1.0.0:
1132211327
version "1.0.1"
1132311328
resolved "https://registry.yarnpkg.com/union-value/-/union-value-1.0.1.tgz#0b6fe7b835aecda61c6ea4d4f02c14221e109847"

0 commit comments

Comments
 (0)