Skip to content

Commit

Permalink
Fix _calculateFee for polkadot native token
Browse files Browse the repository at this point in the history
  • Loading branch information
yrong committed May 3, 2024
1 parent 63e8322 commit c887e7e
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion contracts/src/Gateway.sol
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,17 @@ contract Gateway is IGateway, IInitializable, IUpgradable {
// Ensure outbound messaging is allowed
_ensureOutboundMessagingEnabled(channel);

uint256 fee = _calculateFee(ticket.costs);
uint256 fee;
AssetsStorage.Layout storage $ = AssetsStorage.layout();
if (ticket.dest == $.assetHubParaID) {
fee = _calculateFee(ticket.costs);
} else {
// The assumption here is that no matter what the fee token is, usually the xcm execution cost on substrate chain is very tiny
// as demonstrated in https://www.notion.so/snowfork/Gateway-Parameters-0cf913d089374027a86721883306ee61
// the DELIVERY_COST on BH and TRANSFER_TOKEN_FEE are all no more than 0.1 DOT so the total cost as 0.2 DOT equals 0.00048 ETH.
// Consider a 5x buffer a hard code 0.002 ETH should be pretty enough to cover both costs
fee = 2000000000000000;
}

// Ensure the user has enough funds for this message to be accepted
if (msg.value < fee) {
Expand Down

0 comments on commit c887e7e

Please sign in to comment.