1
1
import { HardhatRuntimeEnvironment , Network } from "hardhat/types" ;
2
2
import { DeployFunction } from "hardhat-deploy/types" ;
3
- import { getConfig , getContract } from "./utils" ;
3
+ import * as readline from "readline" ;
4
+ import { getConfig } from "./utils" ;
5
+ import { deployMarketplaceZap } from "./modules/MarketplaceZap" ;
6
+ import { deployCreateVaultZap } from "./modules/CreateVaultZap" ;
7
+ import { deployMigratorZap } from "./modules/MigratorZap" ;
8
+
9
+ const waitForEnter = async ( ) => {
10
+ const rl = readline . createInterface ( {
11
+ input : process . stdin ,
12
+ output : process . stdout ,
13
+ } ) ;
14
+ return new Promise < void > ( ( resolve ) => {
15
+ rl . question (
16
+ "🚨🚨 Make sure the UniversalRouter is updated & set in deployConfig. Redeploy if UniswapV3Factory address or salt was modified 🚨🚨\n Press Enter to continue..." ,
17
+ ( ) => {
18
+ rl . close ( ) ;
19
+ resolve ( ) ;
20
+ }
21
+ ) ;
22
+ } ) ;
23
+ } ;
4
24
5
25
const func : DeployFunction = async function ( hre : HardhatRuntimeEnvironment ) {
6
- const { config , deployments , deploy , execute , deployer } = await getConfig (
7
- hre
8
- ) ;
26
+ await waitForEnter ( ) ;
27
+
28
+ const { deployments } = await getConfig ( hre ) ;
9
29
10
30
const vaultFactory = await deployments . get ( "NFTXVaultFactoryUpgradeableV3" ) ;
11
31
const uniswapFactory = await deployments . get ( "UniswapV3FactoryUpgradeable" ) ;
@@ -15,95 +35,26 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
15
35
) ;
16
36
const nftxRouter = await deployments . get ( "NFTXRouter" ) ;
17
37
18
- const marketplaceZap = await deploy ( "MarketplaceUniversalRouterZap" , {
19
- from : deployer ,
20
- args : [
21
- vaultFactory . address ,
22
- config . nftxUniversalRouter ,
23
- config . permit2 ,
24
- inventoryStaking . address ,
25
- config . WETH ,
26
- ] ,
27
- log : true ,
38
+ const { marketplaceZap } = await deployMarketplaceZap ( {
39
+ hre,
40
+ vaultFactory : vaultFactory . address ,
41
+ inventoryStaking : inventoryStaking . address ,
28
42
} ) ;
29
43
30
- const vaultFactoryContract = await getContract (
44
+ const { createVaultZap } = await deployCreateVaultZap ( {
31
45
hre,
32
- "NFTXVaultFactoryUpgradeableV3" ,
33
- vaultFactory . address
34
- ) ;
35
- const isMarketplaceZapExcludedFromFees =
36
- await vaultFactoryContract . excludedFromFees ( marketplaceZap . address ) ;
37
- if ( ! isMarketplaceZapExcludedFromFees ) {
38
- // MarketplaceZap has in-built fee handling
39
- console . log ( "Setting fee exclusion for MarketplaceZap..." ) ;
40
- await execute (
41
- "NFTXVaultFactoryUpgradeableV3" ,
42
- { from : deployer } ,
43
- "setFeeExclusion" ,
44
- marketplaceZap . address ,
45
- true
46
- ) ;
47
- console . log ( "Fee exclusion set for MarketplaceZap" ) ;
48
- }
49
-
50
- const createVaultZap = await deploy ( "CreateVaultZap" , {
51
- from : deployer ,
52
- args : [
53
- nftxRouter . address ,
54
- uniswapFactory . address ,
55
- inventoryStaking . address ,
56
- ] ,
57
- log : true ,
46
+ vaultFactory : vaultFactory . address ,
47
+ nftxRouter : nftxRouter . address ,
48
+ uniswapFactory : uniswapFactory . address ,
49
+ inventoryStaking : inventoryStaking . address ,
58
50
} ) ;
59
51
60
- const isCreateVaultZapExcludedFromFees =
61
- await vaultFactoryContract . excludedFromFees ( createVaultZap . address ) ;
62
- if ( ! isCreateVaultZapExcludedFromFees ) {
63
- // CreateVaultZap doesn't deduct fees
64
- console . log ( "Setting fee exclusion for CreateVaultZap..." ) ;
65
- await execute (
66
- "NFTXVaultFactoryUpgradeableV3" ,
67
- { from : deployer } ,
68
- "setFeeExclusion" ,
69
- createVaultZap . address ,
70
- true
71
- ) ;
72
- console . log ( "Fee exclusion set for CreateVaultZap" ) ;
73
- }
74
-
75
- const migratorZap = await deploy ( "MigratorZap" , {
76
- from : deployer ,
77
- args : [
78
- config . WETH ,
79
- config . v2VaultFactory ,
80
- config . v2Inventory ,
81
- config . sushiRouter ,
82
- positionManager . address ,
83
- vaultFactory . address ,
84
- inventoryStaking . address ,
85
- ] ,
86
- log : true ,
52
+ const { migratorZap } = await deployMigratorZap ( {
53
+ hre,
54
+ vaultFactory : vaultFactory . address ,
55
+ positionManager : positionManager . address ,
56
+ inventoryStaking : inventoryStaking . address ,
87
57
} ) ;
88
-
89
- const isMigratorZapExcludedFromFees =
90
- await vaultFactoryContract . excludedFromFees ( migratorZap . address ) ;
91
- if ( ! isMigratorZapExcludedFromFees ) {
92
- // MigratorZap doesn't deduct fees
93
- console . log ( "Setting fee exclusion for MigratorZap in V3..." ) ;
94
- await execute (
95
- "NFTXVaultFactoryUpgradeableV3" ,
96
- { from : deployer } ,
97
- "setFeeExclusion" ,
98
- migratorZap . address ,
99
- true
100
- ) ;
101
- console . log ( "Fee exclusion set for MigratorZap in V3" ) ;
102
- }
103
-
104
- console . warn (
105
- "[NOTE!] Set fee exclusion for MigratorZap in V2 of the protocol"
106
- ) ;
107
58
} ;
108
59
export default func ;
109
60
func . tags = [ "Zaps" ] ;
0 commit comments