@coinbase/cdp-sdk 1.11.0 → 1.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/README.md +117 -0
- package/_cjs/accounts/evm/toEvmServerAccount.js +14 -0
- package/_cjs/accounts/evm/toEvmServerAccount.js.map +1 -1
- package/_cjs/actions/evm/swap/createSwapQuote.js +126 -0
- package/_cjs/actions/evm/swap/createSwapQuote.js.map +1 -0
- package/_cjs/actions/evm/swap/getSwapPrice.js +86 -0
- package/_cjs/actions/evm/swap/getSwapPrice.js.map +1 -0
- package/_cjs/actions/evm/swap/sendSwapTransaction.js +141 -0
- package/_cjs/actions/evm/swap/sendSwapTransaction.js.map +1 -0
- package/_cjs/actions/evm/swap/types.js +3 -0
- package/_cjs/actions/evm/swap/types.js.map +1 -0
- package/_cjs/client/evm/evm.js +46 -1
- package/_cjs/client/evm/evm.js.map +1 -1
- package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +6 -1
- package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -1
- package/_cjs/openapi-client/generated/evm-swaps/evm-swaps.js +26 -0
- package/_cjs/openapi-client/generated/evm-swaps/evm-swaps.js.map +1 -0
- package/_cjs/openapi-client/generated/evm-swaps/evm-swaps.msw.js +179 -0
- package/_cjs/openapi-client/generated/evm-swaps/evm-swaps.msw.js.map +1 -0
- package/_cjs/openapi-client/generated/index.msw.js +5 -4
- package/_cjs/openapi-client/generated/index.msw.js.map +1 -1
- package/_cjs/openapi-client/index.js +4 -0
- package/_cjs/openapi-client/index.js.map +1 -1
- package/_cjs/version.js +1 -1
- package/_esm/accounts/evm/toEvmServerAccount.js +14 -0
- package/_esm/accounts/evm/toEvmServerAccount.js.map +1 -1
- package/_esm/actions/evm/swap/createSwapQuote.js +123 -0
- package/_esm/actions/evm/swap/createSwapQuote.js.map +1 -0
- package/_esm/actions/evm/swap/getSwapPrice.js +83 -0
- package/_esm/actions/evm/swap/getSwapPrice.js.map +1 -0
- package/_esm/actions/evm/swap/sendSwapTransaction.js +138 -0
- package/_esm/actions/evm/swap/sendSwapTransaction.js.map +1 -0
- package/_esm/actions/evm/swap/types.js +2 -0
- package/_esm/actions/evm/swap/types.js.map +1 -0
- package/_esm/client/evm/evm.js +46 -1
- package/_esm/client/evm/evm.js.map +1 -1
- package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +5 -0
- package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -1
- package/_esm/openapi-client/generated/evm-swaps/evm-swaps.js +21 -0
- package/_esm/openapi-client/generated/evm-swaps/evm-swaps.js.map +1 -0
- package/_esm/openapi-client/generated/evm-swaps/evm-swaps.msw.js +167 -0
- package/_esm/openapi-client/generated/evm-swaps/evm-swaps.msw.js.map +1 -0
- package/_esm/openapi-client/generated/index.msw.js +5 -4
- package/_esm/openapi-client/generated/index.msw.js.map +1 -1
- package/_esm/openapi-client/index.js +4 -0
- package/_esm/openapi-client/index.js.map +1 -1
- package/_esm/version.js +1 -1
- package/_types/accounts/evm/toEvmServerAccount.d.ts.map +1 -1
- package/_types/actions/evm/swap/createSwapQuote.d.ts +23 -0
- package/_types/actions/evm/swap/createSwapQuote.d.ts.map +1 -0
- package/_types/actions/evm/swap/getSwapPrice.d.ts +23 -0
- package/_types/actions/evm/swap/getSwapPrice.d.ts.map +1 -0
- package/_types/actions/evm/swap/sendSwapTransaction.d.ts +64 -0
- package/_types/actions/evm/swap/sendSwapTransaction.d.ts.map +1 -0
- package/_types/actions/evm/swap/types.d.ts +80 -0
- package/_types/actions/evm/swap/types.d.ts.map +1 -0
- package/_types/actions/evm/types.d.ts +86 -0
- package/_types/actions/evm/types.d.ts.map +1 -1
- package/_types/client/evm/evm.d.ts +39 -1
- package/_types/client/evm/evm.d.ts.map +1 -1
- package/_types/client/evm/evm.types.d.ts +207 -3
- package/_types/client/evm/evm.types.d.ts.map +1 -1
- package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts +300 -3
- package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts.map +1 -1
- package/_types/openapi-client/generated/evm-swaps/evm-swaps.d.ts +24 -0
- package/_types/openapi-client/generated/evm-swaps/evm-swaps.d.ts.map +1 -0
- package/_types/openapi-client/generated/evm-swaps/evm-swaps.msw.d.ts +12 -0
- package/_types/openapi-client/generated/evm-swaps/evm-swaps.msw.d.ts.map +1 -0
- package/_types/openapi-client/generated/index.msw.d.ts +5 -4
- package/_types/openapi-client/generated/index.msw.d.ts.map +1 -1
- package/_types/openapi-client/index.d.ts +5 -0
- package/_types/openapi-client/index.d.ts.map +1 -1
- package/_types/version.d.ts +1 -1
- package/accounts/evm/toEvmServerAccount.ts +21 -0
- package/actions/evm/swap/createSwapQuote.ts +148 -0
- package/actions/evm/swap/getSwapPrice.ts +95 -0
- package/actions/evm/swap/sendSwapTransaction.ts +173 -0
- package/actions/evm/swap/types.ts +94 -0
- package/actions/evm/types.ts +88 -0
- package/client/evm/evm.ts +58 -1
- package/client/evm/evm.types.ts +225 -1
- package/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.ts +329 -3
- package/openapi-client/generated/evm-swaps/evm-swaps.msw.ts +217 -0
- package/openapi-client/generated/evm-swaps/evm-swaps.ts +51 -0
- package/openapi-client/generated/index.msw.ts +5 -4
- package/openapi-client/index.ts +4 -0
- package/package.json +1 -1
- package/version.ts +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from "./generated/coinbaseDeveloperPlatformAPIs.schemas.js";
|
|
2
2
|
export * from "./generated/evm-accounts/evm-accounts.js";
|
|
3
3
|
export * from "./generated/evm-smart-accounts/evm-smart-accounts.js";
|
|
4
|
+
export * from "./generated/evm-swaps/evm-swaps.js";
|
|
4
5
|
export * from "./generated/evm-token-balances/evm-token-balances.js";
|
|
5
6
|
export * from "./generated/solana-accounts/solana-accounts.js";
|
|
6
7
|
export * from "./generated/faucets/faucets.js";
|
|
@@ -9,6 +10,7 @@ export * from "./generated/payments-alpha/payments-alpha.js";
|
|
|
9
10
|
import { configure } from "./cdpApiClient.js";
|
|
10
11
|
import * as evm from "./generated/evm-accounts/evm-accounts.js";
|
|
11
12
|
import * as evmSmartAccounts from "./generated/evm-smart-accounts/evm-smart-accounts.js";
|
|
13
|
+
import * as evmSwaps from "./generated/evm-swaps/evm-swaps.js";
|
|
12
14
|
import * as evmTokenBalances from "./generated/evm-token-balances/evm-token-balances.js";
|
|
13
15
|
import * as faucets from "./generated/faucets/faucets.js";
|
|
14
16
|
import * as payments from "./generated/payments-alpha/payments-alpha.js";
|
|
@@ -17,6 +19,7 @@ import * as solana from "./generated/solana-accounts/solana-accounts.js";
|
|
|
17
19
|
export const CdpOpenApiClient = {
|
|
18
20
|
...evm,
|
|
19
21
|
...evmSmartAccounts,
|
|
22
|
+
...evmSwaps,
|
|
20
23
|
...evmTokenBalances,
|
|
21
24
|
...solana,
|
|
22
25
|
...faucets,
|
|
@@ -27,6 +30,7 @@ export const CdpOpenApiClient = {
|
|
|
27
30
|
export const OpenApiEvmMethods = {
|
|
28
31
|
...evm,
|
|
29
32
|
...evmSmartAccounts,
|
|
33
|
+
...evmSwaps,
|
|
30
34
|
...evmTokenBalances,
|
|
31
35
|
requestEvmFaucet: faucets.requestEvmFaucet,
|
|
32
36
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../openapi-client/index.ts"],"names":[],"mappings":"AAAA,cAAc,sDAAsD,CAAC;AACrE,cAAc,0CAA0C,CAAC;AACzD,cAAc,sDAAsD,CAAC;AACrE,cAAc,sDAAsD,CAAC;AACrE,cAAc,gDAAgD,CAAC;AAC/D,cAAc,gCAAgC,CAAC;AAC/C,cAAc,4CAA4C,CAAC;AAC3D,cAAc,8CAA8C,CAAC;AAE7D,OAAO,EAAE,SAAS,EAAE,MAAM,m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,OAAO,KAAK,GAAG,MAAM,0CAA0C,CAAC;AAChE,OAAO,KAAK,gBAAgB,MAAM,sDAAsD,CAAC;AACzF,OAAO,KAAK,QAAQ,MAAM,oCAAoC,CAAC;AAC/D,OAAO,KAAK,gBAAgB,MAAM,sDAAsD,CAAC;AACzF,OAAO,KAAK,OAAO,MAAM,gCAAgC,CAAC;AAC1D,OAAO,KAAK,QAAQ,MAAM,8CAA8C,CAAC;AACzE,OAAO,KAAK,QAAQ,MAAM,4CAA4C,CAAC;AACvE,OAAO,KAAK,MAAM,MAAM,gDAAgD,CAAC;AAEzE,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,GAAG,GAAG;IACN,GAAG,gBAAgB;IACnB,GAAG,QAAQ;IACX,GAAG,gBAAgB;IACnB,GAAG,MAAM;IACT,GAAG,OAAO;IACV,GAAG,QAAQ;IACX,GAAG,QAAQ;IACX,SAAS;CACV,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,GAAG,GAAG;IACN,GAAG,gBAAgB;IACnB,GAAG,QAAQ;IACX,GAAG,gBAAgB;IACnB,gBAAgB,EAAE,OAAO,CAAC,gBAAgB;CAC3C,CAAC;AAEF,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,GAAG,MAAM;IACT,mBAAmB,EAAE,OAAO,CAAC,mBAAmB;CACjD,CAAC;AAEF,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,GAAG,QAAQ;CACZ,CAAC"}
|
package/_esm/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const version = "1.
|
|
1
|
+
export const version = "1.12.0";
|
|
2
2
|
//# sourceMappingURL=version.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toEvmServerAccount.d.ts","sourceRoot":"","sources":["../../../accounts/evm/toEvmServerAccount.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"toEvmServerAccount.d.ts","sourceRoot":"","sources":["../../../accounts/evm/toEvmServerAccount.ts"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAYnD,OAAO,KAAK,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAGtF;;GAEG;AACH,MAAM,MAAM,yBAAyB,GAAG;IACtC,kDAAkD;IAClD,OAAO,EAAE,UAAU,CAAC;CACrB,CAAC;AAEF;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,oBAAoB,EAC/B,OAAO,EAAE,yBAAyB,GACjC,gBAAgB,CAwFlB"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { CreateSwapQuoteOptions, CreateSwapQuoteResult, SwapUnavailableResult } from "../../../client/evm/evm.types.js";
|
|
2
|
+
import { CdpOpenApiClientType } from "../../../openapi-client/index.js";
|
|
3
|
+
/**
|
|
4
|
+
* Creates a quote for a swap between two tokens on an EVM network.
|
|
5
|
+
*
|
|
6
|
+
* @param {CdpOpenApiClientType} client - The client to use to create the swap quote.
|
|
7
|
+
* @param {CreateSwapQuoteOptions} options - The options for creating a swap quote.
|
|
8
|
+
*
|
|
9
|
+
* @returns {Promise<CreateSwapQuoteResult | SwapUnavailableResult>} A promise that resolves to the swap quote result or a response indicating that liquidity is unavailable.
|
|
10
|
+
*
|
|
11
|
+
* @example **Creating a swap quote**
|
|
12
|
+
* ```ts
|
|
13
|
+
* const swapQuote = await createSwapQuote(client, {
|
|
14
|
+
* network: "ethereum",
|
|
15
|
+
* toToken: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC
|
|
16
|
+
* fromToken: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", // WETH
|
|
17
|
+
* fromAmount: BigInt("1000000000000000000"), // 1 WETH in wei
|
|
18
|
+
* taker: "0x1234567890123456789012345678901234567890"
|
|
19
|
+
* });
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare function createSwapQuote(client: CdpOpenApiClientType, options: CreateSwapQuoteOptions): Promise<CreateSwapQuoteResult | SwapUnavailableResult>;
|
|
23
|
+
//# sourceMappingURL=createSwapQuote.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createSwapQuote.d.ts","sourceRoot":"","sources":["../../../../actions/evm/swap/createSwapQuote.ts"],"names":[],"mappings":"AACA,OAAO,EACL,sBAAsB,EACtB,qBAAqB,EAGrB,qBAAqB,EACtB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACL,oBAAoB,EAGrB,MAAM,kCAAkC,CAAC;AAG1C;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,oBAAoB,EAC5B,OAAO,EAAE,sBAAsB,GAC9B,OAAO,CAAC,qBAAqB,GAAG,qBAAqB,CAAC,CA8GxD"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { GetSwapPriceOptions, GetSwapPriceResult, SwapUnavailableResult } from "../../../client/evm/evm.types.js";
|
|
2
|
+
import { CdpOpenApiClientType } from "../../../openapi-client/index.js";
|
|
3
|
+
/**
|
|
4
|
+
* Gets the price for a swap between two tokens on an EVM network.
|
|
5
|
+
*
|
|
6
|
+
* @param {CdpOpenApiClientType} client - The client to use to get the swap price.
|
|
7
|
+
* @param {GetSwapPriceOptions} options - The options for getting a swap price.
|
|
8
|
+
*
|
|
9
|
+
* @returns {Promise<GetSwapPriceResult | SwapUnavailableResult>} A promise that resolves to the swap price result or a response indicating that liquidity is unavailable.
|
|
10
|
+
*
|
|
11
|
+
* @example **Getting a swap price**
|
|
12
|
+
* ```ts
|
|
13
|
+
* const price = await getSwapPrice(client, {
|
|
14
|
+
* network: "ethereum-mainnet",
|
|
15
|
+
* toToken: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC
|
|
16
|
+
* fromToken: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", // WETH
|
|
17
|
+
* fromAmount: BigInt("1000000000000000000"), // 1 WETH in wei
|
|
18
|
+
* taker: "0x1234567890123456789012345678901234567890"
|
|
19
|
+
* });
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare function getSwapPrice(client: CdpOpenApiClientType, options: GetSwapPriceOptions): Promise<GetSwapPriceResult | SwapUnavailableResult>;
|
|
23
|
+
//# sourceMappingURL=getSwapPrice.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getSwapPrice.d.ts","sourceRoot":"","sources":["../../../../actions/evm/swap/getSwapPrice.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,qBAAqB,EACtB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,oBAAoB,EAAwB,MAAM,kCAAkC,CAAC;AAG9F;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,YAAY,CAChC,MAAM,EAAE,oBAAoB,EAC5B,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,kBAAkB,GAAG,qBAAqB,CAAC,CAgErD"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { SendSwapTransactionOptions, SendSwapTransactionResult } from "./types.js";
|
|
2
|
+
import type { CdpOpenApiClientType } from "../../../openapi-client/index.js";
|
|
3
|
+
/**
|
|
4
|
+
* Sends a swap transaction to the blockchain.
|
|
5
|
+
* Handles any permit2 signatures required for the swap.
|
|
6
|
+
*
|
|
7
|
+
* If you encounter token allowance issues, you'll need to perform a token approval transaction first to allow
|
|
8
|
+
* the Permit2 contract to spend the appropriate amount of your fromToken.
|
|
9
|
+
* See `examples/typescript/evm/account.sendSwapTransaction.ts` for example code on handling token approvals.
|
|
10
|
+
*
|
|
11
|
+
* @param {CdpOpenApiClientType} client - The client to use for sending the swap.
|
|
12
|
+
* @param {SendSwapTransactionOptions} options - The options for the swap submission.
|
|
13
|
+
*
|
|
14
|
+
* @returns {Promise<SendSwapTransactionResult>} A promise that resolves to the transaction hash.
|
|
15
|
+
*
|
|
16
|
+
* @throws {Error} If liquidity is not available for the swap.
|
|
17
|
+
* @throws {Error} If there are insufficient token allowances. In this case, you need to approve the
|
|
18
|
+
* Permit2 contract to spend your tokens before attempting the swap. The error message
|
|
19
|
+
* will include the current allowance and the spender address that needs approval.
|
|
20
|
+
* @throws {Error} If no transaction data is found in the swap result.
|
|
21
|
+
*
|
|
22
|
+
* @example **Sending a swap with pre-created swap quote object**
|
|
23
|
+
* ```ts
|
|
24
|
+
* // First create a swap quote
|
|
25
|
+
* const swapQuote = await cdp.evm.createSwapQuote({
|
|
26
|
+
* network: "base",
|
|
27
|
+
* toToken: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC
|
|
28
|
+
* fromToken: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", // WETH
|
|
29
|
+
* fromAmount: BigInt("1000000000000000000"), // 1 WETH in wei
|
|
30
|
+
* taker: account.address
|
|
31
|
+
* });
|
|
32
|
+
*
|
|
33
|
+
* // Check if liquidity is available
|
|
34
|
+
* if (!swapQuote.liquidityAvailable) {
|
|
35
|
+
* console.error("Insufficient liquidity for swap");
|
|
36
|
+
* return;
|
|
37
|
+
* }
|
|
38
|
+
*
|
|
39
|
+
* // Send the swap
|
|
40
|
+
* const result = await sendSwapTransaction(client, {
|
|
41
|
+
* address: account.address,
|
|
42
|
+
* swapQuote: swapQuote
|
|
43
|
+
* });
|
|
44
|
+
*
|
|
45
|
+
* console.log(`Swap sent with transaction hash: ${result.transactionHash}`);
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* @example **Sending a swap with inline options (all-in-one)**
|
|
49
|
+
* ```ts
|
|
50
|
+
* // Send swap in one call
|
|
51
|
+
* const result = await sendSwapTransaction(client, {
|
|
52
|
+
* address: account.address,
|
|
53
|
+
* network: "base",
|
|
54
|
+
* toToken: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC
|
|
55
|
+
* fromToken: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", // WETH
|
|
56
|
+
* fromAmount: BigInt("1000000000000000000"), // 1 WETH in wei
|
|
57
|
+
* taker: account.address
|
|
58
|
+
* });
|
|
59
|
+
*
|
|
60
|
+
* console.log(`Swap sent with transaction hash: ${result.transactionHash}`);
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
export declare function sendSwapTransaction(client: CdpOpenApiClientType, options: SendSwapTransactionOptions): Promise<SendSwapTransactionResult>;
|
|
64
|
+
//# sourceMappingURL=sendSwapTransaction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sendSwapTransaction.d.ts","sourceRoot":"","sources":["../../../../actions/evm/swap/sendSwapTransaction.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,0BAA0B,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAMxF,OAAO,KAAK,EACV,oBAAoB,EAErB,MAAM,kCAAkC,CAAC;AAI1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DG;AACH,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,oBAAoB,EAC5B,OAAO,EAAE,0BAA0B,GAClC,OAAO,CAAC,yBAAyB,CAAC,CA2FpC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { CreateSwapQuoteOptions, CreateSwapQuoteResult, SwapUnavailableResult } from "../../../client/evm/evm.types.js";
|
|
2
|
+
import type { SendEvmTransactionBodyNetwork } from "../../../openapi-client/index.js";
|
|
3
|
+
import type { Address, Hex } from "../../../types/misc.js";
|
|
4
|
+
/**
|
|
5
|
+
* Base options for sending a swap transaction.
|
|
6
|
+
*/
|
|
7
|
+
interface BaseSendSwapTransactionOptions {
|
|
8
|
+
/**
|
|
9
|
+
* The address of the account that will execute the swap.
|
|
10
|
+
*/
|
|
11
|
+
address: Address;
|
|
12
|
+
/**
|
|
13
|
+
* Optional idempotency key for the request.
|
|
14
|
+
*/
|
|
15
|
+
idempotencyKey?: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Options when providing an already created swap quote.
|
|
19
|
+
*/
|
|
20
|
+
interface QuoteBasedSendSwapTransactionOptions extends BaseSendSwapTransactionOptions {
|
|
21
|
+
/**
|
|
22
|
+
* The swap quote returned by the createSwapQuote method.
|
|
23
|
+
*/
|
|
24
|
+
swapQuote: CreateSwapQuoteResult;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Options when creating a swap quote inline.
|
|
28
|
+
*/
|
|
29
|
+
interface InlineSendSwapTransactionOptions extends BaseSendSwapTransactionOptions {
|
|
30
|
+
/**
|
|
31
|
+
* The network to execute the swap on (e.g., "ethereum", "base").
|
|
32
|
+
*/
|
|
33
|
+
network: SendEvmTransactionBodyNetwork;
|
|
34
|
+
/** The token to receive (destination token). */
|
|
35
|
+
toToken: Address;
|
|
36
|
+
/** The token to send (source token). */
|
|
37
|
+
fromToken: Address;
|
|
38
|
+
/** The amount to send in atomic units of the token. */
|
|
39
|
+
fromAmount: bigint;
|
|
40
|
+
/** The address that will perform the swap. */
|
|
41
|
+
taker: Address;
|
|
42
|
+
/** The signer address (only needed if taker is a smart contract). */
|
|
43
|
+
signerAddress?: Address;
|
|
44
|
+
/** The gas price in Wei. */
|
|
45
|
+
gasPrice?: bigint;
|
|
46
|
+
/** The slippage tolerance in basis points (0-10000). */
|
|
47
|
+
slippageBps?: number;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Options for sending a swap transaction.
|
|
51
|
+
* Either provide a pre-created swap quote result or inline swap parameters.
|
|
52
|
+
*/
|
|
53
|
+
export type SendSwapTransactionOptions = QuoteBasedSendSwapTransactionOptions | InlineSendSwapTransactionOptions;
|
|
54
|
+
/**
|
|
55
|
+
* Result of sending a swap transaction.
|
|
56
|
+
*/
|
|
57
|
+
export interface SendSwapTransactionResult {
|
|
58
|
+
/**
|
|
59
|
+
* The transaction hash of the submitted swap.
|
|
60
|
+
*/
|
|
61
|
+
transactionHash: Hex;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Options for creating a swap quote (account-level).
|
|
65
|
+
*/
|
|
66
|
+
export type QuoteSwapOptions = Omit<CreateSwapQuoteOptions, "taker">;
|
|
67
|
+
/**
|
|
68
|
+
* Result of creating a swap quote (account-level).
|
|
69
|
+
*/
|
|
70
|
+
export type QuoteSwapResult = CreateSwapQuoteResult | SwapUnavailableResult;
|
|
71
|
+
/**
|
|
72
|
+
* Options for executing a token swap (account-level).
|
|
73
|
+
*/
|
|
74
|
+
export type SwapOptions = Omit<SendSwapTransactionOptions, "address">;
|
|
75
|
+
/**
|
|
76
|
+
* Result of executing a token swap (account-level).
|
|
77
|
+
*/
|
|
78
|
+
export type SwapResult = SendSwapTransactionResult;
|
|
79
|
+
export {};
|
|
80
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../actions/evm/swap/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,sBAAsB,EACtB,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,kCAAkC,CAAC;AACtF,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,wBAAwB,CAAC;AAE3D;;GAEG;AACH,UAAU,8BAA8B;IACtC;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;IAEjB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,UAAU,oCAAqC,SAAQ,8BAA8B;IACnF;;OAEG;IACH,SAAS,EAAE,qBAAqB,CAAC;CAClC;AAED;;GAEG;AACH,UAAU,gCAAiC,SAAQ,8BAA8B;IAC/E;;OAEG;IACH,OAAO,EAAE,6BAA6B,CAAC;IACvC,gDAAgD;IAChD,OAAO,EAAE,OAAO,CAAC;IACjB,wCAAwC;IACxC,SAAS,EAAE,OAAO,CAAC;IACnB,uDAAuD;IACvD,UAAU,EAAE,MAAM,CAAC;IACnB,8CAA8C;IAC9C,KAAK,EAAE,OAAO,CAAC;IACf,qEAAqE;IACrE,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,4BAA4B;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,wDAAwD;IACxD,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;GAGG;AACH,MAAM,MAAM,0BAA0B,GAClC,oCAAoC,GACpC,gCAAgC,CAAC;AAErC;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC;;OAEG;IACH,eAAe,EAAE,GAAG,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,IAAI,CAAC,sBAAsB,EAAE,OAAO,CAAC,CAAC;AAErE;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,qBAAqB,GAAG,qBAAqB,CAAC;AAE5E;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,IAAI,CAAC,0BAA0B,EAAE,SAAS,CAAC,CAAC;AAEtE;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,yBAAyB,CAAC"}
|
|
@@ -9,6 +9,7 @@ import { Hex } from "../../types/misc.js";
|
|
|
9
9
|
import type { ListTokenBalancesOptions, ListTokenBalancesResult } from "./listTokenBalances.js";
|
|
10
10
|
import type { RequestFaucetOptions, RequestFaucetResult } from "./requestFaucet.js";
|
|
11
11
|
import type { SendTransactionOptions, TransactionResult } from "./sendTransaction.js";
|
|
12
|
+
import type { SwapOptions, SwapResult, QuoteSwapOptions, QuoteSwapResult } from "./swap/types.js";
|
|
12
13
|
import type { TransferOptions } from "./transfer/types.js";
|
|
13
14
|
import type { WaitForUserOperationOptions, WaitForUserOperationReturnType } from "./waitForUserOperation.js";
|
|
14
15
|
type Actions = {
|
|
@@ -233,6 +234,91 @@ export type AccountActions = Actions & {
|
|
|
233
234
|
* ```
|
|
234
235
|
*/
|
|
235
236
|
sendTransaction: (options: Omit<SendTransactionOptions, "address">) => Promise<TransactionResult>;
|
|
237
|
+
/**
|
|
238
|
+
* Creates a swap quote without executing the transaction.
|
|
239
|
+
* This is useful when you need to get swap details before executing the swap.
|
|
240
|
+
* The taker is automatically set to the account's address.
|
|
241
|
+
*
|
|
242
|
+
* @param {QuoteSwapOptions} options - Configuration options for creating the swap quote.
|
|
243
|
+
* @param {string} options.network - The network to create the quote on
|
|
244
|
+
* @param {string} options.fromToken - The token address to sell
|
|
245
|
+
* @param {string} options.toToken - The token address to buy
|
|
246
|
+
* @param {bigint} options.fromAmount - The amount of fromToken to sell
|
|
247
|
+
* @param {string} [options.signerAddress] - The signer address (only needed if taker is a smart contract)
|
|
248
|
+
* @param {bigint} [options.gasPrice] - The gas price in Wei
|
|
249
|
+
* @param {number} [options.slippageBps] - The slippage tolerance in basis points (0-10000)
|
|
250
|
+
*
|
|
251
|
+
* @returns A promise that resolves to the swap quote or a response indicating that liquidity is unavailable.
|
|
252
|
+
*
|
|
253
|
+
* @example
|
|
254
|
+
* ```ts
|
|
255
|
+
* const swapQuote = await account.quoteSwap({
|
|
256
|
+
* network: "base",
|
|
257
|
+
* fromToken: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", // WETH
|
|
258
|
+
* toToken: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC
|
|
259
|
+
* fromAmount: BigInt("1000000000000000000"), // 1 WETH in wei
|
|
260
|
+
* });
|
|
261
|
+
*
|
|
262
|
+
* if (swapQuote.liquidityAvailable) {
|
|
263
|
+
* console.log(`Can swap for ${swapQuote.toAmount} USDC`);
|
|
264
|
+
* }
|
|
265
|
+
* ```
|
|
266
|
+
*/
|
|
267
|
+
quoteSwap: (options: QuoteSwapOptions) => Promise<QuoteSwapResult>;
|
|
268
|
+
/**
|
|
269
|
+
* Executes a token swap on the specified network.
|
|
270
|
+
* This method handles all the steps required for a swap, including Permit2 signatures if needed.
|
|
271
|
+
*
|
|
272
|
+
* @param {SwapOptions} options - Configuration options for the swap.
|
|
273
|
+
* @param {string} [options.network] - The network to execute the swap on
|
|
274
|
+
* @param {CreateSwapQuoteResult} [options.swapQuote] - The swap quote returned by the createSwapQuote method.
|
|
275
|
+
* @param {CreateSwapQuoteOptions} [options.swapOptions] - Options to create a swap quote. The function will call createSwapQuote internally.
|
|
276
|
+
* @param {string} [options.idempotencyKey] - Optional idempotency key for the request.
|
|
277
|
+
*
|
|
278
|
+
* @returns A promise that resolves to the transaction hash.
|
|
279
|
+
*
|
|
280
|
+
* @throws {Error} If liquidity is not available when using swapOptions.
|
|
281
|
+
*
|
|
282
|
+
* @example **Using a pre-created swap quote**
|
|
283
|
+
* ```ts
|
|
284
|
+
* // First create a swap quote
|
|
285
|
+
* const swapQuote = await cdp.evm.createSwapQuote({
|
|
286
|
+
* network: "base",
|
|
287
|
+
* buyToken: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC
|
|
288
|
+
* sellToken: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", // WETH
|
|
289
|
+
* sellAmount: BigInt("1000000000000000000"), // 1 WETH in wei
|
|
290
|
+
* taker: account.address
|
|
291
|
+
* });
|
|
292
|
+
*
|
|
293
|
+
* // Check if liquidity is available
|
|
294
|
+
* if (!swapQuote.liquidityAvailable) {
|
|
295
|
+
* console.error("Insufficient liquidity for swap");
|
|
296
|
+
* return;
|
|
297
|
+
* }
|
|
298
|
+
*
|
|
299
|
+
* // Execute the swap
|
|
300
|
+
* const { transactionHash } = await account.swap({
|
|
301
|
+
* swapQuote: swapQuote
|
|
302
|
+
* });
|
|
303
|
+
*
|
|
304
|
+
* console.log(`Swap executed with transaction hash: ${transactionHash}`);
|
|
305
|
+
* ```
|
|
306
|
+
*
|
|
307
|
+
* @example **Using swap options (all-in-one)**
|
|
308
|
+
* ```ts
|
|
309
|
+
* // Create and execute swap in one call
|
|
310
|
+
* const { transactionHash } = await account.swap({
|
|
311
|
+
* network: "base",
|
|
312
|
+
* buyToken: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC
|
|
313
|
+
* sellToken: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", // WETH
|
|
314
|
+
* sellAmount: BigInt("1000000000000000000"), // 1 WETH in wei
|
|
315
|
+
* taker: account.address
|
|
316
|
+
* });
|
|
317
|
+
*
|
|
318
|
+
* console.log(`Swap executed with transaction hash: ${transactionHash}`);
|
|
319
|
+
* ```
|
|
320
|
+
*/
|
|
321
|
+
swap: (options: SwapOptions) => Promise<SwapResult>;
|
|
236
322
|
};
|
|
237
323
|
export type SmartAccountActions = Actions & {
|
|
238
324
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../actions/evm/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EACL,2BAA2B,EAC3B,0BAA0B,EAC3B,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,wBAAwB,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAC/F,OAAO,EAAE,uBAAuB,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACvF,OAAO,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAE1C,OAAO,KAAK,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAChG,OAAO,KAAK,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,oBA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;;;;;;;;;;;;;;OAoDG;IACH,IAAI,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;CACrD,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG,OAAO,GAAG;IAC1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2EG;IACH,QAAQ,EAAE,CAAC,OAAO,EAAE,eAAe,KAAK,OAAO,CAAC,2BAA2B,CAAC,CAAC;IAE7E;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,iBAAiB,EAAE,CACjB,OAAO,EAAE,IAAI,CAAC,wBAAwB,CAAC,OAAO,EAAE,CAAC,EAAE,cAAc,CAAC,KAC/D,OAAO,CAAC,2BAA2B,CAAC,CAAC;IAE1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACH,oBAAoB,EAAE,CACpB,OAAO,EAAE,IAAI,CAAC,2BAA2B,EAAE,qBAAqB,CAAC,KAC9D,OAAO,CAAC,8BAA8B,CAAC,CAAC;IAE7C;;;;;;;;;;;;;;OAcG;IACH,gBAAgB,EAAE,CAChB,OAAO,EAAE,IAAI,CAAC,uBAAuB,EAAE,cAAc,CAAC,KACnD,OAAO,CAAC,aAAa,CAAC,CAAC;CAC7B,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CreateServerAccountOptions, GetServerAccountOptions, ListServerAccountsOptions, CreateSmartAccountOptions, WaitForUserOperationOptions, SignHashOptions, SignatureResult, SignMessageOptions, SignTransactionOptions, GetSmartAccountOptions, SmartAccount, ServerAccount, EvmClientInterface, ListServerAccountResult, PrepareUserOperationOptions, UserOperation, GetUserOperationOptions, ListSmartAccountResult, ListSmartAccountsOptions, GetOrCreateServerAccountOptions, SignTypedDataOptions, UpdateEvmAccountOptions, ImportServerAccountOptions } from "./evm.types.js";
|
|
1
|
+
import { CreateServerAccountOptions, GetServerAccountOptions, ListServerAccountsOptions, CreateSmartAccountOptions, WaitForUserOperationOptions, SignHashOptions, SignatureResult, SignMessageOptions, SignTransactionOptions, GetSmartAccountOptions, SmartAccount, ServerAccount, EvmClientInterface, ListServerAccountResult, PrepareUserOperationOptions, UserOperation, GetUserOperationOptions, ListSmartAccountResult, ListSmartAccountsOptions, GetOrCreateServerAccountOptions, SignTypedDataOptions, UpdateEvmAccountOptions, ImportServerAccountOptions, GetSwapPriceOptions, CreateSwapQuoteOptions, GetSwapPriceResult, CreateSwapQuoteResult, SwapUnavailableResult } from "./evm.types.js";
|
|
2
2
|
import { ListTokenBalancesResult, ListTokenBalancesOptions } from "../../actions/evm/listTokenBalances.js";
|
|
3
3
|
import { RequestFaucetOptions, RequestFaucetResult } from "../../actions/evm/requestFaucet.js";
|
|
4
4
|
import { SendUserOperationOptions, SendUserOperationReturnType } from "../../actions/evm/sendUserOperation.js";
|
|
@@ -194,6 +194,44 @@ export declare class EvmClient implements EvmClientInterface {
|
|
|
194
194
|
* ```
|
|
195
195
|
*/
|
|
196
196
|
getOrCreateAccount(options: GetOrCreateServerAccountOptions): Promise<ServerAccount>;
|
|
197
|
+
/**
|
|
198
|
+
* Gets the price for a swap between two tokens on an EVM network.
|
|
199
|
+
*
|
|
200
|
+
* @param {GetSwapPriceOptions} options - The options for getting a swap price.
|
|
201
|
+
*
|
|
202
|
+
* @returns {Promise<GetSwapPriceResult | SwapUnavailableResult>} A promise that resolves to the swap price result or a response indicating that liquidity is unavailable.
|
|
203
|
+
*
|
|
204
|
+
* @example
|
|
205
|
+
* ```typescript
|
|
206
|
+
* const price = await cdp.evm.getSwapPrice({
|
|
207
|
+
* network: "ethereum-mainnet",
|
|
208
|
+
* toToken: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC
|
|
209
|
+
* fromToken: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", // WETH
|
|
210
|
+
* fromAmount: BigInt("1000000000000000000"), // 1 WETH
|
|
211
|
+
* taker: "0x1234567890123456789012345678901234567890"
|
|
212
|
+
* });
|
|
213
|
+
* ```
|
|
214
|
+
*/
|
|
215
|
+
getSwapPrice(options: GetSwapPriceOptions): Promise<GetSwapPriceResult | SwapUnavailableResult>;
|
|
216
|
+
/**
|
|
217
|
+
* Creates a quote for a swap between two tokens on an EVM network.
|
|
218
|
+
*
|
|
219
|
+
* @param {CreateSwapQuoteOptions} options - The options for creating a swap quote.
|
|
220
|
+
*
|
|
221
|
+
* @returns {Promise<CreateSwapQuoteResult | SwapUnavailableResult>} A promise that resolves to the swap quote result or a response indicating that liquidity is unavailable.
|
|
222
|
+
*
|
|
223
|
+
* @example
|
|
224
|
+
* ```typescript
|
|
225
|
+
* const swapQuote = await cdp.evm.createSwapQuote({
|
|
226
|
+
* network: "ethereum",
|
|
227
|
+
* toToken: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC
|
|
228
|
+
* fromToken: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", // WETH
|
|
229
|
+
* fromAmount: BigInt("1000000000000000000"), // 1 WETH
|
|
230
|
+
* taker: "0x1234567890123456789012345678901234567890"
|
|
231
|
+
* });
|
|
232
|
+
* ```
|
|
233
|
+
*/
|
|
234
|
+
createSwapQuote(options: CreateSwapQuoteOptions): Promise<CreateSwapQuoteResult | SwapUnavailableResult>;
|
|
197
235
|
/**
|
|
198
236
|
* Gets a user operation for a smart account by user operation hash.
|
|
199
237
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evm.d.ts","sourceRoot":"","sources":["../../../client/evm/evm.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,0BAA0B,EAC1B,uBAAuB,EACvB,yBAAyB,EACzB,yBAAyB,EACzB,2BAA2B,EAC3B,eAAe,EACf,eAAe,EACf,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,EACtB,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,uBAAuB,EACvB,2BAA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