@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
package/client/evm/evm.types.ts
CHANGED
|
@@ -18,6 +18,7 @@ import type {
|
|
|
18
18
|
} from "../../actions/evm/sendUserOperation.js";
|
|
19
19
|
import type { SmartAccountActions } from "../../actions/evm/types.js";
|
|
20
20
|
import type {
|
|
21
|
+
EvmSwapsNetwork,
|
|
21
22
|
EvmUserOperationNetwork,
|
|
22
23
|
EvmUserOperationStatus,
|
|
23
24
|
OpenApiEvmMethods,
|
|
@@ -38,6 +39,8 @@ export type EvmClientInterface = Omit<
|
|
|
38
39
|
| "getEvmAccount" // mapped to getAccount
|
|
39
40
|
| "getEvmAccountByName" // mapped to getAccount
|
|
40
41
|
| "getEvmSmartAccount" // mapped to getSmartAccount
|
|
42
|
+
| "getEvmSwapPrice" // mapped to getSwapPrice
|
|
43
|
+
| "createEvmSwapQuote" // mapped to createSwapQuote
|
|
41
44
|
| "getUserOperation"
|
|
42
45
|
| "updateEvmAccount" // mapped to updateAccount
|
|
43
46
|
| "listEvmAccounts" // mapped to listAccounts
|
|
@@ -59,6 +62,12 @@ export type EvmClientInterface = Omit<
|
|
|
59
62
|
importAccount: (options: ImportServerAccountOptions) => Promise<ServerAccount>;
|
|
60
63
|
getAccount: (options: GetServerAccountOptions) => Promise<ServerAccount>;
|
|
61
64
|
getSmartAccount: (options: GetSmartAccountOptions) => Promise<SmartAccount>;
|
|
65
|
+
getSwapPrice: (
|
|
66
|
+
options: GetSwapPriceOptions,
|
|
67
|
+
) => Promise<GetSwapPriceResult | SwapUnavailableResult>;
|
|
68
|
+
createSwapQuote: (
|
|
69
|
+
options: CreateSwapQuoteOptions,
|
|
70
|
+
) => Promise<CreateSwapQuoteResult | SwapUnavailableResult>;
|
|
62
71
|
getOrCreateAccount: (options: GetOrCreateServerAccountOptions) => Promise<ServerAccount>;
|
|
63
72
|
getUserOperation: (options: GetUserOperationOptions) => Promise<UserOperation>;
|
|
64
73
|
updateAccount: (options: UpdateEvmAccountOptions) => Promise<ServerAccount>;
|
|
@@ -79,6 +88,153 @@ export type EvmClientInterface = Omit<
|
|
|
79
88
|
|
|
80
89
|
export type { ServerAccount, SmartAccount };
|
|
81
90
|
|
|
91
|
+
/**
|
|
92
|
+
* Options for creating a swap quote between two tokens on an EVM network.
|
|
93
|
+
*/
|
|
94
|
+
export interface CreateSwapQuoteOptions {
|
|
95
|
+
/** The network to create a swap quote on. */
|
|
96
|
+
network: EvmSwapsNetwork;
|
|
97
|
+
/** The token to receive (destination token). */
|
|
98
|
+
toToken: Address;
|
|
99
|
+
/** The token to send (source token). */
|
|
100
|
+
fromToken: Address;
|
|
101
|
+
/** The amount to send in atomic units of the token. */
|
|
102
|
+
fromAmount: bigint;
|
|
103
|
+
/** The address that will perform the swap. */
|
|
104
|
+
taker?: Address;
|
|
105
|
+
/** The signer address (only needed if taker is a smart contract). */
|
|
106
|
+
signerAddress?: Address;
|
|
107
|
+
/** The gas price in Wei. */
|
|
108
|
+
gasPrice?: bigint;
|
|
109
|
+
/** The slippage tolerance in basis points (0-10000). */
|
|
110
|
+
slippageBps?: number;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Options for getting a swap price.
|
|
115
|
+
*/
|
|
116
|
+
export interface GetSwapPriceOptions {
|
|
117
|
+
/** The network to get a price from. */
|
|
118
|
+
network: EvmSwapsNetwork;
|
|
119
|
+
/** The token to receive (destination token). */
|
|
120
|
+
toToken: Address;
|
|
121
|
+
/** The token to send (source token). */
|
|
122
|
+
fromToken: Address;
|
|
123
|
+
/** The amount to send in atomic units of the token. */
|
|
124
|
+
fromAmount: bigint;
|
|
125
|
+
/** The address that will perform the swap. */
|
|
126
|
+
taker: Address;
|
|
127
|
+
/** The signer address (only needed if taker is a smart contract). */
|
|
128
|
+
signerAddress?: Address;
|
|
129
|
+
/** The gas price in Wei. */
|
|
130
|
+
gasPrice?: bigint;
|
|
131
|
+
/** The slippage tolerance in basis points (0-10000). */
|
|
132
|
+
slippageBps?: number;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Result of getting a swap price.
|
|
137
|
+
*/
|
|
138
|
+
export interface GetSwapPriceResult {
|
|
139
|
+
/** Whether liquidity is available for the swap. */
|
|
140
|
+
liquidityAvailable: true;
|
|
141
|
+
/** The token to receive (destination token). */
|
|
142
|
+
toToken: Address;
|
|
143
|
+
/** The token to send (source token). */
|
|
144
|
+
fromToken: Address;
|
|
145
|
+
/** The amount to send in atomic units of the token. */
|
|
146
|
+
fromAmount: bigint;
|
|
147
|
+
/** The amount to receive in atomic units of the token. */
|
|
148
|
+
toAmount: bigint;
|
|
149
|
+
/** The minimum amount to receive after slippage in atomic units of the token. */
|
|
150
|
+
minToAmount: bigint;
|
|
151
|
+
/** The block number at which the liquidity conditions were examined. */
|
|
152
|
+
blockNumber: bigint;
|
|
153
|
+
/** The estimated fees for the swap. */
|
|
154
|
+
fees: SwapFees;
|
|
155
|
+
/** Potential issues discovered during validation. */
|
|
156
|
+
issues: SwapIssues;
|
|
157
|
+
/** The gas estimate for the swap. */
|
|
158
|
+
gas?: bigint;
|
|
159
|
+
/** The gas price in Wei. */
|
|
160
|
+
gasPrice?: bigint;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Result when liquidity is unavailable for a swap.
|
|
165
|
+
*/
|
|
166
|
+
export interface SwapUnavailableResult {
|
|
167
|
+
/** Whether liquidity is available for the swap. */
|
|
168
|
+
liquidityAvailable: false;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Options for executing a swap quote.
|
|
173
|
+
*/
|
|
174
|
+
export interface ExecuteSwapQuoteOptions {
|
|
175
|
+
/** Optional idempotency key for the request. */
|
|
176
|
+
idempotencyKey?: string;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Result of executing a swap quote.
|
|
181
|
+
*/
|
|
182
|
+
export interface ExecuteSwapQuoteResult {
|
|
183
|
+
/** The transaction hash of the executed swap. */
|
|
184
|
+
transactionHash: Hex;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Result of creating a swap quote.
|
|
189
|
+
*/
|
|
190
|
+
export interface CreateSwapQuoteResult {
|
|
191
|
+
/** Whether liquidity is available for the swap. */
|
|
192
|
+
liquidityAvailable: true;
|
|
193
|
+
/** The network for which this swap quote was created. */
|
|
194
|
+
network: EvmSwapsNetwork;
|
|
195
|
+
/** The token to receive (destination token). */
|
|
196
|
+
toToken: Address;
|
|
197
|
+
/** The token to send (source token). */
|
|
198
|
+
fromToken: Address;
|
|
199
|
+
/** The amount to send in atomic units of the token. */
|
|
200
|
+
fromAmount: bigint;
|
|
201
|
+
/** The amount to receive in atomic units of the token. */
|
|
202
|
+
toAmount: bigint;
|
|
203
|
+
/** The minimum amount to receive after slippage in atomic units of the token. */
|
|
204
|
+
minToAmount: bigint;
|
|
205
|
+
/** The block number at which the liquidity conditions were examined. */
|
|
206
|
+
blockNumber: bigint;
|
|
207
|
+
/** The estimated fees for the swap. */
|
|
208
|
+
fees: SwapFees;
|
|
209
|
+
/** Potential issues discovered during validation. */
|
|
210
|
+
issues: SwapIssues;
|
|
211
|
+
/** The transaction to execute the swap. */
|
|
212
|
+
transaction?: {
|
|
213
|
+
/** The contract address to send the transaction to. */
|
|
214
|
+
to: Address;
|
|
215
|
+
/** The transaction data. */
|
|
216
|
+
data: Hex;
|
|
217
|
+
/** The value to send with the transaction in Wei. */
|
|
218
|
+
value: bigint;
|
|
219
|
+
/** The gas limit for the transaction. */
|
|
220
|
+
gas: bigint;
|
|
221
|
+
/** The gas price for the transaction in Wei. */
|
|
222
|
+
gasPrice: bigint;
|
|
223
|
+
};
|
|
224
|
+
/** Permit2 data if required for the swap. */
|
|
225
|
+
permit2?: {
|
|
226
|
+
/** EIP-712 typed data for signing. */
|
|
227
|
+
eip712: EIP712Message;
|
|
228
|
+
};
|
|
229
|
+
/**
|
|
230
|
+
* Execute the swap using the quote.
|
|
231
|
+
*
|
|
232
|
+
* @param {ExecuteSwapQuoteOptions} options - Options for executing the swap.
|
|
233
|
+
* @returns {Promise<ExecuteSwapQuoteResult>} A promise that resolves to the swap execution result.
|
|
234
|
+
*/
|
|
235
|
+
execute: (options?: ExecuteSwapQuoteOptions) => Promise<ExecuteSwapQuoteResult>;
|
|
236
|
+
}
|
|
237
|
+
|
|
82
238
|
/**
|
|
83
239
|
* Options for getting a user operation.
|
|
84
240
|
*/
|
|
@@ -155,6 +311,8 @@ export interface CreateServerAccountOptions {
|
|
|
155
311
|
* Options for importing an EVM server account.
|
|
156
312
|
*/
|
|
157
313
|
export interface ImportServerAccountOptions {
|
|
314
|
+
/** The public RSA key used to encrypt the private key when importing an EVM account. */
|
|
315
|
+
encryptionPublicKey?: string;
|
|
158
316
|
/** The name of the account. */
|
|
159
317
|
name?: string;
|
|
160
318
|
/** The idempotency key. */
|
|
@@ -295,7 +453,7 @@ export interface SignMessageOptions {
|
|
|
295
453
|
}
|
|
296
454
|
|
|
297
455
|
/**
|
|
298
|
-
* Options for signing an EVM message.
|
|
456
|
+
* Options for signing an EVM typed data message.
|
|
299
457
|
*/
|
|
300
458
|
export interface SignTypedDataOptions {
|
|
301
459
|
/** The address of the account. */
|
|
@@ -332,6 +490,60 @@ export interface SignatureResult {
|
|
|
332
490
|
signature: Hex;
|
|
333
491
|
}
|
|
334
492
|
|
|
493
|
+
/**
|
|
494
|
+
* A fee in a specific token.
|
|
495
|
+
*/
|
|
496
|
+
export interface TokenFee {
|
|
497
|
+
/** The amount of the fee in atomic units of the token. */
|
|
498
|
+
amount: bigint;
|
|
499
|
+
/** The contract address of the token that the fee is paid in. */
|
|
500
|
+
token: Address;
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
/**
|
|
504
|
+
* The estimated fees for a swap.
|
|
505
|
+
*/
|
|
506
|
+
export interface SwapFees {
|
|
507
|
+
/** The estimated gas fee for the swap. */
|
|
508
|
+
gasFee?: TokenFee;
|
|
509
|
+
/** The estimated protocol fee for the swap. */
|
|
510
|
+
protocolFee?: TokenFee;
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
/**
|
|
514
|
+
* Details of allowance issues for a swap.
|
|
515
|
+
*/
|
|
516
|
+
export interface SwapAllowanceIssue {
|
|
517
|
+
/** The current allowance of the fromToken by the taker. */
|
|
518
|
+
currentAllowance: bigint;
|
|
519
|
+
/** The address to set the allowance on. */
|
|
520
|
+
spender: Address;
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
/**
|
|
524
|
+
* Details of balance issues for a swap.
|
|
525
|
+
*/
|
|
526
|
+
export interface SwapBalanceIssue {
|
|
527
|
+
/** The contract address of the token. */
|
|
528
|
+
token: Address;
|
|
529
|
+
/** The current balance of the fromToken by the taker. */
|
|
530
|
+
currentBalance: bigint;
|
|
531
|
+
/** The amount of the token that the taker must hold. */
|
|
532
|
+
requiredBalance: bigint;
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
/**
|
|
536
|
+
* Potential issues discovered during swap validation.
|
|
537
|
+
*/
|
|
538
|
+
export interface SwapIssues {
|
|
539
|
+
/** Details of the allowances that the taker must set. Null if no allowance is required. */
|
|
540
|
+
allowance?: SwapAllowanceIssue;
|
|
541
|
+
/** Details of the balance of the fromToken that the taker must hold. Null if sufficient balance. */
|
|
542
|
+
balance?: SwapBalanceIssue;
|
|
543
|
+
/** True when the transaction cannot be validated (e.g., insufficient balance). */
|
|
544
|
+
simulationIncomplete: boolean;
|
|
545
|
+
}
|
|
546
|
+
|
|
335
547
|
/**
|
|
336
548
|
* Options for waiting for a user operation.
|
|
337
549
|
*/
|
|
@@ -343,3 +555,15 @@ export interface WaitForUserOperationOptions {
|
|
|
343
555
|
/** The wait options. */
|
|
344
556
|
waitOptions?: WaitOptions;
|
|
345
557
|
}
|
|
558
|
+
|
|
559
|
+
/**
|
|
560
|
+
* Legacy type aliases for backwards compatibility.
|
|
561
|
+
*
|
|
562
|
+
* @deprecated Use the new type names instead.
|
|
563
|
+
*/
|
|
564
|
+
export type CreateSwapOptions = CreateSwapQuoteOptions;
|
|
565
|
+
export type CreateSwapResult = CreateSwapQuoteResult;
|
|
566
|
+
export type GetSwapQuoteOptions = GetSwapPriceOptions;
|
|
567
|
+
export type GetSwapQuoteResult = GetSwapPriceResult;
|
|
568
|
+
export type SwapQuoteUnavailableResult = SwapUnavailableResult;
|
|
569
|
+
export type SwapPriceUnavailableResult = SwapUnavailableResult;
|
|
@@ -192,6 +192,281 @@ export interface EvmUserOperation {
|
|
|
192
192
|
transactionHash?: string;
|
|
193
193
|
}
|
|
194
194
|
|
|
195
|
+
/**
|
|
196
|
+
* The network on which to perform the swap.
|
|
197
|
+
*/
|
|
198
|
+
export type EvmSwapsNetwork = (typeof EvmSwapsNetwork)[keyof typeof EvmSwapsNetwork];
|
|
199
|
+
|
|
200
|
+
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
201
|
+
export const EvmSwapsNetwork = {
|
|
202
|
+
base: "base",
|
|
203
|
+
ethereum: "ethereum",
|
|
204
|
+
} as const;
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* The 0x-prefixed contract address of the token to receive.
|
|
208
|
+
* @pattern ^0x[a-fA-F0-9]{40}$
|
|
209
|
+
*/
|
|
210
|
+
export type ToToken = string;
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* The 0x-prefixed contract address of the token to send.
|
|
214
|
+
* @pattern ^0x[a-fA-F0-9]{40}$
|
|
215
|
+
*/
|
|
216
|
+
export type FromToken = string;
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* The amount of the `fromToken` to send in atomic units of the token. For example, `1000000000000000000` when sending ETH equates to 1 ETH, `1000000` when sending USDC equates to 1 USDC, etc.
|
|
220
|
+
* @pattern ^\d+$
|
|
221
|
+
*/
|
|
222
|
+
export type FromAmount = string;
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* The 0x-prefixed address that holds the `fromToken` balance and has the `Permit2` allowance set for the swap.
|
|
226
|
+
* @pattern ^0x[a-fA-F0-9]{40}$
|
|
227
|
+
*/
|
|
228
|
+
export type Taker = string;
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* The 0x-prefixed Externally Owned Account (EOA) address that will sign the `Permit2` EIP-712 permit message. This is only needed if `taker` is a smart contract.
|
|
232
|
+
* @pattern ^0x[a-fA-F0-9]{40}$
|
|
233
|
+
*/
|
|
234
|
+
export type SignerAddress = string;
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* The target gas price for the swap transaction, in Wei. For EIP-1559 transactions, this value should be seen as the `maxFeePerGas` value. If not provided, the API will use an estimate based on the current network conditions.
|
|
238
|
+
* @pattern ^\d+$
|
|
239
|
+
*/
|
|
240
|
+
export type GasPrice = string;
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* The maximum acceptable slippage of the `toToken` in basis points. If this parameter is set to 0, no slippage will be tolerated. If not provided, the default slippage tolerance is 100 bps (i.e., 1%).
|
|
244
|
+
* @minimum 0
|
|
245
|
+
* @maximum 10000
|
|
246
|
+
*/
|
|
247
|
+
export type SlippageBps = number;
|
|
248
|
+
|
|
249
|
+
export interface TokenFee {
|
|
250
|
+
/**
|
|
251
|
+
* The estimated amount of the fee in atomic units of the `token`. For example, `1000000000000000` if the fee is in ETH equates to 0.001 ETH, `10000` if the fee is in USDC equates to 0.01 USDC, etc.
|
|
252
|
+
* @pattern ^\d+$
|
|
253
|
+
*/
|
|
254
|
+
amount: string;
|
|
255
|
+
/**
|
|
256
|
+
* The contract address of the token that the fee is paid in. The address `0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE` is used for the native token of the network (e.g. ETH).
|
|
257
|
+
* @pattern ^0x[a-fA-F0-9]{40}$
|
|
258
|
+
*/
|
|
259
|
+
token: string;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* The estimated gas fee for the swap.
|
|
264
|
+
* @nullable
|
|
265
|
+
*/
|
|
266
|
+
export type CommonSwapResponseFeesGasFee = TokenFee | null;
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* The estimated protocol fee for the swap.
|
|
270
|
+
* @nullable
|
|
271
|
+
*/
|
|
272
|
+
export type CommonSwapResponseFeesProtocolFee = TokenFee | null;
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* The estimated fees for the swap.
|
|
276
|
+
*/
|
|
277
|
+
export type CommonSwapResponseFees = {
|
|
278
|
+
/**
|
|
279
|
+
* The estimated gas fee for the swap.
|
|
280
|
+
* @nullable
|
|
281
|
+
*/
|
|
282
|
+
gasFee: CommonSwapResponseFeesGasFee;
|
|
283
|
+
/**
|
|
284
|
+
* The estimated protocol fee for the swap.
|
|
285
|
+
* @nullable
|
|
286
|
+
*/
|
|
287
|
+
protocolFee: CommonSwapResponseFeesProtocolFee;
|
|
288
|
+
};
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Details of the allowances that the taker must set in order to execute the swap successfully. Null if no allowance is required.
|
|
292
|
+
* @nullable
|
|
293
|
+
*/
|
|
294
|
+
export type CommonSwapResponseIssuesAllowance = {
|
|
295
|
+
/**
|
|
296
|
+
* The current allowance of the `fromToken` by the `taker`.
|
|
297
|
+
* @pattern ^\d+$
|
|
298
|
+
*/
|
|
299
|
+
currentAllowance: string;
|
|
300
|
+
/**
|
|
301
|
+
* The 0x-prefixed address of to set the allowance on.
|
|
302
|
+
* @pattern ^0x[a-fA-F0-9]{40}$
|
|
303
|
+
*/
|
|
304
|
+
spender: string;
|
|
305
|
+
} | null;
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Details of the balance of the `fromToken` that the `taker` must hold. Null if the `taker` has a sufficient balance.
|
|
309
|
+
* @nullable
|
|
310
|
+
*/
|
|
311
|
+
export type CommonSwapResponseIssuesBalance = {
|
|
312
|
+
/**
|
|
313
|
+
* The 0x-prefixed contract address of the token.
|
|
314
|
+
* @pattern ^0x[a-fA-F0-9]{40}$
|
|
315
|
+
*/
|
|
316
|
+
token: string;
|
|
317
|
+
/**
|
|
318
|
+
* The current balance of the `fromToken` by the `taker`.
|
|
319
|
+
* @pattern ^\d+$
|
|
320
|
+
*/
|
|
321
|
+
currentBalance: string;
|
|
322
|
+
/**
|
|
323
|
+
* The amount of the token that the `taker` must hold.
|
|
324
|
+
* @pattern ^\d+$
|
|
325
|
+
*/
|
|
326
|
+
requiredBalance: string;
|
|
327
|
+
} | null;
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* An object containing potential issues discovered during validation that could prevent the swap from being executed successfully.
|
|
331
|
+
*/
|
|
332
|
+
export type CommonSwapResponseIssues = {
|
|
333
|
+
/**
|
|
334
|
+
* Details of the allowances that the taker must set in order to execute the swap successfully. Null if no allowance is required.
|
|
335
|
+
* @nullable
|
|
336
|
+
*/
|
|
337
|
+
allowance: CommonSwapResponseIssuesAllowance;
|
|
338
|
+
/**
|
|
339
|
+
* Details of the balance of the `fromToken` that the `taker` must hold. Null if the `taker` has a sufficient balance.
|
|
340
|
+
* @nullable
|
|
341
|
+
*/
|
|
342
|
+
balance: CommonSwapResponseIssuesBalance;
|
|
343
|
+
/** This is set to true when the transaction cannot be validated. This can happen when the taker has an insufficient balance of the `fromToken`. Note that this does not necessarily mean that the trade will revert. */
|
|
344
|
+
simulationIncomplete: boolean;
|
|
345
|
+
};
|
|
346
|
+
|
|
347
|
+
export interface CommonSwapResponse {
|
|
348
|
+
/**
|
|
349
|
+
* The block number at which the liquidity conditions were examined.
|
|
350
|
+
* @pattern ^[1-9]\d*$
|
|
351
|
+
*/
|
|
352
|
+
blockNumber: string;
|
|
353
|
+
/**
|
|
354
|
+
* The amount of the `toToken` that will be received in atomic units of the `toToken`. For example, `1000000000000000000` when receiving ETH equates to 1 ETH, `1000000` when receiving USDC equates to 1 USDC, etc.
|
|
355
|
+
* @pattern ^(0|[1-9]\d*)$
|
|
356
|
+
*/
|
|
357
|
+
toAmount: string;
|
|
358
|
+
/**
|
|
359
|
+
* The 0x-prefixed contract address of the token that will be received.
|
|
360
|
+
* @pattern ^0x[a-fA-F0-9]{40}$
|
|
361
|
+
*/
|
|
362
|
+
toToken: string;
|
|
363
|
+
/** The estimated fees for the swap. */
|
|
364
|
+
fees: CommonSwapResponseFees;
|
|
365
|
+
/** An object containing potential issues discovered during validation that could prevent the swap from being executed successfully. */
|
|
366
|
+
issues: CommonSwapResponseIssues;
|
|
367
|
+
/** Whether sufficient liquidity is available to settle the swap. All other fields in the response will be empty if this is false. */
|
|
368
|
+
liquidityAvailable: boolean;
|
|
369
|
+
/**
|
|
370
|
+
* The minimum amount of the `toToken` that must be received for the swap to succeed, in atomic units of the `toToken`. For example, `1000000000000000000` when receiving ETH equates to 1 ETH, `1000000` when receiving USDC equates to 1 USDC, etc. This value is influenced by the `slippageBps` parameter.
|
|
371
|
+
* @pattern ^(0|[1-9]\d*)$
|
|
372
|
+
*/
|
|
373
|
+
minToAmount: string;
|
|
374
|
+
/**
|
|
375
|
+
* The amount of the `fromToken` that will be sent in this swap, in atomic units of the `fromToken`. For example, `1000000000000000000` when sending ETH equates to 1 ETH, `1000000` when sending USDC equates to 1 USDC, etc.
|
|
376
|
+
* @pattern ^(0|[1-9]\d*)$
|
|
377
|
+
*/
|
|
378
|
+
fromAmount: string;
|
|
379
|
+
/**
|
|
380
|
+
* The 0x-prefixed contract address of the token that will be sent.
|
|
381
|
+
* @pattern ^0x[a-fA-F0-9]{40}$
|
|
382
|
+
*/
|
|
383
|
+
fromToken: string;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
export type GetSwapPriceResponseAllOf = {
|
|
387
|
+
/**
|
|
388
|
+
* The estimated gas limit that should be used to send the transaction to guarantee settlement.
|
|
389
|
+
* @nullable
|
|
390
|
+
* @pattern ^\d+$
|
|
391
|
+
*/
|
|
392
|
+
gas: string | null;
|
|
393
|
+
/**
|
|
394
|
+
* The gas price, in Wei, that should be used to send the transaction. For EIP-1559 transactions, this value should be seen as the `maxFeePerGas` value. The transaction should be sent with this gas price to guarantee settlement.
|
|
395
|
+
* @pattern ^\d+$
|
|
396
|
+
*/
|
|
397
|
+
gasPrice: string;
|
|
398
|
+
};
|
|
399
|
+
|
|
400
|
+
export type GetSwapPriceResponse = CommonSwapResponse & GetSwapPriceResponseAllOf;
|
|
401
|
+
|
|
402
|
+
export interface SwapUnavailableResponse {
|
|
403
|
+
/** Whether sufficient liquidity is available to settle the swap. All other fields in the response will be empty if this is false. */
|
|
404
|
+
liquidityAvailable: boolean;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
/**
|
|
408
|
+
* A wrapper for the response of a swap price operation.
|
|
409
|
+
*/
|
|
410
|
+
export type GetSwapPriceResponseWrapper = GetSwapPriceResponse | SwapUnavailableResponse;
|
|
411
|
+
|
|
412
|
+
/**
|
|
413
|
+
* The approval object which contains the necessary fields to submit an approval for this transaction. Null if the `fromToken` is the native token or the transaction is a native token wrap / unwrap.
|
|
414
|
+
* @nullable
|
|
415
|
+
*/
|
|
416
|
+
export type CreateSwapQuoteResponseAllOfPermit2 = {
|
|
417
|
+
/**
|
|
418
|
+
* The hash for the approval according to [EIP-712](https://eips.ethereum.org/EIPS/eip-712). Computing the hash of the `eip712` field should match the value of this field.
|
|
419
|
+
* @pattern ^0x[a-fA-F0-9]{64}$
|
|
420
|
+
*/
|
|
421
|
+
hash: string;
|
|
422
|
+
eip712: EIP712Message;
|
|
423
|
+
} | null;
|
|
424
|
+
|
|
425
|
+
/**
|
|
426
|
+
* The details of the transaction to be signed and submitted to execute the swap.
|
|
427
|
+
*/
|
|
428
|
+
export type CreateSwapQuoteResponseAllOfTransaction = {
|
|
429
|
+
/**
|
|
430
|
+
* The 0x-prefixed address of the contract to call.
|
|
431
|
+
* @pattern ^0x[a-fA-F0-9]{40}$
|
|
432
|
+
*/
|
|
433
|
+
to: string;
|
|
434
|
+
/** The hex-encoded call data to send to the contract. */
|
|
435
|
+
data: string;
|
|
436
|
+
/**
|
|
437
|
+
* The estimated gas limit that should be used to send the transaction to guarantee settlement.
|
|
438
|
+
* @pattern ^\d+$
|
|
439
|
+
*/
|
|
440
|
+
gas: string;
|
|
441
|
+
/**
|
|
442
|
+
* The gas price, in Wei, that should be used to send the transaction. For EIP-1559 transactions, this value should be seen as the `maxFeePerGas` value. The transaction should be sent with this gas price to guarantee settlement.
|
|
443
|
+
* @pattern ^\d+$
|
|
444
|
+
*/
|
|
445
|
+
gasPrice: string;
|
|
446
|
+
/**
|
|
447
|
+
* The value of the transaction in Wei.
|
|
448
|
+
* @pattern ^\d+$
|
|
449
|
+
*/
|
|
450
|
+
value: string;
|
|
451
|
+
};
|
|
452
|
+
|
|
453
|
+
export type CreateSwapQuoteResponseAllOf = {
|
|
454
|
+
/**
|
|
455
|
+
* The approval object which contains the necessary fields to submit an approval for this transaction. Null if the `fromToken` is the native token or the transaction is a native token wrap / unwrap.
|
|
456
|
+
* @nullable
|
|
457
|
+
*/
|
|
458
|
+
permit2: CreateSwapQuoteResponseAllOfPermit2;
|
|
459
|
+
/** The details of the transaction to be signed and submitted to execute the swap. */
|
|
460
|
+
transaction: CreateSwapQuoteResponseAllOfTransaction;
|
|
461
|
+
};
|
|
462
|
+
|
|
463
|
+
export type CreateSwapQuoteResponse = CreateSwapQuoteResponseAllOf & CommonSwapResponse;
|
|
464
|
+
|
|
465
|
+
/**
|
|
466
|
+
* A wrapper for the response of a swap quote operation.
|
|
467
|
+
*/
|
|
468
|
+
export type CreateSwapQuoteResponseWrapper = CreateSwapQuoteResponse | SwapUnavailableResponse;
|
|
469
|
+
|
|
195
470
|
/**
|
|
196
471
|
* The name of the supported EVM networks in human-readable format.
|
|
197
472
|
*/
|
|
@@ -329,7 +604,7 @@ export interface EvmAddressCriterion {
|
|
|
329
604
|
export type SignEvmTransactionCriteriaItem = EthValueCriterion | EvmAddressCriterion;
|
|
330
605
|
|
|
331
606
|
/**
|
|
332
|
-
* A schema for specifying
|
|
607
|
+
* A schema for specifying criteria for the SignEvmTransaction operation.
|
|
333
608
|
*/
|
|
334
609
|
export type SignEvmTransactionCriteria = SignEvmTransactionCriteriaItem[];
|
|
335
610
|
|
|
@@ -417,7 +692,7 @@ export type SendEvmTransactionCriteriaItem =
|
|
|
417
692
|
| EvmNetworkCriterion;
|
|
418
693
|
|
|
419
694
|
/**
|
|
420
|
-
* A schema for specifying
|
|
695
|
+
* A schema for specifying criteria for the SignEvmTransaction operation.
|
|
421
696
|
*/
|
|
422
697
|
export type SendEvmTransactionCriteria = SendEvmTransactionCriteriaItem[];
|
|
423
698
|
|
|
@@ -488,7 +763,7 @@ export interface SolAddressCriterion {
|
|
|
488
763
|
}
|
|
489
764
|
|
|
490
765
|
/**
|
|
491
|
-
* A schema for specifying
|
|
766
|
+
* A schema for specifying criteria for the SignSolTransaction operation.
|
|
492
767
|
*/
|
|
493
768
|
export type SignSolTransactionCriteria = SolAddressCriterion[];
|
|
494
769
|
|
|
@@ -1017,6 +1292,57 @@ export type SendUserOperationBody = {
|
|
|
1017
1292
|
signature: string;
|
|
1018
1293
|
};
|
|
1019
1294
|
|
|
1295
|
+
export type GetEvmSwapPriceParams = {
|
|
1296
|
+
network: EvmSwapsNetwork;
|
|
1297
|
+
toToken: ToToken;
|
|
1298
|
+
fromToken: FromToken;
|
|
1299
|
+
fromAmount: FromAmount;
|
|
1300
|
+
taker: Taker;
|
|
1301
|
+
signerAddress?: SignerAddress;
|
|
1302
|
+
gasPrice?: GasPrice;
|
|
1303
|
+
slippageBps?: SlippageBps;
|
|
1304
|
+
};
|
|
1305
|
+
|
|
1306
|
+
export type CreateEvmSwapQuoteBody = {
|
|
1307
|
+
network: EvmSwapsNetwork;
|
|
1308
|
+
/**
|
|
1309
|
+
* The 0x-prefixed contract address of the token to receive.
|
|
1310
|
+
* @pattern ^0x[a-fA-F0-9]{40}$
|
|
1311
|
+
*/
|
|
1312
|
+
toToken: string;
|
|
1313
|
+
/**
|
|
1314
|
+
* The 0x-prefixed contract address of the token to send.
|
|
1315
|
+
* @pattern ^0x[a-fA-F0-9]{40}$
|
|
1316
|
+
*/
|
|
1317
|
+
fromToken: string;
|
|
1318
|
+
/**
|
|
1319
|
+
* The amount of the `fromToken` to send in atomic units of the token. For example, `1000000000000000000` when sending ETH equates to 1 ETH, `1000000` when sending USDC equates to 1 USDC, etc.
|
|
1320
|
+
* @pattern ^\d+$
|
|
1321
|
+
*/
|
|
1322
|
+
fromAmount: string;
|
|
1323
|
+
/**
|
|
1324
|
+
* The 0x-prefixed address that holds the `fromToken` balance and has the `Permit2` allowance set for the swap.
|
|
1325
|
+
* @pattern ^0x[a-fA-F0-9]{40}$
|
|
1326
|
+
*/
|
|
1327
|
+
taker: string;
|
|
1328
|
+
/**
|
|
1329
|
+
* The 0x-prefixed Externally Owned Account (EOA) address that will sign the `Permit2` EIP-712 permit message. This is only needed if `taker` is a smart contract.
|
|
1330
|
+
* @pattern ^0x[a-fA-F0-9]{40}$
|
|
1331
|
+
*/
|
|
1332
|
+
signerAddress?: string;
|
|
1333
|
+
/**
|
|
1334
|
+
* The target gas price for the swap transaction, in Wei. For EIP-1559 transactions, this value should be seen as the `maxFeePerGas` value. If not provided, the API will use an estimate based on the current network conditions.
|
|
1335
|
+
* @pattern ^\d+$
|
|
1336
|
+
*/
|
|
1337
|
+
gasPrice?: string;
|
|
1338
|
+
/**
|
|
1339
|
+
* The maximum acceptable slippage of the `toToken` in basis points. If this parameter is set to 0, no slippage will be tolerated. If not provided, the default slippage tolerance is 100 bps (i.e., 1%).
|
|
1340
|
+
* @minimum 0
|
|
1341
|
+
* @maximum 10000
|
|
1342
|
+
*/
|
|
1343
|
+
slippageBps?: number;
|
|
1344
|
+
};
|
|
1345
|
+
|
|
1020
1346
|
export type ListEvmTokenBalancesParams = {
|
|
1021
1347
|
/**
|
|
1022
1348
|
* The number of balances to return per page.
|