Skip to content

Commit

Permalink
fix: fix asset_hub fee does not calculate delivery fee
Browse files Browse the repository at this point in the history
  • Loading branch information
qwer951123 committed Jul 4, 2024
1 parent e402137 commit a90f21f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,5 @@
"jest": "^28.1.1",
"typescript": "^4.7.4"
},
"stableVersion": "0.1.7-6"
"stableVersion": "0.1.7-7"
}
4 changes: 4 additions & 0 deletions src/adapters/assethub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,8 @@ class BaseAssetHubAdapter extends BaseCrossChainAdapter {
throw new ApiNotFound(this.chain.id);
}

const xcmDeliveryFee = this.getXcmDeliveryFee(token, to);

return combineLatest({
txFee:
token === this.balanceAdapter?.nativeToken
Expand All @@ -360,10 +362,12 @@ class BaseAssetHubAdapter extends BaseCrossChainAdapter {
const fee = FN.fromInner(txFee, tokenMeta?.decimals).mul(
new FN(feeFactor)
);
const deliveryFee = xcmDeliveryFee?.balance || FN.ZERO;

// always minus ed
return balance
.minus(fee)
.minus(deliveryFee)
.minus(FN.fromInner(tokenMeta?.ed || "0", tokenMeta?.decimals));
})
);
Expand Down

0 comments on commit a90f21f

Please sign in to comment.