diff --git a/package.json b/package.json index 4e50177fb..767080b91 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@paraswap/dex-lib", - "version": "4.0.21", + "version": "4.0.22", "main": "build/index.js", "types": "build/index.d.ts", "repository": "https://github.com/paraswap/paraswap-dex-lib", diff --git a/src/dex/bebop/bebop.ts b/src/dex/bebop/bebop.ts index 42e9eda6d..32104674c 100644 --- a/src/dex/bebop/bebop.ts +++ b/src/dex/bebop/bebop.ts @@ -13,7 +13,7 @@ import { NumberAsString, DexExchangeParam, } from '../../types'; -import { SwapSide, Network, ETHER_ADDRESS } from '../../constants'; +import { SwapSide, Network } from '../../constants'; import * as CALLDATA_GAS_COST from '../../calldata-gas-cost'; import { getDexKeysWithNetwork, Utils } from '../../utils'; import { IDex } from '../../dex/idex'; @@ -56,11 +56,10 @@ import BigNumber from 'bignumber.js'; import { getBigNumberPow } from '../../bignumber-constants'; import { ethers, utils } from 'ethers'; import qs from 'qs'; -import { isEqual } from 'lodash'; export class Bebop extends SimpleExchange implements IDex { readonly hasConstantPriceLargeAmounts = false; - readonly needWrapNative = false; + readonly needWrapNative = true; readonly isFeeOnTransferSupported = false; readonly isStatePollingDex = true; @@ -186,11 +185,7 @@ export class Bebop extends SimpleExchange implements IDex { srcToken.address.toLowerCase(), destToken.address.toLowerCase(), ]); - const nativeWrappedSet = new Set([ - this.dexHelper.config.data.wrappedNativeTokenAddress.toLowerCase(), - ETHER_ADDRESS.toLowerCase(), - ]); - if (tokensSet.size < 2 || isEqual(tokensSet, nativeWrappedSet)) { + if (tokensSet.size < 2) { return []; } @@ -281,11 +276,14 @@ export class Bebop extends SimpleExchange implements IDex { // across DEXes. It is recommended to use // ${dexKey}_${poolAddress} as a poolIdentifier async getPoolIdentifiers( - srcToken: Token, - destToken: Token, + _srcToken: Token, + _destToken: Token, side: SwapSide, blockNumber: number, ): Promise { + const srcToken = this.dexHelper.config.wrapETH(_srcToken); + const destToken = this.dexHelper.config.wrapETH(_destToken); + if ( (await this.calculateInstructions(srcToken, destToken, side)).length > 0 ) { @@ -387,8 +385,8 @@ export class Bebop extends SimpleExchange implements IDex { // should be used. If limitPools is undefined then // any pools can be used. async getPricesVolume( - srcToken: Token, - destToken: Token, + _srcToken: Token, + _destToken: Token, amounts: bigint[], side: SwapSide, blockNumber: number, @@ -399,6 +397,9 @@ export class Bebop extends SimpleExchange implements IDex { return null; } + const srcToken = this.dexHelper.config.wrapETH(_srcToken); + const destToken = this.dexHelper.config.wrapETH(_destToken); + try { let pools = limitPools ? limitPools.filter( @@ -696,14 +697,17 @@ export class Bebop extends SimpleExchange implements IDex { async preProcessTransaction( optimalSwapExchange: OptimalSwapExchange, - srcToken: Token, - destToken: Token, + _srcToken: Token, + _destToken: Token, side: SwapSide, options: PreprocessTransactionOptions, ): Promise<[OptimalSwapExchange, ExchangeTxInfo]> { const isSell = side === SwapSide.SELL; const isBuy = side === SwapSide.BUY; + const srcToken = this.dexHelper.config.wrapETH(_srcToken); + const destToken = this.dexHelper.config.wrapETH(_destToken); + const params = { sell_tokens: utils.getAddress(srcToken.address), buy_tokens: utils.getAddress(destToken.address), diff --git a/src/dex/bebop/rate-fetcher.ts b/src/dex/bebop/rate-fetcher.ts index 37de21969..9fa87dd3e 100644 --- a/src/dex/bebop/rate-fetcher.ts +++ b/src/dex/bebop/rate-fetcher.ts @@ -1,4 +1,4 @@ -import { ETHER_ADDRESS, Network } from '../../constants'; +import { Network } from '../../constants'; import { IDexHelper } from '../../dex-helper'; import { Fetcher } from '../../lib/fetcher/fetcher'; import { validateAndCast, ValidationError } from '../../lib/validators'; @@ -10,11 +10,7 @@ import { BebopRateFetcherConfig, BebopTokensResponse, } from './types'; -import { - BebopPricingUpdate, - pricesResponseValidator, - tokensResponseValidator, -} from './validators'; +import { BebopPricingUpdate, tokensResponseValidator } from './validators'; import { WebSocketFetcher } from '../../lib/fetcher/wsFetcher'; import { utils } from 'ethers'; @@ -156,20 +152,9 @@ export class RateFetcher { } private handlePricesResponse(resp: BebopPricingResponse): void { - const wethAddress = - this.dexHelper.config.data.wrappedNativeTokenAddress.toLowerCase(); const normalizedPrices: BebopPricingResponse = {}; for (const [pair, levels] of Object.entries(resp)) { normalizedPrices[pair.toLowerCase()] = levels; - const [base, quote] = pair.split('/'); - // Also enter native token prices. Pricing doesn't come with these - if ( - base.toLowerCase() === wethAddress || - quote.toLowerCase() === wethAddress - ) { - const nativePair = pair.replace(base, ETHER_ADDRESS); - normalizedPrices[nativePair.toLowerCase()] = levels; - } } this.dexHelper.cache.setex(