diff --git a/.env.sample b/.env.sample index e6aebb40..de7767c6 100644 --- a/.env.sample +++ b/.env.sample @@ -1,5 +1,5 @@ # RPCs -EVMX_RPC="https://rpc-socket-composer-testnet.t.conduit.xyz" +EVMX_RPC="https://rpc.evmx.socket.tech" SEPOLIA_RPC="https://rpc.ankr.com/eth_sepolia/" ARBITRUM_SEPOLIA_RPC="https://rpc.ankr.com/arbitrum_sepolia" OPTIMISM_SEPOLIA_RPC="https://rpc.ankr.com/optimism_sepolia" @@ -7,9 +7,10 @@ BASE_SEPOLIA_RPC="https://rpc.ankr.com/base_sepolia" # EVMx key addresses # Find the most up to date addresses in deployments/dev_addresses.json -ADDRESS_RESOLVER="0x1307b0cDCA91e969D5885D0332bD34688E9f6E39" -AUCTION_MANAGER="0xA8016fad20367D9De8B21d4c16BB677bc7a265cE" -ARBITRUM_FEES_PLUG="0xFDd8beaDb07cB224971fD311F9218addC14443fb" +ADDRESS_RESOLVER="0x7480D8D4B1929e751984b01eE877A9D65e1F3737" +AUCTION_MANAGER="0x50E5140d3601812Dc11f49a39CF9520567731c82" +ARBITRUM_FEES_PLUG="0xa08Dac27E27c49A2535b36064c370e6e8B3A0B9a" +FEES_MANAGER="0x80bEc58A00993dc874Ab2fAe56621af24eF06bA5" # Add your deployer private key here # or remove it from this file if it is already an env var @@ -21,4 +22,4 @@ APP_GATEWAY="0x" # FOR INFRASTRUCTURE DEPLOYMENT ONLY # Removes hardhat issues related to linting and syntax checking -SOCKET_SIGNER_KEY="0000dead0000dead0000dead0000dead0000dead0000dead0000dead0000dead" \ No newline at end of file +SOCKET_SIGNER_KEY="0000dead0000dead0000dead0000dead0000dead0000dead0000dead0000dead" diff --git a/foundry.toml b/foundry.toml index 3c9d312f..2b0a2d73 100644 --- a/foundry.toml +++ b/foundry.toml @@ -6,10 +6,10 @@ libs = ["node_modules", "lib"] ffi = true optimizer = true optimizer_runs = 200 -evm_version = 'shanghai' +evm_version = 'paris' # See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options [etherscan] -3605 = { key = "none", url = "https://explorer-cloud-broken-leg-7uu20euqoj.t.conduit.xyz/api" } +7625382 = { key = "empty", url = "https://evms.cloud.blockscout.com/api?" } 421614 = { key = "${ARBISCAN_API_KEY}", url = "https://api-sepolia.arbiscan.io/api?" } 11155420 = { key = "${OPTIMISM_API_KEY}", url = "https://optimism-sepolia.blockscout.com/api?" } diff --git a/script/CheckDepositedFees.s.sol b/script/AppGatewayFeeBalance.s.sol similarity index 100% rename from script/CheckDepositedFees.s.sol rename to script/AppGatewayFeeBalance.s.sol diff --git a/script/PayFeesInArbitrumETH.s.sol b/script/PayFeesInArbitrumETH.s.sol index dec3763b..ff3ff1be 100644 --- a/script/PayFeesInArbitrumETH.s.sol +++ b/script/PayFeesInArbitrumETH.s.sol @@ -21,7 +21,7 @@ contract DepositFees is Script { uint256 balance = sender.balance; console.log("Sender balance in wei:", balance); - uint feesAmount = 0.01 ether; + uint feesAmount = 0.001 ether; feesPlug.deposit{value: feesAmount}(ETH_ADDRESS, appGateway, feesAmount); } } diff --git a/script/counter/IncrementCountersFromApp.s.sol b/script/counter/IncrementCountersFromApp.s.sol index 70036545..379cd9ef 100644 --- a/script/counter/IncrementCountersFromApp.s.sol +++ b/script/counter/IncrementCountersFromApp.s.sol @@ -13,8 +13,8 @@ contract IncrementCounters is Script { vm.createSelectFork(socketRPC); - CounterDeployer deployer = CounterDeployer(vm.envAddress("COUNTER_DEPLOYER")); - CounterAppGateway gateway = CounterAppGateway(vm.envAddress("COUNTER_APP_GATEWAY")); + CounterDeployer deployer = CounterDeployer(vm.envAddress("DEPLOYER")); + CounterAppGateway gateway = CounterAppGateway(vm.envAddress("APP_GATEWAY")); address counterForwarderArbitrumSepolia = deployer.forwarderAddresses( deployer.counter(), @@ -67,15 +67,7 @@ contract IncrementCounters is Script { // console.log("Ethereum Sepolia forwarder not yet deployed"); //} - // vm.startBroadcast(deployerPrivateKey); - bytes memory data = abi.encodeWithSelector( - CounterAppGateway.incrementCounters.selector, - instances - ); - console.log("to"); - console.log(address(gateway)); - console.log("data"); - console.logBytes(data); - // gateway.incrementCounters(instances); + vm.startBroadcast(deployerPrivateKey); + gateway.incrementCounters(instances); } } diff --git a/script/counter/WithdrawFeesArbitrumFeesPlug.s.sol b/script/counter/WithdrawFeesArbitrumFeesPlug.s.sol index 26d2a0f0..098f58bc 100644 --- a/script/counter/WithdrawFeesArbitrumFeesPlug.s.sol +++ b/script/counter/WithdrawFeesArbitrumFeesPlug.s.sol @@ -3,30 +3,59 @@ pragma solidity ^0.8.0; import {Script} from "forge-std/Script.sol"; import {console} from "forge-std/console.sol"; -import {FeesPlug} from "../../contracts/protocol/payload-delivery/FeesPlug.sol"; +import {FeesManager} from "../../contracts/protocol/payload-delivery/app-gateway/FeesManager.sol"; import {ETH_ADDRESS} from "../../contracts/protocol/utils/common/Constants.sol"; import {CounterAppGateway} from "../../contracts/apps/counter/CounterAppGateway.sol"; contract WithdrawFees is Script { function run() external { - vm.createSelectFork(vm.envString("ARBITRUM_SEPOLIA_RPC")); - - uint256 privateKey = vm.envUint("PRIVATE_KEY"); - vm.startBroadcast(privateKey); - FeesPlug feesPlug = FeesPlug(payable(vm.envAddress("ARBITRUM_FEES_PLUG"))); + // EVMX Check available fees + vm.createSelectFork(vm.envString("EVMX_RPC")); + FeesManager feesManager = FeesManager(payable(vm.envAddress("FEES_MANAGER"))); address appGatewayAddress = vm.envAddress("APP_GATEWAY"); CounterAppGateway appGateway = CounterAppGateway(appGatewayAddress); - address sender = vm.addr(privateKey); - console.log("Sender address:", sender); - uint256 balance = sender.balance; - console.log("Sender balance:", balance); + uint256 availableFees = feesManager.getAvailableFees( + 421614, + appGatewayAddress, + ETH_ADDRESS + ); + console.log("Available fees:", availableFees); + + if (availableFees > 0) { + // Switch to Arbitrum Sepolia to get gas price + vm.createSelectFork(vm.envString("ARBITRUM_SEPOLIA_RPC")); + uint256 privateKey = vm.envUint("PRIVATE_KEY"); + address sender = vm.addr(privateKey); + + // Gas price from Arbitrum + uint256 arbitrumGasPrice = block.basefee + 0.1 gwei; // With buffer + uint256 gasLimit = 5_000_000; // Estimate + uint256 estimatedGasCost = gasLimit * arbitrumGasPrice; + + console.log("Arbitrum gas price (wei):", arbitrumGasPrice); + console.log("Gas limit:", gasLimit); + console.log("Estimated gas cost:", estimatedGasCost); + + // Calculate amount to withdraw + uint256 amountToWithdraw = availableFees > estimatedGasCost + ? availableFees - estimatedGasCost + : 0; + + if (amountToWithdraw > 0) { + // Switch back to EVMX to perform withdrawal + vm.createSelectFork(vm.envString("EVMX_RPC")); + vm.startBroadcast(privateKey); + console.log("Withdrawing amount:", amountToWithdraw); + appGateway.withdrawFeeTokens(421614, ETH_ADDRESS, amountToWithdraw, sender); + vm.stopBroadcast(); - uint256 appBalance = feesPlug.balanceOf(appGatewayAddress); - console.log("AppBalance:", appBalance); - if (appBalance > 0) { - appGateway.withdrawFeeTokens(421614, ETH_ADDRESS, appBalance, sender); - console.log("Withdrew:", appBalance); + // Switch back to Arbitrum Sepolia to check final balance + vm.createSelectFork(vm.envString("ARBITRUM_SEPOLIA_RPC")); + console.log("Final sender balance:", sender.balance); + } else { + console.log("Available fees less than estimated gas cost"); + } } } } diff --git a/script/counter/deployOnchainCounters.s.sol b/script/counter/deployOnchainCounters.s.sol index 4279c13a..2c67a1fe 100644 --- a/script/counter/deployOnchainCounters.s.sol +++ b/script/counter/deployOnchainCounters.s.sol @@ -25,7 +25,7 @@ contract CounterDeployOnchain is Script { // deployer.deployContracts(11155420); // console.log("Deploying contracts on Base Sepolia..."); // deployer.deployContracts(84532); - //console.log("Deploying contracts on Ethereum Sepolia..."); - //deployer.deployContracts(11155111); + // console.log("Deploying contracts on Ethereum Sepolia..."); + // deployer.deployContracts(11155111); } }