diff --git a/contracts/src/Assets.sol b/contracts/src/Assets.sol index cdf54a8b18..97ed7b405d 100644 --- a/contracts/src/Assets.sol +++ b/contracts/src/Assets.sol @@ -42,22 +42,21 @@ library Assets { IERC20(token).safeTransferFrom(sender, agent, amount); } - function sendTokenCosts( - address token, - ParaID destinationChain, - uint128 destinationChainFee, - uint128 maxDestinationChainFee - ) external view returns (Costs memory costs) { + function sendTokenCosts(address token, ParaID destinationChain, uint128 destinationChainFee) + external + view + returns (Costs memory costs) + { AssetsStorage.Layout storage $ = AssetsStorage.layout(); TokenInfo storage info = $.tokenRegistry[token]; if (!info.isRegistered) { revert TokenNotRegistered(); } - return _sendTokenCosts(destinationChain, destinationChainFee, maxDestinationChainFee); + return _sendTokenCosts(destinationChain, destinationChainFee); } - function _sendTokenCosts(ParaID destinationChain, uint128 destinationChainFee, uint128 maxDestinationChainFee) + function _sendTokenCosts(ParaID destinationChain, uint128 destinationChainFee) internal view returns (Costs memory costs) @@ -67,7 +66,7 @@ library Assets { costs.foreign = $.assetHubReserveTransferFee; } else { // Destination fee cannot be zero. MultiAssets are not allowed to be zero in xcm v4. - if (destinationChainFee == 0 || destinationChainFee > maxDestinationChainFee) { + if (destinationChainFee == 0) { revert InvalidDestinationFee(); } @@ -85,8 +84,7 @@ library Assets { ParaID destinationChain, MultiAddress calldata destinationAddress, uint128 destinationChainFee, - uint128 amount, - uint128 maxDestinationChainFee + uint128 amount ) external returns (Ticket memory ticket) { AssetsStorage.Layout storage $ = AssetsStorage.layout(); @@ -99,7 +97,7 @@ library Assets { _transferToAgent($.assetHubAgent, token, sender, amount); ticket.dest = $.assetHubParaID; - ticket.costs = _sendTokenCosts(destinationChain, destinationChainFee, maxDestinationChainFee); + ticket.costs = _sendTokenCosts(destinationChain, destinationChainFee); // Construct a message payload if (destinationChain == $.assetHubParaID) { diff --git a/contracts/src/Gateway.sol b/contracts/src/Gateway.sol index a5ce6346e7..fc2078909b 100644 --- a/contracts/src/Gateway.sol +++ b/contracts/src/Gateway.sol @@ -422,8 +422,7 @@ contract Gateway is IGateway, IInitializable { view returns (uint256) { - return - _calculateFee(Assets.sendTokenCosts(token, destinationChain, destinationFee, MAX_DESTINATION_TRANSFER_FEE)); + return _calculateFee(Assets.sendTokenCosts(token, destinationChain, destinationFee)); } // Transfer ERC20 tokens to a Polkadot parachain @@ -434,16 +433,12 @@ contract Gateway is IGateway, IInitializable { uint128 destinationFee, uint128 amount ) external payable { + if (destinationFee > MAX_DESTINATION_TRANSFER_FEE) { + revert Assets.InvalidDestinationFee(); + } + _submitOutbound( - Assets.sendToken( - token, - msg.sender, - destinationChain, - destinationAddress, - destinationFee, - amount, - MAX_DESTINATION_TRANSFER_FEE - ) + Assets.sendToken(token, msg.sender, destinationChain, destinationAddress, destinationFee, amount) ); } diff --git a/contracts/test/Gateway.t.sol b/contracts/test/Gateway.t.sol index 67d1b5da24..1d7def520c 100644 --- a/contracts/test/Gateway.t.sol +++ b/contracts/test/Gateway.t.sol @@ -942,8 +942,6 @@ contract GatewayTest is Test { IGateway(address(gateway)).registerToken{value: fee}(address(token)); uint128 largeFee = destinationMaxTransferFee + 1; // greater than 10 DOT, 10 decimal places - - vm.expectRevert(Assets.InvalidDestinationFee.selector); fee = IGateway(address(gateway)).quoteSendTokenFee(address(token), destPara, largeFee); vm.expectRevert(Assets.InvalidDestinationFee.selector);