Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(governance): bridge UDT on ARB and OP chains (#13521)
* add erc20 oeth bridge contract * deploy script * add fixes * test deploymeny manifest * pass signer to getErc20 helper * add scripts * add optimsim sdk dep * better logs * balances log * scrpt to deploy bridged token on OP * delete custom bridge contract * move deploy script to governance * remove refs to OP sepolia * cleanup gitignore * cleanup and use values from networks package * arb bridge contract * move scripts to bridge folder * arb use mainnet * check if token already exists * add arbitrum addresses * OP default to mainnet * add optimism bridged token * pass correct ERC20 abi * deploy on base * add base token bridge * basic base bridge token script * rm unwanted git ref * move all udt scripts to governance * remove changes from smart-contracts folder * unchecked sepola deployments * deploy UDT on base sepolia * improve base script * add gas estimate
- Loading branch information
Showing
13 changed files
with
8,607 additions
and
2,537 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/** | ||
* Deploy a bridged ERC20 UDT token contract on Optimism networks | ||
* | ||
* Please edit the chain ids constant below to use | ||
*/ | ||
const { getNetwork, getEvent } = require('@unlock-protocol/hardhat-helpers') | ||
const { getProvider } = require('../../helpers/multisig') | ||
|
||
const { ethers } = require('hardhat') | ||
const fs = require('fs-extra') | ||
|
||
// base factory address from https://docs.base.org/base-contracts/ | ||
const OptimismMintableERC20Factory = { | ||
base: '0xf23d369d7471bD9f6487E198723eEa023389f1d4', | ||
optimism: '0x4200000000000000000000000000000000000012', | ||
baseSepolia: '0x4200000000000000000000000000000000000012', | ||
} | ||
|
||
// OP factory address | ||
// const OP_OptimismMintableERC20Factory = | ||
|
||
// edit default values | ||
const L1_CHAIN_ID = 11155111 // default to (Sepolia 11155111) | ||
const l2_CHAIN_ID = 84532 // default to (Base Sepolia 84532) | ||
|
||
async function main({ | ||
tokenSymbol = 'UDT', | ||
tokenName = 'UnlockDiscountToken', | ||
factoryAddress = OptimismMintableERC20Factory.baseSepolia, // bridged erc20 factory address | ||
l1ChainId = L1_CHAIN_ID, | ||
l2ChainId = l2_CHAIN_ID, | ||
} = {}) { | ||
const { DEPLOYER_PRIVATE_KEY } = process.env | ||
const { | ||
name: l1Name, | ||
unlockDaoToken: { address: l1TokenAddress }, | ||
} = await getNetwork(l1ChainId) | ||
|
||
if (!l1TokenAddress) { | ||
throw new Error(`Missing UDT on L1 ${l1Name}`) | ||
} | ||
// get l2 network info | ||
const l2 = await getNetwork(l2ChainId) | ||
console.log( | ||
`Deploying bridged token from L1 (${l1Name}) ${l1TokenAddress} to L2 ${l2.name} (${l2.id})... | ||
- token: ${l1TokenAddress} ` | ||
) | ||
|
||
// Create the RPC providers and wallets | ||
const { provider: l2Provider } = await getProvider(l2ChainId) | ||
const l2Wallet = new ethers.Wallet(DEPLOYER_PRIVATE_KEY, l2Provider) | ||
|
||
// read ABI from node_modules | ||
const { abi: factoryAbi } = JSON.parse( | ||
fs | ||
.readFileSync( | ||
'../node_modules/@eth-optimism/contracts-bedrock/deployments/mainnet/OptimismMintableERC20Factory.json' | ||
) | ||
.toString() | ||
.replace(/\n/g, '') | ||
) | ||
|
||
// get factory contract instance | ||
const factory = await ethers.getContractAt( | ||
factoryAbi, | ||
factoryAddress, | ||
l2Wallet | ||
) | ||
|
||
// create bridged token | ||
const tx = await factory.createOptimismMintableERC20( | ||
l1TokenAddress, | ||
tokenName, | ||
tokenSymbol | ||
) | ||
|
||
// fetch info from tx | ||
const receipt = await tx.wait() | ||
const { | ||
args: { localToken }, | ||
hash, | ||
} = await getEvent(receipt, 'OptimismMintableERC20Created') | ||
|
||
console.log(`Bridged token deployed at: ${localToken} (${hash})`) | ||
} | ||
|
||
// execute as standalone | ||
if (require.main === module) { | ||
main() | ||
.then(() => process.exit(0)) | ||
.catch((error) => { | ||
console.error(error) | ||
process.exit(1) | ||
}) | ||
} |
Oops, something went wrong.