UNPKG

@coinbase/cdp-sdk

Version:

SDK for interacting with the Coinbase Developer Platform Wallet API

52 lines (48 loc) 1.82 kB
/** * Generated by orval v7.21.0 🍺 * Do not edit manually. * Coinbase Developer Platform APIs * The Coinbase Developer Platform APIs - leading the world's transition onchain. * OpenAPI spec version: 2.0.0 */ import type { CreateEvmSwapQuoteBody, CreateSwapQuoteResponseWrapper, GetEvmSwapPriceParams, GetSwapPriceResponseWrapper, } from "../coinbaseDeveloperPlatformAPIs.schemas.js"; import { cdpApiClient } from "../../cdpApiClient.js"; type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1]; /** * Get a price estimate for a swap between two tokens on an EVM network. * @summary Get swap price estimate */ export const getEvmSwapPrice = ( params: GetEvmSwapPriceParams, options?: SecondParameter<typeof cdpApiClient<GetSwapPriceResponseWrapper>>, ) => { return cdpApiClient<GetSwapPriceResponseWrapper>( { url: `/v2/evm/swaps/quote`, method: "GET", params }, options, ); }; /** * Create a swap quote, which includes the payload to sign as well as the transaction data needed to execute the swap. The developer is responsible for signing the payload and submitting the transaction to the network in order to execute the swap. * @summary Create swap quote */ export const createEvmSwapQuote = ( createEvmSwapQuoteBody: CreateEvmSwapQuoteBody, options?: SecondParameter<typeof cdpApiClient<CreateSwapQuoteResponseWrapper>>, ) => { return cdpApiClient<CreateSwapQuoteResponseWrapper>( { url: `/v2/evm/swaps`, method: "POST", headers: { "Content-Type": "application/json" }, data: createEvmSwapQuoteBody, }, options, ); }; export type GetEvmSwapPriceResult = NonNullable<Awaited<ReturnType<typeof getEvmSwapPrice>>>; export type CreateEvmSwapQuoteResult = NonNullable<Awaited<ReturnType<typeof createEvmSwapQuote>>>;