Skip to content

Commit

Permalink
Use MasterMinter contract
Browse files Browse the repository at this point in the history
  • Loading branch information
gvladika committed Jul 31, 2024
1 parent 28c0ab9 commit dacfae8
Showing 1 changed file with 22 additions and 16 deletions.
38 changes: 22 additions & 16 deletions scripts/usdc-bridge-deployment/deployUsdcBridge.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BigNumber, ContractTransaction, Wallet } from 'ethers'
import { BigNumber, Contract, ContractTransaction, Wallet } from 'ethers'
import { ethers } from 'hardhat'
import {
IBridge__factory,
Expand Down Expand Up @@ -75,8 +75,11 @@ async function main() {
const proxyAdminL2 = await _deployProxyAdmin(deployerL2)
console.log('L2 ProxyAdmin deployed: ', proxyAdminL2.address)

const bridgedUsdc = await _deployBridgedUsdc(deployerL2, proxyAdminL2)
console.log('Bridged (L2) USDC deployed: ', bridgedUsdc)
const { l2Usdc, masterMinter } = await _deployBridgedUsdc(
deployerL2,
proxyAdminL2
)
console.log('Bridged (L2) USDC deployed: ', l2Usdc.address)

const l1UsdcGateway = await _deployL1UsdcGateway(
deployerL1,
Expand All @@ -92,7 +95,7 @@ async function main() {
l1UsdcGateway,
l2UsdcGateway,
inbox,
bridgedUsdc,
l2Usdc.address,
deployerL1,
deployerL2
)
Expand All @@ -113,7 +116,7 @@ async function main() {
console.log('Usdc gateway registered')
}

_addMinterRoleToL2Gateway(l2UsdcGateway, deployerL2, bridgedUsdc)
await _addMinterRoleToL2Gateway(l2UsdcGateway, deployerL2, masterMinter)
console.log('Minter role with max allowance added to L2 gateway')
}

Expand Down Expand Up @@ -143,7 +146,7 @@ async function _deployProxyAdmin(deployer: Wallet): Promise<ProxyAdmin> {
async function _deployBridgedUsdc(
deployerL2Wallet: Wallet,
proxyAdminL2: ProxyAdmin
): Promise<string> {
) {
/// create l2 usdc behind proxy
const l2UsdcLogic = await _deployUsdcLogic(deployerL2Wallet)
const l2UsdcProxyAddress = await _deployUsdcProxy(
Expand All @@ -158,7 +161,7 @@ async function _deployBridgedUsdc(
MasterMinterBytecode,
deployerL2Wallet
)
const masterMinterL2 = await masterMinterL2Fac.deploy(l2UsdcProxyAddress)
const masterMinter = await masterMinterL2Fac.deploy(l2UsdcProxyAddress)

/// init usdc proxy
const l2UsdcFiatToken = IFiatToken__factory.connect(
Expand All @@ -175,7 +178,7 @@ async function _deployBridgedUsdc(
'USDC.e',
'USD',
6,
masterMinterL2.address,
masterMinter.address,
pauserL2.address,
blacklisterL2.address,
deployerL2Wallet.address
Expand All @@ -191,7 +194,7 @@ async function _deployBridgedUsdc(
(await l2UsdcFiatToken.symbol()) != 'USDC.e' ||
(await l2UsdcFiatToken.currency()) != 'USD' ||
(await l2UsdcFiatToken.decimals()) != 6 ||
(await l2UsdcFiatToken.masterMinter()) != masterMinterL2.address ||
(await l2UsdcFiatToken.masterMinter()) != masterMinter.address ||
(await l2UsdcFiatToken.pauser()) != pauserL2.address ||
(await l2UsdcFiatToken.blacklister()) != blacklisterL2.address ||
(await l2UsdcFiatToken.owner()) != deployerL2Wallet.address
Expand Down Expand Up @@ -233,7 +236,7 @@ async function _deployBridgedUsdc(
deployerL2Wallet
)

return l2Usdc.address
return { l2Usdc, masterMinter }
}

async function _deployUsdcLogic(deployer: Wallet) {
Expand Down Expand Up @@ -527,16 +530,19 @@ async function _registerGateway(
*/
async function _addMinterRoleToL2Gateway(
l2UsdcGateway: L2USDCGateway,
masterMinter: Wallet,
bridgedUsdc: string
masterMinterOwner: Wallet,
masterMinter: Contract
) {
const l2UsdcFiatToken = IFiatToken__factory.connect(bridgedUsdc, masterMinter)
await (
await l2UsdcFiatToken.configureMinter(
l2UsdcGateway.address,
ethers.constants.MaxUint256
await masterMinter['configureController(address,address)'](
masterMinterOwner.address,
l2UsdcGateway.address
)
).wait()

await (
await masterMinter['configureMinter(uint256)'](ethers.constants.MaxUint256)
).wait()
}

/**
Expand Down

0 comments on commit dacfae8

Please sign in to comment.