Skip to content

Commit

Permalink
v3.1 deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
YouStillAlive committed Dec 10, 2024
1 parent e3f35fa commit a6e8f96
Show file tree
Hide file tree
Showing 16 changed files with 13,282 additions and 11,363 deletions.
8 changes: 2 additions & 6 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const config: HardhatUserConfig = {
enabled: true,
runs: 200,
},
viaIR: true,
},
},
networks: {
Expand Down Expand Up @@ -82,20 +83,15 @@ const config: HardhatUserConfig = {
},
dependencyCompiler: {
paths: [
'@poolzfinance/collateral-provider/contracts/CollateralProvider.sol',
'@poolzfinance/refund-provider/contracts/RefundProvider.sol',
'@poolzfinance/lockdeal-nft/contracts/LockDealNFT/LockDealNFT.sol',
'@poolzfinance/lockdeal-nft/contracts/SimpleProviders/DealProvider/DealProvider.sol',
'@poolzfinance/lockdeal-nft/contracts/SimpleProviders/LockProvider/LockDealProvider.sol',
'@poolzfinance/lockdeal-nft/contracts/SimpleProviders/TimedDealProvider/TimedDealProvider.sol',
'@poolzfinance/builders/contracts/SimpleBuilder/SimpleBuilder.sol',
'@poolzfinance/builders/contracts/SimpleRefundBuilder/SimpleRefundBuilder.sol',
'@poolzfinance/vault-manager/contracts/VaultManager/VaultManager.sol',
'@poolzfinance/vault-manager/contracts/test/ERC20Token.sol',
'@poolzfinance/dispenser-provider/contracts/DispenserProvider.sol',
'@poolzfinance/invest-provider/contracts/InvestProvider.sol',
'@poolzfinance/whitelist/contracts/WhiteList.sol',
'@poolzfinance/whitelist-router/contracts/WhiteListRouter.sol',
'@poolzfinance/invest-provider/contracts/InvestProvider.sol'
],
}
}
Expand Down
24,330 changes: 13,232 additions & 11,098 deletions package-lock.json

Large diffs are not rendered by default.

10 changes: 3 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,10 @@
"@ironblocks/firewall-consumer": "^1.0.13",
"@openzeppelin/contracts": "^5.0.2",
"@poolzfinance/builders": "1.2.2",
"@poolzfinance/collateral-provider": "^1.0.3",
"@poolzfinance/dispenser-provider": "^1.0.0",
"@poolzfinance/invest-provider": "^1.0.0",
"@poolzfinance/dispenser-provider": "^1.0.3",
"@poolzfinance/invest-provider": "^1.0.1",
"@poolzfinance/lockdeal-nft": "^1.0.4",
"@poolzfinance/poolz-helper-v2": "^3.0.0",
"@poolzfinance/refund-provider": "^1.0.3",
"@poolzfinance/vault-manager": "^1.0.0",
"@poolzfinance/whitelist": "^1.0.0",
"@poolzfinance/whitelist-router": "^1.0.0"
"@poolzfinance/vault-manager": "^1.0.0"
}
}
26 changes: 5 additions & 21 deletions scripts/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ import {
DealProvider,
LockDealProvider,
TimedDealProvider,
CollateralProvider,
RefundProvider,
VaultManager,
SimpleBuilder,
SimpleRefundBuilder
DispenserProvider
} from "../typechain-types"
import { deploy } from "./utility/deployment"

Expand All @@ -26,34 +24,20 @@ async function deployAllContracts(baseURI: string = "") {
// Deploy TimedDealProvider contract
const timedDealProvider: TimedDealProvider = await deploy("TimedDealProvider", lockDealNFT.address, lockProvider.address)

// Deploy CollateralProvider contract
const collateralProvider: CollateralProvider = await deploy(
"CollateralProvider",
lockDealNFT.address,
dealProvider.address
)

// Deploy RefundProvider contract
const refundProvider: RefundProvider = await deploy(
"RefundProvider",
lockDealNFT.address,
collateralProvider.address
)

// Deploy Buiders
const simpleBuilder: SimpleBuilder = await deploy("SimpleBuilder", lockDealNFT.address)
const simpleRefundBuilder: SimpleRefundBuilder = await deploy("SimpleRefundBuilder", lockDealNFT.address, refundProvider.address, collateralProvider.address)

// Deploy DispenserProvider
const dispenserProvider: DispenserProvider = await deploy("DispenserProvider", lockDealNFT.address)

let tx = await vaultManager.setTrustee(lockDealNFT.address)
await tx.wait()
await setApprovedContracts(lockDealNFT, [
dealProvider.address,
lockProvider.address,
timedDealProvider.address,
collateralProvider.address,
refundProvider.address,
simpleBuilder.address,
simpleRefundBuilder.address,
dispenserProvider.address
])
}

Expand Down
28 changes: 12 additions & 16 deletions scripts/terminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,23 @@ import { getMenu } from "./utility/deployment/input"
import {
deployVaultAndLockDealNFT,
deploySimpleProviders,
deployRefundProvider,
deployRefundAndCollateral,
deployBuilders,
deployAllContracts,
deployLightMigrator,
deployDelayProviderAndMigrator,
deployWithoutRefund
deployWithoutDispenser,
deployDispenser
} from "./utility/deployment/execute"

const scriptPaths = [
"withoutRefund.ts",
"VaultAndLockDealNFT.ts",
"SimpleProviders.ts",
"RefundProvider.ts",
"RefundAndCollateral.ts",
"Builders.ts",
"LightMigrator.ts",
"DelayVaultProvider.ts"
"DelayVaultProvider.ts",
"DispenserProvider.ts",
"WithoutDispenser.ts",
]

const menuItems = [
Expand All @@ -39,28 +38,25 @@ async function displayMenu() {
await deployAllContracts()
break
case menuItems[1].name:
await deployWithoutRefund()
await deployVaultAndLockDealNFT()
break
case menuItems[2].name:
await deployVaultAndLockDealNFT()
await deploySimpleProviders()
break
case menuItems[3].name:
await deploySimpleProviders()
await deployBuilders()
break
case menuItems[4].name:
await deployRefundProvider()
await deployLightMigrator()
break
case menuItems[5].name:
await deployRefundAndCollateral()
await deployDelayProviderAndMigrator()
break
case menuItems[6].name:
await deployBuilders()
await deployDispenser()
break
case menuItems[7].name:
await deployLightMigrator()
break
case menuItems[8].name:
await deployDelayProviderAndMigrator()
await deployWithoutDispenser()
break
default:
// Exit the loop if an invalid option is selected
Expand Down
26 changes: 3 additions & 23 deletions scripts/testnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,12 @@ import {
DealProvider,
LockDealProvider,
TimedDealProvider,
CollateralProvider,
RefundProvider,
SimpleBuilder,
SimpleRefundBuilder,
ERC20Token,
} from "../typechain-types"
import { deployFrom } from "./utility/deployment"
import { setTrustee, approveContracts, createNewVault, approveToken } from "./utility/manageable"
import { createSimpleNFT, createRefundNFT } from "./utility/creation"
import { createSimpleNFT } from "./utility/creation"
import {
amount,
startTime,
Expand All @@ -23,17 +20,14 @@ import {
v1DelayVaultTestnet
} from "./utility/constants"
import { _withdrawPools, _splitPools } from "./utility/control"
import { createMassSimplePools, createMassRefundPools } from "./utility/builders"
import { createMassSimplePools } from "./utility/builders"

let vaultManager: VaultManager,
lockDealNFT: LockDealNFT,
dealProvider: DealProvider,
lockProvider: LockDealProvider,
timedProvider: TimedDealProvider,
collateralProvider: CollateralProvider,
refundProvider: RefundProvider,
simpleBuilder: SimpleBuilder,
simpleRefundBuilder: SimpleRefundBuilder,
token: ERC20Token,
mainCoin: ERC20Token

Expand All @@ -46,7 +40,6 @@ async function main() {
await splitPools(user, ids)
await withdrawPools(user, ids)
await createMassSimplePools(user, simpleBuilder, vaultManager, dealProvider.address, token)
await createMassRefundPools(user, simpleRefundBuilder, vaultManager, dealProvider.address, token, mainCoin)
} catch (error) {
console.error("Error in main:", error)
}
Expand All @@ -58,16 +51,7 @@ async function deploy(user: Wallet) {
dealProvider = await deployFrom("DealProvider", user, lockDealNFT.address)
lockProvider = await deployFrom("LockDealProvider", user, lockDealNFT.address, dealProvider.address)
timedProvider = await deployFrom("TimedDealProvider", user, lockDealNFT.address, lockProvider.address)
collateralProvider = await deployFrom("CollateralProvider", user, lockDealNFT.address, dealProvider.address)
refundProvider = await deployFrom("RefundProvider", user, lockDealNFT.address, collateralProvider.address)
simpleBuilder = await deployFrom("SimpleBuilder", user, lockDealNFT.address)
simpleRefundBuilder = await deployFrom(
"SimpleRefundBuilder",
user,
lockDealNFT.address,
refundProvider.address,
collateralProvider.address
)
token = await deployFrom("ERC20Token", user, "Test Token", "TT")
mainCoin = await deployFrom("ERC20Token", user, "USDT", "TT")
}
Expand All @@ -78,10 +62,7 @@ async function setup(user: Wallet) {
dealProvider,
lockProvider,
timedProvider,
collateralProvider,
refundProvider,
simpleBuilder,
simpleRefundBuilder
simpleBuilder
])
await createNewVault(vaultManager, user, token)
await createNewVault(vaultManager, user, mainCoin)
Expand All @@ -95,7 +76,6 @@ async function createPools(user: Wallet): Promise<number[]> {
await createSimpleNFT(user, dealProvider, vaultManager, token, [amount])
await createSimpleNFT(user, lockProvider, vaultManager, token, [amount, startTime])
await createSimpleNFT(user, timedProvider, vaultManager, token, [amount, startTime, finishTime])
await createRefundNFT(user, refundProvider, timedProvider, vaultManager, token, mainCoin)
// IDs are always [id, id + 1...] every time the script is run
return [id, id + 1, id + 2, id + 3]
}
Expand Down
29 changes: 2 additions & 27 deletions scripts/utility/builders.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SimpleBuilder, SimpleRefundBuilder, ERC20Token, VaultManager } from "../../typechain-types"
import { SimpleBuilder, ERC20Token, VaultManager } from "../../typechain-types"
import { BuilderState } from "../../typechain-types/contracts/LockDealNFT/contracts/Builders/SimpleBuilder/SimpleBuilder"
import { gasLimit, gasPrice, amount, finishTime } from "./constants"
import { getSignature } from "./creation"
Expand Down Expand Up @@ -40,29 +40,4 @@ export async function createMassSimplePools(
)
await tx.wait()
console.log("Mass simple NFTs created")
}

export async function createMassRefundPools(
user: Wallet,
simpleRefundBuilder: SimpleRefundBuilder,
vaultManager: VaultManager,
provider: string,
token: ERC20Token,
mainCoin: ERC20Token
) {
const tx = await simpleRefundBuilder
.connect(user)
.buildMassPools(
[provider, token.address, mainCoin.address],
sendData,
[[amount.mul(3), finishTime], []],
getSignature(user, vaultManager, token, token.address, amount.mul(9)),
getSignature(user, vaultManager, token, mainCoin.address, amount.mul(3)),
{
gasLimit,
gasPrice,
}
)
await tx.wait()
console.log("Mass refund NFTs created")
}
}
24 changes: 2 additions & 22 deletions scripts/utility/creation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ import {
DealProvider,
LockDealProvider,
TimedDealProvider,
RefundProvider,
VaultManager,
ERC20Token,
} from "../../typechain-types"
import { Wallet, BigNumber } from "ethers"
import { ethers } from "hardhat"
import { gasLimit, gasPrice, startTime, finishTime, amount } from "./constants"
import { gasLimit, gasPrice, amount } from "./constants"

async function createSimpleNFT(
user: Wallet,
Expand All @@ -30,25 +29,6 @@ async function createSimpleNFT(
console.log(name + ` NFT created`)
}

async function createRefundNFT(
user: Wallet,
refundProvider: RefundProvider,
provider: DealProvider | LockDealProvider | TimedDealProvider,
vaultManager: VaultManager,
token: ERC20Token,
mainCoin: ERC20Token
) {
const name = await refundProvider.name()
const tokenSignature = await getSignature(user, vaultManager, token, token.address)
const mainCoinsignature = await getSignature(user, vaultManager, token, mainCoin.address)
const addresses = [user.address, token.address, mainCoin.address, provider.address]
const params = [amount, startTime, finishTime, amount, finishTime]
const tx = await refundProvider
.connect(user)
.createNewRefundPool(addresses, params, tokenSignature, mainCoinsignature, { gasLimit, gasPrice })
await tx.wait()
console.log(name + ` NFT created`)
}

async function getSignature(
user: Wallet,
Expand All @@ -66,4 +46,4 @@ async function getSignature(
return await user.signMessage(ethers.utils.arrayify(hash))
}

export { createSimpleNFT, createRefundNFT, getSignature }
export { createSimpleNFT, getSignature }
11 changes: 2 additions & 9 deletions scripts/utility/deployment/Builders.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
import { deploy } from "../deployment"

export async function deployBuilders(
lockDealNFT: string,
refundProvider: string,
collateralProvider: string
) {
export async function deployBuilder(lockDealNFT: string) {
await deploy("SimpleBuilder", lockDealNFT)
await deploy("SimpleRefundBuilder", lockDealNFT, refundProvider, collateralProvider)
}

const lockDealNFT = process.env.LOCK_DEAL_NFT_ADDRESS || ""
const refundProvider = process.env.REFUND_PROVIDER_ADDRESS || ""
const collateralProvider = process.env.COLLATERAL_PROVIDER_ADDRESS || ""

deployBuilders(lockDealNFT, refundProvider, collateralProvider)
deployBuilder(lockDealNFT)
9 changes: 9 additions & 0 deletions scripts/utility/deployment/DispenserProvider.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { deploy } from "../deployment"

export async function deployDispenser(lockDealNFT: string) {
await deploy("DispenserProvider", lockDealNFT)
}

const lockDealNFT = process.env.LOCK_DEAL_NFT_ADDRESS || ""

deployDispenser(lockDealNFT)
13 changes: 0 additions & 13 deletions scripts/utility/deployment/RefundAndCollateral.ts

This file was deleted.

11 changes: 0 additions & 11 deletions scripts/utility/deployment/RefundProvider.ts

This file was deleted.

Loading

0 comments on commit a6e8f96

Please sign in to comment.