diff --git a/deploy/063_deploy_zkstack_adapter.ts b/deploy/063_deploy_zkstack_adapter.ts new file mode 100644 index 000000000..df939251a --- /dev/null +++ b/deploy/063_deploy_zkstack_adapter.ts @@ -0,0 +1,55 @@ +import assert from "assert"; +import { HardhatRuntimeEnvironment } from "hardhat/types"; +import { DeployFunction } from "hardhat-deploy/types"; +import { + L1_ADDRESS_MAP, + WETH, + ZK_L2_GAS_LIMIT, + ZK_L1_GAS_TO_L2_GAS_PER_PUBDATA_LIMIT, + ZK_MAX_GASPRICE, +} from "./consts"; + +/** + * Note: + * This adapter supports ZkStack L2s. + * + * Usage: + * $ SPOKE_CHAIN_ID=37111 yarn hardhat deploy --network sepolia --tags ZkStackCustomGasTokenAdapter + */ + +const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { + // Excess bridge fees will go to this address on L2. + const L2_REFUND_ADDRESS = "0x07aE8551Be970cB1cCa11Dd7a11F47Ae82e70E67"; + + const { SPOKE_CHAIN_ID } = process.env; + assert(SPOKE_CHAIN_ID !== undefined, "SPOKE_CHAIN_ID not defined in environment"); + assert( + parseInt(SPOKE_CHAIN_ID).toString() === SPOKE_CHAIN_ID, + "SPOKE_CHAIN_ID (${SPOKE_CHAIN_ID}) must be an integer" + ); + + const { deployer } = await hre.getNamedAccounts(); + const chainId = parseInt(await hre.getChainId()); + + const constructorArguments = [ + SPOKE_CHAIN_ID, + L1_ADDRESS_MAP[chainId][`zkBridgeHub_${SPOKE_CHAIN_ID}`], + WETH[chainId], + L2_REFUND_ADDRESS, + ZK_L2_GAS_LIMIT, + ZK_L1_GAS_TO_L2_GAS_PER_PUBDATA_LIMIT, + ZK_MAX_GASPRICE, + ]; + + const { address: deployment } = await hre.deployments.deploy("ZkStack_Adapter", { + from: deployer, + log: true, + skipIfAlreadyDeployed: true, + args: constructorArguments, + }); + + await hre.run("verify:verify", { address: deployment, constructorArguments }); +}; + +module.exports = func; +func.tags = ["ZkStackAdapter", "mainnet"]; diff --git a/deploy/consts.ts b/deploy/consts.ts index 3a2e535d3..90430ceb9 100644 --- a/deploy/consts.ts +++ b/deploy/consts.ts @@ -44,7 +44,7 @@ export const L1_ADDRESS_MAP: { [key: number]: { [contractName: string]: string } l1AlephZeroInbox: "0x56D8EC76a421063e1907503aDd3794c395256AEb", l1AlephZeroERC20GatewayRouter: "0xeBb17f398ed30d02F2e8733e7c1e5cf566e17812", donationBox: "0x0d57392895Db5aF3280e9223323e20F3951E81B1", - // bridgeHub contract for Lens, + zkBridgeHub_324: "0x303a465B659cBB0ab36eE643eA362c509EEb5213", zkBridgeHub_232: "0x9dA9f5dad070649811D77c40CcDcab479cE3Fa07", }, [CHAIN_IDs.SEPOLIA]: { @@ -69,7 +69,7 @@ export const L1_ADDRESS_MAP: { [key: number]: { [contractName: string]: string } polygonRegistry: "0xfE92F7c3a701e43d8479738c8844bCc555b9e5CD", polygonDepositManager: "0x44Ad17990F9128C6d823Ee10dB7F0A5d40a731A4", - zkBridgeHub: "0x236D1c3Ff32Bd0Ca26b72Af287E895627c0478cE", + zkBridgeHub_37111: "0x236D1c3Ff32Bd0Ca26b72Af287E895627c0478cE", }, }; diff --git a/deployments/deployments.json b/deployments/deployments.json index 25388057f..a2e167365 100644 --- a/deployments/deployments.json +++ b/deployments/deployments.json @@ -13,7 +13,7 @@ "Optimism_Adapter": { "address": "0xE1e74B3D6A8E2A479B62958D4E4E6eEaea5B612b", "blockNumber": 19915034 }, "PolygonTokenBridger": { "address": "0x0330E9b4D0325cCfF515E81DFbc7754F2a02ac57", "blockNumber": 14819539 }, "Polygon_Adapter": { "address": "0xb4AeF0178f5725392A26eE18684C2aB62adc912e", "blockNumber": 19915066 }, - "ZkSync_Adapter": { "address": "0xE233009838CB898b50e0012a6E783FC9FeE447FB", "blockNumber": 17842162 }, + "ZkSync_Adapter": { "address": "0x3155A91D2EBAe69443B45556e1DE5ed8eB79C90D", "blockNumber": 22031982 }, "Base_Adapter": { "address": "0xE1421233BF7158A19f89F17c9735F9cbd3D9529c", "blockNumber": 19915087 }, "Linea_Adapter": { "address": "0x7Ea0D1882D610095A45E512B0113f79cA98a8EfE", "blockNumber": 19402413 }, "BondToken": { "address": "0xee1dc6bcf1ee967a350e9ac6caaaa236109002ea", "blockNumber": 17980554 }, diff --git a/deployments/mainnet/ZkStack_Adapter.json b/deployments/mainnet/ZkStack_Adapter.json new file mode 100644 index 000000000..21bf148e8 --- /dev/null +++ b/deployments/mainnet/ZkStack_Adapter.json @@ -0,0 +1,345 @@ +{ + "address": "0x3155A91D2EBAe69443B45556e1DE5ed8eB79C90D", + "abi": [ + { + "inputs": [ + { + "internalType": "uint256", + "name": "_chainId", + "type": "uint256" + }, + { + "internalType": "contract BridgeHubInterface", + "name": "_bridgeHub", + "type": "address" + }, + { + "internalType": "contract WETH9Interface", + "name": "_l1Weth", + "type": "address" + }, + { + "internalType": "address", + "name": "_l2RefundAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_l2GasLimit", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_l1GasToL2GasPerPubDataLimit", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_maxTxGasprice", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "ETHGasTokenRequired", + "type": "error" + }, + { + "inputs": [], + "name": "TransactionFeeTooHigh", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "target", + "type": "address" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "message", + "type": "bytes" + } + ], + "name": "MessageRelayed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "l1Token", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "l2Token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "address", + "name": "to", + "type": "address" + } + ], + "name": "TokensRelayed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "canonicalTxHash", + "type": "bytes32" + } + ], + "name": "ZkStackMessageRelayed", + "type": "event" + }, + { + "inputs": [], + "name": "BRIDGE_HUB", + "outputs": [ + { + "internalType": "contract BridgeHubInterface", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "CHAIN_ID", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "L1_GAS_TO_L2_GAS_PER_PUB_DATA_LIMIT", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "L1_WETH", + "outputs": [ + { + "internalType": "contract WETH9Interface", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "L2_GAS_LIMIT", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "L2_REFUND_ADDRESS", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "SHARED_BRIDGE", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "target", + "type": "address" + }, + { + "internalType": "bytes", + "name": "message", + "type": "bytes" + } + ], + "name": "relayMessage", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "l1Token", + "type": "address" + }, + { + "internalType": "address", + "name": "l2Token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + } + ], + "name": "relayTokens", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + } + ], + "transactionHash": "0xd1a509660412fa7ed6e412e51f38254f27a7d1c264c9ad142766484925314445", + "receipt": { + "to": null, + "from": "0x9A8f92a830A5cB89a3816e3D267CB7791c16b04D", + "contractAddress": "0x7148C51E57994DD2c02A3857B5D61Be8d7a0d04f", + "transactionIndex": 57, + "gasUsed": "1083645", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x5968558a834c45e225dff9dcf3d85144d6388953f3dcd6d1df7a1450c71543e1", + "transactionHash": "0xd1a509660412fa7ed6e412e51f38254f27a7d1c264c9ad142766484925314445", + "logs": [], + "blockNumber": 22032060, + "cumulativeGasUsed": "3739696", + "status": 1, + "byzantium": true + }, + "args": [ + "324", + "0x303a465B659cBB0ab36eE643eA362c509EEb5213", + "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", + "0x07aE8551Be970cB1cCa11Dd7a11F47Ae82e70E67", + 2000000, + 800, + "10000000000000" + ], + "numDeployments": 1, + "solcInputHash": "52176bdd062b3053719867884494ff14", + "metadata": "{\"compiler\":{\"version\":\"0.8.23+commit.f704f362\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_chainId\",\"type\":\"uint256\"},{\"internalType\":\"contract BridgeHubInterface\",\"name\":\"_bridgeHub\",\"type\":\"address\"},{\"internalType\":\"contract WETH9Interface\",\"name\":\"_l1Weth\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_l2RefundAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_l2GasLimit\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_l1GasToL2GasPerPubDataLimit\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_maxTxGasprice\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"ETHGasTokenRequired\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"TransactionFeeTooHigh\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"target\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"MessageRelayed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"l1Token\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"l2Token\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"}],\"name\":\"TokensRelayed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"canonicalTxHash\",\"type\":\"bytes32\"}],\"name\":\"ZkStackMessageRelayed\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"BRIDGE_HUB\",\"outputs\":[{\"internalType\":\"contract BridgeHubInterface\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"CHAIN_ID\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"L1_GAS_TO_L2_GAS_PER_PUB_DATA_LIMIT\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"L1_WETH\",\"outputs\":[{\"internalType\":\"contract WETH9Interface\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"L2_GAS_LIMIT\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"L2_REFUND_ADDRESS\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"SHARED_BRIDGE\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"target\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"relayMessage\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"l1Token\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"l2Token\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"}],\"name\":\"relayTokens\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"custom:security-contact\":\"bugs@across.to\",\"details\":\"Public functions calling external contracts do not guard against reentrancy because they are expected to be called via delegatecall, which will execute this contract's logic within the context of the originating contract. For example, the HubPool will delegatecall these functions, therefore its only necessary that the HubPool's methods that call this contract's logic guard against reentrancy.\",\"kind\":\"dev\",\"methods\":{\"constructor\":{\"params\":{\"_bridgeHub\":\"The bridge hub contract address for the ZkStack network.\",\"_chainId\":\"The target ZkStack network's chain ID.\",\"_l1GasToL2GasPerPubDataLimit\":\"The exchange rate of l1 gas to l2 gas.\",\"_l1Weth\":\"WETH address on L1.\",\"_l2GasLimit\":\"The maximum amount of gas this contract is willing to pay to execute a transaction on L2.\",\"_l2RefundAddress\":\"address that recieves excess gas refunds on L2.\",\"_maxTxGasprice\":\"The maximum effective gas price any transaction sent to this adapter may have.\"}},\"relayMessage(address,bytes)\":{\"details\":\"The HubPool must hold enough ETH to pay for the L2 txn.\",\"params\":{\"message\":\"Data to send to target.\",\"target\":\"Contract on L2 that will receive message.\"}},\"relayTokens(address,address,uint256,address)\":{\"details\":\"The HubPool must hold enough ETH to pay for the L2 txn.\",\"params\":{\"amount\":\"Amount of L1 tokens to deposit and L2 tokens to receive.\",\"l1Token\":\"L1 token to deposit.\",\"l2Token\":\"L2 token to receive.\",\"to\":\"Bridge recipient.\"}}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"constructor\":{\"notice\":\"Constructs new Adapter.\"},\"relayMessage(address,bytes)\":{\"notice\":\"Send cross-chain message to target on ZkStack.\"},\"relayTokens(address,address,uint256,address)\":{\"notice\":\"Bridge tokens to ZkStack.\"}},\"notice\":\"Contract containing logic to send messages from L1 to ZkStack with ETH as the gas token.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/chain-adapters/ZkStack_Adapter.sol\":\"ZkStack_Adapter\"},\"debug\":{\"revertStrings\":\"strip\"},\"evmVersion\":\"shanghai\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":1000000},\"remappings\":[],\"viaIR\":true},\"sources\":{\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20 {\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` tokens from the caller's account to `to`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address to, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `from` to `to` using the\\n * allowance mechanism. `amount` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(address from, address to, uint256 amount) external returns (bool);\\n}\\n\",\"keccak256\":\"0x287b55befed2961a7eabd7d7b1b2839cbca8a5b80ef8dcbb25ed3d4c2002c305\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.4) (token/ERC20/extensions/IERC20Permit.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\\n *\\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\\n * need to send a transaction, and thus is not required to hold Ether at all.\\n *\\n * ==== Security Considerations\\n *\\n * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature\\n * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be\\n * considered as an intention to spend the allowance in any specific way. The second is that because permits have\\n * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should\\n * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be\\n * generally recommended is:\\n *\\n * ```solidity\\n * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {\\n * try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}\\n * doThing(..., value);\\n * }\\n *\\n * function doThing(..., uint256 value) public {\\n * token.safeTransferFrom(msg.sender, address(this), value);\\n * ...\\n * }\\n * ```\\n *\\n * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of\\n * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also\\n * {SafeERC20-safeTransferFrom}).\\n *\\n * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so\\n * contracts should have entry points that don't rely on permit.\\n */\\ninterface IERC20Permit {\\n /**\\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\\n * given ``owner``'s signed approval.\\n *\\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\\n * ordering also apply here.\\n *\\n * Emits an {Approval} event.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n * - `deadline` must be a timestamp in the future.\\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\\n * over the EIP712-formatted function arguments.\\n * - the signature must use ``owner``'s current nonce (see {nonces}).\\n *\\n * For more information on the signature format, see the\\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\\n * section].\\n *\\n * CAUTION: See Security Considerations above.\\n */\\n function permit(\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /**\\n * @dev Returns the current nonce for `owner`. This value must be\\n * included whenever a signature is generated for {permit}.\\n *\\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\\n * prevents a signature from being used multiple times.\\n */\\n function nonces(address owner) external view returns (uint256);\\n\\n /**\\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\\n */\\n // solhint-disable-next-line func-name-mixedcase\\n function DOMAIN_SEPARATOR() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0xb264c03a3442eb37a68ad620cefd1182766b58bee6cec40343480392d6b14d69\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.sol\\\";\\nimport \\\"../extensions/IERC20Permit.sol\\\";\\nimport \\\"../../../utils/Address.sol\\\";\\n\\n/**\\n * @title SafeERC20\\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\\n * contract returns false). Tokens that return no value (and instead revert or\\n * throw on failure) are also supported, non-reverting calls are assumed to be\\n * successful.\\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\\n */\\nlibrary SafeERC20 {\\n using Address for address;\\n\\n /**\\n * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,\\n * non-reverting calls are assumed to be successful.\\n */\\n function safeTransfer(IERC20 token, address to, uint256 value) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\\n }\\n\\n /**\\n * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the\\n * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.\\n */\\n function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\\n }\\n\\n /**\\n * @dev Deprecated. This function has issues similar to the ones found in\\n * {IERC20-approve}, and its usage is discouraged.\\n *\\n * Whenever possible, use {safeIncreaseAllowance} and\\n * {safeDecreaseAllowance} instead.\\n */\\n function safeApprove(IERC20 token, address spender, uint256 value) internal {\\n // safeApprove should only be called when setting an initial allowance,\\n // or when resetting it to zero. To increase and decrease it, use\\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\\n require(\\n (value == 0) || (token.allowance(address(this), spender) == 0),\\n \\\"SafeERC20: approve from non-zero to non-zero allowance\\\"\\n );\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\\n }\\n\\n /**\\n * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\\n * non-reverting calls are assumed to be successful.\\n */\\n function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {\\n uint256 oldAllowance = token.allowance(address(this), spender);\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));\\n }\\n\\n /**\\n * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\\n * non-reverting calls are assumed to be successful.\\n */\\n function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {\\n unchecked {\\n uint256 oldAllowance = token.allowance(address(this), spender);\\n require(oldAllowance >= value, \\\"SafeERC20: decreased allowance below zero\\\");\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));\\n }\\n }\\n\\n /**\\n * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,\\n * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval\\n * to be set to zero before setting it to a non-zero value, such as USDT.\\n */\\n function forceApprove(IERC20 token, address spender, uint256 value) internal {\\n bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);\\n\\n if (!_callOptionalReturnBool(token, approvalCall)) {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));\\n _callOptionalReturn(token, approvalCall);\\n }\\n }\\n\\n /**\\n * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.\\n * Revert on invalid signature.\\n */\\n function safePermit(\\n IERC20Permit token,\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) internal {\\n uint256 nonceBefore = token.nonces(owner);\\n token.permit(owner, spender, value, deadline, v, r, s);\\n uint256 nonceAfter = token.nonces(owner);\\n require(nonceAfter == nonceBefore + 1, \\\"SafeERC20: permit did not succeed\\\");\\n }\\n\\n /**\\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\\n * on the return value: the return value is optional (but if data is returned, it must not be false).\\n * @param token The token targeted by the call.\\n * @param data The call data (encoded using abi.encode or one of its variants).\\n */\\n function _callOptionalReturn(IERC20 token, bytes memory data) private {\\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\\n // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\\n // the target address contains contract code and also asserts for success in the low-level call.\\n\\n bytes memory returndata = address(token).functionCall(data, \\\"SafeERC20: low-level call failed\\\");\\n require(returndata.length == 0 || abi.decode(returndata, (bool)), \\\"SafeERC20: ERC20 operation did not succeed\\\");\\n }\\n\\n /**\\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\\n * on the return value: the return value is optional (but if data is returned, it must not be false).\\n * @param token The token targeted by the call.\\n * @param data The call data (encoded using abi.encode or one of its variants).\\n *\\n * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.\\n */\\n function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {\\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\\n // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false\\n // and not revert is the subcall reverts.\\n\\n (bool success, bytes memory returndata) = address(token).call(data);\\n return\\n success && (returndata.length == 0 || abi.decode(returndata, (bool))) && Address.isContract(address(token));\\n }\\n}\\n\",\"keccak256\":\"0xabefac93435967b4d36a4fabcbdbb918d1f0b7ae3c3d85bc30923b326c927ed1\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n *\\n * Furthermore, `isContract` will also return true if the target contract within\\n * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,\\n * which only has an effect at the end of a transaction.\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x006dd67219697fe68d7fbfdea512e7c4cb64a43565ed86171d67e844982da6fa\",\"license\":\"MIT\"},\"contracts/chain-adapters/ZkStack_Adapter.sol\":{\"content\":\"// SPDX-License-Identifier: BUSL-1.1\\npragma solidity ^0.8.0;\\n\\nimport \\\"./interfaces/AdapterInterface.sol\\\";\\nimport \\\"../external/interfaces/WETH9Interface.sol\\\";\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\nimport { BridgeHubInterface } from \\\"../interfaces/ZkStackBridgeHub.sol\\\";\\n\\n/**\\n * @notice Contract containing logic to send messages from L1 to ZkStack with ETH as the gas token.\\n * @dev Public functions calling external contracts do not guard against reentrancy because they are expected to be\\n * called via delegatecall, which will execute this contract's logic within the context of the originating contract.\\n * For example, the HubPool will delegatecall these functions, therefore its only necessary that the HubPool's methods\\n * that call this contract's logic guard against reentrancy.\\n * @custom:security-contact bugs@across.to\\n */\\n\\n// solhint-disable-next-line contract-name-camelcase\\ncontract ZkStack_Adapter is AdapterInterface {\\n using SafeERC20 for IERC20;\\n\\n // The ZkSync bridgehub contract treats address(1) to represent ETH.\\n address private constant ETH_TOKEN_ADDRESS = address(1);\\n\\n // We need to pay a base fee to the operator to include our L1 --> L2 transaction.\\n // https://docs.zksync.io/build/developer-reference/l1-l2-interoperability#l1-to-l2-gas-estimation-for-transactions\\n\\n // Limit on L2 gas to spend.\\n uint256 public immutable L2_GAS_LIMIT; // typically 2_000_000\\n\\n // How much gas is required to publish a byte of data from L1 to L2. 800 is the required value\\n // as set here https://github.com/matter-labs/era-contracts/blob/6391c0d7bf6184d7f6718060e3991ba6f0efe4a7/ethereum/contracts/zksync/facets/Mailbox.sol#L226\\n // Note, this value can change and will require an updated adapter.\\n uint256 public immutable L1_GAS_TO_L2_GAS_PER_PUB_DATA_LIMIT; // Typically 800\\n\\n // This address receives any remaining fee after an L1 to L2 transaction completes.\\n // If refund recipient = address(0) then L2 msg.sender is used, unless msg.sender is a contract then its address\\n // gets aliased.\\n address public immutable L2_REFUND_ADDRESS;\\n\\n // L2 chain id\\n uint256 public immutable CHAIN_ID;\\n\\n // BridgeHub address\\n BridgeHubInterface public immutable BRIDGE_HUB;\\n\\n // Set l1Weth at construction time to make testing easier.\\n WETH9Interface public immutable L1_WETH;\\n\\n // SharedBridge address, which is read from the BridgeHub at construction.\\n address public immutable SHARED_BRIDGE;\\n\\n // The maximum gas price a transaction sent to this adapter may have. This is set to prevent a block producer from setting an artificially high priority fee\\n // when calling a hub pool message relay, which would otherwise cause a large amount of ETH to be sent to L2.\\n uint256 private immutable MAX_TX_GASPRICE;\\n\\n event ZkStackMessageRelayed(bytes32 indexed canonicalTxHash);\\n\\n error ETHGasTokenRequired();\\n error TransactionFeeTooHigh();\\n\\n /**\\n * @notice Constructs new Adapter.\\n * @param _chainId The target ZkStack network's chain ID.\\n * @param _bridgeHub The bridge hub contract address for the ZkStack network.\\n * @param _l1Weth WETH address on L1.\\n * @param _l2RefundAddress address that recieves excess gas refunds on L2.\\n * @param _l2GasLimit The maximum amount of gas this contract is willing to pay to execute a transaction on L2.\\n * @param _l1GasToL2GasPerPubDataLimit The exchange rate of l1 gas to l2 gas.\\n * @param _maxTxGasprice The maximum effective gas price any transaction sent to this adapter may have.\\n */\\n constructor(\\n uint256 _chainId,\\n BridgeHubInterface _bridgeHub,\\n WETH9Interface _l1Weth,\\n address _l2RefundAddress,\\n uint256 _l2GasLimit,\\n uint256 _l1GasToL2GasPerPubDataLimit,\\n uint256 _maxTxGasprice\\n ) {\\n CHAIN_ID = _chainId;\\n BRIDGE_HUB = _bridgeHub;\\n L1_WETH = _l1Weth;\\n L2_REFUND_ADDRESS = _l2RefundAddress;\\n L2_GAS_LIMIT = _l2GasLimit;\\n MAX_TX_GASPRICE = _maxTxGasprice;\\n L1_GAS_TO_L2_GAS_PER_PUB_DATA_LIMIT = _l1GasToL2GasPerPubDataLimit;\\n SHARED_BRIDGE = BRIDGE_HUB.sharedBridge();\\n address gasToken = BRIDGE_HUB.baseToken(CHAIN_ID);\\n if (gasToken != ETH_TOKEN_ADDRESS) {\\n revert ETHGasTokenRequired();\\n }\\n }\\n\\n /**\\n * @notice Send cross-chain message to target on ZkStack.\\n * @dev The HubPool must hold enough ETH to pay for the L2 txn.\\n * @param target Contract on L2 that will receive message.\\n * @param message Data to send to target.\\n */\\n function relayMessage(address target, bytes memory message) external payable override {\\n uint256 txBaseCost = _computeETHTxCost(L2_GAS_LIMIT);\\n\\n // Returns the hash of the requested L2 transaction. This hash can be used to follow the transaction status.\\n bytes32 canonicalTxHash = BRIDGE_HUB.requestL2TransactionDirect{ value: txBaseCost }(\\n BridgeHubInterface.L2TransactionRequestDirect({\\n chainId: CHAIN_ID,\\n mintValue: txBaseCost,\\n l2Contract: target,\\n l2Value: 0,\\n l2Calldata: message,\\n l2GasLimit: L2_GAS_LIMIT,\\n l2GasPerPubdataByteLimit: L1_GAS_TO_L2_GAS_PER_PUB_DATA_LIMIT,\\n factoryDeps: new bytes[](0),\\n refundRecipient: L2_REFUND_ADDRESS\\n })\\n );\\n\\n emit MessageRelayed(target, message);\\n emit ZkStackMessageRelayed(canonicalTxHash);\\n }\\n\\n /**\\n * @notice Bridge tokens to ZkStack.\\n * @dev The HubPool must hold enough ETH to pay for the L2 txn.\\n * @param l1Token L1 token to deposit.\\n * @param l2Token L2 token to receive.\\n * @param amount Amount of L1 tokens to deposit and L2 tokens to receive.\\n * @param to Bridge recipient.\\n */\\n function relayTokens(\\n address l1Token,\\n address l2Token, // l2Token is unused.\\n uint256 amount,\\n address to\\n ) external payable override {\\n // A bypass proxy seems to no longer be needed to avoid deposit limits. The tracking of these limits seems to be deprecated.\\n // See: https://github.com/matter-labs/era-contracts/blob/bce4b2d0f34bd87f1aaadd291772935afb1c3bd6/l1-contracts/contracts/bridge/L1ERC20Bridge.sol#L54-L55\\n uint256 txBaseCost = _computeETHTxCost(L2_GAS_LIMIT);\\n\\n bytes32 txHash;\\n if (l1Token == address(L1_WETH)) {\\n // If the l1Token is WETH then unwrap it to ETH then send the ETH to the standard bridge along with the base\\n // cost.\\n L1_WETH.withdraw(amount);\\n txHash = BRIDGE_HUB.requestL2TransactionDirect{ value: amount + txBaseCost }(\\n BridgeHubInterface.L2TransactionRequestDirect({\\n chainId: CHAIN_ID,\\n mintValue: txBaseCost + amount,\\n l2Contract: to,\\n l2Value: amount,\\n l2Calldata: \\\"\\\",\\n l2GasLimit: L2_GAS_LIMIT,\\n l2GasPerPubdataByteLimit: L1_GAS_TO_L2_GAS_PER_PUB_DATA_LIMIT,\\n factoryDeps: new bytes[](0),\\n refundRecipient: L2_REFUND_ADDRESS\\n })\\n );\\n } else {\\n // An ERC20 that is not WETH.\\n IERC20(l1Token).forceApprove(SHARED_BRIDGE, amount);\\n txHash = BRIDGE_HUB.requestL2TransactionTwoBridges{ value: txBaseCost }(\\n BridgeHubInterface.L2TransactionRequestTwoBridgesOuter({\\n chainId: CHAIN_ID,\\n mintValue: txBaseCost,\\n l2Value: 0,\\n l2GasLimit: L2_GAS_LIMIT,\\n l2GasPerPubdataByteLimit: L1_GAS_TO_L2_GAS_PER_PUB_DATA_LIMIT,\\n refundRecipient: L2_REFUND_ADDRESS,\\n secondBridgeAddress: SHARED_BRIDGE,\\n secondBridgeValue: 0,\\n secondBridgeCalldata: _secondBridgeCalldata(to, l1Token, amount)\\n })\\n );\\n }\\n\\n emit TokensRelayed(l1Token, l2Token, amount, to);\\n emit ZkStackMessageRelayed(txHash);\\n }\\n\\n /**\\n * @notice Computes the calldata for the \\\"second bridge\\\", which handles sending non native tokens.\\n * @param l2Recipient recipient of the tokens.\\n * @param l1Token the l1 address of the token. Note: ETH is encoded as address(1).\\n * @param amount number of tokens to send.\\n * @return abi encoded bytes.\\n */\\n function _secondBridgeCalldata(\\n address l2Recipient,\\n address l1Token,\\n uint256 amount\\n ) internal pure returns (bytes memory) {\\n return abi.encode(l1Token, amount, l2Recipient);\\n }\\n\\n /**\\n * @notice For a given l2 gas limit, this computes the amount of ETH needed and\\n * returns the amount.\\n * @param l2GasLimit L2 gas limit for the message.\\n * @return amount of ETH that this contract needs to provide in order for the l2 transaction to succeed.\\n */\\n function _computeETHTxCost(uint256 l2GasLimit) internal view returns (uint256) {\\n if (tx.gasprice > MAX_TX_GASPRICE) revert TransactionFeeTooHigh();\\n return BRIDGE_HUB.l2TransactionBaseCost(CHAIN_ID, tx.gasprice, l2GasLimit, L1_GAS_TO_L2_GAS_PER_PUB_DATA_LIMIT);\\n }\\n\\n receive() external payable {}\\n}\\n\",\"keccak256\":\"0xad3121d3b9ab6fd8c6994337606923911d5202eeb82f4fda7a5d73a4e22ed1ce\",\"license\":\"BUSL-1.1\"},\"contracts/chain-adapters/interfaces/AdapterInterface.sol\":{\"content\":\"// SPDX-License-Identifier: BUSL-1.1\\npragma solidity ^0.8.0;\\n\\n/**\\n * @notice Sends cross chain messages and tokens to contracts on a specific L2 network.\\n * This interface is implemented by an adapter contract that is deployed on L1.\\n */\\n\\ninterface AdapterInterface {\\n event MessageRelayed(address target, bytes message);\\n\\n event TokensRelayed(address l1Token, address l2Token, uint256 amount, address to);\\n\\n /**\\n * @notice Send message to `target` on L2.\\n * @dev This method is marked payable because relaying the message might require a fee\\n * to be paid by the sender to forward the message to L2. However, it will not send msg.value\\n * to the target contract on L2.\\n * @param target L2 address to send message to.\\n * @param message Message to send to `target`.\\n */\\n function relayMessage(address target, bytes calldata message) external payable;\\n\\n /**\\n * @notice Send `amount` of `l1Token` to `to` on L2. `l2Token` is the L2 address equivalent of `l1Token`.\\n * @dev This method is marked payable because relaying the message might require a fee\\n * to be paid by the sender to forward the message to L2. However, it will not send msg.value\\n * to the target contract on L2.\\n * @param l1Token L1 token to bridge.\\n * @param l2Token L2 token to receive.\\n * @param amount Amount of `l1Token` to bridge.\\n * @param to Bridge recipient.\\n */\\n function relayTokens(\\n address l1Token,\\n address l2Token,\\n uint256 amount,\\n address to\\n ) external payable;\\n}\\n\",\"keccak256\":\"0x1d52fcb8b10dc7f260345918c1a90d496a4c9f774402cbd5ebde881b8fed6d50\",\"license\":\"BUSL-1.1\"},\"contracts/external/interfaces/WETH9Interface.sol\":{\"content\":\"// SPDX-License-Identifier: BUSL-1.1\\npragma solidity ^0.8.0;\\n\\n/**\\n * @notice Interface for the WETH9 contract.\\n */\\ninterface WETH9Interface {\\n /**\\n * @notice Burn Wrapped Ether and receive native Ether.\\n * @param wad Amount of WETH to unwrap and send to caller.\\n */\\n function withdraw(uint256 wad) external;\\n\\n /**\\n * @notice Lock native Ether and mint Wrapped Ether ERC20\\n * @dev msg.value is amount of Wrapped Ether to mint/Ether to lock.\\n */\\n function deposit() external payable;\\n\\n /**\\n * @notice Get balance of WETH held by `guy`.\\n * @param guy Address to get balance of.\\n * @return wad Amount of WETH held by `guy`.\\n */\\n function balanceOf(address guy) external view returns (uint256 wad);\\n\\n /**\\n * @notice Transfer `wad` of WETH from caller to `guy`.\\n * @param guy Address to send WETH to.\\n * @param wad Amount of WETH to send.\\n * @return ok True if transfer succeeded.\\n */\\n function transfer(address guy, uint256 wad) external returns (bool);\\n}\\n\",\"keccak256\":\"0x3f7892554ec7f54681fdd3cc18a41346c246c9c1afba016c52990ef77741f718\",\"license\":\"BUSL-1.1\"},\"contracts/interfaces/ZkStackBridgeHub.sol\":{\"content\":\"// SPDX-License-Identifier: BUSL-1.1\\npragma solidity ^0.8.0;\\n\\n/**\\n * @title BridgeHubInterface\\n * @notice This interface is shared between ZkStack adapters. It is the main interaction point for bridging to ZkStack chains.\\n */\\ninterface BridgeHubInterface {\\n struct L2TransactionRequestDirect {\\n uint256 chainId;\\n uint256 mintValue;\\n address l2Contract;\\n uint256 l2Value;\\n bytes l2Calldata;\\n uint256 l2GasLimit;\\n uint256 l2GasPerPubdataByteLimit;\\n bytes[] factoryDeps;\\n address refundRecipient;\\n }\\n\\n /**\\n * @notice the mailbox is called directly after the sharedBridge received the deposit.\\n * This assumes that either ether is the base token or the msg.sender has approved mintValue allowance for the\\n * sharedBridge. This means this is not ideal for contract calls, as the contract would have to handle token\\n * allowance of the base Token.\\n * @param _request the direct request.\\n */\\n function requestL2TransactionDirect(L2TransactionRequestDirect calldata _request)\\n external\\n payable\\n returns (bytes32 canonicalTxHash);\\n\\n struct L2TransactionRequestTwoBridgesOuter {\\n uint256 chainId;\\n uint256 mintValue;\\n uint256 l2Value;\\n uint256 l2GasLimit;\\n uint256 l2GasPerPubdataByteLimit;\\n address refundRecipient;\\n address secondBridgeAddress;\\n uint256 secondBridgeValue;\\n bytes secondBridgeCalldata;\\n }\\n\\n /**\\n * @notice After depositing funds to the sharedBridge, the secondBridge is called to return the actual L2 message\\n * which is sent to the Mailbox. This assumes that either ether is the base token or the msg.sender has approved\\n * the sharedBridge with the mintValue, and also the necessary approvals are given for the second bridge. The logic\\n * of this bridge is to allow easy depositing for bridges. Each contract that handles the users ERC20 tokens needs\\n * approvals from the user, this contract allows the user to approve for each token only its respective bridge.\\n * This function is great for contract calls to L2, the secondBridge can be any contract.\\n * @param _request the two bridges request.\\n */\\n function requestL2TransactionTwoBridges(L2TransactionRequestTwoBridgesOuter calldata _request)\\n external\\n payable\\n returns (bytes32 canonicalTxHash);\\n\\n /**\\n * @notice Gets the shared bridge.\\n * @dev The shared bridge manages ERC20 tokens.\\n */\\n function sharedBridge() external view returns (address);\\n\\n /**\\n * @notice Gets the base token for a chain.\\n * @dev Base token == native token.\\n */\\n function baseToken(uint256 _chainId) external view returns (address);\\n\\n /**\\n * @notice Computes the base transaction cost for a transaction.\\n * @param _chainId the chain the transaction is being sent to.\\n * @param _gasPrice the l1 gas price at time of execution.\\n * @param _l2GasLimit the gas limit for the l2 transaction.\\n * @param _l2GasPerPubdataByteLimit configuration value that changes infrequently.\\n */\\n function l2TransactionBaseCost(\\n uint256 _chainId,\\n uint256 _gasPrice,\\n uint256 _l2GasLimit,\\n uint256 _l2GasPerPubdataByteLimit\\n ) external view returns (uint256);\\n}\\n\",\"keccak256\":\"0x0304722d9d0e7eeea6e7163edcc6664214bf7fc7ddb4250cda85f9c9267e0cf8\",\"license\":\"BUSL-1.1\"}},\"version\":1}", + "bytecode": "0x61018060409080825234620002215760e08162001521803803809162000026828562000280565b83398101031262000221578051602080830151936001600160a01b038086169290838703620002215782860151958187168703620002215760049481620000716060869401620002b8565b60808201519060c060a08401519301519960e0526101009b8c526101209a8b5260c05260805261016097885260a05284519586809263070e40ef60e31b82525afa93841562000276575f9462000237575b5061014093845280875116918060e0516024865180968193632cf632d160e11b835260048301525afa9081156200022d575f91620001eb575b50600192501603620001db5751926112539485620002ce8639608051858181610116015281816104060152610582015260a0518581816101b7015281816103ae015281816106b8015281816109c5015261102a015260c0518581816101e3015281816106f801528181610a000152610cf6015260e051858181610177015281816103560152818161066e015281816109930152610ff9015251848181610241015281816104730152818161076a01528181610b0c015261106b0152518381816105c50152610c8a0152518281816104e1015261090801525181610fab0152f35b516308ca5c0760e31b8152600490fd5b905082813d831162000225575b62000204818362000280565b8101031262000221576200021a600192620002b8565b5f620000fb565b5f80fd5b503d620001f8565b84513d5f823e3d90fd5b9093508181813d83116200026e575b62000252818362000280565b8101031262000221576200026690620002b8565b925f620000c2565b503d62000246565b83513d5f823e3d90fd5b601f909101601f19168101906001600160401b03821190821017620002a457604052565b634e487b7160e01b5f52604160045260245ffd5b51906001600160a01b0382168203620002215756fe60806040818152600436101561001e575b5050361561001c575f80fd5b005b5f915f3560e01c90816303c0501914610cae575080631efd482a14610c4057806352c8c75c14610505578063546b6d2a146104975780635d4edca7146104295780635e743ef7146103d15780636c9075b71461037957806385e1f4d0146103215763e6eb8ade0361001057807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031d576100ba610d1a565b60243567ffffffffffffffff8111610319573660238201121561031957806004013590846100e783610dd3565b916100f486519384610d92565b83835260209336602482840101116103155780602486930183860137830101527f0000000000000000000000000000000000000000000000000000000000000000908261023d61014384610fa9565b9573ffffffffffffffffffffffffffffffffffffffff90885161016581610d76565b5f8152828a519261017584610d3d565b7f000000000000000000000000000000000000000000000000000000000000000084528a878501521696878b8401528b606084015286608084015260a08301527f000000000000000000000000000000000000000000000000000000000000000060c083015260e0820152817f00000000000000000000000000000000000000000000000000000000000000001661010082015288519788809481937fd52471c100000000000000000000000000000000000000000000000000000000835260048301610ea3565b03927f0000000000000000000000000000000000000000000000000000000000000000165af193841561030b5786946102d6575b506102ac9085807f9e6c52944e331ba6270e7fe4cea2a4086bae8f7a27e1cdba07f416806f5d0ac49697519586958652850152830190610e0d565b0390a17fb50bccea676fbc831e47d257acd0dbaa101ff4d469933d6d9e6ad85c2d4b63b98280a280f35b9093508281813d8311610304575b6102ee8183610d92565b810103126103005751926102ac610271565b5f80fd5b503d6102e4565b85513d88823e3d90fd5b8280fd5b8380fd5b5080fd5b503461031d57817ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031d57602090517f00000000000000000000000000000000000000000000000000000000000000008152f35b503461031d57817ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031d57602090517f00000000000000000000000000000000000000000000000000000000000000008152f35b503461031d57817ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031d57602090517f00000000000000000000000000000000000000000000000000000000000000008152f35b503461031d57817ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031d576020905173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000168152f35b503461031d57817ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031d576020905173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000168152f35b5060807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261030057610538610d1a565b906024359173ffffffffffffffffffffffffffffffffffffffff8316809303610300576044356064359073ffffffffffffffffffffffffffffffffffffffff8216809203610300577f00000000000000000000000000000000000000000000000000000000000000006105aa81610fa9565b73ffffffffffffffffffffffffffffffffffffffff948516947f0000000000000000000000000000000000000000000000000000000000000000168581036108b857803b15610300575f809160248951809481937f2e1a7d4d0000000000000000000000000000000000000000000000000000000083528960048401525af180156108ae57610863575b5061075191816106508561064a60209582610e69565b92610e69565b9188519061065d82610d76565b5f825289519361066c85610d3d565b7f0000000000000000000000000000000000000000000000000000000000000000855285850152878a85015286606085015289516106a981610d76565b8c8152608085015260a08401527f000000000000000000000000000000000000000000000000000000000000000060c084015260e083015273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016610100830152875180809581947fd52471c100000000000000000000000000000000000000000000000000000000835260048301610ea3565b039173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000165af19081156108595787916107ff575b50907fd7e09655439c3932e55857df3220186e5a7f0980825f20691c2b35d941dee75b946080949392965b815194855260208501528301526060820152a17fb50bccea676fbc831e47d257acd0dbaa101ff4d469933d6d9e6ad85c2d4b63b98280a280f35b93929190506020843d602011610851575b8161081d60209383610d92565b81010312610300579251919290917fd7e09655439c3932e55857df3220186e5a7f0980825f20691c2b35d941dee75b61079a565b3d9150610810565b85513d89823e3d90fd5b90975067ffffffffffffffff81116108815785525f96610751610634565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b87513d5f823e3d90fd5b50610100602091610af3938851848101907f095ea7b300000000000000000000000000000000000000000000000000000000908183525f808c73ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016958660248601528c60448601526044855261094285610d5a565b828551925af1610950611102565b81610c13575b5080610c09575b15610bcf575b50508951908986830152878b8301528860608301526060825261098582610d5a565b8a519261099184610d3d565b7f0000000000000000000000000000000000000000000000000000000000000000845284878501525f8c85015260608401527f0000000000000000000000000000000000000000000000000000000000000000608084015273ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001660a084015260c08301525f60e08301528382015288518095819482937f24fd57fb000000000000000000000000000000000000000000000000000000008452876004850152805160248501528781015160448501528c810151606485015260608101516084850152608081015160a485015273ffffffffffffffffffffffffffffffffffffffff60a08201511660c485015273ffffffffffffffffffffffffffffffffffffffff60c08201511660e485015260e08101516101048501520151610120610124840152610144830190610e0d565b039173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000165af1908115610bc5575f91610b6b575b50907fd7e09655439c3932e55857df3220186e5a7f0980825f20691c2b35d941dee75b946080949392966107c5565b93929190506020843d602011610bbd575b81610b8960209383610d92565b81010312610300579251919290917fd7e09655439c3932e55857df3220186e5a7f0980825f20691c2b35d941dee75b610b3c565b3d9150610b7c565b85513d5f823e3d90fd5b610bfc610c02928d5190898201528460248201525f604482015260448152610bf681610d5a565b8c611149565b8a611149565b5f80610963565b508a3b151561095d565b8051801592508215610c28575b50505f610956565b610c39925081018901908901611131565b5f80610c20565b5034610300575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610300576020905173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000168152f35b34610300575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126103005760209073ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000168152f35b6004359073ffffffffffffffffffffffffffffffffffffffff8216820361030057565b610120810190811067ffffffffffffffff82111761088157604052565b6080810190811067ffffffffffffffff82111761088157604052565b6020810190811067ffffffffffffffff82111761088157604052565b90601f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0910116810190811067ffffffffffffffff82111761088157604052565b67ffffffffffffffff811161088157601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b91908251928382525f5b848110610e555750507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f845f6020809697860101520116010190565b602081830181015184830182015201610e17565b91908201809211610e7657565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b6020808252825181830152808301516040830152604083015173ffffffffffffffffffffffffffffffffffffffff809116606084015260608401516080840152608084015191610f01610120938460a0870152610140860190610e0d565b9460a081015160c086015260c081015160e086015260e0810151957fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0906101009382888303018589015288519182815281810182808560051b8401019b01945f925b858410610f7a575050505050505001511691015290565b9091929394959b8580610f988f936001948787830301895251610e0d565b9e0194019401929594939190610f63565b7f00000000000000000000000000000000000000000000000000000000000000003a116110d857604051907f716232740000000000000000000000000000000000000000000000000000000082527f000000000000000000000000000000000000000000000000000000000000000060048301523a602483015260448201527f0000000000000000000000000000000000000000000000000000000000000000606482015260208160848173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000165afa9081156110cd575f9161109e575090565b90506020813d6020116110c5575b816110b960209383610d92565b81010312610300575190565b3d91506110ac565b6040513d5f823e3d90fd5b60046040517fb33009b4000000000000000000000000000000000000000000000000000000008152fd5b3d1561112c573d9061111382610dd3565b916111216040519384610d92565b82523d5f602084013e565b606090565b90816020910312610300575180151581036103005790565b73ffffffffffffffffffffffffffffffffffffffff166040516040810181811067ffffffffffffffff821117610881576111c4937f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c656460205f948594604052818152015260208151910182855af16111be611102565b916111f4565b80519081159182156111da575b50501561030057565b6111ed9250602080918301019101611131565b5f806111d1565b901561120e57815115611205575090565b3b156103005790565b50805190811561030057602001fdfea2646970667358221220deabf7aa25bbf70a797679695bc79e50bca51d1a116597e90cb7530b89f3744464736f6c63430008170033", + "deployedBytecode": "0x60806040818152600436101561001e575b5050361561001c575f80fd5b005b5f915f3560e01c90816303c0501914610cae575080631efd482a14610c4057806352c8c75c14610505578063546b6d2a146104975780635d4edca7146104295780635e743ef7146103d15780636c9075b71461037957806385e1f4d0146103215763e6eb8ade0361001057807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031d576100ba610d1a565b60243567ffffffffffffffff8111610319573660238201121561031957806004013590846100e783610dd3565b916100f486519384610d92565b83835260209336602482840101116103155780602486930183860137830101527f0000000000000000000000000000000000000000000000000000000000000000908261023d61014384610fa9565b9573ffffffffffffffffffffffffffffffffffffffff90885161016581610d76565b5f8152828a519261017584610d3d565b7f000000000000000000000000000000000000000000000000000000000000000084528a878501521696878b8401528b606084015286608084015260a08301527f000000000000000000000000000000000000000000000000000000000000000060c083015260e0820152817f00000000000000000000000000000000000000000000000000000000000000001661010082015288519788809481937fd52471c100000000000000000000000000000000000000000000000000000000835260048301610ea3565b03927f0000000000000000000000000000000000000000000000000000000000000000165af193841561030b5786946102d6575b506102ac9085807f9e6c52944e331ba6270e7fe4cea2a4086bae8f7a27e1cdba07f416806f5d0ac49697519586958652850152830190610e0d565b0390a17fb50bccea676fbc831e47d257acd0dbaa101ff4d469933d6d9e6ad85c2d4b63b98280a280f35b9093508281813d8311610304575b6102ee8183610d92565b810103126103005751926102ac610271565b5f80fd5b503d6102e4565b85513d88823e3d90fd5b8280fd5b8380fd5b5080fd5b503461031d57817ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031d57602090517f00000000000000000000000000000000000000000000000000000000000000008152f35b503461031d57817ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031d57602090517f00000000000000000000000000000000000000000000000000000000000000008152f35b503461031d57817ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031d57602090517f00000000000000000000000000000000000000000000000000000000000000008152f35b503461031d57817ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031d576020905173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000168152f35b503461031d57817ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031d576020905173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000168152f35b5060807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261030057610538610d1a565b906024359173ffffffffffffffffffffffffffffffffffffffff8316809303610300576044356064359073ffffffffffffffffffffffffffffffffffffffff8216809203610300577f00000000000000000000000000000000000000000000000000000000000000006105aa81610fa9565b73ffffffffffffffffffffffffffffffffffffffff948516947f0000000000000000000000000000000000000000000000000000000000000000168581036108b857803b15610300575f809160248951809481937f2e1a7d4d0000000000000000000000000000000000000000000000000000000083528960048401525af180156108ae57610863575b5061075191816106508561064a60209582610e69565b92610e69565b9188519061065d82610d76565b5f825289519361066c85610d3d565b7f0000000000000000000000000000000000000000000000000000000000000000855285850152878a85015286606085015289516106a981610d76565b8c8152608085015260a08401527f000000000000000000000000000000000000000000000000000000000000000060c084015260e083015273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016610100830152875180809581947fd52471c100000000000000000000000000000000000000000000000000000000835260048301610ea3565b039173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000165af19081156108595787916107ff575b50907fd7e09655439c3932e55857df3220186e5a7f0980825f20691c2b35d941dee75b946080949392965b815194855260208501528301526060820152a17fb50bccea676fbc831e47d257acd0dbaa101ff4d469933d6d9e6ad85c2d4b63b98280a280f35b93929190506020843d602011610851575b8161081d60209383610d92565b81010312610300579251919290917fd7e09655439c3932e55857df3220186e5a7f0980825f20691c2b35d941dee75b61079a565b3d9150610810565b85513d89823e3d90fd5b90975067ffffffffffffffff81116108815785525f96610751610634565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b87513d5f823e3d90fd5b50610100602091610af3938851848101907f095ea7b300000000000000000000000000000000000000000000000000000000908183525f808c73ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016958660248601528c60448601526044855261094285610d5a565b828551925af1610950611102565b81610c13575b5080610c09575b15610bcf575b50508951908986830152878b8301528860608301526060825261098582610d5a565b8a519261099184610d3d565b7f0000000000000000000000000000000000000000000000000000000000000000845284878501525f8c85015260608401527f0000000000000000000000000000000000000000000000000000000000000000608084015273ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001660a084015260c08301525f60e08301528382015288518095819482937f24fd57fb000000000000000000000000000000000000000000000000000000008452876004850152805160248501528781015160448501528c810151606485015260608101516084850152608081015160a485015273ffffffffffffffffffffffffffffffffffffffff60a08201511660c485015273ffffffffffffffffffffffffffffffffffffffff60c08201511660e485015260e08101516101048501520151610120610124840152610144830190610e0d565b039173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000165af1908115610bc5575f91610b6b575b50907fd7e09655439c3932e55857df3220186e5a7f0980825f20691c2b35d941dee75b946080949392966107c5565b93929190506020843d602011610bbd575b81610b8960209383610d92565b81010312610300579251919290917fd7e09655439c3932e55857df3220186e5a7f0980825f20691c2b35d941dee75b610b3c565b3d9150610b7c565b85513d5f823e3d90fd5b610bfc610c02928d5190898201528460248201525f604482015260448152610bf681610d5a565b8c611149565b8a611149565b5f80610963565b508a3b151561095d565b8051801592508215610c28575b50505f610956565b610c39925081018901908901611131565b5f80610c20565b5034610300575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610300576020905173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000168152f35b34610300575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126103005760209073ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000168152f35b6004359073ffffffffffffffffffffffffffffffffffffffff8216820361030057565b610120810190811067ffffffffffffffff82111761088157604052565b6080810190811067ffffffffffffffff82111761088157604052565b6020810190811067ffffffffffffffff82111761088157604052565b90601f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0910116810190811067ffffffffffffffff82111761088157604052565b67ffffffffffffffff811161088157601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b91908251928382525f5b848110610e555750507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f845f6020809697860101520116010190565b602081830181015184830182015201610e17565b91908201809211610e7657565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b6020808252825181830152808301516040830152604083015173ffffffffffffffffffffffffffffffffffffffff809116606084015260608401516080840152608084015191610f01610120938460a0870152610140860190610e0d565b9460a081015160c086015260c081015160e086015260e0810151957fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0906101009382888303018589015288519182815281810182808560051b8401019b01945f925b858410610f7a575050505050505001511691015290565b9091929394959b8580610f988f936001948787830301895251610e0d565b9e0194019401929594939190610f63565b7f00000000000000000000000000000000000000000000000000000000000000003a116110d857604051907f716232740000000000000000000000000000000000000000000000000000000082527f000000000000000000000000000000000000000000000000000000000000000060048301523a602483015260448201527f0000000000000000000000000000000000000000000000000000000000000000606482015260208160848173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000165afa9081156110cd575f9161109e575090565b90506020813d6020116110c5575b816110b960209383610d92565b81010312610300575190565b3d91506110ac565b6040513d5f823e3d90fd5b60046040517fb33009b4000000000000000000000000000000000000000000000000000000008152fd5b3d1561112c573d9061111382610dd3565b916111216040519384610d92565b82523d5f602084013e565b606090565b90816020910312610300575180151581036103005790565b73ffffffffffffffffffffffffffffffffffffffff166040516040810181811067ffffffffffffffff821117610881576111c4937f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c656460205f948594604052818152015260208151910182855af16111be611102565b916111f4565b80519081159182156111da575b50501561030057565b6111ed9250602080918301019101611131565b5f806111d1565b901561120e57815115611205575090565b3b156103005790565b50805190811561030057602001fdfea2646970667358221220deabf7aa25bbf70a797679695bc79e50bca51d1a116597e90cb7530b89f3744464736f6c63430008170033", + "devdoc": { + "custom:security-contact": "bugs@across.to", + "details": "Public functions calling external contracts do not guard against reentrancy because they are expected to be called via delegatecall, which will execute this contract's logic within the context of the originating contract. For example, the HubPool will delegatecall these functions, therefore its only necessary that the HubPool's methods that call this contract's logic guard against reentrancy.", + "kind": "dev", + "methods": { + "constructor": { + "params": { + "_bridgeHub": "The bridge hub contract address for the ZkStack network.", + "_chainId": "The target ZkStack network's chain ID.", + "_l1GasToL2GasPerPubDataLimit": "The exchange rate of l1 gas to l2 gas.", + "_l1Weth": "WETH address on L1.", + "_l2GasLimit": "The maximum amount of gas this contract is willing to pay to execute a transaction on L2.", + "_l2RefundAddress": "address that recieves excess gas refunds on L2.", + "_maxTxGasprice": "The maximum effective gas price any transaction sent to this adapter may have." + } + }, + "relayMessage(address,bytes)": { + "details": "The HubPool must hold enough ETH to pay for the L2 txn.", + "params": { + "message": "Data to send to target.", + "target": "Contract on L2 that will receive message." + } + }, + "relayTokens(address,address,uint256,address)": { + "details": "The HubPool must hold enough ETH to pay for the L2 txn.", + "params": { + "amount": "Amount of L1 tokens to deposit and L2 tokens to receive.", + "l1Token": "L1 token to deposit.", + "l2Token": "L2 token to receive.", + "to": "Bridge recipient." + } + } + }, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": { + "constructor": { + "notice": "Constructs new Adapter." + }, + "relayMessage(address,bytes)": { + "notice": "Send cross-chain message to target on ZkStack." + }, + "relayTokens(address,address,uint256,address)": { + "notice": "Bridge tokens to ZkStack." + } + }, + "notice": "Contract containing logic to send messages from L1 to ZkStack with ETH as the gas token.", + "version": 1 + }, + "storageLayout": { + "storage": [], + "types": null + } +} diff --git a/deployments/mainnet/solcInputs/52176bdd062b3053719867884494ff14.json b/deployments/mainnet/solcInputs/52176bdd062b3053719867884494ff14.json new file mode 100644 index 000000000..e27574804 --- /dev/null +++ b/deployments/mainnet/solcInputs/52176bdd062b3053719867884494ff14.json @@ -0,0 +1,58 @@ +{ + "language": "Solidity", + "sources": { + "@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.4) (token/ERC20/extensions/IERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n *\n * ==== Security Considerations\n *\n * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature\n * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be\n * considered as an intention to spend the allowance in any specific way. The second is that because permits have\n * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should\n * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be\n * generally recommended is:\n *\n * ```solidity\n * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {\n * try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}\n * doThing(..., value);\n * }\n *\n * function doThing(..., uint256 value) public {\n * token.safeTransferFrom(msg.sender, address(this), value);\n * ...\n * }\n * ```\n *\n * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of\n * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also\n * {SafeERC20-safeTransferFrom}).\n *\n * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so\n * contracts should have entry points that don't rely on permit.\n */\ninterface IERC20Permit {\n /**\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n * given ``owner``'s signed approval.\n *\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n * ordering also apply here.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `deadline` must be a timestamp in the future.\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n * over the EIP712-formatted function arguments.\n * - the signature must use ``owner``'s current nonce (see {nonces}).\n *\n * For more information on the signature format, see the\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n * section].\n *\n * CAUTION: See Security Considerations above.\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Returns the current nonce for `owner`. This value must be\n * included whenever a signature is generated for {permit}.\n *\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\n * prevents a signature from being used multiple times.\n */\n function nonces(address owner) external view returns (uint256);\n\n /**\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/IERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n\n /**\n * @dev Returns the amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 amount) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(address from, address to, uint256 amount) external returns (bool);\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\nimport \"../extensions/IERC20Permit.sol\";\nimport \"../../../utils/Address.sol\";\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\n * contract returns false). Tokens that return no value (and instead revert or\n * throw on failure) are also supported, non-reverting calls are assumed to be\n * successful.\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\n */\nlibrary SafeERC20 {\n using Address for address;\n\n /**\n * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,\n * non-reverting calls are assumed to be successful.\n */\n function safeTransfer(IERC20 token, address to, uint256 value) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n /**\n * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the\n * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.\n */\n function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n }\n\n /**\n * @dev Deprecated. This function has issues similar to the ones found in\n * {IERC20-approve}, and its usage is discouraged.\n *\n * Whenever possible, use {safeIncreaseAllowance} and\n * {safeDecreaseAllowance} instead.\n */\n function safeApprove(IERC20 token, address spender, uint256 value) internal {\n // safeApprove should only be called when setting an initial allowance,\n // or when resetting it to zero. To increase and decrease it, use\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n require(\n (value == 0) || (token.allowance(address(this), spender) == 0),\n \"SafeERC20: approve from non-zero to non-zero allowance\"\n );\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n }\n\n /**\n * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\n * non-reverting calls are assumed to be successful.\n */\n function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {\n uint256 oldAllowance = token.allowance(address(this), spender);\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));\n }\n\n /**\n * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\n * non-reverting calls are assumed to be successful.\n */\n function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {\n unchecked {\n uint256 oldAllowance = token.allowance(address(this), spender);\n require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));\n }\n }\n\n /**\n * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,\n * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval\n * to be set to zero before setting it to a non-zero value, such as USDT.\n */\n function forceApprove(IERC20 token, address spender, uint256 value) internal {\n bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);\n\n if (!_callOptionalReturnBool(token, approvalCall)) {\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));\n _callOptionalReturn(token, approvalCall);\n }\n }\n\n /**\n * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.\n * Revert on invalid signature.\n */\n function safePermit(\n IERC20Permit token,\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal {\n uint256 nonceBefore = token.nonces(owner);\n token.permit(owner, spender, value, deadline, v, r, s);\n uint256 nonceAfter = token.nonces(owner);\n require(nonceAfter == nonceBefore + 1, \"SafeERC20: permit did not succeed\");\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param token The token targeted by the call.\n * @param data The call data (encoded using abi.encode or one of its variants).\n */\n function _callOptionalReturn(IERC20 token, bytes memory data) private {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\n // the target address contains contract code and also asserts for success in the low-level call.\n\n bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n require(returndata.length == 0 || abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param token The token targeted by the call.\n * @param data The call data (encoded using abi.encode or one of its variants).\n *\n * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.\n */\n function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false\n // and not revert is the subcall reverts.\n\n (bool success, bytes memory returndata) = address(token).call(data);\n return\n success && (returndata.length == 0 || abi.decode(returndata, (bool))) && Address.isContract(address(token));\n }\n}\n" + }, + "@openzeppelin/contracts/utils/Address.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n *\n * Furthermore, `isContract` will also return true if the target contract within\n * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,\n * which only has an effect at the end of a transaction.\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n *\n * _Available since v4.8._\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n if (success) {\n if (returndata.length == 0) {\n // only check isContract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n require(isContract(target), \"Address: call to non-contract\");\n }\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason or using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n}\n" + }, + "contracts/chain-adapters/interfaces/AdapterInterface.sol": { + "content": "// SPDX-License-Identifier: BUSL-1.1\npragma solidity ^0.8.0;\n\n/**\n * @notice Sends cross chain messages and tokens to contracts on a specific L2 network.\n * This interface is implemented by an adapter contract that is deployed on L1.\n */\n\ninterface AdapterInterface {\n event MessageRelayed(address target, bytes message);\n\n event TokensRelayed(address l1Token, address l2Token, uint256 amount, address to);\n\n /**\n * @notice Send message to `target` on L2.\n * @dev This method is marked payable because relaying the message might require a fee\n * to be paid by the sender to forward the message to L2. However, it will not send msg.value\n * to the target contract on L2.\n * @param target L2 address to send message to.\n * @param message Message to send to `target`.\n */\n function relayMessage(address target, bytes calldata message) external payable;\n\n /**\n * @notice Send `amount` of `l1Token` to `to` on L2. `l2Token` is the L2 address equivalent of `l1Token`.\n * @dev This method is marked payable because relaying the message might require a fee\n * to be paid by the sender to forward the message to L2. However, it will not send msg.value\n * to the target contract on L2.\n * @param l1Token L1 token to bridge.\n * @param l2Token L2 token to receive.\n * @param amount Amount of `l1Token` to bridge.\n * @param to Bridge recipient.\n */\n function relayTokens(\n address l1Token,\n address l2Token,\n uint256 amount,\n address to\n ) external payable;\n}\n" + }, + "contracts/chain-adapters/ZkStack_Adapter.sol": { + "content": "// SPDX-License-Identifier: BUSL-1.1\npragma solidity ^0.8.0;\n\nimport \"./interfaces/AdapterInterface.sol\";\nimport \"../external/interfaces/WETH9Interface.sol\";\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport { BridgeHubInterface } from \"../interfaces/ZkStackBridgeHub.sol\";\n\n/**\n * @notice Contract containing logic to send messages from L1 to ZkStack with ETH as the gas token.\n * @dev Public functions calling external contracts do not guard against reentrancy because they are expected to be\n * called via delegatecall, which will execute this contract's logic within the context of the originating contract.\n * For example, the HubPool will delegatecall these functions, therefore its only necessary that the HubPool's methods\n * that call this contract's logic guard against reentrancy.\n * @custom:security-contact bugs@across.to\n */\n\n// solhint-disable-next-line contract-name-camelcase\ncontract ZkStack_Adapter is AdapterInterface {\n using SafeERC20 for IERC20;\n\n // The ZkSync bridgehub contract treats address(1) to represent ETH.\n address private constant ETH_TOKEN_ADDRESS = address(1);\n\n // We need to pay a base fee to the operator to include our L1 --> L2 transaction.\n // https://docs.zksync.io/build/developer-reference/l1-l2-interoperability#l1-to-l2-gas-estimation-for-transactions\n\n // Limit on L2 gas to spend.\n uint256 public immutable L2_GAS_LIMIT; // typically 2_000_000\n\n // How much gas is required to publish a byte of data from L1 to L2. 800 is the required value\n // as set here https://github.com/matter-labs/era-contracts/blob/6391c0d7bf6184d7f6718060e3991ba6f0efe4a7/ethereum/contracts/zksync/facets/Mailbox.sol#L226\n // Note, this value can change and will require an updated adapter.\n uint256 public immutable L1_GAS_TO_L2_GAS_PER_PUB_DATA_LIMIT; // Typically 800\n\n // This address receives any remaining fee after an L1 to L2 transaction completes.\n // If refund recipient = address(0) then L2 msg.sender is used, unless msg.sender is a contract then its address\n // gets aliased.\n address public immutable L2_REFUND_ADDRESS;\n\n // L2 chain id\n uint256 public immutable CHAIN_ID;\n\n // BridgeHub address\n BridgeHubInterface public immutable BRIDGE_HUB;\n\n // Set l1Weth at construction time to make testing easier.\n WETH9Interface public immutable L1_WETH;\n\n // SharedBridge address, which is read from the BridgeHub at construction.\n address public immutable SHARED_BRIDGE;\n\n // The maximum gas price a transaction sent to this adapter may have. This is set to prevent a block producer from setting an artificially high priority fee\n // when calling a hub pool message relay, which would otherwise cause a large amount of ETH to be sent to L2.\n uint256 private immutable MAX_TX_GASPRICE;\n\n event ZkStackMessageRelayed(bytes32 indexed canonicalTxHash);\n\n error ETHGasTokenRequired();\n error TransactionFeeTooHigh();\n\n /**\n * @notice Constructs new Adapter.\n * @param _chainId The target ZkStack network's chain ID.\n * @param _bridgeHub The bridge hub contract address for the ZkStack network.\n * @param _l1Weth WETH address on L1.\n * @param _l2RefundAddress address that recieves excess gas refunds on L2.\n * @param _l2GasLimit The maximum amount of gas this contract is willing to pay to execute a transaction on L2.\n * @param _l1GasToL2GasPerPubDataLimit The exchange rate of l1 gas to l2 gas.\n * @param _maxTxGasprice The maximum effective gas price any transaction sent to this adapter may have.\n */\n constructor(\n uint256 _chainId,\n BridgeHubInterface _bridgeHub,\n WETH9Interface _l1Weth,\n address _l2RefundAddress,\n uint256 _l2GasLimit,\n uint256 _l1GasToL2GasPerPubDataLimit,\n uint256 _maxTxGasprice\n ) {\n CHAIN_ID = _chainId;\n BRIDGE_HUB = _bridgeHub;\n L1_WETH = _l1Weth;\n L2_REFUND_ADDRESS = _l2RefundAddress;\n L2_GAS_LIMIT = _l2GasLimit;\n MAX_TX_GASPRICE = _maxTxGasprice;\n L1_GAS_TO_L2_GAS_PER_PUB_DATA_LIMIT = _l1GasToL2GasPerPubDataLimit;\n SHARED_BRIDGE = BRIDGE_HUB.sharedBridge();\n address gasToken = BRIDGE_HUB.baseToken(CHAIN_ID);\n if (gasToken != ETH_TOKEN_ADDRESS) {\n revert ETHGasTokenRequired();\n }\n }\n\n /**\n * @notice Send cross-chain message to target on ZkStack.\n * @dev The HubPool must hold enough ETH to pay for the L2 txn.\n * @param target Contract on L2 that will receive message.\n * @param message Data to send to target.\n */\n function relayMessage(address target, bytes memory message) external payable override {\n uint256 txBaseCost = _computeETHTxCost(L2_GAS_LIMIT);\n\n // Returns the hash of the requested L2 transaction. This hash can be used to follow the transaction status.\n bytes32 canonicalTxHash = BRIDGE_HUB.requestL2TransactionDirect{ value: txBaseCost }(\n BridgeHubInterface.L2TransactionRequestDirect({\n chainId: CHAIN_ID,\n mintValue: txBaseCost,\n l2Contract: target,\n l2Value: 0,\n l2Calldata: message,\n l2GasLimit: L2_GAS_LIMIT,\n l2GasPerPubdataByteLimit: L1_GAS_TO_L2_GAS_PER_PUB_DATA_LIMIT,\n factoryDeps: new bytes[](0),\n refundRecipient: L2_REFUND_ADDRESS\n })\n );\n\n emit MessageRelayed(target, message);\n emit ZkStackMessageRelayed(canonicalTxHash);\n }\n\n /**\n * @notice Bridge tokens to ZkStack.\n * @dev The HubPool must hold enough ETH to pay for the L2 txn.\n * @param l1Token L1 token to deposit.\n * @param l2Token L2 token to receive.\n * @param amount Amount of L1 tokens to deposit and L2 tokens to receive.\n * @param to Bridge recipient.\n */\n function relayTokens(\n address l1Token,\n address l2Token, // l2Token is unused.\n uint256 amount,\n address to\n ) external payable override {\n // A bypass proxy seems to no longer be needed to avoid deposit limits. The tracking of these limits seems to be deprecated.\n // See: https://github.com/matter-labs/era-contracts/blob/bce4b2d0f34bd87f1aaadd291772935afb1c3bd6/l1-contracts/contracts/bridge/L1ERC20Bridge.sol#L54-L55\n uint256 txBaseCost = _computeETHTxCost(L2_GAS_LIMIT);\n\n bytes32 txHash;\n if (l1Token == address(L1_WETH)) {\n // If the l1Token is WETH then unwrap it to ETH then send the ETH to the standard bridge along with the base\n // cost.\n L1_WETH.withdraw(amount);\n txHash = BRIDGE_HUB.requestL2TransactionDirect{ value: amount + txBaseCost }(\n BridgeHubInterface.L2TransactionRequestDirect({\n chainId: CHAIN_ID,\n mintValue: txBaseCost + amount,\n l2Contract: to,\n l2Value: amount,\n l2Calldata: \"\",\n l2GasLimit: L2_GAS_LIMIT,\n l2GasPerPubdataByteLimit: L1_GAS_TO_L2_GAS_PER_PUB_DATA_LIMIT,\n factoryDeps: new bytes[](0),\n refundRecipient: L2_REFUND_ADDRESS\n })\n );\n } else {\n // An ERC20 that is not WETH.\n IERC20(l1Token).forceApprove(SHARED_BRIDGE, amount);\n txHash = BRIDGE_HUB.requestL2TransactionTwoBridges{ value: txBaseCost }(\n BridgeHubInterface.L2TransactionRequestTwoBridgesOuter({\n chainId: CHAIN_ID,\n mintValue: txBaseCost,\n l2Value: 0,\n l2GasLimit: L2_GAS_LIMIT,\n l2GasPerPubdataByteLimit: L1_GAS_TO_L2_GAS_PER_PUB_DATA_LIMIT,\n refundRecipient: L2_REFUND_ADDRESS,\n secondBridgeAddress: SHARED_BRIDGE,\n secondBridgeValue: 0,\n secondBridgeCalldata: _secondBridgeCalldata(to, l1Token, amount)\n })\n );\n }\n\n emit TokensRelayed(l1Token, l2Token, amount, to);\n emit ZkStackMessageRelayed(txHash);\n }\n\n /**\n * @notice Computes the calldata for the \"second bridge\", which handles sending non native tokens.\n * @param l2Recipient recipient of the tokens.\n * @param l1Token the l1 address of the token. Note: ETH is encoded as address(1).\n * @param amount number of tokens to send.\n * @return abi encoded bytes.\n */\n function _secondBridgeCalldata(\n address l2Recipient,\n address l1Token,\n uint256 amount\n ) internal pure returns (bytes memory) {\n return abi.encode(l1Token, amount, l2Recipient);\n }\n\n /**\n * @notice For a given l2 gas limit, this computes the amount of ETH needed and\n * returns the amount.\n * @param l2GasLimit L2 gas limit for the message.\n * @return amount of ETH that this contract needs to provide in order for the l2 transaction to succeed.\n */\n function _computeETHTxCost(uint256 l2GasLimit) internal view returns (uint256) {\n if (tx.gasprice > MAX_TX_GASPRICE) revert TransactionFeeTooHigh();\n return BRIDGE_HUB.l2TransactionBaseCost(CHAIN_ID, tx.gasprice, l2GasLimit, L1_GAS_TO_L2_GAS_PER_PUB_DATA_LIMIT);\n }\n\n receive() external payable {}\n}\n" + }, + "contracts/external/interfaces/WETH9Interface.sol": { + "content": "// SPDX-License-Identifier: BUSL-1.1\npragma solidity ^0.8.0;\n\n/**\n * @notice Interface for the WETH9 contract.\n */\ninterface WETH9Interface {\n /**\n * @notice Burn Wrapped Ether and receive native Ether.\n * @param wad Amount of WETH to unwrap and send to caller.\n */\n function withdraw(uint256 wad) external;\n\n /**\n * @notice Lock native Ether and mint Wrapped Ether ERC20\n * @dev msg.value is amount of Wrapped Ether to mint/Ether to lock.\n */\n function deposit() external payable;\n\n /**\n * @notice Get balance of WETH held by `guy`.\n * @param guy Address to get balance of.\n * @return wad Amount of WETH held by `guy`.\n */\n function balanceOf(address guy) external view returns (uint256 wad);\n\n /**\n * @notice Transfer `wad` of WETH from caller to `guy`.\n * @param guy Address to send WETH to.\n * @param wad Amount of WETH to send.\n * @return ok True if transfer succeeded.\n */\n function transfer(address guy, uint256 wad) external returns (bool);\n}\n" + }, + "contracts/interfaces/ZkStackBridgeHub.sol": { + "content": "// SPDX-License-Identifier: BUSL-1.1\npragma solidity ^0.8.0;\n\n/**\n * @title BridgeHubInterface\n * @notice This interface is shared between ZkStack adapters. It is the main interaction point for bridging to ZkStack chains.\n */\ninterface BridgeHubInterface {\n struct L2TransactionRequestDirect {\n uint256 chainId;\n uint256 mintValue;\n address l2Contract;\n uint256 l2Value;\n bytes l2Calldata;\n uint256 l2GasLimit;\n uint256 l2GasPerPubdataByteLimit;\n bytes[] factoryDeps;\n address refundRecipient;\n }\n\n /**\n * @notice the mailbox is called directly after the sharedBridge received the deposit.\n * This assumes that either ether is the base token or the msg.sender has approved mintValue allowance for the\n * sharedBridge. This means this is not ideal for contract calls, as the contract would have to handle token\n * allowance of the base Token.\n * @param _request the direct request.\n */\n function requestL2TransactionDirect(L2TransactionRequestDirect calldata _request)\n external\n payable\n returns (bytes32 canonicalTxHash);\n\n struct L2TransactionRequestTwoBridgesOuter {\n uint256 chainId;\n uint256 mintValue;\n uint256 l2Value;\n uint256 l2GasLimit;\n uint256 l2GasPerPubdataByteLimit;\n address refundRecipient;\n address secondBridgeAddress;\n uint256 secondBridgeValue;\n bytes secondBridgeCalldata;\n }\n\n /**\n * @notice After depositing funds to the sharedBridge, the secondBridge is called to return the actual L2 message\n * which is sent to the Mailbox. This assumes that either ether is the base token or the msg.sender has approved\n * the sharedBridge with the mintValue, and also the necessary approvals are given for the second bridge. The logic\n * of this bridge is to allow easy depositing for bridges. Each contract that handles the users ERC20 tokens needs\n * approvals from the user, this contract allows the user to approve for each token only its respective bridge.\n * This function is great for contract calls to L2, the secondBridge can be any contract.\n * @param _request the two bridges request.\n */\n function requestL2TransactionTwoBridges(L2TransactionRequestTwoBridgesOuter calldata _request)\n external\n payable\n returns (bytes32 canonicalTxHash);\n\n /**\n * @notice Gets the shared bridge.\n * @dev The shared bridge manages ERC20 tokens.\n */\n function sharedBridge() external view returns (address);\n\n /**\n * @notice Gets the base token for a chain.\n * @dev Base token == native token.\n */\n function baseToken(uint256 _chainId) external view returns (address);\n\n /**\n * @notice Computes the base transaction cost for a transaction.\n * @param _chainId the chain the transaction is being sent to.\n * @param _gasPrice the l1 gas price at time of execution.\n * @param _l2GasLimit the gas limit for the l2 transaction.\n * @param _l2GasPerPubdataByteLimit configuration value that changes infrequently.\n */\n function l2TransactionBaseCost(\n uint256 _chainId,\n uint256 _gasPrice,\n uint256 _l2GasLimit,\n uint256 _l2GasPerPubdataByteLimit\n ) external view returns (uint256);\n}\n" + } + }, + "settings": { + "optimizer": { + "enabled": true, + "runs": 1000000 + }, + "viaIR": true, + "debug": { + "revertStrings": "strip" + }, + "outputSelection": { + "*": { + "*": [ + "abi", + "evm.bytecode", + "evm.deployedBytecode", + "evm.methodIdentifiers", + "metadata", + "devdoc", + "userdoc", + "storageLayout", + "evm.gasEstimates" + ], + "": ["ast"] + } + }, + "metadata": { + "useLiteralContent": true + } + } +}