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

Commit

Permalink
Redeploy Mainnet Kovan
Browse files Browse the repository at this point in the history
  • Loading branch information
dekz committed Apr 18, 2020
1 parent f0b3d18 commit 9375947
Show file tree
Hide file tree
Showing 8 changed files with 160 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BigNumber } from '@0x/utils';

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

// tslint:disable: custom-no-magic-numbers

Expand Down Expand Up @@ -46,6 +46,11 @@ export const DEFAULT_GET_MARKET_ORDERS_OPTS: GetMarketOrdersOpts = {
shouldBatchBridgeOrders: true,
};

export const DEFAULT_FAKE_BUY_OPTS: FakeBuyOpts = {
targetSlippageBps: new BigNumber(5),
maxIterations: new BigNumber(5),
};

/**
* Sources to poll for ETH fee price estimates.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { BigNumber, ERC20BridgeSource, SignedOrder } from '../..';

import { DEFAULT_CURVE_OPTS } from './constants';
import { BatchedOperation, DexSample } from './types';
import { DEFAULT_CURVE_OPTS, DEFAULT_FAKE_BUY_OPTS } from './constants';
import { BatchedOperation, DexSample, FakeBuyOpts } from './types';

/**
* Composable operations that can be batched in a single transaction,
Expand Down Expand Up @@ -52,11 +52,12 @@ export const samplerOperations = {
makerToken: string,
takerToken: string,
makerFillAmounts: BigNumber[],
fakeBuyOpts: FakeBuyOpts,
): BatchedOperation<BigNumber[]> {
return {
encodeCall: contract => {
return contract
.sampleBuysFromKyberNetwork(takerToken, makerToken, makerFillAmounts)
.sampleBuysFromKyberNetwork(takerToken, makerToken, makerFillAmounts, fakeBuyOpts)
.getABIEncodedTransactionData();
},
handleCallResultsAsync: async (contract, callResults) => {
Expand Down Expand Up @@ -110,6 +111,7 @@ export const samplerOperations = {
makerToken: string,
takerToken: string,
makerFillAmounts: BigNumber[],
fakeBuyOpts: FakeBuyOpts,
): BatchedOperation<BigNumber[]> {
return {
encodeCall: contract => {
Expand All @@ -119,6 +121,7 @@ export const samplerOperations = {
takerToken,
makerToken,
makerFillAmounts,
fakeBuyOpts,
)
.getABIEncodedTransactionData();
},
Expand Down Expand Up @@ -365,6 +368,7 @@ export const samplerOperations = {
takerToken: string,
makerFillAmounts: BigNumber[],
liquidityProviderRegistryAddress?: string | undefined,
fakeBuyOpts: FakeBuyOpts = DEFAULT_FAKE_BUY_OPTS,
): BatchedOperation<DexSample[][]> {
const subOps = sources
.map(source => {
Expand All @@ -374,13 +378,18 @@ export const samplerOperations = {
} else if (source === ERC20BridgeSource.Uniswap) {
batchedOperation = samplerOperations.getUniswapBuyQuotes(makerToken, takerToken, makerFillAmounts);
} else if (source === ERC20BridgeSource.Kyber) {
batchedOperation = samplerOperations.getKyberBuyQuotes(makerToken, takerToken, makerFillAmounts);
batchedOperation = samplerOperations.getKyberBuyQuotes(
makerToken,
takerToken,
makerFillAmounts,
fakeBuyOpts,
);
} else if (Object.keys(DEFAULT_CURVE_OPTS).includes(source)) {
const { curveAddress, tokens } = DEFAULT_CURVE_OPTS[source];
const fromTokenIdx = tokens.indexOf(takerToken);
const toTokenIdx = tokens.indexOf(makerToken);
if (fromTokenIdx !== -1 && toTokenIdx !== -1) {
batchedOperation = samplerOperations.getCurveSellQuotes(
batchedOperation = samplerOperations.getCurveBuyQuotes(
curveAddress,
fromTokenIdx,
toTokenIdx,
Expand All @@ -398,6 +407,7 @@ export const samplerOperations = {
makerToken,
takerToken,
makerFillAmounts,
fakeBuyOpts,
);
} else {
throw new Error(`Unsupported buy sample source: ${source}`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,3 +197,12 @@ export interface BatchedOperation<TResult> {
encodeCall(contract: IERC20BridgeSamplerContract): string;
handleCallResultsAsync(contract: IERC20BridgeSamplerContract, callResults: string): Promise<TResult>;
}

/**
* Used in the ERC20BridgeSampler when a source does not natively
* support sampling via a specific buy amount.
*/
export interface FakeBuyOpts {
targetSlippageBps: BigNumber;
maxIterations: BigNumber;
}
4 changes: 2 additions & 2 deletions packages/contract-addresses/addresses.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"devUtils": "0x74134cf88b21383713e096a5ecf59e297dc7f547",
"erc20BridgeProxy": "0x8ed95d1746bf1e4dab58d8ed4724f1ef95b20db0",
"uniswapBridge": "0x36691c4f426eb8f42f150ebde43069a31cb080ad",
"erc20BridgeSampler": "0xe603360c47f4cd99026fa01f2da2dec7e23babd9",
"erc20BridgeSampler": "0x867d1b78e7b5c2ac060e7bdeec6d8419a5c6ca4b",
"kyberBridge": "0x1c29670f7a77f1052d30813a0a4f632c78a02610",
"eth2DaiBridge": "0x991c745401d5b5e469b8c3e2cb02c748f08754f1",
"chaiBridge": "0x77c31eba23043b9a72d13470f3a3a311344d7438",
Expand Down Expand Up @@ -120,7 +120,7 @@
"erc20BridgeProxy": "0xfb2dd2a1366de37f7241c83d47da58fd503e2c64",
"uniswapBridge": "0x0e85f89f29998df65402391478e5924700c0079d",
"eth2DaiBridge": "0x2d47147429b474d2e4f83e658015858a1312ed5b",
"erc20BridgeSampler": "0xd3fccc4af0732e99290a57bbc2cc2afcbd08283f",
"erc20BridgeSampler": "0x1fdfcf612026c8deed586353430821bee6330dc8",
"kyberBridge": "0xaecfa25920f892b6eb496e1f6e84037f59da7f44",
"chaiBridge": "0x0000000000000000000000000000000000000000",
"dydxBridge": "0x3be8e59038d8c4e8d8776ca40ef2f024bad95ad1",
Expand Down
32 changes: 26 additions & 6 deletions packages/contract-artifacts/artifacts/ERC20BridgeSampler.json

Large diffs are not rendered by default.

28 changes: 24 additions & 4 deletions packages/contract-artifacts/artifacts/IERC20BridgeSampler.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 9375947

Please sign in to comment.