Skip to content
This repository was archived by the owner on Oct 15, 2024. It is now read-only.

Commit

Permalink
fix: Changes latency to be capped at 600ms, added some extra typing (#…
Browse files Browse the repository at this point in the history
…275)

* Changes latency to be capped at 600ms, added some extra typing

* remove `slippagePercentage` in meta-transactions
  • Loading branch information
PirosB3 authored Jul 6, 2020
1 parent 3681ea2 commit cd545c8
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 13 deletions.
2 changes: 2 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,8 @@ const feeSchedule: { [key in ERC20BridgeSource]: BigNumber } = Object.assign(
})),
);

export const RFQT_REQUEST_MAX_RESPONSE_MS = 600;

export const ASSET_SWAPPER_MARKET_ORDERS_OPTS: Partial<SwapQuoteRequestOpts> = {
excludedSources: EXCLUDED_SOURCES,
bridgeSlippage: DEFAULT_QUOTE_SLIPPAGE_PERCENTAGE,
Expand Down
5 changes: 2 additions & 3 deletions src/services/meta_transaction_service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Orderbook, SwapQuoter, SwapQuoterOpts } from '@0x/asset-swapper';
import { OrderPrunerPermittedFeeTypes } from '@0x/asset-swapper/lib/src/types';
import { OrderPrunerPermittedFeeTypes, SwapQuoteRequestOpts } from '@0x/asset-swapper/lib/src/types';
import { ContractWrappers } from '@0x/contract-wrappers';
import { DevUtilsContract } from '@0x/contracts-dev-utils';
import { generatePseudoRandomSalt, SupportedProvider, ZeroExTransaction } from '@0x/order-utils';
Expand Down Expand Up @@ -113,9 +113,8 @@ export class MetaTransactionService {
takerAddress,
};
}
const assetSwapperOpts = {
const assetSwapperOpts: Partial<SwapQuoteRequestOpts> = {
...ASSET_SWAPPER_MARKET_ORDERS_OPTS,
slippagePercentage,
bridgeSlippage: slippagePercentage,
excludedSources, // TODO(dave4506): overrides the excluded sources selected by chainId
rfqt: _rfqt,
Expand Down
10 changes: 6 additions & 4 deletions src/services/swap_service.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import {
ExtensionContractType,
Orderbook,
RfqtRequestOpts,
SwapQuote,
SwapQuoteConsumer,
SwapQuoter,
SwapQuoterOpts,
} from '@0x/asset-swapper';
import { OrderPrunerPermittedFeeTypes } from '@0x/asset-swapper/lib/src/types';
import { OrderPrunerPermittedFeeTypes, SwapQuoteRequestOpts } from '@0x/asset-swapper/lib/src/types';
import { getContractAddressesForChainOrThrow } from '@0x/contract-addresses';
import { ERC20TokenContract, WETH9Contract } from '@0x/contract-wrappers';
import { assetDataUtils, SupportedProvider } from '@0x/order-utils';
Expand All @@ -21,6 +22,7 @@ import {
LIQUIDITY_POOL_REGISTRY_ADDRESS,
RFQT_API_KEY_WHITELIST,
RFQT_MAKER_ASSET_OFFERINGS,
RFQT_REQUEST_MAX_RESPONSE_MS,
RFQT_SKIP_BUY_REQUESTS,
} from '../config';
import {
Expand Down Expand Up @@ -338,7 +340,7 @@ export class SwapService {
rfqt,
// tslint:disable-next-line:boolean-naming
} = params;
let _rfqt;
let _rfqt: RfqtRequestOpts | undefined;
if (apiKey !== undefined && (isETHSell || from !== undefined)) {
_rfqt = {
...rfqt,
Expand All @@ -348,11 +350,11 @@ export class SwapService {
// forwarder contract. If it's not, then we want to request quotes with the taker set to the
// API's takerAddress query parameter, which in this context is known as `from`.
takerAddress: isETHSell ? this._forwarderAddress : from || '',
makerEndpointMaxResponseTimeMs: RFQT_REQUEST_MAX_RESPONSE_MS,
};
}
const assetSwapperOpts = {
const assetSwapperOpts: Partial<SwapQuoteRequestOpts> = {
...ASSET_SWAPPER_MARKET_ORDERS_OPTS,
slippagePercentage,
bridgeSlippage: slippagePercentage,
gasPrice: providedGasPrice,
excludedSources, // TODO(dave4506): overrides the excluded sources selected by chainId
Expand Down
14 changes: 8 additions & 6 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { ERC20BridgeSource, MarketBuySwapQuote, MarketSellSwapQuote, SupportedProvider } from '@0x/asset-swapper';
import {
ERC20BridgeSource,
MarketBuySwapQuote,
MarketSellSwapQuote,
RfqtRequestOpts,
SupportedProvider,
} from '@0x/asset-swapper';
import { AcceptedOrderInfo, RejectedOrderInfo } from '@0x/mesh-rpc-client';
import {
APIOrder,
Expand Down Expand Up @@ -511,11 +517,7 @@ export interface CalculateSwapQuoteParams {
excludedSources?: ERC20BridgeSource[];
affiliateAddress?: string;
apiKey?: string;
rfqt?: {
intentOnFilling?: boolean;
isIndicative?: boolean;
skipBuyRequests?: boolean;
};
rfqt?: Partial<RfqtRequestOpts>;
skipValidation: boolean;
}

Expand Down

0 comments on commit cd545c8

Please sign in to comment.