|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# Define constants |
| 4 | +AMOUNT=100000 |
| 5 | + |
| 6 | +DEFAULT_ZKSYNC_LOCAL_KEY="0x7726827caac94a7f9e1b160f7ea819f172f7b6f9d2a97f992c38edeab82d4110" |
| 7 | +DEFAULT_ZKSYNC_ADDRESS="0x36615Cf349d7F6344891B1e7CA7C72883F5dc049" |
| 8 | + |
| 9 | +ZKSYNC_REGISTRY_MODULE_OWNER_CUSTOM="0x3139687Ee9938422F57933C3CDB3E21EE43c4d0F" |
| 10 | +ZKSYNC_TOKEN_ADMIN_REGISTRY="0xc7777f12258014866c677Bdb679D0b007405b7DF" |
| 11 | +ZKSYNC_ROUTER="0xA1fdA8aa9A8C4b945C45aD30647b01f07D7A0B16" |
| 12 | +ZKSYNC_RNM_PROXY_ADDRESS="0x3DA20FD3D8a8f8c1f1A5fD03648147143608C467" |
| 13 | +ZKSYNC_SEPOLIA_CHAIN_SELECTOR="6898391096552792247" |
| 14 | +ZKSYNC_LINK_ADDRESS="0x23A1aFD896c8c8876AF46aDc38521f4432658d1e" |
| 15 | + |
| 16 | +SEPOLIA_REGISTRY_MODULE_OWNER_CUSTOM="0x62e731218d0D47305aba2BE3751E7EE9E5520790" |
| 17 | +SEPOLIA_TOKEN_ADMIN_REGISTRY="0x95F29FEE11c5C55d26cCcf1DB6772DE953B37B82" |
| 18 | +SEPOLIA_ROUTER="0x0BF3dE8c5D3e8A2B34D2BEeB17ABfCeBaf363A59" |
| 19 | +SEPOLIA_RNM_PROXY_ADDRESS="0xba3f6251de62dED61Ff98590cB2fDf6871FbB991" |
| 20 | +SEPOLIA_CHAIN_SELECTOR="16015286601757825753" |
| 21 | +SEPOLIA_LINK_ADDRESS="0x779877A7B0D9E8603169DdbD7836e478b4624789" |
| 22 | + |
| 23 | +# Compile and deploy the Rebase Token contract |
| 24 | +foundryup-zksync |
| 25 | +source .env |
| 26 | +forge build --zksync |
| 27 | +echo "Compiling and deploying the Rebase Token contract on ZKsync..." |
| 28 | +ZKSYNC_REBASE_TOKEN_ADDRESS=$(forge create src/RebaseToken.sol:RebaseToken --rpc-url ${ZKSYNC_SEPOLIA_RPC_URL} --account Rebase --legacy --zksync | awk '/Deployed to:/ {print $3}') |
| 29 | +echo "ZKsync rebase token address: $ZKSYNC_REBASE_TOKEN_ADDRESS" |
| 30 | + |
| 31 | +# Compile and deploy the pool contract |
| 32 | +echo "Compiling and deploying the pool contract on ZKsync..." |
| 33 | +ZKSYNC_POOL_ADDRESS=$(forge create src/RebaseTokenPool.sol:RebaseTokenPool --rpc-url ${ZKSYNC_SEPOLIA_RPC_URL} --account Rebase --legacy --zksync --constructor-args ${ZKSYNC_REBASE_TOKEN_ADDRESS} [] ${ZKSYNC_RNM_PROXY_ADDRESS} ${ZKSYNC_ROUTER} | awk '/Deployed to:/ {print $3}') |
| 34 | +echo "Pool address: $ZKSYNC_POOL_ADDRESS" |
| 35 | + |
| 36 | +# Set the permissions for the pool contract |
| 37 | +echo "Setting the permissions for the pool contract on ZKsync..." |
| 38 | +cast send ${ZKSYNC_REBASE_TOKEN_ADDRESS} --rpc-url ${ZKSYNC_SEPOLIA_RPC_URL} --account Rebase "grantMintAndBurnRole(address)" ${ZKSYNC_POOL_ADDRESS} |
| 39 | +echo "Pool permissions set" |
| 40 | + |
| 41 | +# Set the CCIP roles and permissions |
| 42 | +echo "Setting the CCIP roles and permissions on ZKsync..." |
| 43 | +cast send ${ZKSYNC_REGISTRY_MODULE_OWNER_CUSTOM} "registerAdminViaOwner(address)" ${ZKSYNC_REBASE_TOKEN_ADDRESS} --rpc-url ${ZKSYNC_SEPOLIA_RPC_URL} --account Rebase |
| 44 | +cast send ${ZKSYNC_TOKEN_ADMIN_REGISTRY} "acceptAdminRole(address)" ${ZKSYNC_REBASE_TOKEN_ADDRESS} --rpc-url ${ZKSYNC_SEPOLIA_RPC_URL} --account Rebase |
| 45 | +cast send ${ZKSYNC_TOKEN_ADMIN_REGISTRY} "setPool(address,address)" ${ZKSYNC_REBASE_TOKEN_ADDRESS} ${ZKSYNC_POOL_ADDRESS} --rpc-url ${ZKSYNC_SEPOLIA_RPC_URL} --account Rebase |
| 46 | +echo "CCIP roles and permissions set" |
| 47 | + |
| 48 | +# 2. On Sepolia! |
| 49 | + |
| 50 | +echo "Running the script to deploy the contracts on Sepolia..." |
| 51 | +output=$(forge script ./script/Deployer.s.sol:TokenAndPoolDeployer --rpc-url ${SEPOLIA_RPC_URL} --account Rebase --broadcast) |
| 52 | +echo "Contracts deployed and permission set on Sepolia" |
| 53 | + |
| 54 | +# Extract the addresses from the output |
| 55 | +SEPOLIA_REBASE_TOKEN_ADDRESS=$(echo "$output" | grep 'token: contract RebaseToken' | awk '{print $4}') |
| 56 | +SEPOLIA_POOL_ADDRESS=$(echo "$output" | grep 'pool: contract RebaseTokenPool' | awk '{print $4}') |
| 57 | + |
| 58 | +echo "Sepolia rebase token address: $SEPOLIA_REBASE_TOKEN_ADDRESS" |
| 59 | +echo "Sepolia pool address: $SEPOLIA_POOL_ADDRESS" |
| 60 | + |
| 61 | +# Deploy the vault |
| 62 | +echo "Deploying the vault on Sepolia..." |
| 63 | +VAULT_ADDRESS=$(forge script ./script/Deployer.s.sol:VaultDeployer --rpc-url ${SEPOLIA_RPC_URL} --account Rebase --broadcast --sig "run(address)" ${SEPOLIA_REBASE_TOKEN_ADDRESS} | grep 'vault: contract Vault' | awk '{print $NF}') |
| 64 | +echo "Vault address: $VAULT_ADDRESS" |
| 65 | + |
| 66 | +# Configure the pool on Sepolia |
| 67 | +echo "Configuring the pool on Sepolia..." |
| 68 | +# uint64 remoteChainSelector, |
| 69 | +# address remotePoolAddress, / |
| 70 | +# address remoteTokenAddress, / |
| 71 | +# bool outboundRateLimiterIsEnabled, false |
| 72 | +# uint128 outboundRateLimiterCapacity, 0 |
| 73 | +# uint128 outboundRateLimiterRate, 0 |
| 74 | +# bool inboundRateLimiterIsEnabled, false |
| 75 | +# uint128 inboundRateLimiterCapacity, 0 |
| 76 | +# uint128 inboundRateLimiterRate 0 |
| 77 | +forge script ./script/Configure.s.sol:ConfigurePool --rpc-url ${SEPOLIA_RPC_URL} --account Rebase --broadcast --sig "run(address,uint64,address,address,bool,uint128,uint128,bool,uint128,uint128)" ${SEPOLIA_POOL_ADDRESS} ${ZKSYNC_SEPOLIA_CHAIN_SELECTOR} ${ZKSYNC_POOL_ADDRESS} ${ZKSYNC_REBASE_TOKEN_ADDRESS} false 0 0 false 0 0 |
| 78 | + |
| 79 | +# Deposit funds to the vault |
| 80 | +echo "Depositing funds to the vault on Sepolia..." |
| 81 | +cast send ${VAULT_ADDRESS} --value ${AMOUNT} --rpc-url ${SEPOLIA_RPC_URL} --account Rebase "deposit()" |
| 82 | + |
| 83 | +# Wait a beat for some interest to accrue |
| 84 | + |
| 85 | +# Configure the pool on ZKsync |
| 86 | +echo "Configuring the pool on ZKsync..." |
| 87 | +cast send ${ZKSYNC_POOL_ADDRESS} --rpc-url ${ZKSYNC_SEPOLIA_RPC_URL} --account Rebase "applyChainUpdates(uint64[],(uint64,bytes[],bytes,(bool,uint128,uint128),(bool,uint128,uint128))[])" "[${SEPOLIA_CHAIN_SELECTOR}]" "[(${SEPOLIA_CHAIN_SELECTOR},[$(cast abi-encode "f(address)" ${SEPOLIA_POOL_ADDRESS})],$(cast abi-encode "f(address)" ${SEPOLIA_REBASE_TOKEN_ADDRESS}),(false,0,0),(false,0,0))]" |
| 88 | + |
| 89 | +# Bridge the funds using the script to zksync |
| 90 | +echo "Bridging the funds using the script to ZKsync..." |
| 91 | +SEPOLIA_BALANCE_BEFORE=$(cast balance $(cast wallet address --account Rebase) --erc20 ${SEPOLIA_REBASE_TOKEN_ADDRESS} --rpc-url ${SEPOLIA_RPC_URL}) |
| 92 | +echo "Sepolia balance before bridging: $SEPOLIA_BALANCE_BEFORE" |
| 93 | +forge script ./script/BridgeToken.s.sol:BridgeToken --rpc-url ${SEPOLIA_RPC_URL} --account Rebase --broadcast --sig "sendMessage(address,uint64,address,uint256,address,address)" $(cast wallet address --account Rebase) ${ZKSYNC_SEPOLIA_CHAIN_SELECTOR} ${SEPOLIA_REBASE_TOKEN_ADDRESS} ${AMOUNT} ${SEPOLIA_LINK_ADDRESS} ${SEPOLIA_ROUTER} |
| 94 | +echo "Funds bridged to ZKsync" |
| 95 | +SEPOLIA_BALANCE_AFTER=$(cast balance $(cast wallet address --account Rebase) --erc20 ${SEPOLIA_REBASE_TOKEN_ADDRESS} --rpc-url ${SEPOLIA_RPC_URL}) |
| 96 | +echo "Sepolia balance after bridging: $SEPOLIA_BALANCE_AFTER" |
| 97 | + |
| 98 | + |
| 99 | + |
0 commit comments