performed a rename
This commit is contained in:
parent
08619e2c06
commit
7495ac8111
@ -41,7 +41,7 @@ contract DummyLiquidityProviderRegistry
|
||||
poolAddress = _gAddressBook[takerToken][makerToken];
|
||||
require(
|
||||
poolAddress != NULL_ADDRESS,
|
||||
"PLPRegistry/MARKET_PAIR_NOT_SET"
|
||||
"Registry/MARKET_PAIR_NOT_SET"
|
||||
);
|
||||
}
|
||||
}
|
@ -144,7 +144,7 @@ export class SwapQuoter {
|
||||
* @return An instance of SwapQuoter
|
||||
*/
|
||||
constructor(supportedProvider: SupportedProvider, orderbook: Orderbook, options: Partial<SwapQuoterOpts> = {}) {
|
||||
const { chainId, expiryBufferMs, permittedOrderFeeTypes, samplerGasLimit, plpRegistryAddress } = _.merge(
|
||||
const { chainId, expiryBufferMs, permittedOrderFeeTypes, samplerGasLimit, liquidityProviderRegistryAddress } = _.merge(
|
||||
{},
|
||||
constants.DEFAULT_SWAP_QUOTER_OPTS,
|
||||
options,
|
||||
@ -174,7 +174,7 @@ export class SwapQuoter {
|
||||
chainId,
|
||||
exchangeAddress: this._contractAddresses.exchange,
|
||||
},
|
||||
plpRegistryAddress,
|
||||
liquidityProviderRegistryAddress,
|
||||
);
|
||||
this._swapQuoteCalculator = new SwapQuoteCalculator(this._protocolFeeUtils, this._marketOperationUtils);
|
||||
}
|
||||
|
@ -212,7 +212,7 @@ export interface SwapQuoterOpts extends OrderPrunerOpts {
|
||||
expiryBufferMs: number;
|
||||
contractAddresses?: ContractAddresses;
|
||||
samplerGasLimit?: number;
|
||||
plpRegistryAddress?: string;
|
||||
liquidityProviderRegistryAddress?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -32,7 +32,7 @@ export class CreateOrderUtils {
|
||||
outputToken: string,
|
||||
path: CollapsedFill[],
|
||||
bridgeSlippage: number,
|
||||
plpPoolAddress?: string,
|
||||
liquidityPoolAddress?: string,
|
||||
): OptimizedMarketOrder[] {
|
||||
const orders: OptimizedMarketOrder[] = [];
|
||||
for (const fill of path) {
|
||||
@ -43,7 +43,7 @@ export class CreateOrderUtils {
|
||||
createBridgeOrder(
|
||||
orderDomain,
|
||||
fill,
|
||||
this._getBridgeAddressFromSource(fill.source, plpPoolAddress),
|
||||
this._getBridgeAddressFromSource(fill.source, liquidityPoolAddress),
|
||||
outputToken,
|
||||
inputToken,
|
||||
bridgeSlippage,
|
||||
@ -61,7 +61,7 @@ export class CreateOrderUtils {
|
||||
outputToken: string,
|
||||
path: CollapsedFill[],
|
||||
bridgeSlippage: number,
|
||||
plpPoolAddress?: string,
|
||||
liquidityPoolAddress?: string,
|
||||
): OptimizedMarketOrder[] {
|
||||
const orders: OptimizedMarketOrder[] = [];
|
||||
for (const fill of path) {
|
||||
@ -72,7 +72,7 @@ export class CreateOrderUtils {
|
||||
createBridgeOrder(
|
||||
orderDomain,
|
||||
fill,
|
||||
this._getBridgeAddressFromSource(fill.source, plpPoolAddress),
|
||||
this._getBridgeAddressFromSource(fill.source, liquidityPoolAddress),
|
||||
inputToken,
|
||||
outputToken,
|
||||
bridgeSlippage,
|
||||
@ -84,7 +84,7 @@ export class CreateOrderUtils {
|
||||
return orders;
|
||||
}
|
||||
|
||||
private _getBridgeAddressFromSource(source: ERC20BridgeSource, plpPoolAddress?: string): string {
|
||||
private _getBridgeAddressFromSource(source: ERC20BridgeSource, liquidityPoolAddress?: string): string {
|
||||
switch (source) {
|
||||
case ERC20BridgeSource.Eth2Dai:
|
||||
return this._contractAddress.eth2DaiBridge;
|
||||
@ -96,12 +96,12 @@ export class CreateOrderUtils {
|
||||
case ERC20BridgeSource.CurveUsdcDaiUsdt:
|
||||
case ERC20BridgeSource.CurveUsdcDaiUsdtTusd:
|
||||
return this._contractAddress.curveBridge;
|
||||
case ERC20BridgeSource.Plp:
|
||||
if (plpPoolAddress === undefined) {
|
||||
throw new Error('Cannot create a PLP order without a PLP pool address.');
|
||||
case ERC20BridgeSource.LiquidityProvider:
|
||||
if (liquidityPoolAddress === undefined) {
|
||||
throw new Error('Cannot create a LiquidityProvider order without a LiquidityProvider pool address.');
|
||||
}
|
||||
assert.isETHAddressHex('plpPoolAddress', plpPoolAddress);
|
||||
return plpPoolAddress;
|
||||
assert.isETHAddressHex('liquidityPoolAddress', liquidityPoolAddress);
|
||||
return liquidityPoolAddress;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ export class MarketOperationUtils {
|
||||
private readonly _sampler: DexOrderSampler,
|
||||
contractAddresses: ContractAddresses,
|
||||
private readonly _orderDomain: OrderDomain,
|
||||
private readonly _plpRegistryAddress: string = NULL_ADDRESS,
|
||||
private readonly _liquidityProviderRegistry: string = NULL_ADDRESS,
|
||||
) {
|
||||
this._createOrderUtils = new CreateOrderUtils(contractAddresses);
|
||||
this._wethAddress = contractAddresses.etherToken;
|
||||
@ -73,24 +73,24 @@ export class MarketOperationUtils {
|
||||
...opts,
|
||||
};
|
||||
const [makerToken, takerToken] = getOrderTokens(nativeOrders[0]);
|
||||
const [fillableAmounts, plpPoolAddress, ethToMakerAssetRate, dexQuotes] = await this._sampler.executeAsync(
|
||||
const [fillableAmounts, liquidityPoolAddress, ethToMakerAssetRate, dexQuotes] = await this._sampler.executeAsync(
|
||||
DexOrderSampler.ops.getOrderFillableTakerAmounts(nativeOrders),
|
||||
DexOrderSampler.ops.getLiquidityProviderFromRegistry(this._plpRegistryAddress, takerToken, makerToken),
|
||||
DexOrderSampler.ops.getLiquidityProviderFromRegistry(this._liquidityProviderRegistry, takerToken, makerToken),
|
||||
makerToken.toLowerCase() === this._wethAddress.toLowerCase()
|
||||
? DexOrderSampler.ops.constant(new BigNumber(1))
|
||||
: DexOrderSampler.ops.getMedianSellRate(
|
||||
difference(FEE_QUOTE_SOURCES, _opts.excludedSources).concat(this._plpSourceIfAvailable()),
|
||||
difference(FEE_QUOTE_SOURCES, _opts.excludedSources).concat(this._liquidityPoolSourceIfAvailable()),
|
||||
makerToken,
|
||||
this._wethAddress,
|
||||
ONE_ETHER,
|
||||
this._plpRegistryAddress,
|
||||
this._liquidityProviderRegistry,
|
||||
),
|
||||
DexOrderSampler.ops.getSellQuotes(
|
||||
difference(SELL_SOURCES, _opts.excludedSources).concat(this._plpSourceIfAvailable()),
|
||||
difference(SELL_SOURCES, _opts.excludedSources).concat(this._liquidityPoolSourceIfAvailable()),
|
||||
makerToken,
|
||||
takerToken,
|
||||
getSampleAmounts(takerAmount, _opts.numSamples, _opts.sampleDistributionBase),
|
||||
this._plpRegistryAddress,
|
||||
this._liquidityProviderRegistry,
|
||||
),
|
||||
);
|
||||
|
||||
@ -135,7 +135,7 @@ export class MarketOperationUtils {
|
||||
makerToken,
|
||||
collapsePath(optimalPath, false),
|
||||
_opts.bridgeSlippage,
|
||||
plpPoolAddress,
|
||||
liquidityPoolAddress,
|
||||
);
|
||||
}
|
||||
|
||||
@ -160,24 +160,24 @@ export class MarketOperationUtils {
|
||||
...opts,
|
||||
};
|
||||
const [makerToken, takerToken] = getOrderTokens(nativeOrders[0]);
|
||||
const [fillableAmounts, plpPoolAddress, ethToTakerAssetRate, dexQuotes] = await this._sampler.executeAsync(
|
||||
const [fillableAmounts, liquidityPoolAddress, ethToTakerAssetRate, dexQuotes] = await this._sampler.executeAsync(
|
||||
DexOrderSampler.ops.getOrderFillableMakerAmounts(nativeOrders),
|
||||
DexOrderSampler.ops.getLiquidityProviderFromRegistry(this._plpRegistryAddress, takerToken, makerToken),
|
||||
DexOrderSampler.ops.getLiquidityProviderFromRegistry(this._liquidityProviderRegistry, takerToken, makerToken),
|
||||
takerToken.toLowerCase() === this._wethAddress.toLowerCase()
|
||||
? DexOrderSampler.ops.constant(new BigNumber(1))
|
||||
: DexOrderSampler.ops.getMedianSellRate(
|
||||
difference(FEE_QUOTE_SOURCES, _opts.excludedSources).concat(this._plpSourceIfAvailable()),
|
||||
difference(FEE_QUOTE_SOURCES, _opts.excludedSources).concat(this._liquidityPoolSourceIfAvailable()),
|
||||
takerToken,
|
||||
this._wethAddress,
|
||||
ONE_ETHER,
|
||||
this._plpRegistryAddress,
|
||||
this._liquidityProviderRegistry,
|
||||
),
|
||||
DexOrderSampler.ops.getBuyQuotes(
|
||||
difference(BUY_SOURCES, _opts.excludedSources).concat(this._plpSourceIfAvailable()),
|
||||
difference(BUY_SOURCES, _opts.excludedSources).concat(this._liquidityPoolSourceIfAvailable()),
|
||||
makerToken,
|
||||
takerToken,
|
||||
getSampleAmounts(makerAmount, _opts.numSamples, _opts.sampleDistributionBase),
|
||||
this._plpRegistryAddress,
|
||||
this._liquidityProviderRegistry,
|
||||
),
|
||||
);
|
||||
const signedOrderWithFillableAmounts = this._createBuyOrdersPathFromSamplerResultIfExists(
|
||||
@ -187,7 +187,7 @@ export class MarketOperationUtils {
|
||||
dexQuotes,
|
||||
ethToTakerAssetRate,
|
||||
_opts,
|
||||
plpPoolAddress,
|
||||
liquidityPoolAddress,
|
||||
);
|
||||
if (!signedOrderWithFillableAmounts) {
|
||||
throw new Error(AggregationError.NoOptimalPath);
|
||||
@ -253,8 +253,8 @@ export class MarketOperationUtils {
|
||||
);
|
||||
}
|
||||
|
||||
private _plpSourceIfAvailable(): ERC20BridgeSource[] {
|
||||
return this._plpRegistryAddress !== NULL_ADDRESS ? [ERC20BridgeSource.Plp] : [];
|
||||
private _liquidityPoolSourceIfAvailable(): ERC20BridgeSource[] {
|
||||
return this._liquidityProviderRegistry !== NULL_ADDRESS ? [ERC20BridgeSource.LiquidityProvider] : [];
|
||||
}
|
||||
|
||||
private _createBuyOrdersPathFromSamplerResultIfExists(
|
||||
@ -264,7 +264,7 @@ export class MarketOperationUtils {
|
||||
dexQuotes: DexSample[][],
|
||||
ethToTakerAssetRate: BigNumber,
|
||||
opts: GetMarketOrdersOpts,
|
||||
plpPoolAddress?: string | undefined,
|
||||
liquidityPoolAddress?: string | undefined,
|
||||
): OptimizedMarketOrder[] | undefined {
|
||||
const nativeOrdersWithFillableAmounts = createSignedOrdersWithFillableAmounts(
|
||||
nativeOrders,
|
||||
@ -307,7 +307,7 @@ export class MarketOperationUtils {
|
||||
outputToken,
|
||||
collapsePath(optimalPath, true),
|
||||
opts.bridgeSlippage,
|
||||
plpPoolAddress,
|
||||
liquidityPoolAddress,
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -489,8 +489,8 @@ function sourceToFillFlags(source: ERC20BridgeSource): number {
|
||||
if (source === ERC20BridgeSource.Uniswap) {
|
||||
return FillFlags.SourceUniswap;
|
||||
}
|
||||
if (source === ERC20BridgeSource.Plp) {
|
||||
return FillFlags.SourcePlp;
|
||||
if (source === ERC20BridgeSource.LiquidityProvider) {
|
||||
return FillFlags.SourceLiquidityPool;
|
||||
}
|
||||
return FillFlags.SourceNative;
|
||||
}
|
||||
|
@ -75,8 +75,8 @@ const samplerOperations = {
|
||||
},
|
||||
};
|
||||
},
|
||||
getPLPSellQuotes(
|
||||
plpRegistryAddress: string,
|
||||
getLiquidityProviderSellQuotes(
|
||||
liquidityProviderRegistryAddress: string,
|
||||
takerToken: string,
|
||||
makerToken: string,
|
||||
takerFillAmounts: BigNumber[],
|
||||
@ -85,7 +85,7 @@ const samplerOperations = {
|
||||
encodeCall: contract => {
|
||||
return contract
|
||||
.sampleSellsFromLiquidityProviderRegistry(
|
||||
plpRegistryAddress,
|
||||
liquidityProviderRegistryAddress,
|
||||
takerToken,
|
||||
makerToken,
|
||||
takerFillAmounts,
|
||||
@ -100,8 +100,8 @@ const samplerOperations = {
|
||||
},
|
||||
};
|
||||
},
|
||||
getPLPBuyQuotes(
|
||||
plpRegistryAddress: string,
|
||||
getLiquidityProviderBuyQuotes(
|
||||
liquidityProviderRegistryAddress: string,
|
||||
takerToken: string,
|
||||
makerToken: string,
|
||||
makerFillAmounts: BigNumber[],
|
||||
@ -110,7 +110,7 @@ const samplerOperations = {
|
||||
encodeCall: contract => {
|
||||
return contract
|
||||
.sampleBuysFromLiquidityProviderRegistry(
|
||||
plpRegistryAddress,
|
||||
liquidityProviderRegistryAddress,
|
||||
takerToken,
|
||||
makerToken,
|
||||
makerFillAmounts,
|
||||
@ -200,14 +200,14 @@ const samplerOperations = {
|
||||
makerToken: string,
|
||||
takerToken: string,
|
||||
takerFillAmount: BigNumber,
|
||||
plpRegistryAddress?: string | undefined,
|
||||
liquidityProviderRegistryAddress?: string | undefined,
|
||||
): BatchedOperation<BigNumber> {
|
||||
const getSellQuotes = samplerOperations.getSellQuotes(
|
||||
sources,
|
||||
makerToken,
|
||||
takerToken,
|
||||
[takerFillAmount],
|
||||
plpRegistryAddress,
|
||||
liquidityProviderRegistryAddress,
|
||||
);
|
||||
return {
|
||||
encodeCall: contract => {
|
||||
@ -262,7 +262,7 @@ const samplerOperations = {
|
||||
makerToken: string,
|
||||
takerToken: string,
|
||||
takerFillAmounts: BigNumber[],
|
||||
plpRegistryAddress?: string | undefined,
|
||||
liquidityProviderRegistryAddress?: string | undefined,
|
||||
): BatchedOperation<DexSample[][]> {
|
||||
const subOps = sources
|
||||
.map(source => {
|
||||
@ -289,14 +289,14 @@ const samplerOperations = {
|
||||
takerFillAmounts,
|
||||
);
|
||||
}
|
||||
} else if (source === ERC20BridgeSource.Plp) {
|
||||
if (plpRegistryAddress === undefined) {
|
||||
} else if (source === ERC20BridgeSource.LiquidityProvider) {
|
||||
if (liquidityProviderRegistryAddress === undefined) {
|
||||
throw new Error(
|
||||
'Cannot sample liquidity from a PLP liquidity pool, if a registry is not provided.',
|
||||
'Cannot sample liquidity from a LiquidityProvider liquidity pool, if a registry is not provided.',
|
||||
);
|
||||
}
|
||||
batchedOperation = samplerOperations.getPLPSellQuotes(
|
||||
plpRegistryAddress,
|
||||
batchedOperation = samplerOperations.getLiquidityProviderSellQuotes(
|
||||
liquidityProviderRegistryAddress,
|
||||
takerToken,
|
||||
makerToken,
|
||||
takerFillAmounts,
|
||||
@ -337,20 +337,20 @@ const samplerOperations = {
|
||||
makerToken: string,
|
||||
takerToken: string,
|
||||
makerFillAmounts: BigNumber[],
|
||||
plpRegistryAddress?: string | undefined,
|
||||
liquidityProviderRegistryAddress?: string | undefined,
|
||||
): BatchedOperation<DexSample[][]> {
|
||||
const subOps = sources.map(source => {
|
||||
if (source === ERC20BridgeSource.Eth2Dai) {
|
||||
return samplerOperations.getEth2DaiBuyQuotes(makerToken, takerToken, makerFillAmounts);
|
||||
} else if (source === ERC20BridgeSource.Uniswap) {
|
||||
return samplerOperations.getUniswapBuyQuotes(makerToken, takerToken, makerFillAmounts);
|
||||
} else if (source === ERC20BridgeSource.Plp) {
|
||||
if (plpRegistryAddress === undefined) {
|
||||
} else if (source === ERC20BridgeSource.LiquidityProvider) {
|
||||
if (liquidityProviderRegistryAddress === undefined) {
|
||||
throw new Error(
|
||||
'Cannot sample liquidity from a PLP liquidity pool, if a registry is not provided.',
|
||||
'Cannot sample liquidity from a LiquidityProvider liquidity pool, if a registry is not provided.',
|
||||
);
|
||||
}
|
||||
return samplerOperations.getPLPBuyQuotes(plpRegistryAddress, takerToken, makerToken, makerFillAmounts);
|
||||
return samplerOperations.getLiquidityProviderBuyQuotes(liquidityProviderRegistryAddress, takerToken, makerToken, makerFillAmounts);
|
||||
} else {
|
||||
throw new Error(`Unsupported buy sample source: ${source}`);
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ export enum ERC20BridgeSource {
|
||||
CurveUsdcDai = 'Curve_USDC_DAI',
|
||||
CurveUsdcDaiUsdt = 'Curve_USDC_DAI_USDT',
|
||||
CurveUsdcDaiUsdtTusd = 'Curve_USDC_DAI_USDT_TUSD',
|
||||
Plp = 'PLP',
|
||||
LiquidityProvider = 'LiquidityProvider',
|
||||
}
|
||||
|
||||
// Internal `fillData` field for `Fill` objects.
|
||||
@ -61,7 +61,7 @@ export enum FillFlags {
|
||||
SourceUniswap = 0x2,
|
||||
SourceEth2Dai = 0x4,
|
||||
SourceKyber = 0x8,
|
||||
SourcePlp = 0x10,
|
||||
SourceLiquidityPool = 0x10,
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -342,7 +342,7 @@ describe('DexSampler tests', () => {
|
||||
expect(quotes).to.deep.eq(expectedQuotes);
|
||||
});
|
||||
|
||||
describe('PLP Operations', () => {
|
||||
describe('LiquidityProvider Operations', () => {
|
||||
const xAsset = randomAddress();
|
||||
const yAsset = randomAddress();
|
||||
const zAsset = randomAddress();
|
||||
@ -392,7 +392,7 @@ describe('DexSampler tests', () => {
|
||||
expect(yzPool).to.eql(NULL_ADDRESS);
|
||||
expect(nullPool).to.eql(NULL_ADDRESS);
|
||||
});
|
||||
it('is able to sample DEX liquidity from PLP', async () => {
|
||||
it('is able to sample DEX liquidity from LiquidityProvider', async () => {
|
||||
const fakeLiquidityPool = await DummyLiquidityProviderContract.deployFrom0xArtifactAsync(
|
||||
erc20BridgeSamplerArtifacts.DummyLiquidityProvider,
|
||||
provider,
|
||||
@ -408,14 +408,14 @@ describe('DexSampler tests', () => {
|
||||
);
|
||||
const [buyQuotes, sellQuotes] = await dexOrderSampler.executeBatchAsync([
|
||||
DexOrderSampler.ops.getBuyQuotes(
|
||||
[ERC20BridgeSource.Plp],
|
||||
[ERC20BridgeSource.LiquidityProvider],
|
||||
xAsset,
|
||||
yAsset,
|
||||
[new BigNumber(10), new BigNumber(100)],
|
||||
registryContract.address,
|
||||
),
|
||||
DexOrderSampler.ops.getSellQuotes(
|
||||
[ERC20BridgeSource.Plp],
|
||||
[ERC20BridgeSource.LiquidityProvider],
|
||||
xAsset,
|
||||
yAsset,
|
||||
[new BigNumber(10), new BigNumber(100), new BigNumber(500)],
|
||||
@ -423,18 +423,18 @@ describe('DexSampler tests', () => {
|
||||
),
|
||||
]);
|
||||
expect(buyQuotes.length).to.eql(1);
|
||||
const plpBuyQuotes: DexSample[] = buyQuotes[0];
|
||||
expect(plpBuyQuotes.length).to.eql(2);
|
||||
for (const quote of plpBuyQuotes) {
|
||||
expect(quote.source).to.bignumber.eql(ERC20BridgeSource.Plp);
|
||||
const liquidityPoolBuyQuotes: DexSample[] = buyQuotes[0];
|
||||
expect(liquidityPoolBuyQuotes.length).to.eql(2);
|
||||
for (const quote of liquidityPoolBuyQuotes) {
|
||||
expect(quote.source).to.bignumber.eql(ERC20BridgeSource.LiquidityProvider);
|
||||
expect(quote.input.plus(1)).to.bignumber.eql(quote.output);
|
||||
}
|
||||
|
||||
expect(sellQuotes.length).to.eql(1);
|
||||
const plpSellQuotes: DexSample[] = sellQuotes[0];
|
||||
expect(plpSellQuotes.length).to.eql(3);
|
||||
for (const quote of plpSellQuotes) {
|
||||
expect(quote.source).to.bignumber.eql(ERC20BridgeSource.Plp);
|
||||
const iquidityPoolSellQuotes: DexSample[] = sellQuotes[0];
|
||||
expect(iquidityPoolSellQuotes.length).to.eql(3);
|
||||
for (const quote of iquidityPoolSellQuotes) {
|
||||
expect(quote.source).to.bignumber.eql(ERC20BridgeSource.LiquidityProvider);
|
||||
expect(quote.input.minus(1)).to.bignumber.eql(quote.output);
|
||||
}
|
||||
});
|
||||
|
@ -141,7 +141,7 @@ describe('MarketOperationUtils tests', () => {
|
||||
makerToken: string,
|
||||
takerToken: string,
|
||||
fillAmounts: BigNumber[],
|
||||
plpRegistryAddress?: string | undefined,
|
||||
liquidityProviderAddress?: string | undefined,
|
||||
) => DexSample[][];
|
||||
|
||||
function createGetMultipleSellQuotesOperationFromRates(rates: RatesBySource): GetMultipleQuotesOperation {
|
||||
@ -156,26 +156,26 @@ describe('MarketOperationUtils tests', () => {
|
||||
};
|
||||
}
|
||||
|
||||
function callTradeOperationAndRetainPLPParams(
|
||||
function callTradeOperationAndRetainLiquidityProviderParams(
|
||||
tradeOperation: (rates: RatesBySource) => GetMultipleQuotesOperation,
|
||||
rates: RatesBySource,
|
||||
): [{ sources: ERC20BridgeSource[]; plpRegistryAddress?: string }, GetMultipleQuotesOperation] {
|
||||
const plpParams: { sources: ERC20BridgeSource[]; plpRegistryAddress?: string } = {
|
||||
): [{ sources: ERC20BridgeSource[]; liquidityProviderAddress?: string }, GetMultipleQuotesOperation] {
|
||||
const liquidityPoolParams: { sources: ERC20BridgeSource[]; liquidityProviderAddress?: string } = {
|
||||
sources: [],
|
||||
plpRegistryAddress: undefined,
|
||||
liquidityProviderAddress: undefined,
|
||||
};
|
||||
const fn = (
|
||||
sources: ERC20BridgeSource[],
|
||||
makerToken: string,
|
||||
takerToken: string,
|
||||
fillAmounts: BigNumber[],
|
||||
plpRegistryAddress: string | undefined,
|
||||
liquidityProviderAddress: string | undefined,
|
||||
) => {
|
||||
plpParams.plpRegistryAddress = plpRegistryAddress;
|
||||
plpParams.sources = sources;
|
||||
return tradeOperation(rates)(sources, makerToken, takerToken, fillAmounts, plpRegistryAddress);
|
||||
liquidityPoolParams.liquidityProviderAddress = liquidityProviderAddress;
|
||||
liquidityPoolParams.sources = sources;
|
||||
return tradeOperation(rates)(sources, makerToken, takerToken, fillAmounts, liquidityProviderAddress);
|
||||
};
|
||||
return [plpParams, fn];
|
||||
return [liquidityPoolParams, fn];
|
||||
}
|
||||
|
||||
function createGetMultipleBuyQuotesOperationFromRates(rates: RatesBySource): GetMultipleQuotesOperation {
|
||||
@ -195,7 +195,7 @@ describe('MarketOperationUtils tests', () => {
|
||||
makerToken: string,
|
||||
takerToken: string,
|
||||
fillAmounts: BigNumber[],
|
||||
plpRegistryAddress?: string | undefined,
|
||||
liquidityProviderAddress?: string | undefined,
|
||||
) => BigNumber;
|
||||
|
||||
type GetLiquidityProviderFromRegistryOperation = (
|
||||
@ -260,7 +260,7 @@ describe('MarketOperationUtils tests', () => {
|
||||
[ERC20BridgeSource.CurveUsdcDai]: _.times(NUM_SAMPLES, () => 0),
|
||||
[ERC20BridgeSource.CurveUsdcDaiUsdt]: _.times(NUM_SAMPLES, () => 0),
|
||||
[ERC20BridgeSource.CurveUsdcDaiUsdtTusd]: _.times(NUM_SAMPLES, () => 0),
|
||||
[ERC20BridgeSource.Plp]: _.times(NUM_SAMPLES, () => 0),
|
||||
[ERC20BridgeSource.LiquidityProvider]: _.times(NUM_SAMPLES, () => 0),
|
||||
};
|
||||
|
||||
function findSourceWithMaxOutput(rates: RatesBySource): ERC20BridgeSource {
|
||||
@ -375,7 +375,7 @@ describe('MarketOperationUtils tests', () => {
|
||||
});
|
||||
|
||||
it('polls the liquidity provider when the registry is provided in the arguments', async () => {
|
||||
const [args, fn] = callTradeOperationAndRetainPLPParams(
|
||||
const [args, fn] = callTradeOperationAndRetainLiquidityProviderParams(
|
||||
createGetMultipleSellQuotesOperationFromRates,
|
||||
DEFAULT_RATES,
|
||||
);
|
||||
@ -393,8 +393,8 @@ describe('MarketOperationUtils tests', () => {
|
||||
...DEFAULT_OPTS,
|
||||
excludedSources: [],
|
||||
});
|
||||
expect(args.sources.sort()).to.deep.eq(SELL_SOURCES.concat([ERC20BridgeSource.Plp]).sort());
|
||||
expect(args.plpRegistryAddress).to.eql(registryAddress);
|
||||
expect(args.sources.sort()).to.deep.eq(SELL_SOURCES.concat([ERC20BridgeSource.LiquidityProvider]).sort());
|
||||
expect(args.liquidityProviderAddress).to.eql(registryAddress);
|
||||
});
|
||||
|
||||
it('does not poll DEXes in `excludedSources`', async () => {
|
||||
@ -669,7 +669,7 @@ describe('MarketOperationUtils tests', () => {
|
||||
});
|
||||
|
||||
it('polls the liquidity provider when the registry is provided in the arguments', async () => {
|
||||
const [args, fn] = callTradeOperationAndRetainPLPParams(
|
||||
const [args, fn] = callTradeOperationAndRetainLiquidityProviderParams(
|
||||
createGetMultipleBuyQuotesOperationFromRates,
|
||||
DEFAULT_RATES,
|
||||
);
|
||||
@ -687,8 +687,8 @@ describe('MarketOperationUtils tests', () => {
|
||||
...DEFAULT_OPTS,
|
||||
excludedSources: [],
|
||||
});
|
||||
expect(args.sources.sort()).to.deep.eq(BUY_SOURCES.concat([ERC20BridgeSource.Plp]).sort());
|
||||
expect(args.plpRegistryAddress).to.eql(registryAddress);
|
||||
expect(args.sources.sort()).to.deep.eq(BUY_SOURCES.concat([ERC20BridgeSource.LiquidityProvider]).sort());
|
||||
expect(args.liquidityProviderAddress).to.eql(registryAddress);
|
||||
});
|
||||
|
||||
it('does not poll DEXes in `excludedSources`', async () => {
|
||||
@ -871,17 +871,17 @@ describe('MarketOperationUtils tests', () => {
|
||||
expect(orderSources).to.deep.eq(expectedSources);
|
||||
});
|
||||
|
||||
it('is able to create a order from PLP', async () => {
|
||||
it('is able to create a order from LiquidityProvider', async () => {
|
||||
const registryAddress = randomAddress();
|
||||
const liquidityPoolAddress = randomAddress();
|
||||
const xAsset = randomAddress();
|
||||
const yAsset = randomAddress();
|
||||
const toSell = Web3Wrapper.toBaseUnitAmount(10, 18);
|
||||
|
||||
const [getSellQuiotesParams, getSellQuotesFn] = callTradeOperationAndRetainPLPParams(
|
||||
const [getSellQuiotesParams, getSellQuotesFn] = callTradeOperationAndRetainLiquidityProviderParams(
|
||||
createGetMultipleSellQuotesOperationFromRates,
|
||||
{
|
||||
[ERC20BridgeSource.Plp]: createDecreasingRates(5),
|
||||
[ERC20BridgeSource.LiquidityProvider]: createDecreasingRates(5),
|
||||
},
|
||||
);
|
||||
const [
|
||||
@ -920,8 +920,8 @@ describe('MarketOperationUtils tests', () => {
|
||||
expect(decodedAssetData.assetProxyId).to.eql(AssetProxyId.ERC20Bridge);
|
||||
expect(decodedAssetData.bridgeAddress).to.eql(liquidityPoolAddress);
|
||||
expect(result[0].takerAssetAmount).to.bignumber.eql(toSell);
|
||||
expect(getSellQuiotesParams.sources).contains(ERC20BridgeSource.Plp);
|
||||
expect(getSellQuiotesParams.plpRegistryAddress).is.eql(registryAddress);
|
||||
expect(getSellQuiotesParams.sources).contains(ERC20BridgeSource.LiquidityProvider);
|
||||
expect(getSellQuiotesParams.liquidityProviderAddress).is.eql(registryAddress);
|
||||
expect(getLiquidityProviderParams.registryAddress).is.eql(registryAddress);
|
||||
expect(getLiquidityProviderParams.makerToken).is.eql(xAsset);
|
||||
expect(getLiquidityProviderParams.takerToken).is.eql(yAsset);
|
||||
|
Loading…
x
Reference in New Issue
Block a user