1import { formatEther, parseEther, Contract } from 'ethers' 7const arbInboxAddr = '0x4Dbd4fc535Ac27206064B68FfCf827b0A60BAB3f' 8const inboxAbi = ['function depositEth() external payable returns (uint256)'] 10const minScratchBalance = 0.001 11const bridgeAmount = 0.003 12const fundScratchAmount = 0.002 14export const bridgetoarb = async () => { 20 const [peatMainnetBal, peatArbBal, scratchArbBal] = await Promise.all([ 21 mainnetProv.getBalance(peatWallet.address), 22 arbProv.getBalance(peatWallet.address), 23 arbProv.getBalance(scratchWallet.address), 27 peatWallet: peatWallet.address, 28 peatMainnetEth: formatEther(peatMainnetBal), 29 peatArbitrumEth: formatEther(peatArbBal), 30 scratchWallet: scratchWallet.address, 31 scratchArbitrumEth: formatEther(scratchArbBal), 34 if (parseFloat(formatEther(scratchArbBal)) >= minScratchBalance) { 35 console.log('Scratch wallet balance sufficient, no funding needed') 39 const fundAmt = parseEther(String(fundScratchAmount)) 41 if (peatArbBal >= fundAmt) { 42 console.log(`Funding scratch wallet from peatWal on Arbitrum...`) 44 signer: peatWallet.connect(arbProv), 45 destAddr: scratchWallet.address, 48 console.log('Fund tx:', tx.hash) 50 console.log('Scratch wallet funded on Arbitrum') 54 const bridgeAmt = parseEther(String(bridgeAmount)) 55 if (peatMainnetBal < bridgeAmt) { 56 console.log(`peatWal mainnet balance too low to bridge ${bridgeAmount} ETH`) 60 console.log(`Bridging ${bridgeAmount} ETH from peatWal mainnet to Arbitrum...`) 61 const connectedWallet = peatWallet.connect(mainnetProv) 62 const inbox = new Contract(arbInboxAddr, inboxAbi, connectedWallet) 64 const tx = await inbox.depositEth({ value: bridgeAmt }) 65 console.log('Bridge tx:', tx.hash) 67 console.log('Confirmed on mainnet. Funds arrive on Arbitrum in ~15 min.') 68 console.log('Run this action again after funds arrive to fund scratch wallet.') 71bridgetoarb.needsEnvConf = true