@circle-fin/app-kit 1.16.0 → 1.17.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/earn.mjs CHANGED
@@ -743,6 +743,11 @@ class KitError extends Error {
743
743
  code: 5001,
744
744
  name: 'ONCHAIN_TRANSACTION_REVERTED',
745
745
  type: 'ONCHAIN'
746
+ },
747
+ /** Pre-flight transaction simulation failed */ SIMULATION_FAILED: {
748
+ code: 5002,
749
+ name: 'ONCHAIN_SIMULATION_FAILED',
750
+ type: 'ONCHAIN'
746
751
  }};
747
752
  /**
748
753
  * Standardized error definitions for LIQUIDITY type errors.
@@ -1165,6 +1170,49 @@ class KitError extends Error {
1165
1170
  return new KitError(errorDetails);
1166
1171
  }
1167
1172
 
1173
+ /**
1174
+ * Creates error for transaction simulation failures.
1175
+ *
1176
+ * This error is thrown when a pre-flight transaction simulation fails,
1177
+ * typically due to contract logic that would revert. The error is FATAL
1178
+ * as it indicates the transaction would fail if submitted.
1179
+ *
1180
+ * @param chain - The blockchain network where the simulation failed
1181
+ * @param reason - The reason for simulation failure (e.g., revert message)
1182
+ * @param trace - Optional trace context to include in error (can include rawError and additional debugging data)
1183
+ * @returns KitError with simulation failure details
1184
+ *
1185
+ * @example
1186
+ * ```typescript
1187
+ * import { createSimulationFailedError } from '@core/errors'
1188
+ *
1189
+ * throw createSimulationFailedError('Ethereum', 'ERC20: insufficient allowance')
1190
+ * // Message: "Simulation failed on Ethereum: ERC20: insufficient allowance"
1191
+ * ```
1192
+ *
1193
+ * @example
1194
+ * ```typescript
1195
+ * // With trace context for debugging
1196
+ * throw createSimulationFailedError('Ethereum', 'ERC20: insufficient allowance', {
1197
+ * rawError: error,
1198
+ * txHash: '0x1234...',
1199
+ * gasLimit: '21000',
1200
+ * })
1201
+ * ```
1202
+ */ function createSimulationFailedError(chain, reason, trace) {
1203
+ return new KitError({
1204
+ ...OnchainError.SIMULATION_FAILED,
1205
+ recoverability: 'FATAL',
1206
+ message: `Simulation failed on ${chain}: ${reason}`,
1207
+ cause: {
1208
+ trace: {
1209
+ ...trace,
1210
+ chain,
1211
+ reason
1212
+ }
1213
+ }
1214
+ });
1215
+ }
1168
1216
  /**
1169
1217
  * Creates error for transaction reverts.
1170
1218
  *
@@ -1219,6 +1267,82 @@ class KitError extends Error {
1219
1267
  });
1220
1268
  }
1221
1269
 
1270
+ /**
1271
+ * Matches revert data: a 4-byte selector followed by whole ABI-encoded bytes.
1272
+ */ const REVERT_DATA_PATTERN = /^0x[0-9a-f]{8}(?:[0-9a-f]{2})*$/i;
1273
+ /**
1274
+ * Returns the revert data held by one error in a `cause` chain.
1275
+ *
1276
+ * Browser wallets (EIP-1193) wrap the node's error, so the revert data sits
1277
+ * one level down as `data.data`. viem's `getContractError` reads it the same
1278
+ * way, then keeps it on `ContractFunctionRevertedError.raw` and drops the
1279
+ * node's error from the chain.
1280
+ *
1281
+ * @param link - One error in the `cause` chain
1282
+ * @returns The `raw` or `data` string, or undefined if there is none
1283
+ */ function getRevertData(link) {
1284
+ if ('raw' in link && typeof link.raw === 'string' && REVERT_DATA_PATTERN.test(link.raw)) {
1285
+ return link.raw;
1286
+ }
1287
+ if (!('data' in link)) {
1288
+ return undefined;
1289
+ }
1290
+ const { data } = link;
1291
+ if (typeof data === 'string') {
1292
+ return data;
1293
+ }
1294
+ if (data !== null && typeof data === 'object' && 'data' in data && typeof data.data === 'string') {
1295
+ return data.data;
1296
+ }
1297
+ return undefined;
1298
+ }
1299
+ /**
1300
+ * Finds the first revert data on the error or in its `cause` chain that
1301
+ * `accept` takes.
1302
+ *
1303
+ * viem keeps the node's revert data on an inner `RpcRequestError`, not on
1304
+ * the error it throws. The `seen` set stops a self-referencing `cause` chain.
1305
+ *
1306
+ * @param error - The error object
1307
+ * @param accept - Returns true for the data shape the caller wants
1308
+ * @returns The data as written on the error, or undefined if not found
1309
+ */ function findRevertData(error, accept) {
1310
+ const seen = new Set();
1311
+ let current = error;
1312
+ while(current !== null && typeof current === 'object' && !seen.has(current)){
1313
+ seen.add(current);
1314
+ const data = getRevertData(current);
1315
+ if (data !== undefined && accept(data)) {
1316
+ return data;
1317
+ }
1318
+ current = 'cause' in current ? current.cause : undefined;
1319
+ }
1320
+ return undefined;
1321
+ }
1322
+ /**
1323
+ * Finds the raw revert data on an error or anywhere in its `cause` chain.
1324
+ *
1325
+ * Reads `data`, the nested `data.data` from browser wallets, and viem's
1326
+ * `raw`. Only hex of at least 4 bytes counts, so decoded `data` objects and
1327
+ * empty `0x` data are skipped.
1328
+ *
1329
+ * Revert data is public: it is what the contract returned. Keep it when the
1330
+ * rest of a raw error is redacted, so callers can still decode the revert.
1331
+ *
1332
+ * @param error - The raw error from the blockchain library
1333
+ * @returns The revert data in lowercase, or undefined if there is none
1334
+ *
1335
+ * @example
1336
+ * ```typescript
1337
+ * import { extractRevertData } from '@core/errors'
1338
+ *
1339
+ * extractRevertData({ cause: { data: { data: '0xF64059DB' } } })
1340
+ * // Returns: '0xf64059db'
1341
+ * ```
1342
+ */ function extractRevertData(error) {
1343
+ return findRevertData(error, (data)=>REVERT_DATA_PATTERN.test(data))?.toLowerCase();
1344
+ }
1345
+
1222
1346
  /**
1223
1347
  * Type guard to check if an error is a KitError instance.
1224
1348
  *
@@ -2004,7 +2128,7 @@ class KitError extends Error {
2004
2128
  * between input errors (fix your request) and service errors (retry later).
2005
2129
  *
2006
2130
  * Error code ranges:
2007
- * - 1100-1106: INPUT errors — invalid, unsupported, or stale request state
2131
+ * - 1100-1107: INPUT errors — invalid, unsupported, or stale request state
2008
2132
  * - 8100-8105: SERVICE errors — retryable backend/provider failures
2009
2133
  *
2010
2134
  * @example
@@ -2065,6 +2189,15 @@ class KitError extends Error {
2065
2189
  name: 'EARN_BRIDGE_QUOTE_EXPIRED',
2066
2190
  type: 'INPUT'
2067
2191
  },
2192
+ /**
2193
+ * The wallet's vault shares are inside the vault's share lock period, which
2194
+ * starts at deposit. Surfaced as FATAL rather than RETRYABLE because the
2195
+ * lock can last hours, so an immediate retry fails the same way.
2196
+ */ SHARES_LOCKED: {
2197
+ code: 1107,
2198
+ name: 'EARN_SHARES_LOCKED',
2199
+ type: 'INPUT'
2200
+ },
2068
2201
  /** The proxy signing call failed — retryable. */ SIGNING_FAILED: {
2069
2202
  code: 8100,
2070
2203
  name: 'EARN_SIGNING_FAILED',
@@ -2537,6 +2670,8 @@ var SwapChain;
2537
2670
  SwapChain["HyperEVM"] = "HyperEVM";
2538
2671
  SwapChain["Monad"] = "Monad";
2539
2672
  SwapChain["Arc"] = "Arc";
2673
+ SwapChain["Cronos"] = "Cronos";
2674
+ SwapChain["Morph"] = "Morph";
2540
2675
  // Testnet chains with swap support
2541
2676
  SwapChain["Arc_Testnet"] = "Arc_Testnet";
2542
2677
  })(SwapChain || (SwapChain = {}));
@@ -3869,7 +4004,8 @@ var BorrowChain;
3869
4004
  }
3870
4005
  },
3871
4006
  kitContracts: {
3872
- bridge: BRIDGE_CONTRACT_EVM_MAINNET
4007
+ bridge: BRIDGE_CONTRACT_EVM_MAINNET,
4008
+ adapter: ADAPTER_CONTRACT_EVM_MAINNET
3873
4009
  }
3874
4010
  });
3875
4011
 
@@ -4738,7 +4874,8 @@ var BorrowChain;
4738
4874
  }
4739
4875
  },
4740
4876
  kitContracts: {
4741
- bridge: BRIDGE_CONTRACT_EVM_MAINNET
4877
+ bridge: BRIDGE_CONTRACT_EVM_MAINNET,
4878
+ adapter: ADAPTER_CONTRACT_EVM_MAINNET
4742
4879
  }
4743
4880
  });
4744
4881
 
@@ -6628,6 +6765,56 @@ var Chains = /*#__PURE__*/Object.freeze({
6628
6765
  Blockchain.World_Chain_Sepolia
6629
6766
  ]);
6630
6767
 
6768
+ /**
6769
+ * Check if a chain supports a specific type of custom smart contract logic.
6770
+ *
6771
+ * This function examines a chain definition to determine if it has a specific
6772
+ * contract type configured. When a chain has custom contract support, it can
6773
+ * use enhanced features and custom business logic in addition to the standard
6774
+ * CCTP approve/burn/mint flow.
6775
+ *
6776
+ * @param chain - The chain definition to examine for custom contract support.
6777
+ * @param contractType - The type of contract to check for (e.g., 'bridge').
6778
+ * @returns True if the chain supports the specified contract type with a valid address configured.
6779
+ *
6780
+ * @example
6781
+ * ```typescript
6782
+ * import { hasCustomContractSupport, Ethereum } from '@core/chains'
6783
+ *
6784
+ * // Check if a chain supports bridge contracts
6785
+ * if (hasCustomContractSupport(Ethereum, 'bridge')) {
6786
+ * // Runtime validation confirmed kitContracts.bridge exists
6787
+ * console.log('Bridge contract:', Ethereum.kitContracts?.bridge)
6788
+ * return executeCustomFlow(Ethereum.kitContracts?.bridge!, params)
6789
+ * } else {
6790
+ * console.log('Using standard CCTP flow')
6791
+ * return executeStandardFlow(params)
6792
+ * }
6793
+ * ```
6794
+ *
6795
+ * @example
6796
+ * ```typescript
6797
+ * // Usage in flow determination
6798
+ * function determineBridgingFlow(chain: ChainDefinition, params: BridgeParams) {
6799
+ * if (hasCustomContractSupport(chain, 'bridge')) {
6800
+ * return 'custom'
6801
+ * } else if (isCCTPV2Supported(chain)) {
6802
+ * return 'standard'
6803
+ * } else {
6804
+ * throw new Error(`Chain ${chain.name} is not supported for bridging`)
6805
+ * }
6806
+ * }
6807
+ *
6808
+ * // Future usage with other contract types (when added to KitContractType)
6809
+ * // if (hasCustomContractSupport(someChain, 'customType')) {
6810
+ * // console.log('Custom contract:', someChain.kitContracts?.customType)
6811
+ * // }
6812
+ * ```
6813
+ */ function hasCustomContractSupport(chain, contractType) {
6814
+ const contractAddress = chain.kitContracts?.[contractType];
6815
+ return typeof contractAddress === 'string' && contractAddress.trim().length > 0;
6816
+ }
6817
+
6631
6818
  /**
6632
6819
  * Temporary allowlist of chains permitted to initiate Gateway fast deposits.
6633
6820
  * Only chains keyed here are eligible; all others are rejected. Using the
@@ -6881,8 +7068,8 @@ var Chains = /*#__PURE__*/Object.freeze({
6881
7068
  * Zod schema for validating swap-specific chain identifiers.
6882
7069
  *
6883
7070
  * Validates chains based on:
6884
- * - CCTPv2 support (adapter contract deployed)
6885
- * - Mainnet only (no testnets)
7071
+ * - Membership in the SwapChain enum
7072
+ * - Mainnet or explicitly allowlisted testnet
6886
7073
  * - At least one supported token available
6887
7074
  *
6888
7075
  */ const swapChainIdentifierSchema = z.union([
@@ -7287,7 +7474,7 @@ const swapTokenEnumSchema = z.enum([
7287
7474
  *
7288
7475
  * A chain supports swaps if ALL conditions are met:
7289
7476
  * 1. Is a member of the {@link SwapChain} enum
7290
- * 2. Has CCTPv2 support (adapter contract deployed)
7477
+ * 2. Has an Adapter contract configured directly or through CCTP v2
7291
7478
  *
7292
7479
  * Testnets are allowed only when explicitly listed in the
7293
7480
  * {@link SwapChain} enum (e.g., Arc_Testnet).
@@ -7308,14 +7495,14 @@ const swapTokenEnumSchema = z.enum([
7308
7495
  * @remarks
7309
7496
  * Chains automatically become swap-enabled when:
7310
7497
  * - Added to the {@link SwapChain} enum
7311
- * - Adapter contract is deployed (CCTPv2)
7498
+ * - An Adapter contract is deployed and configured
7312
7499
  *
7313
7500
  * No code changes needed when new chains are added!
7314
7501
  */ function isSwapSupportedChain(chain) {
7315
7502
  if (!(chain.chain in SwapChain)) {
7316
7503
  return false;
7317
7504
  }
7318
- if (!isCCTPV2Supported(chain)) {
7505
+ if (!isCCTPV2Supported(chain) && !hasCustomContractSupport(chain, 'adapter')) {
7319
7506
  return false;
7320
7507
  }
7321
7508
  return true;
@@ -7326,7 +7513,7 @@ const swapTokenEnumSchema = z.enum([
7326
7513
  *
7327
7514
  * Dynamically filter chain definitions to include only those that:
7328
7515
  * - Are members of the {@link SwapChain} enum
7329
- * - Have CCTPv2 support
7516
+ * - Have an Adapter contract configured directly or through CCTP v2
7330
7517
  *
7331
7518
  * This function is pure and accepts chains as parameter to avoid
7332
7519
  * circular dependencies.
@@ -8199,11 +8386,13 @@ const swapTokenEnumSchema = z.enum([
8199
8386
  [Blockchain.Arbitrum]: '0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9',
8200
8387
  [Blockchain.Avalanche]: '0x9702230A8Ea53601f5cD2dc00fDBc13d4dF4A8c7',
8201
8388
  [Blockchain.Celo]: '0x48065fbBE25f71C9282ddf5e1cD6D6A887483D5e',
8389
+ [Blockchain.Cronos]: '0x66e428c3f67a68878562e79A0234c1F83c208770',
8202
8390
  [Blockchain.Ethereum]: '0xdAC17F958D2ee523a2206206994597C13D831ec7',
8203
8391
  [Blockchain.HyperEVM]: '0xb8ce59fc3717ada4c02eadf9682a9e934f625ebb',
8204
8392
  [Blockchain.Ink]: '0x0200C29006150606B650577BBE7B6248F58470c1',
8205
8393
  [Blockchain.Linea]: '0xA219439258ca9da29E9Cc4cE5596924745e12B93',
8206
8394
  [Blockchain.Monad]: '0xe7cd86e13AC4309349F30B3435a9d337750fC82D',
8395
+ [Blockchain.Morph]: '0xe7cd86e13AC4309349F30B3435a9d337750fC82D',
8207
8396
  [Blockchain.NEAR]: 'usdt.tether-token.near',
8208
8397
  [Blockchain.Optimism]: '0x94b008aA00579c1307B0EF2c499aD98a8ce58e58',
8209
8398
  [Blockchain.Polkadot_Asset_Hub]: '1984',
@@ -8262,6 +8451,7 @@ const swapTokenEnumSchema = z.enum([
8262
8451
  [Blockchain.Arbitrum]: '0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1',
8263
8452
  [Blockchain.Avalanche]: '0xd586E7F844cEa2F87f50152665BCbc2C279D8d70',
8264
8453
  [Blockchain.Base]: '0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb',
8454
+ [Blockchain.Cronos]: '0xF2001B145b43032AAF5Ee2884e456CCd805F677D',
8265
8455
  [Blockchain.Ethereum]: '0x6B175474E89094C44Da98b954EedeAC495271d0F',
8266
8456
  [Blockchain.Linea]: '0x4AF15ec2A0BD43Db75dd04E62FAA3B8EF36b00d5',
8267
8457
  [Blockchain.Optimism]: '0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1',
@@ -8324,7 +8514,9 @@ const swapTokenEnumSchema = z.enum([
8324
8514
  [Blockchain.Arbitrum]: '0x82aF49447D8a07e3bd95BD0d56f35241523fBab1',
8325
8515
  [Blockchain.Avalanche]: '0x49D5c2BdFfac6CE2BFdB6640F4F80f226bc10bAB',
8326
8516
  [Blockchain.Base]: '0x4200000000000000000000000000000000000006',
8517
+ [Blockchain.Cronos]: '0xe44Fd7fCb2b1581822D0c862B68222998a0c299a',
8327
8518
  [Blockchain.Ethereum]: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
8519
+ [Blockchain.Morph]: '0x5300000000000000000000000000000000000011',
8328
8520
  [Blockchain.Optimism]: '0x4200000000000000000000000000000000000006',
8329
8521
  [Blockchain.Polygon]: '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619',
8330
8522
  [Blockchain.Solana]: '7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs'
@@ -8343,6 +8535,7 @@ const swapTokenEnumSchema = z.enum([
8343
8535
  locators: {
8344
8536
  [Blockchain.Ethereum]: '0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599',
8345
8537
  [Blockchain.Arbitrum]: '0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f',
8538
+ [Blockchain.Cronos]: '0x062E66477Faf219F25D27dCED647BF57C3107d52',
8346
8539
  [Blockchain.Avalanche]: '0x50b7545627a5162F82A992c33b87aDc75187B218'
8347
8540
  }
8348
8541
  };
@@ -9361,7 +9554,7 @@ const swapTokenEnumSchema = z.enum([
9361
9554
  }
9362
9555
 
9363
9556
  var name$4 = "@circle-fin/bridge-kit";
9364
- var version$4 = "1.15.2";
9557
+ var version$4 = "1.15.3";
9365
9558
  var pkg$4 = {
9366
9559
  name: name$4,
9367
9560
  version: version$4};
@@ -11157,7 +11350,7 @@ const validateQuoteItemSchema = z.object({
11157
11350
  registerKit(`${pkg$4.name}/${pkg$4.version}`);
11158
11351
 
11159
11352
  var name$3 = "@circle-fin/swap-kit";
11160
- var version$3 = "1.7.1";
11353
+ var version$3 = "1.8.0";
11161
11354
  var pkg$3 = {
11162
11355
  name: name$3,
11163
11356
  version: version$3};
@@ -11499,6 +11692,64 @@ const optionalChainIdentifierField = chainIdentifierField.optional();
11499
11692
  }, {
11500
11693
  message: 'fee amount must be non-negative (>= 0)'
11501
11694
  });
11695
+ /**
11696
+ * Parses a display-only field leniently: a value `schema` rejects is replaced
11697
+ * with `fallback` instead of failing the response that carries it.
11698
+ * Implemented with `preprocess` rather than Zod's `.catch()` because static
11699
+ * analysis misreads `.catch` on the schema chain as an unhandled Promise
11700
+ * (S7785).
11701
+ */ const withFallback = (schema, fallback)=>z.preprocess((value)=>schema.safeParse(value).success ? value : fallback, schema);
11702
+ const swapRouteTokenSchema = z.object({
11703
+ symbol: z.string(),
11704
+ address: z.string(),
11705
+ decimals: z.number()
11706
+ });
11707
+ const swapRouteMetadataSchema = z.record(z.unknown()).optional();
11708
+ const swapRouteStepSchema = z.object({
11709
+ type: z.string(),
11710
+ tool: z.string(),
11711
+ toolName: z.string(),
11712
+ fromToken: swapRouteTokenSchema,
11713
+ toToken: swapRouteTokenSchema,
11714
+ estimate: z.object({
11715
+ fromAmount: z.string(),
11716
+ toAmount: z.string(),
11717
+ gasCostUSD: z.string().optional()
11718
+ }),
11719
+ metadata: swapRouteMetadataSchema
11720
+ });
11721
+ /**
11722
+ * Strict schema for a `SwapRoute`. Module-private: service responses
11723
+ * parse routes leniently through {@link responseSwapRouteSchema}.
11724
+ */ const swapRouteSchema = z.object({
11725
+ provider: z.string().min(1, 'provider must be a non-empty string'),
11726
+ steps: z.array(swapRouteStepSchema),
11727
+ metadata: swapRouteMetadataSchema
11728
+ });
11729
+ /**
11730
+ * Route details are display-only, so service responses parse them leniently:
11731
+ * steps or metadata in a shape the SDK does not know are dropped rather than
11732
+ * failing the quote or swap they describe. Steps are all-or-nothing: if any
11733
+ * step is malformed, `steps` is empty, so a route never silently loses a hop.
11734
+ */ const responseSwapRouteSchema = swapRouteSchema.extend({
11735
+ steps: withFallback(swapRouteSchema.shape.steps, []),
11736
+ metadata: withFallback(swapRouteMetadataSchema, undefined)
11737
+ });
11738
+ const createSwapFeeItemSchema = z.object({
11739
+ token: z.string({
11740
+ required_error: 'fee token is required',
11741
+ invalid_type_error: 'fee token must be a string'
11742
+ }).min(1, 'fee token must be a non-empty string'),
11743
+ amount: feeAmountSchema,
11744
+ decimals: z.number().int('fee token decimals must be an integer').nonnegative('fee token decimals must be a non-negative integer').optional(),
11745
+ symbol: z.string({
11746
+ invalid_type_error: 'fee token symbol must be a string'
11747
+ }).min(1, 'fee token symbol must be a non-empty string').optional(),
11748
+ // Descriptive metadata: a value the SDK cannot use is dropped rather than
11749
+ // failing the response that carries the fee.
11750
+ type: withFallback(z.string().min(1).optional(), undefined),
11751
+ chain: withFallback(z.string().min(1).optional(), undefined)
11752
+ });
11502
11753
  /**
11503
11754
  * Zod schema for validating API keys.
11504
11755
  *
@@ -11584,10 +11835,7 @@ const optionalChainIdentifierField = chainIdentifierField.optional();
11584
11835
  /** Quote information with estimated amounts and route */ quote: z.object({
11585
11836
  /** Estimated output amount (base units) */ estimatedAmount: z.string().min(1, 'estimatedAmount must be a non-empty string').regex(/^\d+$/, 'estimatedAmount must be a numeric string'),
11586
11837
  /** Guaranteed minimum output amount (base units) */ minAmount: z.string().min(1, 'minAmount must be a non-empty string').regex(/^\d+$/, 'minAmount must be a numeric string'),
11587
- /** Route information from DEX aggregator */ route: z.object({
11588
- provider: z.string().min(1, 'provider must be a non-empty string'),
11589
- steps: z.array(z.unknown())
11590
- })
11838
+ /** Route information from DEX aggregator */ route: responseSwapRouteSchema
11591
11839
  }),
11592
11840
  /** Fee context indicating where fees should be collected */ feeContext: quoteFeeContextSchema
11593
11841
  });
@@ -11803,19 +12051,6 @@ getQuoteRequestBaseSchema.superRefine(requireCrossChainQuoteToAddress);
11803
12051
  }).min(1, 'toChain must be a non-empty string if provided').optional(),
11804
12052
  apiKey: apiKeySchema.optional()
11805
12053
  });
11806
- /**
11807
- * Zod schema for validating CreateSwapResponse payloads.
11808
- */ const createSwapFeeItemSchema = z.object({
11809
- token: z.string({
11810
- required_error: 'fee token is required',
11811
- invalid_type_error: 'fee token must be a string'
11812
- }).min(1, 'fee token must be a non-empty string'),
11813
- amount: feeAmountSchema,
11814
- decimals: z.number().int('fee token decimals must be an integer').nonnegative('fee token decimals must be a non-negative integer').optional(),
11815
- symbol: z.string({
11816
- invalid_type_error: 'fee token symbol must be a string'
11817
- }).min(1, 'fee token symbol must be a non-empty string').optional()
11818
- });
11819
12054
  /**
11820
12055
  * Developer fee item schema with basis field.
11821
12056
  */ const createSwapDeveloperFeeItemSchema = createSwapFeeItemSchema.extend({
@@ -11953,6 +12188,8 @@ getQuoteRequestBaseSchema.superRefine(requireCrossChainQuoteToAddress);
11953
12188
  correlationId: z.preprocess((value)=>z.string().uuid().safeParse(value).success ? value : undefined, z.string().optional()),
11954
12189
  config: createSwapRequestBaseSchema.shape.config.optional(),
11955
12190
  fees: createSwapFeesSchema.optional(),
12191
+ // A route the SDK cannot parse is dropped instead of failing the swap.
12192
+ route: withFallback(responseSwapRouteSchema.optional(), undefined),
11956
12193
  transaction: createSwapTransactionSchema
11957
12194
  });
11958
12195
 
@@ -14915,6 +15152,16 @@ createTokenRegistry();
14915
15152
  name: 'USDC',
14916
15153
  version: '2'
14917
15154
  },
15155
+ Cronos: {
15156
+ chainId: Cronos.chainId,
15157
+ name: 'USDC',
15158
+ version: '2'
15159
+ },
15160
+ Morph: {
15161
+ chainId: Morph.chainId,
15162
+ name: 'USDC',
15163
+ version: '2'
15164
+ },
14918
15165
  Arc_Testnet: {
14919
15166
  chainId: ArcTestnet.chainId,
14920
15167
  name: 'USDC',
@@ -15003,6 +15250,7 @@ const optionalSwapChainIdentifierField = swapChainIdentifierField.optional();
15003
15250
  * - customFee: Optional fee configuration
15004
15251
  * - apiKey: Optional credential string
15005
15252
  * - kitKey: Optional credential string (deprecated alias for apiKey)
15253
+ * - batchTransactions: Optional boolean to opt out of atomic batching
15006
15254
  */ const swapConfigSchema = z.object({
15007
15255
  allowanceStrategy: allowanceStrategySchema.optional(),
15008
15256
  slippageBps: z.number().int().min(0).optional(),
@@ -15013,7 +15261,10 @@ const optionalSwapChainIdentifierField = swapChainIdentifierField.optional();
15013
15261
  })(z.string())).optional(),
15014
15262
  customFee: swapCustomFeeSchema.optional(),
15015
15263
  apiKey: z.string().optional(),
15016
- kitKey: z.string().optional()
15264
+ kitKey: z.string().optional(),
15265
+ batchTransactions: z.boolean({
15266
+ invalid_type_error: 'batchTransactions must be a boolean'
15267
+ }).optional()
15017
15268
  });
15018
15269
  const swapDestinationSchema = z.object({
15019
15270
  chain: optionalSwapChainIdentifierField,
@@ -15206,7 +15457,7 @@ new Set(Object.values(Blockchain));
15206
15457
  registerKit(`${pkg$3.name}/${pkg$3.version}`);
15207
15458
 
15208
15459
  var name$2 = "@circle-fin/earn-kit";
15209
- var version$2 = "1.8.1";
15460
+ var version$2 = "1.9.0";
15210
15461
  var pkg$2 = {
15211
15462
  name: name$2,
15212
15463
  version: version$2};
@@ -16956,6 +17207,187 @@ function isCrossChainDepositStatusStep(step) {
16956
17207
  return step.name === 'status';
16957
17208
  }
16958
17209
 
17210
+ /**
17211
+ * Selector of `TellerWithMultiAssetSupport__SharesAreLocked()`.
17212
+ */ const SHARES_LOCKED_SELECTOR = '0xf64059db';
17213
+ /**
17214
+ * Readable reasons for Veda BoringVault Teller and Accountant reverts.
17215
+ */ const VEDA_REVERT_REASONS = {
17216
+ '0xe0f9e71d': 'The vault is paused',
17217
+ '0x3b3132f6': 'The vault exchange rate is paused',
17218
+ '0xc8bfa33e': 'The vault does not support this asset for this operation',
17219
+ '0x4b37cd2a': 'The asset amount must be greater than zero',
17220
+ '0x3a8c54c4': 'The share amount must be greater than zero',
17221
+ '0x4bd956a8': 'The deposit would mint fewer vault shares than the signed minimum',
17222
+ '0x9883d840': 'The withdrawal would pay out fewer assets than the signed minimum',
17223
+ '0xed32f3bb': 'The deposit would exceed the vault deposit cap',
17224
+ '0x1b8851f0': 'The permit failed and the token allowance is too low',
17225
+ '0x2821264f': 'The vault denied the share transfer'
17226
+ };
17227
+ /**
17228
+ * Matches a 4-byte selector in a message. The lookarounds stop a longer hex
17229
+ * value, such as an address or a hash, from matching.
17230
+ */ const SELECTOR_IN_TEXT = /(?<![0-9a-fx])0x[0-9a-f]{8}(?![0-9a-f])/gi;
17231
+ function toRecord(value) {
17232
+ return typeof value === 'object' && value !== null ? value : {};
17233
+ }
17234
+ function isVedaSelector(selector) {
17235
+ return selector === SHARES_LOCKED_SELECTOR || selector in VEDA_REVERT_REASONS;
17236
+ }
17237
+ /**
17238
+ * Reads the selector from the revert data on a trace. The `/next` adapters
17239
+ * keep it on `revertData`. The default adapters keep the whole raw error on
17240
+ * `rawError`.
17241
+ */ function selectorFromData(trace) {
17242
+ const data = typeof trace['revertData'] === 'string' ? trace['revertData'] : extractRevertData(trace['rawError']);
17243
+ const selector = data?.slice(0, 10).toLowerCase();
17244
+ return selector !== undefined && isVedaSelector(selector) ? selector : undefined;
17245
+ }
17246
+ /**
17247
+ * Reads the selector from error text, for wallets that return no revert
17248
+ * data and put the selector or the decoded error name in the message.
17249
+ */ function selectorFromText(texts) {
17250
+ for (const text of texts){
17251
+ if (typeof text !== 'string') {
17252
+ continue;
17253
+ }
17254
+ if (/SharesAreLocked/i.test(text)) {
17255
+ return SHARES_LOCKED_SELECTOR;
17256
+ }
17257
+ const selector = text.match(SELECTOR_IN_TEXT)?.map((match)=>match.toLowerCase()).find(isVedaSelector);
17258
+ if (selector !== undefined) {
17259
+ return selector;
17260
+ }
17261
+ }
17262
+ return undefined;
17263
+ }
17264
+ /**
17265
+ * Reads a Veda revert from one error, without looking at nested errors.
17266
+ */ function readVedaRevert(error) {
17267
+ const trace = toRecord(error.cause?.trace);
17268
+ const selector = selectorFromData(trace) ?? selectorFromText([
17269
+ error.message,
17270
+ trace['reason']
17271
+ ]);
17272
+ if (selector === undefined) {
17273
+ return undefined;
17274
+ }
17275
+ const chain = trace['chain'];
17276
+ return {
17277
+ selector,
17278
+ chain: typeof chain === 'string' ? chain : undefined
17279
+ };
17280
+ }
17281
+ /**
17282
+ * Returns the errors that a failed batch nests under `trace.cause` or
17283
+ * `trace.error`.
17284
+ */ function nestedErrors(error) {
17285
+ const trace = toRecord(error.cause?.trace);
17286
+ return [
17287
+ trace['cause'],
17288
+ trace['error']
17289
+ ].filter(isKitError);
17290
+ }
17291
+ /**
17292
+ * Finds a Veda revert on the error or on an error nested in its trace.
17293
+ */ function findVedaRevert(error) {
17294
+ const seen = new Set();
17295
+ const pending = [
17296
+ error
17297
+ ];
17298
+ let current = pending.pop();
17299
+ while(current !== undefined){
17300
+ if (!seen.has(current)) {
17301
+ seen.add(current);
17302
+ const revert = readVedaRevert(current);
17303
+ if (revert !== undefined) {
17304
+ return {
17305
+ ...revert,
17306
+ nested: current !== error
17307
+ };
17308
+ }
17309
+ pending.push(...nestedErrors(current));
17310
+ }
17311
+ current = pending.pop();
17312
+ }
17313
+ return undefined;
17314
+ }
17315
+ /**
17316
+ * Map a Veda vault revert to an Earn error.
17317
+ *
17318
+ * A Teller `SharesAreLocked()` revert becomes `EARN_SHARES_LOCKED`. Other
17319
+ * known Veda reverts keep their simulation failed or transaction reverted
17320
+ * code and get a readable reason. A failed batch that wraps a Veda revert
17321
+ * keeps its code, and the reason is added to its message. A timed out batch
17322
+ * is returned unchanged, because its outcome is unknown. Any other error is
17323
+ * returned unchanged.
17324
+ *
17325
+ * @param error - The error caught from an earn operation.
17326
+ * @returns The mapped error, or `error` when it is not a Veda revert.
17327
+ *
17328
+ * @example
17329
+ * ```typescript
17330
+ * import { mapVedaRevert } from './vedaRevert'
17331
+ *
17332
+ * const mapped = mapVedaRevert(error)
17333
+ * console.log(mapped.name) // 'EARN_SHARES_LOCKED' for a share lock revert
17334
+ * ```
17335
+ *
17336
+ * @internal
17337
+ */ function mapVedaRevert(error) {
17338
+ if (error.name === NetworkError.TIMEOUT.name) {
17339
+ return error;
17340
+ }
17341
+ const revert = findVedaRevert(error);
17342
+ if (revert === undefined) {
17343
+ return error;
17344
+ }
17345
+ const trace = toRecord(error.cause?.trace);
17346
+ const chain = typeof trace['chain'] === 'string' ? trace['chain'] : revert.chain ?? 'EVM';
17347
+ if (revert.selector === SHARES_LOCKED_SELECTOR) {
17348
+ return new KitError({
17349
+ ...EarnError.SHARES_LOCKED,
17350
+ // The lock can last hours, so an immediate retry fails the same way.
17351
+ recoverability: 'FATAL',
17352
+ message: `Vault shares on ${chain} are still locked after a recent deposit. Wait for the vault's share lock period to end, then try again.`,
17353
+ cause: {
17354
+ trace: {
17355
+ ...trace,
17356
+ selector: revert.selector,
17357
+ chain
17358
+ }
17359
+ }
17360
+ });
17361
+ }
17362
+ const readable = VEDA_REVERT_REASONS[revert.selector];
17363
+ if (readable === undefined) {
17364
+ return error;
17365
+ }
17366
+ const reason = `${readable} (${revert.selector})`;
17367
+ if (error.name === OnchainError.SIMULATION_FAILED.name) {
17368
+ return createSimulationFailedError(chain, reason, trace);
17369
+ }
17370
+ if (error.name === OnchainError.TRANSACTION_REVERTED.name) {
17371
+ return createTransactionRevertedError(chain, reason, trace);
17372
+ }
17373
+ if (!revert.nested) {
17374
+ return error;
17375
+ }
17376
+ return new KitError({
17377
+ code: error.code,
17378
+ name: error.name,
17379
+ type: error.type,
17380
+ recoverability: error.recoverability,
17381
+ message: `${error.message} Reason: ${reason}.`,
17382
+ cause: {
17383
+ trace: {
17384
+ ...trace,
17385
+ reason
17386
+ }
17387
+ }
17388
+ });
17389
+ }
17390
+
16959
17391
  const EARN_OPERATIONS = new Set([
16960
17392
  'deposit',
16961
17393
  'withdraw',
@@ -17001,6 +17433,10 @@ const EARN_OPERATIONS = new Set([
17001
17433
  * `RESUMABLE` so callers know `retry()` can resume from the failed phase. A
17002
17434
  * fatal underlying error stays fatal — it cannot be resumed.
17003
17435
  *
17436
+ * A Veda vault revert is mapped first (see {@link mapVedaRevert}): a share
17437
+ * lock becomes `EARN_SHARES_LOCKED`, and other known Veda reverts get a
17438
+ * readable reason.
17439
+ *
17004
17440
  * Non-{@link KitError} inputs (which should not occur on provider code paths)
17005
17441
  * are normalized to a retryable {@link ServiceError.INTERNAL_ERROR}.
17006
17442
  *
@@ -17022,7 +17458,7 @@ const EARN_OPERATIONS = new Set([
17022
17458
  * }
17023
17459
  * ```
17024
17460
  */ function augmentEarnError(error, context) {
17025
- const base = isKitError(error) ? error : new KitError({
17461
+ const base = isKitError(error) ? mapVedaRevert(error) : new KitError({
17026
17462
  ...ServiceError.INTERNAL_ERROR,
17027
17463
  recoverability: 'RETRYABLE',
17028
17464
  message: getErrorMessage(error)
@@ -17965,7 +18401,7 @@ const bridgeDepositPrepareReviewSchema = z.object({
17965
18401
  }
17966
18402
 
17967
18403
  var name$1 = "@circle-fin/provider-earn-service";
17968
- var version$1 = "1.7.1";
18404
+ var version$1 = "1.7.2";
17969
18405
  var pkg$1 = {
17970
18406
  name: name$1,
17971
18407
  version: version$1};
@@ -19226,7 +19662,7 @@ function reportTransactionFailure(reportContext, action, error) {
19226
19662
  }
19227
19663
  function transactionReportErrorCode(error) {
19228
19664
  if (isKitError(error)) {
19229
- return error.name;
19665
+ return mapVedaRevert(error).name;
19230
19666
  }
19231
19667
  const message = getErrorMessage(error);
19232
19668
  if (/user (rejected|denied)|rejected by user/i.test(message)) {
@@ -22585,7 +23021,7 @@ registerKit(`${pkg$2.name}/${pkg$2.version}`);
22585
23021
  };
22586
23022
 
22587
23023
  var name = "@circle-fin/borrow-kit";
22588
- var version = "1.0.0";
23024
+ var version = "1.1.0";
22589
23025
  var pkg = {
22590
23026
  name: name,
22591
23027
  version: version};