diff --git a/package.json b/package.json index 90bad732..b8f3a2a8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@lifi/types", - "version": "15.15.0", + "version": "15.16.0-alpha.1", "description": "Types for the LI.FI stack", "keywords": [ "sdk", diff --git a/src/api.ts b/src/api.ts index a1fcdbef..a8c79a0e 100644 --- a/src/api.ts +++ b/src/api.ts @@ -258,11 +258,10 @@ export interface ToolConfiguration { preferExchanges?: string[] } -export interface QuoteRequest extends ToolConfiguration, TimingStrings { +export interface PartialQuoteRequest extends ToolConfiguration, TimingStrings { fromChain: number | string fromToken: string fromAddress: string - fromAmount: string toChain: number | string toToken: string @@ -274,7 +273,7 @@ export interface QuoteRequest extends ToolConfiguration, TimingStrings { referrer?: string fee?: number | string allowDestinationCall?: boolean // (default : true) // destination calls are enabled by default - fromAmountForGas?: string // the amount of token to convert to gas + maxPriceImpact?: number // hide routes with price impact greater than or equal to this value skipSimulation?: boolean @@ -284,11 +283,26 @@ export interface QuoteRequest extends ToolConfiguration, TimingStrings { insurance?: boolean // indicates whether the user wants a quote with bridge insurance } +export interface QuoteFromAmountRequest extends PartialQuoteRequest { + fromAmountForGas?: string // the amount of token to convert to gas + fromAmount: string +} + export interface QuoteToAmountRequest - extends Omit { + extends Omit { toAmount: string } +export type QuoteRequest = QuoteFromAmountRequest | QuoteToAmountRequest + +export const isQuoteRequestWithFromAmount = ( + r: QuoteRequest +): r is QuoteFromAmountRequest => 'fromAmount' in r + +export const isQuoteRequestWithToAmount = ( + r: QuoteRequest +): r is QuoteToAmountRequest => 'toAmount' in r + export interface ContractCall { fromAmount: string fromTokenAddress: string @@ -331,12 +345,13 @@ export type ContractCallsQuoteRequestFromAmount = export type ContractCallsQuoteRequest = | ContractCallsQuoteRequestFromAmount | ContractCallsQuoteRequestToAmount + export const isContractCallsRequestWithFromAmount = ( - r: ContractCallsQuoteRequestFromAmount | ContractCallsQuoteRequestToAmount + r: ContractCallsQuoteRequest ): r is ContractCallsQuoteRequestFromAmount => 'fromAmount' in r export const isContractCallsRequestWithToAmount = ( - r: ContractCallsQuoteRequestFromAmount | ContractCallsQuoteRequestToAmount + r: ContractCallsQuoteRequest ): r is ContractCallsQuoteRequestToAmount => 'toAmount' in r /* @deprecated */