fix: Update to use KNP getExpectedRateAfterFee (#2629)
* Update to use KNP getExpectedRateAfterFee * hack: use overrides instead of forking in ganache * fix: added some tests using overrides * override sampler * Overrides in bridge_sampler_mainnet_test * use getContracts to fake out tests * chore: supply devUtils address * feat: specify the call override by default * CHANGELOGs * export SamplerOverrides * fix package.json * fix: after rebase
This commit is contained in:
@@ -32,6 +32,7 @@ describe('DexSampler tests', () => {
|
||||
const TAKER_ASSET_DATA = assetDataUtils.encodeERC20AssetData(TAKER_TOKEN);
|
||||
|
||||
const wethAddress = getContractAddressesForChainOrThrow(CHAIN_ID).etherToken;
|
||||
const devUtilsAddress = getContractAddressesForChainOrThrow(CHAIN_ID).devUtils;
|
||||
|
||||
describe('getSampleAmounts()', () => {
|
||||
const FILL_AMOUNT = getRandomInteger(1, 1e18);
|
||||
@@ -105,7 +106,7 @@ describe('DexSampler tests', () => {
|
||||
});
|
||||
const dexOrderSampler = new DexOrderSampler(sampler);
|
||||
const [fillableAmounts] = await dexOrderSampler.executeAsync(
|
||||
DexOrderSampler.ops.getOrderFillableMakerAmounts(ORDERS),
|
||||
DexOrderSampler.ops.getOrderFillableMakerAmounts(ORDERS, devUtilsAddress),
|
||||
);
|
||||
expect(fillableAmounts).to.deep.eq(expectedFillableAmounts);
|
||||
});
|
||||
@@ -121,7 +122,7 @@ describe('DexSampler tests', () => {
|
||||
});
|
||||
const dexOrderSampler = new DexOrderSampler(sampler);
|
||||
const [fillableAmounts] = await dexOrderSampler.executeAsync(
|
||||
DexOrderSampler.ops.getOrderFillableTakerAmounts(ORDERS),
|
||||
DexOrderSampler.ops.getOrderFillableTakerAmounts(ORDERS, devUtilsAddress),
|
||||
);
|
||||
expect(fillableAmounts).to.deep.eq(expectedFillableAmounts);
|
||||
});
|
||||
@@ -483,7 +484,7 @@ describe('DexSampler tests', () => {
|
||||
return Promise.resolve(pools);
|
||||
},
|
||||
});
|
||||
const dexOrderSampler = new DexOrderSampler(new MockSamplerContract({}), balancerPoolsCache);
|
||||
const dexOrderSampler = new DexOrderSampler(new MockSamplerContract({}), undefined, balancerPoolsCache);
|
||||
const [quotes] = await dexOrderSampler.executeAsync(
|
||||
await DexOrderSampler.ops.getSellQuotesAsync(
|
||||
[ERC20BridgeSource.Balancer],
|
||||
@@ -589,7 +590,7 @@ describe('DexSampler tests', () => {
|
||||
return Promise.resolve(pools);
|
||||
},
|
||||
});
|
||||
const dexOrderSampler = new DexOrderSampler(new MockSamplerContract({}), balancerPoolsCache);
|
||||
const dexOrderSampler = new DexOrderSampler(new MockSamplerContract({}), undefined, balancerPoolsCache);
|
||||
const [quotes] = await dexOrderSampler.executeAsync(
|
||||
await DexOrderSampler.ops.getBuyQuotesAsync(
|
||||
[ERC20BridgeSource.Balancer],
|
||||
@@ -631,8 +632,8 @@ describe('DexSampler tests', () => {
|
||||
});
|
||||
const dexOrderSampler = new DexOrderSampler(sampler);
|
||||
const [fillableMakerAmounts, fillableTakerAmounts] = await dexOrderSampler.executeAsync(
|
||||
DexOrderSampler.ops.getOrderFillableMakerAmounts(ORDERS),
|
||||
DexOrderSampler.ops.getOrderFillableTakerAmounts(ORDERS),
|
||||
DexOrderSampler.ops.getOrderFillableMakerAmounts(ORDERS, devUtilsAddress),
|
||||
DexOrderSampler.ops.getOrderFillableTakerAmounts(ORDERS, devUtilsAddress),
|
||||
);
|
||||
expect(fillableMakerAmounts).to.deep.eq(expectedFillableMakerAmounts);
|
||||
expect(fillableTakerAmounts).to.deep.eq(expectedFillableTakerAmounts);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ContractFunctionObj } from '@0x/base-contract';
|
||||
import { IERC20BridgeSamplerContract } from '@0x/contract-wrappers';
|
||||
import { ERC20BridgeSamplerContract } from '@0x/contract-wrappers';
|
||||
import { constants } from '@0x/contracts-test-utils';
|
||||
import { Order } from '@0x/types';
|
||||
import { BigNumber, hexUtils } from '@0x/utils';
|
||||
@@ -8,6 +8,7 @@ export type GetOrderFillableAssetAmountResult = BigNumber[];
|
||||
export type GetOrderFillableAssetAmountHandler = (
|
||||
orders: Order[],
|
||||
signatures: string[],
|
||||
devUtilsAddress: string,
|
||||
) => GetOrderFillableAssetAmountResult;
|
||||
|
||||
export type SampleResults = BigNumber[];
|
||||
@@ -58,7 +59,7 @@ interface Handlers {
|
||||
sampleBuysFromLiquidityProviderRegistry: SampleSellsLPHandler;
|
||||
}
|
||||
|
||||
export class MockSamplerContract extends IERC20BridgeSamplerContract {
|
||||
export class MockSamplerContract extends ERC20BridgeSamplerContract {
|
||||
private readonly _handlers: Partial<Handlers> = {};
|
||||
|
||||
public constructor(handlers: Partial<Handlers> = {}) {
|
||||
@@ -82,6 +83,7 @@ export class MockSamplerContract extends IERC20BridgeSamplerContract {
|
||||
this._handlers.getOrderFillableMakerAssetAmounts,
|
||||
orders,
|
||||
signatures,
|
||||
constants.NULL_ADDRESS,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -94,6 +96,7 @@ export class MockSamplerContract extends IERC20BridgeSamplerContract {
|
||||
this._handlers.getOrderFillableTakerAssetAmounts,
|
||||
orders,
|
||||
signatures,
|
||||
constants.NULL_ADDRESS,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user