diff --git a/packages/asset-swapper/CHANGELOG.json b/packages/asset-swapper/CHANGELOG.json index dc11cc88be..35b6bdd0de 100644 --- a/packages/asset-swapper/CHANGELOG.json +++ b/packages/asset-swapper/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "version": "16.66.4", + "changes": [ + { + "note": "Offboard Cream", + "pr": 546 + } + ] + }, { "timestamp": 1660093941, "version": "16.66.3", diff --git a/packages/asset-swapper/package.json b/packages/asset-swapper/package.json index 2e844a2257..51bceaee47 100644 --- a/packages/asset-swapper/package.json +++ b/packages/asset-swapper/package.json @@ -84,7 +84,6 @@ "axios": "^0.21.1", "axios-mock-adapter": "^1.19.0", "balancer-labs-sor-v1": "npm:@balancer-labs/sor@0.3.2", - "cream-sor": "^0.3.3", "ethereum-types": "^3.7.0", "graphql": "^15.4.0", "graphql-request": "^3.4.0", diff --git a/packages/asset-swapper/src/swap_quoter.ts b/packages/asset-swapper/src/swap_quoter.ts index ff9bf46d8e..50d7e16c2c 100644 --- a/packages/asset-swapper/src/swap_quoter.ts +++ b/packages/asset-swapper/src/swap_quoter.ts @@ -144,7 +144,7 @@ export class SwapQuoter { this.chainId, samplerContract, samplerOverrides, - undefined, // pools caches for balancer and cream + undefined, // pools caches for balancer tokenAdjacencyGraph, liquidityProviderRegistry, this.chainId === ChainId.Mainnet // Enable Bancor only on Mainnet diff --git a/packages/asset-swapper/src/utils/market_operation_utils/constants.ts b/packages/asset-swapper/src/utils/market_operation_utils/constants.ts index 35851a66fe..70da3cf9d8 100644 --- a/packages/asset-swapper/src/utils/market_operation_utils/constants.ts +++ b/packages/asset-swapper/src/utils/market_operation_utils/constants.ts @@ -95,7 +95,6 @@ export const SELL_SOURCE_FILTER_BY_CHAIN_ID = valueByChainId( ERC20BridgeSource.MultiHop, ERC20BridgeSource.Dodo, ERC20BridgeSource.DodoV2, - ERC20BridgeSource.Cream, ERC20BridgeSource.LiquidityProvider, ERC20BridgeSource.CryptoCom, ERC20BridgeSource.Lido, @@ -247,7 +246,6 @@ export const BUY_SOURCE_FILTER_BY_CHAIN_ID = valueByChainId( ERC20BridgeSource.MultiHop, ERC20BridgeSource.Dodo, ERC20BridgeSource.DodoV2, - ERC20BridgeSource.Cream, ERC20BridgeSource.Lido, ERC20BridgeSource.LiquidityProvider, ERC20BridgeSource.CryptoCom, @@ -2520,7 +2518,6 @@ export const DEFAULT_GAS_SCHEDULE: Required = { [ERC20BridgeSource.BalancerV2]: (fillData?: FillData) => { return 100e3 + ((fillData as BalancerV2BatchSwapFillData).swapSteps.length - 1) * 50e3; }, - [ERC20BridgeSource.Cream]: () => 120e3, [ERC20BridgeSource.MStable]: () => 200e3, [ERC20BridgeSource.MakerPsm]: (fillData?: FillData) => { const psmFillData = fillData as MakerPsmFillData; diff --git a/packages/asset-swapper/src/utils/market_operation_utils/orders.ts b/packages/asset-swapper/src/utils/market_operation_utils/orders.ts index 433715a291..9cd5cf71dd 100644 --- a/packages/asset-swapper/src/utils/market_operation_utils/orders.ts +++ b/packages/asset-swapper/src/utils/market_operation_utils/orders.ts @@ -8,7 +8,6 @@ import { MAX_UINT256, ZERO_AMOUNT } from './constants'; import { AaveV2FillData, AggregationError, - BalancerFillData, BalancerV2BatchSwapFillData, BalancerV2FillData, BancorFillData, @@ -101,8 +100,6 @@ export function getErc20BridgeSourceToBridgeSource(source: ERC20BridgeSource): s return encodeBridgeSourceId(BridgeProtocol.Bancor, 'Bancor'); case ERC20BridgeSource.Curve: return encodeBridgeSourceId(BridgeProtocol.Curve, 'Curve'); - case ERC20BridgeSource.Cream: - return encodeBridgeSourceId(BridgeProtocol.Balancer, 'Cream'); case ERC20BridgeSource.CryptoCom: return encodeBridgeSourceId(BridgeProtocol.CryptoCom, 'CryptoCom'); case ERC20BridgeSource.Dodo: @@ -258,10 +255,6 @@ export function createBridgeDataForBridgeOrder(order: OptimizedMarketBridgeOrder ]); break; case ERC20BridgeSource.Balancer: - case ERC20BridgeSource.Cream: - const balancerFillData = (order as OptimizedMarketBridgeOrder).fillData; - bridgeData = encoder.encode([balancerFillData.poolAddress]); - break; case ERC20BridgeSource.BalancerV2: { const balancerV2FillData = (order as OptimizedMarketBridgeOrder).fillData; @@ -505,7 +498,6 @@ export const BRIDGE_ENCODERS: { [ERC20BridgeSource.Mooniswap]: poolEncoder, [ERC20BridgeSource.MStable]: poolEncoder, [ERC20BridgeSource.Balancer]: poolEncoder, - [ERC20BridgeSource.Cream]: poolEncoder, [ERC20BridgeSource.Uniswap]: poolEncoder, // Custom integrations [ERC20BridgeSource.MakerPsm]: makerPsmEncoder, diff --git a/packages/asset-swapper/src/utils/market_operation_utils/pools_cache/cream_pools_cache.ts b/packages/asset-swapper/src/utils/market_operation_utils/pools_cache/cream_pools_cache.ts deleted file mode 100644 index 77a3ae2b26..0000000000 --- a/packages/asset-swapper/src/utils/market_operation_utils/pools_cache/cream_pools_cache.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { ChainId } from '@0x/contract-addresses'; -import { Pool } from 'balancer-labs-sor-v1/dist/types'; -import { getPoolsWithTokens, parsePoolData } from 'cream-sor'; - -import { BALANCER_MAX_POOLS_FETCHED } from '../constants'; - -import { NoOpPoolsCache } from './no_op_pools_cache'; -import { AbstractPoolsCache, CacheValue, PoolsCache } from './pools_cache'; - -export class CreamPoolsCache extends AbstractPoolsCache { - public static create(chainId: ChainId): PoolsCache { - if (chainId !== ChainId.Mainnet) { - return new NoOpPoolsCache(); - } - - return new CreamPoolsCache(); - } - protected async _fetchPoolsForPairAsync(takerToken: string, makerToken: string): Promise { - try { - const poolData = (await getPoolsWithTokens(takerToken, makerToken)).pools; - // Sort by maker token balance (descending) - const pools = parsePoolData(poolData, takerToken, makerToken).sort((a, b) => - b.balanceOut.minus(a.balanceOut).toNumber(), - ); - return pools.slice(0, this.maxPoolsFetched); - } catch (err) { - return []; - } - } - private constructor( - _cache: Map = new Map(), - private readonly maxPoolsFetched: number = BALANCER_MAX_POOLS_FETCHED, - ) { - super(_cache); - } -} diff --git a/packages/asset-swapper/src/utils/market_operation_utils/pools_cache/index.ts b/packages/asset-swapper/src/utils/market_operation_utils/pools_cache/index.ts index 0ed00eb9c9..f18f96fb7f 100644 --- a/packages/asset-swapper/src/utils/market_operation_utils/pools_cache/index.ts +++ b/packages/asset-swapper/src/utils/market_operation_utils/pools_cache/index.ts @@ -1,4 +1,3 @@ export { BalancerPoolsCache } from './balancer_pools_cache'; export { BalancerV2PoolsCache } from './balancer_v2_pools_cache'; -export { CreamPoolsCache } from './cream_pools_cache'; export { AbstractPoolsCache, PoolsCache } from './pools_cache'; diff --git a/packages/asset-swapper/src/utils/market_operation_utils/sampler_operations.ts b/packages/asset-swapper/src/utils/market_operation_utils/sampler_operations.ts index 07b132415a..698b1e1b07 100644 --- a/packages/asset-swapper/src/utils/market_operation_utils/sampler_operations.ts +++ b/packages/asset-swapper/src/utils/market_operation_utils/sampler_operations.ts @@ -58,7 +58,7 @@ import { } from './constants'; import { getGeistInfoForPair } from './geist_utils'; import { getLiquidityProvidersForPair } from './liquidity_provider_utils'; -import { BalancerPoolsCache, BalancerV2PoolsCache, CreamPoolsCache, PoolsCache } from './pools_cache'; +import { BalancerPoolsCache, BalancerV2PoolsCache, PoolsCache } from './pools_cache'; import { BalancerV2SwapInfoCache } from './pools_cache/balancer_v2_swap_info_cache'; import { SamplerContractOperation } from './sampler_contract_operation'; import { SamplerNoOperation } from './sampler_no_operation'; @@ -120,7 +120,6 @@ export interface PoolsCacheMap { [ERC20BridgeSource.Balancer]: PoolsCache; [ERC20BridgeSource.BalancerV2]: BalancerV2SwapInfoCache | undefined; [ERC20BridgeSource.Beethovenx]: PoolsCache; - [ERC20BridgeSource.Cream]: PoolsCache; } // tslint:disable:no-inferred-empty-object-type no-unbound-method @@ -160,7 +159,6 @@ export class SamplerOperations { : { [ERC20BridgeSource.Beethovenx]: BalancerV2PoolsCache.createBeethovenXPoolCache(chainId), [ERC20BridgeSource.Balancer]: BalancerPoolsCache.create(chainId), - [ERC20BridgeSource.Cream]: CreamPoolsCache.create(chainId), [ERC20BridgeSource.BalancerV2]: BALANCER_V2_VAULT_ADDRESS_BY_CHAIN[chainId] === NULL_ADDRESS ? undefined @@ -1668,18 +1666,6 @@ export class SamplerOperations { ), ); } - case ERC20BridgeSource.Cream: - return this.poolsCaches[ERC20BridgeSource.Cream] - .getPoolAddressesForPair(takerToken, makerToken) - .map(creamPool => - this.getBalancerSellQuotes( - creamPool, - makerToken, - takerToken, - takerFillAmounts, - ERC20BridgeSource.Cream, - ), - ); case ERC20BridgeSource.Dodo: if (!isValidAddress(DODOV1_CONFIG_BY_CHAIN_ID[this.chainId].registry)) { return []; @@ -2031,18 +2017,6 @@ export class SamplerOperations { ), ); } - case ERC20BridgeSource.Cream: - return this.poolsCaches[ERC20BridgeSource.Cream] - .getPoolAddressesForPair(takerToken, makerToken) - .map(poolAddress => - this.getBalancerBuyQuotes( - poolAddress, - makerToken, - takerToken, - makerFillAmounts, - ERC20BridgeSource.Cream, - ), - ); case ERC20BridgeSource.Dodo: if (!isValidAddress(DODOV1_CONFIG_BY_CHAIN_ID[this.chainId].registry)) { return []; diff --git a/packages/asset-swapper/src/utils/market_operation_utils/types.ts b/packages/asset-swapper/src/utils/market_operation_utils/types.ts index cf2b824a90..0faec653bb 100644 --- a/packages/asset-swapper/src/utils/market_operation_utils/types.ts +++ b/packages/asset-swapper/src/utils/market_operation_utils/types.ts @@ -44,7 +44,6 @@ export enum ERC20BridgeSource { MultiBridge = 'MultiBridge', Balancer = 'Balancer', BalancerV2 = 'Balancer_V2', - Cream = 'CREAM', Bancor = 'Bancor', MakerPsm = 'MakerPsm', MStable = 'mStable', diff --git a/packages/asset-swapper/test/market_operation_utils_test.ts b/packages/asset-swapper/test/market_operation_utils_test.ts index 4cf188c9e0..6e1cfaa2d3 100644 --- a/packages/asset-swapper/test/market_operation_utils_test.ts +++ b/packages/asset-swapper/test/market_operation_utils_test.ts @@ -107,7 +107,7 @@ class MockPoolsCache extends AbstractPoolsCache { } } -// Return some pool so that sampling functions are called for Balancer, BalancerV2, and Cream +// Return some pool so that sampling functions are called for Balancer and BalancerV2 // tslint:disable:custom-no-magic-numbers const mockPoolsCache = new MockPoolsCache((_takerToken: string, _makerToken: string) => { return [ @@ -361,7 +361,6 @@ describe('MarketOperationUtils tests', () => { [ERC20BridgeSource.MultiHop]: {}, [ERC20BridgeSource.Shell]: { poolAddress: randomAddress() }, [ERC20BridgeSource.Component]: { poolAddress: randomAddress() }, - [ERC20BridgeSource.Cream]: { poolAddress: randomAddress() }, [ERC20BridgeSource.Dodo]: {}, [ERC20BridgeSource.DodoV2]: {}, [ERC20BridgeSource.CryptoCom]: { tokenAddressPath: [] }, @@ -401,7 +400,6 @@ describe('MarketOperationUtils tests', () => { poolsCaches: { [ERC20BridgeSource.BalancerV2]: mockPoolsCache, [ERC20BridgeSource.Balancer]: mockPoolsCache, - [ERC20BridgeSource.Cream]: mockPoolsCache, }, liquidityProviderRegistry: {}, chainId: CHAIN_ID, diff --git a/packages/asset-swapper/test/pools_cache_test.ts b/packages/asset-swapper/test/pools_cache_test.ts index 6bd0683702..3ac2adc639 100644 --- a/packages/asset-swapper/test/pools_cache_test.ts +++ b/packages/asset-swapper/test/pools_cache_test.ts @@ -2,12 +2,7 @@ import { ChainId } from '@0x/contract-addresses'; import * as chai from 'chai'; import 'mocha'; -import { - BalancerPoolsCache, - BalancerV2PoolsCache, - CreamPoolsCache, - PoolsCache, -} from '../src/utils/market_operation_utils/pools_cache'; +import { BalancerPoolsCache, BalancerV2PoolsCache, PoolsCache } from '../src/utils/market_operation_utils/pools_cache'; import { chaiSetup } from './utils/chai_setup'; @@ -17,7 +12,6 @@ const expect = chai.expect; const usdcAddress = '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48'; const daiAddress = '0x6b175474e89094c44da98b954eedeac495271d0f'; const wethAddress = '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'; -const creamAddress = '0x2ba592f78db6436527729929aaf6c908497cb200'; const timeoutMs = 5000; const poolKeys: string[] = ['id', 'balanceIn', 'balanceOut', 'weightIn', 'weightOut', 'swapFee']; @@ -63,17 +57,4 @@ describe('Pools Caches for Balancer-based sampling', () => { ); }); }); - - describe('CreamPoolsCache', () => { - const cache = CreamPoolsCache.create(ChainId.Mainnet); - it('fetches pools', async () => { - const pairs = [ - [usdcAddress, creamAddress], - [creamAddress, wethAddress], - ]; - await Promise.all( - pairs.map(async ([takerToken, makerToken]) => fetchAndAssertPoolsAsync(cache, takerToken, makerToken)), - ); - }); - }); }); diff --git a/yarn.lock b/yarn.lock index 7c27a31c13..66c0bdcf07 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4905,13 +4905,6 @@ crc-32@^1.2.0: exit-on-epipe "~1.0.1" printj "~1.1.0" -cream-sor@^0.3.3: - version "0.3.3" - resolved "https://registry.yarnpkg.com/cream-sor/-/cream-sor-0.3.3.tgz#ae7ab50c68cfd36a89e2101187ceebbb79e1b14c" - dependencies: - bignumber.js "^9.0.0" - isomorphic-fetch "^2.2.1" - create-ecdh@^4.0.0: version "4.0.4" resolved "https://registry.yarnpkg.com/create-ecdh/-/create-ecdh-4.0.4.tgz#d6e7f4bffa66736085a0762fd3a632684dabcc4e"