Skip to content

Commit

Permalink
fix: dont request lifi quotes with 0 amount (#4973)
Browse files Browse the repository at this point in the history
  • Loading branch information
woodenfurniture authored and 0xdef1cafe committed Jul 31, 2023
1 parent 68e3a1d commit 8e15e9a
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/lib/swapper/swappers/LifiSwapper/endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import type {
Swapper2Api,
TradeQuote2,
} from 'lib/swapper/api'
import { makeSwapErrorRight, SwapErrorType } from 'lib/swapper/api'
import { getLifi } from 'lib/swapper/swappers/LifiSwapper/utils/getLifi'

import { getTradeQuote } from './getTradeQuote/getTradeQuote'
Expand All @@ -29,6 +30,14 @@ export const lifiApi: Swapper2Api = {
assets: Partial<Record<AssetId, Asset>>,
sellAssetPriceUsdPrecision: string,
): Promise<Result<TradeQuote2, SwapErrorRight>> => {
if (input.sellAmountBeforeFeesCryptoBaseUnit === '0') {
return Err(
makeSwapErrorRight({
message: 'sell amount too low',
code: SwapErrorType.TRADE_QUOTE_AMOUNT_TOO_SMALL,
}),
)
}
if (lifiChainMapPromise === undefined) lifiChainMapPromise = getLifiChainMap()

const maybeLifiChainMap = await lifiChainMapPromise
Expand Down

0 comments on commit 8e15e9a

Please sign in to comment.