Skip to content

Commit

Permalink
apply hotfix (#1428)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomjeatt authored Jul 6, 2023
1 parent b75f0ce commit 4a94ead
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/utils/hooks/transaction/utils/fee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ const getOptimalTradeForTxFeeSwap = (
return trade;
};

// NOTE: This function assumes that there is existing swap path between feeCurrency and
// native fee currency
const getTxFeeSwapData = async (
nativeTxFee: MonetaryAmount<CurrencyExt>,
feeCurrency: CurrencyExt,
Expand All @@ -50,9 +52,8 @@ const getTxFeeSwapData = async (
// First we construct reverse direction trade to get estimated swap path and amount
const reverseDirectionTrade = window.bridge.amm.getOptimalTrade(nativeTxFee, feeCurrency, pools);
if (reverseDirectionTrade === null) {
throw new Error(
`Not possible to exchange ${feeCurrency.name} for ${nativeTxFee.currency.name}: trade path not found.`
);
// If the trade is not found it means the input amount is too small - multiply it by 10 and repeat calculation.
return getTxFeeSwapData(nativeTxFee.mul(10), feeCurrency, baseExtrinsic, pools);
}
// Final native token transaction fee is estimated for base extrinsic wrapped in multiTransactionPayment call.
// NOTE: We assume here the reverse direction trade has similar weight.
Expand Down

2 comments on commit 4a94ead

@vercel
Copy link

@vercel vercel bot commented on 4a94ead Jul 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 4a94ead Jul 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.