|
1 | 1 | import { HardhatRuntimeEnvironment, Network } from "hardhat/types";
|
2 | 2 | import { DeployFunction } from "hardhat-deploy/types";
|
3 |
| -import { utils } from "ethers"; |
4 |
| -import deployConfig from "../deployConfig"; |
| 3 | +import { deployVaultFactory } from "./modules/VaultFactory"; |
| 4 | +import { deployUniswapV3Factory } from "./modules/UniswapV3Factory"; |
| 5 | +import { deployInventoryStaking } from "./modules/InventoryStaking"; |
| 6 | +import { deployUniswapV3Periphery } from "./modules/UniswapV3Periphery"; |
| 7 | +import { deployNFTXRouter } from "./modules/NFTXRouter"; |
| 8 | +import { deployFeeDistributor } from "./modules/FeeDistributor"; |
| 9 | +import { deployFailSafe } from "./modules/FailSafe"; |
5 | 10 |
|
6 | 11 | const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
|
7 |
| - const { deployments, getNamedAccounts, network } = hre; |
8 |
| - const { deploy, execute } = deployments; |
| 12 | + const { vaultFactory } = await deployVaultFactory({ hre }); |
9 | 13 |
|
10 |
| - const { deployer } = await getNamedAccounts(); |
11 |
| - const config = deployConfig[network.name]; |
12 |
| - |
13 |
| - const positionManager = await deployments.get("NonfungiblePositionManager"); |
14 |
| - const uniV3Factory = await deployments.get("UniswapV3FactoryUpgradeable"); |
15 |
| - const router = await deployments.get("SwapRouter"); |
16 |
| - const quoter = await deployments.get("QuoterV2"); |
17 |
| - |
18 |
| - const vaultImpl = await deploy("NFTXVaultUpgradeableV3", { |
19 |
| - from: deployer, |
20 |
| - args: [config.WETH], |
21 |
| - log: true, |
22 |
| - }); |
23 |
| - |
24 |
| - const vaultFactory = await deploy("NFTXVaultFactoryUpgradeableV3", { |
25 |
| - from: deployer, |
26 |
| - proxy: { |
27 |
| - proxyContract: "OpenZeppelinTransparentProxy", |
28 |
| - execute: { |
29 |
| - init: { |
30 |
| - methodName: "__NFTXVaultFactory_init", |
31 |
| - args: [ |
32 |
| - vaultImpl.address, |
33 |
| - config.twapInterval, |
34 |
| - config.premiumDuration, |
35 |
| - config.premiumMax, |
36 |
| - config.depositorPremiumShare, |
37 |
| - ], |
38 |
| - }, |
39 |
| - }, |
40 |
| - }, |
41 |
| - log: true, |
| 14 | + const { inventoryStaking } = await deployInventoryStaking({ |
| 15 | + hre, |
| 16 | + vaultFactory, |
42 | 17 | });
|
43 | 18 |
|
44 |
| - const NFTXEligibilityManager = await deploy("NFTXEligibilityManager", { |
45 |
| - from: deployer, |
46 |
| - proxy: { |
47 |
| - proxyContract: "OpenZeppelinTransparentProxy", |
48 |
| - execute: { |
49 |
| - init: { |
50 |
| - methodName: "__NFTXEligibilityManager_init", |
51 |
| - args: [], |
52 |
| - }, |
53 |
| - }, |
54 |
| - }, |
55 |
| - log: true, |
| 19 | + const { uniswapFactory } = await deployUniswapV3Factory({ |
| 20 | + hre, |
56 | 21 | });
|
57 |
| - console.log("Setting eligibilityManager in VaultFactory..."); |
58 |
| - await execute( |
59 |
| - "NFTXVaultFactoryUpgradeableV3", |
60 |
| - { from: deployer }, |
61 |
| - "setEligibilityManager", |
62 |
| - NFTXEligibilityManager.address |
63 |
| - ); |
64 |
| - console.log("Set eligibilityManager in VaultFactory"); |
65 | 22 |
|
66 |
| - // Deploy various eligibility modules in this order |
67 |
| - const eligibilityModules = [ |
68 |
| - "NFTXListEligibility", |
69 |
| - "NFTXRangeEligibility", |
70 |
| - "NFTXGen0KittyEligibility", |
71 |
| - "NFTXENSMerkleEligibility", |
72 |
| - ]; |
73 |
| - |
74 |
| - for (let i = 0; i < eligibilityModules.length; ++i) { |
75 |
| - const eligibilityModule = await deploy(eligibilityModules[i], { |
76 |
| - from: deployer, |
77 |
| - log: true, |
| 23 | + const { positionManager, swapRouter, quoter } = |
| 24 | + await deployUniswapV3Periphery({ |
| 25 | + hre, |
| 26 | + uniswapFactory, |
78 | 27 | });
|
79 | 28 |
|
80 |
| - console.log( |
81 |
| - `Adding eligibility module ${eligibilityModules[i]} to NFTXEligibilityManager...` |
82 |
| - ); |
83 |
| - await execute( |
84 |
| - "NFTXEligibilityManager", |
85 |
| - { from: deployer }, |
86 |
| - "addModule", |
87 |
| - eligibilityModule.address |
88 |
| - ); |
89 |
| - console.log( |
90 |
| - `Added eligibility module ${eligibilityModules[i]} to NFTXEligibilityManager` |
91 |
| - ); |
92 |
| - } |
93 |
| - |
94 |
| - const timelockExcludeList = await deploy("TimelockExcludeList", { |
95 |
| - from: deployer, |
96 |
| - log: true, |
| 29 | + const { nftxRouter } = await deployNFTXRouter({ |
| 30 | + hre, |
| 31 | + vaultFactory, |
| 32 | + inventoryStaking, |
| 33 | + positionManager, |
| 34 | + swapRouter, |
| 35 | + quoter, |
97 | 36 | });
|
98 | 37 |
|
99 |
| - const inventoryDescriptor = await deploy("InventoryStakingDescriptor", { |
100 |
| - from: deployer, |
101 |
| - log: true, |
| 38 | + const { feeDistributor } = await deployFeeDistributor({ |
| 39 | + hre, |
| 40 | + nftxRouter, |
| 41 | + uniswapFactory, |
| 42 | + inventoryStaking, |
| 43 | + vaultFactory, |
102 | 44 | });
|
103 |
| - const inventoryStaking = await deploy("NFTXInventoryStakingV3Upgradeable", { |
104 |
| - from: deployer, |
105 |
| - args: [config.WETH, config.permit2, vaultFactory.address], |
106 |
| - proxy: { |
107 |
| - proxyContract: "OpenZeppelinTransparentProxy", |
108 |
| - execute: { |
109 |
| - init: { |
110 |
| - methodName: "__NFTXInventoryStaking_init", |
111 |
| - args: [ |
112 |
| - config.inventoryTimelock, |
113 |
| - config.inventoryEarlyWithdrawPenaltyInWei, |
114 |
| - timelockExcludeList.address, |
115 |
| - inventoryDescriptor.address, |
116 |
| - ], |
117 |
| - }, |
118 |
| - }, |
119 |
| - }, |
120 |
| - log: true, |
121 |
| - }); |
122 |
| - |
123 |
| - // InventoryStaking has in-built fee handling |
124 |
| - console.log("Setting fee exclusion for InventoryStaking..."); |
125 |
| - await execute( |
126 |
| - "NFTXVaultFactoryUpgradeableV3", |
127 |
| - { from: deployer }, |
128 |
| - "setFeeExclusion", |
129 |
| - inventoryStaking.address, |
130 |
| - true |
131 |
| - ); |
132 |
| - console.log("Fee exclusion set for InventoryStaking"); |
133 | 45 |
|
134 |
| - console.log("Setting guardian on InventoryStaking..."); |
135 |
| - await execute( |
136 |
| - "NFTXInventoryStakingV3Upgradeable", |
137 |
| - { from: deployer }, |
138 |
| - "setIsGuardian", |
139 |
| - deployer, |
140 |
| - true |
141 |
| - ); |
142 |
| - console.log("Set guardian on InventoryStaking"); |
143 |
| - |
144 |
| - const nftxRouter = await deploy("NFTXRouter", { |
145 |
| - from: deployer, |
146 |
| - args: [ |
147 |
| - positionManager.address, |
148 |
| - router.address, |
149 |
| - quoter.address, |
150 |
| - vaultFactory.address, |
151 |
| - config.permit2, |
152 |
| - config.lpTimelock, |
153 |
| - config.lpEarlyWithdrawPenaltyInWei, |
154 |
| - config.nftxRouterVTokenDustThreshold, |
155 |
| - inventoryStaking.address, |
156 |
| - ], |
157 |
| - log: true, |
| 46 | + const { failSafe } = await deployFailSafe({ |
| 47 | + hre, |
| 48 | + inventoryStaking, |
| 49 | + vaultFactory, |
| 50 | + feeDistributor, |
| 51 | + nftxRouter, |
158 | 52 | });
|
159 |
| - |
160 |
| - // NFTXRouter has in-built fee handling |
161 |
| - console.log("Setting fee exclusion for NFTXRouter..."); |
162 |
| - await execute( |
163 |
| - "NFTXVaultFactoryUpgradeableV3", |
164 |
| - { from: deployer }, |
165 |
| - "setFeeExclusion", |
166 |
| - nftxRouter.address, |
167 |
| - true |
168 |
| - ); |
169 |
| - console.log("Fee exclusion set for NFTXRouter"); |
170 |
| - |
171 |
| - console.log( |
172 |
| - "Setting timelock exclusion for NFTXRouter on positionManager..." |
173 |
| - ); |
174 |
| - await execute( |
175 |
| - "NonfungiblePositionManager", |
176 |
| - { from: deployer }, |
177 |
| - "setTimelockExcluded", |
178 |
| - nftxRouter.address, |
179 |
| - true |
180 |
| - ); |
181 |
| - console.log("Timelock exclusion set for NFTXRouter on positionManager"); |
182 |
| - |
183 |
| - const feeDistributor = await deploy("NFTXFeeDistributorV3", { |
184 |
| - from: deployer, |
185 |
| - args: [ |
186 |
| - vaultFactory.address, |
187 |
| - uniV3Factory.address, |
188 |
| - inventoryStaking.address, |
189 |
| - nftxRouter.address, |
190 |
| - config.treasury, |
191 |
| - config.rewardFeeTier, |
192 |
| - ], |
193 |
| - log: true, |
194 |
| - }); |
195 |
| - |
196 |
| - console.log("Setting FeeDistributor in UniV3Factory..."); |
197 |
| - await execute( |
198 |
| - "UniswapV3FactoryUpgradeable", |
199 |
| - { from: deployer }, |
200 |
| - "setFeeDistributor", |
201 |
| - feeDistributor.address |
202 |
| - ); |
203 |
| - console.log("Set FeeDistributor in UniV3Factory"); |
204 |
| - |
205 |
| - console.log("Setting FeeDistributor in NFTXVaultFactory..."); |
206 |
| - await execute( |
207 |
| - "NFTXVaultFactoryUpgradeableV3", |
208 |
| - { from: deployer }, |
209 |
| - "setFeeDistributor", |
210 |
| - feeDistributor.address |
211 |
| - ); |
212 |
| - console.log("Set FeeDistributor in NFTXVaultFactory"); |
213 | 53 | };
|
214 | 54 | export default func;
|
215 | 55 | func.tags = ["NFTXV3"];
|
216 |
| -func.dependencies = ["UniV3"]; |
| 56 | +func.dependencies = []; |
0 commit comments