diff --git a/packages/asset-swapper/CHANGELOG.json b/packages/asset-swapper/CHANGELOG.json index c854f56619..1ce19f9377 100644 --- a/packages/asset-swapper/CHANGELOG.json +++ b/packages/asset-swapper/CHANGELOG.json @@ -9,6 +9,10 @@ { "note": "Offboard Swerve Finance and LinkSwap", "pr": 469 + }, + { + "note": "Offboard Eth2Dai", + "pr": 470 } ] }, 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 32b86ca707..33e920d0da 100644 --- a/packages/asset-swapper/src/utils/market_operation_utils/constants.ts +++ b/packages/asset-swapper/src/utils/market_operation_utils/constants.ts @@ -44,6 +44,10 @@ export const SELL_SOURCE_FILTER_BY_CHAIN_ID = valueByChainId( ERC20BridgeSource.Native, ERC20BridgeSource.Uniswap, ERC20BridgeSource.UniswapV2, +<<<<<<< HEAD +======= + ERC20BridgeSource.Kyber, +>>>>>>> 9eadc5fc2 (chore: Offboard Eth2Dai [TKR-356] (#470)) ERC20BridgeSource.Curve, ERC20BridgeSource.Balancer, ERC20BridgeSource.BalancerV2, @@ -184,6 +188,10 @@ export const BUY_SOURCE_FILTER_BY_CHAIN_ID = valueByChainId( ERC20BridgeSource.Native, ERC20BridgeSource.Uniswap, ERC20BridgeSource.UniswapV2, +<<<<<<< HEAD +======= + ERC20BridgeSource.Kyber, +>>>>>>> 9eadc5fc2 (chore: Offboard Eth2Dai [TKR-356] (#470)) ERC20BridgeSource.Curve, ERC20BridgeSource.Balancer, ERC20BridgeSource.BalancerV2, @@ -2275,7 +2283,6 @@ export const DEFAULT_GAS_SCHEDULE: Required = { [ERC20BridgeSource.LiquidityProvider]: fillData => { return (fillData as LiquidityProviderFillData).gasCost || 100e3; }, - [ERC20BridgeSource.Eth2Dai]: () => 400e3, [ERC20BridgeSource.Kyber]: () => 450e3, [ERC20BridgeSource.Curve]: fillData => (fillData as CurveFillData).pool.gasSchedule, [ERC20BridgeSource.CurveV2]: fillData => (fillData as CurveFillData).pool.gasSchedule, 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 8450353cc5..6e612983ad 100644 --- a/packages/asset-swapper/src/utils/market_operation_utils/orders.ts +++ b/packages/asset-swapper/src/utils/market_operation_utils/orders.ts @@ -270,10 +270,6 @@ export function createBridgeDataForBridgeOrder(order: OptimizedMarketBridgeOrder const uniFillData = (order as OptimizedMarketBridgeOrder).fillData; bridgeData = encoder.encode([uniFillData.router]); break; - case ERC20BridgeSource.Eth2Dai: - const oasisFillData = (order as OptimizedMarketBridgeOrder).fillData; - bridgeData = encoder.encode([oasisFillData.router]); - break; case ERC20BridgeSource.MStable: const mStableFillData = (order as OptimizedMarketBridgeOrder).fillData; bridgeData = encoder.encode([mStableFillData.router]); @@ -434,7 +430,6 @@ export const BRIDGE_ENCODERS: { [ERC20BridgeSource.Shell]: poolEncoder, [ERC20BridgeSource.Component]: poolEncoder, [ERC20BridgeSource.Mooniswap]: poolEncoder, - [ERC20BridgeSource.Eth2Dai]: poolEncoder, [ERC20BridgeSource.MStable]: poolEncoder, [ERC20BridgeSource.Balancer]: poolEncoder, [ERC20BridgeSource.Cream]: poolEncoder, 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 e3f2a58432..ef9c6951fb 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 @@ -1350,7 +1350,7 @@ export class SamplerOperations { takerFillAmounts: BigNumber[], tokenAdjacencyGraph: TokenAdjacencyGraph = this.tokenAdjacencyGraph, ): SourceQuoteOperation[] { - // Find the adjacent tokens in the provided tooken adjacency graph, + // Find the adjacent tokens in the provided token adjacency graph, // e.g if this is DAI->USDC we may check for DAI->WETH->USDC const intermediateTokens = getIntermediateTokens(makerToken, takerToken, tokenAdjacencyGraph); // Drop out MultiHop and Native as we do not query those here. @@ -1363,8 +1363,6 @@ export class SamplerOperations { return []; } switch (source) { - case ERC20BridgeSource.Eth2Dai: - return []; case ERC20BridgeSource.Uniswap: return isValidAddress(UNISWAPV1_ROUTER_BY_CHAIN_ID[this.chainId]) ? this.getUniswapSellQuotes( @@ -1671,8 +1669,6 @@ export class SamplerOperations { return _.flatten( _sources.map((source): SourceQuoteOperation | SourceQuoteOperation[] => { switch (source) { - case ERC20BridgeSource.Eth2Dai: - return []; case ERC20BridgeSource.Uniswap: return isValidAddress(UNISWAPV1_ROUTER_BY_CHAIN_ID[this.chainId]) ? this.getUniswapBuyQuotes( 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 6201bd1df0..bfcf739360 100644 --- a/packages/asset-swapper/src/utils/market_operation_utils/types.ts +++ b/packages/asset-swapper/src/utils/market_operation_utils/types.ts @@ -39,6 +39,10 @@ export enum ERC20BridgeSource { Native = 'Native', Uniswap = 'Uniswap', UniswapV2 = 'Uniswap_V2', +<<<<<<< HEAD +======= + Kyber = 'Kyber', +>>>>>>> 9eadc5fc2 (chore: Offboard Eth2Dai [TKR-356] (#470)) Curve = 'Curve', LiquidityProvider = 'LiquidityProvider', MultiBridge = 'MultiBridge', diff --git a/packages/asset-swapper/test/market_operation_utils_test.ts b/packages/asset-swapper/test/market_operation_utils_test.ts index 9afae0bb32..36020aaedd 100644 --- a/packages/asset-swapper/test/market_operation_utils_test.ts +++ b/packages/asset-swapper/test/market_operation_utils_test.ts @@ -49,7 +49,7 @@ const MAKER_TOKEN = randomAddress(); const TAKER_TOKEN = randomAddress(); const DEFAULT_INCLUDED = [ - ERC20BridgeSource.Eth2Dai, + ERC20BridgeSource.SushiSwap, ERC20BridgeSource.Kyber, ERC20BridgeSource.Native, ERC20BridgeSource.Uniswap, @@ -319,7 +319,7 @@ describe('MarketOperationUtils tests', () => { const DEFAULT_RATES: RatesBySource = { ...ZERO_RATES, [ERC20BridgeSource.Native]: createDecreasingRates(NUM_SAMPLES), - [ERC20BridgeSource.Eth2Dai]: createDecreasingRates(NUM_SAMPLES), + [ERC20BridgeSource.SushiSwap]: createDecreasingRates(NUM_SAMPLES), [ERC20BridgeSource.Uniswap]: createDecreasingRates(NUM_SAMPLES), [ERC20BridgeSource.Kyber]: createDecreasingRates(NUM_SAMPLES), }; @@ -383,7 +383,6 @@ describe('MarketOperationUtils tests', () => { [ERC20BridgeSource.DodoV2]: {}, [ERC20BridgeSource.CryptoCom]: { tokenAddressPath: [] }, [ERC20BridgeSource.Uniswap]: { router: randomAddress() }, - [ERC20BridgeSource.Eth2Dai]: { router: randomAddress() }, [ERC20BridgeSource.MakerPsm]: {}, [ERC20BridgeSource.KyberDmm]: { tokenAddressPath: [], router: randomAddress(), poolsPath: [] }, }; @@ -511,7 +510,7 @@ describe('MarketOperationUtils tests', () => { }); it('does not poll DEXes in `excludedSources`', async () => { - const excludedSources = [ERC20BridgeSource.Uniswap, ERC20BridgeSource.Eth2Dai]; + const excludedSources = [ERC20BridgeSource.Uniswap, ERC20BridgeSource.SushiSwap]; let sourcesPolled: ERC20BridgeSource[] = []; replaceSamplerOps({ getSellQuotes: (sources, makerToken, takerToken, amounts, wethAddress) => { @@ -541,7 +540,7 @@ describe('MarketOperationUtils tests', () => { }); it('only polls DEXes in `includedSources`', async () => { - const includedSources = [ERC20BridgeSource.Uniswap, ERC20BridgeSource.Eth2Dai]; + const includedSources = [ERC20BridgeSource.Uniswap, ERC20BridgeSource.SushiSwap]; let sourcesPolled: ERC20BridgeSource[] = []; replaceSamplerOps({ getSellQuotes: (sources, makerToken, takerToken, amounts, wethAddress) => { @@ -1034,7 +1033,7 @@ describe('MarketOperationUtils tests', () => { const rates: RatesBySource = { ...DEFAULT_RATES }; rates[ERC20BridgeSource.Native] = [0.4, 0.3, 0.2, 0.1]; rates[ERC20BridgeSource.Uniswap] = [0.5, 0.05, 0.05, 0.05]; - rates[ERC20BridgeSource.Eth2Dai] = [0.6, 0.05, 0.05, 0.05]; + rates[ERC20BridgeSource.SushiSwap] = [0.6, 0.05, 0.05, 0.05]; rates[ERC20BridgeSource.Kyber] = [0, 0, 0, 0]; // unused replaceSamplerOps({ getSellQuotes: createGetMultipleSellQuotesOperationFromRates(rates), @@ -1048,7 +1047,7 @@ describe('MarketOperationUtils tests', () => { const improvedOrders = improvedOrdersResponse.optimizedOrders; const orderSources = improvedOrders.map(o => o.fills[0].source); const expectedSources = [ - ERC20BridgeSource.Eth2Dai, + ERC20BridgeSource.SushiSwap, ERC20BridgeSource.Uniswap, ERC20BridgeSource.Native, ERC20BridgeSource.Native, @@ -1066,7 +1065,7 @@ describe('MarketOperationUtils tests', () => { const rates: RatesBySource = { [ERC20BridgeSource.Native]: [1, 0.99, 0.98, 0.97], // Effectively [0.94, 0.93, 0.92, 0.91] [ERC20BridgeSource.Uniswap]: [0.96, 0.1, 0.1, 0.1], - [ERC20BridgeSource.Eth2Dai]: [0.95, 0.1, 0.1, 0.1], + [ERC20BridgeSource.SushiSwap]: [0.95, 0.1, 0.1, 0.1], [ERC20BridgeSource.Kyber]: [0.1, 0.1, 0.1, 0.1], }; const feeSchedule = { @@ -1091,7 +1090,7 @@ describe('MarketOperationUtils tests', () => { const expectedSources = [ ERC20BridgeSource.Native, ERC20BridgeSource.Uniswap, - ERC20BridgeSource.Eth2Dai, + ERC20BridgeSource.SushiSwap, ERC20BridgeSource.Native, ]; expect(orderSources.sort()).to.deep.eq(expectedSources.sort()); @@ -1104,7 +1103,7 @@ describe('MarketOperationUtils tests', () => { const rates: RatesBySource = { [ERC20BridgeSource.Native]: [0.95, 0.1, 0.1, 0.1], [ERC20BridgeSource.Kyber]: [0.1, 0.1, 0.1, 0.1], - [ERC20BridgeSource.Eth2Dai]: [0.92, 0.1, 0.1, 0.1], + [ERC20BridgeSource.SushiSwap]: [0.92, 0.1, 0.1, 0.1], // Effectively [0.8, ~0.5, ~0, ~0] [ERC20BridgeSource.Uniswap]: [1, 0.7, 0.2, 0.2], }; @@ -1129,7 +1128,7 @@ describe('MarketOperationUtils tests', () => { const orderSources = improvedOrders.map(o => o.fills[0].source); const expectedSources = [ ERC20BridgeSource.Native, - ERC20BridgeSource.Eth2Dai, + ERC20BridgeSource.SushiSwap, ERC20BridgeSource.Uniswap, ]; expect(orderSources.sort()).to.deep.eq(expectedSources.sort()); @@ -1138,7 +1137,7 @@ describe('MarketOperationUtils tests', () => { it('can mix one concave source', async () => { const rates: RatesBySource = { [ERC20BridgeSource.Kyber]: [0, 0, 0, 0], // Won't use - [ERC20BridgeSource.Eth2Dai]: [0.5, 0.85, 0.75, 0.75], // Concave + [ERC20BridgeSource.SushiSwap]: [0.5, 0.85, 0.75, 0.75], // Concave [ERC20BridgeSource.Uniswap]: [0.96, 0.2, 0.1, 0.1], [ERC20BridgeSource.Native]: [0.95, 0.2, 0.2, 0.1], }; @@ -1155,7 +1154,7 @@ describe('MarketOperationUtils tests', () => { const improvedOrders = improvedOrdersResponse.optimizedOrders; const orderSources = improvedOrders.map(o => o.fills[0].source); const expectedSources = [ - ERC20BridgeSource.Eth2Dai, + ERC20BridgeSource.SushiSwap, ERC20BridgeSource.Uniswap, ERC20BridgeSource.Native, ]; @@ -1168,7 +1167,7 @@ describe('MarketOperationUtils tests', () => { const rates: RatesBySource = {}; rates[ERC20BridgeSource.Native] = [1, 1, 0.01, 0.01]; rates[ERC20BridgeSource.Uniswap] = [1, 1, 0.01, 0.01]; - rates[ERC20BridgeSource.Eth2Dai] = [0.49, 0.49, 0.49, 0.49]; + rates[ERC20BridgeSource.SushiSwap] = [0.49, 0.49, 0.49, 0.49]; rates[ERC20BridgeSource.Kyber] = [0.35, 0.2, 0.01, 0.01]; replaceSamplerOps({ getSellQuotes: createGetMultipleSellQuotesOperationFromRates(rates), @@ -1363,7 +1362,7 @@ describe('MarketOperationUtils tests', () => { }); it('does not poll DEXes in `excludedSources`', async () => { - const excludedSources = [ERC20BridgeSource.Uniswap, ERC20BridgeSource.Eth2Dai]; + const excludedSources = [ERC20BridgeSource.Uniswap, ERC20BridgeSource.SushiSwap]; let sourcesPolled: ERC20BridgeSource[] = []; replaceSamplerOps({ getBuyQuotes: (sources, makerToken, takerToken, amounts, wethAddress) => { @@ -1393,7 +1392,7 @@ describe('MarketOperationUtils tests', () => { }); it('only polls DEXes in `includedSources`', async () => { - const includedSources = [ERC20BridgeSource.Uniswap, ERC20BridgeSource.Eth2Dai]; + const includedSources = [ERC20BridgeSource.Uniswap, ERC20BridgeSource.SushiSwap]; let sourcesPolled: ERC20BridgeSource[] = []; replaceSamplerOps({ getBuyQuotes: (sources, makerToken, takerToken, amounts, wethAddress) => { @@ -1485,7 +1484,7 @@ describe('MarketOperationUtils tests', () => { const rates: RatesBySource = { ...ZERO_RATES }; rates[ERC20BridgeSource.Native] = [0.4, 0.3, 0.2, 0.1]; rates[ERC20BridgeSource.Uniswap] = [0.5, 0.05, 0.05, 0.05]; - rates[ERC20BridgeSource.Eth2Dai] = [0.6, 0.05, 0.05, 0.05]; + rates[ERC20BridgeSource.SushiSwap] = [0.6, 0.05, 0.05, 0.05]; replaceSamplerOps({ getBuyQuotes: createGetMultipleBuyQuotesOperationFromRates(rates), }); @@ -1498,7 +1497,7 @@ describe('MarketOperationUtils tests', () => { const improvedOrders = improvedOrdersResponse.optimizedOrders; const orderSources = improvedOrders.map(o => o.fills[0].source); const expectedSources = [ - ERC20BridgeSource.Eth2Dai, + ERC20BridgeSource.SushiSwap, ERC20BridgeSource.Uniswap, ERC20BridgeSource.Native, ERC20BridgeSource.Native, @@ -1517,7 +1516,7 @@ describe('MarketOperationUtils tests', () => { ...ZERO_RATES, [ERC20BridgeSource.Native]: [1, 0.99, 0.98, 0.97], // Effectively [0.94, ~0.93, ~0.92, ~0.91] [ERC20BridgeSource.Uniswap]: [0.96, 0.1, 0.1, 0.1], - [ERC20BridgeSource.Eth2Dai]: [0.95, 0.1, 0.1, 0.1], + [ERC20BridgeSource.SushiSwap]: [0.95, 0.1, 0.1, 0.1], [ERC20BridgeSource.Kyber]: [0.1, 0.1, 0.1, 0.1], }; const feeSchedule = { @@ -1541,7 +1540,7 @@ describe('MarketOperationUtils tests', () => { const orderSources = improvedOrders.map(o => o.fills[0].source); const expectedSources = [ ERC20BridgeSource.Uniswap, - ERC20BridgeSource.Eth2Dai, + ERC20BridgeSource.SushiSwap, ERC20BridgeSource.Native, ERC20BridgeSource.Native, ]; @@ -1557,7 +1556,7 @@ describe('MarketOperationUtils tests', () => { [ERC20BridgeSource.Native]: [0.95, 0.1, 0.1, 0.1], // Effectively [0.8, ~0.5, ~0, ~0] [ERC20BridgeSource.Uniswap]: [1, 0.7, 0.2, 0.2], - [ERC20BridgeSource.Eth2Dai]: [0.92, 0.1, 0.1, 0.1], + [ERC20BridgeSource.SushiSwap]: [0.92, 0.1, 0.1, 0.1], }; const feeSchedule = { [ERC20BridgeSource.Uniswap]: _.constant( @@ -1580,7 +1579,7 @@ describe('MarketOperationUtils tests', () => { const orderSources = improvedOrders.map(o => o.fills[0].source); const expectedSources = [ ERC20BridgeSource.Native, - ERC20BridgeSource.Eth2Dai, + ERC20BridgeSource.SushiSwap, ERC20BridgeSource.Uniswap, ]; expect(orderSources.sort()).to.deep.eq(expectedSources.sort()); @@ -1592,7 +1591,7 @@ describe('MarketOperationUtils tests', () => { const rates: RatesBySource = { ...ZERO_RATES }; rates[ERC20BridgeSource.Native] = [1, 1, 0.01, 0.01]; rates[ERC20BridgeSource.Uniswap] = [1, 1, 0.01, 0.01]; - rates[ERC20BridgeSource.Eth2Dai] = [0.49, 0.49, 0.49, 0.49]; + rates[ERC20BridgeSource.SushiSwap] = [0.49, 0.49, 0.49, 0.49]; replaceSamplerOps({ getBuyQuotes: createGetMultipleBuyQuotesOperationFromRates(rates), });