Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(gov): proposal to set swap burner on mainnet and polygon #15092

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
184 changes: 184 additions & 0 deletions governance/proposals/up/005-set-udt-swap-burner.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
/**
* This proposal send calls accross the bridge to set swap burner
* in Unlock on Arbitrum, Base, and Optimism.
*/
const { getNetwork } = require('@unlock-protocol/hardhat-helpers')
const { Unlock } = require('@unlock-protocol/contracts')
const { parseSafeMulticall, getProvider } = require('../../helpers/multisig')
const { ethers } = require('hardhat')
const { Contract } = require('ethers')
const { parseBridgeCall } = require('../../helpers/crossChain')

const swapBurnerAddresses = {
1: '', // mainnet
137: '0x52690873b22B0949A3A2c1AaD22653218460A002', // polygon
}

const targetChainsIds = Object.keys(swapBurnerAddresses)

const parseCalls = async (destChainId) => {
const { unlockAddress, unlockDaoToken, nativeCurrency, explorer } =
await getNetwork(destChainId)
const swapBurnerAddress = swapBurnerAddresses[destChainId]
if (!unlockDaoToken) {
throw new Error(`No unlockDaoToken for chain ${destChainId}`)
}
const provider = await getProvider(destChainId)

// get Unlock interface
const unlock = new Contract(unlockAddress, Unlock.abi, provider)

if (BigInt(destChainId) !== (await unlock.chainId())) {
throw new Error(
`Mismatch btw ${destChainId} and Unlock settings ${await unlock.chainId()}`
)
}

// parse config args
const estimatedGasForPurchase = 200000n
const configUnlockArgs = [
unlockDaoToken.address,
nativeCurrency.wrapped,
estimatedGasForPurchase,
await unlock.globalTokenSymbol(),
await unlock.globalBaseTokenURI(),
await unlock.chainId(),
]

console.log(configUnlockArgs)

const calls = [
{
contractAddress: unlockAddress,
calldata: unlock.interface.encodeFunctionData('setSwapBurner', [
swapBurnerAddress,
]),
value: 0,
operation: 1,
},
{
contractAddress: unlockAddress,
calldata: unlock.interface.encodeFunctionData(
'configUnlock',
configUnlockArgs
),
value: 0,
operation: 1,
},
]

// parse multicall
const { to, data, value, operation } = await parseSafeMulticall({
chainId: destChainId,
calls,
})

// encode multicall instructions to be executed by the SAFE
const abiCoder = ethers.AbiCoder.defaultAbiCoder()
const moduleData = abiCoder.encode(
['address', 'uint256', 'bytes', 'bool'],
[
to, // to
value, // value
data, // data
operation, // operation: 0 for CALL, 1 for DELEGATECALL
]
)

const configUnlockKeys = [
'_udt',
'_weth',
'_estimatedGasForPurchase',
'_symbol',
'_URI',
'_chainId',
]

const explainer = `Changes sent to the Unlock contract at ${unlockAddress}

1. call \`configUnlock\` with the following parameters

${configUnlockArgs
.map((val, i) => ` - ${configUnlockKeys[i]}: ${val}`)
.join('\n')}

2. call \`setSwapBurner(${swapBurnerAddress})\` and set the [SwapBurner](${explorer.urls.address(
swapBurnerAddress
)}) contract
`

return { moduleData, explainer }
}

module.exports = async () => {
const explainers = []
const targetChains = await Promise.all(
targetChainsIds.map((id) => getNetwork(id))
)

// get setProtocolFee call data for dest chains
const calls = []
for (let i in targetChains) {
const { name, id: chainId } = targetChains[i]
console.log(`Parsing for chain ${name} (${chainId})`)
const { moduleData, explainer } = await parseCalls(chainId)
const bridgedCall = await parseBridgeCall({
destChainId: chainId,
moduleData,
})
calls.push(bridgedCall)
explainers.push({
name,
id: chainId,
explainer: explainer,
})
}

console.log({ explainers, calls })

// parse proposal
const title = `Set UDT and SwapBurner in Unlock contract on Mainnet and Polygon`

const proposalName = `${title}

## Goal of the proposal

This proposal sets 1) the UDT address and 2) the Swap Burner contract address in the main Unlock factory contract on the following chains: ${targetChains
.map(({ name }) => name)
.toString()}.

## About this proposal

Now that UDT has been bridged, the new address has to be set in the main Unlock contract for the tokens to be distributed or swap/burned. For that, we call the \`configUnlock\` function with the bridge UDT address as a parameter (keeping other parameters untouched).

A \`SwapBurner\` helper contract has been deployed on all three chains and will be added as setting to the main Unlock contract. This will enable the “swap and burn” feature of fees collected by the protocol on these chains, following the deployment of bridged versions of UDT there.
ccarfi marked this conversation as resolved.
Show resolved Hide resolved

## How it works

The proposal uses a cross-chain proposal pattern that, once passed, will send the calls to multiple chains at once. This pattern has been introduced and tested in a [previous proposal](https://www.tally.xyz/gov/unlock/proposal/1926572528290918174819693611122933562560576845671089759587616947457423587439).

## The calls

This DAO proposal contains ${calls.length} calls:

${explainers
.map(
({ name, id, explainer: exp }) => `### ${name} (${id}) 1 call

${exp}
`
)
.join('\n\n')}


The Unlock Protocol Team
`
console.log(proposalName)
console.log(calls)

// send to multisig / DAO
return {
proposalName,
calls,
}
}
2 changes: 1 addition & 1 deletion governance/scripts/deployments/swapBurner.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { PERMIT2_ADDRESS } = require('@uniswap/universal-router-sdk')
const {
getNetwork,
PERMIT2_ADDRESS,
deployContract,
copyAndBuildContractsAtVersion,
} = require('@unlock-protocol/hardhat-helpers')
Expand Down
12 changes: 12 additions & 0 deletions packages/networks/src/networks/zksync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,18 @@ export const zksync: NetworkConfig = {
symbol: 'WBTC',
},
],
uniswapV3: {
factoryAddress: '0x8FdA5a7a8dCA67BBcDd10F02Fa0649A937215422',
oracle: {
// TODO: deploy oracles
// 100: '0x92C9b3A4FFD7D2046132732FedC9f9f25E316F0B',
// 3000: '0x584c5af22DB79a13F4Fb45c66E0ff2311D58d9B2',
// 500: '0x2e5F6B31d100C527B782e26953D9509C591aC41d',
},
positionManager: '0x0616e5762c1E7Dc3723c50663dF10a162D690a86',
quoterAddress: '0x8Cb537fc92E26d8EBBb760E632c95484b6Ea3e28',
universalRouterAddress: '0x28731BCC616B5f51dD52CF2e4dF0E78dD1136C06',
},
unlockAddress: '0x32CF553582159F12fBb1Ae1649b3670395610F24',
url: 'https://zksync.io/',
}
Expand Down
Loading