Skip to content

Commit

Permalink
Use SDK estimations instead of hard-coding retryable params
Browse files Browse the repository at this point in the history
  • Loading branch information
gvladika committed Jul 29, 2024
1 parent 0f4d641 commit ce78651
Showing 1 changed file with 29 additions and 3 deletions.
32 changes: 29 additions & 3 deletions scripts/usdc-bridge-deployment/deployUsdcBridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
L1GatewayRouter__factory,
L1USDCGateway,
L1USDCGateway__factory,
L2GatewayRouter__factory,
L2USDCGateway,
L2USDCGateway__factory,
ProxyAdmin,
Expand All @@ -33,18 +34,21 @@ import {
import {
addCustomNetwork,
L1Network,
L1ToL2MessageGasEstimator,
L1ToL2MessageStatus,
L1TransactionReceipt,
L2Network,
} from '@arbitrum/sdk'
import { RollupAdminLogic__factory } from '@arbitrum/sdk/dist/lib/abi/factories/RollupAdminLogic__factory'
import { getBaseFee } from '@arbitrum/sdk/dist/lib/utils/lib'

dotenv.config()

main().then(() => console.log('Done.'))

async function main() {
_checkEnvVars()

const { deployerL1, deployerL2, rollupOwner } = await _loadWallets()
console.log('Loaded deployer wallets')

Expand Down Expand Up @@ -93,6 +97,7 @@ async function main() {
rollupOwner,
deployerL2.provider!,
l1Router,
l2Router,
l1Usdc,
l1UsdcGateway.address
)
Expand Down Expand Up @@ -314,6 +319,7 @@ async function _registerGateway(
rollupOwner: Wallet,
childProvider: Provider,
l1RouterAddress: string,
l2RouterAddress: string,
l1UsdcAddress: string,
l1UsdcGatewayAddress: string
) {
Expand All @@ -333,9 +339,29 @@ async function _registerGateway(
)

/// prepare calldata for executor
const maxGas = BigNumber.from(500000)
const gasPriceBid = BigNumber.from(200000000)
let maxSubmissionCost = BigNumber.from(257600000000)
const routerRegistrationData =
L2GatewayRouter__factory.createInterface().encodeFunctionData(
'setGateway',
[[l1UsdcAddress], [l1UsdcGatewayAddress]]
)

const l1ToL2MessageGasEstimate = new L1ToL2MessageGasEstimator(childProvider)
const retryableParams = await l1ToL2MessageGasEstimate.estimateAll(
{
from: l1RouterAddress,
to: l2RouterAddress,
l2CallValue: BigNumber.from(0),
excessFeeRefundAddress: rollupOwner.address,
callValueRefundAddress: rollupOwner.address,
data: routerRegistrationData,
},
await getBaseFee(rollupOwner.provider),
rollupOwner.provider
)

const maxGas = retryableParams.gasLimit
const gasPriceBid = retryableParams.maxFeePerGas.mul(3)
let maxSubmissionCost = retryableParams.maxSubmissionCost
const registrationCalldata = l1Router.interface.encodeFunctionData(
'setGateways',
[
Expand Down

0 comments on commit ce78651

Please sign in to comment.