Skip to content

Commit

Permalink
fix: amounts checks on swapper (#8106)
Browse files Browse the repository at this point in the history
  • Loading branch information
NeOMakinG authored Nov 8, 2024
1 parent b4bef5c commit 468585a
Showing 1 changed file with 16 additions and 19 deletions.
35 changes: 16 additions & 19 deletions src/state/apis/swapper/helpers/validateTradeQuote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,34 +257,31 @@ export const validateTradeQuote = (
},
},
!walletSupportsIntermediaryAssetChain &&
quoteOrRate === 'quote' &&
secondHop && {
error: TradeQuoteValidationError.IntermediaryAssetNotNotSupportedByWallet,
meta: {
assetSymbol: secondHop.sellAsset.symbol,
chainSymbol: getChainShortName(secondHop.sellAsset.chainId as KnownChainIds),
},
},
!firstHopHasSufficientBalanceForGas &&
quoteOrRate === 'rate' && {
error: TradeQuoteValidationError.InsufficientFirstHopFeeAssetBalance,
meta: {
assetSymbol: firstHopSellFeeAsset?.symbol,
chainSymbol: firstHopSellFeeAsset
? getChainShortName(firstHopSellFeeAsset.chainId as KnownChainIds)
: '',
},
!firstHopHasSufficientBalanceForGas && {
error: TradeQuoteValidationError.InsufficientFirstHopFeeAssetBalance,
meta: {
assetSymbol: firstHopSellFeeAsset?.symbol,
chainSymbol: firstHopSellFeeAsset
? getChainShortName(firstHopSellFeeAsset.chainId as KnownChainIds)
: '',
},
!secondHopHasSufficientBalanceForGas &&
quoteOrRate === 'rate' && {
error: TradeQuoteValidationError.InsufficientSecondHopFeeAssetBalance,
meta: {
assetSymbol: secondHopSellFeeAsset?.symbol,
chainSymbol: secondHopSellFeeAsset
? getChainShortName(secondHopSellFeeAsset.chainId as KnownChainIds)
: '',
},
},
!secondHopHasSufficientBalanceForGas && {
error: TradeQuoteValidationError.InsufficientSecondHopFeeAssetBalance,
meta: {
assetSymbol: secondHopSellFeeAsset?.symbol,
chainSymbol: secondHopSellFeeAsset
? getChainShortName(secondHopSellFeeAsset.chainId as KnownChainIds)
: '',
},
},
feesExceedsSellAmount && { error: TradeQuoteValidationError.SellAmountBelowTradeFee },
invalidQuoteSellAmount && { error: TradeQuoteValidationError.QuoteSellAmountInvalid },

Expand Down

0 comments on commit 468585a

Please sign in to comment.