Skip to content

Commit c00f9eb

Browse files
authored
Merge pull request #102 from NFTX-project/upgrade
Upgrade protocol
2 parents ea4eed7 + 8eba33c commit c00f9eb

File tree

62 files changed

+4688
-2006
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+4688
-2006
lines changed

README.md

Lines changed: 20 additions & 18 deletions
Large diffs are not rendered by default.

addresses.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
{
22
"mainnet": {
33
"CreateVaultZap": "0x56dab32697B4A313f353DA0CE42B5113eD8E6f74",
4+
"DefaultProxyAdmin": "0xf8Cab5e4912e08c475033776d9472b81c1325e58",
5+
"FailSafe": "0x8665664CD32B6263A9b716371814Dc8CecFb8F2B",
46
"MarketplaceUniversalRouterZap": "0x293A0c49c85F1D8851C665Ac3cE1f1DC2a79bE3d",
57
"MigratorZap": "0x089610Fb04c34C014B4B391f4eCEFAef94E98CEc",
68
"NFTXEligibilityManager": "0x4086e98Cce041d286112d021612fD894cFed94D5",
7-
"NFTXFeeDistributorV3": "0xF4d96C5094FCD9eC24E612585e723b58F89e21fe",
9+
"NFTXFeeDistributorV3": "0x6845fF5f102bEF9D785468F0bEb535b4687406E7",
810
"NFTXInventoryStakingV3Upgradeable": "0x889f313e2a3FDC1c9a45bC6020A8a18749CD6152",
911
"NFTXRouter": "0x70A741A12262d4b5Ff45C0179c783a380EebE42a",
1012
"nftxUniversalRouter": "0x250d62a67254A46c0De472d2c9215E1d890cC90f",
@@ -19,10 +21,12 @@
1921
},
2022
"sepolia": {
2123
"CreateVaultZap": "0xD80b916470F8e79FD8d09874cb159CbB8D13d8da",
24+
"DefaultProxyAdmin": "0x36cBBb16F2FA71d4B773E9F4A11cF7FC53B13EfD",
25+
"FailSafe": "",
2226
"MarketplaceUniversalRouterZap": "0xd88a3B9D0Fb2d39ec8394CfFD983aFBB2D4a6410",
2327
"MigratorZap": "0x19762e505aF085284E287c8DAb931fb28545461f",
2428
"NFTXEligibilityManager": "0xa1ad09f8Fd789E3A940Ba9Dc5aE4D17021eF290D",
25-
"NFTXFeeDistributorV3": "0x66EF5B4b6ee05639194844CE4867515665F14fED",
29+
"NFTXFeeDistributorV3": "0x53AE38742C78EE64fC077EF840B2Aa47A7E9c603",
2630
"NFTXInventoryStakingV3Upgradeable": "0xfBFf0635f7c5327FD138E1EBa72BD9877A6a7C1C",
2731
"NFTXRouter": "0x441b7DE4340AAa5aA86dB4DA43d9Badf7B2DAA66",
2832
"nftxUniversalRouter": "0x12156cCA1958B6591CC49EaE03a5553458a4b424",
@@ -37,6 +41,8 @@
3741
},
3842
"goerli": {
3943
"CreateVaultZap": "0xc6464CC63bC20b64e1633A0293C2C9b202F4f1b6",
44+
"DefaultProxyAdmin": "0xa0d26F02D5e94C8E9ED524875D9fce36ab4838a2",
45+
"FailSafe": "",
4046
"MarketplaceUniversalRouterZap": "0x0be2D766Eef4b6a72F1fAe2e49619F013d647B8A",
4147
"MigratorZap": "0xD4B67Fe6a1258fd5e1C4dF84f3De01F62e7ac127",
4248
"NFTXEligibilityManager": "0xA4e9e286CE7A34d19f774c36844225468290C3A8",
File renamed without changes.

deploy/NFTXV3.ts

Lines changed: 37 additions & 197 deletions
Original file line numberDiff line numberDiff line change
@@ -1,216 +1,56 @@
11
import { HardhatRuntimeEnvironment, Network } from "hardhat/types";
22
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";
510

611
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
7-
const { deployments, getNamedAccounts, network } = hre;
8-
const { deploy, execute } = deployments;
12+
const { vaultFactory } = await deployVaultFactory({ hre });
913

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,
4217
});
4318

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,
5621
});
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");
6522

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,
7827
});
7928

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,
9736
});
9837

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,
10244
});
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");
13345

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,
15852
});
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");
21353
};
21454
export default func;
21555
func.tags = ["NFTXV3"];
216-
func.dependencies = ["UniV3"];
56+
func.dependencies = [];

deploy/UniV3.ts

Lines changed: 0 additions & 72 deletions
This file was deleted.

0 commit comments

Comments
 (0)