Update tests
This commit is contained in:
@@ -61,8 +61,9 @@ blockchainTests.skip('Mainnet Sampler Tests', env => {
|
||||
it('samples buys from Curve DAI->USDC', async () => {
|
||||
// From DAI to USDC
|
||||
// I want to buy 1 USDC
|
||||
await testContract.setSampleValues([toBaseUnitAmount(1, 6)]).awaitTransactionSuccessAsync();
|
||||
const samples = await testContract
|
||||
.sampleBuysFromCurve(CURVE_INFO, DAI_TOKEN_INDEX, USDC_TOKEN_INDEX, [toBaseUnitAmount(1, 6)])
|
||||
.sampleBuysFromCurveGlobal(CURVE_INFO, DAI_TOKEN_INDEX, USDC_TOKEN_INDEX)
|
||||
.callAsync({ overrides });
|
||||
expect(samples.length).to.be.bignumber.greaterThan(0);
|
||||
expect(samples[0]).to.be.bignumber.greaterThan(0);
|
||||
@@ -71,8 +72,9 @@ blockchainTests.skip('Mainnet Sampler Tests', env => {
|
||||
it('samples buys from Curve USDC->DAI', async () => {
|
||||
// From USDC to DAI
|
||||
// I want to buy 1 DAI
|
||||
await testContract.setSampleValues([toBaseUnitAmount(1)]).awaitTransactionSuccessAsync();
|
||||
const samples = await testContract
|
||||
.sampleBuysFromCurve(CURVE_INFO, USDC_TOKEN_INDEX, DAI_TOKEN_INDEX, [toBaseUnitAmount(1)])
|
||||
.sampleBuysFromCurveGlobal(CURVE_INFO, USDC_TOKEN_INDEX, DAI_TOKEN_INDEX)
|
||||
.callAsync({ overrides });
|
||||
expect(samples.length).to.be.bignumber.greaterThan(0);
|
||||
expect(samples[0]).to.be.bignumber.greaterThan(0);
|
||||
@@ -117,8 +119,9 @@ blockchainTests.skip('Mainnet Sampler Tests', env => {
|
||||
it('samples buys from Kyber WETH->DAI', async () => {
|
||||
// From ETH to DAI
|
||||
// I want to buy 1 DAI
|
||||
await testContract.setSampleValues([toBaseUnitAmount(1)]).awaitTransactionSuccessAsync();
|
||||
const [, samples] = await testContract
|
||||
.sampleBuysFromKyberNetwork(KYBER_OPTS, WETH, DAI, [toBaseUnitAmount(1)])
|
||||
.sampleBuysFromKyberNetworkGlobal(KYBER_OPTS, WETH, DAI)
|
||||
.callAsync({ overrides });
|
||||
expect(samples.length).to.be.bignumber.greaterThan(0);
|
||||
expect(samples[0]).to.be.bignumber.greaterThan(0);
|
||||
@@ -127,8 +130,9 @@ blockchainTests.skip('Mainnet Sampler Tests', env => {
|
||||
it('samples buys from Kyber DAI->WETH', async () => {
|
||||
// From USDC to DAI
|
||||
// I want to buy 1 WETH
|
||||
await testContract.setSampleValues([toBaseUnitAmount(1)]).awaitTransactionSuccessAsync();
|
||||
const [, samples] = await testContract
|
||||
.sampleBuysFromKyberNetwork(KYBER_OPTS, DAI, WETH, [toBaseUnitAmount(1)])
|
||||
.sampleBuysFromKyberNetworkGlobal(KYBER_OPTS, DAI, WETH)
|
||||
.callAsync({ overrides });
|
||||
expect(samples.length).to.be.bignumber.greaterThan(0);
|
||||
expect(samples[0]).to.be.bignumber.greaterThan(0);
|
||||
|
||||
@@ -426,13 +426,13 @@ blockchainTests.skip('erc20-bridge-sampler', env => {
|
||||
});
|
||||
|
||||
it('throws if tokens are the same', async () => {
|
||||
const tx = testContract.sampleBuysFromKyberNetwork(kyberOpts, MAKER_TOKEN, MAKER_TOKEN, []).callAsync();
|
||||
const tx = testContract.sampleBuysFromKyberNetworkGlobal(kyberOpts, MAKER_TOKEN, MAKER_TOKEN).callAsync();
|
||||
return expect(tx).to.revertWith(INVALID_TOKEN_PAIR_ERROR);
|
||||
});
|
||||
|
||||
it('can return no quotes', async () => {
|
||||
const [, , quotes] = await testContract
|
||||
.sampleBuysFromKyberNetwork(kyberOpts, TAKER_TOKEN, MAKER_TOKEN, [])
|
||||
.sampleBuysFromKyberNetworkGlobal(kyberOpts, TAKER_TOKEN, MAKER_TOKEN)
|
||||
.callAsync();
|
||||
expect(quotes).to.deep.eq([]);
|
||||
});
|
||||
@@ -440,8 +440,9 @@ blockchainTests.skip('erc20-bridge-sampler', env => {
|
||||
it('can quote token -> token', async () => {
|
||||
const sampleAmounts = getSampleAmounts(TAKER_TOKEN);
|
||||
const [expectedQuotes] = getDeterministicBuyQuotes(TAKER_TOKEN, MAKER_TOKEN, ['Kyber'], sampleAmounts);
|
||||
await testContract.setSampleValues(sampleAmounts).awaitTransactionSuccessAsync();
|
||||
const [, , quotes] = await testContract
|
||||
.sampleBuysFromKyberNetwork(kyberOpts, TAKER_TOKEN, MAKER_TOKEN, sampleAmounts)
|
||||
.sampleBuysFromKyberNetworkGlobal(kyberOpts, TAKER_TOKEN, MAKER_TOKEN)
|
||||
.callAsync();
|
||||
expectQuotesWithinRange(quotes, expectedQuotes, ACCEPTABLE_SLIPPAGE);
|
||||
});
|
||||
@@ -450,8 +451,9 @@ blockchainTests.skip('erc20-bridge-sampler', env => {
|
||||
const sampleAmounts = getSampleAmounts(TAKER_TOKEN);
|
||||
const expectedQuotes = _.times(sampleAmounts.length, () => constants.ZERO_AMOUNT);
|
||||
await enableFailTriggerAsync();
|
||||
await testContract.setSampleValues(sampleAmounts).awaitTransactionSuccessAsync();
|
||||
const [, , quotes] = await testContract
|
||||
.sampleBuysFromKyberNetwork(kyberOpts, TAKER_TOKEN, MAKER_TOKEN, sampleAmounts)
|
||||
.sampleBuysFromKyberNetworkGlobal(kyberOpts, TAKER_TOKEN, MAKER_TOKEN)
|
||||
.callAsync();
|
||||
expect(quotes).to.deep.eq(expectedQuotes);
|
||||
});
|
||||
@@ -459,8 +461,9 @@ blockchainTests.skip('erc20-bridge-sampler', env => {
|
||||
it('can quote token -> ETH', async () => {
|
||||
const sampleAmounts = getSampleAmounts(TAKER_TOKEN);
|
||||
const [expectedQuotes] = getDeterministicBuyQuotes(TAKER_TOKEN, WETH_ADDRESS, ['Kyber'], sampleAmounts);
|
||||
await testContract.setSampleValues(sampleAmounts).awaitTransactionSuccessAsync();
|
||||
const [, , quotes] = await testContract
|
||||
.sampleBuysFromKyberNetwork(kyberOpts, TAKER_TOKEN, WETH_ADDRESS, sampleAmounts)
|
||||
.sampleBuysFromKyberNetworkGlobal(kyberOpts, TAKER_TOKEN, WETH_ADDRESS)
|
||||
.callAsync();
|
||||
expectQuotesWithinRange(quotes, expectedQuotes, ACCEPTABLE_SLIPPAGE);
|
||||
});
|
||||
@@ -469,8 +472,9 @@ blockchainTests.skip('erc20-bridge-sampler', env => {
|
||||
const sampleAmounts = getSampleAmounts(TAKER_TOKEN);
|
||||
const expectedQuotes = _.times(sampleAmounts.length, () => constants.ZERO_AMOUNT);
|
||||
await enableFailTriggerAsync();
|
||||
await testContract.setSampleValues(sampleAmounts).awaitTransactionSuccessAsync();
|
||||
const [, , quotes] = await testContract
|
||||
.sampleBuysFromKyberNetwork(kyberOpts, TAKER_TOKEN, WETH_ADDRESS, sampleAmounts)
|
||||
.sampleBuysFromKyberNetworkGlobal(kyberOpts, TAKER_TOKEN, WETH_ADDRESS)
|
||||
.callAsync();
|
||||
expect(quotes).to.deep.eq(expectedQuotes);
|
||||
});
|
||||
@@ -478,8 +482,9 @@ blockchainTests.skip('erc20-bridge-sampler', env => {
|
||||
it('can quote ETH -> token', async () => {
|
||||
const sampleAmounts = getSampleAmounts(TAKER_TOKEN);
|
||||
const [expectedQuotes] = getDeterministicBuyQuotes(WETH_ADDRESS, TAKER_TOKEN, ['Kyber'], sampleAmounts);
|
||||
await testContract.setSampleValues(sampleAmounts).awaitTransactionSuccessAsync();
|
||||
const [, , quotes] = await testContract
|
||||
.sampleBuysFromKyberNetwork(kyberOpts, WETH_ADDRESS, TAKER_TOKEN, sampleAmounts)
|
||||
.sampleBuysFromKyberNetworkGlobal(kyberOpts, WETH_ADDRESS, TAKER_TOKEN)
|
||||
.callAsync();
|
||||
expectQuotesWithinRange(quotes, expectedQuotes, ACCEPTABLE_SLIPPAGE);
|
||||
});
|
||||
@@ -488,8 +493,9 @@ blockchainTests.skip('erc20-bridge-sampler', env => {
|
||||
const sampleAmounts = getSampleAmounts(TAKER_TOKEN);
|
||||
const expectedQuotes = _.times(sampleAmounts.length, () => constants.ZERO_AMOUNT);
|
||||
await enableFailTriggerAsync();
|
||||
await testContract.setSampleValues(sampleAmounts).awaitTransactionSuccessAsync();
|
||||
const [, , quotes] = await testContract
|
||||
.sampleBuysFromKyberNetwork(kyberOpts, WETH_ADDRESS, TAKER_TOKEN, sampleAmounts)
|
||||
.sampleBuysFromKyberNetworkGlobal(kyberOpts, WETH_ADDRESS, TAKER_TOKEN)
|
||||
.callAsync();
|
||||
expect(quotes).to.deep.eq(expectedQuotes);
|
||||
});
|
||||
@@ -502,13 +508,13 @@ blockchainTests.skip('erc20-bridge-sampler', env => {
|
||||
});
|
||||
|
||||
it('throws if tokens are the same', async () => {
|
||||
const tx = testContract.sampleSellsFromUniswap(UNISWAP_ADDRESS, MAKER_TOKEN, MAKER_TOKEN, []).callAsync();
|
||||
const tx = testContract.sampleSellsFromUniswapGlobal(UNISWAP_ADDRESS, MAKER_TOKEN, MAKER_TOKEN).callAsync();
|
||||
return expect(tx).to.revertWith(INVALID_TOKEN_PAIR_ERROR);
|
||||
});
|
||||
|
||||
it('can return no quotes', async () => {
|
||||
const quotes = await testContract
|
||||
.sampleSellsFromUniswap(UNISWAP_ADDRESS, TAKER_TOKEN, MAKER_TOKEN, [])
|
||||
.sampleSellsFromUniswapGlobal(UNISWAP_ADDRESS, TAKER_TOKEN, MAKER_TOKEN)
|
||||
.callAsync();
|
||||
expect(quotes).to.deep.eq([]);
|
||||
});
|
||||
@@ -516,8 +522,9 @@ blockchainTests.skip('erc20-bridge-sampler', env => {
|
||||
it('can quote token -> token', async () => {
|
||||
const sampleAmounts = getSampleAmounts(TAKER_TOKEN);
|
||||
const [expectedQuotes] = getDeterministicSellQuotes(TAKER_TOKEN, MAKER_TOKEN, ['Uniswap'], sampleAmounts);
|
||||
await testContract.setSampleValues(sampleAmounts).awaitTransactionSuccessAsync();
|
||||
const quotes = await testContract
|
||||
.sampleSellsFromUniswap(UNISWAP_ADDRESS, TAKER_TOKEN, MAKER_TOKEN, sampleAmounts)
|
||||
.sampleSellsFromUniswapGlobal(UNISWAP_ADDRESS, TAKER_TOKEN, MAKER_TOKEN)
|
||||
.callAsync();
|
||||
expect(quotes).to.deep.eq(expectedQuotes);
|
||||
});
|
||||
@@ -526,8 +533,9 @@ blockchainTests.skip('erc20-bridge-sampler', env => {
|
||||
const sampleAmounts = getSampleAmounts(TAKER_TOKEN);
|
||||
const expectedQuotes = _.times(sampleAmounts.length, () => constants.ZERO_AMOUNT);
|
||||
await enableFailTriggerAsync();
|
||||
await testContract.setSampleValues(sampleAmounts).awaitTransactionSuccessAsync();
|
||||
const quotes = await testContract
|
||||
.sampleSellsFromUniswap(UNISWAP_ADDRESS, TAKER_TOKEN, MAKER_TOKEN, sampleAmounts)
|
||||
.sampleSellsFromUniswapGlobal(UNISWAP_ADDRESS, TAKER_TOKEN, MAKER_TOKEN)
|
||||
.callAsync();
|
||||
expect(quotes).to.deep.eq(expectedQuotes);
|
||||
});
|
||||
@@ -535,8 +543,9 @@ blockchainTests.skip('erc20-bridge-sampler', env => {
|
||||
it('can quote token -> ETH', async () => {
|
||||
const sampleAmounts = getSampleAmounts(TAKER_TOKEN);
|
||||
const [expectedQuotes] = getDeterministicSellQuotes(TAKER_TOKEN, WETH_ADDRESS, ['Uniswap'], sampleAmounts);
|
||||
await testContract.setSampleValues(sampleAmounts).awaitTransactionSuccessAsync();
|
||||
const quotes = await testContract
|
||||
.sampleSellsFromUniswap(UNISWAP_ADDRESS, TAKER_TOKEN, UNISWAP_ETH_ADDRESS, sampleAmounts)
|
||||
.sampleSellsFromUniswapGlobal(UNISWAP_ADDRESS, TAKER_TOKEN, UNISWAP_ETH_ADDRESS)
|
||||
.callAsync();
|
||||
expect(quotes).to.deep.eq(expectedQuotes);
|
||||
});
|
||||
@@ -545,8 +554,9 @@ blockchainTests.skip('erc20-bridge-sampler', env => {
|
||||
const sampleAmounts = getSampleAmounts(TAKER_TOKEN);
|
||||
const expectedQuotes = _.times(sampleAmounts.length, () => constants.ZERO_AMOUNT);
|
||||
await enableFailTriggerAsync();
|
||||
await testContract.setSampleValues(sampleAmounts).awaitTransactionSuccessAsync();
|
||||
const quotes = await testContract
|
||||
.sampleSellsFromUniswap(UNISWAP_ADDRESS, TAKER_TOKEN, UNISWAP_ETH_ADDRESS, sampleAmounts)
|
||||
.sampleSellsFromUniswapGlobal(UNISWAP_ADDRESS, TAKER_TOKEN, UNISWAP_ETH_ADDRESS)
|
||||
.callAsync();
|
||||
expect(quotes).to.deep.eq(expectedQuotes);
|
||||
});
|
||||
@@ -554,8 +564,9 @@ blockchainTests.skip('erc20-bridge-sampler', env => {
|
||||
it('can quote ETH -> token', async () => {
|
||||
const sampleAmounts = getSampleAmounts(TAKER_TOKEN);
|
||||
const [expectedQuotes] = getDeterministicSellQuotes(WETH_ADDRESS, TAKER_TOKEN, ['Uniswap'], sampleAmounts);
|
||||
await testContract.setSampleValues(sampleAmounts).awaitTransactionSuccessAsync();
|
||||
const quotes = await testContract
|
||||
.sampleSellsFromUniswap(UNISWAP_ADDRESS, UNISWAP_ETH_ADDRESS, TAKER_TOKEN, sampleAmounts)
|
||||
.sampleSellsFromUniswapGlobal(UNISWAP_ADDRESS, UNISWAP_ETH_ADDRESS, TAKER_TOKEN)
|
||||
.callAsync();
|
||||
expect(quotes).to.deep.eq(expectedQuotes);
|
||||
});
|
||||
@@ -564,8 +575,9 @@ blockchainTests.skip('erc20-bridge-sampler', env => {
|
||||
const sampleAmounts = getSampleAmounts(TAKER_TOKEN);
|
||||
const expectedQuotes = _.times(sampleAmounts.length, () => constants.ZERO_AMOUNT);
|
||||
await enableFailTriggerAsync();
|
||||
await testContract.setSampleValues(sampleAmounts).awaitTransactionSuccessAsync();
|
||||
const quotes = await testContract
|
||||
.sampleSellsFromUniswap(UNISWAP_ADDRESS, UNISWAP_ETH_ADDRESS, TAKER_TOKEN, sampleAmounts)
|
||||
.sampleSellsFromUniswapGlobal(UNISWAP_ADDRESS, UNISWAP_ETH_ADDRESS, TAKER_TOKEN)
|
||||
.callAsync();
|
||||
expect(quotes).to.deep.eq(expectedQuotes);
|
||||
});
|
||||
@@ -574,8 +586,9 @@ blockchainTests.skip('erc20-bridge-sampler', env => {
|
||||
const nonExistantToken = randomAddress();
|
||||
const sampleAmounts = getSampleAmounts(TAKER_TOKEN);
|
||||
const expectedQuotes = _.times(sampleAmounts.length, () => constants.ZERO_AMOUNT);
|
||||
await testContract.setSampleValues(sampleAmounts).awaitTransactionSuccessAsync();
|
||||
const quotes = await testContract
|
||||
.sampleSellsFromUniswap(UNISWAP_ADDRESS, TAKER_TOKEN, nonExistantToken, sampleAmounts)
|
||||
.sampleSellsFromUniswapGlobal(UNISWAP_ADDRESS, TAKER_TOKEN, nonExistantToken)
|
||||
.callAsync();
|
||||
expect(quotes).to.deep.eq(expectedQuotes);
|
||||
});
|
||||
@@ -584,8 +597,9 @@ blockchainTests.skip('erc20-bridge-sampler', env => {
|
||||
const nonExistantToken = randomAddress();
|
||||
const sampleAmounts = getSampleAmounts(nonExistantToken);
|
||||
const expectedQuotes = _.times(sampleAmounts.length, () => constants.ZERO_AMOUNT);
|
||||
await testContract.setSampleValues(sampleAmounts).awaitTransactionSuccessAsync();
|
||||
const quotes = await testContract
|
||||
.sampleSellsFromUniswap(UNISWAP_ADDRESS, nonExistantToken, MAKER_TOKEN, sampleAmounts)
|
||||
.sampleSellsFromUniswapGlobal(UNISWAP_ADDRESS, nonExistantToken, MAKER_TOKEN)
|
||||
.callAsync();
|
||||
expect(quotes).to.deep.eq(expectedQuotes);
|
||||
});
|
||||
@@ -598,13 +612,13 @@ blockchainTests.skip('erc20-bridge-sampler', env => {
|
||||
});
|
||||
|
||||
it('throws if tokens are the same', async () => {
|
||||
const tx = testContract.sampleBuysFromUniswap(UNISWAP_ADDRESS, MAKER_TOKEN, MAKER_TOKEN, []).callAsync();
|
||||
const tx = testContract.sampleBuysFromUniswapGlobal(UNISWAP_ADDRESS, MAKER_TOKEN, MAKER_TOKEN).callAsync();
|
||||
return expect(tx).to.revertWith(INVALID_TOKEN_PAIR_ERROR);
|
||||
});
|
||||
|
||||
it('can return no quotes', async () => {
|
||||
const quotes = await testContract
|
||||
.sampleBuysFromUniswap(UNISWAP_ADDRESS, TAKER_TOKEN, MAKER_TOKEN, [])
|
||||
.sampleBuysFromUniswapGlobal(UNISWAP_ADDRESS, TAKER_TOKEN, MAKER_TOKEN)
|
||||
.callAsync();
|
||||
expect(quotes).to.deep.eq([]);
|
||||
});
|
||||
@@ -612,8 +626,9 @@ blockchainTests.skip('erc20-bridge-sampler', env => {
|
||||
it('can quote token -> token', async () => {
|
||||
const sampleAmounts = getSampleAmounts(MAKER_TOKEN);
|
||||
const [expectedQuotes] = getDeterministicBuyQuotes(TAKER_TOKEN, MAKER_TOKEN, ['Uniswap'], sampleAmounts);
|
||||
await testContract.setSampleValues(sampleAmounts).awaitTransactionSuccessAsync();
|
||||
const quotes = await testContract
|
||||
.sampleBuysFromUniswap(UNISWAP_ADDRESS, TAKER_TOKEN, MAKER_TOKEN, sampleAmounts)
|
||||
.sampleBuysFromUniswapGlobal(UNISWAP_ADDRESS, TAKER_TOKEN, MAKER_TOKEN)
|
||||
.callAsync();
|
||||
expect(quotes).to.deep.eq(expectedQuotes);
|
||||
});
|
||||
@@ -622,8 +637,9 @@ blockchainTests.skip('erc20-bridge-sampler', env => {
|
||||
const sampleAmounts = getSampleAmounts(MAKER_TOKEN);
|
||||
const expectedQuotes = _.times(sampleAmounts.length, () => constants.ZERO_AMOUNT);
|
||||
await enableFailTriggerAsync();
|
||||
await testContract.setSampleValues(sampleAmounts).awaitTransactionSuccessAsync();
|
||||
const quotes = await testContract
|
||||
.sampleBuysFromUniswap(UNISWAP_ADDRESS, TAKER_TOKEN, MAKER_TOKEN, sampleAmounts)
|
||||
.sampleBuysFromUniswapGlobal(UNISWAP_ADDRESS, TAKER_TOKEN, MAKER_TOKEN)
|
||||
.callAsync();
|
||||
expect(quotes).to.deep.eq(expectedQuotes);
|
||||
});
|
||||
@@ -632,7 +648,7 @@ blockchainTests.skip('erc20-bridge-sampler', env => {
|
||||
const sampleAmounts = getSampleAmounts(MAKER_TOKEN);
|
||||
const [expectedQuotes] = getDeterministicBuyQuotes(TAKER_TOKEN, WETH_ADDRESS, ['Uniswap'], sampleAmounts);
|
||||
const quotes = await testContract
|
||||
.sampleBuysFromUniswap(UNISWAP_ADDRESS, TAKER_TOKEN, UNISWAP_ETH_ADDRESS, sampleAmounts)
|
||||
.sampleBuysFromUniswapGlobal(UNISWAP_ADDRESS, TAKER_TOKEN, UNISWAP_ETH_ADDRESS)
|
||||
.callAsync();
|
||||
expect(quotes).to.deep.eq(expectedQuotes);
|
||||
});
|
||||
@@ -641,8 +657,9 @@ blockchainTests.skip('erc20-bridge-sampler', env => {
|
||||
const sampleAmounts = getSampleAmounts(MAKER_TOKEN);
|
||||
const expectedQuotes = _.times(sampleAmounts.length, () => constants.ZERO_AMOUNT);
|
||||
await enableFailTriggerAsync();
|
||||
await testContract.setSampleValues(sampleAmounts).awaitTransactionSuccessAsync();
|
||||
const quotes = await testContract
|
||||
.sampleBuysFromUniswap(UNISWAP_ADDRESS, TAKER_TOKEN, UNISWAP_ETH_ADDRESS, sampleAmounts)
|
||||
.sampleBuysFromUniswapGlobal(UNISWAP_ADDRESS, TAKER_TOKEN, UNISWAP_ETH_ADDRESS)
|
||||
.callAsync();
|
||||
expect(quotes).to.deep.eq(expectedQuotes);
|
||||
});
|
||||
@@ -650,8 +667,9 @@ blockchainTests.skip('erc20-bridge-sampler', env => {
|
||||
it('can quote ETH -> token', async () => {
|
||||
const sampleAmounts = getSampleAmounts(MAKER_TOKEN);
|
||||
const [expectedQuotes] = getDeterministicBuyQuotes(WETH_ADDRESS, TAKER_TOKEN, ['Uniswap'], sampleAmounts);
|
||||
await testContract.setSampleValues(sampleAmounts).awaitTransactionSuccessAsync();
|
||||
const quotes = await testContract
|
||||
.sampleBuysFromUniswap(UNISWAP_ADDRESS, UNISWAP_ETH_ADDRESS, TAKER_TOKEN, sampleAmounts)
|
||||
.sampleBuysFromUniswapGlobal(UNISWAP_ADDRESS, UNISWAP_ETH_ADDRESS, TAKER_TOKEN)
|
||||
.callAsync();
|
||||
expect(quotes).to.deep.eq(expectedQuotes);
|
||||
});
|
||||
@@ -660,8 +678,9 @@ blockchainTests.skip('erc20-bridge-sampler', env => {
|
||||
const sampleAmounts = getSampleAmounts(MAKER_TOKEN);
|
||||
const expectedQuotes = _.times(sampleAmounts.length, () => constants.ZERO_AMOUNT);
|
||||
await enableFailTriggerAsync();
|
||||
await testContract.setSampleValues(sampleAmounts).awaitTransactionSuccessAsync();
|
||||
const quotes = await testContract
|
||||
.sampleBuysFromUniswap(UNISWAP_ADDRESS, UNISWAP_ETH_ADDRESS, TAKER_TOKEN, sampleAmounts)
|
||||
.sampleBuysFromUniswapGlobal(UNISWAP_ADDRESS, UNISWAP_ETH_ADDRESS, TAKER_TOKEN)
|
||||
.callAsync();
|
||||
expect(quotes).to.deep.eq(expectedQuotes);
|
||||
});
|
||||
@@ -670,8 +689,9 @@ blockchainTests.skip('erc20-bridge-sampler', env => {
|
||||
const nonExistantToken = randomAddress();
|
||||
const sampleAmounts = getSampleAmounts(nonExistantToken);
|
||||
const expectedQuotes = _.times(sampleAmounts.length, () => constants.ZERO_AMOUNT);
|
||||
await testContract.setSampleValues(sampleAmounts).awaitTransactionSuccessAsync();
|
||||
const quotes = await testContract
|
||||
.sampleBuysFromUniswap(UNISWAP_ADDRESS, TAKER_TOKEN, nonExistantToken, sampleAmounts)
|
||||
.sampleBuysFromUniswapGlobal(UNISWAP_ADDRESS, TAKER_TOKEN, nonExistantToken)
|
||||
.callAsync();
|
||||
expect(quotes).to.deep.eq(expectedQuotes);
|
||||
});
|
||||
@@ -680,8 +700,9 @@ blockchainTests.skip('erc20-bridge-sampler', env => {
|
||||
const nonExistantToken = randomAddress();
|
||||
const sampleAmounts = getSampleAmounts(MAKER_TOKEN);
|
||||
const expectedQuotes = _.times(sampleAmounts.length, () => constants.ZERO_AMOUNT);
|
||||
await testContract.setSampleValues(sampleAmounts).awaitTransactionSuccessAsync();
|
||||
const quotes = await testContract
|
||||
.sampleBuysFromUniswap(UNISWAP_ADDRESS, nonExistantToken, MAKER_TOKEN, sampleAmounts)
|
||||
.sampleBuysFromUniswapGlobal(UNISWAP_ADDRESS, nonExistantToken, MAKER_TOKEN)
|
||||
.callAsync();
|
||||
expect(quotes).to.deep.eq(expectedQuotes);
|
||||
});
|
||||
@@ -700,11 +721,12 @@ blockchainTests.skip('erc20-bridge-sampler', env => {
|
||||
env.txDefaults,
|
||||
{},
|
||||
);
|
||||
await testContract.setSampleValues(sampleAmounts).awaitTransactionSuccessAsync();
|
||||
});
|
||||
|
||||
it('should be able to query sells from the liquidity provider', async () => {
|
||||
const quotes = await testContract
|
||||
.sampleSellsFromLiquidityProvider(liquidityProvider.address, yAsset, xAsset, sampleAmounts)
|
||||
.sampleSellsFromLiquidityProviderGlobal(liquidityProvider.address, yAsset, xAsset)
|
||||
.callAsync();
|
||||
quotes.forEach((value, idx) => {
|
||||
expect(value).is.bignumber.eql(sampleAmounts[idx].minus(1));
|
||||
@@ -713,7 +735,7 @@ blockchainTests.skip('erc20-bridge-sampler', env => {
|
||||
|
||||
it('should be able to query buys from the liquidity provider', async () => {
|
||||
const quotes = await testContract
|
||||
.sampleBuysFromLiquidityProvider(liquidityProvider.address, yAsset, xAsset, sampleAmounts)
|
||||
.sampleBuysFromLiquidityProviderGlobal(liquidityProvider.address, yAsset, xAsset)
|
||||
.callAsync();
|
||||
quotes.forEach((value, idx) => {
|
||||
expect(value).is.bignumber.eql(sampleAmounts[idx].plus(1));
|
||||
@@ -722,7 +744,7 @@ blockchainTests.skip('erc20-bridge-sampler', env => {
|
||||
|
||||
it('should just return zeros if the liquidity provider does not exist', async () => {
|
||||
const quotes = await testContract
|
||||
.sampleBuysFromLiquidityProvider(randomAddress(), yAsset, xAsset, sampleAmounts)
|
||||
.sampleBuysFromLiquidityProviderGlobal(randomAddress(), yAsset, xAsset)
|
||||
.callAsync();
|
||||
quotes.forEach(value => {
|
||||
expect(value).is.bignumber.eql(constants.ZERO_AMOUNT);
|
||||
@@ -737,7 +759,7 @@ blockchainTests.skip('erc20-bridge-sampler', env => {
|
||||
|
||||
it('can return no quotes', async () => {
|
||||
const quotes = await testContract
|
||||
.sampleSellsFromUniswapV2(UNISWAP_V2_ROUTER, [TAKER_TOKEN, MAKER_TOKEN], [])
|
||||
.sampleSellsFromUniswapV2Global(UNISWAP_V2_ROUTER, [TAKER_TOKEN, MAKER_TOKEN])
|
||||
.callAsync();
|
||||
expect(quotes).to.deep.eq([]);
|
||||
});
|
||||
@@ -745,8 +767,9 @@ blockchainTests.skip('erc20-bridge-sampler', env => {
|
||||
it('can quote token -> token', async () => {
|
||||
const sampleAmounts = getSampleAmounts(TAKER_TOKEN);
|
||||
const expectedQuotes = predictSellQuotes([TAKER_TOKEN, MAKER_TOKEN], sampleAmounts);
|
||||
await testContract.setSampleValues(sampleAmounts).awaitTransactionSuccessAsync();
|
||||
const quotes = await testContract
|
||||
.sampleSellsFromUniswapV2(UNISWAP_V2_ROUTER, [TAKER_TOKEN, MAKER_TOKEN], sampleAmounts)
|
||||
.sampleSellsFromUniswapV2Global(UNISWAP_V2_ROUTER, [TAKER_TOKEN, MAKER_TOKEN])
|
||||
.callAsync();
|
||||
expect(quotes).to.deep.eq(expectedQuotes);
|
||||
});
|
||||
@@ -755,8 +778,9 @@ blockchainTests.skip('erc20-bridge-sampler', env => {
|
||||
const sampleAmounts = getSampleAmounts(TAKER_TOKEN);
|
||||
const expectedQuotes = _.times(sampleAmounts.length, () => constants.ZERO_AMOUNT);
|
||||
await enableFailTriggerAsync();
|
||||
await testContract.setSampleValues(sampleAmounts).awaitTransactionSuccessAsync();
|
||||
const quotes = await testContract
|
||||
.sampleSellsFromUniswapV2(UNISWAP_V2_ROUTER, [TAKER_TOKEN, MAKER_TOKEN], sampleAmounts)
|
||||
.sampleSellsFromUniswapV2Global(UNISWAP_V2_ROUTER, [TAKER_TOKEN, MAKER_TOKEN])
|
||||
.callAsync();
|
||||
expect(quotes).to.deep.eq(expectedQuotes);
|
||||
});
|
||||
@@ -765,12 +789,9 @@ blockchainTests.skip('erc20-bridge-sampler', env => {
|
||||
const intermediateToken = randomAddress();
|
||||
const sampleAmounts = getSampleAmounts(TAKER_TOKEN);
|
||||
const expectedQuotes = predictSellQuotes([TAKER_TOKEN, intermediateToken, MAKER_TOKEN], sampleAmounts);
|
||||
await testContract.setSampleValues(sampleAmounts).awaitTransactionSuccessAsync();
|
||||
const quotes = await testContract
|
||||
.sampleSellsFromUniswapV2(
|
||||
UNISWAP_V2_ROUTER,
|
||||
[TAKER_TOKEN, intermediateToken, MAKER_TOKEN],
|
||||
sampleAmounts,
|
||||
)
|
||||
.sampleSellsFromUniswapV2Global(UNISWAP_V2_ROUTER, [TAKER_TOKEN, intermediateToken, MAKER_TOKEN])
|
||||
.callAsync();
|
||||
expect(quotes).to.deep.eq(expectedQuotes);
|
||||
});
|
||||
@@ -783,7 +804,7 @@ blockchainTests.skip('erc20-bridge-sampler', env => {
|
||||
|
||||
it('can return no quotes', async () => {
|
||||
const quotes = await testContract
|
||||
.sampleBuysFromUniswapV2(UNISWAP_V2_ROUTER, [TAKER_TOKEN, MAKER_TOKEN], [])
|
||||
.sampleBuysFromUniswapV2Global(UNISWAP_V2_ROUTER, [TAKER_TOKEN, MAKER_TOKEN])
|
||||
.callAsync();
|
||||
expect(quotes).to.deep.eq([]);
|
||||
});
|
||||
@@ -791,8 +812,9 @@ blockchainTests.skip('erc20-bridge-sampler', env => {
|
||||
it('can quote token -> token', async () => {
|
||||
const sampleAmounts = getSampleAmounts(MAKER_TOKEN);
|
||||
const expectedQuotes = predictBuyQuotes([TAKER_TOKEN, MAKER_TOKEN], sampleAmounts);
|
||||
await testContract.setSampleValues(sampleAmounts).awaitTransactionSuccessAsync();
|
||||
const quotes = await testContract
|
||||
.sampleBuysFromUniswapV2(UNISWAP_V2_ROUTER, [TAKER_TOKEN, MAKER_TOKEN], sampleAmounts)
|
||||
.sampleBuysFromUniswapV2Global(UNISWAP_V2_ROUTER, [TAKER_TOKEN, MAKER_TOKEN])
|
||||
.callAsync();
|
||||
expect(quotes).to.deep.eq(expectedQuotes);
|
||||
});
|
||||
@@ -801,8 +823,9 @@ blockchainTests.skip('erc20-bridge-sampler', env => {
|
||||
const sampleAmounts = getSampleAmounts(MAKER_TOKEN);
|
||||
const expectedQuotes = _.times(sampleAmounts.length, () => constants.ZERO_AMOUNT);
|
||||
await enableFailTriggerAsync();
|
||||
await testContract.setSampleValues(sampleAmounts).awaitTransactionSuccessAsync();
|
||||
const quotes = await testContract
|
||||
.sampleBuysFromUniswapV2(UNISWAP_V2_ROUTER, [TAKER_TOKEN, MAKER_TOKEN], sampleAmounts)
|
||||
.sampleBuysFromUniswapV2Global(UNISWAP_V2_ROUTER, [TAKER_TOKEN, MAKER_TOKEN])
|
||||
.callAsync();
|
||||
expect(quotes).to.deep.eq(expectedQuotes);
|
||||
});
|
||||
@@ -811,12 +834,9 @@ blockchainTests.skip('erc20-bridge-sampler', env => {
|
||||
const intermediateToken = randomAddress();
|
||||
const sampleAmounts = getSampleAmounts(MAKER_TOKEN);
|
||||
const expectedQuotes = predictBuyQuotes([TAKER_TOKEN, intermediateToken, MAKER_TOKEN], sampleAmounts);
|
||||
await testContract.setSampleValues(sampleAmounts).awaitTransactionSuccessAsync();
|
||||
const quotes = await testContract
|
||||
.sampleBuysFromUniswapV2(
|
||||
UNISWAP_V2_ROUTER,
|
||||
[TAKER_TOKEN, intermediateToken, MAKER_TOKEN],
|
||||
sampleAmounts,
|
||||
)
|
||||
.sampleBuysFromUniswapV2Global(UNISWAP_V2_ROUTER, [TAKER_TOKEN, intermediateToken, MAKER_TOKEN])
|
||||
.callAsync();
|
||||
expect(quotes).to.deep.eq(expectedQuotes);
|
||||
});
|
||||
@@ -920,13 +940,15 @@ blockchainTests.skip('erc20-bridge-sampler', env => {
|
||||
// tslint:disable-next-line no-unnecessary-type-assertion
|
||||
const sellAmount = _.last(getSampleAmounts(TAKER_TOKEN))!;
|
||||
const uniswapV2FirstHopPath = [TAKER_TOKEN, INTERMEDIATE_TOKEN];
|
||||
|
||||
await testContract.setSampleValues([sellAmount]).callAsync();
|
||||
const uniswapV2FirstHop = testContract
|
||||
.sampleSellsFromUniswapV2(UNISWAP_V2_ROUTER, uniswapV2FirstHopPath, [constants.ZERO_AMOUNT])
|
||||
.sampleSellsFromUniswapV2Global(UNISWAP_V2_ROUTER, uniswapV2FirstHopPath)
|
||||
.getABIEncodedTransactionData();
|
||||
|
||||
const uniswapV2SecondHopPath = [INTERMEDIATE_TOKEN, randomAddress(), MAKER_TOKEN];
|
||||
const uniswapV2SecondHop = testContract
|
||||
.sampleSellsFromUniswapV2(UNISWAP_V2_ROUTER, uniswapV2SecondHopPath, [constants.ZERO_AMOUNT])
|
||||
.sampleSellsFromUniswapV2Global(UNISWAP_V2_ROUTER, uniswapV2SecondHopPath)
|
||||
.getABIEncodedTransactionData();
|
||||
|
||||
const firstHopQuotes = [getDeterministicUniswapV2SellQuote(uniswapV2FirstHopPath, sellAmount)];
|
||||
@@ -951,13 +973,15 @@ blockchainTests.skip('erc20-bridge-sampler', env => {
|
||||
// tslint:disable-next-line no-unnecessary-type-assertion
|
||||
const buyAmount = _.last(getSampleAmounts(MAKER_TOKEN))!;
|
||||
const uniswapV2FirstHopPath = [TAKER_TOKEN, INTERMEDIATE_TOKEN];
|
||||
|
||||
await testContract.setSampleValues([buyAmount]).callAsync();
|
||||
const uniswapV2FirstHop = testContract
|
||||
.sampleBuysFromUniswapV2(UNISWAP_V2_ROUTER, uniswapV2FirstHopPath, [constants.ZERO_AMOUNT])
|
||||
.sampleBuysFromUniswapV2Global(UNISWAP_V2_ROUTER, uniswapV2FirstHopPath)
|
||||
.getABIEncodedTransactionData();
|
||||
|
||||
const uniswapV2SecondHopPath = [INTERMEDIATE_TOKEN, randomAddress(), MAKER_TOKEN];
|
||||
const uniswapV2SecondHop = testContract
|
||||
.sampleBuysFromUniswapV2(UNISWAP_V2_ROUTER, uniswapV2SecondHopPath, [constants.ZERO_AMOUNT])
|
||||
.sampleBuysFromUniswapV2Global(UNISWAP_V2_ROUTER, uniswapV2SecondHopPath)
|
||||
.getABIEncodedTransactionData();
|
||||
|
||||
const secondHopQuotes = [getDeterministicUniswapV2BuyQuote(uniswapV2SecondHopPath, buyAmount)];
|
||||
|
||||
@@ -148,10 +148,9 @@ describe('DexSampler tests', () => {
|
||||
const expectedTakerFillAmounts = getSampleAmounts(new BigNumber(100e18), 10);
|
||||
const expectedMakerFillAmounts = getSampleAmounts(new BigNumber(100e18), 10);
|
||||
const sampler = new MockSamplerContract({
|
||||
sampleSellsFromKyberNetwork: (_reserveOffset, takerToken, makerToken, fillAmounts) => {
|
||||
sampleSellsFromKyberNetworkGlobal: (_reserveOffset, takerToken, makerToken) => {
|
||||
expect(takerToken).to.eq(expectedTakerToken);
|
||||
expect(makerToken).to.eq(expectedMakerToken);
|
||||
expect(fillAmounts).to.deep.eq(expectedTakerFillAmounts);
|
||||
return ['0x', '0x', expectedMakerFillAmounts];
|
||||
},
|
||||
});
|
||||
@@ -182,7 +181,7 @@ describe('DexSampler tests', () => {
|
||||
const poolAddress = randomAddress();
|
||||
const gasCost = 123;
|
||||
const sampler = new MockSamplerContract({
|
||||
sampleSellsFromLiquidityProvider: (providerAddress, takerToken, makerToken, _fillAmounts) => {
|
||||
sampleSellsFromLiquidityProviderGlobal: (providerAddress, takerToken, makerToken) => {
|
||||
expect(providerAddress).to.eq(poolAddress);
|
||||
expect(takerToken).to.eq(expectedTakerToken);
|
||||
expect(makerToken).to.eq(expectedMakerToken);
|
||||
@@ -226,7 +225,7 @@ describe('DexSampler tests', () => {
|
||||
const poolAddress = randomAddress();
|
||||
const gasCost = 321;
|
||||
const sampler = new MockSamplerContract({
|
||||
sampleBuysFromLiquidityProvider: (providerAddress, takerToken, makerToken, _fillAmounts) => {
|
||||
sampleBuysFromLiquidityProviderGlobal: (providerAddress, takerToken, makerToken) => {
|
||||
expect(providerAddress).to.eq(poolAddress);
|
||||
expect(takerToken).to.eq(expectedTakerToken);
|
||||
expect(makerToken).to.eq(expectedMakerToken);
|
||||
@@ -270,10 +269,9 @@ describe('DexSampler tests', () => {
|
||||
const expectedTakerFillAmounts = getSampleAmounts(new BigNumber(100e18), 10);
|
||||
const expectedMakerFillAmounts = getSampleAmounts(new BigNumber(100e18), 10);
|
||||
const sampler = new MockSamplerContract({
|
||||
sampleSellsFromUniswap: (_router, takerToken, makerToken, fillAmounts) => {
|
||||
sampleSellsFromUniswapGlobal: (_router, takerToken, makerToken) => {
|
||||
expect(takerToken).to.eq(expectedTakerToken);
|
||||
expect(makerToken).to.eq(expectedMakerToken);
|
||||
expect(fillAmounts).to.deep.eq(expectedTakerFillAmounts);
|
||||
return expectedMakerFillAmounts;
|
||||
},
|
||||
});
|
||||
@@ -303,9 +301,8 @@ describe('DexSampler tests', () => {
|
||||
const expectedTakerFillAmounts = getSampleAmounts(new BigNumber(100e18), 10);
|
||||
const expectedMakerFillAmounts = getSampleAmounts(new BigNumber(100e18), 10);
|
||||
const sampler = new MockSamplerContract({
|
||||
sampleSellsFromUniswapV2: (_router, path, fillAmounts) => {
|
||||
sampleSellsFromUniswapV2Global: (_router, path) => {
|
||||
expect(path).to.deep.eq([expectedMakerToken, expectedTakerToken]);
|
||||
expect(fillAmounts).to.deep.eq(expectedTakerFillAmounts);
|
||||
return expectedMakerFillAmounts;
|
||||
},
|
||||
});
|
||||
@@ -334,10 +331,9 @@ describe('DexSampler tests', () => {
|
||||
const expectedTakerFillAmounts = getSampleAmounts(new BigNumber(100e18), 10);
|
||||
const expectedMakerFillAmounts = getSampleAmounts(new BigNumber(100e18), 10);
|
||||
const sampler = new MockSamplerContract({
|
||||
sampleBuysFromUniswap: (_router, takerToken, makerToken, fillAmounts) => {
|
||||
sampleBuysFromUniswapGlobal: (_router, takerToken, makerToken) => {
|
||||
expect(takerToken).to.eq(expectedTakerToken);
|
||||
expect(makerToken).to.eq(expectedMakerToken);
|
||||
expect(fillAmounts).to.deep.eq(expectedMakerFillAmounts);
|
||||
return expectedTakerFillAmounts;
|
||||
},
|
||||
});
|
||||
@@ -378,14 +374,15 @@ describe('DexSampler tests', () => {
|
||||
let uniswapRouter: string;
|
||||
let uniswapV2Router: string;
|
||||
const sampler = new MockSamplerContract({
|
||||
sampleSellsFromUniswap: (router, takerToken, makerToken, fillAmounts) => {
|
||||
sampleSellsFromUniswapGlobal: (router, takerToken, makerToken) => {
|
||||
uniswapRouter = router;
|
||||
expect(takerToken).to.eq(expectedTakerToken);
|
||||
expect(makerToken).to.eq(expectedMakerToken);
|
||||
expect(fillAmounts).to.deep.eq(expectedTakerFillAmounts);
|
||||
return fillAmounts.map(a => a.times(ratesBySource[ERC20BridgeSource.Uniswap]).integerValue());
|
||||
return expectedTakerFillAmounts.map(a =>
|
||||
a.times(ratesBySource[ERC20BridgeSource.Uniswap]).integerValue(),
|
||||
);
|
||||
},
|
||||
sampleSellsFromUniswapV2: (router, path, fillAmounts) => {
|
||||
sampleSellsFromUniswapV2Global: (router, path) => {
|
||||
uniswapV2Router = router;
|
||||
if (path.length === 2) {
|
||||
expect(path).to.deep.eq([expectedTakerToken, expectedMakerToken]);
|
||||
@@ -394,8 +391,9 @@ describe('DexSampler tests', () => {
|
||||
} else {
|
||||
expect(path).to.have.lengthOf.within(2, 3);
|
||||
}
|
||||
expect(fillAmounts).to.deep.eq(expectedTakerFillAmounts);
|
||||
return fillAmounts.map(a => a.times(ratesBySource[ERC20BridgeSource.UniswapV2]).integerValue());
|
||||
return expectedTakerFillAmounts.map(a =>
|
||||
a.times(ratesBySource[ERC20BridgeSource.UniswapV2]).integerValue(),
|
||||
);
|
||||
},
|
||||
});
|
||||
const dexOrderSampler = new DexOrderSampler(
|
||||
@@ -463,14 +461,15 @@ describe('DexSampler tests', () => {
|
||||
let uniswapRouter: string;
|
||||
let uniswapV2Router: string;
|
||||
const sampler = new MockSamplerContract({
|
||||
sampleBuysFromUniswap: (router, takerToken, makerToken, fillAmounts) => {
|
||||
sampleBuysFromUniswapGlobal: (router, takerToken, makerToken) => {
|
||||
uniswapRouter = router;
|
||||
expect(takerToken).to.eq(expectedTakerToken);
|
||||
expect(makerToken).to.eq(expectedMakerToken);
|
||||
expect(fillAmounts).to.deep.eq(expectedMakerFillAmounts);
|
||||
return fillAmounts.map(a => a.times(ratesBySource[ERC20BridgeSource.Uniswap]).integerValue());
|
||||
return expectedMakerFillAmounts.map(a =>
|
||||
a.times(ratesBySource[ERC20BridgeSource.Uniswap]).integerValue(),
|
||||
);
|
||||
},
|
||||
sampleBuysFromUniswapV2: (router, path, fillAmounts) => {
|
||||
sampleBuysFromUniswapV2Global: (router, path) => {
|
||||
uniswapV2Router = router;
|
||||
if (path.length === 2) {
|
||||
expect(path).to.deep.eq([expectedTakerToken, expectedMakerToken]);
|
||||
@@ -479,8 +478,9 @@ describe('DexSampler tests', () => {
|
||||
} else {
|
||||
expect(path).to.have.lengthOf.within(2, 3);
|
||||
}
|
||||
expect(fillAmounts).to.deep.eq(expectedMakerFillAmounts);
|
||||
return fillAmounts.map(a => a.times(ratesBySource[ERC20BridgeSource.UniswapV2]).integerValue());
|
||||
return expectedMakerFillAmounts.map(a =>
|
||||
a.times(ratesBySource[ERC20BridgeSource.UniswapV2]).integerValue(),
|
||||
);
|
||||
},
|
||||
});
|
||||
const dexOrderSampler = new DexOrderSampler(
|
||||
|
||||
@@ -430,6 +430,8 @@ describe('MarketOperationUtils tests', () => {
|
||||
isAddressContract: (..._params: any[]) => false,
|
||||
getGasLeft: () => ZERO_AMOUNT,
|
||||
getBlockNumber: () => ZERO_AMOUNT,
|
||||
// tslint:disable-next-line:no-empty
|
||||
setSampleValues: () => {},
|
||||
};
|
||||
|
||||
const MOCK_SAMPLER = ({
|
||||
|
||||
@@ -15,51 +15,24 @@ export type GetOrderFillableAssetAmountHandler = (
|
||||
) => GetOrderFillableAssetAmountResult;
|
||||
|
||||
export type SampleResults = BigNumber[];
|
||||
export type SampleSellsUniswapHandler = (
|
||||
router: string,
|
||||
takerToken: string,
|
||||
makerToken: string,
|
||||
takerTokenAmounts: BigNumber[],
|
||||
) => SampleResults;
|
||||
export type SampleBuysUniswapHandler = (
|
||||
router: string,
|
||||
takerToken: string,
|
||||
makerToken: string,
|
||||
makerTokenAmounts: BigNumber[],
|
||||
) => SampleResults;
|
||||
export type SampleSellsEth2DaiHandler = (
|
||||
router: string,
|
||||
takerToken: string,
|
||||
makerToken: string,
|
||||
takerTokenAmounts: BigNumber[],
|
||||
) => SampleResults;
|
||||
export type SampleBuysEth2DaiHandler = (
|
||||
router: string,
|
||||
takerToken: string,
|
||||
makerToken: string,
|
||||
makerTokenAmounts: BigNumber[],
|
||||
) => SampleResults;
|
||||
export type SampleSellsUniswapHandler = (router: string, takerToken: string, makerToken: string) => SampleResults;
|
||||
export type SampleBuysUniswapHandler = (router: string, takerToken: string, makerToken: string) => SampleResults;
|
||||
export type SampleSellsEth2DaiHandler = (router: string, takerToken: string, makerToken: string) => SampleResults;
|
||||
export type SampleBuysEth2DaiHandler = (router: string, takerToken: string, makerToken: string) => SampleResults;
|
||||
export type SampleSellsKyberHandler = (
|
||||
opts: KyberSamplerOpts,
|
||||
takerToken: string,
|
||||
makerToken: string,
|
||||
takerTokenAmounts: BigNumber[],
|
||||
) => [string, string, SampleResults];
|
||||
export type SampleBuysKyberHandler = (
|
||||
reserveId: string,
|
||||
takerToken: string,
|
||||
makerToken: string,
|
||||
makerTokenAmounts: BigNumber[],
|
||||
) => [string, SampleResults];
|
||||
export type SampleUniswapV2Handler = (router: string, path: string[], assetAmounts: BigNumber[]) => SampleResults;
|
||||
export type SampleBuysMultihopHandler = (path: string[], takerTokenAmounts: BigNumber[]) => SampleResults;
|
||||
export type SampleSellsLPHandler = (
|
||||
providerAddress: string,
|
||||
takerToken: string,
|
||||
makerToken: string,
|
||||
takerTokenAmounts: BigNumber[],
|
||||
) => SampleResults;
|
||||
export type SampleSellsMultihopHandler = (path: string[], takerTokenAmounts: BigNumber[]) => SampleResults;
|
||||
export type SampleUniswapV2Handler = (router: string, path: string[]) => SampleResults;
|
||||
export type SampleBuysMultihopHandler = (path: string[]) => SampleResults;
|
||||
export type SampleSellsLPHandler = (providerAddress: string, takerToken: string, makerToken: string) => SampleResults;
|
||||
export type SampleSellsMultihopHandler = (path: string[]) => SampleResults;
|
||||
|
||||
const DUMMY_PROVIDER = {
|
||||
sendAsync: (..._args: any[]): any => {
|
||||
@@ -70,13 +43,13 @@ const DUMMY_PROVIDER = {
|
||||
interface Handlers {
|
||||
getLimitOrderFillableMakerAssetAmounts: GetOrderFillableAssetAmountHandler;
|
||||
getLimitOrderFillableTakerAssetAmounts: GetOrderFillableAssetAmountHandler;
|
||||
sampleSellsFromKyberNetwork: SampleSellsKyberHandler;
|
||||
sampleSellsFromLiquidityProvider: SampleSellsLPHandler;
|
||||
sampleSellsFromUniswap: SampleSellsUniswapHandler;
|
||||
sampleSellsFromUniswapV2: SampleUniswapV2Handler;
|
||||
sampleBuysFromUniswap: SampleBuysUniswapHandler;
|
||||
sampleBuysFromUniswapV2: SampleUniswapV2Handler;
|
||||
sampleBuysFromLiquidityProvider: SampleSellsLPHandler;
|
||||
sampleSellsFromKyberNetworkGlobal: SampleSellsKyberHandler;
|
||||
sampleSellsFromLiquidityProviderGlobal: SampleSellsLPHandler;
|
||||
sampleSellsFromUniswapGlobal: SampleSellsUniswapHandler;
|
||||
sampleSellsFromUniswapV2Global: SampleUniswapV2Handler;
|
||||
sampleBuysFromUniswapGlobal: SampleBuysUniswapHandler;
|
||||
sampleBuysFromUniswapV2Global: SampleUniswapV2Handler;
|
||||
sampleBuysFromLiquidityProviderGlobal: SampleSellsLPHandler;
|
||||
}
|
||||
|
||||
// tslint:disable: no-unbound-method
|
||||
@@ -130,12 +103,11 @@ export class MockSamplerContract extends ERC20BridgeSamplerContract {
|
||||
takerAssetAmounts: BigNumber[],
|
||||
): ContractTxFunctionObj<[string, string, BigNumber[]]> {
|
||||
return this._wrapCall(
|
||||
super.sampleSellsFromKyberNetwork,
|
||||
this._handlers.sampleSellsFromKyberNetwork,
|
||||
super.sampleSellsFromKyberNetworkGlobal,
|
||||
this._handlers.sampleSellsFromKyberNetworkGlobal,
|
||||
{ ...opts, reserveOffset: new BigNumber(1), hint: NULL_BYTES },
|
||||
takerToken,
|
||||
makerToken,
|
||||
takerAssetAmounts,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -146,12 +118,11 @@ export class MockSamplerContract extends ERC20BridgeSamplerContract {
|
||||
takerAssetAmounts: BigNumber[],
|
||||
): ContractTxFunctionObj<BigNumber[]> {
|
||||
return this._wrapCall(
|
||||
super.sampleSellsFromUniswap,
|
||||
this._handlers.sampleSellsFromUniswap,
|
||||
super.sampleSellsFromUniswapGlobal,
|
||||
this._handlers.sampleSellsFromUniswapGlobal,
|
||||
router,
|
||||
takerToken,
|
||||
makerToken,
|
||||
takerAssetAmounts,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -161,11 +132,10 @@ export class MockSamplerContract extends ERC20BridgeSamplerContract {
|
||||
takerAssetAmounts: BigNumber[],
|
||||
): ContractTxFunctionObj<BigNumber[]> {
|
||||
return this._wrapCall(
|
||||
super.sampleSellsFromUniswapV2,
|
||||
this._handlers.sampleSellsFromUniswapV2,
|
||||
super.sampleSellsFromUniswapV2Global,
|
||||
this._handlers.sampleSellsFromUniswapV2Global,
|
||||
router,
|
||||
path,
|
||||
takerAssetAmounts,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -176,12 +146,11 @@ export class MockSamplerContract extends ERC20BridgeSamplerContract {
|
||||
takerAssetAmounts: BigNumber[],
|
||||
): ContractTxFunctionObj<BigNumber[]> {
|
||||
return this._wrapCall(
|
||||
super.sampleSellsFromLiquidityProvider,
|
||||
this._handlers.sampleSellsFromLiquidityProvider,
|
||||
super.sampleSellsFromLiquidityProviderGlobal,
|
||||
this._handlers.sampleSellsFromLiquidityProviderGlobal,
|
||||
providerAddress,
|
||||
takerToken,
|
||||
makerToken,
|
||||
takerAssetAmounts,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -192,12 +161,11 @@ export class MockSamplerContract extends ERC20BridgeSamplerContract {
|
||||
makerAssetAmounts: BigNumber[],
|
||||
): ContractTxFunctionObj<BigNumber[]> {
|
||||
return this._wrapCall(
|
||||
super.sampleBuysFromUniswap,
|
||||
this._handlers.sampleBuysFromUniswap,
|
||||
super.sampleBuysFromUniswapGlobal,
|
||||
this._handlers.sampleBuysFromUniswapGlobal,
|
||||
router,
|
||||
takerToken,
|
||||
makerToken,
|
||||
makerAssetAmounts,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -207,11 +175,10 @@ export class MockSamplerContract extends ERC20BridgeSamplerContract {
|
||||
makerAssetAmounts: BigNumber[],
|
||||
): ContractTxFunctionObj<BigNumber[]> {
|
||||
return this._wrapCall(
|
||||
super.sampleBuysFromUniswapV2,
|
||||
this._handlers.sampleBuysFromUniswapV2,
|
||||
super.sampleBuysFromUniswapV2Global,
|
||||
this._handlers.sampleBuysFromUniswapV2Global,
|
||||
router,
|
||||
path,
|
||||
makerAssetAmounts,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user