@yoroi/types
Version:
The Yoroi Types package of Yoroi SDK
166 lines (164 loc) • 3.84 kB
Flow
/**
* Flowtype definitions for api
* Generated by Flowgen from a Typescript Definition
* Flowgen v1.21.0
*/
import { ApiResponse } from "../api/response";
import { PortfolioTokenInfo } from "../portfolio/info";
import { PortfolioTokenId } from "../portfolio/token";
import { SwapAggregator } from "./aggregator";
import { SwapOrder } from "./order";
import { SwapProtocol } from "./protocol";
export type SwapLimitOptionsRequest = {
tokenIn: PortfolioTokenId,
tokenOut: PortfolioTokenId,
...
};
export type SwapLimitOptionsResponse = {
defaultProtocol: SwapProtocol,
wantedPrice: number,
options: Array<{
protocol: SwapProtocol,
initialPrice: number,
batcherFee: number,
...
}>,
...
};
export type SwapEstimateRequest = {
...{
slippage: number,
tokenIn: PortfolioTokenId,
tokenOut: PortfolioTokenId,
protocol?: SwapProtocol,
blockedProtocols?: Array<SwapProtocol>,
...
},
...
| {
amountOut?: void,
amountIn: number,
multiples?: number,
wantedPrice?: number,
...
}
| {
amountOut: number,
amountIn?: void,
multiples?: void,
wantedPrice?: void,
...
},
};
export type SwapSplit = {
amountIn: number,
batcherFee: number,
deposits: number,
protocol: SwapProtocol,
expectedOutput: number,
expectedOutputWithoutSlippage: number,
fee: number,
finalPrice: number,
initialPrice: number,
poolFee: number,
poolId: string,
priceDistortion: number,
priceImpact: number,
aggregator?: SwapAggregator,
aggregatorDexKey?: string,
aggregatorPoolId?: string | string[],
quoteId?: string,
aggregatorImageUrl?: string,
...
};
export type SwapEstimateResponse = {
splits: Array<SwapSplit>,
batcherFee: number,
deposits: number,
aggregatorFee: number,
frontendFee: number,
netPrice: number,
priceImpact: number,
totalFee: number,
totalOutput: number,
totalOutputWithoutSlippage?: number,
totalInput?: number,
...
};
export type SwapCreateRequest = {
...{
amountIn: number,
tokenIn: PortfolioTokenId,
tokenOut: PortfolioTokenId,
protocol?: SwapProtocol,
inputs?: Array<string>,
blockedProtocols?: Array<SwapProtocol>,
routeHint?: SwapRouteHint,
...
},
...
| {
wantedPrice?: number,
slippage?: void,
multiples?: number,
...
}
| {
wantedPrice?: void,
slippage: number,
multiples?: void,
...
},
};
export type SwapRouteHint = {
aggregator: SwapAggregator,
aggregatorDexKey?: string,
poolIds?: string[],
quoteId?: string,
singlePreferredDexKey?: string,
frontendOptions?: string[],
orderContract?: string,
...
};
export type SwapCreateResponse = {
splits: SwapSplit[],
batcherFee: number,
deposits: number,
aggregatorFee: number,
frontendFee: number,
netPrice?: number,
priceImpact: number,
totalFee: number,
totalInput: number,
totalOutput: number,
totalOutputWithoutSlippage?: number,
aggregator: SwapAggregator,
cbor: string,
...
};
export type SwapCancelRequest = {
order: SwapOrder,
...
};
export type SwapCancelResponse = {
cbor: string,
additionalCancellationFee?: number,
...
};
export type SwapApi = $ReadOnly<{
orders: () => Promise<ApiResponse<Array<SwapOrder>>>,
tokens: () => Promise<ApiResponse<Array<PortfolioTokenInfo>>>,
limitOptions(
args: $ReadOnly<SwapLimitOptionsRequest>
): Promise<ApiResponse<SwapLimitOptionsResponse>>,
estimate(
args: $ReadOnly<SwapEstimateRequest>
): Promise<ApiResponse<SwapEstimateResponse>>,
create(
args: $ReadOnly<SwapCreateRequest>
): Promise<ApiResponse<SwapCreateResponse>>,
cancel: (
args: $ReadOnly<SwapCancelRequest>
) => Promise<ApiResponse<SwapCancelResponse>>,
...
}>;