diff --git a/.changeset/kind-months-brush.md b/.changeset/kind-months-brush.md new file mode 100644 index 0000000000..3cbbf8bac4 --- /dev/null +++ b/.changeset/kind-months-brush.md @@ -0,0 +1,5 @@ +--- +"ccip": patch +--- + +Support multi-stage finalization in the rebalancer contracts diff --git a/contracts/.changeset/config.json b/contracts/.changeset/config.json index 8205542a70..aac0227b9e 100644 --- a/contracts/.changeset/config.json +++ b/contracts/.changeset/config.json @@ -10,7 +10,7 @@ "fixed": [], "linked": [], "access": "public", - "baseBranch": "develop", + "baseBranch": "ccip-develop", "updateInternalDependencies": "patch", "ignore": [] } diff --git a/contracts/.changeset/thin-squids-fly.md b/contracts/.changeset/thin-squids-fly.md new file mode 100644 index 0000000000..b627ba0898 --- /dev/null +++ b/contracts/.changeset/thin-squids-fly.md @@ -0,0 +1,5 @@ +--- +"@chainlink/contracts-ccip": patch +--- + +Support multi-stage finalization in the rebalancer contracts diff --git a/contracts/gas-snapshots/rebalancer.gas-snapshot b/contracts/gas-snapshots/rebalancer.gas-snapshot index 41978a5d28..6d8d65a895 100644 --- a/contracts/gas-snapshots/rebalancer.gas-snapshot +++ b/contracts/gas-snapshots/rebalancer.gas-snapshot @@ -15,24 +15,26 @@ OCR3Base_transmit:testTransmit2SignersSuccess_gas() (gas: 56892) OCR3Base_transmit:testUnAuthorizedTransmitterReverts() (gas: 28595) OCR3Base_transmit:testUnauthorizedSignerReverts() (gas: 44736) OCR3Base_transmit:testWrongNumberOfSignaturesReverts() (gas: 25655) -OptimismL1BridgeAdapter_finalizeWithdrawERC20:testFinalizeWithdrawERC20Reverts() (gas: 11929) -OptimismL1BridgeAdapter_finalizeWithdrawERC20:testfinalizeWithdrawERC20FinalizeSuccess() (gas: 16860) -OptimismL1BridgeAdapter_finalizeWithdrawERC20:testfinalizeWithdrawERC20proveWithdrawalSuccess() (gas: 20650) -Rebalancer__report:test_EmptyReportReverts() (gas: 11181) -Rebalancer_addLiquidity:test_addLiquiditySuccess() (gas: 284776) -Rebalancer_rebalanceLiquidity:test_InsufficientLiquidityReverts() (gas: 19579) -Rebalancer_rebalanceLiquidity:test_InvalidRemoteChainReverts() (gas: 197579) -Rebalancer_rebalanceLiquidity:test_rebalanceBetweenPoolsSuccess() (gas: 8207096) -Rebalancer_rebalanceLiquidity:test_rebalanceBetweenPoolsSuccess_AlreadyFinalized() (gas: 8101676) -Rebalancer_rebalanceLiquidity:test_rebalanceLiquiditySuccess() (gas: 384924) +OptimismL1BridgeAdapter_finalizeWithdrawERC20:testFinalizeWithdrawERC20Reverts() (gas: 12932) +OptimismL1BridgeAdapter_finalizeWithdrawERC20:testfinalizeWithdrawERC20FinalizeSuccess() (gas: 16972) +OptimismL1BridgeAdapter_finalizeWithdrawERC20:testfinalizeWithdrawERC20proveWithdrawalSuccess() (gas: 20758) +Rebalancer__report:test_EmptyReportReverts() (gas: 11183) +Rebalancer_addLiquidity:test_addLiquiditySuccess() (gas: 284740) +Rebalancer_rebalanceLiquidity:test_InsufficientLiquidityReverts() (gas: 19585) +Rebalancer_rebalanceLiquidity:test_InvalidRemoteChainReverts() (gas: 197560) +Rebalancer_rebalanceLiquidity:test_rebalanceBetweenPoolsSuccess() (gas: 8631373) +Rebalancer_rebalanceLiquidity:test_rebalanceBetweenPoolsSuccess_AlreadyFinalized() (gas: 8497505) +Rebalancer_rebalanceLiquidity:test_rebalanceBetweenPools_MultiStageFinalization() (gas: 8492713) +Rebalancer_rebalanceLiquidity:test_rebalanceBetweenPools_NativeRewrap() (gas: 8410478) +Rebalancer_rebalanceLiquidity:test_rebalanceLiquiditySuccess() (gas: 384928) Rebalancer_removeLiquidity:test_InsufficientLiquidityReverts() (gas: 191702) Rebalancer_removeLiquidity:test_OnlyOwnerReverts() (gas: 10923) Rebalancer_removeLiquidity:test_removeLiquiditySuccess() (gas: 243268) -Rebalancer_setCrossChainRebalancer:test_OnlyOwnerReverts() (gas: 16997) -Rebalancer_setCrossChainRebalancer:test_ZeroAddressReverts() (gas: 21624) -Rebalancer_setCrossChainRebalancer:test_ZeroChainSelectorReverts() (gas: 13099) -Rebalancer_setCrossChainRebalancer:test_setCrossChainRebalancerSuccess() (gas: 162244) -Rebalancer_setLocalLiquidityContainer:test_OnlyOwnerReverts() (gas: 10986) -Rebalancer_setLocalLiquidityContainer:test_setLocalLiquidityContainerSuccess() (gas: 3277943) +Rebalancer_setCrossChainRebalancer:test_OnlyOwnerReverts() (gas: 16982) +Rebalancer_setCrossChainRebalancer:test_ZeroAddressReverts() (gas: 21630) +Rebalancer_setCrossChainRebalancer:test_ZeroChainSelectorReverts() (gas: 13105) +Rebalancer_setCrossChainRebalancer:test_setCrossChainRebalancerSuccess() (gas: 162288) +Rebalancer_setLocalLiquidityContainer:test_OnlyOwnerReverts() (gas: 11008) +Rebalancer_setLocalLiquidityContainer:test_setLocalLiquidityContainerSuccess() (gas: 3277934) Rebalancer_setMinimumLiquidity:test_OnlyOwnerReverts() (gas: 10925) -Rebalancer_setMinimumLiquidity:test_setMinimumLiquiditySuccess() (gas: 36422) \ No newline at end of file +Rebalancer_setMinimumLiquidity:test_setMinimumLiquiditySuccess() (gas: 36389) \ No newline at end of file diff --git a/contracts/package.json b/contracts/package.json index b21359f20e..5dc6ffc404 100644 --- a/contracts/package.json +++ b/contracts/package.json @@ -104,7 +104,6 @@ "@scroll-tech/contracts": "0.1.0", "@openzeppelin/contracts": "4.9.3", "@openzeppelin/contracts-upgradeable": "4.9.3", - "@scroll-tech/contracts": "0.1.0", "semver": "^7.6.0" } } diff --git a/contracts/src/v0.8/rebalancer/Rebalancer.sol b/contracts/src/v0.8/rebalancer/Rebalancer.sol index 8cb33898c9..512fdcd7d8 100644 --- a/contracts/src/v0.8/rebalancer/Rebalancer.sol +++ b/contracts/src/v0.8/rebalancer/Rebalancer.sol @@ -4,6 +4,7 @@ pragma solidity 0.8.19; import {IBridgeAdapter} from "./interfaces/IBridge.sol"; import {IRebalancer} from "./interfaces/IRebalancer.sol"; import {ILiquidityContainer} from "./interfaces/ILiquidityContainer.sol"; +import {IWrappedNative} from "../ccip/interfaces/IWrappedNative.sol"; import {OCR3Base} from "./ocr/OCR3Base.sol"; @@ -12,7 +13,7 @@ import {SafeERC20} from "../vendor/openzeppelin-solidity/v4.8.3/contracts/token/ /// @notice Rebalancer for a single token over multiple chains. /// @dev This contract is designed to be used with the LockReleaseTokenPool contract but -/// isn't constraint to it. It can be used with any contract that implements the ILiquidityContainer +/// isn't constrained to it. It can be used with any contract that implements the ILiquidityContainer /// interface. /// @dev The OCR3 DON should only be able to transfer funds to other pre-approved contracts /// on other chains. Under no circumstances should it be able to transfer funds to arbitrary @@ -30,6 +31,11 @@ contract Rebalancer is IRebalancer, OCR3Base { error InsufficientLiquidity(uint256 requested, uint256 available); error EmptyReport(); + event FinalizationStepCompleted( + uint64 indexed ocrSeqNum, + uint64 indexed remoteChainSelector, + bytes bridgeSpecificData + ); event LiquidityTransferred( uint64 indexed ocrSeqNum, uint64 indexed fromChainSelector, @@ -165,9 +171,10 @@ contract Rebalancer is IRebalancer, OCR3Base { function receiveLiquidity( uint64 remoteChainSelector, uint256 amount, + bool shouldWrapNative, bytes calldata bridgeSpecificPayload ) external onlyOwner { - _receiveLiquidity(remoteChainSelector, amount, bridgeSpecificPayload, type(uint64).max); + _receiveLiquidity(remoteChainSelector, amount, bridgeSpecificPayload, shouldWrapNative, type(uint64).max); } /// @notice Transfers liquidity to another chain. @@ -217,6 +224,7 @@ contract Rebalancer is IRebalancer, OCR3Base { uint64 remoteChainSelector, uint256 amount, bytes memory bridgeSpecificPayload, + bool shouldWrapNative, uint64 ocrSeqNum ) internal { // check if the remote chain is supported @@ -232,8 +240,20 @@ contract Rebalancer is IRebalancer, OCR3Base { address(this), // localReceiver: this contract bridgeSpecificPayload ) - { - // successfully finalized the withdrawal + returns (bool fundsAvailable) { + if (fundsAvailable) { + // finalization was successful and we can inject the liquidity into the container. + // approve and liquidity container should transferFrom. + _injectLiquidity(amount, ocrSeqNum, remoteChainSelector, bridgeSpecificPayload, shouldWrapNative); + } else { + // a finalization step was completed, but funds are not available. + // hence, we cannot inject any liquidity yet. + emit FinalizationStepCompleted(ocrSeqNum, remoteChainSelector, bridgeSpecificPayload); + } + + // return here on the happy path. + // sad path is when finalizeWithdrawERC20 reverts, which is handled after the catch block. + return; } catch (bytes memory lowLevelData) { // failed to finalize the withdrawal. // this could mean that the withdrawal was already finalized @@ -242,8 +262,29 @@ contract Rebalancer is IRebalancer, OCR3Base { emit FinalizationFailed(ocrSeqNum, remoteChainSelector, bridgeSpecificPayload, lowLevelData); } - // inject liquidity into the liquidity container - // approve and liquidity container should transferFrom + // if we reach this point, the finalization failed. + // since we don't have enough information to know why it failed, + // we assume that it failed because the withdrawal was already finalized, + // and that the funds are available. + _injectLiquidity(amount, ocrSeqNum, remoteChainSelector, bridgeSpecificPayload, shouldWrapNative); + } + + function _injectLiquidity( + uint256 amount, + uint64 ocrSeqNum, + uint64 remoteChainSelector, + bytes memory bridgeSpecificPayload, + bool shouldWrapNative + ) private { + // We trust the DON or the owner (the only two actors who can end up calling this function) + // to correctly set the shouldWrapNative flag. + // Some bridges only bridge native and not wrapped native. + // In such a case we need to re-wrap the native in order to inject it into the liquidity container. + // TODO: escape hatch in case of bug? + if (shouldWrapNative) { + IWrappedNative(address(i_localToken)).deposit{value: amount}(); + } + i_localToken.safeIncreaseAllowance(address(s_localLiquidityContainer), amount); s_localLiquidityContainer.provideLiquidity(amount); @@ -285,6 +326,7 @@ contract Rebalancer is IRebalancer, OCR3Base { instructions.receiveLiquidityParams[i].remoteChainSelector, instructions.receiveLiquidityParams[i].amount, instructions.receiveLiquidityParams[i].bridgeData, + instructions.receiveLiquidityParams[i].shouldWrapNative, ocrSeqNum ); } diff --git a/contracts/src/v0.8/rebalancer/bridge-adapters/ArbitrumL1BridgeAdapter.sol b/contracts/src/v0.8/rebalancer/bridge-adapters/ArbitrumL1BridgeAdapter.sol index 71d13b81e6..3beb338b88 100644 --- a/contracts/src/v0.8/rebalancer/bridge-adapters/ArbitrumL1BridgeAdapter.sol +++ b/contracts/src/v0.8/rebalancer/bridge-adapters/ArbitrumL1BridgeAdapter.sol @@ -58,7 +58,7 @@ contract ArbitrumL1BridgeAdapter is IBridgeAdapter { } /// @dev these are parameters provided by the caller of the sendERC20 function - /// @dev these must be determined offchain. + /// and must be determined offchain. struct SendERC20Params { uint256 gasLimit; uint256 maxSubmissionCost; @@ -110,12 +110,10 @@ contract ArbitrumL1BridgeAdapter is IBridgeAdapter { return inboxSequenceNumber; } - /// @dev This function is so that we can easily abi-encode the arbitrum-specific - /// @dev payload for the sendERC20 function. + /// @dev This function is so that we can easily abi-encode the arbitrum-specific payload for the sendERC20 function. function exposeSendERC20Params(SendERC20Params memory params) public pure {} - /// @dev fees have to be determined offchain for arbitrum - /// @dev therefore revert here to discourage usage + /// @dev fees have to be determined offchain for arbitrum, therefore revert here to discourage usage. function getBridgeFeeInNative() public pure override returns (uint256) { revert Unimplemented(); } @@ -141,16 +139,19 @@ contract ArbitrumL1BridgeAdapter is IBridgeAdapter { bytes data; } - /// @dev This function is so that we can easily abi-encode the arbitrum-specific - /// @dev payload for the finalizeWithdrawERC20 function. + /// @dev This function is so that we can easily abi-encode the arbitrum-specific payload for the finalizeWithdrawERC20 function. function exposeArbitrumFinalizationPayload(ArbitrumFinalizationPayload memory payload) public pure {} /// @notice Finalize an L2 -> L1 transfer. + /// Arbitrum finalizations are single-step, so we always return true. + /// Calls to this function will revert in two cases, 1) if the finalization payload is wrong, + /// i.e incorrect merkle proof, or index and 2) if the withdrawal was already finalized. + /// @return true iff the finalization does not revert. function finalizeWithdrawERC20( address /* remoteSender */, address /* localReceiver */, bytes calldata arbitrumFinalizationPayload - ) external { + ) external override returns (bool) { ArbitrumFinalizationPayload memory payload = abi.decode(arbitrumFinalizationPayload, (ArbitrumFinalizationPayload)); i_l1Outbox.executeTransaction( payload.proof, @@ -163,8 +164,11 @@ contract ArbitrumL1BridgeAdapter is IBridgeAdapter { payload.value, payload.data ); + return true; } + /// @notice Convenience function to get the L2 token address from the L1 token address. + /// @return The L2 token address for the given L1 token address. function getL2Token(address l1Token) external view returns (address) { return i_l1GatewayRouter.calculateL2TokenAddress(l1Token); } diff --git a/contracts/src/v0.8/rebalancer/bridge-adapters/ArbitrumL2BridgeAdapter.sol b/contracts/src/v0.8/rebalancer/bridge-adapters/ArbitrumL2BridgeAdapter.sol index 46700bf633..a719e34fc3 100644 --- a/contracts/src/v0.8/rebalancer/bridge-adapters/ArbitrumL2BridgeAdapter.sol +++ b/contracts/src/v0.8/rebalancer/bridge-adapters/ArbitrumL2BridgeAdapter.sol @@ -58,11 +58,14 @@ contract ArbitrumL2BridgeAdapter is IBridgeAdapter { } /// @notice No-op since L1 -> L2 transfers do not need finalization. + /// @return true always. function finalizeWithdrawERC20( address /* remoteSender */, address /* localReceiver */, bytes calldata /* bridgeSpecificPayload */ - ) external {} + ) external override returns (bool) { + return true; + } /// @notice There are no fees to bridge back to L1 function getBridgeFeeInNative() external pure returns (uint256) { diff --git a/contracts/src/v0.8/rebalancer/bridge-adapters/OptimismL1BridgeAdapter.sol b/contracts/src/v0.8/rebalancer/bridge-adapters/OptimismL1BridgeAdapter.sol index d9ccd60c8b..df26f673ed 100644 --- a/contracts/src/v0.8/rebalancer/bridge-adapters/OptimismL1BridgeAdapter.sol +++ b/contracts/src/v0.8/rebalancer/bridge-adapters/OptimismL1BridgeAdapter.sol @@ -131,11 +131,13 @@ contract OptimismL1BridgeAdapter is IBridgeAdapter { /// @notice Prove or finalize an ERC20 withdrawal from L2. /// The action to take is specified in the payload. See the docstring of FinalizeWithdrawERC20Payload for more details. /// @param data The payload for the action. This is an abi.encode'd FinalizeWithdrawERC20Payload with the appropriate data. + /// @return true iff finalization is successful, and false for proving a withdrawal. If either of these fail, + /// the call to this function will revert. function finalizeWithdrawERC20( address /* remoteSender */, address /* localReceiver */, bytes calldata data - ) external override { + ) external override returns (bool) { // decode the data into FinalizeWithdrawERC20Payload first and extract the action. FinalizeWithdrawERC20Payload memory payload = abi.decode(data, (FinalizeWithdrawERC20Payload)); if (payload.action == FinalizationAction.ProveWithdrawal) { @@ -143,6 +145,7 @@ contract OptimismL1BridgeAdapter is IBridgeAdapter { // Decode the data into OptimismProveWithdrawalPayload and call the proveWithdrawal function. OptimismProveWithdrawalPayload memory provePayload = abi.decode(payload.data, (OptimismProveWithdrawalPayload)); _proveWithdrawal(provePayload); + return false; } else if (payload.action == FinalizationAction.FinalizeWithdrawal) { // decode the data into OptimismFinalizationPayload and call the finalizeWithdrawal function. OptimismFinalizationPayload memory finalizePayload = abi.decode(payload.data, (OptimismFinalizationPayload)); @@ -151,6 +154,7 @@ contract OptimismL1BridgeAdapter is IBridgeAdapter { // However, we can't do that from within this adapter because it doesn't actually have the ether. // So its up to the caller to rectify this by re-wrapping the ether. _finalizeWithdrawal(finalizePayload); + return true; } else { revert InvalidFinalizationAction(); } diff --git a/contracts/src/v0.8/rebalancer/bridge-adapters/OptimismL2BridgeAdapter.sol b/contracts/src/v0.8/rebalancer/bridge-adapters/OptimismL2BridgeAdapter.sol index 7e9f9665ce..048248e911 100644 --- a/contracts/src/v0.8/rebalancer/bridge-adapters/OptimismL2BridgeAdapter.sol +++ b/contracts/src/v0.8/rebalancer/bridge-adapters/OptimismL2BridgeAdapter.sol @@ -88,11 +88,14 @@ contract OptimismL2BridgeAdapter is IBridgeAdapter { } /// @notice No-op since L1 -> L2 transfers do not need finalization. + /// @return true always. function finalizeWithdrawERC20( address /* remoteSender */, address /* localReceiver */, bytes calldata /* bridgeSpecificPayload */ - ) external override {} + ) external override returns (bool) { + return true; + } /// @notice There are no fees to bridge back to L1 function getBridgeFeeInNative() external pure returns (uint256) { diff --git a/contracts/src/v0.8/rebalancer/interfaces/IBridge.sol b/contracts/src/v0.8/rebalancer/interfaces/IBridge.sol index 4652621ad2..83e64edce4 100644 --- a/contracts/src/v0.8/rebalancer/interfaces/IBridge.sol +++ b/contracts/src/v0.8/rebalancer/interfaces/IBridge.sol @@ -9,9 +9,9 @@ interface IBridgeAdapter { error MsgShouldNotContainValue(uint256 value); /// @notice Send the specified amount of the local token cross-chain to the remote chain. - /// @notice The tokens on the remote chain will then be sourced from the remoteToken address. - /// @notice The amount to be sent must be approved by the caller beforehand on the localToken contract. - /// @notice The caller must provide the bridging fee in native currency, i.e msg.value. + /// The tokens on the remote chain will then be sourced from the remoteToken address. + /// The amount to be sent must be approved by the caller beforehand on the localToken contract. + /// The caller must provide the bridging fee in native currency, i.e msg.value. /// @param localToken The address of the local ERC-20 token. /// @param remoteToken The address of the remote ERC-20 token. /// @param recipient The address of the recipient on the remote chain. @@ -26,17 +26,24 @@ interface IBridgeAdapter { ) external payable returns (bytes memory); /// @notice Get the bridging fee in native currency. This fee must be provided upon sending tokens via - /// @notice the sendERC20 function. + /// the sendERC20 function. /// @return The bridging fee in native currency. function getBridgeFeeInNative() external view returns (uint256); /// @notice Finalize the withdrawal of a cross-chain transfer. + /// Not all implementations will finalize a transfer in a single call to this function. + /// Optimism, for example, requires a two-step process to finalize a transfer. The first + /// step requires proving the withdrawal that occurred on L2 on L1. The second step is then + /// the finalization, whereby funds become available to the recipient. So, in that particular + /// scenario, `false` is returned from `finalizeWithdrawERC20` when the first step is completed, + /// and `true` is returned when the second step is completed. /// @param remoteSender The address of the sender on the remote chain. /// @param localReceiver The address of the receiver on the local chain. /// @param bridgeSpecificPayload The payload of the cross-chain transfer, bridge-specific, i.e a proof of some kind. + /// @return true iff the funds are available, false otherwise. function finalizeWithdrawERC20( address remoteSender, address localReceiver, bytes calldata bridgeSpecificPayload - ) external; + ) external returns (bool); } diff --git a/contracts/src/v0.8/rebalancer/interfaces/IRebalancer.sol b/contracts/src/v0.8/rebalancer/interfaces/IRebalancer.sol index eda7c44b6e..3976715543 100644 --- a/contracts/src/v0.8/rebalancer/interfaces/IRebalancer.sol +++ b/contracts/src/v0.8/rebalancer/interfaces/IRebalancer.sol @@ -4,21 +4,29 @@ pragma solidity ^0.8.0; import {IBridgeAdapter} from "./IBridge.sol"; interface IRebalancer { + /// @notice Parameters for sending liquidity to a remote chain. + /// @param amount The amount of tokens to be sent to the remote chain. + /// @param nativeBridgeFee The amount of native that should be sent by the rebalancer in the sendERC20 call. + /// Used to pay for the bridge fees. + /// @param remoteChainSelector The selector of the remote chain. + /// @param bridgeData The bridge data that should be passed to the sendERC20 call. struct SendLiquidityParams { - /// @notice The amount of tokens to be sent to the remote chain. uint256 amount; - /// @notice The amount of native that should be sent by the rebalancer in the sendERC20 call. - /// @notice This is used to pay for the bridge fees. uint256 nativeBridgeFee; - /// @notice The selector of the remote chain. uint64 remoteChainSelector; - /// @notice The bridge data that should be passed to the sendERC20 call. bytes bridgeData; } + /// @notice Parameters for receiving liquidity from a remote chain. + /// @param amount The amount of tokens to be received from the remote chain. + /// @param remoteChainSelector The selector of the remote chain. + /// @param bridgeData The bridge data that should be passed to the finalizeWithdrawERC20 call. + /// @param shouldWrapNative Whether the received native token should be wrapped into wrapped native. + /// This is needed for when the bridge being used doesn't bridge wrapped native but native directly. struct ReceiveLiquidityParams { uint256 amount; uint64 remoteChainSelector; + bool shouldWrapNative; bytes bridgeData; } @@ -36,6 +44,7 @@ interface IRebalancer { } /// @notice Returns the current liquidity in the liquidity container. + /// @return currentLiquidity The current liquidity in the liquidity container. function getLiquidity() external view returns (uint256 currentLiquidity); function getAllCrossChainRebalancers() external view returns (CrossChainRebalancerArgs[] memory); diff --git a/contracts/src/v0.8/rebalancer/test/Rebalancer.t.sol b/contracts/src/v0.8/rebalancer/test/Rebalancer.t.sol index 085642fbff..17f0276967 100644 --- a/contracts/src/v0.8/rebalancer/test/Rebalancer.t.sol +++ b/contracts/src/v0.8/rebalancer/test/Rebalancer.t.sol @@ -10,7 +10,14 @@ import {MockL1BridgeAdapter} from "./mocks/MockBridgeAdapter.sol"; import {RebalancerBaseTest} from "./RebalancerBaseTest.t.sol"; import {RebalancerHelper} from "./helpers/RebalancerHelper.sol"; +import {IERC20} from "../../vendor/openzeppelin-solidity/v4.8.3/contracts/token/ERC20/IERC20.sol"; + contract RebalancerSetup is RebalancerBaseTest { + event FinalizationStepCompleted( + uint64 indexed ocrSeqNum, + uint64 indexed remoteChainSelector, + bytes bridgeSpecificData + ); event LiquidityTransferred( uint64 indexed ocrSeqNum, uint64 indexed fromChainSelector, @@ -38,14 +45,36 @@ contract RebalancerSetup is RebalancerBaseTest { LockReleaseTokenPool internal s_lockReleaseTokenPool; MockL1BridgeAdapter internal s_bridgeAdapter; + // Rebalancer that rebalances weth. + RebalancerHelper internal s_wethRebalancer; + LockReleaseTokenPool internal s_wethLockReleaseTokenPool; + MockL1BridgeAdapter internal s_wethBridgeAdapter; + function setUp() public override { RebalancerBaseTest.setUp(); - s_bridgeAdapter = new MockL1BridgeAdapter(s_l1Token); + s_bridgeAdapter = new MockL1BridgeAdapter(s_l1Token, false); s_lockReleaseTokenPool = new LockReleaseTokenPool(s_l1Token, new address[](0), address(1), true, address(123)); s_rebalancer = new RebalancerHelper(s_l1Token, i_localChainSelector, s_lockReleaseTokenPool, 0); s_lockReleaseTokenPool.setRebalancer(address(s_rebalancer)); + + s_wethBridgeAdapter = new MockL1BridgeAdapter(IERC20(address(s_l1Weth)), true); + s_wethLockReleaseTokenPool = new LockReleaseTokenPool( + IERC20(address(s_l1Weth)), + new address[](0), + address(1), + true, + address(123) + ); + s_wethRebalancer = new RebalancerHelper( + IERC20(address(s_l1Weth)), + i_localChainSelector, + s_wethLockReleaseTokenPool, + 0 + ); + + s_wethLockReleaseTokenPool.setRebalancer(address(s_wethRebalancer)); } } @@ -115,9 +144,10 @@ contract Rebalancer__report is RebalancerSetup { } contract Rebalancer_rebalanceLiquidity is RebalancerSetup { + uint256 internal constant AMOUNT = 12345679; + function test_rebalanceLiquiditySuccess() external { - uint256 amount = 12345679; - deal(address(s_l1Token), address(s_lockReleaseTokenPool), amount); + deal(address(s_l1Token), address(s_lockReleaseTokenPool), AMOUNT); Rebalancer.CrossChainRebalancerArgs[] memory args = new Rebalancer.CrossChainRebalancerArgs[](1); args[0] = IRebalancer.CrossChainRebalancerArgs({ @@ -130,13 +160,13 @@ contract Rebalancer_rebalanceLiquidity is RebalancerSetup { s_rebalancer.setCrossChainRebalancers(args); vm.expectEmit(); - emit Transfer(address(s_lockReleaseTokenPool), address(s_rebalancer), amount); + emit Transfer(address(s_lockReleaseTokenPool), address(s_rebalancer), AMOUNT); vm.expectEmit(); - emit Approval(address(s_rebalancer), address(s_bridgeAdapter), amount); + emit Approval(address(s_rebalancer), address(s_bridgeAdapter), AMOUNT); vm.expectEmit(); - emit Transfer(address(s_rebalancer), address(s_bridgeAdapter), amount); + emit Transfer(address(s_rebalancer), address(s_bridgeAdapter), AMOUNT); vm.expectEmit(); bytes memory encodedNonce = abi.encode(uint256(1)); @@ -145,15 +175,15 @@ contract Rebalancer_rebalanceLiquidity is RebalancerSetup { i_localChainSelector, i_remoteChainSelector, address(s_rebalancer), - amount, + AMOUNT, bytes(""), encodedNonce ); - s_rebalancer.rebalanceLiquidity(i_remoteChainSelector, amount, 0, bytes("")); + s_rebalancer.rebalanceLiquidity(i_remoteChainSelector, AMOUNT, 0, bytes("")); assertEq(s_l1Token.balanceOf(address(s_rebalancer)), 0); - assertEq(s_l1Token.balanceOf(address(s_bridgeAdapter)), amount); + assertEq(s_l1Token.balanceOf(address(s_bridgeAdapter)), AMOUNT); assertEq(s_l1Token.allowance(address(s_rebalancer), address(s_bridgeAdapter)), 0); } @@ -166,7 +196,7 @@ contract Rebalancer_rebalanceLiquidity is RebalancerSetup { s_rebalancer = new RebalancerHelper(s_l1Token, i_localChainSelector, s_bridgeAdapter, 0); - MockL1BridgeAdapter mockRemoteBridgeAdapter = new MockL1BridgeAdapter(s_l1Token); + MockL1BridgeAdapter mockRemoteBridgeAdapter = new MockL1BridgeAdapter(s_l1Token, false); Rebalancer mockRemoteRebalancer = new Rebalancer(s_l1Token, i_remoteChainSelector, mockRemoteBridgeAdapter, 0); Rebalancer.CrossChainRebalancerArgs[] memory args = new Rebalancer.CrossChainRebalancerArgs[](1); @@ -216,11 +246,10 @@ contract Rebalancer_rebalanceLiquidity is RebalancerSetup { } function test_rebalanceBetweenPoolsSuccess_AlreadyFinalized() external { - uint256 amount = 12345670; // set up a rebalancer on another chain, an "L2". // note we use the L1 bridge adapter because it has the reverting logic // when finalization is already done. - MockL1BridgeAdapter remoteBridgeAdapter = new MockL1BridgeAdapter(s_l2Token); + MockL1BridgeAdapter remoteBridgeAdapter = new MockL1BridgeAdapter(s_l2Token, false); LockReleaseTokenPool remotePool = new LockReleaseTokenPool( s_l2Token, new address[](0), @@ -258,81 +287,351 @@ contract Rebalancer_rebalanceLiquidity is RebalancerSetup { // deal some L1 tokens to the L1 bridge adapter so that it can send them to the rebalancer // when the withdrawal gets finalized. - deal(address(s_l1Token), address(s_bridgeAdapter), amount); + deal(address(s_l1Token), address(s_bridgeAdapter), AMOUNT); // deal some L2 tokens to the remote token pool so that we can withdraw it when we rebalance. - deal(address(s_l2Token), address(remotePool), amount); + deal(address(s_l2Token), address(remotePool), AMOUNT); uint256 nonce = 1; uint64 maxSeqNum = type(uint64).max; bytes memory bridgeSendReturnData = abi.encode(nonce); bytes memory bridgeSpecificPayload = bytes(""); vm.expectEmit(); - emit LiquidityRemoved(address(remoteRebalancer), amount); + emit LiquidityRemoved(address(remoteRebalancer), AMOUNT); vm.expectEmit(); emit LiquidityTransferred( maxSeqNum, i_remoteChainSelector, i_localChainSelector, address(s_rebalancer), - amount, + AMOUNT, bridgeSpecificPayload, bridgeSendReturnData ); - remoteRebalancer.rebalanceLiquidity(i_localChainSelector, amount, 0, bridgeSpecificPayload); + remoteRebalancer.rebalanceLiquidity(i_localChainSelector, AMOUNT, 0, bridgeSpecificPayload); // available liquidity has been moved to the remote bridge adapter from the token pool. - assertEq(s_l2Token.balanceOf(address(remoteBridgeAdapter)), amount, "remoteBridgeAdapter balance"); + assertEq(s_l2Token.balanceOf(address(remoteBridgeAdapter)), AMOUNT, "remoteBridgeAdapter balance"); assertEq(s_l2Token.balanceOf(address(remotePool)), 0, "remotePool balance"); - // finalize manually on the L1 bridge adapter. + // prove and finalize manually on the L1 bridge adapter. // this should transfer the funds to the rebalancer. - bytes memory finalizationData = abi.encode(amount, nonce); - s_bridgeAdapter.finalizeWithdrawERC20(address(0), address(s_rebalancer), finalizationData); + MockL1BridgeAdapter.ProvePayload memory provePayload = MockL1BridgeAdapter.ProvePayload({nonce: nonce}); + MockL1BridgeAdapter.Payload memory payload = MockL1BridgeAdapter.Payload({ + action: MockL1BridgeAdapter.FinalizationAction.ProveWithdrawal, + data: abi.encode(provePayload) + }); + bool fundsAvailable = s_bridgeAdapter.finalizeWithdrawERC20(address(0), address(s_rebalancer), abi.encode(payload)); + assertFalse(fundsAvailable, "fundsAvailable must be false"); + MockL1BridgeAdapter.FinalizePayload memory finalizePayload = MockL1BridgeAdapter.FinalizePayload({ + nonce: nonce, + amount: AMOUNT + }); + payload = MockL1BridgeAdapter.Payload({ + action: MockL1BridgeAdapter.FinalizationAction.FinalizeWithdrawal, + data: abi.encode(finalizePayload) + }); + fundsAvailable = s_bridgeAdapter.finalizeWithdrawERC20(address(0), address(s_rebalancer), abi.encode(payload)); + assertTrue(fundsAvailable, "fundsAvailable must be true"); // available balance on the L1 bridge adapter has been moved to the rebalancer. - assertEq(s_l1Token.balanceOf(address(s_rebalancer)), amount, "rebalancer balance 1"); + assertEq(s_l1Token.balanceOf(address(s_rebalancer)), AMOUNT, "rebalancer balance 1"); assertEq(s_l1Token.balanceOf(address(s_bridgeAdapter)), 0, "bridgeAdapter balance"); // try to finalize on L1 again - bytes memory revertData = abi.encodeWithSelector(NonceAlreadyUsed.selector, nonce); + // bytes memory revertData = abi.encodeWithSelector(NonceAlreadyUsed.selector, nonce); vm.expectEmit(); - emit FinalizationFailed(maxSeqNum, i_remoteChainSelector, finalizationData, revertData); + emit FinalizationFailed( + maxSeqNum, + i_remoteChainSelector, + abi.encode(payload), + abi.encodeWithSelector(NonceAlreadyUsed.selector, nonce) + ); vm.expectEmit(); - emit LiquidityAdded(address(s_rebalancer), amount); + emit LiquidityAdded(address(s_rebalancer), AMOUNT); vm.expectEmit(); emit LiquidityTransferred( maxSeqNum, i_remoteChainSelector, i_localChainSelector, address(s_rebalancer), - amount, - finalizationData, + AMOUNT, + abi.encode(payload), bytes("") ); - s_rebalancer.receiveLiquidity(i_remoteChainSelector, amount, finalizationData); + s_rebalancer.receiveLiquidity(i_remoteChainSelector, AMOUNT, false, abi.encode(payload)); // available balance on the rebalancer has been injected into the token pool. assertEq(s_l1Token.balanceOf(address(s_rebalancer)), 0, "rebalancer balance 2"); - assertEq(s_l1Token.balanceOf(address(s_lockReleaseTokenPool)), amount, "lockReleaseTokenPool balance"); + assertEq(s_l1Token.balanceOf(address(s_lockReleaseTokenPool)), AMOUNT, "lockReleaseTokenPool balance"); + } + + function test_rebalanceBetweenPools_MultiStageFinalization() external { + // set up a rebalancer on another chain, an "L2". + // note we use the L1 bridge adapter because it has the reverting logic + // when finalization is already done. + MockL1BridgeAdapter remoteBridgeAdapter = new MockL1BridgeAdapter(s_l2Token, false); + LockReleaseTokenPool remotePool = new LockReleaseTokenPool( + s_l2Token, + new address[](0), + address(1), + true, + address(123) + ); + Rebalancer remoteRebalancer = new Rebalancer(s_l2Token, i_remoteChainSelector, remotePool, 0); + + // set rebalancer role on the pool. + remotePool.setRebalancer(address(remoteRebalancer)); + + // set up the cross chain rebalancer on "L1". + Rebalancer.CrossChainRebalancerArgs[] memory args = new Rebalancer.CrossChainRebalancerArgs[](1); + args[0] = IRebalancer.CrossChainRebalancerArgs({ + remoteRebalancer: address(remoteRebalancer), + localBridge: s_bridgeAdapter, + remoteToken: address(s_l2Token), + remoteChainSelector: i_remoteChainSelector, + enabled: true + }); + + s_rebalancer.setCrossChainRebalancers(args); + + // set up the cross chain rebalancer on "L2". + args[0] = IRebalancer.CrossChainRebalancerArgs({ + remoteRebalancer: address(s_rebalancer), + localBridge: remoteBridgeAdapter, + remoteToken: address(s_l1Token), + remoteChainSelector: i_localChainSelector, + enabled: true + }); + + remoteRebalancer.setCrossChainRebalancers(args); + + // deal some L1 tokens to the L1 bridge adapter so that it can send them to the rebalancer + // when the withdrawal gets finalized. + deal(address(s_l1Token), address(s_bridgeAdapter), AMOUNT); + // deal some L2 tokens to the remote token pool so that we can withdraw it when we rebalance. + deal(address(s_l2Token), address(remotePool), AMOUNT); + + // initiate a send from remote rebalancer to s_rebalancer. + uint256 nonce = 1; + uint64 maxSeqNum = type(uint64).max; + bytes memory bridgeSendReturnData = abi.encode(nonce); + bytes memory bridgeSpecificPayload = bytes(""); + vm.expectEmit(); + emit LiquidityRemoved(address(remoteRebalancer), AMOUNT); + vm.expectEmit(); + emit LiquidityTransferred( + maxSeqNum, + i_remoteChainSelector, + i_localChainSelector, + address(s_rebalancer), + AMOUNT, + bridgeSpecificPayload, + bridgeSendReturnData + ); + remoteRebalancer.rebalanceLiquidity(i_localChainSelector, AMOUNT, 0, bridgeSpecificPayload); + + // available liquidity has been moved to the remote bridge adapter from the token pool. + assertEq(s_l2Token.balanceOf(address(remoteBridgeAdapter)), AMOUNT, "remoteBridgeAdapter balance"); + assertEq(s_l2Token.balanceOf(address(remotePool)), 0, "remotePool balance"); + + // prove withdrawal on the L1 bridge adapter, through the rebalancer. + uint256 balanceBeforeProve = s_l1Token.balanceOf(address(s_lockReleaseTokenPool)); + MockL1BridgeAdapter.ProvePayload memory provePayload = MockL1BridgeAdapter.ProvePayload({nonce: nonce}); + MockL1BridgeAdapter.Payload memory payload = MockL1BridgeAdapter.Payload({ + action: MockL1BridgeAdapter.FinalizationAction.ProveWithdrawal, + data: abi.encode(provePayload) + }); + vm.expectEmit(); + emit FinalizationStepCompleted(maxSeqNum, i_remoteChainSelector, abi.encode(payload)); + s_rebalancer.receiveLiquidity(i_remoteChainSelector, AMOUNT, false, abi.encode(payload)); + + // s_rebalancer should have no tokens. + assertEq(s_l1Token.balanceOf(address(s_rebalancer)), 0, "rebalancer balance 1"); + // balance of s_lockReleaseTokenPool should be unchanged since no liquidity got added yet. + assertEq( + s_l1Token.balanceOf(address(s_lockReleaseTokenPool)), + balanceBeforeProve, + "s_lockReleaseTokenPool balance should be unchanged" + ); + + // finalize withdrawal on the L1 bridge adapter, through the rebalancer. + MockL1BridgeAdapter.FinalizePayload memory finalizePayload = MockL1BridgeAdapter.FinalizePayload({ + nonce: nonce, + amount: AMOUNT + }); + payload = MockL1BridgeAdapter.Payload({ + action: MockL1BridgeAdapter.FinalizationAction.FinalizeWithdrawal, + data: abi.encode(finalizePayload) + }); + vm.expectEmit(); + emit LiquidityAdded(address(s_rebalancer), AMOUNT); + vm.expectEmit(); + emit LiquidityTransferred( + maxSeqNum, + i_remoteChainSelector, + i_localChainSelector, + address(s_rebalancer), + AMOUNT, + abi.encode(payload), + bytes("") + ); + s_rebalancer.receiveLiquidity(i_remoteChainSelector, AMOUNT, false, abi.encode(payload)); + + // s_rebalancer should have no tokens. + assertEq(s_l1Token.balanceOf(address(s_rebalancer)), 0, "rebalancer balance 2"); + // balance of s_lockReleaseTokenPool should be updated + assertEq( + s_l1Token.balanceOf(address(s_lockReleaseTokenPool)), + balanceBeforeProve + AMOUNT, + "s_lockReleaseTokenPool balance should be updated" + ); + } + + function test_rebalanceBetweenPools_NativeRewrap() external { + // set up a rebalancer similar to the above on another chain, an "L2". + MockL1BridgeAdapter remoteBridgeAdapter = new MockL1BridgeAdapter(IERC20(address(s_l2Weth)), true); + LockReleaseTokenPool remotePool = new LockReleaseTokenPool( + IERC20(address(s_l2Weth)), + new address[](0), + address(1), + true, + address(123) + ); + Rebalancer remoteRebalancer = new Rebalancer(IERC20(address(s_l2Weth)), i_remoteChainSelector, remotePool, 0); + + // set rebalancer role on the pool. + remotePool.setRebalancer(address(remoteRebalancer)); + + // set up the cross chain rebalancer on "L1". + Rebalancer.CrossChainRebalancerArgs[] memory args = new Rebalancer.CrossChainRebalancerArgs[](1); + args[0] = IRebalancer.CrossChainRebalancerArgs({ + remoteRebalancer: address(remoteRebalancer), + localBridge: s_wethBridgeAdapter, + remoteToken: address(s_l2Weth), + remoteChainSelector: i_remoteChainSelector, + enabled: true + }); + + s_wethRebalancer.setCrossChainRebalancers(args); + + // set up the cross chain rebalancer on "L2". + args[0] = IRebalancer.CrossChainRebalancerArgs({ + remoteRebalancer: address(s_wethRebalancer), + localBridge: remoteBridgeAdapter, + remoteToken: address(s_l1Weth), + remoteChainSelector: i_localChainSelector, + enabled: true + }); + + remoteRebalancer.setCrossChainRebalancers(args); + + // deal some ether to the L1 bridge adapter so that it can send them to the rebalancer + // when the withdrawal gets finalized. + vm.deal(address(s_wethBridgeAdapter), AMOUNT); + // deal some L2 tokens to the remote token pool so that we can withdraw it when we rebalance. + deal(address(s_l2Weth), address(remotePool), AMOUNT); + // deposit some eth to the weth contract on L2 from the remote bridge adapter + // so that the withdraw() call succeeds. + vm.deal(address(remoteBridgeAdapter), AMOUNT); + vm.startPrank(address(remoteBridgeAdapter)); + s_l2Weth.deposit{value: AMOUNT}(); + vm.stopPrank(); + + // switch back to owner for the rest of the test to avoid reverts. + vm.startPrank(OWNER); + + // initiate a send from remote rebalancer to s_wethRebalancer. + uint256 nonce = 1; + uint64 maxSeqNum = type(uint64).max; + bytes memory bridgeSendReturnData = abi.encode(nonce); + bytes memory bridgeSpecificPayload = bytes(""); + vm.expectEmit(); + emit LiquidityRemoved(address(remoteRebalancer), AMOUNT); + vm.expectEmit(); + emit LiquidityTransferred( + maxSeqNum, + i_remoteChainSelector, + i_localChainSelector, + address(s_wethRebalancer), + AMOUNT, + bridgeSpecificPayload, + bridgeSendReturnData + ); + remoteRebalancer.rebalanceLiquidity(i_localChainSelector, AMOUNT, 0, bridgeSpecificPayload); + + // available liquidity has been moved to the remote bridge adapter from the token pool. + assertEq(s_l2Weth.balanceOf(address(remoteBridgeAdapter)), AMOUNT, "remoteBridgeAdapter balance"); + assertEq(s_l2Weth.balanceOf(address(remotePool)), 0, "remotePool balance"); + + // prove withdrawal on the L1 bridge adapter, through the rebalancer. + uint256 balanceBeforeProve = s_l1Weth.balanceOf(address(s_wethLockReleaseTokenPool)); + MockL1BridgeAdapter.ProvePayload memory provePayload = MockL1BridgeAdapter.ProvePayload({nonce: nonce}); + MockL1BridgeAdapter.Payload memory payload = MockL1BridgeAdapter.Payload({ + action: MockL1BridgeAdapter.FinalizationAction.ProveWithdrawal, + data: abi.encode(provePayload) + }); + vm.expectEmit(); + emit FinalizationStepCompleted(maxSeqNum, i_remoteChainSelector, abi.encode(payload)); + s_wethRebalancer.receiveLiquidity(i_remoteChainSelector, AMOUNT, false, abi.encode(payload)); + + // s_wethRebalancer should have no tokens. + assertEq(s_l1Weth.balanceOf(address(s_wethRebalancer)), 0, "rebalancer balance 1"); + // balance of s_wethLockReleaseTokenPool should be unchanged since no liquidity got added yet. + assertEq( + s_l1Weth.balanceOf(address(s_wethLockReleaseTokenPool)), + balanceBeforeProve, + "s_wethLockReleaseTokenPool balance should be unchanged" + ); + + // finalize withdrawal on the L1 bridge adapter, through the rebalancer. + MockL1BridgeAdapter.FinalizePayload memory finalizePayload = MockL1BridgeAdapter.FinalizePayload({ + nonce: nonce, + amount: AMOUNT + }); + payload = MockL1BridgeAdapter.Payload({ + action: MockL1BridgeAdapter.FinalizationAction.FinalizeWithdrawal, + data: abi.encode(finalizePayload) + }); + vm.expectEmit(); + emit LiquidityAdded(address(s_wethRebalancer), AMOUNT); + vm.expectEmit(); + emit LiquidityTransferred( + maxSeqNum, + i_remoteChainSelector, + i_localChainSelector, + address(s_wethRebalancer), + AMOUNT, + abi.encode(payload), + bytes("") + ); + s_wethRebalancer.receiveLiquidity(i_remoteChainSelector, AMOUNT, true, abi.encode(payload)); + + // s_wethRebalancer should have no tokens. + assertEq(s_l1Weth.balanceOf(address(s_wethRebalancer)), 0, "rebalancer balance 2"); + // s_wethRebalancer should have no native tokens. + assertEq(address(s_wethRebalancer).balance, 0, "rebalancer native balance should be zero"); + // balance of s_wethLockReleaseTokenPool should be updated + assertEq( + s_l1Weth.balanceOf(address(s_wethLockReleaseTokenPool)), + balanceBeforeProve + AMOUNT, + "s_wethLockReleaseTokenPool balance should be updated" + ); } // Reverts function test_InsufficientLiquidityReverts() external { - uint256 amount = 1245; - - vm.expectRevert(abi.encodeWithSelector(Rebalancer.InsufficientLiquidity.selector, amount, 0)); + vm.expectRevert(abi.encodeWithSelector(Rebalancer.InsufficientLiquidity.selector, AMOUNT, 0)); - s_rebalancer.rebalanceLiquidity(0, amount, 0, bytes("")); + s_rebalancer.rebalanceLiquidity(0, AMOUNT, 0, bytes("")); } function test_InvalidRemoteChainReverts() external { - uint256 amount = 12345679; - deal(address(s_l1Token), address(s_lockReleaseTokenPool), amount); + deal(address(s_l1Token), address(s_lockReleaseTokenPool), AMOUNT); vm.expectRevert(abi.encodeWithSelector(Rebalancer.InvalidRemoteChain.selector, i_remoteChainSelector)); - s_rebalancer.rebalanceLiquidity(i_remoteChainSelector, amount, 0, bytes("")); + s_rebalancer.rebalanceLiquidity(i_remoteChainSelector, AMOUNT, 0, bytes("")); } } diff --git a/contracts/src/v0.8/rebalancer/test/RebalancerBaseTest.t.sol b/contracts/src/v0.8/rebalancer/test/RebalancerBaseTest.t.sol index 4e2bbe6c75..c175ca3c64 100644 --- a/contracts/src/v0.8/rebalancer/test/RebalancerBaseTest.t.sol +++ b/contracts/src/v0.8/rebalancer/test/RebalancerBaseTest.t.sol @@ -3,6 +3,8 @@ pragma solidity 0.8.19; import {Test} from "forge-std/Test.sol"; +import {WETH9} from "../../ccip/test/WETH9.sol"; + import {ERC20} from "../../vendor/openzeppelin-solidity/v4.8.3/contracts/token/ERC20/ERC20.sol"; import {IERC20} from "../../vendor/openzeppelin-solidity/v4.8.3/contracts/token/ERC20/IERC20.sol"; @@ -13,6 +15,8 @@ contract RebalancerBaseTest is Test { IERC20 internal s_l1Token; IERC20 internal s_l2Token; + WETH9 internal s_l1Weth; + WETH9 internal s_l2Weth; uint64 internal immutable i_localChainSelector = 1234; uint64 internal immutable i_remoteChainSelector = 9876; @@ -24,6 +28,9 @@ contract RebalancerBaseTest is Test { s_l1Token = new ERC20("l1", "L1"); s_l2Token = new ERC20("l2", "L2"); + s_l1Weth = new WETH9(); + s_l2Weth = new WETH9(); + vm.startPrank(OWNER); vm.label(OWNER, "Owner"); vm.label(STRANGER, "Stranger"); diff --git a/contracts/src/v0.8/rebalancer/test/mocks/MockBridgeAdapter.sol b/contracts/src/v0.8/rebalancer/test/mocks/MockBridgeAdapter.sol index 6375b49784..660b795f1b 100644 --- a/contracts/src/v0.8/rebalancer/test/mocks/MockBridgeAdapter.sol +++ b/contracts/src/v0.8/rebalancer/test/mocks/MockBridgeAdapter.sol @@ -4,26 +4,70 @@ pragma solidity ^0.8.0; import {IBridgeAdapter} from "../../interfaces/IBridge.sol"; import {ILiquidityContainer} from "../../interfaces/ILiquidityContainer.sol"; +import {IWrappedNative} from "../../../ccip/interfaces/IWrappedNative.sol"; import {IERC20} from "../../../vendor/openzeppelin-solidity/v4.8.3/contracts/token/ERC20/IERC20.sol"; import {SafeERC20} from "../../../vendor/openzeppelin-solidity/v4.8.3/contracts/token/ERC20/utils/SafeERC20.sol"; -/// @notice Mock L1 Bridge adapter -/// @dev Sends the L1 tokens from the msg sender to address(this) +/// @notice Mock multiple-stage finalization bridge adapter implementation. +/// @dev Funds are only made available after both the prove and finalization steps are completed. +/// Sends the L1 tokens from the msg sender to address(this). contract MockL1BridgeAdapter is IBridgeAdapter, ILiquidityContainer { using SafeERC20 for IERC20; error InsufficientLiquidity(); error NonceAlreadyUsed(uint256 nonce); + error InvalidFinalizationAction(); + error NonceNotProven(uint256 nonce); + error NativeSendFailed(); + + /// @notice Payload to "prove" the withdrawal. + /// @dev This is just a mock setup, there's no real proving. This is so that + /// we can test the multi-step finalization code path. + /// @param nonce the nonce emitted on the remote chain. + struct ProvePayload { + uint256 nonce; + } + + /// @notice Payload to "finalize" the withdrawal. + /// @dev This is just a mock setup, there's no real finalization. This is so that + /// we can test the multi-step finalization code path. + /// @param nonce the nonce emitted on the remote chain. + struct FinalizePayload { + uint256 nonce; + uint256 amount; + } + + /// @notice The finalization action to take. + /// @dev This emulates Optimism's two-step withdrawal process. + enum FinalizationAction { + ProveWithdrawal, + FinalizeWithdrawal + } + + /// @notice The payload to use for the bridgeSpecificPayload in the finalizeWithdrawERC20 function. + struct Payload { + FinalizationAction action; + bytes data; + } IERC20 internal immutable i_token; uint256 internal s_nonce = 1; - mapping(uint256 => bool) internal s_nonceUsed; + mapping(uint256 => bool) internal s_nonceProven; + mapping(uint256 => bool) internal s_nonceFinalized; + + /// @dev For test cases where we want to send pure native upon finalizeWithdrawERC20 being called. + /// This is to emulate the behavior of bridges that do not bridge wrapped native. + bool internal immutable i_holdNative; - constructor(IERC20 token) { + constructor(IERC20 token, bool holdNative) { i_token = token; + i_holdNative = holdNative; } + /// @dev The receive function is needed for IWrappedNative.withdraw() to work. + receive() external payable {} + /// @notice Simply transferFrom msg.sender the tokens that are to be bridged to address(this). function sendERC20( address localToken, @@ -33,6 +77,14 @@ contract MockL1BridgeAdapter is IBridgeAdapter, ILiquidityContainer { bytes calldata /* bridgeSpecificPayload */ ) external payable override returns (bytes memory) { IERC20(localToken).transferFrom(msg.sender, address(this), amount); + + // If the flag to hold native is set we assume that i_token points to a WETH contract + // and withdraw native. + // This way we can transfer the raw native back to the sender upon finalization. + if (i_holdNative) { + IWrappedNative(address(i_token)).withdraw(amount); + } + bytes memory encodedNonce = abi.encode(s_nonce++); return encodedNonce; } @@ -52,20 +104,60 @@ contract MockL1BridgeAdapter is IBridgeAdapter, ILiquidityContainer { emit LiquidityRemoved(msg.sender, amount); } + /// @dev for easy encoding offchain + function encodeProvePayload(ProvePayload memory payload) external pure {} + + function encodeFinalizePayload(FinalizePayload memory payload) external pure {} + + function encodePayload(Payload memory payload) external pure {} + /// @dev Test setup is trusted, so just transfer the tokens to the localReceiver, - /// @dev which should be the local rebalancer. - /// @dev Infer the amount from the bridgeSpecificPayload - /// @dev Note that this means that this bridge adapter will need to have some tokens, - /// @dev however this is ok in a test environment since we will have infinite tokens. + /// which should be the local rebalancer. Infer the amount from the bridgeSpecificPayload. + /// Note that this means that this bridge adapter will need to have some tokens, + /// however this is ok in a test environment since we will have infinite tokens. + /// @param localReceiver the address to transfer the tokens to. + /// @param bridgeSpecificPayload the payload to use for the finalization or proving. + /// @return true if the transfer was successful, revert otherwise. function finalizeWithdrawERC20( address /* remoteSender */, address localReceiver, bytes calldata bridgeSpecificPayload - ) external { - (uint256 amount, uint256 nonce) = abi.decode(bridgeSpecificPayload, (uint256, uint256)); - if (s_nonceUsed[nonce]) revert NonceAlreadyUsed(nonce); - s_nonceUsed[nonce] = true; - i_token.safeTransfer(localReceiver, amount); + ) external override returns (bool) { + Payload memory payload = abi.decode(bridgeSpecificPayload, (Payload)); + if (payload.action == FinalizationAction.ProveWithdrawal) { + return _proveWithdrawal(payload); + } else if (payload.action == FinalizationAction.FinalizeWithdrawal) { + return _finalizeWithdrawal(payload, localReceiver); + } + revert InvalidFinalizationAction(); + } + + function _proveWithdrawal(Payload memory payload) internal returns (bool) { + ProvePayload memory provePayload = abi.decode(payload.data, (ProvePayload)); + if (s_nonceProven[provePayload.nonce]) revert NonceAlreadyUsed(provePayload.nonce); + s_nonceProven[provePayload.nonce] = true; + return false; + } + + function _finalizeWithdrawal(Payload memory payload, address localReceiver) internal returns (bool) { + FinalizePayload memory finalizePayload = abi.decode(payload.data, (FinalizePayload)); + if (!s_nonceProven[finalizePayload.nonce]) revert NonceNotProven(finalizePayload.nonce); + if (s_nonceFinalized[finalizePayload.nonce]) revert NonceAlreadyUsed(finalizePayload.nonce); + s_nonceFinalized[finalizePayload.nonce] = true; + // re-entrancy prevented by nonce checks above. + _transferTokens(finalizePayload.amount, localReceiver); + return true; + } + + function _transferTokens(uint256 amount, address localReceiver) internal { + if (i_holdNative) { + (bool success, ) = payable(localReceiver).call{value: amount}(""); + if (!success) { + revert NativeSendFailed(); + } + } else { + i_token.safeTransfer(localReceiver, amount); + } } } @@ -93,5 +185,7 @@ contract MockL2BridgeAdapter is IBridgeAdapter { address /* remoteSender */, address /* localReceiver */, bytes calldata /* bridgeSpecificData */ - ) external override {} + ) external override returns (bool) { + return true; + } } diff --git a/core/gethwrappers/rebalancer/generated/arbitrum_l1_bridge_adapter/arbitrum_l1_bridge_adapter.go b/core/gethwrappers/rebalancer/generated/arbitrum_l1_bridge_adapter/arbitrum_l1_bridge_adapter.go index b3ded67105..c0fffa6f56 100644 --- a/core/gethwrappers/rebalancer/generated/arbitrum_l1_bridge_adapter/arbitrum_l1_bridge_adapter.go +++ b/core/gethwrappers/rebalancer/generated/arbitrum_l1_bridge_adapter/arbitrum_l1_bridge_adapter.go @@ -47,8 +47,8 @@ type ArbitrumL1BridgeAdapterSendERC20Params struct { } var ArbitrumL1BridgeAdapterMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[{\"internalType\":\"contractIL1GatewayRouter\",\"name\":\"l1GatewayRouter\",\"type\":\"address\"},{\"internalType\":\"contractIOutbox\",\"name\":\"l1Outbox\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"BridgeAddressCannotBeZero\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"wanted\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"got\",\"type\":\"uint256\"}],\"name\":\"InsufficientEthValue\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"MsgShouldNotContainValue\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"msgValue\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"MsgValueDoesNotMatchAmount\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"}],\"name\":\"NoGatewayForToken\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"Unimplemented\",\"type\":\"error\"},{\"inputs\":[{\"components\":[{\"internalType\":\"bytes32[]\",\"name\":\"proof\",\"type\":\"bytes32[]\"},{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"l2Sender\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"l2Block\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"l1Block\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"l2Timestamp\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"internalType\":\"structArbitrumL1BridgeAdapter.ArbitrumFinalizationPayload\",\"name\":\"payload\",\"type\":\"tuple\"}],\"name\":\"exposeArbitrumFinalizationPayload\",\"outputs\":[],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"gasLimit\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"maxSubmissionCost\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"maxFeePerGas\",\"type\":\"uint256\"}],\"internalType\":\"structArbitrumL1BridgeAdapter.SendERC20Params\",\"name\":\"params\",\"type\":\"tuple\"}],\"name\":\"exposeSendERC20Params\",\"outputs\":[],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"arbitrumFinalizationPayload\",\"type\":\"bytes\"}],\"name\":\"finalizeWithdrawERC20\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getBridgeFeeInNative\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"l1Token\",\"type\":\"address\"}],\"name\":\"getL2Token\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"localToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"bridgeSpecificPayload\",\"type\":\"bytes\"}],\"name\":\"sendERC20\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"}]", - Bin: "0x60c060405234801561001057600080fd5b506040516200143e3803806200143e8339810160408190526100319161009b565b6001600160a01b038216158061004e57506001600160a01b038116155b1561006c57604051635e9c404d60e11b815260040160405180910390fd5b6001600160a01b039182166080521660a0526100d5565b6001600160a01b038116811461009857600080fd5b50565b600080604083850312156100ae57600080fd5b82516100b981610083565b60208401519092506100ca81610083565b809150509250929050565b60805160a0516113356200010960003960006101ff0152600081816102e10152818161045901526105b501526113356000f3fe6080604052600436106100655760003560e01c8063b5399c9e11610043578063b5399c9e146100d4578063c7665dd2146100f2578063c985069c1461010d57600080fd5b80632e4b1fc91461006a57806338314bb214610092578063a71d98b7146100b4575b600080fd5b34801561007657600080fd5b5061007f610152565b6040519081526020015b60405180910390f35b34801561009e57600080fd5b506100b26100ad366004610c27565b610186565b005b6100c76100c2366004610c8c565b610275565b6040516100899190610d7f565b3480156100e057600080fd5b506100b26100ef366004610e41565b50565b3480156100fe57600080fd5b506100b26100ef366004610fae565b34801561011957600080fd5b5061012d610128366004611098565b61056d565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610089565b60006040517f6e12839900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600061019482840184610fae565b805160208201516040808401516060850151608086015160a087015160c088015160e08901516101008a015196517f08635a95000000000000000000000000000000000000000000000000000000008152999a5073ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016996308635a959961023c99909890979695949392916004016110b5565b600060405180830381600087803b15801561025657600080fd5b505af115801561026a573d6000803e3d6000fd5b505050505050505050565b606061029973ffffffffffffffffffffffffffffffffffffffff8816333087610628565b6040517fbda009fe00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff88811660048301526000917f00000000000000000000000000000000000000000000000000000000000000009091169063bda009fe90602401602060405180830381865afa15801561032a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061034e919061116b565b905073ffffffffffffffffffffffffffffffffffffffff81166103ba576040517f6c1460f400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff891660048201526024015b60405180910390fd5b6103db73ffffffffffffffffffffffffffffffffffffffff8916828761070a565b60006103e984860186610e41565b9050600081602001518260400151836000015161040691906111b7565b61041091906111ce565b905080341015610455576040517f03da4d23000000000000000000000000000000000000000000000000000000008152346004820152602481018290526044016103b1565b60007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16634fb1a07b348d8c8d8d89600001518a604001518b60200151604051806020016040528060008152506040516020016104c89291906111e1565b6040516020818303038152906040526040518963ffffffff1660e01b81526004016104f997969594939291906111fa565b60006040518083038185885af1158015610517573d6000803e3d6000fd5b50505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016820160405261055e919081019061125a565b9b9a5050505050505050505050565b6040517fa7e28d4800000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff82811660048301526000917f00000000000000000000000000000000000000000000000000000000000000009091169063a7e28d4890602401602060405180830381865afa1580156105fe573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610622919061116b565b92915050565b60405173ffffffffffffffffffffffffffffffffffffffff808516602483015283166044820152606481018290526107049085907f23b872dd00000000000000000000000000000000000000000000000000000000906084015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152610891565b50505050565b8015806107aa57506040517fdd62ed3e00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff838116602483015284169063dd62ed3e90604401602060405180830381865afa158015610784573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107a891906112d1565b155b610836576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527f20746f206e6f6e2d7a65726f20616c6c6f77616e63650000000000000000000060648201526084016103b1565b60405173ffffffffffffffffffffffffffffffffffffffff831660248201526044810182905261088c9084907f095ea7b30000000000000000000000000000000000000000000000000000000090606401610682565b505050565b60006108f3826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff1661099d9092919063ffffffff16565b80519091501561088c578080602001905181019061091191906112ea565b61088c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f7420737563636565640000000000000000000000000000000000000000000060648201526084016103b1565b60606109ac84846000856109b4565b949350505050565b606082471015610a46576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c000000000000000000000000000000000000000000000000000060648201526084016103b1565b6000808673ffffffffffffffffffffffffffffffffffffffff168587604051610a6f919061130c565b60006040518083038185875af1925050503d8060008114610aac576040519150601f19603f3d011682016040523d82523d6000602084013e610ab1565b606091505b5091509150610ac287838387610acd565b979650505050505050565b60608315610b63578251600003610b5c5773ffffffffffffffffffffffffffffffffffffffff85163b610b5c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016103b1565b50816109ac565b6109ac8383815115610b785781518083602001fd5b806040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103b19190610d7f565b73ffffffffffffffffffffffffffffffffffffffff811681146100ef57600080fd5b8035610bd981610bac565b919050565b60008083601f840112610bf057600080fd5b50813567ffffffffffffffff811115610c0857600080fd5b602083019150836020828501011115610c2057600080fd5b9250929050565b60008060008060608587031215610c3d57600080fd5b8435610c4881610bac565b93506020850135610c5881610bac565b9250604085013567ffffffffffffffff811115610c7457600080fd5b610c8087828801610bde565b95989497509550505050565b60008060008060008060a08789031215610ca557600080fd5b8635610cb081610bac565b95506020870135610cc081610bac565b94506040870135610cd081610bac565b935060608701359250608087013567ffffffffffffffff811115610cf357600080fd5b610cff89828a01610bde565b979a9699509497509295939492505050565b60005b83811015610d2c578181015183820152602001610d14565b50506000910152565b60008151808452610d4d816020860160208601610d11565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b602081526000610d926020830184610d35565b9392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051610120810167ffffffffffffffff81118282101715610dec57610dec610d99565b60405290565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff81118282101715610e3957610e39610d99565b604052919050565b600060608284031215610e5357600080fd5b6040516060810181811067ffffffffffffffff82111715610e7657610e76610d99565b80604052508235815260208301356020820152604083013560408201528091505092915050565b600082601f830112610eae57600080fd5b8135602067ffffffffffffffff821115610eca57610eca610d99565b8160051b610ed9828201610df2565b9283528481018201928281019087851115610ef357600080fd5b83870192505b84831015610ac257823582529183019190830190610ef9565b600067ffffffffffffffff821115610f2c57610f2c610d99565b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b600082601f830112610f6957600080fd5b8135610f7c610f7782610f12565b610df2565b818152846020838601011115610f9157600080fd5b816020850160208301376000918101602001919091529392505050565b600060208284031215610fc057600080fd5b813567ffffffffffffffff80821115610fd857600080fd5b908301906101208286031215610fed57600080fd5b610ff5610dc8565b82358281111561100457600080fd5b61101087828601610e9d565b8252506020830135602082015261102960408401610bce565b604082015261103a60608401610bce565b60608201526080830135608082015260a083013560a082015260c083013560c082015260e083013560e0820152610100808401358381111561107b57600080fd5b61108788828701610f58565b918301919091525095945050505050565b6000602082840312156110aa57600080fd5b8135610d9281610bac565b6101208082528a51908201819052600090610140830190602090818e01845b828110156110f0578151855293830193908301906001016110d4565b50505083018b905273ffffffffffffffffffffffffffffffffffffffff8a16604084015273ffffffffffffffffffffffffffffffffffffffff891660608401528760808401528660a08401528560c08401528460e084015282810361010084015261115b8185610d35565b9c9b505050505050505050505050565b60006020828403121561117d57600080fd5b8151610d9281610bac565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b808202811582820484141761062257610622611188565b8082018082111561062257610622611188565b8281526040602082015260006109ac6040830184610d35565b600073ffffffffffffffffffffffffffffffffffffffff808a16835280891660208401528088166040840152508560608301528460808301528360a083015260e060c083015261124d60e0830184610d35565b9998505050505050505050565b60006020828403121561126c57600080fd5b815167ffffffffffffffff81111561128357600080fd5b8201601f8101841361129457600080fd5b80516112a2610f7782610f12565b8181528560208385010111156112b757600080fd5b6112c8826020830160208601610d11565b95945050505050565b6000602082840312156112e357600080fd5b5051919050565b6000602082840312156112fc57600080fd5b81518015158114610d9257600080fd5b6000825161131e818460208701610d11565b919091019291505056fea164736f6c6343000813000a", + ABI: "[{\"inputs\":[{\"internalType\":\"contractIL1GatewayRouter\",\"name\":\"l1GatewayRouter\",\"type\":\"address\"},{\"internalType\":\"contractIOutbox\",\"name\":\"l1Outbox\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"BridgeAddressCannotBeZero\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"wanted\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"got\",\"type\":\"uint256\"}],\"name\":\"InsufficientEthValue\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"MsgShouldNotContainValue\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"msgValue\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"MsgValueDoesNotMatchAmount\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"}],\"name\":\"NoGatewayForToken\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"Unimplemented\",\"type\":\"error\"},{\"inputs\":[{\"components\":[{\"internalType\":\"bytes32[]\",\"name\":\"proof\",\"type\":\"bytes32[]\"},{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"l2Sender\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"l2Block\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"l1Block\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"l2Timestamp\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"internalType\":\"structArbitrumL1BridgeAdapter.ArbitrumFinalizationPayload\",\"name\":\"payload\",\"type\":\"tuple\"}],\"name\":\"exposeArbitrumFinalizationPayload\",\"outputs\":[],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"gasLimit\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"maxSubmissionCost\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"maxFeePerGas\",\"type\":\"uint256\"}],\"internalType\":\"structArbitrumL1BridgeAdapter.SendERC20Params\",\"name\":\"params\",\"type\":\"tuple\"}],\"name\":\"exposeSendERC20Params\",\"outputs\":[],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"arbitrumFinalizationPayload\",\"type\":\"bytes\"}],\"name\":\"finalizeWithdrawERC20\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getBridgeFeeInNative\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"l1Token\",\"type\":\"address\"}],\"name\":\"getL2Token\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"localToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"bridgeSpecificPayload\",\"type\":\"bytes\"}],\"name\":\"sendERC20\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"}]", + Bin: "0x60c060405234801561001057600080fd5b50604051620013b8380380620013b88339810160408190526100319161009b565b6001600160a01b038216158061004e57506001600160a01b038116155b1561006c57604051635e9c404d60e11b815260040160405180910390fd5b6001600160a01b039182166080521660a0526100d5565b6001600160a01b038116811461009857600080fd5b50565b600080604083850312156100ae57600080fd5b82516100b981610083565b60208401519092506100ca81610083565b809150509250929050565b60805160a0516112af6200010960003960006102100152600081816102f90152818161047101526105cd01526112af6000f3fe6080604052600436106100655760003560e01c8063b5399c9e11610043578063b5399c9e146100e2578063c7665dd214610102578063c985069c1461011d57600080fd5b80632e4b1fc91461006a57806338314bb214610092578063a71d98b7146100c2575b600080fd5b34801561007657600080fd5b5061007f610162565b6040519081526020015b60405180910390f35b34801561009e57600080fd5b506100b26100ad366004610ba1565b610196565b6040519015158152602001610089565b6100d56100d0366004610c06565b61028d565b6040516100899190610cf9565b3480156100ee57600080fd5b506101006100fd366004610dbb565b50565b005b34801561010e57600080fd5b506101006100fd366004610f28565b34801561012957600080fd5b5061013d610138366004611012565b610585565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610089565b60006040517f6e12839900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000806101a583850185610f28565b805160208201516040808401516060850151608086015160a087015160c088015160e08901516101008a015196517f08635a95000000000000000000000000000000000000000000000000000000008152999a5073ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016996308635a959961024d999098909796959493929160040161102f565b600060405180830381600087803b15801561026757600080fd5b505af115801561027b573d6000803e3d6000fd5b5050505060019150505b949350505050565b60606102b173ffffffffffffffffffffffffffffffffffffffff8816333087610640565b6040517fbda009fe00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff88811660048301526000917f00000000000000000000000000000000000000000000000000000000000000009091169063bda009fe90602401602060405180830381865afa158015610342573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061036691906110e5565b905073ffffffffffffffffffffffffffffffffffffffff81166103d2576040517f6c1460f400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff891660048201526024015b60405180910390fd5b6103f373ffffffffffffffffffffffffffffffffffffffff89168287610722565b600061040184860186610dbb565b9050600081602001518260400151836000015161041e9190611131565b6104289190611148565b90508034101561046d576040517f03da4d23000000000000000000000000000000000000000000000000000000008152346004820152602481018290526044016103c9565b60007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16634fb1a07b348d8c8d8d89600001518a604001518b60200151604051806020016040528060008152506040516020016104e092919061115b565b6040516020818303038152906040526040518963ffffffff1660e01b81526004016105119796959493929190611174565b60006040518083038185885af115801561052f573d6000803e3d6000fd5b50505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016820160405261057691908101906111d4565b9b9a5050505050505050505050565b6040517fa7e28d4800000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff82811660048301526000917f00000000000000000000000000000000000000000000000000000000000000009091169063a7e28d4890602401602060405180830381865afa158015610616573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061063a91906110e5565b92915050565b60405173ffffffffffffffffffffffffffffffffffffffff8085166024830152831660448201526064810182905261071c9085907f23b872dd00000000000000000000000000000000000000000000000000000000906084015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff00000000000000000000000000000000000000000000000000000000909316929092179091526108a9565b50505050565b8015806107c257506040517fdd62ed3e00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff838116602483015284169063dd62ed3e90604401602060405180830381865afa15801561079c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107c0919061124b565b155b61084e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527f20746f206e6f6e2d7a65726f20616c6c6f77616e63650000000000000000000060648201526084016103c9565b60405173ffffffffffffffffffffffffffffffffffffffff83166024820152604481018290526108a49084907f095ea7b3000000000000000000000000000000000000000000000000000000009060640161069a565b505050565b600061090b826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff166109b59092919063ffffffff16565b8051909150156108a457808060200190518101906109299190611264565b6108a4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f7420737563636565640000000000000000000000000000000000000000000060648201526084016103c9565b60606102858484600085856000808673ffffffffffffffffffffffffffffffffffffffff1685876040516109e99190611286565b60006040518083038185875af1925050503d8060008114610a26576040519150601f19603f3d011682016040523d82523d6000602084013e610a2b565b606091505b5091509150610a3c87838387610a47565b979650505050505050565b60608315610add578251600003610ad65773ffffffffffffffffffffffffffffffffffffffff85163b610ad6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016103c9565b5081610285565b6102858383815115610af25781518083602001fd5b806040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103c99190610cf9565b73ffffffffffffffffffffffffffffffffffffffff811681146100fd57600080fd5b8035610b5381610b26565b919050565b60008083601f840112610b6a57600080fd5b50813567ffffffffffffffff811115610b8257600080fd5b602083019150836020828501011115610b9a57600080fd5b9250929050565b60008060008060608587031215610bb757600080fd5b8435610bc281610b26565b93506020850135610bd281610b26565b9250604085013567ffffffffffffffff811115610bee57600080fd5b610bfa87828801610b58565b95989497509550505050565b60008060008060008060a08789031215610c1f57600080fd5b8635610c2a81610b26565b95506020870135610c3a81610b26565b94506040870135610c4a81610b26565b935060608701359250608087013567ffffffffffffffff811115610c6d57600080fd5b610c7989828a01610b58565b979a9699509497509295939492505050565b60005b83811015610ca6578181015183820152602001610c8e565b50506000910152565b60008151808452610cc7816020860160208601610c8b565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b602081526000610d0c6020830184610caf565b9392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051610120810167ffffffffffffffff81118282101715610d6657610d66610d13565b60405290565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff81118282101715610db357610db3610d13565b604052919050565b600060608284031215610dcd57600080fd5b6040516060810181811067ffffffffffffffff82111715610df057610df0610d13565b80604052508235815260208301356020820152604083013560408201528091505092915050565b600082601f830112610e2857600080fd5b8135602067ffffffffffffffff821115610e4457610e44610d13565b8160051b610e53828201610d6c565b9283528481018201928281019087851115610e6d57600080fd5b83870192505b84831015610a3c57823582529183019190830190610e73565b600067ffffffffffffffff821115610ea657610ea6610d13565b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b600082601f830112610ee357600080fd5b8135610ef6610ef182610e8c565b610d6c565b818152846020838601011115610f0b57600080fd5b816020850160208301376000918101602001919091529392505050565b600060208284031215610f3a57600080fd5b813567ffffffffffffffff80821115610f5257600080fd5b908301906101208286031215610f6757600080fd5b610f6f610d42565b823582811115610f7e57600080fd5b610f8a87828601610e17565b82525060208301356020820152610fa360408401610b48565b6040820152610fb460608401610b48565b60608201526080830135608082015260a083013560a082015260c083013560c082015260e083013560e08201526101008084013583811115610ff557600080fd5b61100188828701610ed2565b918301919091525095945050505050565b60006020828403121561102457600080fd5b8135610d0c81610b26565b6101208082528a51908201819052600090610140830190602090818e01845b8281101561106a5781518552938301939083019060010161104e565b50505083018b905273ffffffffffffffffffffffffffffffffffffffff8a16604084015273ffffffffffffffffffffffffffffffffffffffff891660608401528760808401528660a08401528560c08401528460e08401528281036101008401526110d58185610caf565b9c9b505050505050505050505050565b6000602082840312156110f757600080fd5b8151610d0c81610b26565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b808202811582820484141761063a5761063a611102565b8082018082111561063a5761063a611102565b8281526040602082015260006102856040830184610caf565b600073ffffffffffffffffffffffffffffffffffffffff808a16835280891660208401528088166040840152508560608301528460808301528360a083015260e060c08301526111c760e0830184610caf565b9998505050505050505050565b6000602082840312156111e657600080fd5b815167ffffffffffffffff8111156111fd57600080fd5b8201601f8101841361120e57600080fd5b805161121c610ef182610e8c565b81815285602083850101111561123157600080fd5b611242826020830160208601610c8b565b95945050505050565b60006020828403121561125d57600080fd5b5051919050565b60006020828403121561127657600080fd5b81518015158114610d0c57600080fd5b60008251611298818460208701610c8b565b919091019291505056fea164736f6c6343000813000a", } var ArbitrumL1BridgeAdapterABI = ArbitrumL1BridgeAdapterMetaData.ABI diff --git a/core/gethwrappers/rebalancer/generated/arbitrum_l2_bridge_adapter/arbitrum_l2_bridge_adapter.go b/core/gethwrappers/rebalancer/generated/arbitrum_l2_bridge_adapter/arbitrum_l2_bridge_adapter.go index f6bc7391b4..781a6f6ffb 100644 --- a/core/gethwrappers/rebalancer/generated/arbitrum_l2_bridge_adapter/arbitrum_l2_bridge_adapter.go +++ b/core/gethwrappers/rebalancer/generated/arbitrum_l2_bridge_adapter/arbitrum_l2_bridge_adapter.go @@ -29,8 +29,8 @@ var ( ) var ArbitrumL2BridgeAdapterMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[{\"internalType\":\"contractIL2GatewayRouter\",\"name\":\"l2GatewayRouter\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"BridgeAddressCannotBeZero\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"wanted\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"got\",\"type\":\"uint256\"}],\"name\":\"InsufficientEthValue\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"MsgShouldNotContainValue\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"msgValue\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"MsgValueDoesNotMatchAmount\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"}],\"name\":\"depositNativeToL1\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"name\":\"finalizeWithdrawERC20\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getBridgeFeeInNative\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"localToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"remoteToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"name\":\"sendERC20\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"}]", - Bin: "0x60a060405234801561001057600080fd5b50604051610a7e380380610a7e83398101604081905261002f91610067565b6001600160a01b03811661005657604051635e9c404d60e11b815260040160405180910390fd5b6001600160a01b0316608052610097565b60006020828403121561007957600080fd5b81516001600160a01b038116811461009057600080fd5b9392505050565b6080516109cc6100b2600039600061020001526109cc6000f3fe60806040526004361061003f5760003560e01c80630ff98e31146100445780632e4b1fc91461005957806338314bb21461007a578063a71d98b71461009b575b600080fd5b610057610052366004610664565b6100bb565b005b34801561006557600080fd5b50604051600081526020015b60405180910390f35b34801561008657600080fd5b506100576100953660046106cf565b50505050565b6100ae6100a9366004610730565b610152565b604051610071919061081d565b6040517f25e1606300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff821660048201526064906325e1606390349060240160206040518083038185885af1158015610129573d6000803e3d6000fd5b50505050506040513d601f19601f8201168201806040525081019061014e9190610830565b5050565b60603415610193576040517f2543d86e0000000000000000000000000000000000000000000000000000000081523460048201526024015b60405180910390fd5b6101b573ffffffffffffffffffffffffffffffffffffffff88163330876102aa565b60408051602081018252600080825291517f7b3a3c8b00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001691637b3a3c8b91610239918b918b918b91600401610849565b6000604051808303816000875af1158015610258573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016820160405261029e91908101906108c1565b98975050505050505050565b6040805173ffffffffffffffffffffffffffffffffffffffff8581166024830152848116604483015260648083018590528351808403909101815260849092018352602080830180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f23b872dd0000000000000000000000000000000000000000000000000000000017905283518085019094528084527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564908401526100959287929160009161037d91851690849061042c565b805190915015610427578080602001905181019061039b9190610981565b610427576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f74207375636365656400000000000000000000000000000000000000000000606482015260840161018a565b505050565b606061043b8484600085610443565b949350505050565b6060824710156104d5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c0000000000000000000000000000000000000000000000000000606482015260840161018a565b6000808673ffffffffffffffffffffffffffffffffffffffff1685876040516104fe91906109a3565b60006040518083038185875af1925050503d806000811461053b576040519150601f19603f3d011682016040523d82523d6000602084013e610540565b606091505b50915091506105518783838761055c565b979650505050505050565b606083156105f25782516000036105eb5773ffffffffffffffffffffffffffffffffffffffff85163b6105eb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161018a565b508161043b565b61043b83838151156106075781518083602001fd5b806040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161018a919061081d565b803573ffffffffffffffffffffffffffffffffffffffff8116811461065f57600080fd5b919050565b60006020828403121561067657600080fd5b61067f8261063b565b9392505050565b60008083601f84011261069857600080fd5b50813567ffffffffffffffff8111156106b057600080fd5b6020830191508360208285010111156106c857600080fd5b9250929050565b600080600080606085870312156106e557600080fd5b6106ee8561063b565b93506106fc6020860161063b565b9250604085013567ffffffffffffffff81111561071857600080fd5b61072487828801610686565b95989497509550505050565b60008060008060008060a0878903121561074957600080fd5b6107528761063b565b95506107606020880161063b565b945061076e6040880161063b565b935060608701359250608087013567ffffffffffffffff81111561079157600080fd5b61079d89828a01610686565b979a9699509497509295939492505050565b60005b838110156107ca5781810151838201526020016107b2565b50506000910152565b600081518084526107eb8160208601602086016107af565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b60208152600061067f60208301846107d3565b60006020828403121561084257600080fd5b5051919050565b600073ffffffffffffffffffffffffffffffffffffffff80871683528086166020840152508360408301526080606083015261088860808301846107d3565b9695505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000602082840312156108d357600080fd5b815167ffffffffffffffff808211156108eb57600080fd5b818401915084601f8301126108ff57600080fd5b81518181111561091157610911610892565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f0116810190838211818310171561095757610957610892565b8160405282815287602084870101111561097057600080fd5b6105518360208301602088016107af565b60006020828403121561099357600080fd5b8151801515811461067f57600080fd5b600082516109b58184602087016107af565b919091019291505056fea164736f6c6343000813000a", + ABI: "[{\"inputs\":[{\"internalType\":\"contractIL2GatewayRouter\",\"name\":\"l2GatewayRouter\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"BridgeAddressCannotBeZero\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"wanted\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"got\",\"type\":\"uint256\"}],\"name\":\"InsufficientEthValue\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"MsgShouldNotContainValue\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"msgValue\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"MsgValueDoesNotMatchAmount\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"}],\"name\":\"depositNativeToL1\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"name\":\"finalizeWithdrawERC20\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getBridgeFeeInNative\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"localToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"remoteToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"name\":\"sendERC20\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"}]", + Bin: "0x60a060405234801561001057600080fd5b50604051610a24380380610a2483398101604081905261002f91610067565b6001600160a01b03811661005657604051635e9c404d60e11b815260040160405180910390fd5b6001600160a01b0316608052610097565b60006020828403121561007957600080fd5b81516001600160a01b038116811461009057600080fd5b9392505050565b6080516109726100b2600039600061021a01526109726000f3fe60806040526004361061003f5760003560e01c80630ff98e31146100445780632e4b1fc91461005957806338314bb21461007a578063a71d98b7146100aa575b600080fd5b61005761005236600461060a565b6100ca565b005b34801561006557600080fd5b50604051600081526020015b60405180910390f35b34801561008657600080fd5b5061009a610095366004610675565b610161565b6040519015158152602001610071565b6100bd6100b83660046106d6565b61016c565b60405161007191906107c3565b6040517f25e1606300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff821660048201526064906325e1606390349060240160206040518083038185885af1158015610138573d6000803e3d6000fd5b50505050506040513d601f19601f8201168201806040525081019061015d91906107d6565b5050565b60015b949350505050565b606034156101ad576040517f2543d86e0000000000000000000000000000000000000000000000000000000081523460048201526024015b60405180910390fd5b6101cf73ffffffffffffffffffffffffffffffffffffffff88163330876102c4565b60408051602081018252600080825291517f7b3a3c8b00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001691637b3a3c8b91610253918b918b918b916004016107ef565b6000604051808303816000875af1158015610272573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01682016040526102b89190810190610867565b98975050505050505050565b6040805173ffffffffffffffffffffffffffffffffffffffff85811660248301528416604482015260648082018490528251808303909101815260849091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f23b872dd0000000000000000000000000000000000000000000000000000000017905261035990859061035f565b50505050565b60006103c1826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff166104709092919063ffffffff16565b80519091501561046b57808060200190518101906103df9190610927565b61046b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f7420737563636565640000000000000000000000000000000000000000000060648201526084016101a4565b505050565b60606101648484600085856000808673ffffffffffffffffffffffffffffffffffffffff1685876040516104a49190610949565b60006040518083038185875af1925050503d80600081146104e1576040519150601f19603f3d011682016040523d82523d6000602084013e6104e6565b606091505b50915091506104f787838387610502565b979650505050505050565b606083156105985782516000036105915773ffffffffffffffffffffffffffffffffffffffff85163b610591576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016101a4565b5081610164565b61016483838151156105ad5781518083602001fd5b806040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016101a491906107c3565b803573ffffffffffffffffffffffffffffffffffffffff8116811461060557600080fd5b919050565b60006020828403121561061c57600080fd5b610625826105e1565b9392505050565b60008083601f84011261063e57600080fd5b50813567ffffffffffffffff81111561065657600080fd5b60208301915083602082850101111561066e57600080fd5b9250929050565b6000806000806060858703121561068b57600080fd5b610694856105e1565b93506106a2602086016105e1565b9250604085013567ffffffffffffffff8111156106be57600080fd5b6106ca8782880161062c565b95989497509550505050565b60008060008060008060a087890312156106ef57600080fd5b6106f8876105e1565b9550610706602088016105e1565b9450610714604088016105e1565b935060608701359250608087013567ffffffffffffffff81111561073757600080fd5b61074389828a0161062c565b979a9699509497509295939492505050565b60005b83811015610770578181015183820152602001610758565b50506000910152565b60008151808452610791816020860160208601610755565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b6020815260006106256020830184610779565b6000602082840312156107e857600080fd5b5051919050565b600073ffffffffffffffffffffffffffffffffffffffff80871683528086166020840152508360408301526080606083015261082e6080830184610779565b9695505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60006020828403121561087957600080fd5b815167ffffffffffffffff8082111561089157600080fd5b818401915084601f8301126108a557600080fd5b8151818111156108b7576108b7610838565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f011681019083821181831017156108fd576108fd610838565b8160405282815287602084870101111561091657600080fd5b6104f7836020830160208801610755565b60006020828403121561093957600080fd5b8151801515811461062557600080fd5b6000825161095b818460208701610755565b919091019291505056fea164736f6c6343000813000a", } var ArbitrumL2BridgeAdapterABI = ArbitrumL2BridgeAdapterMetaData.ABI diff --git a/core/gethwrappers/rebalancer/generated/mock_l1_bridge_adapter/mock_l1_bridge_adapter.go b/core/gethwrappers/rebalancer/generated/mock_l1_bridge_adapter/mock_l1_bridge_adapter.go index f3617c2f2c..7f86005a90 100644 --- a/core/gethwrappers/rebalancer/generated/mock_l1_bridge_adapter/mock_l1_bridge_adapter.go +++ b/core/gethwrappers/rebalancer/generated/mock_l1_bridge_adapter/mock_l1_bridge_adapter.go @@ -30,16 +30,30 @@ var ( _ = abi.ConvertType ) +type MockL1BridgeAdapterFinalizePayload struct { + Nonce *big.Int + Amount *big.Int +} + +type MockL1BridgeAdapterPayload struct { + Action uint8 + Data []byte +} + +type MockL1BridgeAdapterProvePayload struct { + Nonce *big.Int +} + var MockL1BridgeAdapterMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[{\"internalType\":\"contractIERC20\",\"name\":\"token\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"BridgeAddressCannotBeZero\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"wanted\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"got\",\"type\":\"uint256\"}],\"name\":\"InsufficientEthValue\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InsufficientLiquidity\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"MsgShouldNotContainValue\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"msgValue\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"MsgValueDoesNotMatchAmount\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"}],\"name\":\"NonceAlreadyUsed\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"provider\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"LiquidityAdded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"provider\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"LiquidityRemoved\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"localReceiver\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"bridgeSpecificPayload\",\"type\":\"bytes\"}],\"name\":\"finalizeWithdrawERC20\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getBridgeFeeInNative\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"provideLiquidity\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"localToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"name\":\"sendERC20\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"withdrawLiquidity\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", - Bin: "0x60a0604052600160005534801561001557600080fd5b50604051610c8a380380610c8a83398101604081905261003491610045565b6001600160a01b0316608052610075565b60006020828403121561005757600080fd5b81516001600160a01b038116811461006e57600080fd5b9392505050565b608051610be56100a5600039600081816101320152818161020401528181610314015261045d0152610be56000f3fe60806040526004361061005a5760003560e01c806338314bb21161004357806338314bb2146100a2578063a71d98b7146100c2578063eb521a4c146100e257600080fd5b80630a861f2a1461005f5780632e4b1fc914610081575b600080fd5b34801561006b57600080fd5b5061007f61007a36600461090d565b610102565b005b34801561008d57600080fd5b50604051600081526020015b60405180910390f35b3480156100ae57600080fd5b5061007f6100bd366004610998565b61025b565b6100d56100d03660046109f9565b610343565b6040516100999190610ae6565b3480156100ee57600080fd5b5061007f6100fd36600461090d565b610443565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015281907f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16906370a0823190602401602060405180830381865afa15801561018e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101b29190610b00565b10156101ea576040517fbb55fd2700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61022b73ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001633836104b5565b604051819033907fc2c3f06e49b9f15e7b4af9055e183b0d73362e033ad82a07dec9bf984017171990600090a350565b60008061026a83850185610b19565b600081815260016020526040902054919350915060ff16156102c0576040517f91cab504000000000000000000000000000000000000000000000000000000008152600481018290526024015b60405180910390fd5b600081815260016020819052604090912080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016909117905561033b73ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001686846104b5565b505050505050565b6040517f23b872dd0000000000000000000000000000000000000000000000000000000081523360048201523060248201526044810184905260609073ffffffffffffffffffffffffffffffffffffffff8816906323b872dd906064016020604051808303816000875af11580156103bf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103e39190610b3b565b506000805481806103f383610b5d565b9190505560405160200161040991815260200190565b604080518083037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe001815291905298975050505050505050565b61048573ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001633308461058e565b604051819033907fc17cea59c2955cb181b03393209566960365771dbba9dc3d510180e7cb31208890600090a350565b60405173ffffffffffffffffffffffffffffffffffffffff83166024820152604481018290526105899084907fa9059cbb00000000000000000000000000000000000000000000000000000000906064015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff00000000000000000000000000000000000000000000000000000000909316929092179091526105f2565b505050565b60405173ffffffffffffffffffffffffffffffffffffffff808516602483015283166044820152606481018290526105ec9085907f23b872dd0000000000000000000000000000000000000000000000000000000090608401610507565b50505050565b6000610654826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff166106fe9092919063ffffffff16565b80519091501561058957808060200190518101906106729190610b3b565b610589576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f7420737563636565640000000000000000000000000000000000000000000060648201526084016102b7565b606061070d8484600085610715565b949350505050565b6060824710156107a7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c000000000000000000000000000000000000000000000000000060648201526084016102b7565b6000808673ffffffffffffffffffffffffffffffffffffffff1685876040516107d09190610bbc565b60006040518083038185875af1925050503d806000811461080d576040519150601f19603f3d011682016040523d82523d6000602084013e610812565b606091505b50915091506108238783838761082e565b979650505050505050565b606083156108c45782516000036108bd5773ffffffffffffffffffffffffffffffffffffffff85163b6108bd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016102b7565b508161070d565b61070d83838151156108d95781518083602001fd5b806040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102b79190610ae6565b60006020828403121561091f57600080fd5b5035919050565b803573ffffffffffffffffffffffffffffffffffffffff8116811461094a57600080fd5b919050565b60008083601f84011261096157600080fd5b50813567ffffffffffffffff81111561097957600080fd5b60208301915083602082850101111561099157600080fd5b9250929050565b600080600080606085870312156109ae57600080fd5b6109b785610926565b93506109c560208601610926565b9250604085013567ffffffffffffffff8111156109e157600080fd5b6109ed8782880161094f565b95989497509550505050565b60008060008060008060a08789031215610a1257600080fd5b610a1b87610926565b9550610a2960208801610926565b9450610a3760408801610926565b935060608701359250608087013567ffffffffffffffff811115610a5a57600080fd5b610a6689828a0161094f565b979a9699509497509295939492505050565b60005b83811015610a93578181015183820152602001610a7b565b50506000910152565b60008151808452610ab4816020860160208601610a78565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b602081526000610af96020830184610a9c565b9392505050565b600060208284031215610b1257600080fd5b5051919050565b60008060408385031215610b2c57600080fd5b50508035926020909101359150565b600060208284031215610b4d57600080fd5b81518015158114610af957600080fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203610bb5577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b5060010190565b60008251610bce818460208701610a78565b919091019291505056fea164736f6c6343000813000a", + ABI: "[{\"inputs\":[{\"internalType\":\"contractIERC20\",\"name\":\"token\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"holdNative\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"BridgeAddressCannotBeZero\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"wanted\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"got\",\"type\":\"uint256\"}],\"name\":\"InsufficientEthValue\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InsufficientLiquidity\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidFinalizationAction\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"MsgShouldNotContainValue\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"msgValue\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"MsgValueDoesNotMatchAmount\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NativeSendFailed\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"}],\"name\":\"NonceAlreadyUsed\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"}],\"name\":\"NonceNotProven\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"provider\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"LiquidityAdded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"provider\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"LiquidityRemoved\",\"type\":\"event\"},{\"inputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"internalType\":\"structMockL1BridgeAdapter.FinalizePayload\",\"name\":\"payload\",\"type\":\"tuple\"}],\"name\":\"encodeFinalizePayload\",\"outputs\":[],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"enumMockL1BridgeAdapter.FinalizationAction\",\"name\":\"action\",\"type\":\"uint8\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"internalType\":\"structMockL1BridgeAdapter.Payload\",\"name\":\"payload\",\"type\":\"tuple\"}],\"name\":\"encodePayload\",\"outputs\":[],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"}],\"internalType\":\"structMockL1BridgeAdapter.ProvePayload\",\"name\":\"payload\",\"type\":\"tuple\"}],\"name\":\"encodeProvePayload\",\"outputs\":[],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"localReceiver\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"bridgeSpecificPayload\",\"type\":\"bytes\"}],\"name\":\"finalizeWithdrawERC20\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getBridgeFeeInNative\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"provideLiquidity\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"localToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"name\":\"sendERC20\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"withdrawLiquidity\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}]", + Bin: "0x60c0604052600160005534801561001557600080fd5b5060405161126f38038061126f8339810160408190526100349161004c565b6001600160a01b03909116608052151560a052610097565b6000806040838503121561005f57600080fd5b82516001600160a01b038116811461007657600080fd5b6020840151909250801515811461008c57600080fd5b809150509250929050565b60805160a0516111906100df6000396000818161042801526109cf0152600081816101c2015281816102940152818161047b015281816105660152610aa701526111906000f3fe60806040526004361061007f5760003560e01c8063a71d98b71161004e578063a71d98b71461011c578063aee0c3881461013c578063eb521a4c14610157578063f19e1eb61461017757600080fd5b80630a861f2a1461008b5780632e4b1fc9146100ad578063331e5ff0146100ce57806338314bb2146100ec57600080fd5b3661008657005b600080fd5b34801561009757600080fd5b506100ab6100a6366004610c43565b610192565b005b3480156100b957600080fd5b50604051600081526020015b60405180910390f35b3480156100da57600080fd5b506100ab6100e9366004610d26565b50565b3480156100f857600080fd5b5061010c610107366004610e8a565b6102eb565b60405190151581526020016100c5565b61012f61012a366004610eeb565b610385565b6040516100c59190610fd8565b34801561014857600080fd5b506100ab6100e9366004610ff2565b34801561016357600080fd5b506100ab610172366004610c43565b61054c565b34801561018357600080fd5b506100ab6100e9366004611024565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015281907f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16906370a0823190602401602060405180830381865afa15801561021e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102429190611048565b101561027a576040517fbb55fd2700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6102bb73ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001633836105be565b604051819033907fc2c3f06e49b9f15e7b4af9055e183b0d73362e033ad82a07dec9bf984017171990600090a350565b6000806102fa83850185610d26565b905060008151600181111561031157610311611061565b036103275761031f81610697565b91505061037d565b60018151600181111561033c5761033c611061565b0361034b5761031f818661074b565b6040517fee2ef09800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b949350505050565b6040517f23b872dd0000000000000000000000000000000000000000000000000000000081523360048201523060248201526044810184905260609073ffffffffffffffffffffffffffffffffffffffff8816906323b872dd906064016020604051808303816000875af1158015610401573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104259190611090565b507f0000000000000000000000000000000000000000000000000000000000000000156104ed576040517f2e1a7d4d000000000000000000000000000000000000000000000000000000008152600481018590527f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1690632e1a7d4d90602401600060405180830381600087803b1580156104d457600080fd5b505af11580156104e8573d6000803e3d6000fd5b505050505b6000805481806104fc836110b2565b9190505560405160200161051291815260200190565b604080518083037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe001815291905298975050505050505050565b61058e73ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001633308461085d565b604051819033907fc17cea59c2955cb181b03393209566960365771dbba9dc3d510180e7cb31208890600090a350565b60405173ffffffffffffffffffffffffffffffffffffffff83166024820152604481018290526106929084907fa9059cbb00000000000000000000000000000000000000000000000000000000906064015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff00000000000000000000000000000000000000000000000000000000909316929092179091526108c1565b505050565b60008082602001518060200190518101906106b29190611111565b805160009081526001602052604090205490915060ff161561070b5780516040517f91cab50400000000000000000000000000000000000000000000000000000000815260048101919091526024015b60405180910390fd5b516000908152600160208190526040822080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016909117905592915050565b60008083602001518060200190518101906107669190611135565b805160009081526001602052604090205490915060ff166107b95780516040517f974f61110000000000000000000000000000000000000000000000000000000081526004810191909152602401610702565b805160009081526002602052604090205460ff161561080a5780516040517f91cab5040000000000000000000000000000000000000000000000000000000081526004810191909152602401610702565b8051600090815260026020908152604090912080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600117905581015161085390846109cd565b5060019392505050565b60405173ffffffffffffffffffffffffffffffffffffffff808516602483015283166044820152606481018290526108bb9085907f23b872dd0000000000000000000000000000000000000000000000000000000090608401610610565b50505050565b6000610923826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff16610ad29092919063ffffffff16565b80519091501561069257808060200190518101906109419190611090565b610692576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401610702565b7f000000000000000000000000000000000000000000000000000000000000000015610a8d5760008173ffffffffffffffffffffffffffffffffffffffff168360405160006040518083038185875af1925050503d8060008114610a4d576040519150601f19603f3d011682016040523d82523d6000602084013e610a52565b606091505b5050905080610692576040517fa0c968e700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610ace73ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001682846105be565b5050565b606061037d8484600085856000808673ffffffffffffffffffffffffffffffffffffffff168587604051610b069190611167565b60006040518083038185875af1925050503d8060008114610b43576040519150601f19603f3d011682016040523d82523d6000602084013e610b48565b606091505b5091509150610b5987838387610b64565b979650505050505050565b60608315610bfa578251600003610bf35773ffffffffffffffffffffffffffffffffffffffff85163b610bf3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610702565b508161037d565b61037d8383815115610c0f5781518083602001fd5b806040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107029190610fd8565b600060208284031215610c5557600080fd5b5035919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040805190810167ffffffffffffffff81118282101715610cae57610cae610c5c565b60405290565b6040516020810167ffffffffffffffff81118282101715610cae57610cae610c5c565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff81118282101715610d1e57610d1e610c5c565b604052919050565b60006020808385031215610d3957600080fd5b823567ffffffffffffffff80821115610d5157600080fd5b9084019060408287031215610d6557600080fd5b610d6d610c8b565b823560028110610d7c57600080fd5b81528284013582811115610d8f57600080fd5b80840193505086601f840112610da457600080fd5b823582811115610db657610db6610c5c565b610de6857fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f84011601610cd7565b92508083528785828601011115610dfc57600080fd5b8085850186850137600090830185015292830152509392505050565b803573ffffffffffffffffffffffffffffffffffffffff81168114610e3c57600080fd5b919050565b60008083601f840112610e5357600080fd5b50813567ffffffffffffffff811115610e6b57600080fd5b602083019150836020828501011115610e8357600080fd5b9250929050565b60008060008060608587031215610ea057600080fd5b610ea985610e18565b9350610eb760208601610e18565b9250604085013567ffffffffffffffff811115610ed357600080fd5b610edf87828801610e41565b95989497509550505050565b60008060008060008060a08789031215610f0457600080fd5b610f0d87610e18565b9550610f1b60208801610e18565b9450610f2960408801610e18565b935060608701359250608087013567ffffffffffffffff811115610f4c57600080fd5b610f5889828a01610e41565b979a9699509497509295939492505050565b60005b83811015610f85578181015183820152602001610f6d565b50506000910152565b60008151808452610fa6816020860160208601610f6a565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b602081526000610feb6020830184610f8e565b9392505050565b60006040828403121561100457600080fd5b61100c610c8b565b82358152602083013560208201528091505092915050565b60006020828403121561103657600080fd5b61103e610cb4565b9135825250919050565b60006020828403121561105a57600080fd5b5051919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b6000602082840312156110a257600080fd5b81518015158114610feb57600080fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820361110a577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b5060010190565b60006020828403121561112357600080fd5b61112b610cb4565b9151825250919050565b60006040828403121561114757600080fd5b61114f610c8b565b82518152602083015160208201528091505092915050565b60008251611179818460208701610f6a565b919091019291505056fea164736f6c6343000813000a", } var MockL1BridgeAdapterABI = MockL1BridgeAdapterMetaData.ABI var MockL1BridgeAdapterBin = MockL1BridgeAdapterMetaData.Bin -func DeployMockL1BridgeAdapter(auth *bind.TransactOpts, backend bind.ContractBackend, token common.Address) (common.Address, *types.Transaction, *MockL1BridgeAdapter, error) { +func DeployMockL1BridgeAdapter(auth *bind.TransactOpts, backend bind.ContractBackend, token common.Address, holdNative bool) (common.Address, *types.Transaction, *MockL1BridgeAdapter, error) { parsed, err := MockL1BridgeAdapterMetaData.GetAbi() if err != nil { return common.Address{}, nil, nil, err @@ -48,7 +62,7 @@ func DeployMockL1BridgeAdapter(auth *bind.TransactOpts, backend bind.ContractBac return common.Address{}, nil, nil, errors.New("GetABI returned nil") } - address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex(MockL1BridgeAdapterBin), backend, token) + address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex(MockL1BridgeAdapterBin), backend, token, holdNative) if err != nil { return common.Address{}, nil, nil, err } @@ -171,6 +185,66 @@ func (_MockL1BridgeAdapter *MockL1BridgeAdapterTransactorRaw) Transact(opts *bin return _MockL1BridgeAdapter.Contract.contract.Transact(opts, method, params...) } +func (_MockL1BridgeAdapter *MockL1BridgeAdapterCaller) EncodeFinalizePayload(opts *bind.CallOpts, payload MockL1BridgeAdapterFinalizePayload) error { + var out []interface{} + err := _MockL1BridgeAdapter.contract.Call(opts, &out, "encodeFinalizePayload", payload) + + if err != nil { + return err + } + + return err + +} + +func (_MockL1BridgeAdapter *MockL1BridgeAdapterSession) EncodeFinalizePayload(payload MockL1BridgeAdapterFinalizePayload) error { + return _MockL1BridgeAdapter.Contract.EncodeFinalizePayload(&_MockL1BridgeAdapter.CallOpts, payload) +} + +func (_MockL1BridgeAdapter *MockL1BridgeAdapterCallerSession) EncodeFinalizePayload(payload MockL1BridgeAdapterFinalizePayload) error { + return _MockL1BridgeAdapter.Contract.EncodeFinalizePayload(&_MockL1BridgeAdapter.CallOpts, payload) +} + +func (_MockL1BridgeAdapter *MockL1BridgeAdapterCaller) EncodePayload(opts *bind.CallOpts, payload MockL1BridgeAdapterPayload) error { + var out []interface{} + err := _MockL1BridgeAdapter.contract.Call(opts, &out, "encodePayload", payload) + + if err != nil { + return err + } + + return err + +} + +func (_MockL1BridgeAdapter *MockL1BridgeAdapterSession) EncodePayload(payload MockL1BridgeAdapterPayload) error { + return _MockL1BridgeAdapter.Contract.EncodePayload(&_MockL1BridgeAdapter.CallOpts, payload) +} + +func (_MockL1BridgeAdapter *MockL1BridgeAdapterCallerSession) EncodePayload(payload MockL1BridgeAdapterPayload) error { + return _MockL1BridgeAdapter.Contract.EncodePayload(&_MockL1BridgeAdapter.CallOpts, payload) +} + +func (_MockL1BridgeAdapter *MockL1BridgeAdapterCaller) EncodeProvePayload(opts *bind.CallOpts, payload MockL1BridgeAdapterProvePayload) error { + var out []interface{} + err := _MockL1BridgeAdapter.contract.Call(opts, &out, "encodeProvePayload", payload) + + if err != nil { + return err + } + + return err + +} + +func (_MockL1BridgeAdapter *MockL1BridgeAdapterSession) EncodeProvePayload(payload MockL1BridgeAdapterProvePayload) error { + return _MockL1BridgeAdapter.Contract.EncodeProvePayload(&_MockL1BridgeAdapter.CallOpts, payload) +} + +func (_MockL1BridgeAdapter *MockL1BridgeAdapterCallerSession) EncodeProvePayload(payload MockL1BridgeAdapterProvePayload) error { + return _MockL1BridgeAdapter.Contract.EncodeProvePayload(&_MockL1BridgeAdapter.CallOpts, payload) +} + func (_MockL1BridgeAdapter *MockL1BridgeAdapterCaller) GetBridgeFeeInNative(opts *bind.CallOpts) (*big.Int, error) { var out []interface{} err := _MockL1BridgeAdapter.contract.Call(opts, &out, "getBridgeFeeInNative") @@ -241,6 +315,18 @@ func (_MockL1BridgeAdapter *MockL1BridgeAdapterTransactorSession) WithdrawLiquid return _MockL1BridgeAdapter.Contract.WithdrawLiquidity(&_MockL1BridgeAdapter.TransactOpts, amount) } +func (_MockL1BridgeAdapter *MockL1BridgeAdapterTransactor) Receive(opts *bind.TransactOpts) (*types.Transaction, error) { + return _MockL1BridgeAdapter.contract.RawTransact(opts, nil) +} + +func (_MockL1BridgeAdapter *MockL1BridgeAdapterSession) Receive() (*types.Transaction, error) { + return _MockL1BridgeAdapter.Contract.Receive(&_MockL1BridgeAdapter.TransactOpts) +} + +func (_MockL1BridgeAdapter *MockL1BridgeAdapterTransactorSession) Receive() (*types.Transaction, error) { + return _MockL1BridgeAdapter.Contract.Receive(&_MockL1BridgeAdapter.TransactOpts) +} + type MockL1BridgeAdapterLiquidityAddedIterator struct { Event *MockL1BridgeAdapterLiquidityAdded @@ -538,6 +624,12 @@ func (_MockL1BridgeAdapter *MockL1BridgeAdapter) Address() common.Address { } type MockL1BridgeAdapterInterface interface { + EncodeFinalizePayload(opts *bind.CallOpts, payload MockL1BridgeAdapterFinalizePayload) error + + EncodePayload(opts *bind.CallOpts, payload MockL1BridgeAdapterPayload) error + + EncodeProvePayload(opts *bind.CallOpts, payload MockL1BridgeAdapterProvePayload) error + GetBridgeFeeInNative(opts *bind.CallOpts) (*big.Int, error) FinalizeWithdrawERC20(opts *bind.TransactOpts, arg0 common.Address, localReceiver common.Address, bridgeSpecificPayload []byte) (*types.Transaction, error) @@ -548,6 +640,8 @@ type MockL1BridgeAdapterInterface interface { WithdrawLiquidity(opts *bind.TransactOpts, amount *big.Int) (*types.Transaction, error) + Receive(opts *bind.TransactOpts) (*types.Transaction, error) + FilterLiquidityAdded(opts *bind.FilterOpts, provider []common.Address, amount []*big.Int) (*MockL1BridgeAdapterLiquidityAddedIterator, error) WatchLiquidityAdded(opts *bind.WatchOpts, sink chan<- *MockL1BridgeAdapterLiquidityAdded, provider []common.Address, amount []*big.Int) (event.Subscription, error) diff --git a/core/gethwrappers/rebalancer/generated/mock_l2_bridge_adapter/mock_l2_bridge_adapter.go b/core/gethwrappers/rebalancer/generated/mock_l2_bridge_adapter/mock_l2_bridge_adapter.go index 45a90488e6..ddec7eeaee 100644 --- a/core/gethwrappers/rebalancer/generated/mock_l2_bridge_adapter/mock_l2_bridge_adapter.go +++ b/core/gethwrappers/rebalancer/generated/mock_l2_bridge_adapter/mock_l2_bridge_adapter.go @@ -29,8 +29,8 @@ var ( ) var MockL2BridgeAdapterMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[],\"name\":\"BridgeAddressCannotBeZero\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"wanted\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"got\",\"type\":\"uint256\"}],\"name\":\"InsufficientEthValue\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"MsgShouldNotContainValue\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"msgValue\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"MsgValueDoesNotMatchAmount\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"name\":\"finalizeWithdrawERC20\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getBridgeFeeInNative\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"localToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"name\":\"sendERC20\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"}]", - Bin: "0x608060405234801561001057600080fd5b5061034c806100206000396000f3fe6080604052600436106100345760003560e01c80632e4b1fc91461003957806338314bb21461005a578063a71d98b71461007d575b600080fd5b34801561004557600080fd5b50604051600081526020015b60405180910390f35b34801561006657600080fd5b5061007b6100753660046101ca565b50505050565b005b61009061008b36600461022b565b61009d565b60405161005191906102aa565b6040517f23b872dd0000000000000000000000000000000000000000000000000000000081523360048201523060248201526044810184905260609073ffffffffffffffffffffffffffffffffffffffff8816906323b872dd906064016020604051808303816000875af1158015610119573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061013d9190610316565b50506040805160208101909152600081529695505050505050565b803573ffffffffffffffffffffffffffffffffffffffff8116811461017c57600080fd5b919050565b60008083601f84011261019357600080fd5b50813567ffffffffffffffff8111156101ab57600080fd5b6020830191508360208285010111156101c357600080fd5b9250929050565b600080600080606085870312156101e057600080fd5b6101e985610158565b93506101f760208601610158565b9250604085013567ffffffffffffffff81111561021357600080fd5b61021f87828801610181565b95989497509550505050565b60008060008060008060a0878903121561024457600080fd5b61024d87610158565b955061025b60208801610158565b945061026960408801610158565b935060608701359250608087013567ffffffffffffffff81111561028c57600080fd5b61029889828a01610181565b979a9699509497509295939492505050565b600060208083528351808285015260005b818110156102d7578581018301518582016040015282016102bb565b5060006040828601015260407fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8301168501019250505092915050565b60006020828403121561032857600080fd5b8151801515811461033857600080fd5b939250505056fea164736f6c6343000813000a", + ABI: "[{\"inputs\":[],\"name\":\"BridgeAddressCannotBeZero\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"wanted\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"got\",\"type\":\"uint256\"}],\"name\":\"InsufficientEthValue\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"MsgShouldNotContainValue\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"msgValue\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"MsgValueDoesNotMatchAmount\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"name\":\"finalizeWithdrawERC20\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getBridgeFeeInNative\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"localToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"name\":\"sendERC20\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"}]", + Bin: "0x608060405234801561001057600080fd5b5061035e806100206000396000f3fe6080604052600436106100345760003560e01c80632e4b1fc91461003957806338314bb21461005a578063a71d98b71461008f575b600080fd5b34801561004557600080fd5b50604051600081526020015b60405180910390f35b34801561006657600080fd5b5061007f6100753660046101dc565b6001949350505050565b6040519015158152602001610051565b6100a261009d36600461023d565b6100af565b60405161005191906102bc565b6040517f23b872dd0000000000000000000000000000000000000000000000000000000081523360048201523060248201526044810184905260609073ffffffffffffffffffffffffffffffffffffffff8816906323b872dd906064016020604051808303816000875af115801561012b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061014f9190610328565b50506040805160208101909152600081529695505050505050565b803573ffffffffffffffffffffffffffffffffffffffff8116811461018e57600080fd5b919050565b60008083601f8401126101a557600080fd5b50813567ffffffffffffffff8111156101bd57600080fd5b6020830191508360208285010111156101d557600080fd5b9250929050565b600080600080606085870312156101f257600080fd5b6101fb8561016a565b93506102096020860161016a565b9250604085013567ffffffffffffffff81111561022557600080fd5b61023187828801610193565b95989497509550505050565b60008060008060008060a0878903121561025657600080fd5b61025f8761016a565b955061026d6020880161016a565b945061027b6040880161016a565b935060608701359250608087013567ffffffffffffffff81111561029e57600080fd5b6102aa89828a01610193565b979a9699509497509295939492505050565b600060208083528351808285015260005b818110156102e9578581018301518582016040015282016102cd565b5060006040828601015260407fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8301168501019250505092915050565b60006020828403121561033a57600080fd5b8151801515811461034a57600080fd5b939250505056fea164736f6c6343000813000a", } var MockL2BridgeAdapterABI = MockL2BridgeAdapterMetaData.ABI diff --git a/core/gethwrappers/rebalancer/generated/optimism_l1_bridge_adapter/optimism_l1_bridge_adapter.go b/core/gethwrappers/rebalancer/generated/optimism_l1_bridge_adapter/optimism_l1_bridge_adapter.go index 65b456877d..90472a3ef2 100644 --- a/core/gethwrappers/rebalancer/generated/optimism_l1_bridge_adapter/optimism_l1_bridge_adapter.go +++ b/core/gethwrappers/rebalancer/generated/optimism_l1_bridge_adapter/optimism_l1_bridge_adapter.go @@ -29,8 +29,8 @@ var ( ) var OptimismL1BridgeAdapterMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[{\"internalType\":\"contractIL1StandardBridge\",\"name\":\"l1Bridge\",\"type\":\"address\"},{\"internalType\":\"contractIWrappedNative\",\"name\":\"wrappedNative\",\"type\":\"address\"},{\"internalType\":\"contractIOptimismPortal\",\"name\":\"optimismPortal\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"BridgeAddressCannotBeZero\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"wanted\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"got\",\"type\":\"uint256\"}],\"name\":\"InsufficientEthValue\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidFinalizationAction\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"MsgShouldNotContainValue\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"msgValue\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"MsgValueDoesNotMatchAmount\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"finalizeWithdrawERC20\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getBridgeFeeInNative\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getL1Bridge\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getOptimismPortal\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getWrappedNative\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"localToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"remoteToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"name\":\"sendERC20\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}]", - Bin: "0x60e0604052600080546001600160401b03191690553480156200002157600080fd5b506040516200175e3803806200175e8339810160408190526200004491620000cb565b6001600160a01b03831615806200006257506001600160a01b038216155b806200007557506001600160a01b038116155b156200009457604051635e9c404d60e11b815260040160405180910390fd5b6001600160a01b0392831660805290821660a0521660c0526200011f565b6001600160a01b0381168114620000c857600080fd5b50565b600080600060608486031215620000e157600080fd5b8351620000ee81620000b2565b60208501519093506200010181620000b2565b60408501519092506200011481620000b2565b809150509250925092565b60805160a05160c0516115df6200017f6000396000818160c7015281816105d901526106b301526000818161016e0152818161033401526103b401526000818161013b01528181610460015281816104f5015261055701526115df6000f3fe6080604052600436106100695760003560e01c8063a71d98b711610043578063a71d98b71461010c578063c86d5bdd1461012c578063e861e9071461015f57600080fd5b80632e4b1fc91461007557806338314bb21461009657806354fd969f146100b857600080fd5b3661007057005b600080fd5b34801561008157600080fd5b50604051600081526020015b60405180910390f35b3480156100a257600080fd5b506100b66100b1366004610cd9565b610192565b005b3480156100c457600080fd5b507f00000000000000000000000000000000000000000000000000000000000000005b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200161008d565b61011f61011a366004610d3e565b61025f565b60405161008d9190610e31565b34801561013857600080fd5b507f00000000000000000000000000000000000000000000000000000000000000006100e7565b34801561016b57600080fd5b507f00000000000000000000000000000000000000000000000000000000000000006100e7565b60006101a082840184610f5b565b90506000815160018111156101b7576101b7611021565b036101e757600081602001518060200190518101906101d691906111e3565b90506101e1816105d7565b50610258565b6001815160018111156101fc576101fc611021565b03610226576000816020015180602001905181019061021b91906112e1565b90506101e181610674565b6040517fee2ef09800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5050505050565b606061028373ffffffffffffffffffffffffffffffffffffffff88163330876106e7565b34156102c2576040517f2543d86e0000000000000000000000000000000000000000000000000000000081523460048201526024015b60405180910390fd5b6000805467ffffffffffffffff1681806102db83611364565b91906101000a81548167ffffffffffffffff021916908367ffffffffffffffff160217905550604051602001610321919067ffffffffffffffff91909116815260200190565b60405160208183030381529060405290507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff16036104d9576040517f2e1a7d4d000000000000000000000000000000000000000000000000000000008152600481018690527f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1690632e1a7d4d90602401600060405180830381600087803b15801561040d57600080fd5b505af1158015610421573d6000803e3d6000fd5b50506040517f9a2ac6d500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000169250639a2ac6d59150879061049e908a9060009087906004016113b2565b6000604051808303818588803b1580156104b757600080fd5b505af11580156104cb573d6000803e3d6000fd5b5050505050809150506105cd565b61051a73ffffffffffffffffffffffffffffffffffffffff89167f0000000000000000000000000000000000000000000000000000000000000000876107c9565b6040517f838b252000000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000169063838b252090610597908b908b908b908b9060009089906004016113f6565b600060405180830381600087803b1580156105b157600080fd5b505af11580156105c5573d6000803e3d6000fd5b509293505050505b9695505050505050565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16634870496f82600001518360200151846040015185606001516040518563ffffffff1660e01b815260040161064694939291906114ac565b600060405180830381600087803b15801561066057600080fd5b505af1158015610258573d6000803e3d6000fd5b80516040517f8c3152e900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001691638c3152e9916106469190600401611568565b60405173ffffffffffffffffffffffffffffffffffffffff808516602483015283166044820152606481018290526107c39085907f23b872dd00000000000000000000000000000000000000000000000000000000906084015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152610950565b50505050565b80158061086957506040517fdd62ed3e00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff838116602483015284169063dd62ed3e90604401602060405180830381865afa158015610843573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610867919061157b565b155b6108f5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527f20746f206e6f6e2d7a65726f20616c6c6f77616e63650000000000000000000060648201526084016102b9565b60405173ffffffffffffffffffffffffffffffffffffffff831660248201526044810182905261094b9084907f095ea7b30000000000000000000000000000000000000000000000000000000090606401610741565b505050565b60006109b2826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff16610a5c9092919063ffffffff16565b80519091501561094b57808060200190518101906109d09190611594565b61094b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f7420737563636565640000000000000000000000000000000000000000000060648201526084016102b9565b6060610a6b8484600085610a73565b949350505050565b606082471015610b05576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c000000000000000000000000000000000000000000000000000060648201526084016102b9565b6000808673ffffffffffffffffffffffffffffffffffffffff168587604051610b2e91906115b6565b60006040518083038185875af1925050503d8060008114610b6b576040519150601f19603f3d011682016040523d82523d6000602084013e610b70565b606091505b5091509150610b8187838387610b8c565b979650505050505050565b60608315610c22578251600003610c1b5773ffffffffffffffffffffffffffffffffffffffff85163b610c1b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016102b9565b5081610a6b565b610a6b8383815115610c375781518083602001fd5b806040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102b99190610e31565b73ffffffffffffffffffffffffffffffffffffffff81168114610c8d57600080fd5b50565b60008083601f840112610ca257600080fd5b50813567ffffffffffffffff811115610cba57600080fd5b602083019150836020828501011115610cd257600080fd5b9250929050565b60008060008060608587031215610cef57600080fd5b8435610cfa81610c6b565b93506020850135610d0a81610c6b565b9250604085013567ffffffffffffffff811115610d2657600080fd5b610d3287828801610c90565b95989497509550505050565b60008060008060008060a08789031215610d5757600080fd5b8635610d6281610c6b565b95506020870135610d7281610c6b565b94506040870135610d8281610c6b565b935060608701359250608087013567ffffffffffffffff811115610da557600080fd5b610db189828a01610c90565b979a9699509497509295939492505050565b60005b83811015610dde578181015183820152602001610dc6565b50506000910152565b60008151808452610dff816020860160208601610dc3565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b602081526000610e446020830184610de7565b9392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040805190810167ffffffffffffffff81118282101715610e9d57610e9d610e4b565b60405290565b6040516080810167ffffffffffffffff81118282101715610e9d57610e9d610e4b565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff81118282101715610f0d57610f0d610e4b565b604052919050565b600067ffffffffffffffff821115610f2f57610f2f610e4b565b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b60006020808385031215610f6e57600080fd5b823567ffffffffffffffff80821115610f8657600080fd5b9084019060408287031215610f9a57600080fd5b610fa2610e7a565b823560028110610fb157600080fd5b81528284013582811115610fc457600080fd5b80840193505086601f840112610fd957600080fd5b82359150610fee610fe983610f15565b610ec6565b828152878584860101111561100257600080fd5b8285850186830137600092810185019290925292830152509392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b600082601f83011261106157600080fd5b815161106f610fe982610f15565b81815284602083860101111561108457600080fd5b610a6b826020830160208701610dc3565b600060c082840312156110a757600080fd5b60405160c0810167ffffffffffffffff82821081831117156110cb576110cb610e4b565b8160405282935084518352602085015191506110e682610c6b565b816020840152604085015191506110fc82610c6b565b816040840152606085015160608401526080850151608084015260a085015191508082111561112a57600080fd5b5061113785828601611050565b60a0830152505092915050565b600082601f83011261115557600080fd5b8151602067ffffffffffffffff8083111561117257611172610e4b565b8260051b611181838201610ec6565b938452858101830193838101908886111561119b57600080fd5b84880192505b858310156111d7578251848111156111b95760008081fd5b6111c78a87838c0101611050565b83525091840191908401906111a1565b98975050505050505050565b6000602082840312156111f557600080fd5b815167ffffffffffffffff8082111561120d57600080fd5b9083019081850360e081121561122257600080fd5b61122a610ea3565b83518381111561123957600080fd5b61124588828701611095565b8252506020840151602082015260807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc08301121561128257600080fd5b61128a610ea3565b6040858101518252606080870151602084015260808701518284015260a08701519083015282015260c08401519150828211156112c657600080fd5b6112d287838601611144565b60608201529695505050505050565b6000602082840312156112f357600080fd5b815167ffffffffffffffff8082111561130b57600080fd5b908301906020828603121561131f57600080fd5b60405160208101818110838211171561133a5761133a610e4b565b60405282518281111561134c57600080fd5b61135887828601611095565b82525095945050505050565b600067ffffffffffffffff8083168181036113a8577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6001019392505050565b73ffffffffffffffffffffffffffffffffffffffff8416815263ffffffff831660208201526060604082015260006113ed6060830184610de7565b95945050505050565b600073ffffffffffffffffffffffffffffffffffffffff8089168352808816602084015280871660408401525084606083015263ffffffff8416608083015260c060a08301526111d760c0830184610de7565b805182526000602082015173ffffffffffffffffffffffffffffffffffffffff80821660208601528060408501511660408601525050606082015160608401526080820151608084015260a082015160c060a0850152610a6b60c0850182610de7565b60e0815260006114bf60e0830187611449565b602086818501528551604085015280860151606085015260408601516080850152606086015160a085015283820360c08501528185518084528284019150828160051b85010183880160005b83811015611557577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0878403018552611545838351610de7565b9486019492509085019060010161150b565b50909b9a5050505050505050505050565b602081526000610e446020830184611449565b60006020828403121561158d57600080fd5b5051919050565b6000602082840312156115a657600080fd5b81518015158114610e4457600080fd5b600082516115c8818460208701610dc3565b919091019291505056fea164736f6c6343000813000a", + ABI: "[{\"inputs\":[{\"internalType\":\"contractIL1StandardBridge\",\"name\":\"l1Bridge\",\"type\":\"address\"},{\"internalType\":\"contractIWrappedNative\",\"name\":\"wrappedNative\",\"type\":\"address\"},{\"internalType\":\"contractIOptimismPortal\",\"name\":\"optimismPortal\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"BridgeAddressCannotBeZero\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"wanted\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"got\",\"type\":\"uint256\"}],\"name\":\"InsufficientEthValue\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidFinalizationAction\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"MsgShouldNotContainValue\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"msgValue\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"MsgValueDoesNotMatchAmount\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"finalizeWithdrawERC20\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getBridgeFeeInNative\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getL1Bridge\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getOptimismPortal\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getWrappedNative\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"localToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"remoteToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"name\":\"sendERC20\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}]", + Bin: "0x60e0604052600080546001600160401b03191690553480156200002157600080fd5b50604051620016e7380380620016e78339810160408190526200004491620000cb565b6001600160a01b03831615806200006257506001600160a01b038216155b806200007557506001600160a01b038116155b156200009457604051635e9c404d60e11b815260040160405180910390fd5b6001600160a01b0392831660805290821660a0521660c0526200011f565b6001600160a01b0381168114620000c857600080fd5b50565b600080600060608486031215620000e157600080fd5b8351620000ee81620000b2565b60208501519093506200010181620000b2565b60408501519092506200011481620000b2565b809150509250925092565b60805160a05160c0516115686200017f6000396000818160d5015281816105f901526106da01526000818161017c0152818161035401526103d40152600081816101490152818161048001528181610515015261057701526115686000f3fe6080604052600436106100695760003560e01c8063a71d98b711610043578063a71d98b71461011a578063c86d5bdd1461013a578063e861e9071461016d57600080fd5b80632e4b1fc91461007557806338314bb21461009657806354fd969f146100c657600080fd5b3661007057005b600080fd5b34801561008157600080fd5b50604051600081526020015b60405180910390f35b3480156100a257600080fd5b506100b66100b1366004610c62565b6101a0565b604051901515815260200161008d565b3480156100d257600080fd5b507f00000000000000000000000000000000000000000000000000000000000000005b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200161008d565b61012d610128366004610cc7565b61027f565b60405161008d9190610dba565b34801561014657600080fd5b507f00000000000000000000000000000000000000000000000000000000000000006100f5565b34801561017957600080fd5b507f00000000000000000000000000000000000000000000000000000000000000006100f5565b6000806101af83850185610ee4565b90506000815160018111156101c6576101c6610faa565b036101fb57600081602001518060200190518101906101e5919061116c565b90506101f0816105f7565b600092505050610277565b60018151600181111561021057610210610faa565b03610245576000816020015180602001905181019061022f919061126a565b905061023a8161069b565b600192505050610277565b6040517fee2ef09800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b949350505050565b60606102a373ffffffffffffffffffffffffffffffffffffffff881633308761070e565b34156102e2576040517f2543d86e0000000000000000000000000000000000000000000000000000000081523460048201526024015b60405180910390fd5b6000805467ffffffffffffffff1681806102fb836112ed565b91906101000a81548167ffffffffffffffff021916908367ffffffffffffffff160217905550604051602001610341919067ffffffffffffffff91909116815260200190565b60405160208183030381529060405290507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff16036104f9576040517f2e1a7d4d000000000000000000000000000000000000000000000000000000008152600481018690527f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1690632e1a7d4d90602401600060405180830381600087803b15801561042d57600080fd5b505af1158015610441573d6000803e3d6000fd5b50506040517f9a2ac6d500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000169250639a2ac6d5915087906104be908a90600090879060040161133b565b6000604051808303818588803b1580156104d757600080fd5b505af11580156104eb573d6000803e3d6000fd5b5050505050809150506105ed565b61053a73ffffffffffffffffffffffffffffffffffffffff89167f0000000000000000000000000000000000000000000000000000000000000000876107f0565b6040517f838b252000000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000169063838b2520906105b7908b908b908b908b90600090899060040161137f565b600060405180830381600087803b1580156105d157600080fd5b505af11580156105e5573d6000803e3d6000fd5b509293505050505b9695505050505050565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16634870496f82600001518360200151846040015185606001516040518563ffffffff1660e01b81526004016106669493929190611435565b600060405180830381600087803b15801561068057600080fd5b505af1158015610694573d6000803e3d6000fd5b5050505050565b80516040517f8c3152e900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001691638c3152e99161066691906004016114f1565b60405173ffffffffffffffffffffffffffffffffffffffff808516602483015283166044820152606481018290526107ea9085907f23b872dd00000000000000000000000000000000000000000000000000000000906084015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152610977565b50505050565b80158061089057506040517fdd62ed3e00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff838116602483015284169063dd62ed3e90604401602060405180830381865afa15801561086a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061088e9190611504565b155b61091c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527f20746f206e6f6e2d7a65726f20616c6c6f77616e63650000000000000000000060648201526084016102d9565b60405173ffffffffffffffffffffffffffffffffffffffff83166024820152604481018290526109729084907f095ea7b30000000000000000000000000000000000000000000000000000000090606401610768565b505050565b60006109d9826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff16610a839092919063ffffffff16565b80519091501561097257808060200190518101906109f7919061151d565b610972576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f7420737563636565640000000000000000000000000000000000000000000060648201526084016102d9565b60606102778484600085856000808673ffffffffffffffffffffffffffffffffffffffff168587604051610ab7919061153f565b60006040518083038185875af1925050503d8060008114610af4576040519150601f19603f3d011682016040523d82523d6000602084013e610af9565b606091505b5091509150610b0a87838387610b15565b979650505050505050565b60608315610bab578251600003610ba45773ffffffffffffffffffffffffffffffffffffffff85163b610ba4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016102d9565b5081610277565b6102778383815115610bc05781518083602001fd5b806040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102d99190610dba565b73ffffffffffffffffffffffffffffffffffffffff81168114610c1657600080fd5b50565b60008083601f840112610c2b57600080fd5b50813567ffffffffffffffff811115610c4357600080fd5b602083019150836020828501011115610c5b57600080fd5b9250929050565b60008060008060608587031215610c7857600080fd5b8435610c8381610bf4565b93506020850135610c9381610bf4565b9250604085013567ffffffffffffffff811115610caf57600080fd5b610cbb87828801610c19565b95989497509550505050565b60008060008060008060a08789031215610ce057600080fd5b8635610ceb81610bf4565b95506020870135610cfb81610bf4565b94506040870135610d0b81610bf4565b935060608701359250608087013567ffffffffffffffff811115610d2e57600080fd5b610d3a89828a01610c19565b979a9699509497509295939492505050565b60005b83811015610d67578181015183820152602001610d4f565b50506000910152565b60008151808452610d88816020860160208601610d4c565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b602081526000610dcd6020830184610d70565b9392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040805190810167ffffffffffffffff81118282101715610e2657610e26610dd4565b60405290565b6040516080810167ffffffffffffffff81118282101715610e2657610e26610dd4565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff81118282101715610e9657610e96610dd4565b604052919050565b600067ffffffffffffffff821115610eb857610eb8610dd4565b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b60006020808385031215610ef757600080fd5b823567ffffffffffffffff80821115610f0f57600080fd5b9084019060408287031215610f2357600080fd5b610f2b610e03565b823560028110610f3a57600080fd5b81528284013582811115610f4d57600080fd5b80840193505086601f840112610f6257600080fd5b82359150610f77610f7283610e9e565b610e4f565b8281528785848601011115610f8b57600080fd5b8285850186830137600092810185019290925292830152509392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b600082601f830112610fea57600080fd5b8151610ff8610f7282610e9e565b81815284602083860101111561100d57600080fd5b610277826020830160208701610d4c565b600060c0828403121561103057600080fd5b60405160c0810167ffffffffffffffff828210818311171561105457611054610dd4565b81604052829350845183526020850151915061106f82610bf4565b8160208401526040850151915061108582610bf4565b816040840152606085015160608401526080850151608084015260a08501519150808211156110b357600080fd5b506110c085828601610fd9565b60a0830152505092915050565b600082601f8301126110de57600080fd5b8151602067ffffffffffffffff808311156110fb576110fb610dd4565b8260051b61110a838201610e4f565b938452858101830193838101908886111561112457600080fd5b84880192505b85831015611160578251848111156111425760008081fd5b6111508a87838c0101610fd9565b835250918401919084019061112a565b98975050505050505050565b60006020828403121561117e57600080fd5b815167ffffffffffffffff8082111561119657600080fd5b9083019081850360e08112156111ab57600080fd5b6111b3610e2c565b8351838111156111c257600080fd5b6111ce8882870161101e565b8252506020840151602082015260807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc08301121561120b57600080fd5b611213610e2c565b6040858101518252606080870151602084015260808701518284015260a08701519083015282015260c084015191508282111561124f57600080fd5b61125b878386016110cd565b60608201529695505050505050565b60006020828403121561127c57600080fd5b815167ffffffffffffffff8082111561129457600080fd5b90830190602082860312156112a857600080fd5b6040516020810181811083821117156112c3576112c3610dd4565b6040528251828111156112d557600080fd5b6112e18782860161101e565b82525095945050505050565b600067ffffffffffffffff808316818103611331577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6001019392505050565b73ffffffffffffffffffffffffffffffffffffffff8416815263ffffffff831660208201526060604082015260006113766060830184610d70565b95945050505050565b600073ffffffffffffffffffffffffffffffffffffffff8089168352808816602084015280871660408401525084606083015263ffffffff8416608083015260c060a083015261116060c0830184610d70565b805182526000602082015173ffffffffffffffffffffffffffffffffffffffff80821660208601528060408501511660408601525050606082015160608401526080820151608084015260a082015160c060a085015261027760c0850182610d70565b60e08152600061144860e08301876113d2565b602086818501528551604085015280860151606085015260408601516080850152606086015160a085015283820360c08501528185518084528284019150828160051b85010183880160005b838110156114e0577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08784030185526114ce838351610d70565b94860194925090850190600101611494565b50909b9a5050505050505050505050565b602081526000610dcd60208301846113d2565b60006020828403121561151657600080fd5b5051919050565b60006020828403121561152f57600080fd5b81518015158114610dcd57600080fd5b60008251611551818460208701610d4c565b919091019291505056fea164736f6c6343000813000a", } var OptimismL1BridgeAdapterABI = OptimismL1BridgeAdapterMetaData.ABI diff --git a/core/gethwrappers/rebalancer/generated/optimism_l2_bridge_adapter/optimism_l2_bridge_adapter.go b/core/gethwrappers/rebalancer/generated/optimism_l2_bridge_adapter/optimism_l2_bridge_adapter.go index 43e85f794d..dc259bef7f 100644 --- a/core/gethwrappers/rebalancer/generated/optimism_l2_bridge_adapter/optimism_l2_bridge_adapter.go +++ b/core/gethwrappers/rebalancer/generated/optimism_l2_bridge_adapter/optimism_l2_bridge_adapter.go @@ -29,8 +29,8 @@ var ( ) var OptimismL2BridgeAdapterMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[{\"internalType\":\"contractIWrappedNative\",\"name\":\"wrappedNative\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"BridgeAddressCannotBeZero\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"wanted\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"got\",\"type\":\"uint256\"}],\"name\":\"InsufficientEthValue\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"MsgShouldNotContainValue\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"msgValue\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"MsgValueDoesNotMatchAmount\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"name\":\"finalizeWithdrawERC20\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getBridgeFeeInNative\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getL2Bridge\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getWrappedNative\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"localToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"name\":\"sendERC20\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}]", - Bin: "0x60c0604052734200000000000000000000000000000000000010608052600080546001600160401b031916905534801561003857600080fd5b50604051610c8a380380610c8a83398101604081905261005791610068565b6001600160a01b031660a052610098565b60006020828403121561007a57600080fd5b81516001600160a01b038116811461009157600080fd5b9392505050565b60805160a051610bab6100df600039600081816101310152818161022a01526102aa015260008181609a015281816103560152818161042401526104de0152610bab6000f3fe60806040526004361061005e5760003560e01c806338314bb21161004357806338314bb2146100df578063a71d98b714610102578063e861e9071461012257600080fd5b80632e4b1fc91461006a5780633429072c1461008b57600080fd5b3661006557005b600080fd5b34801561007657600080fd5b50604051600081526020015b60405180910390f35b34801561009757600080fd5b507f00000000000000000000000000000000000000000000000000000000000000005b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610082565b3480156100eb57600080fd5b506101006100fa36600461095f565b50505050565b005b6101156101103660046109c0565b610155565b6040516100829190610aad565b34801561012e57600080fd5b507f00000000000000000000000000000000000000000000000000000000000000006100ba565b60603415610196576040517f2543d86e0000000000000000000000000000000000000000000000000000000081523460048201526024015b60405180910390fd5b6101b873ffffffffffffffffffffffffffffffffffffffff881633308761055c565b6000805467ffffffffffffffff1681806101d183610ac7565b91906101000a81548167ffffffffffffffff021916908367ffffffffffffffff160217905550604051602001610217919067ffffffffffffffff91909116815260200190565b60405160208183030381529060405290507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff16036103e7576040517f2e1a7d4d000000000000000000000000000000000000000000000000000000008152600481018690527f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1690632e1a7d4d90602401600060405180830381600087803b15801561030357600080fd5b505af1158015610317573d6000803e3d6000fd5b50506040517fa3a7954800000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016925063a3a79548915087906103ac9073deaddeaddeaddeaddeaddeaddeaddeaddead0000908b9084906000908990600401610b15565b6000604051808303818588803b1580156103c557600080fd5b505af11580156103d9573d6000803e3d6000fd5b505050505080915050610552565b6040517f095ea7b300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000811660048301526024820187905289169063095ea7b3906044016020604051808303816000875af115801561047c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104a09190610b60565b506040517fa3a7954800000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000169063a3a795489061051c908b908a908a906000908890600401610b15565b600060405180830381600087803b15801561053657600080fd5b505af115801561054a573d6000803e3d6000fd5b509293505050505b9695505050505050565b6040805173ffffffffffffffffffffffffffffffffffffffff8581166024830152848116604483015260648083018590528351808403909101815260849092018352602080830180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f23b872dd0000000000000000000000000000000000000000000000000000000017905283518085019094528084527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564908401526100fa9287929160009161062f9185169084906106de565b8051909150156106d9578080602001905181019061064d9190610b60565b6106d9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f74207375636365656400000000000000000000000000000000000000000000606482015260840161018d565b505050565b60606106ed84846000856106f5565b949350505050565b606082471015610787576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c0000000000000000000000000000000000000000000000000000606482015260840161018d565b6000808673ffffffffffffffffffffffffffffffffffffffff1685876040516107b09190610b82565b60006040518083038185875af1925050503d80600081146107ed576040519150601f19603f3d011682016040523d82523d6000602084013e6107f2565b606091505b50915091506108038783838761080e565b979650505050505050565b606083156108a457825160000361089d5773ffffffffffffffffffffffffffffffffffffffff85163b61089d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161018d565b50816106ed565b6106ed83838151156108b95781518083602001fd5b806040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161018d9190610aad565b803573ffffffffffffffffffffffffffffffffffffffff8116811461091157600080fd5b919050565b60008083601f84011261092857600080fd5b50813567ffffffffffffffff81111561094057600080fd5b60208301915083602082850101111561095857600080fd5b9250929050565b6000806000806060858703121561097557600080fd5b61097e856108ed565b935061098c602086016108ed565b9250604085013567ffffffffffffffff8111156109a857600080fd5b6109b487828801610916565b95989497509550505050565b60008060008060008060a087890312156109d957600080fd5b6109e2876108ed565b95506109f0602088016108ed565b94506109fe604088016108ed565b935060608701359250608087013567ffffffffffffffff811115610a2157600080fd5b610a2d89828a01610916565b979a9699509497509295939492505050565b60005b83811015610a5a578181015183820152602001610a42565b50506000910152565b60008151808452610a7b816020860160208601610a3f565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b602081526000610ac06020830184610a63565b9392505050565b600067ffffffffffffffff808316818103610b0b577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6001019392505050565b600073ffffffffffffffffffffffffffffffffffffffff808816835280871660208401525084604083015263ffffffff8416606083015260a0608083015261080360a0830184610a63565b600060208284031215610b7257600080fd5b81518015158114610ac057600080fd5b60008251610b94818460208701610a3f565b919091019291505056fea164736f6c6343000813000a", + ABI: "[{\"inputs\":[{\"internalType\":\"contractIWrappedNative\",\"name\":\"wrappedNative\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"BridgeAddressCannotBeZero\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"wanted\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"got\",\"type\":\"uint256\"}],\"name\":\"InsufficientEthValue\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"MsgShouldNotContainValue\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"msgValue\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"MsgValueDoesNotMatchAmount\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"name\":\"finalizeWithdrawERC20\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getBridgeFeeInNative\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getL2Bridge\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getWrappedNative\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"localToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"name\":\"sendERC20\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}]", + Bin: "0x60c0604052734200000000000000000000000000000000000010608052600080546001600160401b031916905534801561003857600080fd5b50604051610c2e380380610c2e83398101604081905261005791610068565b6001600160a01b031660a052610098565b60006020828403121561007a57600080fd5b81516001600160a01b038116811461009157600080fd5b9392505050565b60805160a051610b4f6100df6000396000818161013e0152818161024201526102c2015260008181609a0152818161036e0152818161043c01526104f60152610b4f6000f3fe60806040526004361061005e5760003560e01c806338314bb21161004357806338314bb2146100df578063a71d98b71461010f578063e861e9071461012f57600080fd5b80632e4b1fc91461006a5780633429072c1461008b57600080fd5b3661006557005b600080fd5b34801561007657600080fd5b50604051600081526020015b60405180910390f35b34801561009757600080fd5b507f00000000000000000000000000000000000000000000000000000000000000005b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610082565b3480156100eb57600080fd5b506100ff6100fa366004610903565b610162565b6040519015158152602001610082565b61012261011d366004610964565b61016d565b6040516100829190610a51565b34801561013b57600080fd5b507f00000000000000000000000000000000000000000000000000000000000000006100ba565b60015b949350505050565b606034156101ae576040517f2543d86e0000000000000000000000000000000000000000000000000000000081523460048201526024015b60405180910390fd5b6101d073ffffffffffffffffffffffffffffffffffffffff8816333087610574565b6000805467ffffffffffffffff1681806101e983610a6b565b91906101000a81548167ffffffffffffffff021916908367ffffffffffffffff16021790555060405160200161022f919067ffffffffffffffff91909116815260200190565b60405160208183030381529060405290507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff16036103ff576040517f2e1a7d4d000000000000000000000000000000000000000000000000000000008152600481018690527f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1690632e1a7d4d90602401600060405180830381600087803b15801561031b57600080fd5b505af115801561032f573d6000803e3d6000fd5b50506040517fa3a7954800000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016925063a3a79548915087906103c49073deaddeaddeaddeaddeaddeaddeaddeaddead0000908b9084906000908990600401610ab9565b6000604051808303818588803b1580156103dd57600080fd5b505af11580156103f1573d6000803e3d6000fd5b50505050508091505061056a565b6040517f095ea7b300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000811660048301526024820187905289169063095ea7b3906044016020604051808303816000875af1158015610494573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104b89190610b04565b506040517fa3a7954800000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000169063a3a7954890610534908b908a908a906000908890600401610ab9565b600060405180830381600087803b15801561054e57600080fd5b505af1158015610562573d6000803e3d6000fd5b509293505050505b9695505050505050565b6040805173ffffffffffffffffffffffffffffffffffffffff85811660248301528416604482015260648082018490528251808303909101815260849091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f23b872dd0000000000000000000000000000000000000000000000000000000017905261060990859061060f565b50505050565b6000610671826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff166107209092919063ffffffff16565b80519091501561071b578080602001905181019061068f9190610b04565b61071b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f7420737563636565640000000000000000000000000000000000000000000060648201526084016101a5565b505050565b60606101658484600085856000808673ffffffffffffffffffffffffffffffffffffffff1685876040516107549190610b26565b60006040518083038185875af1925050503d8060008114610791576040519150601f19603f3d011682016040523d82523d6000602084013e610796565b606091505b50915091506107a7878383876107b2565b979650505050505050565b606083156108485782516000036108415773ffffffffffffffffffffffffffffffffffffffff85163b610841576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016101a5565b5081610165565b610165838381511561085d5781518083602001fd5b806040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016101a59190610a51565b803573ffffffffffffffffffffffffffffffffffffffff811681146108b557600080fd5b919050565b60008083601f8401126108cc57600080fd5b50813567ffffffffffffffff8111156108e457600080fd5b6020830191508360208285010111156108fc57600080fd5b9250929050565b6000806000806060858703121561091957600080fd5b61092285610891565b935061093060208601610891565b9250604085013567ffffffffffffffff81111561094c57600080fd5b610958878288016108ba565b95989497509550505050565b60008060008060008060a0878903121561097d57600080fd5b61098687610891565b955061099460208801610891565b94506109a260408801610891565b935060608701359250608087013567ffffffffffffffff8111156109c557600080fd5b6109d189828a016108ba565b979a9699509497509295939492505050565b60005b838110156109fe5781810151838201526020016109e6565b50506000910152565b60008151808452610a1f8160208601602086016109e3565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b602081526000610a646020830184610a07565b9392505050565b600067ffffffffffffffff808316818103610aaf577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6001019392505050565b600073ffffffffffffffffffffffffffffffffffffffff808816835280871660208401525084604083015263ffffffff8416606083015260a060808301526107a760a0830184610a07565b600060208284031215610b1657600080fd5b81518015158114610a6457600080fd5b60008251610b388184602087016109e3565b919091019291505056fea164736f6c6343000813000a", } var OptimismL2BridgeAdapterABI = OptimismL2BridgeAdapterMetaData.ABI diff --git a/core/gethwrappers/rebalancer/generated/rebalancer/rebalancer.go b/core/gethwrappers/rebalancer/generated/rebalancer/rebalancer.go index 52cbc78b22..4aaaed71f6 100644 --- a/core/gethwrappers/rebalancer/generated/rebalancer/rebalancer.go +++ b/core/gethwrappers/rebalancer/generated/rebalancer/rebalancer.go @@ -46,8 +46,8 @@ type RebalancerCrossChainRebalancer struct { } var RebalancerMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[{\"internalType\":\"contractIERC20\",\"name\":\"token\",\"type\":\"address\"},{\"internalType\":\"uint64\",\"name\":\"localChainSelector\",\"type\":\"uint64\"},{\"internalType\":\"contractILiquidityContainer\",\"name\":\"localLiquidityContainer\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"minimumLiquidity\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"expected\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"actual\",\"type\":\"bytes32\"}],\"name\":\"ConfigDigestMismatch\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"EmptyReport\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"expected\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"actual\",\"type\":\"uint256\"}],\"name\":\"ForkedChain\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"requested\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"available\",\"type\":\"uint256\"}],\"name\":\"InsufficientLiquidity\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"message\",\"type\":\"string\"}],\"name\":\"InvalidConfig\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint64\",\"name\":\"chainSelector\",\"type\":\"uint64\"}],\"name\":\"InvalidRemoteChain\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint64\",\"name\":\"sequenceNumber\",\"type\":\"uint64\"},{\"internalType\":\"uint64\",\"name\":\"latestSequenceNumber\",\"type\":\"uint64\"}],\"name\":\"NonIncreasingSequenceNumber\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NonUniqueSignatures\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"OracleCannotBeZeroAddress\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"SignaturesOutOfRegistration\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"UnauthorizedSigner\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"UnauthorizedTransmitter\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"expected\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"actual\",\"type\":\"uint256\"}],\"name\":\"WrongMessageLength\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"WrongNumberOfSignatures\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ZeroAddress\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ZeroChainSelector\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint32\",\"name\":\"previousConfigBlockNumber\",\"type\":\"uint32\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"configDigest\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"configCount\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"address[]\",\"name\":\"signers\",\"type\":\"address[]\"},{\"indexed\":false,\"internalType\":\"address[]\",\"name\":\"transmitters\",\"type\":\"address[]\"},{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"f\",\"type\":\"uint8\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"onchainConfig\",\"type\":\"bytes\"},{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"offchainConfigVersion\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"offchainConfig\",\"type\":\"bytes\"}],\"name\":\"ConfigSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint64\",\"name\":\"remoteChainSelector\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"contractIBridgeAdapter\",\"name\":\"localBridge\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"remoteToken\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"remoteRebalancer\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"enabled\",\"type\":\"bool\"}],\"name\":\"CrossChainRebalancerSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint64\",\"name\":\"ocrSeqNum\",\"type\":\"uint64\"},{\"indexed\":true,\"internalType\":\"uint64\",\"name\":\"remoteChainSelector\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"bridgeSpecificData\",\"type\":\"bytes\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"reason\",\"type\":\"bytes\"}],\"name\":\"FinalizationFailed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"provider\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"LiquidityAddedToContainer\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newLiquidityContainer\",\"type\":\"address\"}],\"name\":\"LiquidityContainerSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"remover\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"LiquidityRemovedFromContainer\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint64\",\"name\":\"ocrSeqNum\",\"type\":\"uint64\"},{\"indexed\":true,\"internalType\":\"uint64\",\"name\":\"fromChainSelector\",\"type\":\"uint64\"},{\"indexed\":true,\"internalType\":\"uint64\",\"name\":\"toChainSelector\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"bridgeSpecificData\",\"type\":\"bytes\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"bridgeReturnData\",\"type\":\"bytes\"}],\"name\":\"LiquidityTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldBalance\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newBalance\",\"type\":\"uint256\"}],\"name\":\"MinimumLiquiditySet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"}],\"name\":\"OwnershipTransferRequested\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"configDigest\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"sequenceNumber\",\"type\":\"uint64\"}],\"name\":\"Transmitted\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"acceptOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"addLiquidity\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getAllCrossChainRebalancers\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"remoteRebalancer\",\"type\":\"address\"},{\"internalType\":\"contractIBridgeAdapter\",\"name\":\"localBridge\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"remoteToken\",\"type\":\"address\"},{\"internalType\":\"uint64\",\"name\":\"remoteChainSelector\",\"type\":\"uint64\"},{\"internalType\":\"bool\",\"name\":\"enabled\",\"type\":\"bool\"}],\"internalType\":\"structIRebalancer.CrossChainRebalancerArgs[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint64\",\"name\":\"chainSelector\",\"type\":\"uint64\"}],\"name\":\"getCrossChainRebalancer\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"remoteRebalancer\",\"type\":\"address\"},{\"internalType\":\"contractIBridgeAdapter\",\"name\":\"localBridge\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"remoteToken\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"enabled\",\"type\":\"bool\"}],\"internalType\":\"structRebalancer.CrossChainRebalancer\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getLiquidity\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"currentLiquidity\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getLocalLiquidityContainer\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getMinimumLiquidity\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getSupportedDestChains\",\"outputs\":[{\"internalType\":\"uint64[]\",\"name\":\"\",\"type\":\"uint64[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getTransmitters\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"i_localToken\",\"outputs\":[{\"internalType\":\"contractIERC20\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"latestConfigDetails\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"configCount\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"blockNumber\",\"type\":\"uint32\"},{\"internalType\":\"bytes32\",\"name\":\"configDigest\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"latestConfigDigestAndEpoch\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"scanLogs\",\"type\":\"bool\"},{\"internalType\":\"bytes32\",\"name\":\"configDigest\",\"type\":\"bytes32\"},{\"internalType\":\"uint64\",\"name\":\"sequenceNumber\",\"type\":\"uint64\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint64\",\"name\":\"chainSelector\",\"type\":\"uint64\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nativeBridgeFee\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"bridgeSpecificPayload\",\"type\":\"bytes\"}],\"name\":\"rebalanceLiquidity\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint64\",\"name\":\"remoteChainSelector\",\"type\":\"uint64\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"bridgeSpecificPayload\",\"type\":\"bytes\"}],\"name\":\"receiveLiquidity\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"removeLiquidity\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"remoteRebalancer\",\"type\":\"address\"},{\"internalType\":\"contractIBridgeAdapter\",\"name\":\"localBridge\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"remoteToken\",\"type\":\"address\"},{\"internalType\":\"uint64\",\"name\":\"remoteChainSelector\",\"type\":\"uint64\"},{\"internalType\":\"bool\",\"name\":\"enabled\",\"type\":\"bool\"}],\"internalType\":\"structIRebalancer.CrossChainRebalancerArgs\",\"name\":\"crossChainLiqManager\",\"type\":\"tuple\"}],\"name\":\"setCrossChainRebalancer\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"remoteRebalancer\",\"type\":\"address\"},{\"internalType\":\"contractIBridgeAdapter\",\"name\":\"localBridge\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"remoteToken\",\"type\":\"address\"},{\"internalType\":\"uint64\",\"name\":\"remoteChainSelector\",\"type\":\"uint64\"},{\"internalType\":\"bool\",\"name\":\"enabled\",\"type\":\"bool\"}],\"internalType\":\"structIRebalancer.CrossChainRebalancerArgs[]\",\"name\":\"crossChainRebalancers\",\"type\":\"tuple[]\"}],\"name\":\"setCrossChainRebalancers\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contractILiquidityContainer\",\"name\":\"localLiquidityContainer\",\"type\":\"address\"}],\"name\":\"setLocalLiquidityContainer\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"minimumLiquidity\",\"type\":\"uint256\"}],\"name\":\"setMinimumLiquidity\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"signers\",\"type\":\"address[]\"},{\"internalType\":\"address[]\",\"name\":\"transmitters\",\"type\":\"address[]\"},{\"internalType\":\"uint8\",\"name\":\"f\",\"type\":\"uint8\"},{\"internalType\":\"bytes\",\"name\":\"onchainConfig\",\"type\":\"bytes\"},{\"internalType\":\"uint64\",\"name\":\"offchainConfigVersion\",\"type\":\"uint64\"},{\"internalType\":\"bytes\",\"name\":\"offchainConfig\",\"type\":\"bytes\"}],\"name\":\"setOCR3Config\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32[3]\",\"name\":\"reportContext\",\"type\":\"bytes32[3]\"},{\"internalType\":\"bytes\",\"name\":\"report\",\"type\":\"bytes\"},{\"internalType\":\"bytes32[]\",\"name\":\"rs\",\"type\":\"bytes32[]\"},{\"internalType\":\"bytes32[]\",\"name\":\"ss\",\"type\":\"bytes32[]\"},{\"internalType\":\"bytes32\",\"name\":\"rawVs\",\"type\":\"bytes32\"}],\"name\":\"transmit\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"typeAndVersion\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}]", - Bin: "0x60e06040523480156200001157600080fd5b506040516200456e3803806200456e833981016040819052620000349162000218565b33806000816200008b5760405162461bcd60e51b815260206004820152601860248201527f43616e6e6f7420736574206f776e657220746f207a65726f000000000000000060448201526064015b60405180910390fd5b600080546001600160a01b0319166001600160a01b0384811691909117909155811615620000be57620000be8162000154565b505046608052506001600160401b038316600003620000f05760405163f89d762960e01b815260040160405180910390fd5b6001600160a01b038416620001185760405163d92e233d60e01b815260040160405180910390fd5b6001600160a01b0393841660a0526001600160401b039290921660c052600b80546001600160a01b03191691909316179091556008556200027d565b336001600160a01b03821603620001ae5760405162461bcd60e51b815260206004820152601760248201527f43616e6e6f74207472616e7366657220746f2073656c66000000000000000000604482015260640162000082565b600180546001600160a01b0319166001600160a01b0383811691821790925560008054604051929316917fed8889f560326eb138920d842192f0eb3dd22b4f139c87a2c57538e05bae12789190a350565b6001600160a01b03811681146200021557600080fd5b50565b600080600080608085870312156200022f57600080fd5b84516200023c81620001ff565b60208601519094506001600160401b03811681146200025a57600080fd5b60408601519093506200026d81620001ff565b6060959095015193969295505050565b60805160a05160c05161427b620002f3600039600081816127960152612e650152600081816103c10152818161069a015281816108110152818161088801528181611452015281816115a1015281816126e701528181612cfa0152612dc401526000818161173e015261178a015261427b6000f3fe60806040526004361061018f5760003560e01c806379ba5097116100d6578063afcb95d71161007f578063f2fde38b11610059578063f2fde38b146105ed578063f8c2d8fa1461060d578063fe65d5af1461062d57600080fd5b8063afcb95d714610567578063b1dc65a4146105ad578063b7e7fa05146105cd57600080fd5b80638da5cb5b116100b05780638da5cb5b146104fc578063958e31b6146105275780639c8f9f231461054757600080fd5b806379ba50971461049557806381ff7048146104aa57806383d34afe146104e757600080fd5b8063568446e7116101385780636a11ee90116101125780636a11ee901461042a578063706bf6451461044a578063791781f51461046a57600080fd5b8063568446e71461029d5780636511d919146103af578063666cab8d1461040857600080fd5b80633275636e116101695780633275636e1461023b578063348759c11461025b57806351c6590a1461027d57600080fd5b80630910a5101461019b578063181f5a77146101c3578063282567b41461021957600080fd5b3661019657005b600080fd5b3480156101a757600080fd5b506101b061064f565b6040519081526020015b60405180910390f35b3480156101cf57600080fd5b5061020c6040518060400160405280601481526020017f526562616c616e63657220312e302e302d64657600000000000000000000000081525081565b6040516101ba9190613429565b34801561022557600080fd5b50610239610234366004613443565b61070a565b005b34801561024757600080fd5b5061023961025636600461345c565b610757565b34801561026757600080fd5b5061027061076b565b6040516101ba9190613474565b34801561028957600080fd5b50610239610298366004613443565b6107f7565b3480156102a957600080fd5b506103606102b83660046134df565b6040805160808101825260008082526020820181905291810182905260608101919091525067ffffffffffffffff166000908152600960209081526040918290208251608081018452815473ffffffffffffffffffffffffffffffffffffffff908116825260018301548116938201939093526002909101549182169281019290925274010000000000000000000000000000000000000000900460ff161515606082015290565b60408051825173ffffffffffffffffffffffffffffffffffffffff90811682526020808501518216908301528383015116918101919091526060918201511515918101919091526080016101ba565b3480156103bb57600080fd5b506103e37f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016101ba565b34801561041457600080fd5b5061041d6109ac565b6040516101ba919061354b565b34801561043657600080fd5b506102396104453660046137ad565b610a1a565b34801561045657600080fd5b5061023961046536600461387a565b611232565b34801561047657600080fd5b50600b5473ffffffffffffffffffffffffffffffffffffffff166103e3565b3480156104a157600080fd5b506102396112a9565b3480156104b657600080fd5b506004546002546040805163ffffffff808516825264010000000090940490931660208401528201526060016101ba565b3480156104f357600080fd5b506008546101b0565b34801561050857600080fd5b5060005473ffffffffffffffffffffffffffffffffffffffff166103e3565b34801561053357600080fd5b506102396105423660046138e0565b6113a6565b34801561055357600080fd5b50610239610562366004613443565b6113ff565b34801561057357600080fd5b50600254600454604080516001815260208101939093526801000000000000000090910467ffffffffffffffff16908201526060016101ba565b3480156105b957600080fd5b506102396105c836600461397f565b6115fb565b3480156105d957600080fd5b506102396105e8366004613a36565b611c75565b3480156105f957600080fd5b5061023961060836600461387a565b611cbd565b34801561061957600080fd5b50610239610628366004613aab565b611cce565b34801561063957600080fd5b50610642611d28565b6040516101ba9190613b13565b600b546040517f70a0823100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff91821660048201526000917f000000000000000000000000000000000000000000000000000000000000000016906370a0823190602401602060405180830381865afa1580156106e1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107059190613ba8565b905090565b610712611ef2565b600880549082905560408051828152602081018490527ff97e758c8b3d81df7b0e1b7327a6a7fcf09a41536b2d274b9103015d715f11eb910160405180910390a15050565b61075f611ef2565b61076881611f75565b50565b6060600a8054806020026020016040519081016040528092919081815260200182805480156107ed57602002820191906000526020600020906000905b82829054906101000a900467ffffffffffffffff1667ffffffffffffffff16815260200190600801906020826007010492830192600103820291508084116107a85790505b5050505050905090565b61083973ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016333084612371565b600b546040517f095ea7b300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9182166004820152602481018390527f00000000000000000000000000000000000000000000000000000000000000009091169063095ea7b3906044016020604051808303816000875af11580156108d3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108f79190613bcf565b50600b546040517feb521a4c0000000000000000000000000000000000000000000000000000000081526004810183905273ffffffffffffffffffffffffffffffffffffffff9091169063eb521a4c90602401600060405180830381600087803b15801561096457600080fd5b505af1158015610978573d6000803e3d6000fd5b50506040518392503391507f5414b81d05ac3542606f164e16a9a107d05d21e906539cc5ceb61d7b6b707eb590600090a350565b606060078054806020026020016040519081016040528092919081815260200182805480156107ed57602002820191906000526020600020905b815473ffffffffffffffffffffffffffffffffffffffff1681526001909101906020018083116109e6575050505050905090565b855185518560ff16601f831115610a92576040517f89a6198900000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f746f6f206d616e79207369676e6572730000000000000000000000000000000060448201526064015b60405180910390fd5b80600003610afc576040517f89a6198900000000000000000000000000000000000000000000000000000000815260206004820152601260248201527f66206d75737420626520706f73697469766500000000000000000000000000006044820152606401610a89565b818314610b8a576040517f89a61989000000000000000000000000000000000000000000000000000000008152602060048201526024808201527f6f7261636c6520616464726573736573206f7574206f6620726567697374726160448201527f74696f6e000000000000000000000000000000000000000000000000000000006064820152608401610a89565b610b95816003613c1b565b8311610bfd576040517f89a6198900000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f6661756c74792d6f7261636c65206620746f6f206869676800000000000000006044820152606401610a89565b610c05611ef2565b60065460005b81811015610d01576005600060068381548110610c2a57610c2a613c38565b600091825260208083209091015473ffffffffffffffffffffffffffffffffffffffff168352820192909252604001812080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000016905560078054600592919084908110610c9a57610c9a613c38565b600091825260208083209091015473ffffffffffffffffffffffffffffffffffffffff168352820192909252604001902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000169055610cfa81613c67565b9050610c0b565b50895160005b818110156110da5760008c8281518110610d2357610d23613c38565b6020026020010151905060006002811115610d4057610d40613c9f565b73ffffffffffffffffffffffffffffffffffffffff8216600090815260056020526040902054610100900460ff166002811115610d7f57610d7f613c9f565b14610de6576040517f89a6198900000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f7265706561746564207369676e657220616464726573730000000000000000006044820152606401610a89565b73ffffffffffffffffffffffffffffffffffffffff8116610e33576040517fd6c62c9b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040805180820190915260ff83168152602081016001905273ffffffffffffffffffffffffffffffffffffffff821660009081526005602090815260409091208251815460ff9091167fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0082168117835592840151919283917fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00001617610100836002811115610ee357610ee3613c9f565b021790555090505060008c8381518110610eff57610eff613c38565b6020026020010151905060006002811115610f1c57610f1c613c9f565b73ffffffffffffffffffffffffffffffffffffffff8216600090815260056020526040902054610100900460ff166002811115610f5b57610f5b613c9f565b14610fc2576040517f89a6198900000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f7265706561746564207472616e736d69747465722061646472657373000000006044820152606401610a89565b73ffffffffffffffffffffffffffffffffffffffff811661100f576040517fd6c62c9b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040805180820190915260ff84168152602081016002905273ffffffffffffffffffffffffffffffffffffffff821660009081526005602090815260409091208251815460ff9091167fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0082168117835592840151919283917fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000016176101008360028111156110bf576110bf613c9f565b02179055509050505050806110d390613c67565b9050610d07565b508a516110ee9060069060208e01906132fd565b5089516111029060079060208d01906132fd565b506003805460ff838116610100027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000909216908c16171790556004805461118891469130919060009061115a9063ffffffff16613cce565b91906101000a81548163ffffffff021916908363ffffffff160217905563ffffffff168e8e8e8e8e8e61244d565b600260000181905550600060048054906101000a900463ffffffff169050436004806101000a81548163ffffffff021916908363ffffffff1602179055507f1591690b8638f5fb2dbec82ac741805ac5da8b45dc5263f4875b0496fdce4e0581600260000154600460009054906101000a900463ffffffff168f8f8f8f8f8f60405161121c99989796959493929190613cf1565b60405180910390a1505050505050505050505050565b61123a611ef2565b600b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83169081179091556040517f07dc474694ac40123aadcd2445f1b38d2eb353edd9319dcea043548ab34990ec90600090a250565b60015473ffffffffffffffffffffffffffffffffffffffff16331461132a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f4d7573742062652070726f706f736564206f776e6572000000000000000000006044820152606401610a89565b60008054337fffffffffffffffffffffffff00000000000000000000000000000000000000008083168217845560018054909116905560405173ffffffffffffffffffffffffffffffffffffffff90921692909183917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a350565b6113ae611ef2565b6113f9848484848080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525067ffffffffffffffff92506124f8915050565b50505050565b611407611ef2565b600b546040517f70a0823100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff91821660048201526000917f000000000000000000000000000000000000000000000000000000000000000016906370a0823190602401602060405180830381865afa158015611499573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114bd9190613ba8565b905081811015611503576040517fa17e11d50000000000000000000000000000000000000000000000000000000081526004810183905260248101829052604401610a89565b600b546040517f0a861f2a0000000000000000000000000000000000000000000000000000000081526004810184905273ffffffffffffffffffffffffffffffffffffffff90911690630a861f2a90602401600060405180830381600087803b15801561156f57600080fd5b505af1158015611583573d6000803e3d6000fd5b506115ca92505073ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001690503384612828565b604051829033907f2bda316674f8d73d289689d7a3acdf8e353b7a142fb5a68ac2aa475104039c1890600090a35050565b60045460208901359067ffffffffffffffff6801000000000000000090910481169082161161167e57600480546040517f6e376b6600000000000000000000000000000000000000000000000000000000815267ffffffffffffffff80851693820193909352680100000000000000009091049091166024820152604401610a89565b61168988888361287e565b600480547fffffffffffffffffffffffffffffffff0000000000000000ffffffffffffffff166801000000000000000067ffffffffffffffff8416021790556040805160608101825260025480825260035460ff808216602085015261010090910416928201929092528a3591821461173b5780516040517f93df584c000000000000000000000000000000000000000000000000000000008152600481019190915260248101839052604401610a89565b467f0000000000000000000000000000000000000000000000000000000000000000146117bc576040517f0f01ce850000000000000000000000000000000000000000000000000000000081527f00000000000000000000000000000000000000000000000000000000000000006004820152466024820152604401610a89565b6040805183815267ffffffffffffffff851660208201527fe893c2681d327421d89e1cb54fbe64645b4dcea668d6826130b62cf4c6eefea2910160405180910390a1602081015161180e906001613d87565b60ff168714611849576040517f71253a2500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b868514611882576040517fa75d88af00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b3360009081526005602090815260408083208151808301909252805460ff808216845292939192918401916101009091041660028111156118c5576118c5613c9f565b60028111156118d6576118d6613c9f565b90525090506002816020015160028111156118f3576118f3613c9f565b14801561193a57506007816000015160ff168154811061191557611915613c38565b60009182526020909120015473ffffffffffffffffffffffffffffffffffffffff1633145b611970576040517fda0f08e800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50600061197e866020613c1b565b611989896020613c1b565b6119958c610144613da0565b61199f9190613da0565b6119a99190613da0565b90503681146119ed576040517f8e1192e100000000000000000000000000000000000000000000000000000000815260048101829052366024820152604401610a89565b5060008a8a604051611a00929190613db3565b604051908190038120611a17918e90602001613dc3565b604051602081830303815290604052805190602001209050611a37613387565b8860005b81811015611c645760006001858a8460208110611a5a57611a5a613c38565b611a6791901a601b613d87565b8f8f86818110611a7957611a79613c38565b905060200201358e8e87818110611a9257611a92613c38565b9050602002013560405160008152602001604052604051611acf949392919093845260ff9290921660208401526040830152606082015260800190565b6020604051602081039080840390855afa158015611af1573d6000803e3d6000fd5b5050604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081015173ffffffffffffffffffffffffffffffffffffffff8116600090815260056020908152848220848601909552845460ff8082168652939750919550929392840191610100909104166002811115611b7457611b74613c9f565b6002811115611b8557611b85613c9f565b9052509050600181602001516002811115611ba257611ba2613c9f565b14611bd9576040517fca31867a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8051859060ff16601f8110611bf057611bf0613c38565b602002015115611c2c576040517ff67bc7c400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600185826000015160ff16601f8110611c4757611c47613c38565b9115156020909202015250611c5d905081613c67565b9050611a3b565b505050505050505050505050505050565b611c7d611ef2565b60005b81811015611cb857611ca8838383818110611c9d57611c9d613c38565b905060a00201611f75565b611cb181613c67565b9050611c80565b505050565b611cc5611ef2565b61076881612a1b565b611cd6611ef2565b611d2185858567ffffffffffffffff86868080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250612b1092505050565b5050505050565b600a5460609060008167ffffffffffffffff811115611d4957611d4961355e565b604051908082528060200260200182016040528015611dc057816020015b6040805160a0810182526000808252602080830182905292820181905260608201819052608082015282527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff909201910181611d675790505b50905060005b82811015611eeb576000600a8281548110611de357611de3613c38565b6000918252602080832060048304015460039092166008026101000a90910467ffffffffffffffff1680835260098252604092839020835160808082018652825473ffffffffffffffffffffffffffffffffffffffff9081168352600184015481168387019081526002909401548082168489019081527401000000000000000000000000000000000000000090910460ff1615156060808601918252895160a081018b52865185168152965184169887019890985290519091169684019690965293820183905293511515928101929092528551909350859085908110611ecd57611ecd613c38565b6020026020010181905250505080611ee490613c67565b9050611dc6565b5092915050565b60005473ffffffffffffffffffffffffffffffffffffffff163314611f73576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f4f6e6c792063616c6c61626c65206279206f776e6572000000000000000000006044820152606401610a89565b565b611f8560808201606083016134df565b67ffffffffffffffff16600003611fc8576040517ff89d762900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000611fd7602083018361387a565b73ffffffffffffffffffffffffffffffffffffffff16148061201e57506000612006604083016020840161387a565b73ffffffffffffffffffffffffffffffffffffffff16145b8061204e57506000612036606083016040840161387a565b73ffffffffffffffffffffffffffffffffffffffff16145b15612085576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600060098161209a60808501606086016134df565b67ffffffffffffffff16815260208101919091526040016000206002015473ffffffffffffffffffffffffffffffffffffffff160361212657600a6120e560808301606084016134df565b8154600181018355600092835260209092206004830401805460039093166008026101000a67ffffffffffffffff8181021990941692909316929092021790555b60408051608081019091528061213f602084018461387a565b73ffffffffffffffffffffffffffffffffffffffff16815260200182602001602081019061216d919061387a565b73ffffffffffffffffffffffffffffffffffffffff168152602001612198606084016040850161387a565b73ffffffffffffffffffffffffffffffffffffffff1681526020016121c360a0840160808501613dd7565b15159052600960006121db60808501606086016134df565b67ffffffffffffffff16815260208082019290925260409081016000208351815473ffffffffffffffffffffffffffffffffffffffff9182167fffffffffffffffffffffffff00000000000000000000000000000000000000009182161783559385015160018301805491831691909516179093559083015160029091018054606094850151151574010000000000000000000000000000000000000000027fffffffffffffffffffffff00000000000000000000000000000000000000000090911692909316919091179190911790556122bc90608083019083016134df565b67ffffffffffffffff167fab9bd0e4888101232b8f09dae2952ff59a6eea4a19fbddf2a8ca7b23f0e4cb406122f7604084016020850161387a565b612307606085016040860161387a565b612314602086018661387a565b61232460a0870160808801613dd7565b604051612366949392919073ffffffffffffffffffffffffffffffffffffffff9485168152928416602084015292166040820152901515606082015260800190565b60405180910390a250565b60405173ffffffffffffffffffffffffffffffffffffffff808516602483015283166044820152606481018290526113f99085907f23b872dd00000000000000000000000000000000000000000000000000000000906084015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152612ee4565b6000808a8a8a8a8a8a8a8a8a60405160200161247199989796959493929190613df4565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081840301815291905280516020909101207dffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff167e01000000000000000000000000000000000000000000000000000000000000179150509998505050505050505050565b67ffffffffffffffff84166000908152600960209081526040918290208251608081018452815473ffffffffffffffffffffffffffffffffffffffff908116825260018301548116938201939093526002909101549182169281019290925274010000000000000000000000000000000000000000900460ff161515606082018190526125bd576040517fc9ff038f00000000000000000000000000000000000000000000000000000000815267ffffffffffffffff86166004820152602401610a89565b602081015181516040517f38314bb200000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff909216916338314bb2916126199130908890600401613e89565b600060405180830381600087803b15801561263357600080fd5b505af1925050508015612644575060015b6126c9573d808015612672576040519150601f19603f3d011682016040523d82523d6000602084013e612677565b606091505b508567ffffffffffffffff168367ffffffffffffffff167fa481d91c3f9574c23ee84fef85246354b760a0527a535d6382354e4684703ce386846040516126bf929190613ecb565b60405180910390a3505b600b546127109073ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000008116911686612ff0565b600b546040517feb521a4c0000000000000000000000000000000000000000000000000000000081526004810186905273ffffffffffffffffffffffffffffffffffffffff9091169063eb521a4c90602401600060405180830381600087803b15801561277c57600080fd5b505af1158015612790573d6000803e3d6000fd5b505050507f000000000000000000000000000000000000000000000000000000000000000067ffffffffffffffff168567ffffffffffffffff168367ffffffffffffffff167f2a0b69eaf1b415ca57005b4f87582ddefc6d960325ff30dc62a9b3e1e1e5b8a8308888604051806020016040528060008152506040516128199493929190613ef0565b60405180910390a45050505050565b60405173ffffffffffffffffffffffffffffffffffffffff8316602482015260448101829052611cb89084907fa9059cbb00000000000000000000000000000000000000000000000000000000906064016123cb565b600061288c83850185614029565b80515160208201515191925090811580156128a5575080155b156128db576040517ebf199700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60005b8281101561298757612977846000015182815181106128ff576128ff613c38565b6020026020010151604001518560000151838151811061292157612921613c38565b6020026020010151600001518660000151848151811061294357612943613c38565b602002602001015160200151888860000151868151811061296657612966613c38565b602002602001015160600151612b10565b61298081613c67565b90506128de565b5060005b81811015612a1257612a02846020015182815181106129ac576129ac613c38565b602002602001015160200151856020015183815181106129ce576129ce613c38565b602002602001015160000151866020015184815181106129f0576129f0613c38565b602002602001015160400151886124f8565b612a0b81613c67565b905061298b565b50505050505050565b3373ffffffffffffffffffffffffffffffffffffffff821603612a9a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f43616e6e6f74207472616e7366657220746f2073656c660000000000000000006044820152606401610a89565b600180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83811691821790925560008054604051929316917fed8889f560326eb138920d842192f0eb3dd22b4f139c87a2c57538e05bae12789190a350565b6000612b1a61064f565b905084811015612b60576040517fa17e11d50000000000000000000000000000000000000000000000000000000081526004810186905260248101829052604401610a89565b67ffffffffffffffff86166000908152600960209081526040918290208251608081018452815473ffffffffffffffffffffffffffffffffffffffff908116825260018301548116938201939093526002909101549182169281019290925274010000000000000000000000000000000000000000900460ff16151560608201819052612c25576040517fc9ff038f00000000000000000000000000000000000000000000000000000000815267ffffffffffffffff88166004820152602401610a89565b600b546040517f0a861f2a0000000000000000000000000000000000000000000000000000000081526004810188905273ffffffffffffffffffffffffffffffffffffffff90911690630a861f2a90602401600060405180830381600087803b158015612c9157600080fd5b505af1158015612ca5573d6000803e3d6000fd5b5050505060208101516040517f095ea7b300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9182166004820152602481018890527f00000000000000000000000000000000000000000000000000000000000000009091169063095ea7b3906044016020604051808303816000875af1158015612d45573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d699190613bcf565b506020810151604080830151835191517fa71d98b700000000000000000000000000000000000000000000000000000000815260009373ffffffffffffffffffffffffffffffffffffffff169263a71d98b7928a92612df1927f000000000000000000000000000000000000000000000000000000000000000092918e908c9060040161419d565b60006040518083038185885af1158015612e0f573d6000803e3d6000fd5b50505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201604052612e5691908101906141e4565b90508767ffffffffffffffff167f000000000000000000000000000000000000000000000000000000000000000067ffffffffffffffff168667ffffffffffffffff167f2a0b69eaf1b415ca57005b4f87582ddefc6d960325ff30dc62a9b3e1e1e5b8a885600001518b8987604051612ed29493929190613ef0565b60405180910390a45050505050505050565b6000612f46826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff166130ee9092919063ffffffff16565b805190915015611cb85780806020019051810190612f649190613bcf565b611cb8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401610a89565b6040517fdd62ed3e00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff8381166024830152600091839186169063dd62ed3e90604401602060405180830381865afa158015613067573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061308b9190613ba8565b6130959190613da0565b60405173ffffffffffffffffffffffffffffffffffffffff85166024820152604481018290529091506113f99085907f095ea7b300000000000000000000000000000000000000000000000000000000906064016123cb565b60606130fd8484600085613105565b949350505050565b606082471015613197576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610a89565b6000808673ffffffffffffffffffffffffffffffffffffffff1685876040516131c09190614252565b60006040518083038185875af1925050503d80600081146131fd576040519150601f19603f3d011682016040523d82523d6000602084013e613202565b606091505b50915091506132138783838761321e565b979650505050505050565b606083156132b45782516000036132ad5773ffffffffffffffffffffffffffffffffffffffff85163b6132ad576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610a89565b50816130fd565b6130fd83838151156132c95781518083602001fd5b806040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a899190613429565b828054828255906000526020600020908101928215613377579160200282015b8281111561337757825182547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff90911617825560209092019160019091019061331d565b506133839291506133a6565b5090565b604051806103e00160405280601f906020820280368337509192915050565b5b8082111561338357600081556001016133a7565b60005b838110156133d65781810151838201526020016133be565b50506000910152565b600081518084526133f78160208601602086016133bb565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b60208152600061343c60208301846133df565b9392505050565b60006020828403121561345557600080fd5b5035919050565b600060a0828403121561346e57600080fd5b50919050565b6020808252825182820181905260009190848201906040850190845b818110156134b657835167ffffffffffffffff1683529284019291840191600101613490565b50909695505050505050565b803567ffffffffffffffff811681146134da57600080fd5b919050565b6000602082840312156134f157600080fd5b61343c826134c2565b600081518084526020808501945080840160005b8381101561354057815173ffffffffffffffffffffffffffffffffffffffff168752958201959082019060010161350e565b509495945050505050565b60208152600061343c60208301846134fa565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040516060810167ffffffffffffffff811182821017156135b0576135b061355e565b60405290565b6040805190810167ffffffffffffffff811182821017156135b0576135b061355e565b6040516080810167ffffffffffffffff811182821017156135b0576135b061355e565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff811182821017156136435761364361355e565b604052919050565b600067ffffffffffffffff8211156136655761366561355e565b5060051b60200190565b73ffffffffffffffffffffffffffffffffffffffff8116811461076857600080fd5b600082601f8301126136a257600080fd5b813560206136b76136b28361364b565b6135fc565b82815260059290921b840181019181810190868411156136d657600080fd5b8286015b848110156136fa5780356136ed8161366f565b83529183019183016136da565b509695505050505050565b803560ff811681146134da57600080fd5b600067ffffffffffffffff8211156137305761373061355e565b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b600082601f83011261376d57600080fd5b813561377b6136b282613716565b81815284602083860101111561379057600080fd5b816020850160208301376000918101602001919091529392505050565b60008060008060008060c087890312156137c657600080fd5b863567ffffffffffffffff808211156137de57600080fd5b6137ea8a838b01613691565b9750602089013591508082111561380057600080fd5b61380c8a838b01613691565b965061381a60408a01613705565b9550606089013591508082111561383057600080fd5b61383c8a838b0161375c565b945061384a60808a016134c2565b935060a089013591508082111561386057600080fd5b5061386d89828a0161375c565b9150509295509295509295565b60006020828403121561388c57600080fd5b813561343c8161366f565b60008083601f8401126138a957600080fd5b50813567ffffffffffffffff8111156138c157600080fd5b6020830191508360208285010111156138d957600080fd5b9250929050565b600080600080606085870312156138f657600080fd5b6138ff856134c2565b935060208501359250604085013567ffffffffffffffff81111561392257600080fd5b61392e87828801613897565b95989497509550505050565b60008083601f84011261394c57600080fd5b50813567ffffffffffffffff81111561396457600080fd5b6020830191508360208260051b85010111156138d957600080fd5b60008060008060008060008060e0898b03121561399b57600080fd5b606089018a8111156139ac57600080fd5b8998503567ffffffffffffffff808211156139c657600080fd5b6139d28c838d01613897565b909950975060808b01359150808211156139eb57600080fd5b6139f78c838d0161393a565b909750955060a08b0135915080821115613a1057600080fd5b50613a1d8b828c0161393a565b999c989b50969995989497949560c00135949350505050565b60008060208385031215613a4957600080fd5b823567ffffffffffffffff80821115613a6157600080fd5b818501915085601f830112613a7557600080fd5b813581811115613a8457600080fd5b86602060a083028501011115613a9957600080fd5b60209290920196919550909350505050565b600080600080600060808688031215613ac357600080fd5b613acc866134c2565b94506020860135935060408601359250606086013567ffffffffffffffff811115613af657600080fd5b613b0288828901613897565b969995985093965092949392505050565b602080825282518282018190526000919060409081850190868401855b82811015613b9b578151805173ffffffffffffffffffffffffffffffffffffffff90811686528782015181168887015286820151168686015260608082015167ffffffffffffffff169086015260809081015115159085015260a09093019290850190600101613b30565b5091979650505050505050565b600060208284031215613bba57600080fd5b5051919050565b801515811461076857600080fd5b600060208284031215613be157600080fd5b815161343c81613bc1565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b8082028115828204841417613c3257613c32613bec565b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203613c9857613c98613bec565b5060010190565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b600063ffffffff808316818103613ce757613ce7613bec565b6001019392505050565b600061012063ffffffff808d1684528b6020850152808b16604085015250806060840152613d218184018a6134fa565b90508281036080840152613d3581896134fa565b905060ff871660a084015282810360c0840152613d5281876133df565b905067ffffffffffffffff851660e0840152828103610100840152613d7781856133df565b9c9b505050505050505050505050565b60ff8181168382160190811115613c3257613c32613bec565b80820180821115613c3257613c32613bec565b8183823760009101908152919050565b828152606082602083013760800192915050565b600060208284031215613de957600080fd5b813561343c81613bc1565b60006101208b835273ffffffffffffffffffffffffffffffffffffffff8b16602084015267ffffffffffffffff808b166040850152816060850152613e3b8285018b6134fa565b91508382036080850152613e4f828a6134fa565b915060ff881660a085015283820360c0850152613e6c82886133df565b90861660e08501528381036101008501529050613d7781856133df565b600073ffffffffffffffffffffffffffffffffffffffff808616835280851660208401525060606040830152613ec260608301846133df565b95945050505050565b604081526000613ede60408301856133df565b8281036020840152613ec281856133df565b73ffffffffffffffffffffffffffffffffffffffff85168152836020820152608060408201526000613f2560808301856133df565b828103606084015261321381856133df565b600082601f830112613f4857600080fd5b81356020613f586136b28361364b565b82815260059290921b84018101918181019086841115613f7757600080fd5b8286015b848110156136fa57803567ffffffffffffffff80821115613f9c5760008081fd5b81890191506060807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0848d03011215613fd55760008081fd5b613fdd61358d565b8784013581526040613ff08186016134c2565b828a01529184013591838311156140075760008081fd5b6140158d8a8588010161375c565b908201528652505050918301918301613f7b565b6000602080838503121561403c57600080fd5b823567ffffffffffffffff8082111561405457600080fd5b908401906040828703121561406857600080fd5b6140706135b6565b82358281111561407f57600080fd5b8301601f8101881361409057600080fd5b803561409e6136b28261364b565b81815260059190911b8201860190868101908a8311156140bd57600080fd5b8784015b83811015614169578035878111156140d857600080fd5b85016080818e037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe001121561410c57600080fd5b6141146135d9565b8a820135815260408201358b82015261412f606083016134c2565b60408201526080820135898111156141475760008081fd5b6141558f8d8386010161375c565b6060830152508452509188019188016140c1565b508452505050828401358281111561418057600080fd5b61418c88828601613f37565b948201949094529695505050505050565b600073ffffffffffffffffffffffffffffffffffffffff8088168352808716602084015280861660408401525083606083015260a0608083015261321360a08301846133df565b6000602082840312156141f657600080fd5b815167ffffffffffffffff81111561420d57600080fd5b8201601f8101841361421e57600080fd5b805161422c6136b282613716565b81815285602083850101111561424157600080fd5b613ec28260208301602086016133bb565b600082516142648184602087016133bb565b919091019291505056fea164736f6c6343000813000a", + ABI: "[{\"inputs\":[{\"internalType\":\"contractIERC20\",\"name\":\"token\",\"type\":\"address\"},{\"internalType\":\"uint64\",\"name\":\"localChainSelector\",\"type\":\"uint64\"},{\"internalType\":\"contractILiquidityContainer\",\"name\":\"localLiquidityContainer\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"minimumLiquidity\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"expected\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"actual\",\"type\":\"bytes32\"}],\"name\":\"ConfigDigestMismatch\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"EmptyReport\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"expected\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"actual\",\"type\":\"uint256\"}],\"name\":\"ForkedChain\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"requested\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"available\",\"type\":\"uint256\"}],\"name\":\"InsufficientLiquidity\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"message\",\"type\":\"string\"}],\"name\":\"InvalidConfig\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint64\",\"name\":\"chainSelector\",\"type\":\"uint64\"}],\"name\":\"InvalidRemoteChain\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint64\",\"name\":\"sequenceNumber\",\"type\":\"uint64\"},{\"internalType\":\"uint64\",\"name\":\"latestSequenceNumber\",\"type\":\"uint64\"}],\"name\":\"NonIncreasingSequenceNumber\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NonUniqueSignatures\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"OracleCannotBeZeroAddress\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"SignaturesOutOfRegistration\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"UnauthorizedSigner\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"UnauthorizedTransmitter\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"expected\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"actual\",\"type\":\"uint256\"}],\"name\":\"WrongMessageLength\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"WrongNumberOfSignatures\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ZeroAddress\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ZeroChainSelector\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint32\",\"name\":\"previousConfigBlockNumber\",\"type\":\"uint32\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"configDigest\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"configCount\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"address[]\",\"name\":\"signers\",\"type\":\"address[]\"},{\"indexed\":false,\"internalType\":\"address[]\",\"name\":\"transmitters\",\"type\":\"address[]\"},{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"f\",\"type\":\"uint8\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"onchainConfig\",\"type\":\"bytes\"},{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"offchainConfigVersion\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"offchainConfig\",\"type\":\"bytes\"}],\"name\":\"ConfigSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint64\",\"name\":\"remoteChainSelector\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"contractIBridgeAdapter\",\"name\":\"localBridge\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"remoteToken\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"remoteRebalancer\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"enabled\",\"type\":\"bool\"}],\"name\":\"CrossChainRebalancerSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint64\",\"name\":\"ocrSeqNum\",\"type\":\"uint64\"},{\"indexed\":true,\"internalType\":\"uint64\",\"name\":\"remoteChainSelector\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"bridgeSpecificData\",\"type\":\"bytes\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"reason\",\"type\":\"bytes\"}],\"name\":\"FinalizationFailed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint64\",\"name\":\"ocrSeqNum\",\"type\":\"uint64\"},{\"indexed\":true,\"internalType\":\"uint64\",\"name\":\"remoteChainSelector\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"bridgeSpecificData\",\"type\":\"bytes\"}],\"name\":\"FinalizationStepCompleted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"provider\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"LiquidityAddedToContainer\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newLiquidityContainer\",\"type\":\"address\"}],\"name\":\"LiquidityContainerSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"remover\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"LiquidityRemovedFromContainer\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint64\",\"name\":\"ocrSeqNum\",\"type\":\"uint64\"},{\"indexed\":true,\"internalType\":\"uint64\",\"name\":\"fromChainSelector\",\"type\":\"uint64\"},{\"indexed\":true,\"internalType\":\"uint64\",\"name\":\"toChainSelector\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"bridgeSpecificData\",\"type\":\"bytes\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"bridgeReturnData\",\"type\":\"bytes\"}],\"name\":\"LiquidityTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldBalance\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newBalance\",\"type\":\"uint256\"}],\"name\":\"MinimumLiquiditySet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"}],\"name\":\"OwnershipTransferRequested\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"configDigest\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"sequenceNumber\",\"type\":\"uint64\"}],\"name\":\"Transmitted\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"acceptOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"addLiquidity\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getAllCrossChainRebalancers\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"remoteRebalancer\",\"type\":\"address\"},{\"internalType\":\"contractIBridgeAdapter\",\"name\":\"localBridge\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"remoteToken\",\"type\":\"address\"},{\"internalType\":\"uint64\",\"name\":\"remoteChainSelector\",\"type\":\"uint64\"},{\"internalType\":\"bool\",\"name\":\"enabled\",\"type\":\"bool\"}],\"internalType\":\"structIRebalancer.CrossChainRebalancerArgs[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint64\",\"name\":\"chainSelector\",\"type\":\"uint64\"}],\"name\":\"getCrossChainRebalancer\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"remoteRebalancer\",\"type\":\"address\"},{\"internalType\":\"contractIBridgeAdapter\",\"name\":\"localBridge\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"remoteToken\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"enabled\",\"type\":\"bool\"}],\"internalType\":\"structRebalancer.CrossChainRebalancer\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getLiquidity\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"currentLiquidity\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getLocalLiquidityContainer\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getMinimumLiquidity\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getSupportedDestChains\",\"outputs\":[{\"internalType\":\"uint64[]\",\"name\":\"\",\"type\":\"uint64[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getTransmitters\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"i_localToken\",\"outputs\":[{\"internalType\":\"contractIERC20\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"latestConfigDetails\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"configCount\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"blockNumber\",\"type\":\"uint32\"},{\"internalType\":\"bytes32\",\"name\":\"configDigest\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"latestConfigDigestAndEpoch\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"scanLogs\",\"type\":\"bool\"},{\"internalType\":\"bytes32\",\"name\":\"configDigest\",\"type\":\"bytes32\"},{\"internalType\":\"uint64\",\"name\":\"sequenceNumber\",\"type\":\"uint64\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint64\",\"name\":\"chainSelector\",\"type\":\"uint64\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nativeBridgeFee\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"bridgeSpecificPayload\",\"type\":\"bytes\"}],\"name\":\"rebalanceLiquidity\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint64\",\"name\":\"remoteChainSelector\",\"type\":\"uint64\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"shouldWrapNative\",\"type\":\"bool\"},{\"internalType\":\"bytes\",\"name\":\"bridgeSpecificPayload\",\"type\":\"bytes\"}],\"name\":\"receiveLiquidity\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"removeLiquidity\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"remoteRebalancer\",\"type\":\"address\"},{\"internalType\":\"contractIBridgeAdapter\",\"name\":\"localBridge\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"remoteToken\",\"type\":\"address\"},{\"internalType\":\"uint64\",\"name\":\"remoteChainSelector\",\"type\":\"uint64\"},{\"internalType\":\"bool\",\"name\":\"enabled\",\"type\":\"bool\"}],\"internalType\":\"structIRebalancer.CrossChainRebalancerArgs\",\"name\":\"crossChainLiqManager\",\"type\":\"tuple\"}],\"name\":\"setCrossChainRebalancer\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"remoteRebalancer\",\"type\":\"address\"},{\"internalType\":\"contractIBridgeAdapter\",\"name\":\"localBridge\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"remoteToken\",\"type\":\"address\"},{\"internalType\":\"uint64\",\"name\":\"remoteChainSelector\",\"type\":\"uint64\"},{\"internalType\":\"bool\",\"name\":\"enabled\",\"type\":\"bool\"}],\"internalType\":\"structIRebalancer.CrossChainRebalancerArgs[]\",\"name\":\"crossChainRebalancers\",\"type\":\"tuple[]\"}],\"name\":\"setCrossChainRebalancers\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contractILiquidityContainer\",\"name\":\"localLiquidityContainer\",\"type\":\"address\"}],\"name\":\"setLocalLiquidityContainer\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"minimumLiquidity\",\"type\":\"uint256\"}],\"name\":\"setMinimumLiquidity\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"signers\",\"type\":\"address[]\"},{\"internalType\":\"address[]\",\"name\":\"transmitters\",\"type\":\"address[]\"},{\"internalType\":\"uint8\",\"name\":\"f\",\"type\":\"uint8\"},{\"internalType\":\"bytes\",\"name\":\"onchainConfig\",\"type\":\"bytes\"},{\"internalType\":\"uint64\",\"name\":\"offchainConfigVersion\",\"type\":\"uint64\"},{\"internalType\":\"bytes\",\"name\":\"offchainConfig\",\"type\":\"bytes\"}],\"name\":\"setOCR3Config\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32[3]\",\"name\":\"reportContext\",\"type\":\"bytes32[3]\"},{\"internalType\":\"bytes\",\"name\":\"report\",\"type\":\"bytes\"},{\"internalType\":\"bytes32[]\",\"name\":\"rs\",\"type\":\"bytes32[]\"},{\"internalType\":\"bytes32[]\",\"name\":\"ss\",\"type\":\"bytes32[]\"},{\"internalType\":\"bytes32\",\"name\":\"rawVs\",\"type\":\"bytes32\"}],\"name\":\"transmit\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"typeAndVersion\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}]", + Bin: "0x60e06040523480156200001157600080fd5b50604051620046c2380380620046c2833981016040819052620000349162000218565b33806000816200008b5760405162461bcd60e51b815260206004820152601860248201527f43616e6e6f7420736574206f776e657220746f207a65726f000000000000000060448201526064015b60405180910390fd5b600080546001600160a01b0319166001600160a01b0384811691909117909155811615620000be57620000be8162000154565b505046608052506001600160401b038316600003620000f05760405163f89d762960e01b815260040160405180910390fd5b6001600160a01b038416620001185760405163d92e233d60e01b815260040160405180910390fd5b6001600160a01b0393841660a0526001600160401b039290921660c052600b80546001600160a01b03191691909316179091556008556200027d565b336001600160a01b03821603620001ae5760405162461bcd60e51b815260206004820152601760248201527f43616e6e6f74207472616e7366657220746f2073656c66000000000000000000604482015260640162000082565b600180546001600160a01b0319166001600160a01b0383811691821790925560008054604051929316917fed8889f560326eb138920d842192f0eb3dd22b4f139c87a2c57538e05bae12789190a350565b6001600160a01b03811681146200021557600080fd5b50565b600080600080608085870312156200022f57600080fd5b84516200023c81620001ff565b60208601519094506001600160401b03811681146200025a57600080fd5b60408601519093506200026d81620001ff565b6060959095015193969295505050565b60805160a05160c0516143c8620002fa60003960008181612dde0152612fb20152600081816103e10152818161069a0152818161086d015281816108e401528181611455015281816115a401528181612c7301528181612d3d01528181612e650152612f03015260008181611741015261178d01526143c86000f3fe60806040526004361061018f5760003560e01c8063791781f5116100d6578063afcb95d71161007f578063f2fde38b11610059578063f2fde38b146105ed578063f8c2d8fa1461060d578063fe65d5af1461062d57600080fd5b8063afcb95d714610567578063b1dc65a4146105ad578063b7e7fa05146105cd57600080fd5b806383d34afe116100b057806383d34afe146105075780638da5cb5b1461051c5780639c8f9f231461054757600080fd5b8063791781f51461048a57806379ba5097146104b557806381ff7048146104ca57600080fd5b806351c6590a11610138578063666cab8d11610112578063666cab8d146104285780636a11ee901461044a578063706bf6451461046a57600080fd5b806351c6590a1461029d578063568446e7146102bd5780636511d919146103cf57600080fd5b80633275636e116101695780633275636e1461023b578063348759c11461025b57806350a197d71461027d57600080fd5b80630910a5101461019b578063181f5a77146101c3578063282567b41461021957600080fd5b3661019657005b600080fd5b3480156101a757600080fd5b506101b061064f565b6040519081526020015b60405180910390f35b3480156101cf57600080fd5b5061020c6040518060400160405280601481526020017f526562616c616e63657220312e302e302d64657600000000000000000000000081525081565b6040516101ba9190613589565b34801561022557600080fd5b506102396102343660046135a3565b61070a565b005b34801561024757600080fd5b506102396102563660046135bc565b610757565b34801561026757600080fd5b5061027061076b565b6040516101ba91906135d4565b34801561028957600080fd5b50610239610298366004613696565b6107f7565b3480156102a957600080fd5b506102396102b83660046135a3565b610853565b3480156102c957600080fd5b506103806102d8366004613707565b6040805160808101825260008082526020820181905291810182905260608101919091525067ffffffffffffffff166000908152600960209081526040918290208251608081018452815473ffffffffffffffffffffffffffffffffffffffff908116825260018301548116938201939093526002909101549182169281019290925274010000000000000000000000000000000000000000900460ff161515606082015290565b60408051825173ffffffffffffffffffffffffffffffffffffffff90811682526020808501518216908301528383015116918101919091526060918201511515918101919091526080016101ba565b3480156103db57600080fd5b506104037f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016101ba565b34801561043457600080fd5b5061043d610a08565b6040516101ba9190613773565b34801561045657600080fd5b506102396104653660046139b2565b610a76565b34801561047657600080fd5b50610239610485366004613a7f565b61128e565b34801561049657600080fd5b50600b5473ffffffffffffffffffffffffffffffffffffffff16610403565b3480156104c157600080fd5b50610239611305565b3480156104d657600080fd5b506004546002546040805163ffffffff808516825264010000000090940490931660208401528201526060016101ba565b34801561051357600080fd5b506008546101b0565b34801561052857600080fd5b5060005473ffffffffffffffffffffffffffffffffffffffff16610403565b34801561055357600080fd5b506102396105623660046135a3565b611402565b34801561057357600080fd5b50600254600454604080516001815260208101939093526801000000000000000090910467ffffffffffffffff16908201526060016101ba565b3480156105b957600080fd5b506102396105c8366004613ae1565b6115fe565b3480156105d957600080fd5b506102396105e8366004613b98565b611c78565b3480156105f957600080fd5b50610239610608366004613a7f565b611cc0565b34801561061957600080fd5b50610239610628366004613c0d565b611cd1565b34801561063957600080fd5b50610642611d24565b6040516101ba9190613c58565b600b546040517f70a0823100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff91821660048201526000917f000000000000000000000000000000000000000000000000000000000000000016906370a0823190602401602060405180830381865afa1580156106e1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107059190613ced565b905090565b610712611eee565b600880549082905560408051828152602081018490527ff97e758c8b3d81df7b0e1b7327a6a7fcf09a41536b2d274b9103015d715f11eb910160405180910390a15050565b61075f611eee565b61076881611f71565b50565b6060600a8054806020026020016040519081016040528092919081815260200182805480156107ed57602002820191906000526020600020906000905b82829054906101000a900467ffffffffffffffff1667ffffffffffffffff16815260200190600801906020826007010492830192600103820291508084116107a85790505b5050505050905090565b6107ff611eee565b61084c858584848080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525089925067ffffffffffffffff915061236d9050565b5050505050565b61089573ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000163330846125f2565b600b546040517f095ea7b300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9182166004820152602481018390527f00000000000000000000000000000000000000000000000000000000000000009091169063095ea7b3906044016020604051808303816000875af115801561092f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109539190613d06565b50600b546040517feb521a4c0000000000000000000000000000000000000000000000000000000081526004810183905273ffffffffffffffffffffffffffffffffffffffff9091169063eb521a4c90602401600060405180830381600087803b1580156109c057600080fd5b505af11580156109d4573d6000803e3d6000fd5b50506040518392503391507f5414b81d05ac3542606f164e16a9a107d05d21e906539cc5ceb61d7b6b707eb590600090a350565b606060078054806020026020016040519081016040528092919081815260200182805480156107ed57602002820191906000526020600020905b815473ffffffffffffffffffffffffffffffffffffffff168152600190910190602001808311610a42575050505050905090565b855185518560ff16601f831115610aee576040517f89a6198900000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f746f6f206d616e79207369676e6572730000000000000000000000000000000060448201526064015b60405180910390fd5b80600003610b58576040517f89a6198900000000000000000000000000000000000000000000000000000000815260206004820152601260248201527f66206d75737420626520706f73697469766500000000000000000000000000006044820152606401610ae5565b818314610be6576040517f89a61989000000000000000000000000000000000000000000000000000000008152602060048201526024808201527f6f7261636c6520616464726573736573206f7574206f6620726567697374726160448201527f74696f6e000000000000000000000000000000000000000000000000000000006064820152608401610ae5565b610bf1816003613d52565b8311610c59576040517f89a6198900000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f6661756c74792d6f7261636c65206620746f6f206869676800000000000000006044820152606401610ae5565b610c61611eee565b60065460005b81811015610d5d576005600060068381548110610c8657610c86613d6f565b600091825260208083209091015473ffffffffffffffffffffffffffffffffffffffff168352820192909252604001812080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000016905560078054600592919084908110610cf657610cf6613d6f565b600091825260208083209091015473ffffffffffffffffffffffffffffffffffffffff168352820192909252604001902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000169055610d5681613d9e565b9050610c67565b50895160005b818110156111365760008c8281518110610d7f57610d7f613d6f565b6020026020010151905060006002811115610d9c57610d9c613dd6565b73ffffffffffffffffffffffffffffffffffffffff8216600090815260056020526040902054610100900460ff166002811115610ddb57610ddb613dd6565b14610e42576040517f89a6198900000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f7265706561746564207369676e657220616464726573730000000000000000006044820152606401610ae5565b73ffffffffffffffffffffffffffffffffffffffff8116610e8f576040517fd6c62c9b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040805180820190915260ff83168152602081016001905273ffffffffffffffffffffffffffffffffffffffff821660009081526005602090815260409091208251815460ff9091167fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0082168117835592840151919283917fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00001617610100836002811115610f3f57610f3f613dd6565b021790555090505060008c8381518110610f5b57610f5b613d6f565b6020026020010151905060006002811115610f7857610f78613dd6565b73ffffffffffffffffffffffffffffffffffffffff8216600090815260056020526040902054610100900460ff166002811115610fb757610fb7613dd6565b1461101e576040517f89a6198900000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f7265706561746564207472616e736d69747465722061646472657373000000006044820152606401610ae5565b73ffffffffffffffffffffffffffffffffffffffff811661106b576040517fd6c62c9b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040805180820190915260ff84168152602081016002905273ffffffffffffffffffffffffffffffffffffffff821660009081526005602090815260409091208251815460ff9091167fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0082168117835592840151919283917fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000161761010083600281111561111b5761111b613dd6565b021790555090505050508061112f90613d9e565b9050610d63565b508a5161114a9060069060208e019061345d565b50895161115e9060079060208d019061345d565b506003805460ff838116610100027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000909216908c1617179055600480546111e49146913091906000906111b69063ffffffff16613e05565b91906101000a81548163ffffffff021916908363ffffffff160217905563ffffffff168e8e8e8e8e8e6126d4565b600260000181905550600060048054906101000a900463ffffffff169050436004806101000a81548163ffffffff021916908363ffffffff1602179055507f1591690b8638f5fb2dbec82ac741805ac5da8b45dc5263f4875b0496fdce4e0581600260000154600460009054906101000a900463ffffffff168f8f8f8f8f8f60405161127899989796959493929190613e28565b60405180910390a1505050505050505050505050565b611296611eee565b600b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83169081179091556040517f07dc474694ac40123aadcd2445f1b38d2eb353edd9319dcea043548ab34990ec90600090a250565b60015473ffffffffffffffffffffffffffffffffffffffff163314611386576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f4d7573742062652070726f706f736564206f776e6572000000000000000000006044820152606401610ae5565b60008054337fffffffffffffffffffffffff00000000000000000000000000000000000000008083168217845560018054909116905560405173ffffffffffffffffffffffffffffffffffffffff90921692909183917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a350565b61140a611eee565b600b546040517f70a0823100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff91821660048201526000917f000000000000000000000000000000000000000000000000000000000000000016906370a0823190602401602060405180830381865afa15801561149c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114c09190613ced565b905081811015611506576040517fa17e11d50000000000000000000000000000000000000000000000000000000081526004810183905260248101829052604401610ae5565b600b546040517f0a861f2a0000000000000000000000000000000000000000000000000000000081526004810184905273ffffffffffffffffffffffffffffffffffffffff90911690630a861f2a90602401600060405180830381600087803b15801561157257600080fd5b505af1158015611586573d6000803e3d6000fd5b506115cd92505073ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000169050338461277f565b604051829033907f2bda316674f8d73d289689d7a3acdf8e353b7a142fb5a68ac2aa475104039c1890600090a35050565b60045460208901359067ffffffffffffffff6801000000000000000090910481169082161161168157600480546040517f6e376b6600000000000000000000000000000000000000000000000000000000815267ffffffffffffffff80851693820193909352680100000000000000009091049091166024820152604401610ae5565b61168c8888836127d5565b600480547fffffffffffffffffffffffffffffffff0000000000000000ffffffffffffffff166801000000000000000067ffffffffffffffff8416021790556040805160608101825260025480825260035460ff808216602085015261010090910416928201929092528a3591821461173e5780516040517f93df584c000000000000000000000000000000000000000000000000000000008152600481019190915260248101839052604401610ae5565b467f0000000000000000000000000000000000000000000000000000000000000000146117bf576040517f0f01ce850000000000000000000000000000000000000000000000000000000081527f00000000000000000000000000000000000000000000000000000000000000006004820152466024820152604401610ae5565b6040805183815267ffffffffffffffff851660208201527fe893c2681d327421d89e1cb54fbe64645b4dcea668d6826130b62cf4c6eefea2910160405180910390a16020810151611811906001613ebe565b60ff16871461184c576040517f71253a2500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b868514611885576040517fa75d88af00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b3360009081526005602090815260408083208151808301909252805460ff808216845292939192918401916101009091041660028111156118c8576118c8613dd6565b60028111156118d9576118d9613dd6565b90525090506002816020015160028111156118f6576118f6613dd6565b14801561193d57506007816000015160ff168154811061191857611918613d6f565b60009182526020909120015473ffffffffffffffffffffffffffffffffffffffff1633145b611973576040517fda0f08e800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b506000611981866020613d52565b61198c896020613d52565b6119988c610144613ed7565b6119a29190613ed7565b6119ac9190613ed7565b90503681146119f0576040517f8e1192e100000000000000000000000000000000000000000000000000000000815260048101829052366024820152604401610ae5565b5060008a8a604051611a03929190613eea565b604051908190038120611a1a918e90602001613efa565b604051602081830303815290604052805190602001209050611a3a6134e7565b8860005b81811015611c675760006001858a8460208110611a5d57611a5d613d6f565b611a6a91901a601b613ebe565b8f8f86818110611a7c57611a7c613d6f565b905060200201358e8e87818110611a9557611a95613d6f565b9050602002013560405160008152602001604052604051611ad2949392919093845260ff9290921660208401526040830152606082015260800190565b6020604051602081039080840390855afa158015611af4573d6000803e3d6000fd5b5050604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081015173ffffffffffffffffffffffffffffffffffffffff8116600090815260056020908152848220848601909552845460ff8082168652939750919550929392840191610100909104166002811115611b7757611b77613dd6565b6002811115611b8857611b88613dd6565b9052509050600181602001516002811115611ba557611ba5613dd6565b14611bdc576040517fca31867a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8051859060ff16601f8110611bf357611bf3613d6f565b602002015115611c2f576040517ff67bc7c400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600185826000015160ff16601f8110611c4a57611c4a613d6f565b9115156020909202015250611c60905081613d9e565b9050611a3e565b505050505050505050505050505050565b611c80611eee565b60005b81811015611cbb57611cab838383818110611ca057611ca0613d6f565b905060a00201611f71565b611cb481613d9e565b9050611c83565b505050565b611cc8611eee565b61076881612994565b611cd9611eee565b61084c85858567ffffffffffffffff86868080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250612a8992505050565b600a5460609060008167ffffffffffffffff811115611d4557611d45613786565b604051908082528060200260200182016040528015611dbc57816020015b6040805160a0810182526000808252602080830182905292820181905260608201819052608082015282527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff909201910181611d635790505b50905060005b82811015611ee7576000600a8281548110611ddf57611ddf613d6f565b6000918252602080832060048304015460039092166008026101000a90910467ffffffffffffffff1680835260098252604092839020835160808082018652825473ffffffffffffffffffffffffffffffffffffffff9081168352600184015481168387019081526002909401548082168489019081527401000000000000000000000000000000000000000090910460ff1615156060808601918252895160a081018b52865185168152965184169887019890985290519091169684019690965293820183905293511515928101929092528551909350859085908110611ec957611ec9613d6f565b6020026020010181905250505080611ee090613d9e565b9050611dc2565b5092915050565b60005473ffffffffffffffffffffffffffffffffffffffff163314611f6f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f4f6e6c792063616c6c61626c65206279206f776e6572000000000000000000006044820152606401610ae5565b565b611f816080820160608301613707565b67ffffffffffffffff16600003611fc4576040517ff89d762900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000611fd36020830183613a7f565b73ffffffffffffffffffffffffffffffffffffffff16148061201a575060006120026040830160208401613a7f565b73ffffffffffffffffffffffffffffffffffffffff16145b8061204a575060006120326060830160408401613a7f565b73ffffffffffffffffffffffffffffffffffffffff16145b15612081576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006009816120966080850160608601613707565b67ffffffffffffffff16815260208101919091526040016000206002015473ffffffffffffffffffffffffffffffffffffffff160361212257600a6120e16080830160608401613707565b8154600181018355600092835260209092206004830401805460039093166008026101000a67ffffffffffffffff8181021990941692909316929092021790555b60408051608081019091528061213b6020840184613a7f565b73ffffffffffffffffffffffffffffffffffffffff1681526020018260200160208101906121699190613a7f565b73ffffffffffffffffffffffffffffffffffffffff1681526020016121946060840160408501613a7f565b73ffffffffffffffffffffffffffffffffffffffff1681526020016121bf60a0840160808501613f0e565b15159052600960006121d76080850160608601613707565b67ffffffffffffffff16815260208082019290925260409081016000208351815473ffffffffffffffffffffffffffffffffffffffff9182167fffffffffffffffffffffffff00000000000000000000000000000000000000009182161783559385015160018301805491831691909516179093559083015160029091018054606094850151151574010000000000000000000000000000000000000000027fffffffffffffffffffffff00000000000000000000000000000000000000000090911692909316919091179190911790556122b89060808301908301613707565b67ffffffffffffffff167fab9bd0e4888101232b8f09dae2952ff59a6eea4a19fbddf2a8ca7b23f0e4cb406122f36040840160208501613a7f565b6123036060850160408601613a7f565b6123106020860186613a7f565b61232060a0870160808801613f0e565b604051612362949392919073ffffffffffffffffffffffffffffffffffffffff9485168152928416602084015292166040820152901515606082015260800190565b60405180910390a250565b67ffffffffffffffff85166000908152600960209081526040918290208251608081018452815473ffffffffffffffffffffffffffffffffffffffff908116825260018301548116938201939093526002909101549182169281019290925274010000000000000000000000000000000000000000900460ff16151560608201819052612432576040517fc9ff038f00000000000000000000000000000000000000000000000000000000815267ffffffffffffffff87166004820152602401610ae5565b602081015181516040517f38314bb200000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff909216916338314bb29161248e9130908990600401613f2b565b6020604051808303816000875af19250505080156124e7575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01682019092526124e491810190613d06565b60015b612570573d808015612515576040519150601f19603f3d011682016040523d82523d6000602084013e61251a565b606091505b508667ffffffffffffffff168367ffffffffffffffff167fa481d91c3f9574c23ee84fef85246354b760a0527a535d6382354e4684703ce38784604051612562929190613f6d565b60405180910390a3506125dd565b8015612588576125838684898888612e5d565b6125d6565b8667ffffffffffffffff168367ffffffffffffffff167f8d3121fe961b40270f336aa75feb1213f1c979a33993311c60da4dd0f24526cf876040516125cd9190613589565b60405180910390a35b505061084c565b6125ea8583888787612e5d565b505050505050565b60405173ffffffffffffffffffffffffffffffffffffffff808516602483015283166044820152606481018290526126ce9085907f23b872dd00000000000000000000000000000000000000000000000000000000906084015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152613044565b50505050565b6000808a8a8a8a8a8a8a8a8a6040516020016126f899989796959493929190613f92565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081840301815291905280516020909101207dffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff167e01000000000000000000000000000000000000000000000000000000000000179150509998505050505050505050565b60405173ffffffffffffffffffffffffffffffffffffffff8316602482015260448101829052611cbb9084907fa9059cbb000000000000000000000000000000000000000000000000000000009060640161264c565b60006127e38385018561412f565b80515160208201515191925090811580156127fc575080155b15612832576040517ebf199700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60005b828110156128de576128ce8460000151828151811061285657612856613d6f565b6020026020010151604001518560000151838151811061287857612878613d6f565b6020026020010151600001518660000151848151811061289a5761289a613d6f565b60200260200101516020015188886000015186815181106128bd576128bd613d6f565b602002602001015160600151612a89565b6128d781613d9e565b9050612835565b5060005b8181101561298b5761297b8460200151828151811061290357612903613d6f565b6020026020010151602001518560200151838151811061292557612925613d6f565b6020026020010151600001518660200151848151811061294757612947613d6f565b6020026020010151606001518760200151858151811061296957612969613d6f565b6020026020010151604001518961236d565b61298481613d9e565b90506128e2565b50505050505050565b3373ffffffffffffffffffffffffffffffffffffffff821603612a13576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f43616e6e6f74207472616e7366657220746f2073656c660000000000000000006044820152606401610ae5565b600180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83811691821790925560008054604051929316917fed8889f560326eb138920d842192f0eb3dd22b4f139c87a2c57538e05bae12789190a350565b6000612a9361064f565b905084811015612ad9576040517fa17e11d50000000000000000000000000000000000000000000000000000000081526004810186905260248101829052604401610ae5565b67ffffffffffffffff86166000908152600960209081526040918290208251608081018452815473ffffffffffffffffffffffffffffffffffffffff908116825260018301548116938201939093526002909101549182169281019290925274010000000000000000000000000000000000000000900460ff16151560608201819052612b9e576040517fc9ff038f00000000000000000000000000000000000000000000000000000000815267ffffffffffffffff88166004820152602401610ae5565b600b546040517f0a861f2a0000000000000000000000000000000000000000000000000000000081526004810188905273ffffffffffffffffffffffffffffffffffffffff90911690630a861f2a90602401600060405180830381600087803b158015612c0a57600080fd5b505af1158015612c1e573d6000803e3d6000fd5b5050505060208101516040517f095ea7b300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9182166004820152602481018890527f00000000000000000000000000000000000000000000000000000000000000009091169063095ea7b3906044016020604051808303816000875af1158015612cbe573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ce29190613d06565b506020810151604080830151835191517fa71d98b700000000000000000000000000000000000000000000000000000000815260009373ffffffffffffffffffffffffffffffffffffffff169263a71d98b7928a92612d6a927f000000000000000000000000000000000000000000000000000000000000000092918e908c906004016142a3565b60006040518083038185885af1158015612d88573d6000803e3d6000fd5b50505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201604052612dcf91908101906142ea565b90508767ffffffffffffffff167f000000000000000000000000000000000000000000000000000000000000000067ffffffffffffffff168667ffffffffffffffff167f2a0b69eaf1b415ca57005b4f87582ddefc6d960325ff30dc62a9b3e1e1e5b8a885600001518b8987604051612e4b9493929190614358565b60405180910390a45050505050505050565b8015612ee5577f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663d0e30db0866040518263ffffffff1660e01b81526004016000604051808303818588803b158015612ecb57600080fd5b505af1158015612edf573d6000803e3d6000fd5b50505050505b600b54612f2c9073ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000008116911687613150565b600b546040517feb521a4c0000000000000000000000000000000000000000000000000000000081526004810187905273ffffffffffffffffffffffffffffffffffffffff9091169063eb521a4c90602401600060405180830381600087803b158015612f9857600080fd5b505af1158015612fac573d6000803e3d6000fd5b505050507f000000000000000000000000000000000000000000000000000000000000000067ffffffffffffffff168367ffffffffffffffff168567ffffffffffffffff167f2a0b69eaf1b415ca57005b4f87582ddefc6d960325ff30dc62a9b3e1e1e5b8a8308987604051806020016040528060008152506040516130359493929190614358565b60405180910390a45050505050565b60006130a6826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff1661324e9092919063ffffffff16565b805190915015611cbb57808060200190518101906130c49190613d06565b611cbb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401610ae5565b6040517fdd62ed3e00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff8381166024830152600091839186169063dd62ed3e90604401602060405180830381865afa1580156131c7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131eb9190613ced565b6131f59190613ed7565b60405173ffffffffffffffffffffffffffffffffffffffff85166024820152604481018290529091506126ce9085907f095ea7b3000000000000000000000000000000000000000000000000000000009060640161264c565b606061325d8484600085613265565b949350505050565b6060824710156132f7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610ae5565b6000808673ffffffffffffffffffffffffffffffffffffffff168587604051613320919061439f565b60006040518083038185875af1925050503d806000811461335d576040519150601f19603f3d011682016040523d82523d6000602084013e613362565b606091505b50915091506133738783838761337e565b979650505050505050565b6060831561341457825160000361340d5773ffffffffffffffffffffffffffffffffffffffff85163b61340d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610ae5565b508161325d565b61325d83838151156134295781518083602001fd5b806040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ae59190613589565b8280548282559060005260206000209081019282156134d7579160200282015b828111156134d757825182547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff90911617825560209092019160019091019061347d565b506134e3929150613506565b5090565b604051806103e00160405280601f906020820280368337509192915050565b5b808211156134e35760008155600101613507565b60005b8381101561353657818101518382015260200161351e565b50506000910152565b6000815180845261355781602086016020860161351b565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b60208152600061359c602083018461353f565b9392505050565b6000602082840312156135b557600080fd5b5035919050565b600060a082840312156135ce57600080fd5b50919050565b6020808252825182820181905260009190848201906040850190845b8181101561361657835167ffffffffffffffff16835292840192918401916001016135f0565b50909695505050505050565b803567ffffffffffffffff8116811461363a57600080fd5b919050565b801515811461076857600080fd5b60008083601f84011261365f57600080fd5b50813567ffffffffffffffff81111561367757600080fd5b60208301915083602082850101111561368f57600080fd5b9250929050565b6000806000806000608086880312156136ae57600080fd5b6136b786613622565b94506020860135935060408601356136ce8161363f565b9250606086013567ffffffffffffffff8111156136ea57600080fd5b6136f68882890161364d565b969995985093965092949392505050565b60006020828403121561371957600080fd5b61359c82613622565b600081518084526020808501945080840160005b8381101561376857815173ffffffffffffffffffffffffffffffffffffffff1687529582019590820190600101613736565b509495945050505050565b60208152600061359c6020830184613722565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040516080810167ffffffffffffffff811182821017156137d8576137d8613786565b60405290565b6040805190810167ffffffffffffffff811182821017156137d8576137d8613786565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff8111828210171561384857613848613786565b604052919050565b600067ffffffffffffffff82111561386a5761386a613786565b5060051b60200190565b73ffffffffffffffffffffffffffffffffffffffff8116811461076857600080fd5b600082601f8301126138a757600080fd5b813560206138bc6138b783613850565b613801565b82815260059290921b840181019181810190868411156138db57600080fd5b8286015b848110156138ff5780356138f281613874565b83529183019183016138df565b509695505050505050565b803560ff8116811461363a57600080fd5b600067ffffffffffffffff82111561393557613935613786565b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b600082601f83011261397257600080fd5b81356139806138b78261391b565b81815284602083860101111561399557600080fd5b816020850160208301376000918101602001919091529392505050565b60008060008060008060c087890312156139cb57600080fd5b863567ffffffffffffffff808211156139e357600080fd5b6139ef8a838b01613896565b97506020890135915080821115613a0557600080fd5b613a118a838b01613896565b9650613a1f60408a0161390a565b95506060890135915080821115613a3557600080fd5b613a418a838b01613961565b9450613a4f60808a01613622565b935060a0890135915080821115613a6557600080fd5b50613a7289828a01613961565b9150509295509295509295565b600060208284031215613a9157600080fd5b813561359c81613874565b60008083601f840112613aae57600080fd5b50813567ffffffffffffffff811115613ac657600080fd5b6020830191508360208260051b850101111561368f57600080fd5b60008060008060008060008060e0898b031215613afd57600080fd5b606089018a811115613b0e57600080fd5b8998503567ffffffffffffffff80821115613b2857600080fd5b613b348c838d0161364d565b909950975060808b0135915080821115613b4d57600080fd5b613b598c838d01613a9c565b909750955060a08b0135915080821115613b7257600080fd5b50613b7f8b828c01613a9c565b999c989b50969995989497949560c00135949350505050565b60008060208385031215613bab57600080fd5b823567ffffffffffffffff80821115613bc357600080fd5b818501915085601f830112613bd757600080fd5b813581811115613be657600080fd5b86602060a083028501011115613bfb57600080fd5b60209290920196919550909350505050565b600080600080600060808688031215613c2557600080fd5b613c2e86613622565b94506020860135935060408601359250606086013567ffffffffffffffff8111156136ea57600080fd5b602080825282518282018190526000919060409081850190868401855b82811015613ce0578151805173ffffffffffffffffffffffffffffffffffffffff90811686528782015181168887015286820151168686015260608082015167ffffffffffffffff169086015260809081015115159085015260a09093019290850190600101613c75565b5091979650505050505050565b600060208284031215613cff57600080fd5b5051919050565b600060208284031215613d1857600080fd5b815161359c8161363f565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b8082028115828204841417613d6957613d69613d23565b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203613dcf57613dcf613d23565b5060010190565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b600063ffffffff808316818103613e1e57613e1e613d23565b6001019392505050565b600061012063ffffffff808d1684528b6020850152808b16604085015250806060840152613e588184018a613722565b90508281036080840152613e6c8189613722565b905060ff871660a084015282810360c0840152613e89818761353f565b905067ffffffffffffffff851660e0840152828103610100840152613eae818561353f565b9c9b505050505050505050505050565b60ff8181168382160190811115613d6957613d69613d23565b80820180821115613d6957613d69613d23565b8183823760009101908152919050565b828152606082602083013760800192915050565b600060208284031215613f2057600080fd5b813561359c8161363f565b600073ffffffffffffffffffffffffffffffffffffffff808616835280851660208401525060606040830152613f64606083018461353f565b95945050505050565b604081526000613f80604083018561353f565b8281036020840152613f64818561353f565b60006101208b835273ffffffffffffffffffffffffffffffffffffffff8b16602084015267ffffffffffffffff808b166040850152816060850152613fd98285018b613722565b91508382036080850152613fed828a613722565b915060ff881660a085015283820360c085015261400a828861353f565b90861660e08501528381036101008501529050613eae818561353f565b600082601f83011261403857600080fd5b813560206140486138b783613850565b82815260059290921b8401810191818101908684111561406757600080fd5b8286015b848110156138ff57803567ffffffffffffffff8082111561408c5760008081fd5b81890191506080807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0848d030112156140c55760008081fd5b6140cd6137b5565b87840135815260406140e0818601613622565b898301526060808601356140f38161363f565b8383015292850135928484111561410c57600091508182fd5b61411a8e8b86890101613961565b9083015250865250505091830191830161406b565b6000602080838503121561414257600080fd5b823567ffffffffffffffff8082111561415a57600080fd5b908401906040828703121561416e57600080fd5b6141766137de565b82358281111561418557600080fd5b8301601f8101881361419657600080fd5b80356141a46138b782613850565b81815260059190911b8201860190868101908a8311156141c357600080fd5b8784015b8381101561426f578035878111156141de57600080fd5b85016080818e037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe001121561421257600080fd5b61421a6137b5565b8a820135815260408201358b82015261423560608301613622565b604082015260808201358981111561424d5760008081fd5b61425b8f8d83860101613961565b6060830152508452509188019188016141c7565b508452505050828401358281111561428657600080fd5b61429288828601614027565b948201949094529695505050505050565b600073ffffffffffffffffffffffffffffffffffffffff8088168352808716602084015280861660408401525083606083015260a0608083015261337360a083018461353f565b6000602082840312156142fc57600080fd5b815167ffffffffffffffff81111561431357600080fd5b8201601f8101841361432457600080fd5b80516143326138b78261391b565b81815285602083850101111561434757600080fd5b613f6482602083016020860161351b565b73ffffffffffffffffffffffffffffffffffffffff8516815283602082015260806040820152600061438d608083018561353f565b8281036060840152613373818561353f565b600082516143b181846020870161351b565b919091019291505056fea164736f6c6343000813000a", } var RebalancerABI = RebalancerMetaData.ABI @@ -504,16 +504,16 @@ func (_Rebalancer *RebalancerTransactorSession) RebalanceLiquidity(chainSelector return _Rebalancer.Contract.RebalanceLiquidity(&_Rebalancer.TransactOpts, chainSelector, amount, nativeBridgeFee, bridgeSpecificPayload) } -func (_Rebalancer *RebalancerTransactor) ReceiveLiquidity(opts *bind.TransactOpts, remoteChainSelector uint64, amount *big.Int, bridgeSpecificPayload []byte) (*types.Transaction, error) { - return _Rebalancer.contract.Transact(opts, "receiveLiquidity", remoteChainSelector, amount, bridgeSpecificPayload) +func (_Rebalancer *RebalancerTransactor) ReceiveLiquidity(opts *bind.TransactOpts, remoteChainSelector uint64, amount *big.Int, shouldWrapNative bool, bridgeSpecificPayload []byte) (*types.Transaction, error) { + return _Rebalancer.contract.Transact(opts, "receiveLiquidity", remoteChainSelector, amount, shouldWrapNative, bridgeSpecificPayload) } -func (_Rebalancer *RebalancerSession) ReceiveLiquidity(remoteChainSelector uint64, amount *big.Int, bridgeSpecificPayload []byte) (*types.Transaction, error) { - return _Rebalancer.Contract.ReceiveLiquidity(&_Rebalancer.TransactOpts, remoteChainSelector, amount, bridgeSpecificPayload) +func (_Rebalancer *RebalancerSession) ReceiveLiquidity(remoteChainSelector uint64, amount *big.Int, shouldWrapNative bool, bridgeSpecificPayload []byte) (*types.Transaction, error) { + return _Rebalancer.Contract.ReceiveLiquidity(&_Rebalancer.TransactOpts, remoteChainSelector, amount, shouldWrapNative, bridgeSpecificPayload) } -func (_Rebalancer *RebalancerTransactorSession) ReceiveLiquidity(remoteChainSelector uint64, amount *big.Int, bridgeSpecificPayload []byte) (*types.Transaction, error) { - return _Rebalancer.Contract.ReceiveLiquidity(&_Rebalancer.TransactOpts, remoteChainSelector, amount, bridgeSpecificPayload) +func (_Rebalancer *RebalancerTransactorSession) ReceiveLiquidity(remoteChainSelector uint64, amount *big.Int, shouldWrapNative bool, bridgeSpecificPayload []byte) (*types.Transaction, error) { + return _Rebalancer.Contract.ReceiveLiquidity(&_Rebalancer.TransactOpts, remoteChainSelector, amount, shouldWrapNative, bridgeSpecificPayload) } func (_Rebalancer *RebalancerTransactor) RemoveLiquidity(opts *bind.TransactOpts, amount *big.Int) (*types.Transaction, error) { @@ -1018,6 +1018,143 @@ func (_Rebalancer *RebalancerFilterer) ParseFinalizationFailed(log types.Log) (* return event, nil } +type RebalancerFinalizationStepCompletedIterator struct { + Event *RebalancerFinalizationStepCompleted + + contract *bind.BoundContract + event string + + logs chan types.Log + sub ethereum.Subscription + done bool + fail error +} + +func (it *RebalancerFinalizationStepCompletedIterator) Next() bool { + + if it.fail != nil { + return false + } + + if it.done { + select { + case log := <-it.logs: + it.Event = new(RebalancerFinalizationStepCompleted) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + + select { + case log := <-it.logs: + it.Event = new(RebalancerFinalizationStepCompleted) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +func (it *RebalancerFinalizationStepCompletedIterator) Error() error { + return it.fail +} + +func (it *RebalancerFinalizationStepCompletedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +type RebalancerFinalizationStepCompleted struct { + OcrSeqNum uint64 + RemoteChainSelector uint64 + BridgeSpecificData []byte + Raw types.Log +} + +func (_Rebalancer *RebalancerFilterer) FilterFinalizationStepCompleted(opts *bind.FilterOpts, ocrSeqNum []uint64, remoteChainSelector []uint64) (*RebalancerFinalizationStepCompletedIterator, error) { + + var ocrSeqNumRule []interface{} + for _, ocrSeqNumItem := range ocrSeqNum { + ocrSeqNumRule = append(ocrSeqNumRule, ocrSeqNumItem) + } + var remoteChainSelectorRule []interface{} + for _, remoteChainSelectorItem := range remoteChainSelector { + remoteChainSelectorRule = append(remoteChainSelectorRule, remoteChainSelectorItem) + } + + logs, sub, err := _Rebalancer.contract.FilterLogs(opts, "FinalizationStepCompleted", ocrSeqNumRule, remoteChainSelectorRule) + if err != nil { + return nil, err + } + return &RebalancerFinalizationStepCompletedIterator{contract: _Rebalancer.contract, event: "FinalizationStepCompleted", logs: logs, sub: sub}, nil +} + +func (_Rebalancer *RebalancerFilterer) WatchFinalizationStepCompleted(opts *bind.WatchOpts, sink chan<- *RebalancerFinalizationStepCompleted, ocrSeqNum []uint64, remoteChainSelector []uint64) (event.Subscription, error) { + + var ocrSeqNumRule []interface{} + for _, ocrSeqNumItem := range ocrSeqNum { + ocrSeqNumRule = append(ocrSeqNumRule, ocrSeqNumItem) + } + var remoteChainSelectorRule []interface{} + for _, remoteChainSelectorItem := range remoteChainSelector { + remoteChainSelectorRule = append(remoteChainSelectorRule, remoteChainSelectorItem) + } + + logs, sub, err := _Rebalancer.contract.WatchLogs(opts, "FinalizationStepCompleted", ocrSeqNumRule, remoteChainSelectorRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + + event := new(RebalancerFinalizationStepCompleted) + if err := _Rebalancer.contract.UnpackLog(event, "FinalizationStepCompleted", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +func (_Rebalancer *RebalancerFilterer) ParseFinalizationStepCompleted(log types.Log) (*RebalancerFinalizationStepCompleted, error) { + event := new(RebalancerFinalizationStepCompleted) + if err := _Rebalancer.contract.UnpackLog(event, "FinalizationStepCompleted", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + type RebalancerLiquidityAddedToContainerIterator struct { Event *RebalancerLiquidityAddedToContainer @@ -2093,6 +2230,8 @@ func (_Rebalancer *Rebalancer) ParseLog(log types.Log) (generated.AbigenLog, err return _Rebalancer.ParseCrossChainRebalancerSet(log) case _Rebalancer.abi.Events["FinalizationFailed"].ID: return _Rebalancer.ParseFinalizationFailed(log) + case _Rebalancer.abi.Events["FinalizationStepCompleted"].ID: + return _Rebalancer.ParseFinalizationStepCompleted(log) case _Rebalancer.abi.Events["LiquidityAddedToContainer"].ID: return _Rebalancer.ParseLiquidityAddedToContainer(log) case _Rebalancer.abi.Events["LiquidityContainerSet"].ID: @@ -2127,6 +2266,10 @@ func (RebalancerFinalizationFailed) Topic() common.Hash { return common.HexToHash("0xa481d91c3f9574c23ee84fef85246354b760a0527a535d6382354e4684703ce3") } +func (RebalancerFinalizationStepCompleted) Topic() common.Hash { + return common.HexToHash("0x8d3121fe961b40270f336aa75feb1213f1c979a33993311c60da4dd0f24526cf") +} + func (RebalancerLiquidityAddedToContainer) Topic() common.Hash { return common.HexToHash("0x5414b81d05ac3542606f164e16a9a107d05d21e906539cc5ceb61d7b6b707eb5") } @@ -2198,7 +2341,7 @@ type RebalancerInterface interface { RebalanceLiquidity(opts *bind.TransactOpts, chainSelector uint64, amount *big.Int, nativeBridgeFee *big.Int, bridgeSpecificPayload []byte) (*types.Transaction, error) - ReceiveLiquidity(opts *bind.TransactOpts, remoteChainSelector uint64, amount *big.Int, bridgeSpecificPayload []byte) (*types.Transaction, error) + ReceiveLiquidity(opts *bind.TransactOpts, remoteChainSelector uint64, amount *big.Int, shouldWrapNative bool, bridgeSpecificPayload []byte) (*types.Transaction, error) RemoveLiquidity(opts *bind.TransactOpts, amount *big.Int) (*types.Transaction, error) @@ -2236,6 +2379,12 @@ type RebalancerInterface interface { ParseFinalizationFailed(log types.Log) (*RebalancerFinalizationFailed, error) + FilterFinalizationStepCompleted(opts *bind.FilterOpts, ocrSeqNum []uint64, remoteChainSelector []uint64) (*RebalancerFinalizationStepCompletedIterator, error) + + WatchFinalizationStepCompleted(opts *bind.WatchOpts, sink chan<- *RebalancerFinalizationStepCompleted, ocrSeqNum []uint64, remoteChainSelector []uint64) (event.Subscription, error) + + ParseFinalizationStepCompleted(log types.Log) (*RebalancerFinalizationStepCompleted, error) + FilterLiquidityAddedToContainer(opts *bind.FilterOpts, provider []common.Address, amount []*big.Int) (*RebalancerLiquidityAddedToContainerIterator, error) WatchLiquidityAddedToContainer(opts *bind.WatchOpts, sink chan<- *RebalancerLiquidityAddedToContainer, provider []common.Address, amount []*big.Int) (event.Subscription, error) diff --git a/core/gethwrappers/rebalancer/generated/rebalancer_report_encoder/rebalancer_report_encoder.go b/core/gethwrappers/rebalancer/generated/rebalancer_report_encoder/rebalancer_report_encoder.go index ca36f9f960..a61729b7dd 100644 --- a/core/gethwrappers/rebalancer/generated/rebalancer_report_encoder/rebalancer_report_encoder.go +++ b/core/gethwrappers/rebalancer/generated/rebalancer_report_encoder/rebalancer_report_encoder.go @@ -44,6 +44,7 @@ type IRebalancerLiquidityInstructions struct { type IRebalancerReceiveLiquidityParams struct { Amount *big.Int RemoteChainSelector uint64 + ShouldWrapNative bool BridgeData []byte } @@ -55,7 +56,7 @@ type IRebalancerSendLiquidityParams struct { } var RebalancerReportEncoderMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[{\"components\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nativeBridgeFee\",\"type\":\"uint256\"},{\"internalType\":\"uint64\",\"name\":\"remoteChainSelector\",\"type\":\"uint64\"},{\"internalType\":\"bytes\",\"name\":\"bridgeData\",\"type\":\"bytes\"}],\"internalType\":\"structIRebalancer.SendLiquidityParams[]\",\"name\":\"sendLiquidityParams\",\"type\":\"tuple[]\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"uint64\",\"name\":\"remoteChainSelector\",\"type\":\"uint64\"},{\"internalType\":\"bytes\",\"name\":\"bridgeData\",\"type\":\"bytes\"}],\"internalType\":\"structIRebalancer.ReceiveLiquidityParams[]\",\"name\":\"receiveLiquidityParams\",\"type\":\"tuple[]\"}],\"internalType\":\"structIRebalancer.LiquidityInstructions\",\"name\":\"instructions\",\"type\":\"tuple\"}],\"name\":\"exposeForEncoding\",\"outputs\":[],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getAllCrossChainRebalancers\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"remoteRebalancer\",\"type\":\"address\"},{\"internalType\":\"contractIBridgeAdapter\",\"name\":\"localBridge\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"remoteToken\",\"type\":\"address\"},{\"internalType\":\"uint64\",\"name\":\"remoteChainSelector\",\"type\":\"uint64\"},{\"internalType\":\"bool\",\"name\":\"enabled\",\"type\":\"bool\"}],\"internalType\":\"structIRebalancer.CrossChainRebalancerArgs[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getLiquidity\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"currentLiquidity\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]", + ABI: "[{\"inputs\":[{\"components\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nativeBridgeFee\",\"type\":\"uint256\"},{\"internalType\":\"uint64\",\"name\":\"remoteChainSelector\",\"type\":\"uint64\"},{\"internalType\":\"bytes\",\"name\":\"bridgeData\",\"type\":\"bytes\"}],\"internalType\":\"structIRebalancer.SendLiquidityParams[]\",\"name\":\"sendLiquidityParams\",\"type\":\"tuple[]\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"uint64\",\"name\":\"remoteChainSelector\",\"type\":\"uint64\"},{\"internalType\":\"bool\",\"name\":\"shouldWrapNative\",\"type\":\"bool\"},{\"internalType\":\"bytes\",\"name\":\"bridgeData\",\"type\":\"bytes\"}],\"internalType\":\"structIRebalancer.ReceiveLiquidityParams[]\",\"name\":\"receiveLiquidityParams\",\"type\":\"tuple[]\"}],\"internalType\":\"structIRebalancer.LiquidityInstructions\",\"name\":\"instructions\",\"type\":\"tuple\"}],\"name\":\"exposeForEncoding\",\"outputs\":[],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getAllCrossChainRebalancers\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"remoteRebalancer\",\"type\":\"address\"},{\"internalType\":\"contractIBridgeAdapter\",\"name\":\"localBridge\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"remoteToken\",\"type\":\"address\"},{\"internalType\":\"uint64\",\"name\":\"remoteChainSelector\",\"type\":\"uint64\"},{\"internalType\":\"bool\",\"name\":\"enabled\",\"type\":\"bool\"}],\"internalType\":\"structIRebalancer.CrossChainRebalancerArgs[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getLiquidity\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"currentLiquidity\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]", } var RebalancerReportEncoderABI = RebalancerReportEncoderMetaData.ABI diff --git a/core/gethwrappers/rebalancer/generation/generated-wrapper-dependency-versions-do-not-edit.txt b/core/gethwrappers/rebalancer/generation/generated-wrapper-dependency-versions-do-not-edit.txt index b069c51ae5..dfc1f79280 100644 --- a/core/gethwrappers/rebalancer/generation/generated-wrapper-dependency-versions-do-not-edit.txt +++ b/core/gethwrappers/rebalancer/generation/generated-wrapper-dependency-versions-do-not-edit.txt @@ -3,26 +3,26 @@ abstract_arbitrum_token_gateway: ../../../contracts/solc/v0.8.19/IAbstractArbitr arb_node_interface: ../../../contracts/solc/v0.8.19/INodeInterface/INodeInterface.abi ../../../contracts/solc/v0.8.19/INodeInterface/INodeInterface.bin c72f9e9d1e9b9c371c42817590a490a327e743775f423d9417982914d6136ff7 arbitrum_gateway_router: ../../../contracts/solc/v0.8.19/IArbitrumGatewayRouter/IArbitrumGatewayRouter.abi ../../../contracts/solc/v0.8.19/IArbitrumGatewayRouter/IArbitrumGatewayRouter.bin d02c8ed0b4bfe50630e0fce452f9aef23d394bd28110314356954185a6544cb8 arbitrum_inbox: ../../../contracts/solc/v0.8.19/IArbitrumInbox/IArbitrumInbox.abi ../../../contracts/solc/v0.8.19/IArbitrumInbox/IArbitrumInbox.bin 815c2ba12fadd3a6961330d746645dd1920a06253ce9555b46b4c8526065dbaf -arbitrum_l1_bridge_adapter: ../../../contracts/solc/v0.8.19/ArbitrumL1BridgeAdapter/ArbitrumL1BridgeAdapter.abi ../../../contracts/solc/v0.8.19/ArbitrumL1BridgeAdapter/ArbitrumL1BridgeAdapter.bin 856f6474529c093635f30b9b73d088d11c5adee7db83d5d5e9e992c3855b147d +arbitrum_l1_bridge_adapter: ../../../contracts/solc/v0.8.19/ArbitrumL1BridgeAdapter/ArbitrumL1BridgeAdapter.abi ../../../contracts/solc/v0.8.19/ArbitrumL1BridgeAdapter/ArbitrumL1BridgeAdapter.bin 210a71d10c63139b07c96a094f5018817da6df8bfff759dcb07017d2d1e67bd4 arbitrum_l1_gateway_router: ../../../contracts/solc/v0.8.19/IArbitrumL1GatewayRouter/IArbitrumL1GatewayRouter.abi ../../../contracts/solc/v0.8.19/IArbitrumL1GatewayRouter/IArbitrumL1GatewayRouter.bin 48b098f0667521be7c4a31f2c361a2898536c5ab5406c18c2cedf8c8238909ad -arbitrum_l2_bridge_adapter: ../../../contracts/solc/v0.8.19/ArbitrumL2BridgeAdapter/ArbitrumL2BridgeAdapter.abi ../../../contracts/solc/v0.8.19/ArbitrumL2BridgeAdapter/ArbitrumL2BridgeAdapter.bin 295ccfe115efa538db634135ed9cc86c8b54921752169bf023a8a59db579a662 +arbitrum_l2_bridge_adapter: ../../../contracts/solc/v0.8.19/ArbitrumL2BridgeAdapter/ArbitrumL2BridgeAdapter.abi ../../../contracts/solc/v0.8.19/ArbitrumL2BridgeAdapter/ArbitrumL2BridgeAdapter.bin ae7b329409f84ddaece62b92028616215ed106b8bacf18d6221c1d8693f39ebf arbitrum_rollup_core: ../../../contracts/solc/v0.8.19/IArbRollupCore/IArbRollupCore.abi ../../../contracts/solc/v0.8.19/IArbRollupCore/IArbRollupCore.bin 18ebdef208265cde0cde8671214840afdffaf57b5d82627d18604727b6210fa6 arbitrum_token_gateway: ../../../contracts/solc/v0.8.19/IArbitrumTokenGateway/IArbitrumTokenGateway.abi ../../../contracts/solc/v0.8.19/IArbitrumTokenGateway/IArbitrumTokenGateway.bin c3d42c4f174317fe06f96435952ebe7ca8b042c787a61bf3f69060c00c396eae arbsys: ../../../contracts/solc/v0.8.19/IArbSys/IArbSys.abi ../../../contracts/solc/v0.8.19/IArbSys/IArbSys.bin 70adb49f157d8e077485d1a5c87ddf64b214822aef736bb68e122a77bab78a16 l2_arbitrum_gateway: ../../../contracts/solc/v0.8.19/IL2ArbitrumGateway/IL2ArbitrumGateway.abi ../../../contracts/solc/v0.8.19/IL2ArbitrumGateway/IL2ArbitrumGateway.bin 4d1af2bdb0aeb0b15e3cbc4ed2158f9bcba4925f68ed3669e0ecfde14115c893 l2_arbitrum_messenger: ../../../contracts/solc/v0.8.19/IL2ArbitrumMessenger/IL2ArbitrumMessenger.abi ../../../contracts/solc/v0.8.19/IL2ArbitrumMessenger/IL2ArbitrumMessenger.bin 84d4bfedf16e92e3fb15880832fa54a3a21808dffea8a7c0946cde3b5e17a0c3 -mock_l1_bridge_adapter: ../../../contracts/solc/v0.8.19/MockBridgeAdapter/MockL1BridgeAdapter.abi ../../../contracts/solc/v0.8.19/MockBridgeAdapter/MockL1BridgeAdapter.bin fb2f863373364f3a4d77b208157e52d87c56b74050ce78cb8830656be2cc2051 -mock_l2_bridge_adapter: ../../../contracts/solc/v0.8.19/MockBridgeAdapter/MockL2BridgeAdapter.abi ../../../contracts/solc/v0.8.19/MockBridgeAdapter/MockL2BridgeAdapter.bin 229a123993c0194abb2901488ebc1730da64cbe2e5c0c4cc86bc63d325c77884 +mock_l1_bridge_adapter: ../../../contracts/solc/v0.8.19/MockBridgeAdapter/MockL1BridgeAdapter.abi ../../../contracts/solc/v0.8.19/MockBridgeAdapter/MockL1BridgeAdapter.bin bdf2dcc0dff76de9aa8eb3eee8cce23c426577aa511b581c30b95ed0178c4041 +mock_l2_bridge_adapter: ../../../contracts/solc/v0.8.19/MockBridgeAdapter/MockL2BridgeAdapter.abi ../../../contracts/solc/v0.8.19/MockBridgeAdapter/MockL2BridgeAdapter.bin ae85dc829dcd8fbe37f7b439c4c7c6f462fedb14254c86beafa30ba28f7b5ac6 no_op_ocr3: ../../../contracts/solc/v0.8.19/NoOpOCR3/NoOpOCR3.abi ../../../contracts/solc/v0.8.19/NoOpOCR3/NoOpOCR3.bin 3a5ef6a7a6502339d7965b44debb5536ee9b6d2181985e52d905307315c0a853 optimism_cross_domain_messenger: ../../../contracts/solc/v0.8.19/IOptimismCrossDomainMessenger/IOptimismCrossDomainMessenger.abi ../../../contracts/solc/v0.8.19/IOptimismCrossDomainMessenger/IOptimismCrossDomainMessenger.bin cfc9724d20c87eb0c567efb6f7cad7d0039a929e518c9de18afdaaea6160be4d optimism_dispute_game_factory: ../../../contracts/solc/v0.8.19/IOptimismDisputeGameFactory/IOptimismDisputeGameFactory.abi ../../../contracts/solc/v0.8.19/IOptimismDisputeGameFactory/IOptimismDisputeGameFactory.bin d4bcd96a87fdc6316b3788bd33eb8d96140002f7716b123a03ba4196a5aeeb72 -optimism_l1_bridge_adapter: ../../../contracts/solc/v0.8.19/OptimismL1BridgeAdapter/OptimismL1BridgeAdapter.abi ../../../contracts/solc/v0.8.19/OptimismL1BridgeAdapter/OptimismL1BridgeAdapter.bin 00028fd87f8b7bdbfcf816d9addbbdd55947d0f88ce1d1227068293a33a086b4 +optimism_l1_bridge_adapter: ../../../contracts/solc/v0.8.19/OptimismL1BridgeAdapter/OptimismL1BridgeAdapter.abi ../../../contracts/solc/v0.8.19/OptimismL1BridgeAdapter/OptimismL1BridgeAdapter.bin c84219280f8eee1f2804080f47cedc882633364d11cb27a8b097006f5da06ab8 optimism_l1_bridge_adapter_encoder: ../../../contracts/solc/v0.8.19/OptimismL1BridgeAdapterEncoder/OptimismL1BridgeAdapterEncoder.abi ../../../contracts/solc/v0.8.19/OptimismL1BridgeAdapterEncoder/OptimismL1BridgeAdapterEncoder.bin 449f12408130b7d0a17aa1da14b5bbae7f22d90307422992ebf26c7fe93b85f2 -optimism_l2_bridge_adapter: ../../../contracts/solc/v0.8.19/OptimismL2BridgeAdapter/OptimismL2BridgeAdapter.abi ../../../contracts/solc/v0.8.19/OptimismL2BridgeAdapter/OptimismL2BridgeAdapter.bin 80837b741da787dc69e79597b73b4757ce1253af5eff4044c8974908b91eb664 +optimism_l2_bridge_adapter: ../../../contracts/solc/v0.8.19/OptimismL2BridgeAdapter/OptimismL2BridgeAdapter.abi ../../../contracts/solc/v0.8.19/OptimismL2BridgeAdapter/OptimismL2BridgeAdapter.bin 21a797ec70e1ac735f9b1b00b3bdf80bdbb9c5249468af84c408274814694145 optimism_l2_output_oracle: ../../../contracts/solc/v0.8.19/IOptimismL2OutputOracle/IOptimismL2OutputOracle.abi ../../../contracts/solc/v0.8.19/IOptimismL2OutputOracle/IOptimismL2OutputOracle.bin c89386866c41c4b31fed4b8b945ba27aa8258ad472968da98a81448a8a95e43c optimism_l2_to_l1_message_passer: ../../../contracts/solc/v0.8.19/IOptimismL2ToL1MessagePasser/IOptimismL2ToL1MessagePasser.abi ../../../contracts/solc/v0.8.19/IOptimismL2ToL1MessagePasser/IOptimismL2ToL1MessagePasser.bin 51f4568aa734c564a9aa82169f06e974e30650aeccbd07b20b0c8c60d48459fd optimism_portal: ../../../contracts/solc/v0.8.19/IOptimismPortal/IOptimismPortal.abi ../../../contracts/solc/v0.8.19/IOptimismPortal/IOptimismPortal.bin a644f108c9267f16bcea1648c8935e0e3741484b9b9ba7e87e0c2cb02bd0839f optimism_portal_2: ../../../contracts/solc/v0.8.19/IOptimismPortal2/IOptimismPortal2.abi ../../../contracts/solc/v0.8.19/IOptimismPortal2/IOptimismPortal2.bin 5f6785b0df74dd78fe10b7ec015742b4d28e2c742e339f23e3d9a6f8db0d15e9 -rebalancer: ../../../contracts/solc/v0.8.19/Rebalancer/Rebalancer.abi ../../../contracts/solc/v0.8.19/Rebalancer/Rebalancer.bin 09c7d564eec385587242bb345959e6013214ad2efc85934930d5a214f809b024 +rebalancer: ../../../contracts/solc/v0.8.19/Rebalancer/Rebalancer.abi ../../../contracts/solc/v0.8.19/Rebalancer/Rebalancer.bin c9aade6b19daaac8cd7e92016432869d51aac514be06ff20f6d9eec50b2f8c1d rebalancer_interface: ../../../contracts/solc/v0.8.19/IRebalancer/IRebalancer.abi ../../../contracts/solc/v0.8.19/IRebalancer/IRebalancer.bin 35fac5f725a6b974303bb0cb2c6e9004303ded549186fee6626b9d70ab973903 -rebalancer_report_encoder: ../../../contracts/solc/v0.8.19/RebalancerReportEncoder/RebalancerReportEncoder.abi ../../../contracts/solc/v0.8.19/RebalancerReportEncoder/RebalancerReportEncoder.bin a5f9ecfbea589f98c5b3c6d2044def803342249fcb9fec9507a1e95e84b4325b +rebalancer_report_encoder: ../../../contracts/solc/v0.8.19/RebalancerReportEncoder/RebalancerReportEncoder.abi ../../../contracts/solc/v0.8.19/RebalancerReportEncoder/RebalancerReportEncoder.bin 1a077f3e21c67304e6648c0ac5e652e86c88d2b9bf206ba9c0f4b4a4cdfc43c9 diff --git a/core/scripts/ccip/rebalancer/arb/send_to_l2.go b/core/scripts/ccip/rebalancer/arb/send_to_l2.go index db2cab25bc..d31b31bc02 100644 --- a/core/scripts/ccip/rebalancer/arb/send_to_l2.go +++ b/core/scripts/ccip/rebalancer/arb/send_to_l2.go @@ -218,7 +218,7 @@ func estimateAll(env multienv.Env, l1ChainID, l2ChainID uint64, rd RetryableData maxSubmissionFee := estimateSubmissionFee(env.Clients[l1ChainID], l1ChainID, l1BaseFee, uint64(len(rd.Data))) - gasLimit := estimateRetryableGasLimit(env, l2Client, l2ChainID, rd) + gasLimit := estimateRetryableGasLimit(l2Client, l2ChainID, rd) deposit := new(big.Int).Mul(gasLimit, l2MaxFeePerGas) deposit = deposit.Add(deposit, maxSubmissionFee) @@ -237,7 +237,7 @@ func estimateAll(env multienv.Env, l1ChainID, l2ChainID uint64, rd RetryableData } } -func estimateRetryableGasLimit(env multienv.Env, l2Client *ethclient.Client, l2ChainID uint64, rd RetryableData) *big.Int { +func estimateRetryableGasLimit(l2Client *ethclient.Client, l2ChainID uint64, rd RetryableData) *big.Int { packed, err := nodeInterfaceABI.Pack("estimateRetryableTicket", rd.From, assets.Ether(1).ToInt(), // this is what is done in the SDK, not sure why yet diff --git a/core/scripts/ccip/rebalancer/main.go b/core/scripts/ccip/rebalancer/main.go index c9fd46c9b9..ad2853bf8e 100644 --- a/core/scripts/ccip/rebalancer/main.go +++ b/core/scripts/ccip/rebalancer/main.go @@ -330,6 +330,8 @@ func main() { tx, err := weth.Transfer(env.Transactors[*chainID], common.HexToAddress(*toAddress), decimal.RequireFromString(*amount).BigInt()) helpers.PanicErr(err) helpers.ConfirmTXMined(context.Background(), env.Clients[*chainID], tx, int64(*chainID)) + + // Optimism specific commands case "deploy-op-l1-adapter": cmd := flag.NewFlagSet("deploy-op-l1-adapter", flag.ExitOnError) l1ChainID := cmd.Uint64("l1-chain-id", 0, "L1 Chain ID") @@ -432,8 +434,106 @@ func main() { *l1ChainID, *l2ChainID, common.HexToAddress(*l1BridgeAdapterAddress), - opstack.OptimismContracts[*l1ChainID]["OptimismPortal"], common.HexToHash(*l2TxHash)) + + // operations through the rebalancer contract instead of the adapters. + case "op-send-to-l2-via-rebalancer": + cmd := flag.NewFlagSet("op-send-to-l2-via-rebalancer", flag.ExitOnError) + l1ChainID := cmd.Uint64("l1-chain-id", 0, "L1 Chain ID") + l1RebalancerAddress := cmd.String("l1-rebalancer-address", "", "L1 Rebalancer Address") + remoteChainID := cmd.Uint64("remote-chain-id", 0, "Remote Chain ID") + amount := cmd.String("amount", "1", "Amount") + helpers.ParseArgs(cmd, os.Args[2:], "l1-chain-id", "l1-rebalancer-address", "remote-chain-id") + + env := multienv.New(false, false) + opstack.SendToL2ViaRebalancer( + env, + *l1ChainID, + *remoteChainID, + common.HexToAddress(*l1RebalancerAddress), + decimal.RequireFromString(*amount).BigInt(), + ) + case "op-receive-on-l2-via-rebalancer": + cmd := flag.NewFlagSet("op-receive-on-l2-via-rebalancer", flag.ExitOnError) + l2ChainID := cmd.Uint64("l2-chain-id", 0, "L2 Chain ID") + l2RebalancerAddress := cmd.String("l2-rebalancer-address", "", "L2 Rebalancer Address") + remoteChainID := cmd.Uint64("remote-chain-id", 0, "Remote Chain ID") + amount := cmd.String("amount", "1", "Amount") + shouldWrapNative := cmd.Bool("should-wrap-native", false, "Should wrap native") + helpers.ParseArgs(cmd, os.Args[2:], "l2-chain-id", "l2-rebalancer-address", "remote-chain-id", "amount") + + env := multienv.New(false, false) + l2Rebalancer, err := rebalancer.NewRebalancer(common.HexToAddress(*l2RebalancerAddress), env.Clients[*l2ChainID]) + helpers.PanicErr(err) + + tx, err := l2Rebalancer.ReceiveLiquidity( + env.Transactors[*l2ChainID], + mustGetChainByEvmID(*remoteChainID).Selector, + decimal.RequireFromString(*amount).BigInt(), + *shouldWrapNative, + []byte{}, // no bridge specific payload for receiving liquidity on OP L2 + ) + helpers.PanicErr(err) + helpers.ConfirmTXMined(context.Background(), env.Clients[*l2ChainID], tx, int64(*l2ChainID), + "ReceiveLiquidity", *amount, "wei from", fmt.Sprintf("chain %d", *remoteChainID)) + case "op-withdraw-to-l1-via-rebalancer": + cmd := flag.NewFlagSet("op-withdraw-to-l1-via-rebalancer", flag.ExitOnError) + l2ChainID := cmd.Uint64("l2-chain-id", 0, "L2 Chain ID") + l2RebalancerAddress := cmd.String("l2-rebalancer-address", "", "L2 Rebalancer Address") + remoteChainID := cmd.Uint64("remote-chain-id", 0, "Remote Chain ID") + amount := cmd.String("amount", "1", "Amount") + helpers.ParseArgs(cmd, os.Args[2:], "l2-chain-id", "l2-rebalancer-address", "remote-chain-id", "amount") + + env := multienv.New(false, false) + opstack.WithdrawFromL2ViaRebalancer( + env, + *l2ChainID, + *remoteChainID, + common.HexToAddress(*l2RebalancerAddress), + decimal.RequireFromString(*amount).BigInt(), + ) + case "op-prove-withdrawal-on-l1-via-rebalancer": + cmd := flag.NewFlagSet("op-prove-withdrawal-on-l1-via-rebalancer", flag.ExitOnError) + l1ChainID := cmd.Uint64("l1-chain-id", 0, "L1 Chain ID") + l2ChainID := cmd.Uint64("l2-chain-id", 0, "L2 Chain ID") + l2TxHash := cmd.String("l2-tx-hash", "", "L2 Tx Hash") + l1RebalancerAddress := cmd.String("l1-rebalancer-address", "", "L1 Rebalancer Address") + remoteChainID := cmd.Uint64("remote-chain-id", 0, "Remote Chain ID") + amount := cmd.String("amount", "1", "Amount") + helpers.ParseArgs(cmd, os.Args[2:], "l1-chain-id", "l2-chain-id", "l2-tx-hash", "l1-rebalancer-address", "remote-chain-id", "amount") + + env := multienv.New(false, false) + opstack.ProveWithdrawalViaRebalancer( + env, + *l1ChainID, + *l2ChainID, + *remoteChainID, + decimal.RequireFromString(*amount).BigInt(), + common.HexToAddress(*l1RebalancerAddress), + opstack.OptimismContracts[*l1ChainID]["L2OutputOracle"], + opstack.OptimismContracts[*l1ChainID]["OptimismPortal"], + common.HexToHash(*l2TxHash), + ) + case "op-finalize-withdrawal-on-l1-via-rebalancer": + cmd := flag.NewFlagSet("op-finalize-withdrawal-on-l1-via-rebalancer", flag.ExitOnError) + l1ChainID := cmd.Uint64("l1-chain-id", 0, "L1 Chain ID") + l2ChainID := cmd.Uint64("l2-chain-id", 0, "L2 Chain ID") + l2TxHash := cmd.String("l2-tx-hash", "", "L2 Tx Hash") + l1RebalancerAddress := cmd.String("l1-rebalancer-address", "", "L1 Rebalancer Address") + remoteChainID := cmd.Uint64("remote-chain-id", 0, "Remote Chain ID") + amount := cmd.String("amount", "1", "Amount") + helpers.ParseArgs(cmd, os.Args[2:], "l1-chain-id", "l2-chain-id", "l2-tx-hash", "l1-rebalancer-address", "remote-chain-id", "amount") + + env := multienv.New(false, false) + opstack.FinalizeWithdrawalViaRebalancer( + env, + *l1ChainID, + *l2ChainID, + *remoteChainID, + decimal.RequireFromString(*amount).BigInt(), + common.HexToAddress(*l1RebalancerAddress), + common.HexToHash(*l2TxHash), + ) } } diff --git a/core/scripts/ccip/rebalancer/opstack/finalize.go b/core/scripts/ccip/rebalancer/opstack/finalize.go index 9a51a79bd9..a746bc746f 100644 --- a/core/scripts/ccip/rebalancer/opstack/finalize.go +++ b/core/scripts/ccip/rebalancer/opstack/finalize.go @@ -3,13 +3,17 @@ package opstack import ( "context" "fmt" + "math/big" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/ethclient" + chainsel "github.com/smartcontractkit/chain-selectors" "github.com/smartcontractkit/chainlink/core/scripts/ccip/rebalancer/multienv" helpers "github.com/smartcontractkit/chainlink/core/scripts/common" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/rebalancer/generated/optimism_l1_bridge_adapter" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/rebalancer/generated/optimism_l1_bridge_adapter_encoder" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/rebalancer/generated/rebalancer" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/rebalancer/bridge/opstack/withdrawprover" ) @@ -22,8 +26,7 @@ func FinalizeL1( env multienv.Env, l1ChainID, l2ChainID uint64, - l1BridgeAdapterAddress, - optimismPortalAddress common.Address, + l1BridgeAdapterAddress common.Address, l2TxHash common.Hash, ) { l1Client, ok := env.Clients[l1ChainID] @@ -36,6 +39,64 @@ func FinalizeL1( panic(fmt.Sprintf("No L2 client found for chain ID %d", l2ChainID)) } + l1Adapter, err := optimism_l1_bridge_adapter.NewOptimismL1BridgeAdapter(l1BridgeAdapterAddress, l1Client) + helpers.PanicErr(err) + + encodedPayload := finalizationPayload(l2Client, l2TxHash) + + tx, err := l1Adapter.FinalizeWithdrawERC20( + env.Transactors[l1ChainID], + common.Address{}, // not used + common.Address{}, // not used + encodedPayload, // finalization payload + ) + helpers.PanicErr(err) + + helpers.ConfirmTXMined(context.Background(), env.Clients[l1ChainID], tx, int64(l1ChainID), "FinalizeWithdrawalTransaction") +} + +func FinalizeWithdrawalViaRebalancer( + env multienv.Env, + l1ChainID, + l2ChainID, + remoteChainID uint64, + amount *big.Int, + l1RebalancerAddress common.Address, + l2TxHash common.Hash, +) { + remoteChain, ok := chainsel.ChainByEvmChainID(remoteChainID) + if !ok { + panic(fmt.Sprintf("Chain ID %d not found in chain selectors", remoteChainID)) + } + + l1Client, ok := env.Clients[l1ChainID] + if !ok { + panic(fmt.Sprintf("No L1 client found for chain ID %d", l1ChainID)) + } + + l2Client, ok := env.Clients[l2ChainID] + if !ok { + panic(fmt.Sprintf("No L2 client found for chain ID %d", l2ChainID)) + } + + l1Rebalancer, err := rebalancer.NewRebalancer(l1RebalancerAddress, l1Client) + helpers.PanicErr(err) + + encodedPayload := finalizationPayload(l2Client, l2TxHash) + + tx, err := l1Rebalancer.ReceiveLiquidity( + env.Transactors[l1ChainID], + remoteChain.Selector, + amount, + true, // shouldWrapNative + encodedPayload, + ) + helpers.PanicErr(err) + + helpers.ConfirmTXMined(context.Background(), env.Clients[l1ChainID], tx, int64(l1ChainID), "FinalizeWithdrawalTransaction") +} + +func finalizationPayload(l2Client *ethclient.Client, l2TxHash common.Hash) []byte { receipt, err := l2Client.TransactionReceipt(context.Background(), l2TxHash) helpers.PanicErr(err) @@ -47,9 +108,6 @@ func FinalizeL1( messagePassed, err := withdrawprover.ParseMessagePassedLog(messagePassedLog) helpers.PanicErr(err) - l1Adapter, err := optimism_l1_bridge_adapter.NewOptimismL1BridgeAdapter(l1BridgeAdapterAddress, l1Client) - helpers.PanicErr(err) - encodedFinalizeWithdrawal, err := encoderABI.Methods["encodeOptimismFinalizationPayload"].Inputs.Pack( optimism_l1_bridge_adapter_encoder.OptimismL1BridgeAdapterOptimismFinalizationPayload{ WithdrawalTransaction: optimism_l1_bridge_adapter_encoder.TypesWithdrawalTransaction{ @@ -73,13 +131,5 @@ func FinalizeL1( ) helpers.PanicErr(err) - tx, err := l1Adapter.FinalizeWithdrawERC20( - env.Transactors[l1ChainID], - common.Address{}, // not used - common.Address{}, // not used - encodedPayload, // finalization payload - ) - helpers.PanicErr(err) - - helpers.ConfirmTXMined(context.Background(), env.Clients[l1ChainID], tx, int64(l1ChainID), "FinalizeWithdrawalTransaction") + return encodedPayload } diff --git a/core/scripts/ccip/rebalancer/opstack/prove_withdrawal.go b/core/scripts/ccip/rebalancer/opstack/prove_withdrawal.go index 4ea2a275db..e1c75560a1 100644 --- a/core/scripts/ccip/rebalancer/opstack/prove_withdrawal.go +++ b/core/scripts/ccip/rebalancer/opstack/prove_withdrawal.go @@ -3,16 +3,20 @@ package opstack import ( "context" "fmt" + "math/big" "strings" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/ethclient" + chainsel "github.com/smartcontractkit/chain-selectors" + "github.com/smartcontractkit/chainlink/core/scripts/ccip/rebalancer/multienv" helpers "github.com/smartcontractkit/chainlink/core/scripts/common" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/rebalancer/generated/optimism_l1_bridge_adapter" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/rebalancer/generated/optimism_l1_bridge_adapter_encoder" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/rebalancer/generated/rebalancer" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/abihelpers" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/rebalancer/bridge/opstack/withdrawprover" ) @@ -38,17 +42,69 @@ func ProveWithdrawal( if !ok { panic(fmt.Sprintf("No client found for chain %d, map: %+v", l1ChainID, env.Clients)) } - proveMessage(env, l1Client, l2Client, l2TxHash, optimismPortalAddress, l2OutputOracleAddress, l1BridgeAdapterAddress) + + encodedPayload := proveMessagePayload(l1Client, l2Client, l2TxHash, optimismPortalAddress, l2OutputOracleAddress) + + l1BridgeAdapter, err := optimism_l1_bridge_adapter.NewOptimismL1BridgeAdapter(l1BridgeAdapterAddress, l1Client) + helpers.PanicErr(err) + + tx, err := l1BridgeAdapter.FinalizeWithdrawERC20(env.Transactors[l1ChainID], + common.HexToAddress("0x0"), // doesn't matter + common.HexToAddress("0x0"), // doesn't matter + encodedPayload, // all the data needed to prove withdrawal onchain. + ) + helpers.PanicErr(err) + helpers.ConfirmTXMined(context.Background(), l1Client, tx, int64(l1ChainID), "ProveWithdrawal") } -func proveMessage( +func ProveWithdrawalViaRebalancer( env multienv.Env, + l1ChainID, + l2ChainID, + remoteChainID uint64, + amount *big.Int, + l1RebalancerAddress, + l2OutputOracleAddress, + optimismPortalAddress common.Address, + l2TxHash common.Hash, +) { + remoteChain, ok := chainsel.ChainByEvmChainID(remoteChainID) + if !ok { + panic(fmt.Sprintf("Chain ID %d not found in chain selectors", remoteChainID)) + } + + l2Client, ok := env.Clients[l2ChainID] + if !ok { + panic(fmt.Sprintf("No client found for chain %d, map: %+v", l2ChainID, env.Clients)) + } + l1Client, ok := env.Clients[l1ChainID] + if !ok { + panic(fmt.Sprintf("No client found for chain %d, map: %+v", l1ChainID, env.Clients)) + } + + encodedPayload := proveMessagePayload(l1Client, l2Client, l2TxHash, optimismPortalAddress, l2OutputOracleAddress) + + l1Rebalancer, err := rebalancer.NewRebalancer(l1RebalancerAddress, l1Client) + helpers.PanicErr(err) + + tx, err := l1Rebalancer.ReceiveLiquidity( + env.Transactors[l1ChainID], + remoteChain.Selector, + amount, + false, + encodedPayload, + ) + helpers.PanicErr(err) + helpers.ConfirmTXMined(context.Background(), l1Client, tx, int64(l1ChainID), + "ProveWithdrawal", amount.String(), "from", remoteChain.Name) +} + +func proveMessagePayload( l1Client, l2Client *ethclient.Client, l2TxHash common.Hash, optimismPortalAddress, - l2OutputOracleAddress, - l1BridgeAdapterAddress common.Address, -) { + l2OutputOracleAddress common.Address, +) []byte { prover, err := withdrawprover.New( ðClient{l1Client}, ðClient{l2Client}, @@ -61,12 +117,6 @@ func proveMessage( messageProof, err := prover.Prove(context.Background(), l2TxHash) helpers.PanicErr(err) - l1BridgeAdapter, err := optimism_l1_bridge_adapter.NewOptimismL1BridgeAdapter(l1BridgeAdapterAddress, l1Client) - helpers.PanicErr(err) - - l1ChainID, err := l1Client.ChainID(context.Background()) - helpers.PanicErr(err) - fmt.Println("Calling proveWithdrawalTransaction on bridge adapter, nonce:", messageProof.LowLevelMessage.Nonce, "\n", "sender:", messageProof.LowLevelMessage.Sender.String(), "\n", "target:", messageProof.LowLevelMessage.Target.String(), "\n", @@ -112,13 +162,7 @@ func proveMessage( ) helpers.PanicErr(err) - tx, err := l1BridgeAdapter.FinalizeWithdrawERC20(env.Transactors[l1ChainID.Uint64()], - common.HexToAddress("0x0"), // doesn't matter - common.HexToAddress("0x0"), // doesn't matter - encodedPayload, // all the data needed to prove withdrawal onchain. - ) - helpers.PanicErr(err) - helpers.ConfirmTXMined(context.Background(), l1Client, tx, int64(l1ChainID.Uint64()), "ProveWithdrawal") + return encodedPayload } func formatWithdrawalProof(proof [][]byte) string { diff --git a/core/scripts/ccip/rebalancer/opstack/send_to_l2.go b/core/scripts/ccip/rebalancer/opstack/send_to_l2.go index 5c9015c59b..96fc709e62 100644 --- a/core/scripts/ccip/rebalancer/opstack/send_to_l2.go +++ b/core/scripts/ccip/rebalancer/opstack/send_to_l2.go @@ -8,16 +8,19 @@ import ( "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" + chainsel "github.com/smartcontractkit/chain-selectors" "github.com/smartcontractkit/chainlink/core/scripts/ccip/rebalancer/multienv" helpers "github.com/smartcontractkit/chainlink/core/scripts/common" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/rebalancer/generated/optimism_l1_bridge_adapter" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/rebalancer/generated/rebalancer" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/shared/generated/erc20" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/abihelpers" ) var ( - l1AdapterABI = abihelpers.MustParseABI(optimism_l1_bridge_adapter.OptimismL1BridgeAdapterMetaData.ABI) + l1AdapterABI = abihelpers.MustParseABI(optimism_l1_bridge_adapter.OptimismL1BridgeAdapterMetaData.ABI) + rebalancerABI = abihelpers.MustParseABI(rebalancer.RebalancerMetaData.ABI) ) func SendToL2( @@ -111,3 +114,63 @@ func SendToL2( func scaleGasCost(gasCost uint64) uint64 { return gasCost * 18 / 10 } + +func SendToL2ViaRebalancer( + env multienv.Env, + l1ChainID, + remoteChainID uint64, + l1RebalancerAddress common.Address, + amount *big.Int, +) { + remoteChain, ok := chainsel.ChainByEvmChainID(remoteChainID) + if !ok { + panic(fmt.Sprintf("Chain ID %d not found in chain selectors", remoteChainID)) + } + + l1Rebalancer, err := rebalancer.NewRebalancer(l1RebalancerAddress, env.Clients[l1ChainID]) + helpers.PanicErr(err) + + // check if there is enough liquidity to transfer the provided amount. + liquidity, err := l1Rebalancer.GetLiquidity(nil) + helpers.PanicErr(err) + if liquidity.Cmp(amount) < 0 { + panic(fmt.Sprintf("Insufficient liquidity, add more tokens to the liquidity container or specify smaller amount: %s < %s", liquidity, amount)) + } + + // Estimate gas of the bridging operation and multiply that by 1.6 since + // optimism bridging costs are paid for in gas. + calldata, err := rebalancerABI.Pack("rebalanceLiquidity", + remoteChain.Selector, + amount, + big.NewInt(0), // no eth fee for L1 -> L2 + []byte{}, // no bridge specific payload for L1 to OP stack L2 + ) + helpers.PanicErr(err) + + gasPrice, err := env.Clients[l1ChainID].SuggestGasPrice(context.Background()) + helpers.PanicErr(err) + + // Estimate gas of the bridging operation and multiply that by 1.6 since + // optimism bridging costs are paid for in gas. + gasCost, err := env.Clients[l1ChainID].EstimateGas(context.Background(), ethereum.CallMsg{ + From: env.Transactors[l1ChainID].From, + Gas: 1e6, + GasPrice: gasPrice, + To: &l1RebalancerAddress, + Data: calldata, + }) + helpers.PanicErr(err) + + gasCost = scaleGasCost(gasCost) + + fmt.Println("Estimated gas cost for bridging operation, after scaling by 1.8x:", gasCost) + + tx, err := l1Rebalancer.RebalanceLiquidity(&bind.TransactOpts{ + From: env.Transactors[l1ChainID].From, + Signer: env.Transactors[l1ChainID].Signer, + GasLimit: gasCost, + }, remoteChain.Selector, amount, big.NewInt(0), []byte{}) + helpers.PanicErr(err) + helpers.ConfirmTXMined(context.Background(), env.Clients[l1ChainID], tx, int64(l1ChainID), + "RebalanceLiquidity", amount.String(), "to", remoteChain.Name) +} diff --git a/core/scripts/ccip/rebalancer/opstack/withdraw.go b/core/scripts/ccip/rebalancer/opstack/withdraw.go index 10392b9abd..5dedc910a7 100644 --- a/core/scripts/ccip/rebalancer/opstack/withdraw.go +++ b/core/scripts/ccip/rebalancer/opstack/withdraw.go @@ -7,9 +7,12 @@ import ( "github.com/ethereum/go-ethereum/common" + chainsel "github.com/smartcontractkit/chain-selectors" + "github.com/smartcontractkit/chainlink/core/scripts/ccip/rebalancer/multienv" helpers "github.com/smartcontractkit/chainlink/core/scripts/common" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/rebalancer/generated/optimism_l2_bridge_adapter" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/rebalancer/generated/rebalancer" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/shared/generated/erc20" ) @@ -58,3 +61,38 @@ func WithdrawFromL2( helpers.PanicErr(err) helpers.ConfirmTXMined(context.Background(), env.Clients[l2ChainID], tx, int64(l2ChainID), "WithdrawFromL2") } + +func WithdrawFromL2ViaRebalancer( + env multienv.Env, + l2ChainID, + remoteChainID uint64, + l2RebalancerAddress common.Address, + amount *big.Int, +) { + remoteChain, ok := chainsel.ChainByEvmChainID(remoteChainID) + if !ok { + panic(fmt.Sprintf("Chain ID %d not found in chain selectors", remoteChainID)) + } + + // check if there is enough liquidity in the rebalancer. + l2Rebalancer, err := rebalancer.NewRebalancer(l2RebalancerAddress, env.Clients[l2ChainID]) + helpers.PanicErr(err) + + liquidity, err := l2Rebalancer.GetLiquidity(nil) + helpers.PanicErr(err) + if liquidity.Cmp(amount) < 0 { + panic(fmt.Sprintf("not enough liquidity to withdraw, inject more tokens into the liquidity container or specify less amount, liquidity: %s, want: %s", + liquidity.String(), amount.String())) + } + + tx, err := l2Rebalancer.RebalanceLiquidity( + env.Transactors[l2ChainID], + remoteChain.Selector, + amount, + big.NewInt(0), // no eth fee for L2 -> L1 + []byte{}, // no bridge specific payload for OP stack L2 to L1 + ) + helpers.PanicErr(err) + helpers.ConfirmTXMined(context.Background(), env.Clients[l2ChainID], tx, int64(l2ChainID), + "WithdrawFromL2ViaRebalancer", amount.String(), "to", remoteChain.Name) +} diff --git a/core/scripts/ccip/rebalancer/setup_rebalancer.go b/core/scripts/ccip/rebalancer/setup_rebalancer.go index 59aec3cf9c..901355d777 100644 --- a/core/scripts/ccip/rebalancer/setup_rebalancer.go +++ b/core/scripts/ccip/rebalancer/setup_rebalancer.go @@ -318,7 +318,7 @@ func SetupNode( resetDatabase(client, ctx) } - return setupRebalancerNodeFromClient(client, ctx, e) + return setupRebalancerNodeFromClient(client, ctx) } func configureEnvironmentVariables( @@ -364,8 +364,7 @@ func resetDatabase(client *cmd.Shell, context *cli.Context) { func setupRebalancerNodeFromClient( client *cmd.Shell, - context *cli.Context, - e multienv.Env) *cmd.SetupRebalancerNodePayload { + context *cli.Context) *cmd.SetupRebalancerNodePayload { payload, err := client.ConfigureRebalancerNode(context) helpers.PanicErr(err) diff --git a/core/scripts/ccip/rebalancer/util.go b/core/scripts/ccip/rebalancer/util.go index 120ea3288e..2021d8c557 100644 --- a/core/scripts/ccip/rebalancer/util.go +++ b/core/scripts/ccip/rebalancer/util.go @@ -9,6 +9,7 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/ethclient" + chainsel "github.com/smartcontractkit/chain-selectors" confighelper2 "github.com/smartcontractkit/libocr/offchainreporting2plus/confighelper" "github.com/smartcontractkit/libocr/offchainreporting2plus/types" @@ -16,13 +17,16 @@ import ( "github.com/smartcontractkit/chainlink/core/scripts/ccip/rebalancer/arb" "github.com/smartcontractkit/chainlink/core/scripts/ccip/rebalancer/multienv" + "github.com/smartcontractkit/chainlink/core/scripts/ccip/rebalancer/opstack" helpers "github.com/smartcontractkit/chainlink/core/scripts/common" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/arm_proxy_contract" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/lock_release_token_pool" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/mock_arm_contract" - router2 "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/router" + cciprouter "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/router" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/rebalancer/generated/arbitrum_l1_bridge_adapter" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/rebalancer/generated/arbitrum_l2_bridge_adapter" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/rebalancer/generated/optimism_l1_bridge_adapter" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/rebalancer/generated/optimism_l2_bridge_adapter" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/rebalancer/generated/rebalancer" ) @@ -59,41 +63,30 @@ func deployUniverse( // required by the token pool. l1Arm, l1ArmProxy := deployArm(l1Transactor, l1Client, l1ChainID) - l1RouterAddress, _, _, err := router2.DeployRouter(l1Transactor, l1Client, common.Address{}, l1ArmProxy.Address()) + _, tx, _, err := cciprouter.DeployRouter(l1Transactor, l1Client, common.Address{}, l1ArmProxy.Address()) helpers.PanicErr(err) + l1RouterAddress := helpers.ConfirmContractDeployed(context.Background(), l1Client, tx, int64(l1ChainID)) - // deploy token pool targeting l1TokenAddress + // deploy token pool targeting l1TokenAddress. l1TokenPool, l1Rebalancer := deployTokenPoolAndRebalancer(l1Transactor, l1Client, l1TokenAddress, l1ArmProxy.Address(), l1ChainSelector, l1RouterAddress) - // deploy the L1 bridge adapter to point to the token address - _, tx, _, err := arbitrum_l1_bridge_adapter.DeployArbitrumL1BridgeAdapter( - l1Transactor, - l1Client, - arb.ArbitrumContracts[l1ChainID]["L1GatewayRouter"], - arb.ArbitrumContracts[l1ChainID]["L1Outbox"], - ) - helpers.PanicErr(err) - l1BridgeAdapterAddress := helpers.ConfirmContractDeployed(context.Background(), l1Client, tx, int64(l1ChainID)) + // deploy the appropriate L1 bridge adapter depending on the chain. + l1BridgeAdapterAddress := deployL1BridgeAdapter(l1Transactor, l1Client, l1ChainID, l2ChainID) // L2 deploys // deploy arm and arm proxy. // required by the token pool. l2Arm, l2ArmProxy := deployArm(l2Transactor, l2Client, l2ChainID) - l2RouterAddress, _, _, err := router2.DeployRouter(l2Transactor, l2Client, common.Address{}, l2ArmProxy.Address()) + _, tx, _, err = cciprouter.DeployRouter(l2Transactor, l2Client, common.Address{}, l2ArmProxy.Address()) helpers.PanicErr(err) + l2RouterAddress := helpers.ConfirmContractDeployed(context.Background(), l2Client, tx, int64(l2ChainID)) // deploy token pool targeting l2TokenAddress l2TokenPool, l2Rebalancer := deployTokenPoolAndRebalancer(l2Transactor, l2Client, l2TokenAddress, l2ArmProxy.Address(), l2ChainSelector, l2RouterAddress) // deploy the L2 bridge adapter to point to the token address - _, tx, _, err = arbitrum_l2_bridge_adapter.DeployArbitrumL2BridgeAdapter( - l2Transactor, - l2Client, - arb.ArbitrumContracts[l2ChainID]["L2GatewayRouter"], - ) - helpers.PanicErr(err) - l2BridgeAdapterAddress := helpers.ConfirmContractDeployed(context.Background(), l2Client, tx, int64(l2ChainID)) + l2BridgeAdapterAddress := deployL2BridgeAdapter(l2Transactor, l2Client, l2ChainID) // link the l1 and l2 rebalancers together via the SetCrossChainRebalancer function tx, err = l1Rebalancer.SetCrossChainRebalancer(l1Transactor, rebalancer.IRebalancerCrossChainRebalancerArgs{ @@ -139,16 +132,20 @@ func deployUniverse( } fmt.Println("Deployments complete\n", - "L1 Arm:", l1Arm.Address().Hex(), "\n", - "L1 Arm Proxy:", l1ArmProxy.Address().Hex(), "\n", - "L1 Token Pool:", l1TokenPool.Address().Hex(), "\n", - "L1 Rebalancer:", l1Rebalancer.Address().Hex(), "\n", - "L1 Bridge Adapter:", l1BridgeAdapterAddress.Hex(), "\n", - "L2 Arm:", l2Arm.Address().Hex(), "\n", - "L2 Arm Proxy:", l2ArmProxy.Address().Hex(), "\n", - "L2 Token Pool:", l2TokenPool.Address().Hex(), "\n", - "L2 Rebalancer:", l2Rebalancer.Address().Hex(), "\n", - "L2 Bridge Adapter:", l2BridgeAdapterAddress.Hex(), + "L1 Chain ID:", l1ChainID, "\n", + "L1 Chain Selector:", l1ChainSelector, "\n", + "L1 Arm:", helpers.ContractExplorerLink(int64(l1ChainID), l1Arm.Address()), "(", l1Arm.Address().Hex(), ")\n", + "L1 Arm Proxy:", helpers.ContractExplorerLink(int64(l1ChainID), l1ArmProxy.Address()), "(", l1ArmProxy.Address().Hex(), ")\n", + "L1 Token Pool:", helpers.ContractExplorerLink(int64(l1ChainID), l1TokenPool.Address()), "(", l1TokenPool.Address().Hex(), ")\n", + "L1 Rebalancer:", helpers.ContractExplorerLink(int64(l1ChainID), l1Rebalancer.Address()), "(", l1Rebalancer.Address().Hex(), ")\n", + "L1 Bridge Adapter:", helpers.ContractExplorerLink(int64(l1ChainID), l1BridgeAdapterAddress), "(", l1BridgeAdapterAddress.Hex(), ")\n", + "L2 Chain ID:", l2ChainID, "\n", + "L2 Chain Selector:", l2ChainSelector, "\n", + "L2 Arm:", helpers.ContractExplorerLink(int64(l2ChainID), l2Arm.Address()), "(", l2Arm.Address().Hex(), ")\n", + "L2 Arm Proxy:", helpers.ContractExplorerLink(int64(l2ChainID), l2ArmProxy.Address()), "(", l2ArmProxy.Address().Hex(), ")\n", + "L2 Token Pool:", helpers.ContractExplorerLink(int64(l2ChainID), l2TokenPool.Address()), "(", l2TokenPool.Address().Hex(), ")\n", + "L2 Rebalancer:", helpers.ContractExplorerLink(int64(l2ChainID), l2Rebalancer.Address()), "(", l2Rebalancer.Address().Hex(), ")\n", + "L2 Bridge Adapter:", helpers.ContractExplorerLink(int64(l2ChainID), l2BridgeAdapterAddress), "(", l2BridgeAdapterAddress.Hex(), ")", ) return universe{ @@ -181,6 +178,59 @@ func deployUniverse( } } +func deployL1BridgeAdapter( + l1Transactor *bind.TransactOpts, + l1Client *ethclient.Client, + l1ChainID, l2ChainID uint64, +) common.Address { + if l2ChainID == chainsel.ETHEREUM_MAINNET_ARBITRUM_1.EvmChainID || l2ChainID == chainsel.ETHEREUM_TESTNET_SEPOLIA_ARBITRUM_1.EvmChainID { + _, tx, _, err := arbitrum_l1_bridge_adapter.DeployArbitrumL1BridgeAdapter( + l1Transactor, + l1Client, + arb.ArbitrumContracts[l1ChainID]["L1GatewayRouter"], + arb.ArbitrumContracts[l1ChainID]["L1Outbox"], + ) + helpers.PanicErr(err) + return helpers.ConfirmContractDeployed(context.Background(), l1Client, tx, int64(l1ChainID)) + } else if l2ChainID == chainsel.ETHEREUM_MAINNET_OPTIMISM_1.EvmChainID || l2ChainID == chainsel.ETHEREUM_TESTNET_SEPOLIA_OPTIMISM_1.EvmChainID { + _, tx, _, err := optimism_l1_bridge_adapter.DeployOptimismL1BridgeAdapter( + l1Transactor, + l1Client, + opstack.OptimismContracts[l1ChainID]["L1StandardBridge"], + opstack.OptimismContracts[l1ChainID]["WETH"], + opstack.OptimismContracts[l1ChainID]["OptimismPortal"], + ) + helpers.PanicErr(err) + return helpers.ConfirmContractDeployed(context.Background(), l1Client, tx, int64(l1ChainID)) + } + panic(fmt.Sprintf("unsupported chain id %d", l1ChainID)) +} + +func deployL2BridgeAdapter( + l2Transactor *bind.TransactOpts, + l2Client *ethclient.Client, + l2ChainID uint64, +) common.Address { + if l2ChainID == chainsel.ETHEREUM_MAINNET_ARBITRUM_1.EvmChainID || l2ChainID == chainsel.ETHEREUM_TESTNET_SEPOLIA_ARBITRUM_1.EvmChainID { + _, tx, _, err := arbitrum_l2_bridge_adapter.DeployArbitrumL2BridgeAdapter( + l2Transactor, + l2Client, + arb.ArbitrumContracts[l2ChainID]["L2GatewayRouter"], + ) + helpers.PanicErr(err) + return helpers.ConfirmContractDeployed(context.Background(), l2Client, tx, int64(l2ChainID)) + } else if l2ChainID == chainsel.ETHEREUM_MAINNET_OPTIMISM_1.EvmChainID || l2ChainID == chainsel.ETHEREUM_TESTNET_SEPOLIA_OPTIMISM_1.EvmChainID { + _, tx, _, err := optimism_l2_bridge_adapter.DeployOptimismL2BridgeAdapter( + l2Transactor, + l2Client, + opstack.OptimismContracts[l2ChainID]["WETH"], + ) + helpers.PanicErr(err) + return helpers.ConfirmContractDeployed(context.Background(), l2Client, tx, int64(l2ChainID)) + } + panic(fmt.Sprintf("unsupported l2 chain id %d", l2ChainID)) +} + func deployTokenPoolAndRebalancer( transactor *bind.TransactOpts, client *ethclient.Client, diff --git a/core/services/ocr2/plugins/rebalancer/bridge/arb/common.go b/core/services/ocr2/plugins/rebalancer/bridge/arb/common.go index f9ada1c979..3a2c46701e 100644 --- a/core/services/ocr2/plugins/rebalancer/bridge/arb/common.go +++ b/core/services/ocr2/plugins/rebalancer/bridge/arb/common.go @@ -33,6 +33,15 @@ const ( // DepositFinalizedToAddressTopicIndex is the index of the topic in the DepositFinalized event // that contains the "to" address. DepositFinalizedToAddressTopicIndex = 3 + + // Arbitrum stages + // StageRebalanceConfirmed is set as the transfer stage when the rebalanceLiquidity tx is confirmed onchain. + StageRebalanceConfirmed = 1 + // StageFinalizeReady is set as the transfer stage when the finalization is ready to execute onchain. + StageFinalizeReady = 2 + // StageFinalizeConfirmed is set as the transfer stage when the finalization is confirmed onchain. + // This is a terminal stage. + StageFinalizeConfirmed = 3 ) var ( diff --git a/core/services/ocr2/plugins/rebalancer/bridge/arb/l1_to_l2.go b/core/services/ocr2/plugins/rebalancer/bridge/arb/l1_to_l2.go index 642d4c61ba..d12ff2115a 100644 --- a/core/services/ocr2/plugins/rebalancer/bridge/arb/l1_to_l2.go +++ b/core/services/ocr2/plugins/rebalancer/bridge/arb/l1_to_l2.go @@ -353,6 +353,7 @@ func (l *l1ToL2Bridge) toPendingTransfers( logIndex: int64(transfer.Raw.Index), }].BlockTimestamp, BridgeData: []byte{}, // no finalization data, not ready + Stage: StageRebalanceConfirmed, }, Status: models.TransferStatusNotReady, ID: fmt.Sprintf("%s-%d", transfer.Raw.TxHash.Hex(), transfer.Raw.Index), @@ -373,11 +374,14 @@ func (l *l1ToL2Bridge) toPendingTransfers( logIndex: int64(transfer.Raw.Index), }].BlockTimestamp, BridgeData: readyData[i], // finalization data since its ready + Stage: StageFinalizeReady, }, Status: models.TransferStatusReady, // ready == finalized for L1 -> L2 transfers due to auto-finalization by the native bridge ID: fmt.Sprintf("%s-%d", transfer.Raw.TxHash.Hex(), transfer.Raw.Index), }) } + // TODO: need to also return executed finalizations. See https://smartcontract-it.atlassian.net/browse/CCIP-1893. + // Use stage StageFinalizeConfirmed for executed finalizations. return transfers, nil } diff --git a/core/services/ocr2/plugins/rebalancer/bridge/arb/l1_to_l2_test.go b/core/services/ocr2/plugins/rebalancer/bridge/arb/l1_to_l2_test.go index 6dcf9ee2e4..306cc8bcb3 100644 --- a/core/services/ocr2/plugins/rebalancer/bridge/arb/l1_to_l2_test.go +++ b/core/services/ocr2/plugins/rebalancer/bridge/arb/l1_to_l2_test.go @@ -1086,6 +1086,7 @@ func Test_l1ToL2Bridge_toPendingTransfers(t *testing.T) { Amount: ubig.NewI(100), Date: time.Time{}, BridgeData: []byte{}, + Stage: 1, }, Status: models.TransferStatusNotReady, ID: fmt.Sprintf("%s-%d", common.HexToHash("0x1"), 1), @@ -1101,6 +1102,7 @@ func Test_l1ToL2Bridge_toPendingTransfers(t *testing.T) { Amount: ubig.NewI(300), Date: time.Time{}, BridgeData: []byte{1, 2, 3}, + Stage: 2, }, Status: models.TransferStatusReady, ID: fmt.Sprintf("%s-%d", common.HexToHash("0x2"), 2), diff --git a/core/services/ocr2/plugins/rebalancer/bridge/arb/l2_to_l1.go b/core/services/ocr2/plugins/rebalancer/bridge/arb/l2_to_l1.go index 865abc2637..4a23b9571e 100644 --- a/core/services/ocr2/plugins/rebalancer/bridge/arb/l2_to_l1.go +++ b/core/services/ocr2/plugins/rebalancer/bridge/arb/l2_to_l1.go @@ -306,6 +306,7 @@ func (l *l2ToL1Bridge) toPendingTransfers( logIndex: int64(transfer.Raw.Index), }].BlockTimestamp, BridgeData: readyData[i], // finalization data for withdrawals that are ready + Stage: StageFinalizeReady, }, Status: models.TransferStatusReady, ID: fmt.Sprintf("%s-%d", transfer.Raw.TxHash.Hex(), transfer.Raw.Index), @@ -326,11 +327,14 @@ func (l *l2ToL1Bridge) toPendingTransfers( logIndex: int64(transfer.Raw.Index), }].BlockTimestamp, BridgeData: []byte{}, // No data since its not ready + Stage: StageRebalanceConfirmed, }, Status: models.TransferStatusNotReady, ID: fmt.Sprintf("%s-%d", transfer.Raw.TxHash.Hex(), transfer.Raw.Index), }) } + // TODO: need to also return executed finalizations. See https://smartcontract-it.atlassian.net/browse/CCIP-1893. + // Use stage StageFinalizeConfirmed for executed finalizations. return transfers, nil } diff --git a/core/services/ocr2/plugins/rebalancer/bridge/testonlybridge/l1_to_l1.go b/core/services/ocr2/plugins/rebalancer/bridge/testonlybridge/l1_to_l1.go index 6e36411d00..43c28a3bb0 100644 --- a/core/services/ocr2/plugins/rebalancer/bridge/testonlybridge/l1_to_l1.go +++ b/core/services/ocr2/plugins/rebalancer/bridge/testonlybridge/l1_to_l1.go @@ -1,6 +1,7 @@ package testonlybridge import ( + "bytes" "context" "fmt" "math/big" @@ -16,12 +17,23 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/rebalancer/generated/mock_l1_bridge_adapter" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/rebalancer/generated/rebalancer" "github.com/smartcontractkit/chainlink/v2/core/logger" + "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/abihelpers" + "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/rebalancer/abiutils" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/rebalancer/models" ) +const ( + // These correspond to the enumeration FinalizationAction in the MockL1BridgeAdapter contract. + FinalizationActionProveWithdrawal uint8 = 0 + FinalizationActionFinalizeWithdrawal uint8 = 1 +) + var ( + adapterABI = abihelpers.MustParseABI(mock_l1_bridge_adapter.MockL1BridgeAdapterABI) + // Emitted on both source and destination - LiquidityTransferredTopic = rebalancer.RebalancerLiquidityTransferred{}.Topic() + LiquidityTransferredTopic = rebalancer.RebalancerLiquidityTransferred{}.Topic() + FinalizationStepCompletedTopic = rebalancer.RebalancerFinalizationStepCompleted{}.Topic() ) type testBridge struct { @@ -29,8 +41,8 @@ type testBridge struct { destSelector models.NetworkSelector sourceRebalancer rebalancer.RebalancerInterface destRebalancer rebalancer.RebalancerInterface - sourceAdapter *mock_l1_bridge_adapter.MockL1BridgeAdapter - destAdapter *mock_l1_bridge_adapter.MockL1BridgeAdapter + sourceAdapter mock_l1_bridge_adapter.MockL1BridgeAdapterInterface + destAdapter mock_l1_bridge_adapter.MockL1BridgeAdapterInterface sourceLogPoller logpoller.LogPoller destLogPoller logpoller.LogPoller sourceClient client.Client @@ -45,14 +57,15 @@ func New( sourceClient, destClient client.Client, lggr logger.Logger, ) (*testBridge, error) { - // FIXME Makram ctx ctx := context.Background() err := sourceLogPoller.RegisterFilter( ctx, logpoller.Filter{ - Name: logpoller.FilterName("L1-LiquidityTransferred", sourceSelector), + Name: logpoller.FilterName("Local-LiquidityTransferred-FinalizationCompleted", + sourceSelector, sourceRebalancerAddress.String()), EventSigs: []common.Hash{ LiquidityTransferredTopic, + FinalizationStepCompletedTopic, }, Addresses: []common.Address{ common.Address(sourceRebalancerAddress), @@ -65,9 +78,11 @@ func New( err = destLogPoller.RegisterFilter( ctx, logpoller.Filter{ - Name: logpoller.FilterName("L2-LiquidityTransferred", destSelector), + Name: logpoller.FilterName("Remote-LiquidityTransferred-FinalizationCompleted", + destSelector, destRebalancerAddress.String()), EventSigs: []common.Hash{ LiquidityTransferredTopic, + FinalizationStepCompletedTopic, }, Addresses: []common.Address{ common.Address(destRebalancerAddress), @@ -165,7 +180,7 @@ func (t *testBridge) GetTransfers(ctx context.Context, localToken models.Address ctx, 1, latestDestBlock.BlockNumber, - []common.Hash{LiquidityTransferredTopic}, + []common.Hash{LiquidityTransferredTopic, FinalizationStepCompletedTopic}, t.destRebalancer.Address(), ) if err != nil { @@ -177,36 +192,67 @@ func (t *testBridge) GetTransfers(ctx context.Context, localToken models.Address return nil, fmt.Errorf("parse source send logs: %w", err) } - parsedFinalizeLogs, _, err := parseLiquidityTransferred(t.destRebalancer.ParseLiquidityTransferred, receiveLogs) + parsedStepCompleted, parsedFinalizeLogs, err := parseLiquidityTransferredAndFinalizationStepCompleted( + t.destRebalancer.ParseLiquidityTransferred, + t.destRebalancer.ParseFinalizationStepCompleted, + receiveLogs) if err != nil { return nil, fmt.Errorf("parse dest finalize logs: %w", err) } - ready, err := t.getReadyToFinalize(parsedSendLogs, parsedFinalizeLogs) + readyToProve, readyToFinalize, err := filterAndGroupByStage(t.lggr, parsedSendLogs, parsedFinalizeLogs, parsedStepCompleted) if err != nil { return nil, fmt.Errorf("get ready to finalize: %w", err) } - return t.toPendingTransfers(localToken, remoteToken, ready, parsedToLP), nil + return t.toPendingTransfers(localToken, remoteToken, readyToProve, readyToFinalize, parsedToLP) } func (t *testBridge) toPendingTransfers( localToken, remoteToken models.Address, - ready []*rebalancer.RebalancerLiquidityTransferred, + readyToProve, + readyToFinalize []*rebalancer.RebalancerLiquidityTransferred, parsedToLP map[logKey]logpoller.Log, -) []models.PendingTransfer { +) ([]models.PendingTransfer, error) { var transfers []models.PendingTransfer - for _, send := range ready { + + for _, send := range readyToProve { + lp := parsedToLP[logKey{txHash: send.Raw.TxHash, logIndex: int64(send.Raw.Index)}] + sendNonce, err := UnpackBridgeSendReturnData(send.BridgeReturnData) + if err != nil { + return nil, fmt.Errorf("unpack send bridge data %x: %w", send.BridgeReturnData, err) + } + bridgeData, err := PackProveBridgePayload(sendNonce) + if err != nil { + return nil, fmt.Errorf("pack bridge data (%s): %w", sendNonce.String(), err) + } + transfers = append(transfers, models.PendingTransfer{ + Transfer: models.Transfer{ + From: t.sourceSelector, + To: t.destSelector, + Sender: models.Address(t.sourceAdapter.Address()), + Receiver: models.Address(t.destRebalancer.Address()), + Amount: ubig.New(send.Amount), + LocalTokenAddress: localToken, + RemoteTokenAddress: remoteToken, + Date: lp.BlockTimestamp, + BridgeData: bridgeData, + Stage: 1, + }, + Status: models.TransferStatusReady, + ID: fmt.Sprintf("%s-%d-prove", send.Raw.TxHash.Hex(), send.Raw.Index), + }) + } + + for _, send := range readyToFinalize { lp := parsedToLP[logKey{txHash: send.Raw.TxHash, logIndex: int64(send.Raw.Index)}] sendNonce, err := UnpackBridgeSendReturnData(send.BridgeReturnData) if err != nil { - t.lggr.Errorw("unpack send bridge data", "err", err) - continue + return nil, fmt.Errorf("unpack send bridge data %x: %w", send.BridgeReturnData, err) } bridgeData, err := PackFinalizeBridgePayload(send.Amount, sendNonce) if err != nil { - t.lggr.Errorw("pack bridge data", "err", err) - continue + return nil, fmt.Errorf("pack bridge data (%s): %w", sendNonce.String(), err) } transfers = append(transfers, models.PendingTransfer{ Transfer: models.Transfer{ @@ -219,9 +265,10 @@ func (t *testBridge) toPendingTransfers( RemoteTokenAddress: remoteToken, Date: lp.BlockTimestamp, BridgeData: bridgeData, + Stage: 2, }, Status: models.TransferStatusReady, - ID: fmt.Sprintf("%s-%d", send.Raw.TxHash.Hex(), send.Raw.Index), + ID: fmt.Sprintf("%s-%d-finalize", send.Raw.TxHash.Hex(), send.Raw.Index), }) } @@ -229,21 +276,110 @@ func (t *testBridge) toPendingTransfers( t.lggr.Infow("produced pending transfers", "pendingTransfers", transfers) } - return transfers + return transfers, nil } -func (t *testBridge) getReadyToFinalize( +// filterAndGroupByStage filters out sends that have already been finalized +// and groups the remaining sends into ready to prove and ready to finalize slices. +func filterAndGroupByStage( + lggr logger.Logger, sends []*rebalancer.RebalancerLiquidityTransferred, finalizes []*rebalancer.RebalancerLiquidityTransferred, -) ([]*rebalancer.RebalancerLiquidityTransferred, error) { - t.lggr.Debugw("Getting ready to finalize", + stepsCompleted []*rebalancer.RebalancerFinalizationStepCompleted, +) (readyToProve, readyToFinalize []*rebalancer.RebalancerLiquidityTransferred, err error) { + lggr = lggr.With( "sendsLen", len(sends), "finalizesLen", len(finalizes), + "stepsCompletedLen", len(stepsCompleted), "sends", sends, - "finalizes", finalizes) + "finalizes", finalizes, + "stepsCompleted", stepsCompleted) + lggr.Debugw("Getting ready to finalize") // find sent events that don't have a matching finalized event - var ready []*rebalancer.RebalancerLiquidityTransferred + unfinalized, err := filterFinalized(sends, finalizes) + if err != nil { + return nil, nil, fmt.Errorf("filter finalized: %w", err) + } + + // group remaining unfinalized sends into ready to finalize and ready to prove. + // ready to finalize sends will be finalized, while ready to prove will be proven. + readyToProve, readyToFinalize, err = groupByStage(unfinalized, stepsCompleted) + if err != nil { + return nil, nil, fmt.Errorf("group by stage: %w", err) + } + + if len(readyToFinalize) > 0 { + lggr.Infow("found proven sends, ready to finalize", + "provenSendsLen", len(readyToFinalize), + "readyToFinalize", readyToFinalize) + } + if len(readyToProve) > 0 { + lggr.Infow("found unproven sends, ready to prove", + "unprovenSendsLen", len(readyToProve), + "readyToProve", readyToProve) + } + + if len(readyToFinalize) == 0 && len(readyToProve) == 0 { + lggr.Debugw("No sends ready to finalize or prove", + "finalizes", finalizes) + } + + return +} + +// groupByStage groups the unfinalized transfers into two categories: ready to prove and ready to finalize. +func groupByStage( + unfinalized []*rebalancer.RebalancerLiquidityTransferred, + stepsCompleted []*rebalancer.RebalancerFinalizationStepCompleted, +) ( + readyToProve, + readyToFinalize []*rebalancer.RebalancerLiquidityTransferred, + err error, +) { + for _, candidate := range unfinalized { + proven, err := isCandidateProven(candidate, stepsCompleted) + if err != nil { + return nil, nil, fmt.Errorf("new function: %w", err) + } + + if proven { + readyToFinalize = append(readyToFinalize, candidate) + } else { + readyToProve = append(readyToProve, candidate) + } + } + return +} + +// isCandidateProven returns true if the candidate transfer has already been proven. +// it does this by checking if the candidate's nonce matches any of the nonces in the +// stepsCompleted logs. +// see contracts/src/v0.8/rebalancer/test/mocks/MockBridgeAdapter.sol for details on this. +func isCandidateProven(candidate *rebalancer.RebalancerLiquidityTransferred, stepsCompleted []*rebalancer.RebalancerFinalizationStepCompleted) (bool, error) { + for _, stepCompleted := range stepsCompleted { + sendNonce, err := UnpackBridgeSendReturnData(candidate.BridgeReturnData) + if err != nil { + return false, fmt.Errorf("unpack send bridge data: %w", err) + } + proveNonce, err := UnpackProveBridgePayload(stepCompleted.BridgeSpecificData) + if err != nil { + return false, fmt.Errorf("unpack prove bridge data: %w", err) + } + if proveNonce.Cmp(sendNonce) == 0 { + return true, nil + } + } + return false, nil +} + +func filterFinalized( + sends []*rebalancer.RebalancerLiquidityTransferred, + finalizes []*rebalancer.RebalancerLiquidityTransferred) ( + []*rebalancer.RebalancerLiquidityTransferred, + error, +) { + var unfinalized []*rebalancer.RebalancerLiquidityTransferred for _, send := range sends { var finalized bool for _, finalize := range finalizes { @@ -261,53 +397,115 @@ func (t *testBridge) getReadyToFinalize( } } if !finalized { - ready = append(ready, send) + unfinalized = append(unfinalized, send) } } + return unfinalized, nil +} - if len(ready) > 0 { - t.lggr.Infow("found ready to finalize", "sendsLen", len(sends), - "finalizesLen", len(finalizes), - "sends", sends, - "finalizes", finalizes, - "ready", ready) - } else { - t.lggr.Debugw("no requests ready to finalize", "sendsLen", len(sends), - "finalizesLen", len(finalizes), - "sends", sends, - "finalizes", finalizes) +func PackProveBridgePayload(nonce *big.Int) ([]byte, error) { + encodedProvePayload, err := adapterABI.Methods["encodeProvePayload"].Inputs.Pack(mock_l1_bridge_adapter.MockL1BridgeAdapterProvePayload{ + Nonce: nonce, + }) + if err != nil { + return nil, fmt.Errorf("pack prove bridge data: %w", err) } - return ready, nil + encodedPayload, err := adapterABI.Methods["encodePayload"].Inputs.Pack( + mock_l1_bridge_adapter.MockL1BridgeAdapterPayload{ + Action: FinalizationActionProveWithdrawal, + Data: encodedProvePayload, + }, + ) + if err != nil { + return nil, fmt.Errorf("pack bridge data: %w", err) + } + + return encodedPayload, nil } func PackFinalizeBridgePayload(amount, nonce *big.Int) ([]byte, error) { - return utils.ABIEncode(`[{"type": "uint256"}, {"type": "uint256"}]`, amount, nonce) + encodedFinalizePayload, err := adapterABI.Methods["encodeFinalizePayload"].Inputs.Pack(mock_l1_bridge_adapter.MockL1BridgeAdapterFinalizePayload{ + Amount: amount, + Nonce: nonce, + }) + if err != nil { + return nil, fmt.Errorf("pack finalize bridge data: %w", err) + } + + encodedPayload, err := adapterABI.Methods["encodePayload"].Inputs.Pack( + mock_l1_bridge_adapter.MockL1BridgeAdapterPayload{ + Action: FinalizationActionFinalizeWithdrawal, + Data: encodedFinalizePayload, + }, + ) + if err != nil { + return nil, fmt.Errorf("pack bridge data: %w", err) + } + + return encodedPayload, nil } -func UnpackFinalizeBridgePayload(data []byte) (*big.Int, *big.Int, error) { - ifaces, err := utils.ABIDecode(`[{"type": "uint256"}, {"type": "uint256"}]`, data) +func UnpackProveBridgePayload(data []byte) (*big.Int, error) { + ifaces, err := adapterABI.Methods["encodePayload"].Inputs.Unpack(data) if err != nil { - return nil, nil, fmt.Errorf("decode bridge data: %w", err) + return nil, fmt.Errorf("decode prove bridge data: %w", err) } - if len(ifaces) != 2 { - return nil, nil, fmt.Errorf("expected 2 arguments, got %d", len(ifaces)) + + if len(ifaces) != 1 { + return nil, fmt.Errorf("decode payload: expected 1 argument, got %d", len(ifaces)) + } + + payload := *abi.ConvertType(ifaces[0], new(mock_l1_bridge_adapter.MockL1BridgeAdapterPayload)).(*mock_l1_bridge_adapter.MockL1BridgeAdapterPayload) + + // decode the prove payload from the payload + proveIfaces, err := adapterABI.Methods["encodeProvePayload"].Inputs.Unpack(payload.Data) + if err != nil { + return nil, fmt.Errorf("decode prove payload: %w", err) + } + + if len(proveIfaces) != 1 { + return nil, fmt.Errorf("decode prove payload: expected 1 argument, got %d", len(proveIfaces)) } - val1 := *abi.ConvertType(ifaces[0], new(*big.Int)).(**big.Int) - val2 := *abi.ConvertType(ifaces[1], new(*big.Int)).(**big.Int) - return val1, val2, nil + + provePayload := *abi.ConvertType(proveIfaces[0], new(mock_l1_bridge_adapter.MockL1BridgeAdapterProvePayload)).(*mock_l1_bridge_adapter.MockL1BridgeAdapterProvePayload) + + return provePayload.Nonce, nil } -func UnpackBridgeSendReturnData(data []byte) (*big.Int, error) { - ifaces, err := utils.ABIDecode(`[{"type": "uint256"}]`, data) +func UnpackFinalizeBridgePayload(data []byte) (*big.Int, *big.Int, error) { + ifaces, err := adapterABI.Methods["encodePayload"].Inputs.Unpack(data) if err != nil { - return nil, fmt.Errorf("decode bridge data: %w", err) + return nil, nil, fmt.Errorf("decode prove bridge data: %w", err) } + if len(ifaces) != 1 { - return nil, fmt.Errorf("expected 1 argument, got %d", len(ifaces)) + return nil, nil, fmt.Errorf("decode payload: expected 1 argument, got %d", len(ifaces)) } - val := *abi.ConvertType(ifaces[0], new(*big.Int)).(**big.Int) - return val, nil + + payload := *abi.ConvertType(ifaces[0], new(mock_l1_bridge_adapter.MockL1BridgeAdapterPayload)).(*mock_l1_bridge_adapter.MockL1BridgeAdapterPayload) + + // decode the finalize payload from the payload + finalizeIfaces, err := adapterABI.Methods["encodeFinalizePayload"].Inputs.Unpack(payload.Data) + if err != nil { + return nil, nil, fmt.Errorf("decode finalize payload: %w", err) + } + + if len(finalizeIfaces) != 1 { + return nil, nil, fmt.Errorf("decode finalize payload: expected 1 argument1, got %d", len(finalizeIfaces)) + } + + finalizePayload := *abi.ConvertType(finalizeIfaces[0], new(mock_l1_bridge_adapter.MockL1BridgeAdapterFinalizePayload)).(*mock_l1_bridge_adapter.MockL1BridgeAdapterFinalizePayload) + + return finalizePayload.Amount, finalizePayload.Nonce, nil +} + +func UnpackBridgeSendReturnData(data []byte) (*big.Int, error) { + return abiutils.UnpackUint256(data) +} + +func PackBridgeSendReturnData(nonce *big.Int) ([]byte, error) { + return utils.ABIEncode(`[{"type": "uint256"}]`, nonce) } type logKey struct { @@ -332,3 +530,35 @@ func parseLiquidityTransferred(parseFunc func(gethtypes.Log) (*rebalancer.Rebala } return transferred, toLP, nil } + +func parseLiquidityTransferredAndFinalizationStepCompleted( + transferredParse func(gethtypes.Log) (*rebalancer.RebalancerLiquidityTransferred, error), + finalizeParse func(gethtypes.Log) (*rebalancer.RebalancerFinalizationStepCompleted, error), + lgs []logpoller.Log) ( + []*rebalancer.RebalancerFinalizationStepCompleted, + []*rebalancer.RebalancerLiquidityTransferred, + error, +) { + var finalizationStepCompletedLogs []*rebalancer.RebalancerFinalizationStepCompleted + var liquidityTransferredLogs []*rebalancer.RebalancerLiquidityTransferred + for _, lg := range lgs { + if bytes.Equal(lg.Topics[0], LiquidityTransferredTopic.Bytes()) { + parsed, err := transferredParse(lg.ToGethLog()) + if err != nil { + // should never happen + return nil, nil, fmt.Errorf("parse LiquidityTransferred log: %w", err) + } + liquidityTransferredLogs = append(liquidityTransferredLogs, parsed) + } else if bytes.Equal(lg.Topics[0], FinalizationStepCompletedTopic.Bytes()) { + parsed, err := finalizeParse(lg.ToGethLog()) + if err != nil { + // should never happen + return nil, nil, fmt.Errorf("parse FinalizationStepCompleted log: %w", err) + } + finalizationStepCompletedLogs = append(finalizationStepCompletedLogs, parsed) + } else { + return nil, nil, fmt.Errorf("unexpected topic: %x", lg.Topics[0]) + } + } + return finalizationStepCompletedLogs, liquidityTransferredLogs, nil +} diff --git a/core/services/ocr2/plugins/rebalancer/bridge/testonlybridge/l1_to_l1_test.go b/core/services/ocr2/plugins/rebalancer/bridge/testonlybridge/l1_to_l1_test.go new file mode 100644 index 0000000000..864d2a0907 --- /dev/null +++ b/core/services/ocr2/plugins/rebalancer/bridge/testonlybridge/l1_to_l1_test.go @@ -0,0 +1,741 @@ +package testonlybridge + +import ( + "fmt" + "math/big" + "strings" + "testing" + "time" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/stretchr/testify/mock" + "github.com/stretchr/testify/require" + + evmclient_mocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client/mocks" + "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller" + lp_mocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller/mocks" + "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils" + ubig "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils/big" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/rebalancer/generated/mock_l1_bridge_adapter" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/rebalancer/generated/rebalancer" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" + "github.com/smartcontractkit/chainlink/v2/core/logger" + "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/rebalancer/models" +) + +func Test_testBridge_toPendingTransfers(t *testing.T) { + var ( + sourceSelector = models.NetworkSelector(1) + destSelector = models.NetworkSelector(2) + localToken = models.Address(testutils.NewAddress()) + remoteToken = models.Address(testutils.NewAddress()) + sourceAdapterAddress = models.Address(testutils.NewAddress()) + destRebalancerAddress = models.Address(testutils.NewAddress()) + ) + sourceAdapter, err := mock_l1_bridge_adapter.NewMockL1BridgeAdapter(common.Address(sourceAdapterAddress), nil) + require.NoError(t, err) + destRebalancer, err := rebalancer.NewRebalancer(common.Address(destRebalancerAddress), nil) + require.NoError(t, err) + type fields struct { + sourceSelector models.NetworkSelector + destSelector models.NetworkSelector + destRebalancer rebalancer.RebalancerInterface + sourceAdapter mock_l1_bridge_adapter.MockL1BridgeAdapterInterface + lggr logger.Logger + } + type args struct { + localToken models.Address + remoteToken models.Address + readyToProve []*rebalancer.RebalancerLiquidityTransferred + readyToFinalize []*rebalancer.RebalancerLiquidityTransferred + parsedToLP map[logKey]logpoller.Log + } + tests := []struct { + name string + fields fields + args args + want []models.PendingTransfer + }{ + { + "no pending transfers", + fields{ + sourceSelector: sourceSelector, + destSelector: destSelector, + destRebalancer: destRebalancer, + sourceAdapter: sourceAdapter, + lggr: logger.TestLogger(t), + }, + args{ + localToken: localToken, + remoteToken: remoteToken, + readyToProve: []*rebalancer.RebalancerLiquidityTransferred{}, + readyToFinalize: []*rebalancer.RebalancerLiquidityTransferred{}, + parsedToLP: map[logKey]logpoller.Log{}, + }, + nil, + }, + { + "some pending transfers, all ready to prove", + fields{ + sourceSelector: sourceSelector, + destSelector: destSelector, + destRebalancer: destRebalancer, + sourceAdapter: sourceAdapter, + lggr: logger.TestLogger(t), + }, + args{ + localToken: localToken, + remoteToken: remoteToken, + readyToProve: []*rebalancer.RebalancerLiquidityTransferred{ + { + Amount: big.NewInt(1), + BridgeReturnData: mustPackSendReturnData(t, big.NewInt(1)), + Raw: types.Log{ + TxHash: common.HexToHash("0x1"), + Index: 1, + }, + }, + { + Amount: big.NewInt(2), + BridgeReturnData: mustPackSendReturnData(t, big.NewInt(2)), + Raw: types.Log{ + TxHash: common.HexToHash("0x2"), + Index: 2, + }, + }, + }, + readyToFinalize: []*rebalancer.RebalancerLiquidityTransferred{}, + parsedToLP: map[logKey]logpoller.Log{ + {txHash: common.HexToHash("0x1"), logIndex: 1}: { + BlockTimestamp: mustParseTime(t, "2021-01-01T00:00:00Z"), + }, + {txHash: common.HexToHash("0x2"), logIndex: 2}: { + BlockTimestamp: mustParseTime(t, "2021-01-02T00:00:00Z"), + }, + }, + }, + []models.PendingTransfer{ + { + Transfer: models.Transfer{ + From: sourceSelector, + To: destSelector, + Sender: sourceAdapterAddress, + Receiver: destRebalancerAddress, + LocalTokenAddress: localToken, + RemoteTokenAddress: remoteToken, + Date: mustParseTime(t, "2021-01-01T00:00:00Z"), + Amount: ubig.NewI(1), + BridgeData: mustPackProvePayload(t, big.NewInt(1)), + Stage: 1, + }, + Status: models.TransferStatusReady, + ID: fmt.Sprintf("%s-%d-prove", common.HexToHash("0x1"), 1), + }, + { + Transfer: models.Transfer{ + From: sourceSelector, + To: destSelector, + Sender: sourceAdapterAddress, + Receiver: destRebalancerAddress, + LocalTokenAddress: localToken, + RemoteTokenAddress: remoteToken, + Date: mustParseTime(t, "2021-01-02T00:00:00Z"), + Amount: ubig.NewI(2), + BridgeData: mustPackProvePayload(t, big.NewInt(2)), + Stage: 1, + }, + Status: models.TransferStatusReady, + ID: fmt.Sprintf("%s-%d-prove", common.HexToHash("0x2"), 2), + }, + }, + }, + { + "some pending transfers, all ready to finalize", + fields{ + sourceSelector: sourceSelector, + destSelector: destSelector, + destRebalancer: destRebalancer, + sourceAdapter: sourceAdapter, + lggr: logger.TestLogger(t), + }, + args{ + localToken: localToken, + remoteToken: remoteToken, + readyToProve: []*rebalancer.RebalancerLiquidityTransferred{}, + readyToFinalize: []*rebalancer.RebalancerLiquidityTransferred{ + { + Amount: big.NewInt(1), + BridgeReturnData: mustPackSendReturnData(t, big.NewInt(1)), + Raw: types.Log{ + TxHash: common.HexToHash("0x1"), + Index: 1, + }, + }, + { + Amount: big.NewInt(2), + BridgeReturnData: mustPackSendReturnData(t, big.NewInt(2)), + Raw: types.Log{ + TxHash: common.HexToHash("0x2"), + Index: 2, + }, + }, + }, + parsedToLP: map[logKey]logpoller.Log{ + {txHash: common.HexToHash("0x1"), logIndex: 1}: { + BlockTimestamp: mustParseTime(t, "2021-01-01T00:00:00Z"), + }, + {txHash: common.HexToHash("0x2"), logIndex: 2}: { + BlockTimestamp: mustParseTime(t, "2021-01-02T00:00:00Z"), + }, + }, + }, + []models.PendingTransfer{ + { + Transfer: models.Transfer{ + From: sourceSelector, + To: destSelector, + Sender: sourceAdapterAddress, + Receiver: destRebalancerAddress, + LocalTokenAddress: localToken, + RemoteTokenAddress: remoteToken, + Date: mustParseTime(t, "2021-01-01T00:00:00Z"), + Amount: ubig.NewI(1), + BridgeData: mustPackFinalizePayload(t, big.NewInt(1), big.NewInt(1)), + Stage: 2, + }, + Status: models.TransferStatusReady, + ID: fmt.Sprintf("%s-%d-finalize", common.HexToHash("0x1"), 1), + }, + { + Transfer: models.Transfer{ + From: sourceSelector, + To: destSelector, + Sender: sourceAdapterAddress, + Receiver: destRebalancerAddress, + LocalTokenAddress: localToken, + RemoteTokenAddress: remoteToken, + Date: mustParseTime(t, "2021-01-02T00:00:00Z"), + Amount: ubig.NewI(2), + BridgeData: mustPackFinalizePayload(t, big.NewInt(2), big.NewInt(2)), + Stage: 2, + }, + Status: models.TransferStatusReady, + ID: fmt.Sprintf("%s-%d-finalize", common.HexToHash("0x2"), 2), + }, + }, + }, + { + "some pending transfers, someready to finalize, some ready to prove", + fields{ + sourceSelector: sourceSelector, + destSelector: destSelector, + destRebalancer: destRebalancer, + sourceAdapter: sourceAdapter, + lggr: logger.TestLogger(t), + }, + args{ + localToken: localToken, + remoteToken: remoteToken, + readyToProve: []*rebalancer.RebalancerLiquidityTransferred{ + { + Amount: big.NewInt(3), + BridgeReturnData: mustPackSendReturnData(t, big.NewInt(3)), + Raw: types.Log{ + TxHash: common.HexToHash("0x3"), + Index: 3, + }, + }, + { + Amount: big.NewInt(4), + BridgeReturnData: mustPackSendReturnData(t, big.NewInt(4)), + Raw: types.Log{ + TxHash: common.HexToHash("0x4"), + Index: 4, + }, + }, + }, + readyToFinalize: []*rebalancer.RebalancerLiquidityTransferred{ + { + Amount: big.NewInt(1), + BridgeReturnData: mustPackSendReturnData(t, big.NewInt(1)), + Raw: types.Log{ + TxHash: common.HexToHash("0x1"), + Index: 1, + }, + }, + { + Amount: big.NewInt(2), + BridgeReturnData: mustPackSendReturnData(t, big.NewInt(2)), + Raw: types.Log{ + TxHash: common.HexToHash("0x2"), + Index: 2, + }, + }, + }, + parsedToLP: map[logKey]logpoller.Log{ + {txHash: common.HexToHash("0x1"), logIndex: 1}: { + BlockTimestamp: mustParseTime(t, "2021-01-01T00:00:00Z"), + }, + {txHash: common.HexToHash("0x2"), logIndex: 2}: { + BlockTimestamp: mustParseTime(t, "2021-01-02T00:00:00Z"), + }, + {txHash: common.HexToHash("0x3"), logIndex: 3}: { + BlockTimestamp: mustParseTime(t, "2021-01-03T00:00:00Z"), + }, + {txHash: common.HexToHash("0x4"), logIndex: 4}: { + BlockTimestamp: mustParseTime(t, "2021-01-04T00:00:00Z"), + }, + }, + }, + []models.PendingTransfer{ + { + Transfer: models.Transfer{ + From: sourceSelector, + To: destSelector, + Sender: sourceAdapterAddress, + Receiver: destRebalancerAddress, + LocalTokenAddress: localToken, + RemoteTokenAddress: remoteToken, + Date: mustParseTime(t, "2021-01-03T00:00:00Z"), + Amount: ubig.NewI(3), + BridgeData: mustPackProvePayload(t, big.NewInt(3)), + Stage: 1, + }, + Status: models.TransferStatusReady, + ID: fmt.Sprintf("%s-%d-prove", common.HexToHash("0x3"), 3), + }, + { + Transfer: models.Transfer{ + From: sourceSelector, + To: destSelector, + Sender: sourceAdapterAddress, + Receiver: destRebalancerAddress, + LocalTokenAddress: localToken, + RemoteTokenAddress: remoteToken, + Date: mustParseTime(t, "2021-01-04T00:00:00Z"), + Amount: ubig.NewI(4), + BridgeData: mustPackProvePayload(t, big.NewInt(4)), + Stage: 1, + }, + Status: models.TransferStatusReady, + ID: fmt.Sprintf("%s-%d-prove", common.HexToHash("0x4"), 4), + }, + { + Transfer: models.Transfer{ + From: sourceSelector, + To: destSelector, + Sender: sourceAdapterAddress, + Receiver: destRebalancerAddress, + LocalTokenAddress: localToken, + RemoteTokenAddress: remoteToken, + Date: mustParseTime(t, "2021-01-01T00:00:00Z"), + Amount: ubig.NewI(1), + BridgeData: mustPackFinalizePayload(t, big.NewInt(1), big.NewInt(1)), + Stage: 2, + }, + Status: models.TransferStatusReady, + ID: fmt.Sprintf("%s-%d-finalize", common.HexToHash("0x1"), 1), + }, + { + Transfer: models.Transfer{ + From: sourceSelector, + To: destSelector, + Sender: sourceAdapterAddress, + Receiver: destRebalancerAddress, + LocalTokenAddress: localToken, + RemoteTokenAddress: remoteToken, + Date: mustParseTime(t, "2021-01-02T00:00:00Z"), + Amount: ubig.NewI(2), + BridgeData: mustPackFinalizePayload(t, big.NewInt(2), big.NewInt(2)), + Stage: 2, + }, + Status: models.TransferStatusReady, + ID: fmt.Sprintf("%s-%d-finalize", common.HexToHash("0x2"), 2), + }, + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + tr := &testBridge{ + sourceSelector: tt.fields.sourceSelector, + destSelector: tt.fields.destSelector, + destRebalancer: tt.fields.destRebalancer, + sourceAdapter: tt.fields.sourceAdapter, + lggr: tt.fields.lggr, + } + got, err := tr.toPendingTransfers(tt.args.localToken, tt.args.remoteToken, tt.args.readyToProve, tt.args.readyToFinalize, tt.args.parsedToLP) + require.NoError(t, err) + require.Equal(t, tt.want, got) + }) + } +} + +func mustParseTime(t *testing.T, s string) time.Time { + tm, err := time.Parse(time.RFC3339, s) + require.NoError(t, err) + return tm +} + +func Test_filterFinalized(t *testing.T) { + type args struct { + sends []*rebalancer.RebalancerLiquidityTransferred + finalizes []*rebalancer.RebalancerLiquidityTransferred + } + tests := []struct { + name string + args args + want []*rebalancer.RebalancerLiquidityTransferred + wantErr bool + }{ + { + "no finalizes", + args{ + []*rebalancer.RebalancerLiquidityTransferred{ + { + Amount: big.NewInt(1), + BridgeReturnData: mustPackSendReturnData(t, big.NewInt(1)), + }, + { + Amount: big.NewInt(2), + BridgeReturnData: mustPackSendReturnData(t, big.NewInt(2)), + }, + { + Amount: big.NewInt(3), + BridgeReturnData: mustPackSendReturnData(t, big.NewInt(3)), + }, + }, + []*rebalancer.RebalancerLiquidityTransferred{}, + }, + []*rebalancer.RebalancerLiquidityTransferred{ + { + Amount: big.NewInt(1), + BridgeReturnData: mustPackSendReturnData(t, big.NewInt(1)), + }, + { + Amount: big.NewInt(2), + BridgeReturnData: mustPackSendReturnData(t, big.NewInt(2)), + }, + { + Amount: big.NewInt(3), + BridgeReturnData: mustPackSendReturnData(t, big.NewInt(3)), + }, + }, + false, + }, + { + "some finalizes", + args{ + []*rebalancer.RebalancerLiquidityTransferred{ + { + Amount: big.NewInt(1), + BridgeReturnData: mustPackSendReturnData(t, big.NewInt(1)), + }, + { + Amount: big.NewInt(2), + BridgeReturnData: mustPackSendReturnData(t, big.NewInt(2)), + }, + { + Amount: big.NewInt(3), + BridgeReturnData: mustPackSendReturnData(t, big.NewInt(3)), + }, + }, + []*rebalancer.RebalancerLiquidityTransferred{ + { + Amount: big.NewInt(2), + BridgeSpecificData: mustPackFinalizePayload(t, big.NewInt(2), big.NewInt(2)), + }, + }, + }, + []*rebalancer.RebalancerLiquidityTransferred{ + { + Amount: big.NewInt(1), + BridgeReturnData: mustPackSendReturnData(t, big.NewInt(1)), + }, + { + Amount: big.NewInt(3), + BridgeReturnData: mustPackSendReturnData(t, big.NewInt(3)), + }, + }, + false, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + got, err := filterFinalized(tt.args.sends, tt.args.finalizes) + if tt.wantErr { + require.Error(t, err) + } else { + require.NoError(t, err) + require.Equal(t, tt.want, got) + } + }) + } +} + +func Test_groupByStage(t *testing.T) { + type args struct { + unfinalized []*rebalancer.RebalancerLiquidityTransferred + stepsCompleted []*rebalancer.RebalancerFinalizationStepCompleted + } + tests := []struct { + name string + args args + wantReadyToProve []*rebalancer.RebalancerLiquidityTransferred + wantReadyToFinalize []*rebalancer.RebalancerLiquidityTransferred + wantErr bool + }{ + { + "all ready to prove", + args{ + []*rebalancer.RebalancerLiquidityTransferred{ + { + Amount: big.NewInt(1), + BridgeReturnData: mustPackSendReturnData(t, big.NewInt(1)), + }, + { + Amount: big.NewInt(2), + BridgeReturnData: mustPackSendReturnData(t, big.NewInt(2)), + }, + { + Amount: big.NewInt(3), + BridgeReturnData: mustPackSendReturnData(t, big.NewInt(3)), + }, + }, + []*rebalancer.RebalancerFinalizationStepCompleted{}, // none proven + }, + []*rebalancer.RebalancerLiquidityTransferred{ + { + Amount: big.NewInt(1), + BridgeReturnData: mustPackSendReturnData(t, big.NewInt(1)), + }, + { + Amount: big.NewInt(2), + BridgeReturnData: mustPackSendReturnData(t, big.NewInt(2)), + }, + { + Amount: big.NewInt(3), + BridgeReturnData: mustPackSendReturnData(t, big.NewInt(3)), + }, + }, + nil, + false, + }, + { + "all ready to finalize", + args{ + []*rebalancer.RebalancerLiquidityTransferred{ + { + Amount: big.NewInt(1), + BridgeReturnData: mustPackSendReturnData(t, big.NewInt(1)), + }, + { + Amount: big.NewInt(2), + BridgeReturnData: mustPackSendReturnData(t, big.NewInt(2)), + }, + { + Amount: big.NewInt(3), + BridgeReturnData: mustPackSendReturnData(t, big.NewInt(3)), + }, + }, + []*rebalancer.RebalancerFinalizationStepCompleted{ // all proven + { + BridgeSpecificData: mustPackProvePayload(t, big.NewInt(1)), + }, + { + BridgeSpecificData: mustPackProvePayload(t, big.NewInt(2)), + }, + { + BridgeSpecificData: mustPackProvePayload(t, big.NewInt(3)), + }, + }, + }, + nil, + []*rebalancer.RebalancerLiquidityTransferred{ + { + Amount: big.NewInt(1), + BridgeReturnData: mustPackSendReturnData(t, big.NewInt(1)), + }, + { + Amount: big.NewInt(2), + BridgeReturnData: mustPackSendReturnData(t, big.NewInt(2)), + }, + { + Amount: big.NewInt(3), + BridgeReturnData: mustPackSendReturnData(t, big.NewInt(3)), + }, + }, + false, + }, + { + "mix of ready to prove and ready to finalize", + args{ + []*rebalancer.RebalancerLiquidityTransferred{ + { + Amount: big.NewInt(1), + BridgeReturnData: mustPackSendReturnData(t, big.NewInt(1)), + }, + { + Amount: big.NewInt(2), + BridgeReturnData: mustPackSendReturnData(t, big.NewInt(2)), + }, + { + Amount: big.NewInt(3), + BridgeReturnData: mustPackSendReturnData(t, big.NewInt(3)), + }, + { + Amount: big.NewInt(4), + BridgeReturnData: mustPackSendReturnData(t, big.NewInt(4)), + }, + }, + []*rebalancer.RebalancerFinalizationStepCompleted{ // 1 and 3 already proven, ready to finalize + { + BridgeSpecificData: mustPackProvePayload(t, big.NewInt(1)), + }, + { + BridgeSpecificData: mustPackProvePayload(t, big.NewInt(3)), + }, + }, + }, + []*rebalancer.RebalancerLiquidityTransferred{ + { + Amount: big.NewInt(2), + BridgeReturnData: mustPackSendReturnData(t, big.NewInt(2)), + }, + { + Amount: big.NewInt(4), + BridgeReturnData: mustPackSendReturnData(t, big.NewInt(4)), + }, + }, + []*rebalancer.RebalancerLiquidityTransferred{ + { + Amount: big.NewInt(1), + BridgeReturnData: mustPackSendReturnData(t, big.NewInt(1)), + }, + { + Amount: big.NewInt(3), + BridgeReturnData: mustPackSendReturnData(t, big.NewInt(3)), + }, + }, + false, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + gotReadyToProve, gotReadyToFinalize, err := groupByStage(tt.args.unfinalized, tt.args.stepsCompleted) + if tt.wantErr { + require.Error(t, err) + } else { + require.NoError(t, err) + require.Equal(t, tt.wantReadyToProve, gotReadyToProve) + require.Equal(t, tt.wantReadyToFinalize, gotReadyToFinalize) + } + }) + } +} + +func mustPackSendReturnData(t *testing.T, nonce *big.Int) []byte { + packed, err := utils.ABIEncode(`[{"type": "uint256"}]`, nonce) + require.NoError(t, err) + return packed +} + +func mustPackFinalizePayload(t *testing.T, nonce, amount *big.Int) []byte { + packed, err := PackFinalizeBridgePayload(amount, nonce) + require.NoError(t, err) + return packed +} + +func mustPackProvePayload(t *testing.T, nonce *big.Int) []byte { + packed, err := PackProveBridgePayload(nonce) + require.NoError(t, err) + return packed +} + +func TestNew(t *testing.T) { + var ( + sourceSelector = models.NetworkSelector(1) + destSelector = models.NetworkSelector(2) + sourceRebalancerAddress = models.Address(testutils.NewAddress()) + destRebalancerAddress = models.Address(testutils.NewAddress()) + sourceAdapterAddress = models.Address(testutils.NewAddress()) + destAdapterAddress = models.Address(testutils.NewAddress()) + ) + type args struct { + sourceSelector models.NetworkSelector + destSelector models.NetworkSelector + sourceRebalancerAddress models.Address + destRebalancerAddress models.Address + sourceAdapter models.Address + destAdapter models.Address + sourceLogPoller *lp_mocks.LogPoller + destLogPoller *lp_mocks.LogPoller + sourceClient *evmclient_mocks.Client + destClient *evmclient_mocks.Client + lggr logger.Logger + } + tests := []struct { + name string + args args + expect func(t *testing.T, args args) + assert func(t *testing.T, args args) + wantErr bool + }{ + { + "happy path", + args{ + sourceSelector: sourceSelector, + destSelector: destSelector, + sourceRebalancerAddress: sourceRebalancerAddress, + destRebalancerAddress: destRebalancerAddress, + sourceAdapter: sourceAdapterAddress, + destAdapter: destAdapterAddress, + sourceLogPoller: lp_mocks.NewLogPoller(t), + destLogPoller: lp_mocks.NewLogPoller(t), + sourceClient: evmclient_mocks.NewClient(t), + destClient: evmclient_mocks.NewClient(t), + lggr: logger.TestLogger(t), + }, + func(t *testing.T, args args) { + args.sourceLogPoller.On("RegisterFilter", mock.Anything, mock.MatchedBy(func(f logpoller.Filter) bool { + ok := len(f.Addresses) == 1 + ok = ok && f.Addresses[0] == common.Address(args.sourceRebalancerAddress) + ok = ok && len(f.EventSigs) == 2 + ok = ok && f.EventSigs[0] == LiquidityTransferredTopic + ok = ok && f.EventSigs[1] == FinalizationStepCompletedTopic + ok = ok && strings.HasPrefix(f.Name, "Local-LiquidityTransferred-FinalizationCompleted") + return ok + })).Return(nil) + args.destLogPoller.On("RegisterFilter", mock.Anything, mock.MatchedBy(func(f logpoller.Filter) bool { + ok := len(f.Addresses) == 1 + ok = ok && f.Addresses[0] == common.Address(args.destRebalancerAddress) + ok = ok && len(f.EventSigs) == 2 + ok = ok && f.EventSigs[0] == LiquidityTransferredTopic + ok = ok && f.EventSigs[1] == FinalizationStepCompletedTopic + ok = ok && strings.HasPrefix(f.Name, "Remote-LiquidityTransferred-FinalizationCompleted") + return ok + })).Return(nil) + }, + func(t *testing.T, args args) { + args.sourceLogPoller.AssertExpectations(t) + args.destLogPoller.AssertExpectations(t) + }, + false, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + tt.expect(t, tt.args) + defer tt.assert(t, tt.args) + got, err := New(tt.args.sourceSelector, tt.args.destSelector, tt.args.sourceRebalancerAddress, tt.args.destRebalancerAddress, tt.args.sourceAdapter, tt.args.destAdapter, tt.args.sourceLogPoller, tt.args.destLogPoller, tt.args.sourceClient, tt.args.destClient, tt.args.lggr) + if tt.wantErr { + require.Error(t, err) + } else { + require.NoError(t, err) + require.NotNil(t, got) + tt.expect(t, tt.args) + } + }) + } +} diff --git a/core/services/ocr2/plugins/rebalancer/inflight/inflight.go b/core/services/ocr2/plugins/rebalancer/inflight/inflight.go index 182f95ed66..15093cdf4c 100644 --- a/core/services/ocr2/plugins/rebalancer/inflight/inflight.go +++ b/core/services/ocr2/plugins/rebalancer/inflight/inflight.go @@ -60,8 +60,19 @@ func (i *inflight) Expire(pending []models.PendingTransfer) int { To: p.To, Amount: p.Amount.String(), } - _, ok := i.transfers[k] - if ok { + t, ok := i.transfers[k] + // This check handles scenarios where the same transfer can be in-flight multiple times. + // This only arises in bridges that have multi-stage finalization, like Optimism, or the + // testonly bridge, which emulates Optimism. In that case, this is the scenario that arises: + // 1. Initial rebalance out of Optimism is sent to the chain, and the transfer is added to the inflight container. + // 2. The transfer is confirmed on-chain, and the inflight transfer is expired. This is regular so far. + // 3. The bridge transfer is now in a pending state, where we are waiting for it to be ready to prove on L1. + // 4. Once the transfer is ready to prove on L1, we generate the proof data and submit it to the rebalancer on L1. This is a new inflight transfer. + // 5. In the next round, we still notice that the transfer is ready to prove, so we return it from the bridge. However, it is not ready to remove from the + // inflight container, because its still inflight to L1. This stage check would return false because the stage of the inflight transfer is the same + // as the stage of the pending transfer provided. + // 6. The prove withdrawal tx is confirmed on L1, and the bridge notices that, so the transfer is then expired because it has a higher stage. + if ok && p.Stage > t.Stage { numExpired++ delete(i.transfers, k) } diff --git a/core/services/ocr2/plugins/rebalancer/inflight/inflight_test.go b/core/services/ocr2/plugins/rebalancer/inflight/inflight_test.go index 4b8e29c41f..b20e5431fa 100644 --- a/core/services/ocr2/plugins/rebalancer/inflight/inflight_test.go +++ b/core/services/ocr2/plugins/rebalancer/inflight/inflight_test.go @@ -107,6 +107,7 @@ func Test_inflight_Expire(t *testing.T) { From: 1, To: 2, Amount: ubig.NewI(1), + Stage: 0, }, }, }, @@ -121,13 +122,14 @@ func Test_inflight_Expire(t *testing.T) { }, }, { - "pending transfer", + "pending transfer with larger stage", fields{ items: map[transferID]models.Transfer{ {From: 1, To: 2, Amount: "1"}: { From: 1, To: 2, Amount: ubig.NewI(1), + Stage: 0, }, }, }, @@ -138,6 +140,7 @@ func Test_inflight_Expire(t *testing.T) { From: 1, To: 2, Amount: ubig.NewI(1), + Stage: 1, }, }, }, @@ -149,6 +152,37 @@ func Test_inflight_Expire(t *testing.T) { require.Len(t, i.transfers, 0) }, }, + { + "pending transfer with equal stage", + fields{ + items: map[transferID]models.Transfer{ + {From: 1, To: 2, Amount: "1"}: { + From: 1, + To: 2, + Amount: ubig.NewI(1), + Stage: 0, + }, + }, + }, + args{ + []models.PendingTransfer{ + { + Transfer: models.Transfer{ + From: 1, + To: 2, + Amount: ubig.NewI(1), + Stage: 0, + }, + }, + }, + }, + func(t *testing.T, i *inflight) { + require.Len(t, i.transfers, 1) + }, + func(t *testing.T, i *inflight) { + require.Len(t, i.transfers, 1) + }, + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { diff --git a/core/services/ocr2/plugins/rebalancer/internal/rebalancer_integration_test.go b/core/services/ocr2/plugins/rebalancer/internal/rebalancer_integration_test.go index 728fe1fabc..8ae8a1b716 100644 --- a/core/services/ocr2/plugins/rebalancer/internal/rebalancer_integration_test.go +++ b/core/services/ocr2/plugins/rebalancer/internal/rebalancer_integration_test.go @@ -63,7 +63,7 @@ var ( ) func TestRebalancer_Integration(t *testing.T) { - newTestUniverse(t, 2) + newTestUniverse(t, 2, false) } type ocr3Node struct { @@ -223,10 +223,10 @@ func setupNodeOCR3( } } -func newTestUniverse(t *testing.T, numChains int) { +func newTestUniverse(t *testing.T, numChains int, adapterHoldNative bool) { // create chains and deploy contracts owner, chains := createChains(t, numChains) - universes := deployContracts(t, owner, chains) + universes := deployContracts(t, owner, chains, adapterHoldNative) createConnectedNetwork(t, owner, chains, universes) transferBalances(t, owner, universes) mainContract := universes[mainChainID].rebalancer.Address() @@ -410,6 +410,7 @@ func waitForTransmissions( ) { start := uint64(1) liquidityTransferredSink := make(chan *rebalancer.RebalancerLiquidityTransferred) + finalizationStepSink := make(chan *rebalancer.RebalancerFinalizationStepCompleted) var subs []event.Subscription for _, uni := range universes { sub, err := uni.rebalancer.WatchLiquidityTransferred(&bind.WatchOpts{ @@ -417,6 +418,12 @@ func waitForTransmissions( }, liquidityTransferredSink, nil, nil, nil) require.NoError(t, err, "failed to create subscription") subs = append(subs, sub) + + sub, err = uni.rebalancer.WatchFinalizationStepCompleted(&bind.WatchOpts{ + Start: &start, + }, finalizationStepSink, nil, nil) + require.NoError(t, err, "failed to create subscription") + subs = append(subs, sub) } defer func() { for _, sub := range subs { @@ -449,6 +456,11 @@ func waitForTransmissions( } t.Fatal("received receive event without corresponding send event") } + case fsc := <-finalizationStepSink: + nonce, err := testonlybridge.UnpackProveBridgePayload(fsc.BridgeSpecificData) + require.NoError(t, err) + t.Log("received finalization step completed event with seqNr:", fsc.OcrSeqNum, + ", nonce:", nonce.String(), ", tx hash:", fsc.Raw.TxHash.String()) case <-ticker.C: t.Log("waiting for transmission or liquidity transferred event") } @@ -631,6 +643,7 @@ func deployContracts( t *testing.T, owner *bind.TransactOpts, chains map[int64]*backends.SimulatedBackend, + adapterHoldNative bool, ) ( universes map[int64]onchainUniverse, ) { @@ -691,7 +704,7 @@ func deployContracts( require.Equal(t, rebalancerAddr, actualRebalancer) // deploy the bridge adapter to point to the weth contract address - bridgeAdapterAddress, _, _, err := mock_l1_bridge_adapter.DeployMockL1BridgeAdapter(owner, backend, wethAddress) + bridgeAdapterAddress, _, _, err := mock_l1_bridge_adapter.DeployMockL1BridgeAdapter(owner, backend, wethAddress, adapterHoldNative) require.NoError(t, err, "failed to deploy mock l1 bridge adapter") backend.Commit() bridgeAdapter, err := mock_l1_bridge_adapter.NewMockL1BridgeAdapter(bridgeAdapterAddress, backend) diff --git a/core/services/ocr2/plugins/rebalancer/liquiditymanager/reportcodec_test.go b/core/services/ocr2/plugins/rebalancer/liquiditymanager/reportcodec_test.go index f6f33ac239..5a5be236c4 100644 --- a/core/services/ocr2/plugins/rebalancer/liquiditymanager/reportcodec_test.go +++ b/core/services/ocr2/plugins/rebalancer/liquiditymanager/reportcodec_test.go @@ -6,11 +6,11 @@ import ( "time" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/common/hexutil" "github.com/stretchr/testify/require" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/assets" ubig "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils/big" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/rebalancer/generated/rebalancer_report_encoder" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/rebalancer/bridge/testonlybridge" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/rebalancer/models" @@ -78,7 +78,20 @@ func TestEvmReportCodec(t *testing.T) { evmEncoder := NewEvmReportCodec() // an actual report from one integration test run // should consist of 1 send operation from 909606746561742123 to 3379446385462418246 - encodedReport := hexutil.MustDecode("0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000004563918244f4000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002ee634951ef71b46000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000004563918244f400000000000000000000000000000000000000000000000000000000000000000000") + packedBridgeData, err := testonlybridge.PackBridgeSendReturnData(big.NewInt(1)) + require.NoError(t, err) + encodedReport, err := evmEncoder.onchainReportArguments.Pack(rebalancer_report_encoder.IRebalancerLiquidityInstructions{ + SendLiquidityParams: []rebalancer_report_encoder.IRebalancerSendLiquidityParams{ + { + Amount: assets.Ether(5).ToInt(), + NativeBridgeFee: big.NewInt(0), + RemoteChainSelector: 3379446385462418246, + BridgeData: packedBridgeData, + }, + }, + ReceiveLiquidityParams: []rebalancer_report_encoder.IRebalancerReceiveLiquidityParams{}, + }) + require.NoError(t, err) _, instructions, err := evmEncoder.Decode( 909606746561742123, models.Address(common.HexToAddress("0x2033C546BC60900f8B765F0a8e7E2376a17cba5d")), @@ -91,10 +104,22 @@ func TestEvmReportCodec(t *testing.T) { require.Equal(t, big.NewInt(0).String(), instructions.SendLiquidityParams[0].NativeBridgeFee.String()) amount, err := testonlybridge.UnpackBridgeSendReturnData(instructions.SendLiquidityParams[0].BridgeData) require.NoError(t, err) - require.Equal(t, assets.Ether(5).ToInt().String(), amount.String()) + require.Equal(t, big.NewInt(1).String(), amount.String()) - // should consist of 1 receive instruction from 3379446385462418246 to 909606746561742123 - encodedReport = hexutil.MustDecode("0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000004563918244f400000000000000000000000000000000000000000000000000000c9f9284461c852b000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000004563918244f400000000000000000000000000000000000000000000000000000000000000000001") + // should consist of 1 receive instruction from 909606746561742123 to 3379446385462418246 + packedBridgeData, err = testonlybridge.PackFinalizeBridgePayload(assets.Ether(5).ToInt(), big.NewInt(1)) + require.NoError(t, err) + encodedReport, err = evmEncoder.onchainReportArguments.Pack(rebalancer_report_encoder.IRebalancerLiquidityInstructions{ + SendLiquidityParams: []rebalancer_report_encoder.IRebalancerSendLiquidityParams{}, + ReceiveLiquidityParams: []rebalancer_report_encoder.IRebalancerReceiveLiquidityParams{ + { + Amount: assets.Ether(5).ToInt(), + RemoteChainSelector: 909606746561742123, + BridgeData: packedBridgeData, + }, + }, + }) + require.NoError(t, err) _, instructions, err = evmEncoder.Decode( 3379446385462418246, models.Address(common.HexToAddress("0x2033C546BC60900f8B765F0a8e7E2376a17cba5d")), diff --git a/core/services/ocr2/plugins/rebalancer/models/models.go b/core/services/ocr2/plugins/rebalancer/models/models.go index 53346b3172..4c116de964 100644 --- a/core/services/ocr2/plugins/rebalancer/models/models.go +++ b/core/services/ocr2/plugins/rebalancer/models/models.go @@ -106,6 +106,10 @@ type Transfer struct { BridgeData hexutil.Bytes // NativeBridgeFee is the fee that the bridge charges for the transfer. NativeBridgeFee *ubig.Big + // Stage is the stage of the transfer. + // This is primarily used for correct inflight tracking and expiry. + // In particular, only transfers with a strictly higher stage can expire a transfer with a lower stage. + Stage int // todo: consider adding some unique id field } @@ -144,11 +148,13 @@ func (t Transfer) Equals(other Transfer) bool { t.RemoteTokenAddress == other.RemoteTokenAddress && t.Amount.Cmp(other.Amount) == 0 && t.Date.Equal(other.Date) && - bytes.Equal(t.BridgeData, other.BridgeData) + bytes.Equal(t.BridgeData, other.BridgeData) && + t.NativeBridgeFee.Cmp(other.NativeBridgeFee) == 0 && + t.Stage == other.Stage } func (t Transfer) String() string { - return fmt.Sprintf("{From: %d, To: %d, Amount: %s, Sender: %s, Receiver: %s, LocalTokenAddress: %s, RemoteTokenAddress: %s, BridgeData: %s, NativeBridgeFee: %s}", + return fmt.Sprintf("{From: %d, To: %d, Amount: %s, Sender: %s, Receiver: %s, LocalTokenAddress: %s, RemoteTokenAddress: %s, BridgeData: %s, NativeBridgeFee: %s, Stage: %d}", t.From, t.To, t.Amount.String(), @@ -158,6 +164,7 @@ func (t Transfer) String() string { t.RemoteTokenAddress.String(), hexutil.Encode(t.BridgeData), t.NativeBridgeFee.String(), + t.Stage, ) } diff --git a/core/services/ocr2/plugins/rebalancer/plugin.go b/core/services/ocr2/plugins/rebalancer/plugin.go index 344ea701b2..b233f46de4 100644 --- a/core/services/ocr2/plugins/rebalancer/plugin.go +++ b/core/services/ocr2/plugins/rebalancer/plugin.go @@ -354,7 +354,8 @@ func (p *Plugin) ShouldAcceptAttestedReport(ctx context.Context, seqNr uint64, r } // add the transfers to the inflight container since none of them are inflight already. - for _, transfer := range report.Transfers { + // need to range through the meta because it has the correct stage information. + for _, transfer := range r.Info.Transfers { p.inflight.Add(transfer) } @@ -707,6 +708,7 @@ func (p *Plugin) resolveProposedTransfers(ctx context.Context, lggr logger.Logge } resolvedTransfer.BridgeData = bridgePayload resolvedTransfer.NativeBridgeFee = ubig.New(bridgeFee) + resolvedTransfer.Stage = 0 resolvedTransfers = append(resolvedTransfers, resolvedTransfer) } diff --git a/core/services/ocr2/plugins/rebalancer/plugin_test.go b/core/services/ocr2/plugins/rebalancer/plugin_test.go index 402a757b4d..42fae6d83d 100644 --- a/core/services/ocr2/plugins/rebalancer/plugin_test.go +++ b/core/services/ocr2/plugins/rebalancer/plugin_test.go @@ -11,6 +11,7 @@ import ( "time" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/common/hexutil" "github.com/smartcontractkit/libocr/commontypes" ocrtypes "github.com/smartcontractkit/libocr/offchainreporting2/types" "github.com/smartcontractkit/libocr/offchainreporting2plus/ocr3types" @@ -1190,7 +1191,7 @@ func TestPlugin_E2EWithMocks(t *testing.T) { br. On("GetBridgePayloadAndFee", mock.Anything, mock.Anything). - Return(nil, big.NewInt(10), nil).Maybe() + Return(nil, nativeBridgeFee, nil).Maybe() br. On("QuorumizedBridgePayload", mock.Anything, mock.Anything). @@ -1299,15 +1300,19 @@ func twoNodesFourRounds(t *testing.T) testCase { }, pendingTransfersPerNode: [][]models.PendingTransfer{{}, {}, {}, {}}, inflightPerNode: [][]models.Transfer{ - {models.NewTransfer(networkA, networkB, big.NewInt(1000), time.Time{}, nil)}, - {models.NewTransfer(networkA, networkB, big.NewInt(1000), time.Time{}, nil)}, - {models.NewTransfer(networkA, networkB, big.NewInt(1000), time.Time{}, nil)}, - {models.NewTransfer(networkA, networkB, big.NewInt(1000), time.Time{}, nil)}, + {models.Transfer{From: networkA, To: networkB, Amount: ubig.NewI(1000), LocalTokenAddress: tokenX, + RemoteTokenAddress: tokenY, Sender: rebalancerA, Receiver: rebalancerB, BridgeData: hexutil.Bytes{}, NativeBridgeFee: ubig.New(nativeBridgeFee)}}, + {models.Transfer{From: networkA, To: networkB, Amount: ubig.NewI(1000), LocalTokenAddress: tokenX, + RemoteTokenAddress: tokenY, Sender: rebalancerA, Receiver: rebalancerB, BridgeData: hexutil.Bytes{}, NativeBridgeFee: ubig.New(nativeBridgeFee)}}, + {models.Transfer{From: networkA, To: networkB, Amount: ubig.NewI(1000), LocalTokenAddress: tokenX, + RemoteTokenAddress: tokenY, Sender: rebalancerA, Receiver: rebalancerB, BridgeData: hexutil.Bytes{}, NativeBridgeFee: ubig.New(nativeBridgeFee)}}, + {models.Transfer{From: networkA, To: networkB, Amount: ubig.NewI(1000), LocalTokenAddress: tokenX, + RemoteTokenAddress: tokenY, Sender: rebalancerA, Receiver: rebalancerB, BridgeData: hexutil.Bytes{}, NativeBridgeFee: ubig.New(nativeBridgeFee)}}, }, expTransmitted: []ocr3types.ReportWithInfo[models.Report]{ { Info: models.Report{ - Transfers: []models.Transfer{models.NewTransfer(networkA, networkB, big.NewInt(1000), time.Time{}, nil)}, + Transfers: []models.Transfer{{From: networkA, To: networkB, Amount: ubig.NewI(1000), LocalTokenAddress: tokenX, RemoteTokenAddress: tokenY, Sender: rebalancerA, Receiver: rebalancerB}}, LiquidityManagerAddress: rebalancerA, NetworkID: networkA, ConfigDigest: cfgDigest1, @@ -1318,7 +1323,7 @@ func twoNodesFourRounds(t *testing.T) testCase { expNotAccepted: []ocr3types.ReportWithInfo[models.Report]{}, expOutcome: models.NewOutcome( nil, - []models.Transfer{{From: networkA, To: networkB, Amount: ubig.New(big.NewInt(1000))}}, + []models.Transfer{{From: networkA, To: networkB, Amount: ubig.NewI(1000), LocalTokenAddress: tokenX, RemoteTokenAddress: tokenY, Sender: rebalancerA, Receiver: rebalancerB}}, nil, []models.ConfigDigestWithMeta{{Digest: cfgDigest1, NetworkSel: networkA}, {Digest: cfgDigest2, NetworkSel: networkB}}), dataPerRebalancer: map[models.NetworkSelector]perRebalancerData{ @@ -1343,10 +1348,14 @@ func twoNodesFourRounds(t *testing.T) testCase { }, pendingTransfersPerNode: [][]models.PendingTransfer{{}, {}, {}, {}}, inflightPerNode: [][]models.Transfer{ - {models.NewTransfer(networkA, networkB, big.NewInt(1000), time.Time{}, nil)}, - {models.NewTransfer(networkA, networkB, big.NewInt(1000), time.Time{}, nil)}, - {models.NewTransfer(networkA, networkB, big.NewInt(1000), time.Time{}, nil)}, - {models.NewTransfer(networkA, networkB, big.NewInt(1000), time.Time{}, nil)}, + {models.Transfer{From: networkA, To: networkB, Amount: ubig.NewI(1000), LocalTokenAddress: tokenX, + RemoteTokenAddress: tokenY, Sender: rebalancerA, Receiver: rebalancerB, BridgeData: hexutil.Bytes{}, NativeBridgeFee: ubig.New(nativeBridgeFee)}}, + {models.Transfer{From: networkA, To: networkB, Amount: ubig.NewI(1000), LocalTokenAddress: tokenX, + RemoteTokenAddress: tokenY, Sender: rebalancerA, Receiver: rebalancerB, BridgeData: hexutil.Bytes{}, NativeBridgeFee: ubig.New(nativeBridgeFee)}}, + {models.Transfer{From: networkA, To: networkB, Amount: ubig.NewI(1000), LocalTokenAddress: tokenX, + RemoteTokenAddress: tokenY, Sender: rebalancerA, Receiver: rebalancerB, BridgeData: hexutil.Bytes{}, NativeBridgeFee: ubig.New(nativeBridgeFee)}}, + {models.Transfer{From: networkA, To: networkB, Amount: ubig.NewI(1000), LocalTokenAddress: tokenX, + RemoteTokenAddress: tokenY, Sender: rebalancerA, Receiver: rebalancerB, BridgeData: hexutil.Bytes{}, NativeBridgeFee: ubig.New(nativeBridgeFee)}}, }, expTransmitted: []ocr3types.ReportWithInfo[models.Report]{}, expNotTransmitted: []ocr3types.ReportWithInfo[models.Report]{}, @@ -1384,6 +1393,7 @@ func twoNodesFourRounds(t *testing.T) testCase { Amount: ubig.NewI(1000), LocalTokenAddress: tokenX, RemoteTokenAddress: tokenY, + Stage: 1, }, Status: models.TransferStatusNotReady, }, @@ -1395,6 +1405,7 @@ func twoNodesFourRounds(t *testing.T) testCase { Amount: ubig.NewI(1000), LocalTokenAddress: tokenX, RemoteTokenAddress: tokenY, + Stage: 1, }, Status: models.TransferStatusNotReady, }, @@ -1406,6 +1417,7 @@ func twoNodesFourRounds(t *testing.T) testCase { Amount: ubig.NewI(1000), LocalTokenAddress: tokenX, RemoteTokenAddress: tokenY, + Stage: 1, }, Status: models.TransferStatusNotReady, }, @@ -1417,6 +1429,7 @@ func twoNodesFourRounds(t *testing.T) testCase { Amount: ubig.NewI(1000), LocalTokenAddress: tokenX, RemoteTokenAddress: tokenY, + Stage: 1, }, Status: models.TransferStatusNotReady, }, @@ -1700,6 +1713,8 @@ var ( date2010 = time.Date(2010, 5, 6, 12, 4, 4, 0, time.UTC) date2011 = time.Date(2011, 5, 6, 12, 4, 4, 0, time.UTC) + + nativeBridgeFee = big.NewInt(10) ) // JsonReportCodec is used in tests