Skip to content

Commit

Permalink
V4.1 multi chain deploy (#1210)
Browse files Browse the repository at this point in the history
* multi-chain deploy for pool, registry; ownership helper; add base

* polygon deploy for registry

* swap, swap-erc20, wrapper deploys

* remaining rsk; wrapper on base

* bump package versions for publishing

* update pool, registry on goerli

* bump constants and utils
  • Loading branch information
dmosites authored Oct 10, 2023
1 parent 0d1e6bc commit d1cb17c
Show file tree
Hide file tree
Showing 38 changed files with 512 additions and 138 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ POLYGONSCAN_API_KEY=00000000000000000000000000000000
SNOWTRACE_API_KEY=00000000000000000000000000000000
ARBISCAN_API_KEY=00000000000000000000000000000000
LINEASCAN_API_KEY=00000000000000000000000000000000
BASESCAN_API_KEY=00000000000000000000000000000000
BLOCKSCOUT_API_KEY=abc
MULTISIG_OWNER=0xf8bB149F9525875Fa47B8CC632d368EB600FAba3
REPORT_GAS=true
35 changes: 35 additions & 0 deletions hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@ module.exports = {
url: apiUrls[ChainIds.LINEA] + '/' + process.env.INFURA_API_KEY,
accounts: process.env.PRIVATE_KEY ? [process.env.PRIVATE_KEY] : undefined,
},
basegoerli: {
url: apiUrls[ChainIds.BASEGOERLI],
accounts: process.env.PRIVATE_KEY ? [process.env.PRIVATE_KEY] : undefined,
},
base: {
url: apiUrls[ChainIds.BASE],
accounts: process.env.PRIVATE_KEY ? [process.env.PRIVATE_KEY] : undefined,
},
},
solidity: {
compilers: [
Expand Down Expand Up @@ -111,7 +119,10 @@ module.exports = {
polygonMumbai: process.env.POLYGONSCAN_API_KEY,
linea: process.env.LINEASCAN_API_KEY,
lineagoerli: process.env.LINEASCAN_API_KEY,
base: process.env.BASESCAN_API_KEY,
basegoerli: process.env.BASESCAN_API_KEY,
rsk: process.env.BLOCKSCOUT_API_KEY,
rsktestnet: process.env.BLOCKSCOUT_API_KEY,
},
customChains: [
{
Expand All @@ -122,6 +133,14 @@ module.exports = {
browserURL: explorerUrls[ChainIds.RSK],
},
},
{
network: 'rsktestnet',
chainId: 31,
urls: {
apiURL: explorerApiUrls[ChainIds.RSKTESTNET],
browserURL: explorerUrls[ChainIds.RSKTESTNET],
},
},
{
network: 'linea',
chainId: 59144,
Expand All @@ -138,6 +157,22 @@ module.exports = {
browserURL: explorerUrls[ChainIds.LINEAGOERLI],
},
},
{
network: 'base',
chainId: 8453,
urls: {
apiURL: explorerApiUrls[ChainIds.BASE],
browserURL: explorerUrls[ChainIds.BASE],
},
},
{
network: 'basegoerli',
chainId: 84531,
urls: {
apiURL: explorerApiUrls[ChainIds.BASEGOERLI],
browserURL: explorerUrls[ChainIds.BASEGOERLI],
},
},
{
network: 'arbitrumGoerli',
chainId: 421613,
Expand Down
4 changes: 2 additions & 2 deletions source/balances/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
"@openzeppelin/contracts": "^4.8.3"
},
"devDependencies": {
"@airswap/constants": "^4.1.0",
"@airswap/utils": "^4.1.3",
"@airswap/constants": "^4.1.1",
"@airswap/utils": "^4.1.4",
"prompt-confirm": "^2.0.4"
},
"publishConfig": {
Expand Down
16 changes: 15 additions & 1 deletion source/pool/deploys-blocks.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
module.exports = {
1: 18262813,
5: 9774330,
5: 9838499,
30: 5709706,
31: 4368347,
56: 32421270,
97: 34021042,
137: 48475105,
8453: 4991925,
42161: 138719068,
43113: 26588390,
43114: 36195383,
59140: 1680152,
59144: 588294,
80001: 40970461,
84531: 10788756,
421613: 46251592,
}
16 changes: 15 additions & 1 deletion source/pool/deploys.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
module.exports = {
1: '0xEEcD248D977Fd4D392915b4AdeF8154BA3aE9c02',
5: '0xa55CDCe4F6300D57831b2792c45E55a899D8e2a4',
5: '0xEEcD248D977Fd4D392915b4AdeF8154BA3aE9c02',
30: '0xEEcD248D977Fd4D392915b4AdeF8154BA3aE9c02',
31: '0xEEcD248D977Fd4D392915b4AdeF8154BA3aE9c02',
56: '0xEEcD248D977Fd4D392915b4AdeF8154BA3aE9c02',
97: '0xEEcD248D977Fd4D392915b4AdeF8154BA3aE9c02',
137: '0xEEcD248D977Fd4D392915b4AdeF8154BA3aE9c02',
8453: '0xEEcD248D977Fd4D392915b4AdeF8154BA3aE9c02',
42161: '0xEEcD248D977Fd4D392915b4AdeF8154BA3aE9c02',
43113: '0xEEcD248D977Fd4D392915b4AdeF8154BA3aE9c02',
43114: '0xEEcD248D977Fd4D392915b4AdeF8154BA3aE9c02',
59140: '0xEEcD248D977Fd4D392915b4AdeF8154BA3aE9c02',
59144: '0xEEcD248D977Fd4D392915b4AdeF8154BA3aE9c02',
80001: '0xEEcD248D977Fd4D392915b4AdeF8154BA3aE9c02',
84531: '0xEEcD248D977Fd4D392915b4AdeF8154BA3aE9c02',
421613: '0xEEcD248D977Fd4D392915b4AdeF8154BA3aE9c02',
}
9 changes: 5 additions & 4 deletions source/pool/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@airswap/pool",
"version": "4.1.0",
"version": "4.1.1",
"description": "AirSwap: Withdrawable Token Pool",
"license": "MIT",
"repository": {
Expand All @@ -22,15 +22,16 @@
"test": "hardhat test",
"test:ci": "hardhat test",
"deploy": "hardhat run ./scripts/deploy.js",
"verify": "hardhat run ./scripts/verify.js"
"verify": "hardhat run ./scripts/verify.js",
"ownership": "hardhat run ./scripts/ownership.js"
},
"dependencies": {
"@openzeppelin/contracts": "^4.8.3"
},
"devDependencies": {
"@airswap/constants": "^4.1.0",
"@airswap/constants": "^4.1.1",
"@airswap/types": "^4.1.1",
"@airswap/utils": "^4.1.3",
"@airswap/utils": "^4.1.4",
"prompt-confirm": "^2.0.4"
},
"publishConfig": {
Expand Down
4 changes: 3 additions & 1 deletion source/pool/scripts/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ async function main() {
const prompt = new Confirm('Proceed to deploy?')
if (await prompt.run()) {
const poolFactory = await ethers.getContractFactory('Pool')
const poolContract = await poolFactory.deploy(scale, max)
const poolContract = await poolFactory.deploy(scale, max, {
gasPrice,
})
console.log(
'Deploying...',
getReceiptUrl(chainId, poolContract.deployTransaction.hash)
Expand Down
53 changes: 53 additions & 0 deletions source/pool/scripts/ownership.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/* eslint-disable no-console */
const Confirm = require('prompt-confirm')
const { ethers } = require('hardhat')
const { Pool__factory } = require('@airswap/pool/typechain/factories/contracts')
const { chainNames, ChainIds, ownerAddresses } = require('@airswap/constants')
const { getReceiptUrl } = require('@airswap/utils')
const poolDeploys = require('../deploys.js')

async function main() {
const [deployer] = await ethers.getSigners()
const gasPrice = await deployer.getGasPrice()
const chainId = await deployer.getChainId()
if (chainId === ChainIds.HARDHAT) {
console.log('Value for --network flag is required')
return
}
console.log(`Deployer: ${deployer.address}`)
console.log(`Network: ${chainNames[chainId].toUpperCase()}\n`)

if (!poolDeploys[chainId]) {
console.log(`✘ No deploy found for selected network.\n`)
process.exit(0)
}

const contract = Pool__factory.connect(poolDeploys[chainId], deployer)
const currentOwner = await contract.owner()

console.log(`Current owner: ${currentOwner}`)
console.log(`Intended owner: ${ownerAddresses[chainId] || 'Not set'}`)

if (currentOwner === ownerAddresses[chainId]) {
console.log(`\n✔ Owner matches intended owner.\n`)
} else if (!ownerAddresses[chainId]) {
console.log(`\n✘ Intended owner must be set.\n`)
} else if (deployer.address !== currentOwner) {
console.log(`\n✘ Deployer does not match current owner.\n`)
} else {
console.log(`\n✘ Current owner does not match intended owner.\n`)
console.log(`Gas price: ${gasPrice / 10 ** 9} gwei\n`)
const prompt = new Confirm(`Update owner to intended?`)
if (await prompt.run()) {
const tx = contract.transferOwnership(ownerAddresses[chainId])
console.log('Updating...', getReceiptUrl(chainId, tx.hash))
}
}
}

main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error)
process.exit(1)
})
16 changes: 15 additions & 1 deletion source/registry/deploys-blocks.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
module.exports = {
1: 18262901,
5: 9774339,
5: 9838505,
30: 5709710,
31: 4368351,
56: 32426789,
97: 34026519,
137: 48480674,
8453: 4993843,
42161: 138763545,
43113: 26588430,
43114: 36195417,
59140: 1681257,
59144: 589314,
80001: 40977305,
84531: 10791692,
421613: 46289808,
}
16 changes: 15 additions & 1 deletion source/registry/deploys.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
module.exports = {
1: '0x339Eb75235CBf823C6352D529A258226ecF59cfF',
5: '0x33Cded9D1C082AA57439FB7a6784913321e17316',
5: '0x339Eb75235CBf823C6352D529A258226ecF59cfF',
30: '0x339Eb75235CBf823C6352D529A258226ecF59cfF',
31: '0x339Eb75235CBf823C6352D529A258226ecF59cfF',
56: '0x339Eb75235CBf823C6352D529A258226ecF59cfF',
97: '0x339Eb75235CBf823C6352D529A258226ecF59cfF',
137: '0x339Eb75235CBf823C6352D529A258226ecF59cfF',
8453: '0x339Eb75235CBf823C6352D529A258226ecF59cfF',
42161: '0x339Eb75235CBf823C6352D529A258226ecF59cfF',
43113: '0x339Eb75235CBf823C6352D529A258226ecF59cfF',
43114: '0x339Eb75235CBf823C6352D529A258226ecF59cfF',
59140: '0x339Eb75235CBf823C6352D529A258226ecF59cfF',
59144: '0x339Eb75235CBf823C6352D529A258226ecF59cfF',
80001: '0x339Eb75235CBf823C6352D529A258226ecF59cfF',
84531: '0x339Eb75235CBf823C6352D529A258226ecF59cfF',
421613: '0x339Eb75235CBf823C6352D529A258226ecF59cfF',
}
6 changes: 3 additions & 3 deletions source/registry/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@airswap/registry",
"version": "4.1.0",
"version": "4.1.1",
"description": "AirSwap: Server URL Registry",
"license": "MIT",
"repository": {
Expand Down Expand Up @@ -31,8 +31,8 @@
"access": "public"
},
"devDependencies": {
"@airswap/constants": "^4.1.0",
"@airswap/utils": "^4.1.3",
"@airswap/constants": "^4.1.1",
"@airswap/utils": "^4.1.4",
"prompt-confirm": "^2.0.4"
}
}
12 changes: 8 additions & 4 deletions source/registry/scripts/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const {
chainLabels,
chainNames,
stakingTokenAddresses,
ADDRESS_ZERO,
} = require('@airswap/constants')
const { getReceiptUrl } = require('@airswap/utils')
const registryDeploys = require('../deploys.js')
Expand All @@ -28,9 +29,9 @@ async function main() {
console.log(`Network: ${chainNames[chainId].toUpperCase()}`)
console.log(`Gas price: ${gasPrice / 10 ** 9} gwei\n`)

const stakingToken = stakingTokenAddresses[chainId]
const stakingCost = 1000000000
const supportCost = 1000000
const stakingToken = stakingTokenAddresses[chainId] || ADDRESS_ZERO
const stakingCost = 0
const supportCost = 0

console.log(`\nstakingToken: ${stakingToken}`)
console.log(`stakingCost: ${stakingCost}`)
Expand All @@ -42,7 +43,10 @@ async function main() {
const registryContract = await registryFactory.deploy(
stakingToken,
stakingCost,
supportCost
supportCost,
{
gasPrice,
}
)
console.log(
'Deploying...',
Expand Down
12 changes: 8 additions & 4 deletions source/registry/scripts/verify.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
/* eslint-disable no-console */
const { ethers, run } = require('hardhat')
const registryDeploys = require('../deploys.js')
const { chainNames, stakingTokenAddresses } = require('@airswap/constants')
const {
chainNames,
stakingTokenAddresses,
ADDRESS_ZERO,
} = require('@airswap/constants')

async function main() {
await run('compile')
const [deployer] = await ethers.getSigners()
console.log(`Deployer: ${deployer.address}`)

const chainId = await deployer.getChainId()
const stakingToken = stakingTokenAddresses[chainId]
const stakingCost = 1000000000
const supportCost = 1000000
const stakingToken = stakingTokenAddresses[chainId] || ADDRESS_ZERO
const stakingCost = 0
const supportCost = 0

console.log(`Verifying on ${chainNames[chainId].toUpperCase()}`)
await run('verify:verify', {
Expand Down
2 changes: 1 addition & 1 deletion source/staking/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"access": "public"
},
"devDependencies": {
"@airswap/utils": "^4.1.3",
"@airswap/utils": "^4.1.4",
"prompt-confirm": "^2.0.4"
}
}
18 changes: 16 additions & 2 deletions source/swap-erc20/deploys-blocks.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
module.exports = {
1: 18262981,
5: 9775062,
1: 18313788,
5: 9836907,
30: 5709868,
31: 4368360,
56: 32456402,
97: 34057585,
137: 48518111,
8453: 5043516,
42161: 139083040,
43113: 26625815,
43114: 36240432,
59140: 1688890,
59144: 596970,
80001: 41015710,
84531: 10838615,
421613: 46573263,
}
18 changes: 16 additions & 2 deletions source/swap-erc20/deploys.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
module.exports = {
1: '0x0A655E762238Fee539338F433087A3B9dAdD798b',
5: '0x1E6EBD18B5Ee1C31DcB3fc6AD23f32a35a8FF8e4',
1: '0xE2d2e134d61Cd1e7338ea184FB5c1224a23F5A56',
5: '0xE2d2e134d61Cd1e7338ea184FB5c1224a23F5A56',
30: '0xE2d2e134d61Cd1e7338ea184FB5c1224a23F5A56',
31: '0xE2d2e134d61Cd1e7338ea184FB5c1224a23F5A56',
56: '0xE2d2e134d61Cd1e7338ea184FB5c1224a23F5A56',
97: '0xE2d2e134d61Cd1e7338ea184FB5c1224a23F5A56',
137: '0xE2d2e134d61Cd1e7338ea184FB5c1224a23F5A56',
8453: '0xE2d2e134d61Cd1e7338ea184FB5c1224a23F5A56',
42161: '0xE2d2e134d61Cd1e7338ea184FB5c1224a23F5A56',
43113: '0xE2d2e134d61Cd1e7338ea184FB5c1224a23F5A56',
43114: '0xE2d2e134d61Cd1e7338ea184FB5c1224a23F5A56',
59140: '0xE2d2e134d61Cd1e7338ea184FB5c1224a23F5A56',
59144: '0xE2d2e134d61Cd1e7338ea184FB5c1224a23F5A56',
80001: '0xE2d2e134d61Cd1e7338ea184FB5c1224a23F5A56',
84531: '0xE2d2e134d61Cd1e7338ea184FB5c1224a23F5A56',
421613: '0xE2d2e134d61Cd1e7338ea184FB5c1224a23F5A56',
}
Loading

0 comments on commit d1cb17c

Please sign in to comment.