Remove chainId when using connect from asset-swapper
This commit is contained in:
parent
8a8ec79c6c
commit
595358fa69
@ -15,7 +15,6 @@ import { assert } from '../utils/assert';
|
|||||||
|
|
||||||
export class StandardRelayerAPIOrderProvider implements OrderProvider {
|
export class StandardRelayerAPIOrderProvider implements OrderProvider {
|
||||||
public readonly apiUrl: string;
|
public readonly apiUrl: string;
|
||||||
public readonly chainId: number;
|
|
||||||
private readonly _sraClient: HttpClient;
|
private readonly _sraClient: HttpClient;
|
||||||
/**
|
/**
|
||||||
* Given an array of APIOrder objects from a standard relayer api, return an array
|
* Given an array of APIOrder objects from a standard relayer api, return an array
|
||||||
@ -49,14 +48,11 @@ export class StandardRelayerAPIOrderProvider implements OrderProvider {
|
|||||||
/**
|
/**
|
||||||
* Instantiates a new StandardRelayerAPIOrderProvider instance
|
* Instantiates a new StandardRelayerAPIOrderProvider instance
|
||||||
* @param apiUrl The standard relayer API base HTTP url you would like to source orders from.
|
* @param apiUrl The standard relayer API base HTTP url you would like to source orders from.
|
||||||
* @param chainId The ethereum chain id.
|
|
||||||
* @return An instance of StandardRelayerAPIOrderProvider
|
* @return An instance of StandardRelayerAPIOrderProvider
|
||||||
*/
|
*/
|
||||||
constructor(apiUrl: string, chainId: number) {
|
constructor(apiUrl: string) {
|
||||||
assert.isWebUri('apiUrl', apiUrl);
|
assert.isWebUri('apiUrl', apiUrl);
|
||||||
assert.isNumber('chainId', chainId);
|
|
||||||
this.apiUrl = apiUrl;
|
this.apiUrl = apiUrl;
|
||||||
this.chainId = chainId;
|
|
||||||
this._sraClient = new HttpClient(apiUrl);
|
this._sraClient = new HttpClient(apiUrl);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@ -68,10 +64,9 @@ export class StandardRelayerAPIOrderProvider implements OrderProvider {
|
|||||||
assert.isValidOrderProviderRequest('orderProviderRequest', orderProviderRequest);
|
assert.isValidOrderProviderRequest('orderProviderRequest', orderProviderRequest);
|
||||||
const { makerAssetData, takerAssetData } = orderProviderRequest;
|
const { makerAssetData, takerAssetData } = orderProviderRequest;
|
||||||
const orderbookRequest = { baseAssetData: makerAssetData, quoteAssetData: takerAssetData };
|
const orderbookRequest = { baseAssetData: makerAssetData, quoteAssetData: takerAssetData };
|
||||||
const requestOpts = { chainId: this.chainId };
|
|
||||||
let orderbook: OrderbookResponse;
|
let orderbook: OrderbookResponse;
|
||||||
try {
|
try {
|
||||||
orderbook = await this._sraClient.getOrderbookAsync(orderbookRequest, requestOpts);
|
orderbook = await this._sraClient.getOrderbookAsync(orderbookRequest);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
throw new Error(AssetBuyerError.StandardRelayerApiError);
|
throw new Error(AssetBuyerError.StandardRelayerApiError);
|
||||||
}
|
}
|
||||||
@ -91,7 +86,7 @@ export class StandardRelayerAPIOrderProvider implements OrderProvider {
|
|||||||
public async getAvailableMakerAssetDatasAsync(takerAssetData: string): Promise<string[]> {
|
public async getAvailableMakerAssetDatasAsync(takerAssetData: string): Promise<string[]> {
|
||||||
// Return a maximum of 1000 asset datas
|
// Return a maximum of 1000 asset datas
|
||||||
const maxPerPage = 1000;
|
const maxPerPage = 1000;
|
||||||
const requestOpts = { chainId: this.chainId, perPage: maxPerPage };
|
const requestOpts = { perPage: maxPerPage };
|
||||||
const assetPairsRequest = { assetDataA: takerAssetData };
|
const assetPairsRequest = { assetDataA: takerAssetData };
|
||||||
const fullRequest = {
|
const fullRequest = {
|
||||||
...requestOpts,
|
...requestOpts,
|
||||||
|
@ -69,7 +69,6 @@ export class SwapQuoter {
|
|||||||
httpEndpoint: sraApiUrl,
|
httpEndpoint: sraApiUrl,
|
||||||
pollingIntervalMs:
|
pollingIntervalMs:
|
||||||
options.orderRefreshIntervalMs || constants.DEFAULT_SWAP_QUOTER_OPTS.orderRefreshIntervalMs,
|
options.orderRefreshIntervalMs || constants.DEFAULT_SWAP_QUOTER_OPTS.orderRefreshIntervalMs,
|
||||||
chainId: options.chainId || constants.DEFAULT_SWAP_QUOTER_OPTS.chainId,
|
|
||||||
perPage: options.perPage || constants.DEFAULT_PER_PAGE,
|
perPage: options.perPage || constants.DEFAULT_PER_PAGE,
|
||||||
});
|
});
|
||||||
const swapQuoter = new SwapQuoter(provider, orderbook, options);
|
const swapQuoter = new SwapQuoter(provider, orderbook, options);
|
||||||
@ -97,7 +96,6 @@ export class SwapQuoter {
|
|||||||
const orderbook = Orderbook.getOrderbookForWebsocketProvider({
|
const orderbook = Orderbook.getOrderbookForWebsocketProvider({
|
||||||
httpEndpoint: sraApiUrl,
|
httpEndpoint: sraApiUrl,
|
||||||
websocketEndpoint: sraWebsocketAPIUrl,
|
websocketEndpoint: sraWebsocketAPIUrl,
|
||||||
chainId: options.chainId,
|
|
||||||
});
|
});
|
||||||
const swapQuoter = new SwapQuoter(provider, orderbook, options);
|
const swapQuoter = new SwapQuoter(provider, orderbook, options);
|
||||||
return swapQuoter;
|
return swapQuoter;
|
||||||
|
@ -5,12 +5,10 @@ import { MethodAbi } from 'ethereum-types';
|
|||||||
/**
|
/**
|
||||||
* makerAssetData: The assetData representing the desired makerAsset.
|
* makerAssetData: The assetData representing the desired makerAsset.
|
||||||
* takerAssetData: The assetData representing the desired takerAsset.
|
* takerAssetData: The assetData representing the desired takerAsset.
|
||||||
* chainId: The chainId that the desired orders should be for.
|
|
||||||
*/
|
*/
|
||||||
export interface OrderProviderRequest {
|
export interface OrderProviderRequest {
|
||||||
makerAssetData: string;
|
makerAssetData: string;
|
||||||
takerAssetData: string;
|
takerAssetData: string;
|
||||||
chainId: number;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -111,14 +109,14 @@ export interface ForwarderSmartContractParamsBase {
|
|||||||
|
|
||||||
export interface ForwarderMarketBuySmartContractParams
|
export interface ForwarderMarketBuySmartContractParams
|
||||||
extends ExchangeMarketBuySmartContractParams,
|
extends ExchangeMarketBuySmartContractParams,
|
||||||
ForwarderSmartContractParamsBase {}
|
ForwarderSmartContractParamsBase { }
|
||||||
|
|
||||||
// Temporary fix until typescript is upgraded to ^3.5
|
// Temporary fix until typescript is upgraded to ^3.5
|
||||||
type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
|
type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
|
||||||
|
|
||||||
export interface ForwarderMarketSellSmartContractParams
|
export interface ForwarderMarketSellSmartContractParams
|
||||||
extends Omit<ExchangeMarketSellSmartContractParams, 'takerAssetFillAmount'>,
|
extends Omit<ExchangeMarketSellSmartContractParams, 'takerAssetFillAmount'>,
|
||||||
ForwarderSmartContractParamsBase {}
|
ForwarderSmartContractParamsBase { }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents all the parameters to interface with 0x forwarder extension contract marketSell and marketBuy functions.
|
* Represents all the parameters to interface with 0x forwarder extension contract marketSell and marketBuy functions.
|
||||||
@ -157,7 +155,7 @@ export interface SwapQuoteConsumerOpts {
|
|||||||
/**
|
/**
|
||||||
* Represents the options provided to a generic SwapQuoteConsumer
|
* Represents the options provided to a generic SwapQuoteConsumer
|
||||||
*/
|
*/
|
||||||
export interface SwapQuoteGetOutputOptsBase {}
|
export interface SwapQuoteGetOutputOptsBase { }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* takerAddress: The address to perform the buy. Defaults to the first available address from the provider.
|
* takerAddress: The address to perform the buy. Defaults to the first available address from the provider.
|
||||||
@ -196,12 +194,12 @@ export interface SwapQuoteGetOutputOpts extends ForwarderSwapQuoteGetOutputOpts
|
|||||||
useExtensionContract: ExtensionContractType;
|
useExtensionContract: ExtensionContractType;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ForwarderSwapQuoteExecutionOpts extends ForwarderSwapQuoteGetOutputOpts, SwapQuoteExecutionOptsBase {}
|
export interface ForwarderSwapQuoteExecutionOpts extends ForwarderSwapQuoteGetOutputOpts, SwapQuoteExecutionOptsBase { }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents the options for executing a swap quote with SwapQuoteConsumer
|
* Represents the options for executing a swap quote with SwapQuoteConsumer
|
||||||
*/
|
*/
|
||||||
export interface SwapQuoteExecutionOpts extends SwapQuoteGetOutputOpts, ForwarderSwapQuoteExecutionOpts {}
|
export interface SwapQuoteExecutionOpts extends SwapQuoteGetOutputOpts, ForwarderSwapQuoteExecutionOpts { }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* takerAssetData: String that represents a specific taker asset (for more info: https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md).
|
* takerAssetData: String that represents a specific taker asset (for more info: https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md).
|
||||||
@ -242,9 +240,9 @@ export interface SwapQuoteWithAffiliateFeeBase {
|
|||||||
feePercentage: number;
|
feePercentage: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface MarketSellSwapQuoteWithAffiliateFee extends SwapQuoteWithAffiliateFeeBase, MarketSellSwapQuote {}
|
export interface MarketSellSwapQuoteWithAffiliateFee extends SwapQuoteWithAffiliateFeeBase, MarketSellSwapQuote { }
|
||||||
|
|
||||||
export interface MarketBuySwapQuoteWithAffiliateFee extends SwapQuoteWithAffiliateFeeBase, MarketBuySwapQuote {}
|
export interface MarketBuySwapQuoteWithAffiliateFee extends SwapQuoteWithAffiliateFeeBase, MarketBuySwapQuote { }
|
||||||
|
|
||||||
export type SwapQuoteWithAffiliateFee = MarketBuySwapQuoteWithAffiliateFee | MarketSellSwapQuoteWithAffiliateFee;
|
export type SwapQuoteWithAffiliateFee = MarketBuySwapQuoteWithAffiliateFee | MarketSellSwapQuoteWithAffiliateFee;
|
||||||
|
|
||||||
|
@ -33,12 +33,14 @@ describe('swapQuoteCalculator', () => {
|
|||||||
// generate one order for fees
|
// generate one order for fees
|
||||||
// the fee order has a rate of 1 ZRX / WETH with no taker fee and has 100 ZRX left to fill (completely fillable)
|
// the fee order has a rate of 1 ZRX / WETH with no taker fee and has 100 ZRX left to fill (completely fillable)
|
||||||
firstOrder = orderFactory.createSignedOrderFromPartial({
|
firstOrder = orderFactory.createSignedOrderFromPartial({
|
||||||
|
chainId: 42,
|
||||||
makerAssetAmount: new BigNumber(400),
|
makerAssetAmount: new BigNumber(400),
|
||||||
takerAssetAmount: new BigNumber(100),
|
takerAssetAmount: new BigNumber(100),
|
||||||
takerFee: new BigNumber(200),
|
takerFee: new BigNumber(200),
|
||||||
});
|
});
|
||||||
firstRemainingFillAmount = new BigNumber(200);
|
firstRemainingFillAmount = new BigNumber(200);
|
||||||
secondOrder = orderFactory.createSignedOrderFromPartial({
|
secondOrder = orderFactory.createSignedOrderFromPartial({
|
||||||
|
chainId: 42,
|
||||||
makerAssetAmount: new BigNumber(200),
|
makerAssetAmount: new BigNumber(200),
|
||||||
takerAssetAmount: new BigNumber(100),
|
takerAssetAmount: new BigNumber(100),
|
||||||
takerFee: new BigNumber(100),
|
takerFee: new BigNumber(100),
|
||||||
@ -49,6 +51,7 @@ describe('swapQuoteCalculator', () => {
|
|||||||
remainingFillableMakerAssetAmounts: [firstRemainingFillAmount, secondRemainingFillAmount],
|
remainingFillableMakerAssetAmounts: [firstRemainingFillAmount, secondRemainingFillAmount],
|
||||||
};
|
};
|
||||||
const smallFeeOrder = orderFactory.createSignedOrderFromPartial({
|
const smallFeeOrder = orderFactory.createSignedOrderFromPartial({
|
||||||
|
chainId: 42,
|
||||||
makerAssetAmount: new BigNumber(100),
|
makerAssetAmount: new BigNumber(100),
|
||||||
takerAssetAmount: new BigNumber(100),
|
takerAssetAmount: new BigNumber(100),
|
||||||
});
|
});
|
||||||
@ -57,6 +60,7 @@ describe('swapQuoteCalculator', () => {
|
|||||||
remainingFillableMakerAssetAmounts: [smallFeeOrder.makerAssetAmount],
|
remainingFillableMakerAssetAmounts: [smallFeeOrder.makerAssetAmount],
|
||||||
};
|
};
|
||||||
const largeFeeOrder = orderFactory.createSignedOrderFromPartial({
|
const largeFeeOrder = orderFactory.createSignedOrderFromPartial({
|
||||||
|
chainId: 42,
|
||||||
makerAssetAmount: new BigNumber(113),
|
makerAssetAmount: new BigNumber(113),
|
||||||
takerAssetAmount: new BigNumber(200),
|
takerAssetAmount: new BigNumber(200),
|
||||||
takerFee: new BigNumber(11),
|
takerFee: new BigNumber(11),
|
||||||
@ -132,6 +136,7 @@ describe('swapQuoteCalculator', () => {
|
|||||||
});
|
});
|
||||||
it('should throw if not enough taker asset liquidity (completely fillable order)', () => {
|
it('should throw if not enough taker asset liquidity (completely fillable order)', () => {
|
||||||
const completelyFillableOrder = orderFactory.createSignedOrderFromPartial({
|
const completelyFillableOrder = orderFactory.createSignedOrderFromPartial({
|
||||||
|
chainId: 42,
|
||||||
makerAssetAmount: new BigNumber(123),
|
makerAssetAmount: new BigNumber(123),
|
||||||
takerAssetAmount: new BigNumber(80),
|
takerAssetAmount: new BigNumber(80),
|
||||||
takerFee: new BigNumber(200),
|
takerFee: new BigNumber(200),
|
||||||
@ -154,6 +159,7 @@ describe('swapQuoteCalculator', () => {
|
|||||||
});
|
});
|
||||||
it('should throw with 1 amount available if no slippage', () => {
|
it('should throw with 1 amount available if no slippage', () => {
|
||||||
const smallOrder = orderFactory.createSignedOrderFromPartial({
|
const smallOrder = orderFactory.createSignedOrderFromPartial({
|
||||||
|
chainId: 42,
|
||||||
makerAssetAmount: new BigNumber(1),
|
makerAssetAmount: new BigNumber(1),
|
||||||
takerAssetAmount: new BigNumber(1),
|
takerAssetAmount: new BigNumber(1),
|
||||||
takerFee: new BigNumber(0),
|
takerFee: new BigNumber(0),
|
||||||
@ -172,6 +178,7 @@ describe('swapQuoteCalculator', () => {
|
|||||||
});
|
});
|
||||||
it('should throw with 0 available to fill if amount rounds to 0', () => {
|
it('should throw with 0 available to fill if amount rounds to 0', () => {
|
||||||
const smallOrder = orderFactory.createSignedOrderFromPartial({
|
const smallOrder = orderFactory.createSignedOrderFromPartial({
|
||||||
|
chainId: 42,
|
||||||
makerAssetAmount: new BigNumber(1),
|
makerAssetAmount: new BigNumber(1),
|
||||||
takerAssetAmount: new BigNumber(1),
|
takerAssetAmount: new BigNumber(1),
|
||||||
takerFee: new BigNumber(0),
|
takerFee: new BigNumber(0),
|
||||||
@ -391,12 +398,14 @@ describe('swapQuoteCalculator', () => {
|
|||||||
// generate one order for fees
|
// generate one order for fees
|
||||||
// the fee order has a rate of 1 ZRX / WETH with no taker fee and has 100 ZRX left to fill (completely fillable)
|
// the fee order has a rate of 1 ZRX / WETH with no taker fee and has 100 ZRX left to fill (completely fillable)
|
||||||
firstOrder = orderFactory.createSignedOrderFromPartial({
|
firstOrder = orderFactory.createSignedOrderFromPartial({
|
||||||
|
chainId: 42,
|
||||||
makerAssetAmount: new BigNumber(400),
|
makerAssetAmount: new BigNumber(400),
|
||||||
takerAssetAmount: new BigNumber(100),
|
takerAssetAmount: new BigNumber(100),
|
||||||
takerFee: new BigNumber(200),
|
takerFee: new BigNumber(200),
|
||||||
});
|
});
|
||||||
firstRemainingFillAmount = new BigNumber(200);
|
firstRemainingFillAmount = new BigNumber(200);
|
||||||
secondOrder = orderFactory.createSignedOrderFromPartial({
|
secondOrder = orderFactory.createSignedOrderFromPartial({
|
||||||
|
chainId: 42,
|
||||||
makerAssetAmount: new BigNumber(200),
|
makerAssetAmount: new BigNumber(200),
|
||||||
takerAssetAmount: new BigNumber(100),
|
takerAssetAmount: new BigNumber(100),
|
||||||
takerFee: new BigNumber(100),
|
takerFee: new BigNumber(100),
|
||||||
@ -407,6 +416,7 @@ describe('swapQuoteCalculator', () => {
|
|||||||
remainingFillableMakerAssetAmounts: [firstRemainingFillAmount, secondRemainingFillAmount],
|
remainingFillableMakerAssetAmounts: [firstRemainingFillAmount, secondRemainingFillAmount],
|
||||||
};
|
};
|
||||||
const smallFeeOrder = orderFactory.createSignedOrderFromPartial({
|
const smallFeeOrder = orderFactory.createSignedOrderFromPartial({
|
||||||
|
chainId: 42,
|
||||||
makerAssetAmount: new BigNumber(100),
|
makerAssetAmount: new BigNumber(100),
|
||||||
takerAssetAmount: new BigNumber(100),
|
takerAssetAmount: new BigNumber(100),
|
||||||
});
|
});
|
||||||
@ -415,6 +425,7 @@ describe('swapQuoteCalculator', () => {
|
|||||||
remainingFillableMakerAssetAmounts: [smallFeeOrder.makerAssetAmount],
|
remainingFillableMakerAssetAmounts: [smallFeeOrder.makerAssetAmount],
|
||||||
};
|
};
|
||||||
const largeFeeOrder = orderFactory.createSignedOrderFromPartial({
|
const largeFeeOrder = orderFactory.createSignedOrderFromPartial({
|
||||||
|
chainId: 42,
|
||||||
makerAssetAmount: new BigNumber(113),
|
makerAssetAmount: new BigNumber(113),
|
||||||
takerAssetAmount: new BigNumber(200),
|
takerAssetAmount: new BigNumber(200),
|
||||||
takerFee: new BigNumber(11),
|
takerFee: new BigNumber(11),
|
||||||
@ -490,6 +501,7 @@ describe('swapQuoteCalculator', () => {
|
|||||||
});
|
});
|
||||||
it('should throw if not enough maker asset liquidity (completely fillable order)', () => {
|
it('should throw if not enough maker asset liquidity (completely fillable order)', () => {
|
||||||
const completelyFillableOrder = orderFactory.createSignedOrderFromPartial({
|
const completelyFillableOrder = orderFactory.createSignedOrderFromPartial({
|
||||||
|
chainId: 42,
|
||||||
makerAssetAmount: new BigNumber(123),
|
makerAssetAmount: new BigNumber(123),
|
||||||
takerAssetAmount: new BigNumber(100),
|
takerAssetAmount: new BigNumber(100),
|
||||||
takerFee: new BigNumber(200),
|
takerFee: new BigNumber(200),
|
||||||
@ -512,6 +524,7 @@ describe('swapQuoteCalculator', () => {
|
|||||||
});
|
});
|
||||||
it('should throw with 1 amount available if no slippage', () => {
|
it('should throw with 1 amount available if no slippage', () => {
|
||||||
const smallOrder = orderFactory.createSignedOrderFromPartial({
|
const smallOrder = orderFactory.createSignedOrderFromPartial({
|
||||||
|
chainId: 42,
|
||||||
makerAssetAmount: new BigNumber(1),
|
makerAssetAmount: new BigNumber(1),
|
||||||
takerAssetAmount: new BigNumber(1),
|
takerAssetAmount: new BigNumber(1),
|
||||||
takerFee: new BigNumber(0),
|
takerFee: new BigNumber(0),
|
||||||
@ -530,6 +543,7 @@ describe('swapQuoteCalculator', () => {
|
|||||||
});
|
});
|
||||||
it('should throw with 0 available to fill if amount rounds to 0', () => {
|
it('should throw with 0 available to fill if amount rounds to 0', () => {
|
||||||
const smallOrder = orderFactory.createSignedOrderFromPartial({
|
const smallOrder = orderFactory.createSignedOrderFromPartial({
|
||||||
|
chainId: 42,
|
||||||
makerAssetAmount: new BigNumber(1),
|
makerAssetAmount: new BigNumber(1),
|
||||||
takerAssetAmount: new BigNumber(1),
|
takerAssetAmount: new BigNumber(1),
|
||||||
takerFee: new BigNumber(0),
|
takerFee: new BigNumber(0),
|
||||||
|
@ -155,10 +155,12 @@ describe('SwapQuoter', () => {
|
|||||||
const sellTwoTokensFor1Weth: SignedOrder = orderFactory.createSignedOrderFromPartial({
|
const sellTwoTokensFor1Weth: SignedOrder = orderFactory.createSignedOrderFromPartial({
|
||||||
makerAssetAmount: baseUnitAmount(2),
|
makerAssetAmount: baseUnitAmount(2),
|
||||||
takerAssetAmount: baseUnitAmount(1, WETH_DECIMALS),
|
takerAssetAmount: baseUnitAmount(1, WETH_DECIMALS),
|
||||||
|
chainId: 42,
|
||||||
});
|
});
|
||||||
const sellTenTokensFor10Weth: SignedOrder = orderFactory.createSignedOrderFromPartial({
|
const sellTenTokensFor10Weth: SignedOrder = orderFactory.createSignedOrderFromPartial({
|
||||||
makerAssetAmount: baseUnitAmount(10),
|
makerAssetAmount: baseUnitAmount(10),
|
||||||
takerAssetAmount: baseUnitAmount(10, WETH_DECIMALS),
|
takerAssetAmount: baseUnitAmount(10, WETH_DECIMALS),
|
||||||
|
chainId: 42,
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
@ -46,6 +46,7 @@ export const getPartialSignedOrdersWithNoFees = (
|
|||||||
makerAssetData,
|
makerAssetData,
|
||||||
takerAssetAmount: fillableAmount,
|
takerAssetAmount: fillableAmount,
|
||||||
takerAssetData,
|
takerAssetData,
|
||||||
|
chainId: 42,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@ -69,6 +70,7 @@ export const getPartialSignedOrdersWithFees = (
|
|||||||
orderFactory.createSignedOrderFromPartial({
|
orderFactory.createSignedOrderFromPartial({
|
||||||
...order,
|
...order,
|
||||||
...{ takerFee: takerFees[index] },
|
...{ takerFee: takerFees[index] },
|
||||||
|
chainId: 42,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -24,19 +24,23 @@ const baseUnitAmount = (unitAmount: number, decimals = TOKEN_DECIMALS): BigNumbe
|
|||||||
describe('utils', () => {
|
describe('utils', () => {
|
||||||
// orders
|
// orders
|
||||||
const sellTwoTokensFor1Weth: SignedOrder = orderFactory.createSignedOrderFromPartial({
|
const sellTwoTokensFor1Weth: SignedOrder = orderFactory.createSignedOrderFromPartial({
|
||||||
|
chainId: 42,
|
||||||
makerAssetAmount: baseUnitAmount(2),
|
makerAssetAmount: baseUnitAmount(2),
|
||||||
takerAssetAmount: baseUnitAmount(1, WETH_DECIMALS),
|
takerAssetAmount: baseUnitAmount(1, WETH_DECIMALS),
|
||||||
});
|
});
|
||||||
const sellTenTokensFor10Weth: SignedOrder = orderFactory.createSignedOrderFromPartial({
|
const sellTenTokensFor10Weth: SignedOrder = orderFactory.createSignedOrderFromPartial({
|
||||||
|
chainId: 42,
|
||||||
makerAssetAmount: baseUnitAmount(10),
|
makerAssetAmount: baseUnitAmount(10),
|
||||||
takerAssetAmount: baseUnitAmount(10, WETH_DECIMALS),
|
takerAssetAmount: baseUnitAmount(10, WETH_DECIMALS),
|
||||||
});
|
});
|
||||||
const sellTwoTokensFor1WethWithTwoTokenFee: SignedOrder = orderFactory.createSignedOrderFromPartial({
|
const sellTwoTokensFor1WethWithTwoTokenFee: SignedOrder = orderFactory.createSignedOrderFromPartial({
|
||||||
|
chainId: 42,
|
||||||
makerAssetAmount: baseUnitAmount(2),
|
makerAssetAmount: baseUnitAmount(2),
|
||||||
takerAssetAmount: baseUnitAmount(1, WETH_DECIMALS),
|
takerAssetAmount: baseUnitAmount(1, WETH_DECIMALS),
|
||||||
takerFee: baseUnitAmount(2),
|
takerFee: baseUnitAmount(2),
|
||||||
});
|
});
|
||||||
const sellTenTokensFor1WethWithFourTokenFee: SignedOrder = orderFactory.createSignedOrderFromPartial({
|
const sellTenTokensFor1WethWithFourTokenFee: SignedOrder = orderFactory.createSignedOrderFromPartial({
|
||||||
|
chainId: 42,
|
||||||
makerAssetAmount: baseUnitAmount(2),
|
makerAssetAmount: baseUnitAmount(2),
|
||||||
takerAssetAmount: baseUnitAmount(1, WETH_DECIMALS),
|
takerAssetAmount: baseUnitAmount(1, WETH_DECIMALS),
|
||||||
takerFee: baseUnitAmount(4),
|
takerFee: baseUnitAmount(4),
|
||||||
|
@ -36,7 +36,6 @@ import * as relayerApiOrdersChannelSubscribeSchema from '../schemas/relayer_api_
|
|||||||
import * as relayerApiOrdersChannelUpdateSchema from '../schemas/relayer_api_orders_channel_update_response_schema.json';
|
import * as relayerApiOrdersChannelUpdateSchema from '../schemas/relayer_api_orders_channel_update_response_schema.json';
|
||||||
import * as relayerApiOrdersResponseSchema from '../schemas/relayer_api_orders_response_schema.json';
|
import * as relayerApiOrdersResponseSchema from '../schemas/relayer_api_orders_response_schema.json';
|
||||||
import * as relayerApiOrdersSchema from '../schemas/relayer_api_orders_schema.json';
|
import * as relayerApiOrdersSchema from '../schemas/relayer_api_orders_schema.json';
|
||||||
import * as requestOptsSchema from '../schemas/request_opts_schema.json';
|
|
||||||
import * as signedOrderSchema from '../schemas/signed_order_schema.json';
|
import * as signedOrderSchema from '../schemas/signed_order_schema.json';
|
||||||
import * as signedOrdersSchema from '../schemas/signed_orders_schema.json';
|
import * as signedOrdersSchema from '../schemas/signed_orders_schema.json';
|
||||||
import * as tokenSchema from '../schemas/token_schema.json';
|
import * as tokenSchema from '../schemas/token_schema.json';
|
||||||
@ -66,7 +65,6 @@ export const schemas = {
|
|||||||
blockRangeSchema,
|
blockRangeSchema,
|
||||||
tokenSchema,
|
tokenSchema,
|
||||||
jsNumber,
|
jsNumber,
|
||||||
requestOptsSchema,
|
|
||||||
pagedRequestOptsSchema,
|
pagedRequestOptsSchema,
|
||||||
ordersRequestOptsSchema,
|
ordersRequestOptsSchema,
|
||||||
orderBookRequestSchema,
|
orderBookRequestSchema,
|
||||||
|
@ -5,7 +5,10 @@
|
|||||||
"rootDir": ".",
|
"rootDir": ".",
|
||||||
"resolveJsonModule": true
|
"resolveJsonModule": true
|
||||||
},
|
},
|
||||||
"include": ["./src/**/*", "./test/**/*"],
|
"include": [
|
||||||
|
"./src/**/*",
|
||||||
|
"./test/**/*"
|
||||||
|
],
|
||||||
"files": [
|
"files": [
|
||||||
"./schemas/address_schema.json",
|
"./schemas/address_schema.json",
|
||||||
"./schemas/number_schema.json",
|
"./schemas/number_schema.json",
|
||||||
@ -50,7 +53,6 @@
|
|||||||
"./schemas/orderbook_request_schema.json",
|
"./schemas/orderbook_request_schema.json",
|
||||||
"./schemas/orders_request_opts_schema.json",
|
"./schemas/orders_request_opts_schema.json",
|
||||||
"./schemas/paged_request_opts_schema.json",
|
"./schemas/paged_request_opts_schema.json",
|
||||||
"./schemas/request_opts_schema.json",
|
|
||||||
"./schemas/order_config_request_schema.json"
|
"./schemas/order_config_request_schema.json"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user