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

Commit

Permalink
Add rfqt: namespace for RFQ-T specific options
Browse files Browse the repository at this point in the history
  • Loading branch information
feuGeneA committed Apr 10, 2020
1 parent a77fd8d commit 6146027
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
19 changes: 14 additions & 5 deletions src/handlers/swap_handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class SwapHandlers {
gasPrice,
excludedSources,
affiliateAddress,
intentOnFilling,
rfqt,
} = parseGetSwapQuoteRequestParams(req);
const isETHSell = isETHSymbol(sellToken);
const sellTokenAddress = findTokenAddressOrThrowApiError(sellToken, 'sellToken', CHAIN_ID);
Expand Down Expand Up @@ -65,7 +65,12 @@ export class SwapHandlers {
excludedSources,
affiliateAddress,
apiKey: req.header('0x-api-key'),
intentOnFilling,
rfqt:
rfqt === undefined
? undefined
: {
intentOnFilling: rfqt.intentOnFilling,
},
});
res.status(HttpStatus.OK).send(swapQuote);
} catch (e) {
Expand Down Expand Up @@ -169,8 +174,12 @@ const parseGetSwapQuoteRequestParams = (req: express.Request): GetSwapQuoteReque
? undefined
: parseStringArrForERC20BridgeSources(req.query.excludedSources.split(','));
const affiliateAddress = req.query.affiliateAddress;
// tslint:disable-next-line:boolean-naming
const intentOnFilling = req.query.intentOnFilling === 'true' ? true : false;
const rfqt =
req.query.intentOnFilling === undefined
? undefined
: {
intentOnFilling: req.query.intentOnFilling === 'true' ? true : false,
};
return {
takerAddress,
sellToken,
Expand All @@ -181,6 +190,6 @@ const parseGetSwapQuoteRequestParams = (req: express.Request): GetSwapQuoteReque
gasPrice,
excludedSources,
affiliateAddress,
intentOnFilling,
rfqt,
};
};
2 changes: 1 addition & 1 deletion src/services/swap_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export class SwapService {
excludedSources,
affiliateAddress,
apiKey,
intentOnFilling,
rfqt,
} = params;
const assetSwapperOpts = {
...ASSET_SWAPPER_MARKET_ORDERS_OPTS,
Expand Down
8 changes: 6 additions & 2 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,9 @@ export interface GetSwapQuoteRequestParams {
gasPrice?: BigNumber;
excludedSources?: ERC20BridgeSource[];
affiliateAddress?: string;
intentOnFilling?: boolean;
rfqt?: {
intentOnFilling: boolean;
};
}

export interface CalculateSwapQuoteParams {
Expand All @@ -357,7 +359,9 @@ export interface CalculateSwapQuoteParams {
excludedSources?: ERC20BridgeSource[];
affiliateAddress?: string;
apiKey?: string;
intentOnFilling?: boolean;
rfqt?: {
intentOnFilling: boolean;
};
}

export interface GetSwapQuoteResponseLiquiditySource {
Expand Down

0 comments on commit 6146027

Please sign in to comment.