@coinbase/cdp-sdk 1.10.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 +14 -0
- package/README.md +137 -0
- package/_cjs/accounts/evm/toEvmServerAccount.js +32 -0
- package/_cjs/accounts/evm/toEvmServerAccount.js.map +1 -1
- package/_cjs/accounts/evm/toEvmSmartAccount.js +18 -0
- package/_cjs/accounts/evm/toEvmSmartAccount.js.map +1 -1
- package/_cjs/actions/evm/fund/Quote.js +63 -0
- package/_cjs/actions/evm/fund/Quote.js.map +1 -0
- package/_cjs/actions/evm/fund/fund.js +49 -0
- package/_cjs/actions/evm/fund/fund.js.map +1 -0
- package/_cjs/actions/evm/fund/quoteFund.js +46 -0
- package/_cjs/actions/evm/fund/quoteFund.js.map +1 -0
- package/_cjs/actions/evm/fund/types.js +3 -0
- package/_cjs/actions/evm/fund/types.js.map +1 -0
- package/_cjs/actions/evm/fund/waitForFundOperationReceipt.js +64 -0
- package/_cjs/actions/evm/fund/waitForFundOperationReceipt.js.map +1 -0
- 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 +47 -1
- package/_cjs/client/evm/evm.js.map +1 -1
- package/_cjs/client/solana/solana.js +4 -1
- package/_cjs/client/solana/solana.js.map +1 -1
- package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +45 -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 -3
- package/_cjs/openapi-client/generated/index.msw.js.map +1 -1
- package/_cjs/openapi-client/generated/payments-alpha/payments-alpha.js +50 -0
- package/_cjs/openapi-client/generated/payments-alpha/payments-alpha.js.map +1 -0
- package/_cjs/openapi-client/generated/payments-alpha/payments-alpha.msw.js +270 -0
- package/_cjs/openapi-client/generated/payments-alpha/payments-alpha.msw.js.map +1 -0
- package/_cjs/openapi-client/index.js +7 -0
- package/_cjs/openapi-client/index.js.map +1 -1
- package/_cjs/version.js +1 -1
- package/_esm/accounts/evm/toEvmServerAccount.js +32 -0
- package/_esm/accounts/evm/toEvmServerAccount.js.map +1 -1
- package/_esm/accounts/evm/toEvmSmartAccount.js +18 -0
- package/_esm/accounts/evm/toEvmSmartAccount.js.map +1 -1
- package/_esm/actions/evm/fund/Quote.js +59 -0
- package/_esm/actions/evm/fund/Quote.js.map +1 -0
- package/_esm/actions/evm/fund/fund.js +46 -0
- package/_esm/actions/evm/fund/fund.js.map +1 -0
- package/_esm/actions/evm/fund/quoteFund.js +43 -0
- package/_esm/actions/evm/fund/quoteFund.js.map +1 -0
- package/_esm/actions/evm/fund/types.js +2 -0
- package/_esm/actions/evm/fund/types.js.map +1 -0
- package/_esm/actions/evm/fund/waitForFundOperationReceipt.js +61 -0
- package/_esm/actions/evm/fund/waitForFundOperationReceipt.js.map +1 -0
- 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 +47 -1
- package/_esm/client/evm/evm.js.map +1 -1
- package/_esm/client/solana/solana.js +4 -1
- package/_esm/client/solana/solana.js.map +1 -1
- package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +44 -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 -3
- package/_esm/openapi-client/generated/index.msw.js.map +1 -1
- package/_esm/openapi-client/generated/payments-alpha/payments-alpha.js +42 -0
- package/_esm/openapi-client/generated/payments-alpha/payments-alpha.js.map +1 -0
- package/_esm/openapi-client/generated/payments-alpha/payments-alpha.msw.js +250 -0
- package/_esm/openapi-client/generated/payments-alpha/payments-alpha.msw.js.map +1 -0
- package/_esm/openapi-client/index.js +7 -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/accounts/evm/toEvmSmartAccount.d.ts.map +1 -1
- package/_types/accounts/evm/types.d.ts +1 -2
- package/_types/accounts/evm/types.d.ts.map +1 -1
- package/_types/actions/evm/fund/Quote.d.ts +51 -0
- package/_types/actions/evm/fund/Quote.d.ts.map +1 -0
- package/_types/actions/evm/fund/fund.d.ts +25 -0
- package/_types/actions/evm/fund/fund.d.ts.map +1 -0
- package/_types/actions/evm/fund/quoteFund.d.ts +25 -0
- package/_types/actions/evm/fund/quoteFund.d.ts.map +1 -0
- package/_types/actions/evm/fund/types.d.ts +16 -0
- package/_types/actions/evm/fund/types.d.ts.map +1 -0
- package/_types/actions/evm/fund/waitForFundOperationReceipt.d.ts +68 -0
- package/_types/actions/evm/fund/waitForFundOperationReceipt.d.ts.map +1 -0
- 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 +151 -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 +209 -3
- package/_types/client/evm/evm.types.d.ts.map +1 -1
- package/_types/client/solana/solana.d.ts.map +1 -1
- package/_types/client/solana/solana.types.d.ts +2 -0
- package/_types/client/solana/solana.types.d.ts.map +1 -1
- package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts +547 -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 -3
- package/_types/openapi-client/generated/index.msw.d.ts.map +1 -1
- package/_types/openapi-client/generated/payments-alpha/payments-alpha.d.ts +42 -0
- package/_types/openapi-client/generated/payments-alpha/payments-alpha.d.ts.map +1 -0
- package/_types/openapi-client/generated/payments-alpha/payments-alpha.msw.d.ts +20 -0
- package/_types/openapi-client/generated/payments-alpha/payments-alpha.msw.d.ts.map +1 -0
- package/_types/openapi-client/index.d.ts +11 -0
- package/_types/openapi-client/index.d.ts.map +1 -1
- package/_types/types/misc.d.ts +2 -2
- package/_types/types/misc.d.ts.map +1 -1
- package/_types/version.d.ts +1 -1
- package/accounts/evm/toEvmServerAccount.ts +47 -0
- package/accounts/evm/toEvmSmartAccount.ts +26 -0
- package/accounts/evm/types.ts +1 -2
- package/actions/evm/fund/Quote.ts +83 -0
- package/actions/evm/fund/fund.ts +76 -0
- package/actions/evm/fund/quoteFund.ts +81 -0
- package/actions/evm/fund/types.ts +16 -0
- package/actions/evm/fund/waitForFundOperationReceipt.ts +118 -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 +161 -0
- package/client/evm/evm.ts +59 -1
- package/client/evm/evm.types.ts +227 -1
- package/client/solana/solana.ts +4 -1
- package/client/solana/solana.types.ts +2 -0
- package/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.ts +617 -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 -3
- package/openapi-client/generated/payments-alpha/payments-alpha.msw.ts +369 -0
- package/openapi-client/generated/payments-alpha/payments-alpha.ts +96 -0
- package/openapi-client/index.ts +7 -0
- package/package.json +1 -1
- package/types/misc.ts +2 -2
- package/version.ts +1 -1
|
@@ -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"}
|
|
@@ -1,9 +1,15 @@
|
|
|
1
|
+
import { FundOptions } from "./fund/fund.js";
|
|
2
|
+
import { Quote } from "./fund/Quote.js";
|
|
3
|
+
import { QuoteFundOptions } from "./fund/quoteFund.js";
|
|
4
|
+
import { FundOperationResult } from "./fund/types.js";
|
|
5
|
+
import { WaitForFundOperationOptions, WaitForFundOperationResult } from "./fund/waitForFundOperationReceipt.js";
|
|
1
6
|
import { SendUserOperationOptions, SendUserOperationReturnType } from "./sendUserOperation.js";
|
|
2
7
|
import { GetUserOperationOptions, UserOperation } from "../../client/evm/evm.types.js";
|
|
3
8
|
import { Hex } from "../../types/misc.js";
|
|
4
9
|
import type { ListTokenBalancesOptions, ListTokenBalancesResult } from "./listTokenBalances.js";
|
|
5
10
|
import type { RequestFaucetOptions, RequestFaucetResult } from "./requestFaucet.js";
|
|
6
11
|
import type { SendTransactionOptions, TransactionResult } from "./sendTransaction.js";
|
|
12
|
+
import type { SwapOptions, SwapResult, QuoteSwapOptions, QuoteSwapResult } from "./swap/types.js";
|
|
7
13
|
import type { TransferOptions } from "./transfer/types.js";
|
|
8
14
|
import type { WaitForUserOperationOptions, WaitForUserOperationReturnType } from "./waitForUserOperation.js";
|
|
9
15
|
type Actions = {
|
|
@@ -42,6 +48,66 @@ type Actions = {
|
|
|
42
48
|
* ```
|
|
43
49
|
*/
|
|
44
50
|
requestFaucet: (options: Omit<RequestFaucetOptions, "address">) => Promise<RequestFaucetResult>;
|
|
51
|
+
/**
|
|
52
|
+
* Gets a quote to fund an EVM account.
|
|
53
|
+
*
|
|
54
|
+
* @param options - The options for the quote fund.
|
|
55
|
+
* @param options.network - The network to fund the account on.
|
|
56
|
+
* @param options.token - The token to fund the account with.
|
|
57
|
+
* @param options.amount - The amount of the token to fund represented as an atomic unit.
|
|
58
|
+
* It's common to use `parseUnits` utils from viem to convert to atomic units.
|
|
59
|
+
* Otherwise, you can pass atomic units directly.
|
|
60
|
+
*
|
|
61
|
+
* @returns A promise that resolves to a Quote object containing details about the funding operation.
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```ts
|
|
65
|
+
* const quote = await account.quoteFund({
|
|
66
|
+
* network: "base",
|
|
67
|
+
* token: "usdc",
|
|
68
|
+
* amount: 1000000n,
|
|
69
|
+
* });
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
quoteFund: (options: Omit<QuoteFundOptions, "address">) => Promise<Quote>;
|
|
73
|
+
/**
|
|
74
|
+
* Funds an EVM account with the specified token amount.
|
|
75
|
+
*
|
|
76
|
+
* @param options - The options for the fund operation.
|
|
77
|
+
* @param options.network - The network to fund the account on.
|
|
78
|
+
* @param options.token - The token to fund the account with (e.g., 'usdc').
|
|
79
|
+
* @param options.amount - The amount of the token to fund represented as an atomic unit.
|
|
80
|
+
* It's common to use `parseUnits` utils from viem to convert to atomic units.
|
|
81
|
+
* Otherwise, you can pass atomic units directly.
|
|
82
|
+
*
|
|
83
|
+
* @returns A promise that resolves to the fund operation result containing the transfer details.
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```ts
|
|
87
|
+
* const fundOperation = await account.fund({
|
|
88
|
+
* network: "base",
|
|
89
|
+
* token: "usdc",
|
|
90
|
+
* amount: 1000000n,
|
|
91
|
+
* });
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
94
|
+
fund: (options: Omit<FundOptions, "address">) => Promise<FundOperationResult>;
|
|
95
|
+
/**
|
|
96
|
+
* Waits for a fund operation to complete and returns the transfer receipt.
|
|
97
|
+
*
|
|
98
|
+
* @param options - The options for the wait for fund operation.
|
|
99
|
+
* @param options.transferId - The ID of the transfer to wait for.
|
|
100
|
+
*
|
|
101
|
+
* @returns A promise that resolves to the completed transfer receipt containing details about the funding operation.
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* ```ts
|
|
105
|
+
* const completedTransfer = await account.waitForFundOperationReceipt({
|
|
106
|
+
* transferId: "transfer_123",
|
|
107
|
+
* });
|
|
108
|
+
* ```
|
|
109
|
+
*/
|
|
110
|
+
waitForFundOperationReceipt(options: WaitForFundOperationOptions): Promise<WaitForFundOperationResult>;
|
|
45
111
|
};
|
|
46
112
|
export type AccountActions = Actions & {
|
|
47
113
|
/**
|
|
@@ -168,6 +234,91 @@ export type AccountActions = Actions & {
|
|
|
168
234
|
* ```
|
|
169
235
|
*/
|
|
170
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>;
|
|
171
322
|
};
|
|
172
323
|
export type SmartAccountActions = Actions & {
|
|
173
324
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../actions/evm/types.ts"],"names":[],"mappings":"AAAA,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,oBAAoB,CAAC;AACpF,OAAO,KAAK,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACtF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,EACV,2BAA2B,EAC3B,8BAA8B,EAC/B,MAAM,2BAA2B,CAAC;AAEnC,KAAK,OAAO,GAAG;IACb;;;;;;;;;;;;;;OAcG;IACH,iBAAiB,EAAE,CACjB,OAAO,EAAE,IAAI,CAAC,wBAAwB,EAAE,SAAS,CAAC,KAC/C,OAAO,CAAC,uBAAuB,CAAC,CAAC;IAEtC;;;;;;;;;;;;;;;;;OAiBG;IACH,aAAa,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,oBAAoB,EAAE,SAAS,CAAC,KAAK,OAAO,CAAC,mBAAmB,CAAC,CAAC;
|
|
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,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,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,2BAA2B,EAC3B,aAAa,EACb,uBAAuB,EACvB,sBAAsB,EACtB,wBAAwB,EACxB,+BAA+B,EAC/B,oBAAoB,EACpB,uBAAuB,EACvB,0BAA0B,
|
|
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,2BAA2B,EAC3B,aAAa,EACb,uBAAuB,EACvB,sBAA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