@coinbase/cdp-sdk 1.11.0 → 1.13.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 +126 -0
- package/_cjs/accounts/evm/toEvmServerAccount.js +15 -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 +28 -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/generated/policy-engine/policy-engine.msw.js +59 -1
- package/_cjs/openapi-client/generated/policy-engine/policy-engine.msw.js.map +1 -1
- package/_cjs/openapi-client/index.js +4 -0
- package/_cjs/openapi-client/index.js.map +1 -1
- package/_cjs/policies/schema.js +59 -1
- package/_cjs/policies/schema.js.map +1 -1
- package/_cjs/version.js +1 -1
- package/_esm/accounts/evm/toEvmServerAccount.js +15 -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 +27 -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/generated/policy-engine/policy-engine.msw.js +54 -0
- package/_esm/openapi-client/generated/policy-engine/policy-engine.msw.js.map +1 -1
- package/_esm/openapi-client/index.js +4 -0
- package/_esm/openapi-client/index.js.map +1 -1
- package/_esm/policies/schema.js +58 -0
- package/_esm/policies/schema.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 +119 -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 +364 -4
- 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/generated/policy-engine/policy-engine.msw.d.ts +5 -1
- package/_types/openapi-client/generated/policy-engine/policy-engine.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/policies/schema.d.ts +338 -0
- package/_types/policies/schema.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 +137 -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 +422 -4
- 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/generated/policy-engine/policy-engine.msw.ts +87 -0
- package/openapi-client/index.ts +4 -0
- package/package.json +1 -1
- package/policies/schema.ts +70 -0
- package/version.ts +1 -1
|
@@ -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
|
|
|
@@ -452,6 +727,63 @@ export interface SendEvmTransactionRule {
|
|
|
452
727
|
criteria: SendEvmTransactionCriteria;
|
|
453
728
|
}
|
|
454
729
|
|
|
730
|
+
/**
|
|
731
|
+
* The type of criterion to use. This should be `evmMessage`.
|
|
732
|
+
*/
|
|
733
|
+
export type EvmMessageCriterionType =
|
|
734
|
+
(typeof EvmMessageCriterionType)[keyof typeof EvmMessageCriterionType];
|
|
735
|
+
|
|
736
|
+
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
737
|
+
export const EvmMessageCriterionType = {
|
|
738
|
+
evmMessage: "evmMessage",
|
|
739
|
+
} as const;
|
|
740
|
+
|
|
741
|
+
/**
|
|
742
|
+
* A schema for specifying a criterion for the message being signed.
|
|
743
|
+
*/
|
|
744
|
+
export interface EvmMessageCriterion {
|
|
745
|
+
/** The type of criterion to use. This should be `evmMessage`. */
|
|
746
|
+
type: EvmMessageCriterionType;
|
|
747
|
+
/** A regular expression the message is matched against. Accepts valid regular expression syntax described by [RE2](https://github.com/google/re2/wiki/Syntax). */
|
|
748
|
+
match: string;
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
/**
|
|
752
|
+
* A schema for specifying the rejection criteria for the SignEvmMessage operation.
|
|
753
|
+
*/
|
|
754
|
+
export type SignEvmMessageCriteria = EvmMessageCriterion[];
|
|
755
|
+
|
|
756
|
+
/**
|
|
757
|
+
* Whether matching the rule will cause the request to be rejected or accepted.
|
|
758
|
+
*/
|
|
759
|
+
export type SignEvmMessageRuleAction =
|
|
760
|
+
(typeof SignEvmMessageRuleAction)[keyof typeof SignEvmMessageRuleAction];
|
|
761
|
+
|
|
762
|
+
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
763
|
+
export const SignEvmMessageRuleAction = {
|
|
764
|
+
reject: "reject",
|
|
765
|
+
accept: "accept",
|
|
766
|
+
} as const;
|
|
767
|
+
|
|
768
|
+
/**
|
|
769
|
+
* The operation to which the rule applies. Every element of the `criteria` array must match the specified operation.
|
|
770
|
+
*/
|
|
771
|
+
export type SignEvmMessageRuleOperation =
|
|
772
|
+
(typeof SignEvmMessageRuleOperation)[keyof typeof SignEvmMessageRuleOperation];
|
|
773
|
+
|
|
774
|
+
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
775
|
+
export const SignEvmMessageRuleOperation = {
|
|
776
|
+
signEvmMessage: "signEvmMessage",
|
|
777
|
+
} as const;
|
|
778
|
+
|
|
779
|
+
export interface SignEvmMessageRule {
|
|
780
|
+
/** Whether matching the rule will cause the request to be rejected or accepted. */
|
|
781
|
+
action: SignEvmMessageRuleAction;
|
|
782
|
+
/** The operation to which the rule applies. Every element of the `criteria` array must match the specified operation. */
|
|
783
|
+
operation: SignEvmMessageRuleOperation;
|
|
784
|
+
criteria: SignEvmMessageCriteria;
|
|
785
|
+
}
|
|
786
|
+
|
|
455
787
|
/**
|
|
456
788
|
* The type of criterion to use. This should be `solAddress`.
|
|
457
789
|
*/
|
|
@@ -488,7 +820,7 @@ export interface SolAddressCriterion {
|
|
|
488
820
|
}
|
|
489
821
|
|
|
490
822
|
/**
|
|
491
|
-
* A schema for specifying
|
|
823
|
+
* A schema for specifying criteria for the SignSolTransaction operation.
|
|
492
824
|
*/
|
|
493
825
|
export type SignSolTransactionCriteria = SolAddressCriterion[];
|
|
494
826
|
|
|
@@ -523,10 +855,45 @@ export interface SignSolTransactionRule {
|
|
|
523
855
|
criteria: SignSolTransactionCriteria;
|
|
524
856
|
}
|
|
525
857
|
|
|
858
|
+
/**
|
|
859
|
+
* Whether any attempts to sign a hash will be accepted or rejected. This rule does not accept any criteria.
|
|
860
|
+
*/
|
|
861
|
+
export type SignEvmHashRuleAction =
|
|
862
|
+
(typeof SignEvmHashRuleAction)[keyof typeof SignEvmHashRuleAction];
|
|
863
|
+
|
|
864
|
+
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
865
|
+
export const SignEvmHashRuleAction = {
|
|
866
|
+
reject: "reject",
|
|
867
|
+
accept: "accept",
|
|
868
|
+
} as const;
|
|
869
|
+
|
|
870
|
+
/**
|
|
871
|
+
* The operation to which the rule applies.
|
|
872
|
+
*/
|
|
873
|
+
export type SignEvmHashRuleOperation =
|
|
874
|
+
(typeof SignEvmHashRuleOperation)[keyof typeof SignEvmHashRuleOperation];
|
|
875
|
+
|
|
876
|
+
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
877
|
+
export const SignEvmHashRuleOperation = {
|
|
878
|
+
signEvmHash: "signEvmHash",
|
|
879
|
+
} as const;
|
|
880
|
+
|
|
881
|
+
export interface SignEvmHashRule {
|
|
882
|
+
/** Whether any attempts to sign a hash will be accepted or rejected. This rule does not accept any criteria. */
|
|
883
|
+
action: SignEvmHashRuleAction;
|
|
884
|
+
/** The operation to which the rule applies. */
|
|
885
|
+
operation: SignEvmHashRuleOperation;
|
|
886
|
+
}
|
|
887
|
+
|
|
526
888
|
/**
|
|
527
889
|
* A rule that limits the behavior of an account.
|
|
528
890
|
*/
|
|
529
|
-
export type Rule =
|
|
891
|
+
export type Rule =
|
|
892
|
+
| SignEvmTransactionRule
|
|
893
|
+
| SendEvmTransactionRule
|
|
894
|
+
| SignEvmMessageRule
|
|
895
|
+
| SignSolTransactionRule
|
|
896
|
+
| SignEvmHashRule;
|
|
530
897
|
|
|
531
898
|
/**
|
|
532
899
|
* The scope of the policy. Only one project-level policy can exist at any time.
|
|
@@ -1017,6 +1384,57 @@ export type SendUserOperationBody = {
|
|
|
1017
1384
|
signature: string;
|
|
1018
1385
|
};
|
|
1019
1386
|
|
|
1387
|
+
export type GetEvmSwapPriceParams = {
|
|
1388
|
+
network: EvmSwapsNetwork;
|
|
1389
|
+
toToken: ToToken;
|
|
1390
|
+
fromToken: FromToken;
|
|
1391
|
+
fromAmount: FromAmount;
|
|
1392
|
+
taker: Taker;
|
|
1393
|
+
signerAddress?: SignerAddress;
|
|
1394
|
+
gasPrice?: GasPrice;
|
|
1395
|
+
slippageBps?: SlippageBps;
|
|
1396
|
+
};
|
|
1397
|
+
|
|
1398
|
+
export type CreateEvmSwapQuoteBody = {
|
|
1399
|
+
network: EvmSwapsNetwork;
|
|
1400
|
+
/**
|
|
1401
|
+
* The 0x-prefixed contract address of the token to receive.
|
|
1402
|
+
* @pattern ^0x[a-fA-F0-9]{40}$
|
|
1403
|
+
*/
|
|
1404
|
+
toToken: string;
|
|
1405
|
+
/**
|
|
1406
|
+
* The 0x-prefixed contract address of the token to send.
|
|
1407
|
+
* @pattern ^0x[a-fA-F0-9]{40}$
|
|
1408
|
+
*/
|
|
1409
|
+
fromToken: string;
|
|
1410
|
+
/**
|
|
1411
|
+
* 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.
|
|
1412
|
+
* @pattern ^\d+$
|
|
1413
|
+
*/
|
|
1414
|
+
fromAmount: string;
|
|
1415
|
+
/**
|
|
1416
|
+
* The 0x-prefixed address that holds the `fromToken` balance and has the `Permit2` allowance set for the swap.
|
|
1417
|
+
* @pattern ^0x[a-fA-F0-9]{40}$
|
|
1418
|
+
*/
|
|
1419
|
+
taker: string;
|
|
1420
|
+
/**
|
|
1421
|
+
* 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.
|
|
1422
|
+
* @pattern ^0x[a-fA-F0-9]{40}$
|
|
1423
|
+
*/
|
|
1424
|
+
signerAddress?: string;
|
|
1425
|
+
/**
|
|
1426
|
+
* 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.
|
|
1427
|
+
* @pattern ^\d+$
|
|
1428
|
+
*/
|
|
1429
|
+
gasPrice?: string;
|
|
1430
|
+
/**
|
|
1431
|
+
* 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%).
|
|
1432
|
+
* @minimum 0
|
|
1433
|
+
* @maximum 10000
|
|
1434
|
+
*/
|
|
1435
|
+
slippageBps?: number;
|
|
1436
|
+
};
|
|
1437
|
+
|
|
1020
1438
|
export type ListEvmTokenBalancesParams = {
|
|
1021
1439
|
/**
|
|
1022
1440
|
* The number of balances to return per page.
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated by orval v7.6.0 🍺
|
|
3
|
+
* Do not edit manually.
|
|
4
|
+
* Coinbase Developer Platform APIs
|
|
5
|
+
* The Coinbase Developer Platform APIs - leading the world's transition onchain.
|
|
6
|
+
* OpenAPI spec version: 2.0.0
|
|
7
|
+
*/
|
|
8
|
+
import { faker } from "@faker-js/faker";
|
|
9
|
+
|
|
10
|
+
import { HttpResponse, delay, http } from "msw";
|
|
11
|
+
|
|
12
|
+
import type {
|
|
13
|
+
CreateSwapQuoteResponse,
|
|
14
|
+
CreateSwapQuoteResponseWrapper,
|
|
15
|
+
GetSwapPriceResponse,
|
|
16
|
+
GetSwapPriceResponseWrapper,
|
|
17
|
+
SwapUnavailableResponse,
|
|
18
|
+
} from "../coinbaseDeveloperPlatformAPIs.schemas.js";
|
|
19
|
+
|
|
20
|
+
export const getGetEvmSwapPriceResponseGetSwapPriceResponseMock = (
|
|
21
|
+
overrideResponse: Partial<GetSwapPriceResponse> = {},
|
|
22
|
+
): GetSwapPriceResponse => ({
|
|
23
|
+
...{
|
|
24
|
+
...{
|
|
25
|
+
blockNumber: faker.helpers.fromRegExp("^[1-9]\d*$"),
|
|
26
|
+
toAmount: faker.helpers.fromRegExp("^(0|[1-9]\d*)$"),
|
|
27
|
+
toToken: faker.helpers.fromRegExp("^0x[a-fA-F0-9]{40}$"),
|
|
28
|
+
fees: {
|
|
29
|
+
gasFee: {
|
|
30
|
+
...{
|
|
31
|
+
amount: faker.helpers.fromRegExp("^\d+$"),
|
|
32
|
+
token: faker.helpers.fromRegExp("^0x[a-fA-F0-9]{40}$"),
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
protocolFee: {
|
|
36
|
+
...{
|
|
37
|
+
amount: faker.helpers.fromRegExp("^\d+$"),
|
|
38
|
+
token: faker.helpers.fromRegExp("^0x[a-fA-F0-9]{40}$"),
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
issues: {
|
|
43
|
+
allowance: {
|
|
44
|
+
currentAllowance: faker.helpers.fromRegExp("^\d+$"),
|
|
45
|
+
spender: faker.helpers.fromRegExp("^0x[a-fA-F0-9]{40}$"),
|
|
46
|
+
},
|
|
47
|
+
balance: {
|
|
48
|
+
token: faker.helpers.fromRegExp("^0x[a-fA-F0-9]{40}$"),
|
|
49
|
+
currentBalance: faker.helpers.fromRegExp("^\d+$"),
|
|
50
|
+
requiredBalance: faker.helpers.fromRegExp("^\d+$"),
|
|
51
|
+
},
|
|
52
|
+
simulationIncomplete: faker.datatype.boolean(),
|
|
53
|
+
},
|
|
54
|
+
liquidityAvailable: faker.datatype.boolean(),
|
|
55
|
+
minToAmount: faker.helpers.fromRegExp("^(0|[1-9]\d*)$"),
|
|
56
|
+
fromAmount: faker.helpers.fromRegExp("^(0|[1-9]\d*)$"),
|
|
57
|
+
fromToken: faker.helpers.fromRegExp("^0x[a-fA-F0-9]{40}$"),
|
|
58
|
+
},
|
|
59
|
+
...{
|
|
60
|
+
gas: faker.helpers.arrayElement([faker.helpers.fromRegExp("^\d+$"), null]),
|
|
61
|
+
gasPrice: faker.helpers.fromRegExp("^\d+$"),
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
...overrideResponse,
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
export const getGetEvmSwapPriceResponseSwapUnavailableResponseMock = (
|
|
68
|
+
overrideResponse: Partial<SwapUnavailableResponse> = {},
|
|
69
|
+
): SwapUnavailableResponse => ({
|
|
70
|
+
...{ liquidityAvailable: faker.datatype.boolean() },
|
|
71
|
+
...overrideResponse,
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
export const getGetEvmSwapPriceResponseMock = (): GetSwapPriceResponseWrapper =>
|
|
75
|
+
faker.helpers.arrayElement([
|
|
76
|
+
{ ...getGetEvmSwapPriceResponseGetSwapPriceResponseMock() },
|
|
77
|
+
{ ...getGetEvmSwapPriceResponseSwapUnavailableResponseMock() },
|
|
78
|
+
]);
|
|
79
|
+
|
|
80
|
+
export const getCreateEvmSwapQuoteResponseCreateSwapQuoteResponseMock = (
|
|
81
|
+
overrideResponse: Partial<CreateSwapQuoteResponse> = {},
|
|
82
|
+
): CreateSwapQuoteResponse => ({
|
|
83
|
+
...{
|
|
84
|
+
...{
|
|
85
|
+
permit2: {
|
|
86
|
+
hash: faker.helpers.fromRegExp("^0x[a-fA-F0-9]{64}$"),
|
|
87
|
+
eip712: {
|
|
88
|
+
domain: {
|
|
89
|
+
name: faker.helpers.arrayElement([faker.string.alpha(20), undefined]),
|
|
90
|
+
version: faker.helpers.arrayElement([faker.string.alpha(20), undefined]),
|
|
91
|
+
chainId: faker.helpers.arrayElement([
|
|
92
|
+
faker.number.int({ min: undefined, max: undefined }),
|
|
93
|
+
undefined,
|
|
94
|
+
]),
|
|
95
|
+
verifyingContract: faker.helpers.arrayElement([
|
|
96
|
+
faker.helpers.fromRegExp("^0x[a-fA-F0-9]{40}$"),
|
|
97
|
+
undefined,
|
|
98
|
+
]),
|
|
99
|
+
salt: faker.helpers.arrayElement([
|
|
100
|
+
faker.helpers.fromRegExp("^0x[a-fA-F0-9]{64}$"),
|
|
101
|
+
undefined,
|
|
102
|
+
]),
|
|
103
|
+
},
|
|
104
|
+
types: {},
|
|
105
|
+
primaryType: faker.string.alpha(20),
|
|
106
|
+
message: {},
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
transaction: {
|
|
110
|
+
to: faker.helpers.fromRegExp("^0x[a-fA-F0-9]{40}$"),
|
|
111
|
+
data: faker.string.alpha(20),
|
|
112
|
+
gas: faker.helpers.fromRegExp("^\d+$"),
|
|
113
|
+
gasPrice: faker.helpers.fromRegExp("^\d+$"),
|
|
114
|
+
value: faker.helpers.fromRegExp("^\d+$"),
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
...{
|
|
118
|
+
blockNumber: faker.helpers.fromRegExp("^[1-9]\d*$"),
|
|
119
|
+
toAmount: faker.helpers.fromRegExp("^(0|[1-9]\d*)$"),
|
|
120
|
+
toToken: faker.helpers.fromRegExp("^0x[a-fA-F0-9]{40}$"),
|
|
121
|
+
fees: {
|
|
122
|
+
gasFee: {
|
|
123
|
+
...{
|
|
124
|
+
amount: faker.helpers.fromRegExp("^\d+$"),
|
|
125
|
+
token: faker.helpers.fromRegExp("^0x[a-fA-F0-9]{40}$"),
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
protocolFee: {
|
|
129
|
+
...{
|
|
130
|
+
amount: faker.helpers.fromRegExp("^\d+$"),
|
|
131
|
+
token: faker.helpers.fromRegExp("^0x[a-fA-F0-9]{40}$"),
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
issues: {
|
|
136
|
+
allowance: {
|
|
137
|
+
currentAllowance: faker.helpers.fromRegExp("^\d+$"),
|
|
138
|
+
spender: faker.helpers.fromRegExp("^0x[a-fA-F0-9]{40}$"),
|
|
139
|
+
},
|
|
140
|
+
balance: {
|
|
141
|
+
token: faker.helpers.fromRegExp("^0x[a-fA-F0-9]{40}$"),
|
|
142
|
+
currentBalance: faker.helpers.fromRegExp("^\d+$"),
|
|
143
|
+
requiredBalance: faker.helpers.fromRegExp("^\d+$"),
|
|
144
|
+
},
|
|
145
|
+
simulationIncomplete: faker.datatype.boolean(),
|
|
146
|
+
},
|
|
147
|
+
liquidityAvailable: faker.datatype.boolean(),
|
|
148
|
+
minToAmount: faker.helpers.fromRegExp("^(0|[1-9]\d*)$"),
|
|
149
|
+
fromAmount: faker.helpers.fromRegExp("^(0|[1-9]\d*)$"),
|
|
150
|
+
fromToken: faker.helpers.fromRegExp("^0x[a-fA-F0-9]{40}$"),
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
...overrideResponse,
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
export const getCreateEvmSwapQuoteResponseSwapUnavailableResponseMock = (
|
|
157
|
+
overrideResponse: Partial<SwapUnavailableResponse> = {},
|
|
158
|
+
): SwapUnavailableResponse => ({
|
|
159
|
+
...{ liquidityAvailable: faker.datatype.boolean() },
|
|
160
|
+
...overrideResponse,
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
export const getCreateEvmSwapQuoteResponseMock = (): CreateSwapQuoteResponseWrapper =>
|
|
164
|
+
faker.helpers.arrayElement([
|
|
165
|
+
{ ...getCreateEvmSwapQuoteResponseCreateSwapQuoteResponseMock() },
|
|
166
|
+
{ ...getCreateEvmSwapQuoteResponseSwapUnavailableResponseMock() },
|
|
167
|
+
]);
|
|
168
|
+
|
|
169
|
+
export const getGetEvmSwapPriceMockHandler = (
|
|
170
|
+
overrideResponse?:
|
|
171
|
+
| GetSwapPriceResponseWrapper
|
|
172
|
+
| ((
|
|
173
|
+
info: Parameters<Parameters<typeof http.get>[1]>[0],
|
|
174
|
+
) => Promise<GetSwapPriceResponseWrapper> | GetSwapPriceResponseWrapper),
|
|
175
|
+
) => {
|
|
176
|
+
return http.get("*/v2/evm/swaps/quote", async info => {
|
|
177
|
+
await delay(0);
|
|
178
|
+
|
|
179
|
+
return new HttpResponse(
|
|
180
|
+
JSON.stringify(
|
|
181
|
+
overrideResponse !== undefined
|
|
182
|
+
? typeof overrideResponse === "function"
|
|
183
|
+
? await overrideResponse(info)
|
|
184
|
+
: overrideResponse
|
|
185
|
+
: getGetEvmSwapPriceResponseMock(),
|
|
186
|
+
),
|
|
187
|
+
{ status: 200, headers: { "Content-Type": "application/json" } },
|
|
188
|
+
);
|
|
189
|
+
});
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
export const getCreateEvmSwapQuoteMockHandler = (
|
|
193
|
+
overrideResponse?:
|
|
194
|
+
| CreateSwapQuoteResponseWrapper
|
|
195
|
+
| ((
|
|
196
|
+
info: Parameters<Parameters<typeof http.post>[1]>[0],
|
|
197
|
+
) => Promise<CreateSwapQuoteResponseWrapper> | CreateSwapQuoteResponseWrapper),
|
|
198
|
+
) => {
|
|
199
|
+
return http.post("*/v2/evm/swaps", async info => {
|
|
200
|
+
await delay(0);
|
|
201
|
+
|
|
202
|
+
return new HttpResponse(
|
|
203
|
+
JSON.stringify(
|
|
204
|
+
overrideResponse !== undefined
|
|
205
|
+
? typeof overrideResponse === "function"
|
|
206
|
+
? await overrideResponse(info)
|
|
207
|
+
: overrideResponse
|
|
208
|
+
: getCreateEvmSwapQuoteResponseMock(),
|
|
209
|
+
),
|
|
210
|
+
{ status: 201, headers: { "Content-Type": "application/json" } },
|
|
211
|
+
);
|
|
212
|
+
});
|
|
213
|
+
};
|
|
214
|
+
export const getEvmSwapsMock = () => [
|
|
215
|
+
getGetEvmSwapPriceMockHandler(),
|
|
216
|
+
getCreateEvmSwapQuoteMockHandler(),
|
|
217
|
+
];
|