Skip to content
This repository has been archived by the owner on Jul 9, 2021. It is now read-only.

Commit

Permalink
[asset-swapper] Add latest BUSD Curve
Browse files Browse the repository at this point in the history
  • Loading branch information
dekz committed Feb 29, 2020
1 parent 7742901 commit 5509aea
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 23 deletions.
10 changes: 10 additions & 0 deletions packages/asset-swapper/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,16 @@ const DEFAULT_CURVE_OPTS: { [source: string]: { version: number; curveAddress: s
'0x0000000000085d4780b73119b644ae5ecd22b376',
],
},
[ERC20BridgeSource.CurveUsdcDaiUsdtBusd]: {
version: 1,
curveAddress: '0x79a8c46dea5ada233abaffd40f3a0a2b1e5a4f27',
tokens: [
'0x6b175474e89094c44da98b954eedeac495271d0f',
'0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
'0xdac17f958d2ee523a2206206994597c13d831ec7',
'0x4fabb145d64652a948d72533023f6e7a623c7c53',
],
},
};

export const constants = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { BigNumber } from '@0x/utils';

import { constants as globalConstants } from '../../constants';

import { ERC20BridgeSource, GetMarketOrdersOpts } from './types';

const INFINITE_TIMESTAMP_SEC = new BigNumber(2524604400);
Expand All @@ -11,9 +13,8 @@ export const SELL_SOURCES = [
ERC20BridgeSource.Uniswap,
ERC20BridgeSource.Eth2Dai,
ERC20BridgeSource.Kyber,
ERC20BridgeSource.CurveUsdcDai,
ERC20BridgeSource.CurveUsdcDaiUsdt,
ERC20BridgeSource.CurveUsdcDaiUsdtTusd,
// All Curve Sources
...(Object.keys(globalConstants.DEFAULT_CURVE_OPTS) as ERC20BridgeSource[]),
];

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export class CreateOrderUtils {
case ERC20BridgeSource.CurveUsdcDai:
case ERC20BridgeSource.CurveUsdcDaiUsdt:
case ERC20BridgeSource.CurveUsdcDaiUsdtTusd:
case ERC20BridgeSource.CurveUsdcDaiUsdtBusd:
return this._contractAddress.curveBridge;
default:
break;
Expand All @@ -110,11 +111,7 @@ function createBridgeOrder(
isBuy: boolean = false,
): OptimizedMarketOrder {
let makerAssetData;
if (
fill.source === ERC20BridgeSource.CurveUsdcDai ||
fill.source === ERC20BridgeSource.CurveUsdcDaiUsdt ||
fill.source === ERC20BridgeSource.CurveUsdcDaiUsdtTusd
) {
if (Object.keys(constants.DEFAULT_CURVE_OPTS).includes(fill.source)) {
const { curveAddress, tokens, version } = constants.DEFAULT_CURVE_OPTS[fill.source];
const fromTokenIdx = tokens.indexOf(takerToken);
const toTokenIdx = tokens.indexOf(makerToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,7 @@ const samplerOperations = {
batchedOperation = samplerOperations.getUniswapSellQuotes(makerToken, takerToken, takerFillAmounts);
} else if (source === ERC20BridgeSource.Kyber) {
batchedOperation = samplerOperations.getKyberSellQuotes(makerToken, takerToken, takerFillAmounts);
} else if (
source === ERC20BridgeSource.CurveUsdcDai ||
source === ERC20BridgeSource.CurveUsdcDaiUsdt ||
source === ERC20BridgeSource.CurveUsdcDaiUsdtTusd
) {
} else if (Object.keys(constants.DEFAULT_CURVE_OPTS).includes(source)) {
const { curveAddress, tokens } = constants.DEFAULT_CURVE_OPTS[source];
const fromTokenIdx = tokens.indexOf(takerToken);
const toTokenIdx = tokens.indexOf(makerToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export enum ERC20BridgeSource {
CurveUsdcDai = 'Curve_USDC_DAI',
CurveUsdcDaiUsdt = 'Curve_USDC_DAI_USDT',
CurveUsdcDaiUsdtTusd = 'Curve_USDC_DAI_USDT_TUSD',
CurveUsdcDaiUsdtBusd = 'Curve_USDC_DAI_USDT_BUSD',
}

// Internal `fillData` field for `Fill` objects.
Expand Down
13 changes: 3 additions & 10 deletions packages/asset-swapper/test/market_operation_utils_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ describe('MarketOperationUtils tests', () => {
[ERC20BridgeSource.CurveUsdcDai]: _.times(NUM_SAMPLES, () => 0),
[ERC20BridgeSource.CurveUsdcDaiUsdt]: _.times(NUM_SAMPLES, () => 0),
[ERC20BridgeSource.CurveUsdcDaiUsdtTusd]: _.times(NUM_SAMPLES, () => 0),
[ERC20BridgeSource.CurveUsdcDaiUsdtBusd]: _.times(NUM_SAMPLES, () => 0),
};

function findSourceWithMaxOutput(rates: RatesBySource): ERC20BridgeSource {
Expand Down Expand Up @@ -274,11 +275,7 @@ describe('MarketOperationUtils tests', () => {
runLimit: 0,
sampleDistributionBase: 1,
bridgeSlippage: 0,
excludedSources: [
ERC20BridgeSource.CurveUsdcDai,
ERC20BridgeSource.CurveUsdcDaiUsdt,
ERC20BridgeSource.CurveUsdcDaiUsdtTusd,
],
excludedSources: Object.keys(assetSwapperConstants.DEFAULT_CURVE_OPTS) as ERC20BridgeSource[],
};

beforeEach(() => {
Expand Down Expand Up @@ -545,11 +542,7 @@ describe('MarketOperationUtils tests', () => {
numSamples: NUM_SAMPLES,
runLimit: 0,
sampleDistributionBase: 1,
excludedSources: [
ERC20BridgeSource.CurveUsdcDai,
ERC20BridgeSource.CurveUsdcDaiUsdt,
ERC20BridgeSource.CurveUsdcDaiUsdtTusd,
],
excludedSources: Object.keys(assetSwapperConstants.DEFAULT_CURVE_OPTS) as ERC20BridgeSource[],
};

beforeEach(() => {
Expand Down

0 comments on commit 5509aea

Please sign in to comment.