From 22476311f6c9334942ea6070947029ad1643c889 Mon Sep 17 00:00:00 2001 From: Yorke Rhodes Date: Thu, 1 Aug 2024 16:33:46 -0400 Subject: [PATCH] Account for post dispatch fees --- .../middleware/TransferAndCallRouter.sol | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/solidity/contracts/middleware/TransferAndCallRouter.sol b/solidity/contracts/middleware/TransferAndCallRouter.sol index fe95ad545..4d0d12796 100644 --- a/solidity/contracts/middleware/TransferAndCallRouter.sol +++ b/solidity/contracts/middleware/TransferAndCallRouter.sol @@ -21,17 +21,16 @@ contract TransferAndCall { IERC20 asset, // not derivable from TokenRouter TokenRouter warpRoute, CallLib.Call[] calldata calls - ) public { + ) external payable { asset.transferFrom(msg.sender, address(this), amount); - address recipient = interchainAccountRouter.getRemoteInterchainAccount( + bytes32 self = interchainAccountRouter + .getRemoteInterchainAccount(destination, address(this)) + .addressToBytes32(); + uint256 warpFee = warpRoute.quoteGasPayment(destination); + warpRoute.transferRemote{value: warpFee}(destination, self, amount); + interchainAccountRouter.callRemote{value: msg.value - warpFee}( destination, - msg.sender + calls ); - warpRoute.transferRemote( - destination, - recipient.addressToBytes32(), - amount - ); - interchainAccountRouter.callRemote(destination, calls); } }