UNPKG

@0x/swap-ts-sdk

Version:

0x Swap API TypeScript Client

1,113 lines 112 kB
import { type RouterV2 } from '../__generated__/routers'; /** * Creates a tRPC v10.x client typed for usage with 0x Swap v2. * See: https://trpc.io/docs/v10/client * https://docs.0x.org */ export declare function createClientV2(params: { apiKey: string; url?: string; }): { swap: { permit2: { getPrice: { query: import("@trpc/client").Resolver<import("@trpc/server").BuildProcedure<"query", { _config: import("@trpc/server").RootConfig<{ ctx: object; meta: any; errorShape: import("@trpc/server/rpc").TRPCErrorShape<import("@trpc/server/rpc").TRPC_ERROR_CODE_NUMBER, import("@trpc/server/dist/error/formatter").DefaultErrorData>; transformer: import("@trpc/server").DefaultDataTransformer; }>; _meta: any; _ctx_out: any; _input_in: { chainId: number; sellToken: string; buyToken: string; sellAmount?: unknown; taker?: string | undefined; txOrigin?: string | undefined; swapFeeRecipient?: string | undefined; swapFeeBps?: number | undefined; swapFeeToken?: string | undefined; tradeSurplusRecipient?: string | undefined; gasPrice?: unknown; slippageBps?: number | undefined; excludedSources?: string | undefined; }; _input_out: { chainId: import("../__generated__/routers").ChainId; sellToken: string; buyToken: string; sellAmount: import("@0x/utils").BigNumber; slippageBps: number; taker?: string | undefined; txOrigin?: string | undefined; swapFeeRecipient?: string | undefined; swapFeeBps?: number | undefined; swapFeeToken?: string | undefined; tradeSurplusRecipient?: string | undefined; gasPrice?: import("@0x/utils").BigNumber | undefined; excludedSources?: string | undefined; }; _output_in: { fees: { integratorFee: { amount: import("@0x/utils").BigNumber; type: "volume"; token: string; } | null; zeroExFee: { amount: import("@0x/utils").BigNumber; type: "volume"; token: string; } | null; gasFee: { amount: import("@0x/utils").BigNumber; type: "gas"; token: string; } | null; }; zid: string; gas: import("@0x/utils").BigNumber | null; sellToken: string; buyToken: string; sellAmount: import("@0x/utils").BigNumber; minBuyAmount: import("@0x/utils").BigNumber; buyAmount: import("@0x/utils").BigNumber; blockNumber: import("@0x/utils").BigNumber; gasPrice: import("@0x/utils").BigNumber; route: { tokens: { symbol: string; address: string; }[]; fills: { from: string; to: string; source: string; proportionBps: import("@0x/utils").BigNumber; }[]; }; issues: { balance: { expected: import("@0x/utils").BigNumber; token: string; actual: import("@0x/utils").BigNumber; } | null; allowance: { spender: string; actual: import("@0x/utils").BigNumber; } | null; simulationIncomplete: boolean; invalidSourcesPassed: string[]; }; liquidityAvailable: true; tokenMetadata: { sellToken: { buyTaxBps: import("@0x/utils").BigNumber | null; sellTaxBps: import("@0x/utils").BigNumber | null; }; buyToken: { buyTaxBps: import("@0x/utils").BigNumber | null; sellTaxBps: import("@0x/utils").BigNumber | null; }; }; totalNetworkFee: import("@0x/utils").BigNumber | null; } | { zid: string; liquidityAvailable: false; }; _output_out: { fees: { integratorFee: { amount: string; type: "volume"; token: string; } | null; zeroExFee: { amount: string; type: "volume"; token: string; } | null; gasFee: { amount: string; type: "gas"; token: string; } | null; }; zid: string; gas: string | null; sellToken: string; buyToken: string; sellAmount: string; minBuyAmount: string; buyAmount: string; blockNumber: string; gasPrice: string; route: { tokens: { symbol: string; address: string; }[]; fills: { from: string; to: string; source: string; proportionBps: string; }[]; }; issues: { balance: { expected: string; token: string; actual: string; } | null; allowance: { spender: string; actual: string; } | null; simulationIncomplete: boolean; invalidSourcesPassed: string[]; }; liquidityAvailable: true; tokenMetadata: { sellToken: { buyTaxBps: string | null; sellTaxBps: string | null; }; buyToken: { buyTaxBps: string | null; sellTaxBps: string | null; }; }; totalNetworkFee: string | null; } | { zid: string; liquidityAvailable: false; }; }, { fees: { integratorFee: { amount: string; type: "volume"; token: string; } | null; zeroExFee: { amount: string; type: "volume"; token: string; } | null; gasFee: { amount: string; type: "gas"; token: string; } | null; }; zid: string; gas: string | null; sellToken: string; buyToken: string; sellAmount: string; minBuyAmount: string; buyAmount: string; blockNumber: string; gasPrice: string; route: { tokens: { symbol: string; address: string; }[]; fills: { from: string; to: string; source: string; proportionBps: string; }[]; }; issues: { balance: { expected: string; token: string; actual: string; } | null; allowance: { spender: string; actual: string; } | null; simulationIncomplete: boolean; invalidSourcesPassed: string[]; }; liquidityAvailable: true; tokenMetadata: { sellToken: { buyTaxBps: string | null; sellTaxBps: string | null; }; buyToken: { buyTaxBps: string | null; sellTaxBps: string | null; }; }; totalNetworkFee: string | null; } | { zid: string; liquidityAvailable: false; }>>; }; getQuote: { query: import("@trpc/client").Resolver<import("@trpc/server").BuildProcedure<"query", { _config: import("@trpc/server").RootConfig<{ ctx: object; meta: any; errorShape: import("@trpc/server/rpc").TRPCErrorShape<import("@trpc/server/rpc").TRPC_ERROR_CODE_NUMBER, import("@trpc/server/dist/error/formatter").DefaultErrorData>; transformer: import("@trpc/server").DefaultDataTransformer; }>; _meta: any; _ctx_out: any; _input_in: { taker: string; chainId: number; sellToken: string; buyToken: string; sellAmount?: unknown; txOrigin?: string | undefined; swapFeeRecipient?: string | undefined; swapFeeBps?: number | undefined; swapFeeToken?: string | undefined; tradeSurplusRecipient?: string | undefined; gasPrice?: unknown; slippageBps?: number | undefined; excludedSources?: string | undefined; }; _input_out: { taker: string; chainId: import("../__generated__/routers").ChainId; sellToken: string; buyToken: string; sellAmount: import("@0x/utils").BigNumber; slippageBps: number; txOrigin?: string | undefined; swapFeeRecipient?: string | undefined; swapFeeBps?: number | undefined; swapFeeToken?: string | undefined; tradeSurplusRecipient?: string | undefined; gasPrice?: import("@0x/utils").BigNumber | undefined; excludedSources?: string | undefined; }; _output_in: { fees: { integratorFee: { amount: import("@0x/utils").BigNumber; type: "volume"; token: string; } | null; zeroExFee: { amount: import("@0x/utils").BigNumber; type: "volume"; token: string; } | null; gasFee: { amount: import("@0x/utils").BigNumber; type: "gas"; token: string; } | null; }; zid: string; sellToken: string; buyToken: string; permit2: { type: "Permit2"; hash: string; eip712: { message: import("../__generated__/routers").Eip712Object; types: Record<string, { type: string; name: string; }[]>; domain: { name?: string | undefined; version?: string | undefined; chainId?: number | undefined; verifyingContract?: string | undefined; salt?: string | undefined; }; primaryType: string; }; } | null; sellAmount: import("@0x/utils").BigNumber; minBuyAmount: import("@0x/utils").BigNumber; buyAmount: import("@0x/utils").BigNumber; blockNumber: import("@0x/utils").BigNumber; transaction: { value: import("@0x/utils").BigNumber; data: string; gas: import("@0x/utils").BigNumber | null; to: string; gasPrice: import("@0x/utils").BigNumber; }; route: { tokens: { symbol: string; address: string; }[]; fills: { from: string; to: string; source: string; proportionBps: import("@0x/utils").BigNumber; }[]; }; issues: { balance: { expected: import("@0x/utils").BigNumber; token: string; actual: import("@0x/utils").BigNumber; } | null; allowance: { spender: string; actual: import("@0x/utils").BigNumber; } | null; simulationIncomplete: boolean; invalidSourcesPassed: string[]; }; liquidityAvailable: true; tokenMetadata: { sellToken: { buyTaxBps: import("@0x/utils").BigNumber | null; sellTaxBps: import("@0x/utils").BigNumber | null; }; buyToken: { buyTaxBps: import("@0x/utils").BigNumber | null; sellTaxBps: import("@0x/utils").BigNumber | null; }; }; totalNetworkFee: import("@0x/utils").BigNumber | null; } | { zid: string; liquidityAvailable: false; }; _output_out: { fees: { integratorFee: { amount: string; type: "volume"; token: string; } | null; zeroExFee: { amount: string; type: "volume"; token: string; } | null; gasFee: { amount: string; type: "gas"; token: string; } | null; }; zid: string; sellToken: string; buyToken: string; permit2: { type: "Permit2"; hash: string; eip712: { message: import("../__generated__/routers").Eip712Object; types: Record<string, { type: string; name: string; }[]>; domain: { name?: string | undefined; version?: string | undefined; chainId?: number | undefined; verifyingContract?: string | undefined; salt?: string | undefined; }; primaryType: string; }; } | null; sellAmount: string; minBuyAmount: string; buyAmount: string; blockNumber: string; transaction: { value: string; data: string; gas: string | null; to: string; gasPrice: string; }; route: { tokens: { symbol: string; address: string; }[]; fills: { from: string; to: string; source: string; proportionBps: string; }[]; }; issues: { balance: { expected: string; token: string; actual: string; } | null; allowance: { spender: string; actual: string; } | null; simulationIncomplete: boolean; invalidSourcesPassed: string[]; }; liquidityAvailable: true; tokenMetadata: { sellToken: { buyTaxBps: string | null; sellTaxBps: string | null; }; buyToken: { buyTaxBps: string | null; sellTaxBps: string | null; }; }; totalNetworkFee: string | null; } | { zid: string; liquidityAvailable: false; }; }, { fees: { integratorFee: { amount: string; type: "volume"; token: string; } | null; zeroExFee: { amount: string; type: "volume"; token: string; } | null; gasFee: { amount: string; type: "gas"; token: string; } | null; }; zid: string; sellToken: string; buyToken: string; permit2: { type: "Permit2"; hash: string; eip712: { message: import("../__generated__/routers").Eip712Object; types: Record<string, { type: string; name: string; }[]>; domain: { name?: string | undefined; version?: string | undefined; chainId?: number | undefined; verifyingContract?: string | undefined; salt?: string | undefined; }; primaryType: string; }; } | null; sellAmount: string; minBuyAmount: string; buyAmount: string; blockNumber: string; transaction: { value: string; data: string; gas: string | null; to: string; gasPrice: string; }; route: { tokens: { symbol: string; address: string; }[]; fills: { from: string; to: string; source: string; proportionBps: string; }[]; }; issues: { balance: { expected: string; token: string; actual: string; } | null; allowance: { spender: string; actual: string; } | null; simulationIncomplete: boolean; invalidSourcesPassed: string[]; }; liquidityAvailable: true; tokenMetadata: { sellToken: { buyTaxBps: string | null; sellTaxBps: string | null; }; buyToken: { buyTaxBps: string | null; sellTaxBps: string | null; }; }; totalNetworkFee: string | null; } | { zid: string; liquidityAvailable: false; }>>; }; }; allowanceHolder: { getPrice: { query: import("@trpc/client").Resolver<import("@trpc/server").BuildProcedure<"query", { _config: import("@trpc/server").RootConfig<{ ctx: object; meta: any; errorShape: import("@trpc/server/rpc").TRPCErrorShape<import("@trpc/server/rpc").TRPC_ERROR_CODE_NUMBER, import("@trpc/server/dist/error/formatter").DefaultErrorData>; transformer: import("@trpc/server").DefaultDataTransformer; }>; _meta: any; _ctx_out: any; _input_in: { chainId: number; sellToken: string; buyToken: string; sellAmount?: unknown; taker?: string | undefined; txOrigin?: string | undefined; swapFeeRecipient?: string | undefined; swapFeeBps?: number | undefined; swapFeeToken?: string | undefined; tradeSurplusRecipient?: string | undefined; gasPrice?: unknown; slippageBps?: number | undefined; excludedSources?: string | undefined; }; _input_out: { chainId: import("../__generated__/routers").ChainId; sellToken: string; buyToken: string; sellAmount: import("@0x/utils").BigNumber; slippageBps: number; taker?: string | undefined; txOrigin?: string | undefined; swapFeeRecipient?: string | undefined; swapFeeBps?: number | undefined; swapFeeToken?: string | undefined; tradeSurplusRecipient?: string | undefined; gasPrice?: import("@0x/utils").BigNumber | undefined; excludedSources?: string | undefined; }; _output_in: { fees: { integratorFee: { amount: import("@0x/utils").BigNumber; type: "volume"; token: string; } | null; zeroExFee: { amount: import("@0x/utils").BigNumber; type: "volume"; token: string; } | null; gasFee: { amount: import("@0x/utils").BigNumber; type: "gas"; token: string; } | null; }; zid: string; gas: import("@0x/utils").BigNumber | null; sellToken: string; buyToken: string; sellAmount: import("@0x/utils").BigNumber; minBuyAmount: import("@0x/utils").BigNumber; buyAmount: import("@0x/utils").BigNumber; blockNumber: import("@0x/utils").BigNumber; gasPrice: import("@0x/utils").BigNumber; route: { tokens: { symbol: string; address: string; }[]; fills: { from: string; to: string; source: string; proportionBps: import("@0x/utils").BigNumber; }[]; }; issues: { balance: { expected: import("@0x/utils").BigNumber; token: string; actual: import("@0x/utils").BigNumber; } | null; allowance: { spender: string; actual: import("@0x/utils").BigNumber; } | null; simulationIncomplete: boolean; invalidSourcesPassed: string[]; }; liquidityAvailable: true; tokenMetadata: { sellToken: { buyTaxBps: import("@0x/utils").BigNumber | null; sellTaxBps: import("@0x/utils").BigNumber | null; }; buyToken: { buyTaxBps: import("@0x/utils").BigNumber | null; sellTaxBps: import("@0x/utils").BigNumber | null; }; }; totalNetworkFee: import("@0x/utils").BigNumber | null; } | { zid: string; liquidityAvailable: false; }; _output_out: { fees: { integratorFee: { amount: string; type: "volume"; token: string; } | null; zeroExFee: { amount: string; type: "volume"; token: string; } | null; gasFee: { amount: string; type: "gas"; token: string; } | null; }; zid: string; gas: string | null; sellToken: string; buyToken: string; sellAmount: string; minBuyAmount: string; buyAmount: string; blockNumber: string; gasPrice: string; route: { tokens: { symbol: string; address: string; }[]; fills: { from: string; to: string; source: string; proportionBps: string; }[]; }; issues: { balance: { expected: string; token: string; actual: string; } | null; allowance: { spender: string; actual: string; } | null; simulationIncomplete: boolean; invalidSourcesPassed: string[]; }; liquidityAvailable: true; tokenMetadata: { sellToken: { buyTaxBps: string | null; sellTaxBps: string | null; }; buyToken: { buyTaxBps: string | null; sellTaxBps: string | null; }; }; totalNetworkFee: string | null; } | { zid: string; liquidityAvailable: false; }; }, { fees: { integratorFee: { amount: string; type: "volume"; token: string; } | null; zeroExFee: { amount: string; type: "volume"; token: string; } | null; gasFee: { amount: string; type: "gas"; token: string; } | null; }; zid: string; gas: string | null; sellToken: string; buyToken: string; sellAmount: string; minBuyAmount: string; buyAmount: string; blockNumber: string; gasPrice: string; route: { tokens: { symbol: string; address: string; }[]; fills: { from: string; to: string; source: string; proportionBps: string; }[]; }; issues: { balance: { expected: string; token: string; actual: string; } | null; allowance: { spender: string; actual: string; } | null; simulationIncomplete: boolean; invalidSourcesPassed: string[]; }; liquidityAvailable: true; tokenMetadata: { sellToken: { buyTaxBps: string | null; sellTaxBps: string | null; }; buyToken: { buyTaxBps: string | null; sellTaxBps: string | null; }; }; totalNetworkFee: string | null; } | { zid: string; liquidityAvailable: false; }>>; }; getQuote: { query: import("@trpc/client").Resolver<import("@trpc/server").BuildProcedure<"query", { _config: import("@trpc/server").RootConfig<{ ctx: object; meta: any; errorShape: import("@trpc/server/rpc").TRPCErrorShape<import("@trpc/server/rpc").TRPC_ERROR_CODE_NUMBER, import("@trpc/server/dist/error/formatter").DefaultErrorData>; transformer: import("@trpc/server").DefaultDataTransformer; }>; _meta: any; _ctx_out: any; _input_in: { taker: string; chainId: number; sellToken: string; buyToken: string; sellAmount?: unknown; txOrigin?: string | undefined; swapFeeRecipient?: string | undefined; swapFeeBps?: number | undefined; swapFeeToken?: string | undefined; tradeSurplusRecipient?: string | undefined; gasPrice?: unknown; slippageBps?: number | undefined; excludedSources?: string | undefined; }; _input_out: { taker: string; chainId: import("../__generated__/routers").ChainId; sellToken: string; buyToken: string; sellAmount: import("@0x/utils").BigNumber; slippageBps: number; txOrigin?: string | undefined; swapFeeRecipient?: string | undefined; swapFeeBps?: number | undefined; swapFeeToken?: string | undefined; tradeSurplusRecipient?: string | undefined; gasPrice?: import("@0x/utils").BigNumber | undefined; excludedSources?: string | undefined; }; _output_in: { fees: { integratorFee: { amount: import("@0x/utils").BigNumber; type: "volume"; token: string; } | null; zeroExFee: { amount: import("@0x/utils").BigNumber; type: "volume"; token: string; } | null; gasFee: { amount: import("@0x/utils").BigNumber; type: "gas"; token: string; } | null; }; zid: string; sellToken: string; buyToken: string; sellAmount: import("@0x/utils").BigNumber; minBuyAmount: import("@0x/utils").BigNumber; buyAmount: import("@0x/utils").BigNumber; blockNumber: import("@0x/utils").BigNumber; transaction: { value: import("@0x/utils").BigNumber; data: string; gas: import("@0x/utils").BigNumber | null; to: string; gasPrice: import("@0x/utils").BigNumber; }; route: { tokens: { symbol: string; address: string; }[]; fills: { from: string; to: string; source: string; proportionBps: import("@0x/utils").BigNumber; }[]; }; issues: { balance: { expected: import("@0x/utils").BigNumber; token: string; actual: import("@0x/utils").BigNumber; } | null; allowance: { spender: string; actual: import("@0x/utils").BigNumber; } | null; simulationIncomplete: boolean; invalidSourcesPassed: string[]; }; liquidityAvailable: true; tokenMetadata: { sellToken: { buyTaxBps: import("@0x/utils").BigNumber | null; sellTaxBps: import("@0x/utils").BigNumber | null; }; buyToken: { buyTaxBps: import("@0x/utils").BigNumber | null; sellTaxBps: import("@0x/utils").BigNumber | null; }; }; totalNetworkFee: import("@0x/utils").BigNumber | null; } | { zid: string; liquidityAvailable: false; }; _output_out: { fees: { integratorFee: { amount: string; type: "volume"; token: string; } | null; zeroExFee: { amount: string; type: "volume"; token: string; } | null; gasFee: { amount: string; type: "gas"; token: string; } | null; }; zid: string; sellToken: string; buyToken: string; sellAmount: string; minBuyAmount: string; buyAmount: string; blockNumber: string; transaction: { value: string; data: string; gas: string | null; to: string; gasPrice: string; }; route: { tokens: { symbol: string; address: string; }[]; fills: { from: string; to: string; source: string; proportionBps: string; }[]; }; issues: { balance: { expected: string; token: string; actual: string; } | null; allowance: { spender: string; actual: string; } | null; simulationIncomplete: boolean; invalidSourcesPassed: string[]; }; liquidityAvailable: true; tokenMetadata: { sellToken: { buyTaxBps: string | null; sellTaxBps: string | null; }; buyToken: { buyTaxBps: string | null; sellTaxBps: string | null; }; }; totalNetworkFee: string | null; } | { zid: string; liquidityAvailable: false; }; }, { fees: { integratorFee: { amount: string; type: "volume"; token: string; } | null; zeroExFee: { amount: string; type: "volume"; token: string; } | null; gasFee: { amount: string; type: "gas"; token: string; } | null; }; zid: string; sellToken: string; buyToken: string; sellAmount: string; minBuyAmount: string; buyAmount: string; blockNumber: string; transaction: { value: string; data: string; gas: string | null; to: string; gasPrice: string; }; route: { tokens: { symbol: string; address: string; }[]; fills: { from: string; to: string; source: string; proportionBps: string; }[]; }; issues: { balance: { expected: string; token: string; actual: string; } | null; allowance: { spender: string; actual: string; } | null; simulationIncomplete: boolean; invalidSourcesPassed: string[]; }; liquidityAvailable: true; tokenMetadata: { sellToken: { buyTaxBps: string | null; sellTaxBps: string | null; }; buyToken: { buyTaxBps: string | null; sellTaxBps: string | null; }; }; totalNetworkFee: string | null; } | { zid: string; liquidityAvailable: false; }>>; }; }; getTrades: { query: import("@trpc/client").Resolver<import("@trpc/server").BuildProcedure<"query", { _config: import("@trpc/server").RootConfig<{ ctx: object; meta: any; errorShape: import("@trpc/server/rpc").TRPCErrorShape<import("@trpc/server/rpc").TRPC_ERROR_CODE_NUMBER, import("@trpc/server/dist/error/formatter").DefaultErrorData>; transformer: import("@trpc/server").DefaultDataTransformer; }>; _meta: any; _ctx_out: any; _input_in: { cursor?: string | undefined; startTimestamp?: number | undefined; endTimestamp?: number | undefined; }; _input_out: { cursor?: string | undefined; startTimestamp?: number | undefined; endTimestamp?: number | undefined; }; _output_in: { zid: string; nextCursor: string | null; trades: { taker: string; chainId: number; zid: string; sellToken: string; buyToken: string; gasUsed: string; blo