Skip to content

Commit

Permalink
feat(governance): deploy swap purchaser to base network (#13177)
Browse files Browse the repository at this point in the history
* release task support any contract

* release `UnlockSwapPurchaser` into contracts package

* export purchaser abi correctly

* fix release json artifact

* update swapper deploy script

* add base unsiwap router addresses

* add swapper address to networks package
  • Loading branch information
clemsos authored and julien51 committed Jan 7, 2024
1 parent 2439e91 commit e7d264a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 17 deletions.
36 changes: 19 additions & 17 deletions governance/scripts/deployments/swapper.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
const { ethers, unlock, run } = require('hardhat')
const { ethers, run } = require('hardhat')
const { PERMIT2_ADDRESS } = require('@uniswap/universal-router-sdk')
const { getUniswapRouters } = require('../../test/helpers')
const {
uniswapRouterAddresses,
getNetwork,
} = require('@unlock-protocol/hardhat-helpers')
const { UnlockSwapPurchaser } = require('@unlock-protocol/contracts')

async function main() {
const [deployer] = await ethers.getSigners()

// fetch chain info
const chainId = await deployer.getChainId()
const { unlockAddress } = unlock.networks[chainId]
const { unlockAddress, id: chainId } = await getNetwork()

const routers = Object.values(uniswapRouterAddresses[chainId])
console.log(`Deploying Swapper to ${chainId}
- unlockAddress: ${unlockAddress}
- PERMIT2_ADDRESS : ${PERMIT2_ADDRESS}
- routers: ${routers}`)

const routers = getUniswapRouters(chainId)
if (!routers.length) {
console.log('Uniswap undefined for this network')
return
Expand All @@ -18,23 +24,19 @@ async function main() {
console.log(
`Deploying UnlockSwapPurchaser on chain ${chainId} (unlock: ${unlockAddress}, permit2: ${PERMIT2_ADDRESS}, routers: ${routers.toString()}) `
)
const UnlockSwapPurchaser = await ethers.getContractFactory(
'UnlockSwapPurchaser'
const Swapper = await ethers.getContractFactory(
UnlockSwapPurchaser.abi,
UnlockSwapPurchaser.bytecode
)

const swapper = await UnlockSwapPurchaser.deploy(
unlockAddress,
PERMIT2_ADDRESS,
routers
)
const swapper = await Swapper.deploy(unlockAddress, PERMIT2_ADDRESS, routers)
console.log(` swapper deployed at ${swapper.address}`)

if (chainId !== 31337) {
console.log(` waiting for tx to be mined for contract verification...`)
await swapper.deployTransaction.wait(5)

await swapper.waitForDeployment(5)
await run('verify:verify', {
address: swapper.address,
address: await swapper.getAddress(),
constructorArguments: [unlockAddress, PERMIT2_ADDRESS, routers],
})
}
Expand Down
4 changes: 4 additions & 0 deletions packages/hardhat-helpers/src/uniswap.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ const getUniswapTokens = async (chainId = 1) => {
}

const routerAddresses = {
8453: {
SwapRouter02: '0x2626664c2603336E57B271c5C0b26F421741e481',
UniversalRouter: '0x198EF79F1F515F02dFE9e3115eD9fC07183f02fC',
},
421613: {
UniversalRouter: '0x4648a43B2C14Da09FdF82B161150d3F634f40491',
UnsupportedProtocol: '0x5302086A3a25d473aAbBd0356eFf8Dd811a4d89B',
Expand Down
1 change: 1 addition & 0 deletions packages/networks/src/networks/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export const base: NetworkConfig = {
networkName: 'base',
studioEndpoint: 'unlock-protocol-base',
},
swapPurchaser: '0x70B3c9Dd9788570FAAb24B92c3a57d99f8186Cc7',
tokens: [
{
address: '0x50c5725949a6f0c72e6c4a641f24049a917db0cb',
Expand Down

0 comments on commit e7d264a

Please sign in to comment.