@avalabs/fusion-sdk 0.23.1 → 0.25.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.
Files changed (51) hide show
  1. package/dist/errors.cjs +1 -1
  2. package/dist/errors.cjs.map +1 -1
  3. package/dist/errors.d.cts +18 -1
  4. package/dist/errors.d.ts +18 -1
  5. package/dist/errors.js +1 -1
  6. package/dist/errors.js.map +1 -1
  7. package/dist/quoter/quoter.cjs.map +1 -1
  8. package/dist/quoter/quoter.d.cts +3 -1
  9. package/dist/quoter/quoter.d.ts +3 -1
  10. package/dist/quoter/quoter.js.map +1 -1
  11. package/dist/transfer-service/markr/_handlers/stream-quotes.cjs +1 -1
  12. package/dist/transfer-service/markr/_handlers/stream-quotes.cjs.map +1 -1
  13. package/dist/transfer-service/markr/_handlers/stream-quotes.js +1 -1
  14. package/dist/transfer-service/markr/_handlers/stream-quotes.js.map +1 -1
  15. package/dist/transfer-service/markr/_schema.cjs +1 -1
  16. package/dist/transfer-service/markr/_schema.cjs.map +1 -1
  17. package/dist/transfer-service/markr/_schema.js +1 -1
  18. package/dist/transfer-service/markr/_schema.js.map +1 -1
  19. package/dist/transfer-service/markr/_utils.cjs +1 -1
  20. package/dist/transfer-service/markr/_utils.cjs.map +1 -1
  21. package/dist/transfer-service/markr/_utils.js +1 -1
  22. package/dist/transfer-service/markr/_utils.js.map +1 -1
  23. package/dist/transfer-service/markr/recurring/_api.cjs +1 -1
  24. package/dist/transfer-service/markr/recurring/_api.cjs.map +1 -1
  25. package/dist/transfer-service/markr/recurring/_api.js +1 -1
  26. package/dist/transfer-service/markr/recurring/_api.js.map +1 -1
  27. package/dist/transfer-service/markr/recurring/_chain-info.cjs +1 -1
  28. package/dist/transfer-service/markr/recurring/_chain-info.cjs.map +1 -1
  29. package/dist/transfer-service/markr/recurring/_chain-info.js +1 -1
  30. package/dist/transfer-service/markr/recurring/_chain-info.js.map +1 -1
  31. package/dist/transfer-service/markr/recurring/_eligibility.cjs +1 -1
  32. package/dist/transfer-service/markr/recurring/_eligibility.cjs.map +1 -1
  33. package/dist/transfer-service/markr/recurring/_eligibility.js +1 -1
  34. package/dist/transfer-service/markr/recurring/_eligibility.js.map +1 -1
  35. package/dist/transfer-service/markr/recurring/_namespace.cjs +1 -1
  36. package/dist/transfer-service/markr/recurring/_namespace.cjs.map +1 -1
  37. package/dist/transfer-service/markr/recurring/_namespace.js +1 -1
  38. package/dist/transfer-service/markr/recurring/_namespace.js.map +1 -1
  39. package/dist/transfer-service/markr/recurring/_schema.cjs +1 -1
  40. package/dist/transfer-service/markr/recurring/_schema.cjs.map +1 -1
  41. package/dist/transfer-service/markr/recurring/_schema.js +1 -1
  42. package/dist/transfer-service/markr/recurring/_schema.js.map +1 -1
  43. package/dist/transfer-service/markr/recurring/types.cjs +1 -1
  44. package/dist/transfer-service/markr/recurring/types.cjs.map +1 -1
  45. package/dist/transfer-service/markr/recurring/types.d.cts +32 -23
  46. package/dist/transfer-service/markr/recurring/types.d.ts +32 -23
  47. package/dist/transfer-service/markr/recurring/types.js +1 -1
  48. package/dist/transfer-service/markr/recurring/types.js.map +1 -1
  49. package/dist/types/service.d.cts +3 -1
  50. package/dist/types/service.d.ts +3 -1
  51. package/package.json +3 -3
@@ -1 +1 @@
1
- {"version":3,"file":"types.cjs","names":[],"sources":["../../../../src/transfer-service/markr/recurring/types.ts"],"sourcesContent":["import type { Address as EvmAddress } from 'viem';\nimport type { Chain } from '../../../types/chain';\nimport type { GasSettings } from '../../../types/service';\nimport type { Hex } from '../../../types/signer';\n\n/**\n * Frequency units accepted by Markr's `/recurring/quote` and `/recurring/orders` endpoints.\n *\n * @see https://orchestrator-docs.markr.io/#/paths/~1recurring~1quote/post\n */\nexport const RECURRING_FREQUENCY_UNITS = ['minute', 'hour', 'day', 'week', 'month'] as const;\n\nexport type RecurringFrequencyUnit = (typeof RECURRING_FREQUENCY_UNITS)[number];\n\nexport interface RecurringFrequency {\n unit: RecurringFrequencyUnit;\n /**\n * Integer in `[1, 365]` (server-enforced upper bound). `validateFrequency`\n * surfaces violations as `{ ok: false, reason: 'invalid-value' }`.\n */\n value: number;\n}\n\n/**\n * Markr's \"unlimited orders\" sentinel. Sent to the server as `-1`, which the\n * router expands to `uint256` max on-chain. Callers can also pass `Infinity`\n * to {@link RecurringQuoteParams.numberOfOrders} for the same effect; the API\n * helpers translate to `-1` at the wire boundary.\n */\nexport const RECURRING_UNLIMITED_ORDERS_SENTINEL = -1;\n\n/**\n * Status values emitted by Markr for a recurring schedule. Treated as a\n * closed set — if Markr ever adds a new value server-side, the schema\n * will reject it loudly so the SDK update gates rendering changes\n * (instead of silently passing an unhandled state through to the UI).\n *\n * Mirrors the existing `TransferSignatureReason` enum pattern in\n * `constants.ts`: PascalCase members with kebab/lowercase wire values.\n */\nexport enum RecurringOrderStatus {\n Active = 'active',\n Completed = 'completed',\n Cancelled = 'cancelled',\n Paused = 'paused',\n}\n\nexport interface RecurringOrderFailure {\n /** 1-based index of the failed scheduled swap. */\n executionIndex: number;\n /** Reason strings supplied by the orchestrator (e.g. `\"Slippage tolerance exceeded\"`). */\n reasons: ReadonlyArray<string>;\n /** On-chain attempts before the execution was marked failed. */\n tryCount: number;\n /** Unix seconds. */\n failedAt: number;\n}\n\n/**\n * Server-side recurring-swap order returned by `GET /recurring/orders` and\n * `POST /recurring/orders/{orderId}/cancel`.\n *\n * @see https://orchestrator-docs.markr.io/#/Recurring%20Swaps\n */\nexport interface RecurringOrder {\n /**\n * bytes32 hex (`0x` + 64 hex chars). Used as the path param for cancellation.\n * Typed as a template-literal `0x`-prefixed string to catch the obvious\n * \"I forgot the `0x`\" mistake at compile time; the wire-level regex check\n * (in `markrCancelRecurringOrder`) enforces the full bytes32 shape.\n */\n orderId: `0x${string}`;\n /** EVM wallet that created the schedule. */\n owner: EvmAddress;\n chainId: number;\n tokenIn: EvmAddress;\n tokenOut: EvmAddress;\n /** Per-order input amount, in `tokenIn`'s smallest unit. */\n amount: bigint;\n /** -1 when unlimited; otherwise a positive integer (server-clamped to ≤ 365). */\n numberOfOrders: number;\n executedOrders: number;\n /**\n * `numberOfOrders - executedOrders` on finite schedules. `null` on\n * unlimited schedules (`numberOfOrders === -1`) — they have no finite\n * remainder to report. Per the Markr OpenAPI spec the field is\n * nullable; the schema also normalizes `undefined` to `null` so a\n * `=== null` check is sufficient.\n */\n remainingOrders: number | null;\n frequency: RecurringFrequency;\n /** `amount × numberOfOrders` — the ERC-20 allowance granted at setup. */\n totalAmountIn: bigint;\n /** Retry count for the *next* pending execution. `0` when none is pending. */\n tryCount: number;\n /** History of failed `executionIndex` values, newest last. */\n failures: ReadonlyArray<RecurringOrderFailure>;\n status: RecurringOrderStatus;\n /** Unix seconds. */\n createdAt: number;\n /**\n * Unix seconds. `null` once the schedule is completed / cancelled /\n * inactive. Per the Markr OpenAPI spec this field is optional + nullable;\n * the schema normalizes an omitted-field response to `null` so consumers\n * can branch on a single `=== null` check.\n */\n nextExecutionAt: number | null;\n /**\n * Unix seconds when the order was cancelled; `null` otherwise. Populated\n * with a number when `status === 'cancelled'`. Per the Markr OpenAPI spec\n * this field is optional + nullable; the schema normalizes both wire\n * shapes (`null` and omitted) to `null` for consumer ergonomics.\n */\n cancelledAt: number | null;\n}\n\n/**\n * Known fee types emitted by Markr today. Open at runtime — the schema\n * tolerates unknown values so a new fee category from the orchestrator doesn't\n * fail quote parsing. See {@link RecurringOrderStatus} for the widening\n * pattern.\n */\nexport type RecurringQuoteFeeType =\n | 'gas'\n | 'recurring'\n | 'protocol'\n | 'bridge'\n | 'slippage'\n | 'swap'\n | 'other'\n // See `RecurringOrderStatus` for why `Record<never, never>` replaces `{}`.\n | (string & Record<never, never>);\n\nexport interface RecurringQuoteFee {\n type: RecurringQuoteFeeType;\n name: string;\n amount: bigint;\n token: { chainId: number; address: EvmAddress };\n /**\n * Docs document `extra` as `boolean or object`. The boolean form is the\n * legacy \"additive one-time charge\" flag (e.g. the one-time native\n * schedule fee with `type: 'recurring'`); the object form is reserved\n * for future structured metadata. Consumers should treat any truthy\n * value as \"additive — balance-check separately.\"\n */\n extra?: boolean | Record<string, unknown>;\n}\n\nexport interface RecurringQuoteResponse {\n uuid: string;\n chainId: number;\n tokenIn: EvmAddress;\n tokenOut: EvmAddress;\n /** Per-order input. */\n amount: bigint;\n /** Server-side clamped value (may be 365 if the request was unlimited). */\n numberOfOrders: number;\n frequency: RecurringFrequency;\n /** Server-derived from `frequency`. */\n intervalSeconds: number;\n /** `amount × numberOfOrders` — the ERC-20 allowance the caller must grant. */\n totalAmountIn: bigint;\n /** First-fill output estimate. */\n amountOut: bigint;\n /** First-fill `minAmountOut` (slippage applied). */\n minAmountOut: bigint;\n fees: ReadonlyArray<RecurringQuoteFee>;\n /** Basis points. */\n recommendedSlippage: number;\n /** Unix seconds. */\n expiredAt: number;\n}\n\nexport interface RecurringQuoteParams {\n appId: string;\n chainId: number;\n tokenIn: EvmAddress;\n tokenInDecimals: number;\n tokenOut: EvmAddress;\n tokenOutDecimals: number;\n /**\n * Per-order input in smallest unit. `bigint` only — matches the rest of the\n * SDK's internal amount types (response amounts, `Quote.amountIn`, etc.).\n * Callers holding a decimal string should coerce with `BigInt(s)` at the\n * call site.\n */\n amount: bigint;\n /**\n * Number of orders. Accepts:\n * - `Infinity` or `-1` — translated to the unlimited sentinel (`-1`) on the wire.\n * - Integer in `[2, 365]` — Markr's documented finite bound.\n *\n * Anything else (`NaN`, `0`, `1`, negatives other than `-1`, non-integers,\n * values > 365) throws `InvalidParamsError` at the SDK boundary so a\n * misbehaving form parse (`parseInt('')` → `NaN`, or a stale \"minimum is 1\"\n * assumption) can't silently become an unlimited schedule or a guaranteed\n * server-side rejection.\n */\n numberOfOrders: number;\n frequency: RecurringFrequency;\n /** Basis points (matches `/quote` semantics). */\n slippage?: number;\n}\n\nexport interface RecurringSwapParams {\n uuid: string;\n appId: string;\n}\n\nexport interface ListRecurringOrdersParams {\n address: EvmAddress;\n chainId?: number;\n status?: RecurringOrderStatus;\n}\n\nexport interface ListRecurringOrdersResponse {\n address: EvmAddress;\n count: number;\n orders: ReadonlyArray<RecurringOrder>;\n}\n\n/**\n * Wire-level params for the internal `_api.ts` cancel/pause/unpause helpers\n * (`markrPrepareCancellation` etc.). Public consumers reach the same endpoints\n * via {@link RecurringNamespace.executeCancellation}/`executePause`/\n * `executeUnpause`, which take {@link RecurringExecuteOrderActionParams}\n * instead and derive `chainId` from the passed `sourceChain`.\n */\nexport interface RecurringOrderActionApiParams {\n /** See {@link RecurringOrder.orderId} for the shape. */\n orderId: `0x${string}`;\n address: EvmAddress;\n /**\n * Chain the schedule lives on — required by Markr's\n * `POST /recurring/orders/{orderId}/{action}` endpoints (the orchestrator\n * scopes orderIds per chain, so the same bytes32 could in principle exist\n * on multiple chains).\n */\n chainId: number;\n}\n\n/**\n * Shared params for the three order-action execute methods\n * ({@link RecurringNamespace.executeCancellation},\n * {@link RecurringNamespace.executePause},\n * {@link RecurringNamespace.executeUnpause}). The SDK derives the wire-level\n * `chainId` from `sourceChain`, estimates gas via the chain's RPC, then signs\n * and broadcasts via the configured `evmSigner`.\n */\nexport interface RecurringExecuteOrderActionParams {\n /** See {@link RecurringOrder.orderId} for the shape. */\n orderId: `0x${string}`;\n /** Owner address of the schedule — must match the order's `owner`. */\n address: EvmAddress;\n /**\n * Source chain the schedule lives on — pass the same `Chain` that backs\n * `sourceChain` on the recurring order (the SDK reads `rpcUrl` + multicall\n * for the on-chain gas estimate and uses `chainId` for the wire request).\n */\n sourceChain: Chain;\n /** Optional fee-margin + 1559 overrides forwarded to the signed TX. */\n gasSettings?: GasSettings;\n /**\n * Opaque payload forwarded unchanged onto the `step.signerContext` field\n * seen by the configured `EvmSigner`. Lets consumers correlate the wallet\n * prompt back to the specific cancel / pause / unpause request that\n * produced it (e.g. UI slot id, display label) without relying on an\n * action-type-keyed lookup map that two concurrent same-type actions\n * could clobber.\n */\n signerContext?: unknown;\n}\n\n/**\n * Params for {@link RecurringNamespace.executeFirstFill}. Replaces the\n * pre-signer `prepareFirstFill` shape; the SDK now reads the on-chain\n * allowance against `totalAmountIn`, signs an `approve` if needed (batched\n * one-click when `evmSigner.signBatch` is available and the swap is\n * same-chain), then signs and broadcasts the first-fill swap.\n */\nexport interface RecurringExecuteFirstFillParams {\n /** Full recurring quote — carries `uuid`, `totalAmountIn`, `expiredAt`. */\n quote: RecurringQuoteResponse;\n /** EVM address creating the schedule (and signing the first fill). */\n fromAddress: EvmAddress;\n /**\n * Source chain — same `Chain` used to obtain the recurring quote. The SDK\n * reads `rpcUrl` for allowance + gas calls; `chainId` is cross-checked\n * against `quote.chainId` to catch obvious wiring mistakes.\n */\n sourceChain: Chain;\n /** Optional fee-margin + 1559 overrides. */\n gasSettings?: GasSettings;\n /**\n * Mirrors the same flag on `TransferService.transferAsset`: when the\n * one-click batch (approval + first-fill) is attempted and the consumer's\n * wallet rejects the batch, fall back to two sequential signatures\n * (`approve`, then `swap`) instead of bubbling the batch error up.\n */\n fallbackToDefaultOnBatchFailure?: boolean;\n /**\n * Opaque payload forwarded unchanged onto the `step.signerContext` field\n * seen by the configured `EvmSigner` for both the optional approval step\n * and the first-fill swap step. See\n * {@link RecurringExecuteOrderActionParams.signerContext}.\n */\n signerContext?: unknown;\n}\n\n/** Result of any `recurring.execute*` method — broadcast TX hash. */\nexport interface RecurringExecuteResult {\n txHash: Hex;\n}\n\nexport interface RecurringChainInfoEntry {\n /** Server-published lower bound for `intervalSeconds` (today: 300s on enabled chains). */\n minFrequencySeconds: number;\n supportedTokens: ReadonlyArray<{\n address: EvmAddress;\n /**\n * Smallest-unit decimal string — must be `BigInt()`-parseable (i.e.\n * matches `/^\\d+$/`). The Zod schema enforces this on the wire, but the\n * TS type alone is plain `string`; consumers constructing this map by\n * hand (caching, tests) should pass a digits-only decimal string or\n * `BigInt(minimumAmount)` will throw downstream in `checkEligibility`.\n */\n minimumAmount: string;\n }>;\n}\n\n/**\n * Cached `/info/chains` recurring metadata keyed by EVM chainId. SVM chains\n * are omitted — Markr supports recurring on same-chain EVM only.\n */\nexport type RecurringChainInfoMap = ReadonlyMap<number, RecurringChainInfoEntry>;\n\n/**\n * Reasons surfaced when {@link checkRecurringEligibility} returns\n * `{ eligible: false, … }`. Mirrors the existing `TransferSignatureReason`\n * enum pattern (PascalCase member, kebab-case wire value) so external\n * consumers comparing the raw string still match.\n */\nexport enum RecurringEligibilityReason {\n CrossChain = 'cross-chain',\n UnsupportedSourceChain = 'unsupported-source-chain',\n UnsupportedToken = 'unsupported-token',\n NoEvmAddress = 'no-evm-address',\n AmountBelowMinimum = 'amount-below-minimum',\n}\n\nexport type RecurringEligibility =\n | { eligible: true; minimumAmount: string; minIntervalSeconds: number }\n // `AmountBelowMinimum` carries the floor so error UIs can say \"Min is X\"\n // without a second `getRecurringChainInfo()` lookup. The value is the same\n // smallest-unit decimal string as the success branch's `minimumAmount`.\n | { eligible: false; reason: RecurringEligibilityReason.AmountBelowMinimum; minimumAmount: string }\n | { eligible: false; reason: Exclude<RecurringEligibilityReason, RecurringEligibilityReason.AmountBelowMinimum> };\n\nexport interface CheckRecurringEligibilityParams {\n recurringChainInfo: RecurringChainInfoMap;\n fromTokenAddress: EvmAddress;\n toTokenAddress: EvmAddress;\n sourceChainId: number;\n targetChainId: number;\n ownerAddress?: EvmAddress;\n /** Per-order amount; when present, enables the `amount-below-minimum` check. */\n amount?: bigint;\n}\n\n/**\n * Params passed to `RecurringNamespace.checkEligibility`. Same as\n * `CheckRecurringEligibilityParams` minus the chain-info map, which the\n * namespace closure injects.\n */\nexport type RecurringNamespaceCheckEligibilityParams = Omit<CheckRecurringEligibilityParams, 'recurringChainInfo'>;\n\n/**\n * Params passed to `RecurringNamespace.quote`. Same as `RecurringQuoteParams`\n * minus `appId`, which the namespace closure injects.\n */\nexport type RecurringNamespaceQuoteParams = Omit<RecurringQuoteParams, 'appId'>;\n\n/**\n * High-level wrapper exposed as `MarkrService.recurring`. Methods curry\n * `apiOptions`, `appId`, and the cached `recurringChainInfo` so callers only\n * pass per-call inputs.\n */\nexport interface RecurringNamespace {\n /** POST `/recurring/quote` — full quote with `totalAmountIn`, fees, expiry, uuid. */\n quote(props: RecurringNamespaceQuoteParams): Promise<RecurringQuoteResponse>;\n\n /**\n * Creates the schedule on-chain by signing and broadcasting the first\n * `/recurring/swap` fill via the configured `evmSigner`. Mirrors\n * `TransferService.transferAsset`:\n *\n * 1. Reads on-chain `allowance(tokenIn → router)` against `quote.totalAmountIn`.\n * 2. If allowance is short, builds an `approve(router, totalAmountIn)` TX.\n * When the consumer's signer exposes `signBatch`, the SDK attempts a\n * one-click batch (approve + swap) — set\n * {@link RecurringExecuteFirstFillParams.fallbackToDefaultOnBatchFailure}\n * to fall back to two sequential signatures if the wallet rejects the\n * batch.\n * 3. Estimates gas (with `gasSettings.estimateGasMarginBps` margin) for\n * each TX before signing, and dispatches the signed serialized TX via\n * the chain's RPC.\n *\n * Quote-expiry guard mirrors the previous `prepareFirstFill` behavior —\n * `quote.expiredAt <= now` throws `InvalidParamsError(QUOTE_EXPIRED)` at\n * the SDK boundary before any HTTP / on-chain call.\n *\n * Returns the broadcast first-fill TX hash; the schedule transitions to\n * `'active'` once Markr observes the on-chain event (poll `listOrders`).\n */\n executeFirstFill(props: RecurringExecuteFirstFillParams): Promise<RecurringExecuteResult>;\n\n /**\n * GET `/recurring/orders?address=…&chainId?=…&status?=…` — returns the\n * full response (`{ address, count, orders }`) so callers can render the\n * server-echoed `address` (e.g. confirming the queried wallet matches the\n * current EVM signer) and `count` (pagination / \"you have N schedules\"\n * affordances) without an extra lookup. Consumers that only care about the\n * orders array can destructure: `const { orders } = await listOrders(…)`.\n */\n listOrders(props: ListRecurringOrdersParams): Promise<ListRecurringOrdersResponse>;\n\n /**\n * Cancels the recurring schedule identified by `orderId`: fetches the\n * `/recurring/orders/{orderId}/cancel` calldata, estimates gas, then signs\n * and broadcasts via the configured `evmSigner`. The schedule transitions\n * to `status: 'cancelled'` only once the TX confirms and Markr observes\n * the on-chain event.\n *\n * Eligibility: only `'active'` and `'paused'` orders can be cancelled per\n * Markr's docs. An attempt to cancel a `'completed'` order surfaces as\n * `HttpError(400)` from the orchestrator before signing.\n */\n executeCancellation(props: RecurringExecuteOrderActionParams): Promise<RecurringExecuteResult>;\n\n /**\n * Pauses the recurring schedule identified by `orderId`: fetches the\n * `/recurring/orders/{orderId}/pause` calldata, estimates gas, then signs\n * and broadcasts via the configured `evmSigner`. The schedule transitions\n * to `status: 'paused'` only once the TX confirms and Markr observes the\n * on-chain event.\n *\n * Eligibility: only `'active'` orders can be paused per Markr's docs.\n * Attempting to pause a non-`active` order surfaces as `HttpError(400)`.\n *\n * Pausing preserves the schedule's existing ERC-20 allowance — when the\n * user later unpauses, no re-approval and no new native schedule fee are\n * required (this is the key UX benefit of pause over cancel-and-recreate).\n *\n * @see https://orchestrator-docs.markr.io/#tag/Recurring-Swaps/paths/~1recurring~1orders~1{orderId}~1pause/post\n */\n executePause(props: RecurringExecuteOrderActionParams): Promise<RecurringExecuteResult>;\n\n /**\n * Unpauses (resumes) the recurring schedule identified by `orderId`:\n * fetches the `/recurring/orders/{orderId}/unpause` calldata, estimates\n * gas, then signs and broadcasts via the configured `evmSigner`. The\n * schedule transitions back to `status: 'active'` only once the TX\n * confirms and Markr observes the on-chain event.\n *\n * Eligibility: only `'paused'` orders can be unpaused per Markr's docs.\n * Attempting to unpause a non-`paused` order surfaces as `HttpError(400)`.\n *\n * Resumes execution from where the schedule left off — remaining fills\n * continue on the original `frequency` cadence. The orchestrator recomputes\n * `nextExecutionAt` after the TX confirms.\n *\n * @see https://orchestrator-docs.markr.io/#tag/Recurring-Swaps/paths/~1recurring~1orders~1{orderId}~1unpause/post\n */\n executeUnpause(props: RecurringExecuteOrderActionParams): Promise<RecurringExecuteResult>;\n\n /**\n * Pure (no fetch) — uses the cached `/info/chains` recurring metadata.\n *\n * **Covers:** chain support, token support, EVM-address presence, same-chain\n * (cross-chain rejected), and per-order minimum (when `amount` is passed —\n * failure carries `minimumAmount`).\n *\n * **Does NOT cover wallet balance.** This helper has no wallet/RPC context.\n * Checking that the user holds `amount × numberOfOrders` of `tokenIn` (plus\n * native gas for the first fill) is the consumer's responsibility, same as\n * the one-shot swap flow. There is no `InsufficientBalance` reason on\n * {@link RecurringEligibilityReason} by design.\n *\n * **Does NOT cover post-fill failures.** Once a schedule is live, on-chain\n * reverts (slippage, runtime insufficient balance, etc.) surface server-side\n * as open-ended strings on `RecurringOrder.failures[].reasons` — substring-\n * match those for client-driven auto-cancel (AC4 pattern) and call\n * {@link RecurringNamespace.prepareCancellation} when applicable.\n *\n * **Does NOT cover server-side quote rejection.** Slippage, target-token\n * unsupported, liquidity, etc. are decided at `/recurring/quote` time and\n * surface as `HttpError` from {@link RecurringNamespace.quote}.\n */\n checkEligibility(props: RecurringNamespaceCheckEligibilityParams): RecurringEligibility;\n\n /** Returns the cached `/info/chains` recurring metadata. */\n getRecurringChainInfo(): RecurringChainInfoMap;\n}\n"],"mappings":"AAUA,MAAa,EAA4B,CAAC,SAAU,OAAQ,MAAO,OAAQ,QAAQ,CA8BnF,IAAY,EAAL,SAAA,EAAA,OACL,GAAA,OAAA,SACA,EAAA,UAAA,YACA,EAAA,UAAA,YACA,EAAA,OAAA,eACD,CAySW,EAAL,SAAA,EAAA,OACL,GAAA,WAAA,cACA,EAAA,uBAAA,2BACA,EAAA,iBAAA,oBACA,EAAA,aAAA,iBACA,EAAA,mBAAA,6BACD"}
1
+ {"version":3,"file":"types.cjs","names":[],"sources":["../../../../src/transfer-service/markr/recurring/types.ts"],"sourcesContent":["import type { Address as EvmAddress } from 'viem';\nimport type { Chain } from '../../../types/chain';\nimport type { GasSettings } from '../../../types/service';\nimport type { Hex } from '../../../types/signer';\n\n/**\n * Frequency units accepted by Markr's `/recurring/quote` and `/recurring/orders` endpoints.\n *\n * @see https://orchestrator-docs.markr.io/#/paths/~1recurring~1quote/post\n */\nexport const RECURRING_FREQUENCY_UNITS = ['minute', 'hour', 'day', 'week', 'month'] as const;\n\nexport type RecurringFrequencyUnit = (typeof RECURRING_FREQUENCY_UNITS)[number];\n\nexport interface RecurringFrequency {\n unit: RecurringFrequencyUnit;\n /**\n * Integer in `[1, 365]` (server-enforced upper bound). `validateFrequency`\n * surfaces violations as `{ ok: false, reason: 'invalid-value' }`.\n */\n value: number;\n}\n\n/**\n * Markr's \"unlimited orders\" sentinel. Sent to the server as `-1`, which the\n * router expands to `uint256` max on-chain. Callers can also pass `Infinity`\n * to {@link RecurringQuoteParams.numberOfOrders} for the same effect; the API\n * helpers translate to `-1` at the wire boundary.\n */\nexport const RECURRING_UNLIMITED_ORDERS_SENTINEL = -1;\n\n/**\n * Status values emitted by Markr for a recurring schedule. Treated as a\n * closed set — if Markr ever adds a new value server-side, the schema\n * will reject it loudly so the SDK update gates rendering changes\n * (instead of silently passing an unhandled state through to the UI).\n *\n * Mirrors the existing `TransferSignatureReason` enum pattern in\n * `constants.ts`: PascalCase members with kebab/lowercase wire values.\n */\nexport enum RecurringOrderStatus {\n Active = 'active',\n Completed = 'completed',\n Cancelled = 'cancelled',\n Paused = 'paused',\n}\n\nexport interface RecurringOrderFailure {\n /** 1-based index of the failed scheduled swap. */\n executionIndex: number;\n /** Reason strings supplied by the orchestrator (e.g. `\"Slippage tolerance exceeded\"`). */\n reasons: ReadonlyArray<string>;\n /** On-chain attempts before the execution was marked failed. */\n tryCount: number;\n /** Unix seconds. */\n failedAt: number;\n}\n\n/**\n * Server-side recurring-swap order returned by `GET /recurring/orders` and\n * `POST /recurring/orders/{orderId}/cancel`.\n *\n * @see https://orchestrator-docs.markr.io/#/Recurring%20Swaps\n */\nexport interface RecurringOrder {\n /**\n * bytes32 hex (`0x` + 64 hex chars). Used as the path param for cancellation.\n * Typed as a template-literal `0x`-prefixed string to catch the obvious\n * \"I forgot the `0x`\" mistake at compile time; the wire-level regex check\n * (in `markrCancelRecurringOrder`) enforces the full bytes32 shape.\n */\n orderId: `0x${string}`;\n /** EVM wallet that created the schedule. */\n owner: EvmAddress;\n chainId: number;\n tokenIn: EvmAddress;\n tokenOut: EvmAddress;\n /** Per-order input amount, in `tokenIn`'s smallest unit. */\n amount: bigint;\n /** -1 when unlimited; otherwise a positive integer (server-clamped to ≤ 365). */\n numberOfOrders: number;\n executedOrders: number;\n /**\n * `numberOfOrders - executedOrders` on finite schedules. `null` on\n * unlimited schedules (`numberOfOrders === -1`) — they have no finite\n * remainder to report. Per the Markr OpenAPI spec the field is\n * nullable; the schema also normalizes `undefined` to `null` so a\n * `=== null` check is sufficient.\n */\n remainingOrders: number | null;\n frequency: RecurringFrequency;\n /** `amount × numberOfOrders` — the ERC-20 allowance granted at setup. */\n totalAmountIn: bigint;\n /** Retry count for the *next* pending execution. `0` when none is pending. */\n tryCount: number;\n /** History of failed `executionIndex` values, newest last. */\n failures: ReadonlyArray<RecurringOrderFailure>;\n status: RecurringOrderStatus;\n /** Unix seconds. */\n createdAt: number;\n /**\n * Unix seconds. `null` once the schedule is completed / cancelled /\n * inactive. Per the Markr OpenAPI spec this field is optional + nullable;\n * the schema normalizes an omitted-field response to `null` so consumers\n * can branch on a single `=== null` check.\n */\n nextExecutionAt: number | null;\n /**\n * Unix seconds when the order was cancelled; `null` otherwise. Populated\n * with a number when `status === 'cancelled'`. Per the Markr OpenAPI spec\n * this field is optional + nullable; the schema normalizes both wire\n * shapes (`null` and omitted) to `null` for consumer ergonomics.\n */\n cancelledAt: number | null;\n}\n\n/**\n * Known fee types emitted by Markr today. Open at runtime — the schema\n * tolerates unknown values so a new fee category from the orchestrator doesn't\n * fail quote parsing. See {@link RecurringOrderStatus} for the widening\n * pattern.\n */\nexport type RecurringQuoteFeeType =\n | 'gas'\n | 'recurring'\n | 'protocol'\n | 'bridge'\n | 'slippage'\n | 'swap'\n | 'other'\n // See `RecurringOrderStatus` for why `Record<never, never>` replaces `{}`.\n | (string & Record<never, never>);\n\nexport interface RecurringQuoteFee {\n type: RecurringQuoteFeeType;\n name: string;\n amount: bigint;\n token: { chainId: number; address: EvmAddress };\n /**\n * Docs document `extra` as `boolean or object`. The boolean form is the\n * legacy \"additive one-time charge\" flag (e.g. the one-time native\n * schedule fee with `type: 'recurring'`); the object form is reserved\n * for future structured metadata. Consumers should treat any truthy\n * value as \"additive — balance-check separately.\"\n */\n extra?: boolean | Record<string, unknown>;\n}\n\nexport interface RecurringQuoteResponse {\n uuid: string;\n chainId: number;\n tokenIn: EvmAddress;\n tokenOut: EvmAddress;\n /** Per-order input. */\n amount: bigint;\n /** Server-side clamped value (may be 365 if the request was unlimited). */\n numberOfOrders: number;\n frequency: RecurringFrequency;\n /** Server-derived from `frequency`. */\n intervalSeconds: number;\n /** `amount × numberOfOrders` — the ERC-20 allowance the caller must grant. */\n totalAmountIn: bigint;\n /** First-fill output estimate. */\n amountOut: bigint;\n /** First-fill `minAmountOut` (slippage applied). */\n minAmountOut: bigint;\n fees: ReadonlyArray<RecurringQuoteFee>;\n /** Basis points. */\n recommendedSlippage: number;\n /** Unix seconds. */\n expiredAt: number;\n}\n\nexport interface RecurringQuoteParams {\n appId: string;\n chainId: number;\n tokenIn: EvmAddress;\n tokenInDecimals: number;\n tokenOut: EvmAddress;\n tokenOutDecimals: number;\n /**\n * Per-order input in smallest unit. `bigint` only — matches the rest of the\n * SDK's internal amount types (response amounts, `Quote.amountIn`, etc.).\n * Callers holding a decimal string should coerce with `BigInt(s)` at the\n * call site.\n */\n amount: bigint;\n /**\n * Number of orders. Accepts:\n * - `Infinity` or `-1` — translated to the unlimited sentinel (`-1`) on the wire.\n * - Integer in `[2, 365]` — Markr's documented finite bound.\n *\n * Anything else (`NaN`, `0`, `1`, negatives other than `-1`, non-integers,\n * values > 365) throws `InvalidParamsError` at the SDK boundary so a\n * misbehaving form parse (`parseInt('')` → `NaN`, or a stale \"minimum is 1\"\n * assumption) can't silently become an unlimited schedule or a guaranteed\n * server-side rejection.\n */\n numberOfOrders: number;\n frequency: RecurringFrequency;\n /** Basis points (matches `/quote` semantics). */\n slippage?: number;\n}\n\nexport interface RecurringSwapParams {\n uuid: string;\n appId: string;\n}\n\n/**\n * Step type for entries in {@link RecurringSwapResponse}. Mirrors Markr's\n * `/recurring/swap` documented discriminator (`type: \"wrap\" | \"createOrder\"`).\n *\n * - `wrap`: `WAVAX.deposit{value: totalAmountIn}()` against the chain\n * wrapped-native contract. Only present when the recurring quote was\n * issued against a native `tokenIn` (`0x0…`); first leg in the array.\n * - `createOrder`: the RecurringSwaps router call that creates the on-chain\n * schedule. Always present. `value` is the one-time native schedule fee\n * (NOT the total funded amount — that comes from the wrap leg / prior\n * ERC-20 approval).\n */\nexport type RecurringSwapTransactionType = 'wrap' | 'createOrder';\n\n/**\n * Single ordered step in {@link RecurringSwapResponse}. Submitted to the\n * chain in array order; the consumer also signs an ERC-20 `approve` for the\n * wrapped-native between the `wrap` and `createOrder` legs (SDK-built —\n * Markr does not return an approval step).\n */\nexport interface RecurringSwapTransaction {\n type: RecurringSwapTransactionType;\n to: `0x${string}`;\n data: `0x${string}`;\n value: bigint;\n}\n\n/**\n * Response type for Markr's `/recurring/swap` endpoint. Always an array,\n * ordered:\n * - ERC-20 `tokenIn`: `[createOrder]` (1 element).\n * - Native `tokenIn` (`0x0…`): `[wrap, createOrder]` (2 elements).\n *\n * @see https://orchestrator-docs.markr.io/#tag/Recurring-Swaps/paths/~1recurring~1swap/post\n */\nexport type RecurringSwapResponse = ReadonlyArray<RecurringSwapTransaction>;\n\nexport interface ListRecurringOrdersParams {\n address: EvmAddress;\n chainId?: number;\n status?: RecurringOrderStatus;\n}\n\nexport interface ListRecurringOrdersResponse {\n address: EvmAddress;\n count: number;\n orders: ReadonlyArray<RecurringOrder>;\n}\n\n/**\n * Wire-level params for the internal `_api.ts` cancel/pause/unpause helpers\n * (`markrPrepareCancellation` etc.). Public consumers reach the same endpoints\n * via {@link RecurringNamespace.executeCancellation}/`executePause`/\n * `executeUnpause`, which take {@link RecurringExecuteOrderActionParams}\n * instead and derive `chainId` from the passed `sourceChain`.\n */\nexport interface RecurringOrderActionApiParams {\n /** See {@link RecurringOrder.orderId} for the shape. */\n orderId: `0x${string}`;\n address: EvmAddress;\n /**\n * Chain the schedule lives on — required by Markr's\n * `POST /recurring/orders/{orderId}/{action}` endpoints (the orchestrator\n * scopes orderIds per chain, so the same bytes32 could in principle exist\n * on multiple chains).\n */\n chainId: number;\n}\n\n/**\n * Shared params for the three order-action execute methods\n * ({@link RecurringNamespace.executeCancellation},\n * {@link RecurringNamespace.executePause},\n * {@link RecurringNamespace.executeUnpause}). The SDK derives the wire-level\n * `chainId` from `sourceChain`, estimates gas via the chain's RPC, then signs\n * and broadcasts via the configured `evmSigner`.\n */\nexport interface RecurringExecuteOrderActionParams {\n /** See {@link RecurringOrder.orderId} for the shape. */\n orderId: `0x${string}`;\n /** Owner address of the schedule — must match the order's `owner`. */\n address: EvmAddress;\n /**\n * Source chain the schedule lives on — pass the same `Chain` that backs\n * `sourceChain` on the recurring order (the SDK reads `rpcUrl` + multicall\n * for the on-chain gas estimate and uses `chainId` for the wire request).\n */\n sourceChain: Chain;\n /** Optional fee-margin + 1559 overrides forwarded to the signed TX. */\n gasSettings?: GasSettings;\n /**\n * Opaque payload forwarded unchanged onto the `step.signerContext` field\n * seen by the configured `EvmSigner`. Lets consumers correlate the wallet\n * prompt back to the specific cancel / pause / unpause request that\n * produced it (e.g. UI slot id, display label) without relying on an\n * action-type-keyed lookup map that two concurrent same-type actions\n * could clobber.\n */\n signerContext?: unknown;\n}\n\n/**\n * Params for {@link RecurringNamespace.executeFirstFill}. Replaces the\n * pre-signer `prepareFirstFill` shape; the SDK now reads the on-chain\n * allowance against `totalAmountIn`, signs an `approve` if needed (batched\n * one-click when `evmSigner.signBatch` is available and the swap is\n * same-chain), then signs and broadcasts the first-fill swap.\n */\nexport interface RecurringExecuteFirstFillParams {\n /** Full recurring quote — carries `uuid`, `totalAmountIn`, `expiredAt`. */\n quote: RecurringQuoteResponse;\n /** EVM address creating the schedule (and signing the first fill). */\n fromAddress: EvmAddress;\n /**\n * Source chain — same `Chain` used to obtain the recurring quote. The SDK\n * reads `rpcUrl` for allowance + gas calls; `chainId` is cross-checked\n * against `quote.chainId` to catch obvious wiring mistakes.\n */\n sourceChain: Chain;\n /** Optional fee-margin + 1559 overrides. */\n gasSettings?: GasSettings;\n /**\n * Mirrors the same flag on `TransferService.transferAsset`: when the\n * one-click batch (approval + first-fill) is attempted and the consumer's\n * wallet rejects the batch, fall back to two sequential signatures\n * (`approve`, then `swap`) instead of bubbling the batch error up.\n */\n fallbackToDefaultOnBatchFailure?: boolean;\n /**\n * Opaque payload forwarded unchanged onto the `step.signerContext` field\n * seen by the configured `EvmSigner` for both the optional approval step\n * and the first-fill swap step. See\n * {@link RecurringExecuteOrderActionParams.signerContext}.\n */\n signerContext?: unknown;\n}\n\n/** Result of any `recurring.execute*` method — broadcast TX hash. */\nexport interface RecurringExecuteResult {\n txHash: Hex;\n}\n\nexport interface RecurringChainInfoEntry {\n /** Server-published lower bound for `intervalSeconds` (today: 300s on enabled chains). */\n minFrequencySeconds: number;\n /**\n * Chain wrapped-native ERC-20 (e.g. WAVAX on 43114, WETH on 1). Sourced\n * from `/info/chains[].wrapped_token` so the SDK doesn't need its own\n * static wrapped-native map. Used by:\n * - `_eligibility.ts` — to reject the native → wrapped-native pairing\n * (e.g. AVAX → WAVAX) with the dedicated `NativeToWrappedNative` reason,\n * and to fail-closed when the chain has no known wrapped-native.\n * - `_namespace.ts` — to fail-fast at `quote()` for native input on a\n * chain Markr hasn't published a wrapped-native for, and to cross-check\n * `wrap.to` from `/recurring/swap` before granting the user's allowance.\n *\n * Undefined for chains where Markr did not return `wrapped_token` — the\n * SDK fails closed on native input in that case.\n */\n wrappedNativeAddress?: EvmAddress;\n}\n\n/**\n * Cached `/info/chains` recurring metadata keyed by EVM chainId. SVM chains\n * are omitted — Markr supports recurring on same-chain EVM only.\n */\nexport type RecurringChainInfoMap = ReadonlyMap<number, RecurringChainInfoEntry>;\n\n/**\n * Reasons surfaced when {@link checkRecurringEligibility} returns\n * `{ eligible: false, … }`. Mirrors the existing `TransferSignatureReason`\n * enum pattern (PascalCase member, kebab-case wire value) so external\n * consumers comparing the raw string still match.\n */\nexport enum RecurringEligibilityReason {\n CrossChain = 'cross-chain',\n UnsupportedSourceChain = 'unsupported-source-chain',\n UnsupportedToken = 'unsupported-token',\n NoEvmAddress = 'no-evm-address',\n /**\n * Caller asked for a recurring schedule from the chain's native asset to\n * its wrapped-native ERC-20 (e.g. AVAX → WAVAX on C-Chain). Economically\n * just a scheduled wrap, not a swap — Markr would have nothing to route\n * after the on-chain wrap leg. Surfaced as a dedicated reason (vs.\n * {@link RecurringEligibilityReason.UnsupportedToken}) so consumer UI can\n * steer the user to a one-shot wrap rather than failing with a generic\n * \"token not supported\" message.\n */\n NativeToWrappedNative = 'native-to-wrapped-native',\n}\n\nexport type RecurringEligibility =\n | { eligible: true; minIntervalSeconds: number }\n | { eligible: false; reason: RecurringEligibilityReason };\n\nexport interface CheckRecurringEligibilityParams {\n recurringChainInfo: RecurringChainInfoMap;\n fromTokenAddress: EvmAddress;\n toTokenAddress: EvmAddress;\n sourceChainId: number;\n targetChainId: number;\n ownerAddress?: EvmAddress;\n}\n\n/**\n * Params passed to `RecurringNamespace.checkEligibility`. Same as\n * `CheckRecurringEligibilityParams` minus the chain-info map, which the\n * namespace closure injects.\n */\nexport type RecurringNamespaceCheckEligibilityParams = Omit<CheckRecurringEligibilityParams, 'recurringChainInfo'>;\n\n/**\n * Params passed to `RecurringNamespace.quote`. Same as `RecurringQuoteParams`\n * minus `appId`, which the namespace closure injects.\n */\nexport type RecurringNamespaceQuoteParams = Omit<RecurringQuoteParams, 'appId'>;\n\n/**\n * High-level wrapper exposed as `MarkrService.recurring`. Methods curry\n * `apiOptions`, `appId`, and the cached `recurringChainInfo` so callers only\n * pass per-call inputs.\n */\nexport interface RecurringNamespace {\n /** POST `/recurring/quote` — full quote with `totalAmountIn`, fees, expiry, uuid. */\n quote(props: RecurringNamespaceQuoteParams): Promise<RecurringQuoteResponse>;\n\n /**\n * Creates the schedule on-chain by signing and broadcasting the first\n * `/recurring/swap` fill via the configured `evmSigner`. Mirrors\n * `TransferService.transferAsset`:\n *\n * 1. Reads on-chain `allowance(tokenIn → router)` against `quote.totalAmountIn`.\n * 2. If allowance is short, builds an `approve(router, totalAmountIn)` TX.\n * When the consumer's signer exposes `signBatch`, the SDK attempts a\n * one-click batch (approve + swap) — set\n * {@link RecurringExecuteFirstFillParams.fallbackToDefaultOnBatchFailure}\n * to fall back to two sequential signatures if the wallet rejects the\n * batch.\n * 3. Estimates gas (with `gasSettings.estimateGasMarginBps` margin) for\n * each TX before signing, and dispatches the signed serialized TX via\n * the chain's RPC.\n *\n * Quote-expiry guard mirrors the previous `prepareFirstFill` behavior —\n * `quote.expiredAt <= now` throws `InvalidParamsError(QUOTE_EXPIRED)` at\n * the SDK boundary before any HTTP / on-chain call.\n *\n * Returns the broadcast first-fill TX hash; the schedule transitions to\n * `'active'` once Markr observes the on-chain event (poll `listOrders`).\n */\n executeFirstFill(props: RecurringExecuteFirstFillParams): Promise<RecurringExecuteResult>;\n\n /**\n * GET `/recurring/orders?address=…&chainId?=…&status?=…` — returns the\n * full response (`{ address, count, orders }`) so callers can render the\n * server-echoed `address` (e.g. confirming the queried wallet matches the\n * current EVM signer) and `count` (pagination / \"you have N schedules\"\n * affordances) without an extra lookup. Consumers that only care about the\n * orders array can destructure: `const { orders } = await listOrders(…)`.\n */\n listOrders(props: ListRecurringOrdersParams): Promise<ListRecurringOrdersResponse>;\n\n /**\n * Cancels the recurring schedule identified by `orderId`: fetches the\n * `/recurring/orders/{orderId}/cancel` calldata, estimates gas, then signs\n * and broadcasts via the configured `evmSigner`. The schedule transitions\n * to `status: 'cancelled'` only once the TX confirms and Markr observes\n * the on-chain event.\n *\n * Eligibility: only `'active'` and `'paused'` orders can be cancelled per\n * Markr's docs. An attempt to cancel a `'completed'` order surfaces as\n * `HttpError(400)` from the orchestrator before signing.\n */\n executeCancellation(props: RecurringExecuteOrderActionParams): Promise<RecurringExecuteResult>;\n\n /**\n * Pauses the recurring schedule identified by `orderId`: fetches the\n * `/recurring/orders/{orderId}/pause` calldata, estimates gas, then signs\n * and broadcasts via the configured `evmSigner`. The schedule transitions\n * to `status: 'paused'` only once the TX confirms and Markr observes the\n * on-chain event.\n *\n * Eligibility: only `'active'` orders can be paused per Markr's docs.\n * Attempting to pause a non-`active` order surfaces as `HttpError(400)`.\n *\n * Pausing preserves the schedule's existing ERC-20 allowance — when the\n * user later unpauses, no re-approval and no new native schedule fee are\n * required (this is the key UX benefit of pause over cancel-and-recreate).\n *\n * @see https://orchestrator-docs.markr.io/#tag/Recurring-Swaps/paths/~1recurring~1orders~1{orderId}~1pause/post\n */\n executePause(props: RecurringExecuteOrderActionParams): Promise<RecurringExecuteResult>;\n\n /**\n * Unpauses (resumes) the recurring schedule identified by `orderId`:\n * fetches the `/recurring/orders/{orderId}/unpause` calldata, estimates\n * gas, then signs and broadcasts via the configured `evmSigner`. The\n * schedule transitions back to `status: 'active'` only once the TX\n * confirms and Markr observes the on-chain event.\n *\n * Eligibility: only `'paused'` orders can be unpaused per Markr's docs.\n * Attempting to unpause a non-`paused` order surfaces as `HttpError(400)`.\n *\n * Resumes execution from where the schedule left off — remaining fills\n * continue on the original `frequency` cadence. The orchestrator recomputes\n * `nextExecutionAt` after the TX confirms.\n *\n * @see https://orchestrator-docs.markr.io/#tag/Recurring-Swaps/paths/~1recurring~1orders~1{orderId}~1unpause/post\n */\n executeUnpause(props: RecurringExecuteOrderActionParams): Promise<RecurringExecuteResult>;\n\n /**\n * Pure (no fetch) — uses the cached `/info/chains` recurring metadata.\n *\n * **Covers:** chain support (recurring enabled on the source chain),\n * EVM-address presence, same-chain (cross-chain rejected), and the\n * native → wrapped-native rejection. Markr no longer publishes a\n * per-chain supported-token list, so every ERC-20 (and the chain's\n * native asset) is treated as recurring-eligible — token-level support is\n * decided server-side at `/recurring/quote` time.\n *\n * **Does NOT cover wallet balance.** This helper has no wallet/RPC context.\n * Checking that the user holds `amount × numberOfOrders` of `tokenIn` (plus\n * native gas for the first fill) is the consumer's responsibility, same as\n * the one-shot swap flow. There is no `InsufficientBalance` reason on\n * {@link RecurringEligibilityReason} by design.\n *\n * **Does NOT cover post-fill failures.** Once a schedule is live, on-chain\n * reverts (slippage, runtime insufficient balance, etc.) surface server-side\n * as open-ended strings on `RecurringOrder.failures[].reasons` — substring-\n * match those for client-driven auto-cancel (AC4 pattern) and call\n * {@link RecurringNamespace.prepareCancellation} when applicable.\n *\n * **Does NOT cover server-side quote rejection.** Slippage, target-token\n * unsupported, liquidity, etc. are decided at `/recurring/quote` time and\n * surface as `HttpError` from {@link RecurringNamespace.quote}.\n */\n checkEligibility(props: RecurringNamespaceCheckEligibilityParams): RecurringEligibility;\n\n /** Returns the cached `/info/chains` recurring metadata. */\n getRecurringChainInfo(): RecurringChainInfoMap;\n}\n"],"mappings":"AAUA,MAAa,EAA4B,CAAC,SAAU,OAAQ,MAAO,OAAQ,QAAQ,CA8BnF,IAAY,EAAL,SAAA,EAAA,OACL,GAAA,OAAA,SACA,EAAA,UAAA,YACA,EAAA,UAAA,YACA,EAAA,OAAA,eACD,CAkVW,EAAL,SAAA,EAAA,OACL,GAAA,WAAA,cACA,EAAA,uBAAA,2BACA,EAAA,iBAAA,oBACA,EAAA,aAAA,iBAUA,EAAA,sBAAA,iCACD"}
@@ -273,17 +273,21 @@ interface RecurringExecuteResult {
273
273
  interface RecurringChainInfoEntry {
274
274
  /** Server-published lower bound for `intervalSeconds` (today: 300s on enabled chains). */
275
275
  minFrequencySeconds: number;
276
- supportedTokens: ReadonlyArray<{
277
- address: Address;
278
- /**
279
- * Smallest-unit decimal string — must be `BigInt()`-parseable (i.e.
280
- * matches `/^\d+$/`). The Zod schema enforces this on the wire, but the
281
- * TS type alone is plain `string`; consumers constructing this map by
282
- * hand (caching, tests) should pass a digits-only decimal string or
283
- * `BigInt(minimumAmount)` will throw downstream in `checkEligibility`.
284
- */
285
- minimumAmount: string;
286
- }>;
276
+ /**
277
+ * Chain wrapped-native ERC-20 (e.g. WAVAX on 43114, WETH on 1). Sourced
278
+ * from `/info/chains[].wrapped_token` so the SDK doesn't need its own
279
+ * static wrapped-native map. Used by:
280
+ * - `_eligibility.ts` to reject the native wrapped-native pairing
281
+ * (e.g. AVAX WAVAX) with the dedicated `NativeToWrappedNative` reason,
282
+ * and to fail-closed when the chain has no known wrapped-native.
283
+ * - `_namespace.ts` — to fail-fast at `quote()` for native input on a
284
+ * chain Markr hasn't published a wrapped-native for, and to cross-check
285
+ * `wrap.to` from `/recurring/swap` before granting the user's allowance.
286
+ *
287
+ * Undefined for chains where Markr did not return `wrapped_token` — the
288
+ * SDK fails closed on native input in that case.
289
+ */
290
+ wrappedNativeAddress?: Address;
287
291
  }
288
292
  /**
289
293
  * Cached `/info/chains` recurring metadata keyed by EVM chainId. SVM chains
@@ -301,19 +305,23 @@ declare enum RecurringEligibilityReason {
301
305
  UnsupportedSourceChain = "unsupported-source-chain",
302
306
  UnsupportedToken = "unsupported-token",
303
307
  NoEvmAddress = "no-evm-address",
304
- AmountBelowMinimum = "amount-below-minimum"
308
+ /**
309
+ * Caller asked for a recurring schedule from the chain's native asset to
310
+ * its wrapped-native ERC-20 (e.g. AVAX → WAVAX on C-Chain). Economically
311
+ * just a scheduled wrap, not a swap — Markr would have nothing to route
312
+ * after the on-chain wrap leg. Surfaced as a dedicated reason (vs.
313
+ * {@link RecurringEligibilityReason.UnsupportedToken}) so consumer UI can
314
+ * steer the user to a one-shot wrap rather than failing with a generic
315
+ * "token not supported" message.
316
+ */
317
+ NativeToWrappedNative = "native-to-wrapped-native"
305
318
  }
306
319
  type RecurringEligibility = {
307
320
  eligible: true;
308
- minimumAmount: string;
309
321
  minIntervalSeconds: number;
310
322
  } | {
311
323
  eligible: false;
312
- reason: RecurringEligibilityReason.AmountBelowMinimum;
313
- minimumAmount: string;
314
- } | {
315
- eligible: false;
316
- reason: Exclude<RecurringEligibilityReason, RecurringEligibilityReason.AmountBelowMinimum>;
324
+ reason: RecurringEligibilityReason;
317
325
  };
318
326
  interface CheckRecurringEligibilityParams {
319
327
  recurringChainInfo: RecurringChainInfoMap;
@@ -322,8 +330,6 @@ interface CheckRecurringEligibilityParams {
322
330
  sourceChainId: number;
323
331
  targetChainId: number;
324
332
  ownerAddress?: Address;
325
- /** Per-order amount; when present, enables the `amount-below-minimum` check. */
326
- amount?: bigint;
327
333
  }
328
334
  /**
329
335
  * Params passed to `RecurringNamespace.checkEligibility`. Same as
@@ -426,9 +432,12 @@ interface RecurringNamespace {
426
432
  /**
427
433
  * Pure (no fetch) — uses the cached `/info/chains` recurring metadata.
428
434
  *
429
- * **Covers:** chain support, token support, EVM-address presence, same-chain
430
- * (cross-chain rejected), and per-order minimum (when `amount` is passed —
431
- * failure carries `minimumAmount`).
435
+ * **Covers:** chain support (recurring enabled on the source chain),
436
+ * EVM-address presence, same-chain (cross-chain rejected), and the
437
+ * native wrapped-native rejection. Markr no longer publishes a
438
+ * per-chain supported-token list, so every ERC-20 (and the chain's
439
+ * native asset) is treated as recurring-eligible — token-level support is
440
+ * decided server-side at `/recurring/quote` time.
432
441
  *
433
442
  * **Does NOT cover wallet balance.** This helper has no wallet/RPC context.
434
443
  * Checking that the user holds `amount × numberOfOrders` of `tokenIn` (plus
@@ -273,17 +273,21 @@ interface RecurringExecuteResult {
273
273
  interface RecurringChainInfoEntry {
274
274
  /** Server-published lower bound for `intervalSeconds` (today: 300s on enabled chains). */
275
275
  minFrequencySeconds: number;
276
- supportedTokens: ReadonlyArray<{
277
- address: Address;
278
- /**
279
- * Smallest-unit decimal string — must be `BigInt()`-parseable (i.e.
280
- * matches `/^\d+$/`). The Zod schema enforces this on the wire, but the
281
- * TS type alone is plain `string`; consumers constructing this map by
282
- * hand (caching, tests) should pass a digits-only decimal string or
283
- * `BigInt(minimumAmount)` will throw downstream in `checkEligibility`.
284
- */
285
- minimumAmount: string;
286
- }>;
276
+ /**
277
+ * Chain wrapped-native ERC-20 (e.g. WAVAX on 43114, WETH on 1). Sourced
278
+ * from `/info/chains[].wrapped_token` so the SDK doesn't need its own
279
+ * static wrapped-native map. Used by:
280
+ * - `_eligibility.ts` to reject the native wrapped-native pairing
281
+ * (e.g. AVAX WAVAX) with the dedicated `NativeToWrappedNative` reason,
282
+ * and to fail-closed when the chain has no known wrapped-native.
283
+ * - `_namespace.ts` — to fail-fast at `quote()` for native input on a
284
+ * chain Markr hasn't published a wrapped-native for, and to cross-check
285
+ * `wrap.to` from `/recurring/swap` before granting the user's allowance.
286
+ *
287
+ * Undefined for chains where Markr did not return `wrapped_token` — the
288
+ * SDK fails closed on native input in that case.
289
+ */
290
+ wrappedNativeAddress?: Address;
287
291
  }
288
292
  /**
289
293
  * Cached `/info/chains` recurring metadata keyed by EVM chainId. SVM chains
@@ -301,19 +305,23 @@ declare enum RecurringEligibilityReason {
301
305
  UnsupportedSourceChain = "unsupported-source-chain",
302
306
  UnsupportedToken = "unsupported-token",
303
307
  NoEvmAddress = "no-evm-address",
304
- AmountBelowMinimum = "amount-below-minimum"
308
+ /**
309
+ * Caller asked for a recurring schedule from the chain's native asset to
310
+ * its wrapped-native ERC-20 (e.g. AVAX → WAVAX on C-Chain). Economically
311
+ * just a scheduled wrap, not a swap — Markr would have nothing to route
312
+ * after the on-chain wrap leg. Surfaced as a dedicated reason (vs.
313
+ * {@link RecurringEligibilityReason.UnsupportedToken}) so consumer UI can
314
+ * steer the user to a one-shot wrap rather than failing with a generic
315
+ * "token not supported" message.
316
+ */
317
+ NativeToWrappedNative = "native-to-wrapped-native"
305
318
  }
306
319
  type RecurringEligibility = {
307
320
  eligible: true;
308
- minimumAmount: string;
309
321
  minIntervalSeconds: number;
310
322
  } | {
311
323
  eligible: false;
312
- reason: RecurringEligibilityReason.AmountBelowMinimum;
313
- minimumAmount: string;
314
- } | {
315
- eligible: false;
316
- reason: Exclude<RecurringEligibilityReason, RecurringEligibilityReason.AmountBelowMinimum>;
324
+ reason: RecurringEligibilityReason;
317
325
  };
318
326
  interface CheckRecurringEligibilityParams {
319
327
  recurringChainInfo: RecurringChainInfoMap;
@@ -322,8 +330,6 @@ interface CheckRecurringEligibilityParams {
322
330
  sourceChainId: number;
323
331
  targetChainId: number;
324
332
  ownerAddress?: Address;
325
- /** Per-order amount; when present, enables the `amount-below-minimum` check. */
326
- amount?: bigint;
327
333
  }
328
334
  /**
329
335
  * Params passed to `RecurringNamespace.checkEligibility`. Same as
@@ -426,9 +432,12 @@ interface RecurringNamespace {
426
432
  /**
427
433
  * Pure (no fetch) — uses the cached `/info/chains` recurring metadata.
428
434
  *
429
- * **Covers:** chain support, token support, EVM-address presence, same-chain
430
- * (cross-chain rejected), and per-order minimum (when `amount` is passed —
431
- * failure carries `minimumAmount`).
435
+ * **Covers:** chain support (recurring enabled on the source chain),
436
+ * EVM-address presence, same-chain (cross-chain rejected), and the
437
+ * native wrapped-native rejection. Markr no longer publishes a
438
+ * per-chain supported-token list, so every ERC-20 (and the chain's
439
+ * native asset) is treated as recurring-eligible — token-level support is
440
+ * decided server-side at `/recurring/quote` time.
432
441
  *
433
442
  * **Does NOT cover wallet balance.** This helper has no wallet/RPC context.
434
443
  * Checking that the user holds `amount × numberOfOrders` of `tokenIn` (plus
@@ -1,2 +1,2 @@
1
- const e=[`minute`,`hour`,`day`,`week`,`month`],t=-1;let n=function(e){return e.Active=`active`,e.Completed=`completed`,e.Cancelled=`cancelled`,e.Paused=`paused`,e}({}),r=function(e){return e.CrossChain=`cross-chain`,e.UnsupportedSourceChain=`unsupported-source-chain`,e.UnsupportedToken=`unsupported-token`,e.NoEvmAddress=`no-evm-address`,e.AmountBelowMinimum=`amount-below-minimum`,e}({});export{e as RECURRING_FREQUENCY_UNITS,t as RECURRING_UNLIMITED_ORDERS_SENTINEL,r as RecurringEligibilityReason,n as RecurringOrderStatus};
1
+ const e=[`minute`,`hour`,`day`,`week`,`month`],t=-1;let n=function(e){return e.Active=`active`,e.Completed=`completed`,e.Cancelled=`cancelled`,e.Paused=`paused`,e}({}),r=function(e){return e.CrossChain=`cross-chain`,e.UnsupportedSourceChain=`unsupported-source-chain`,e.UnsupportedToken=`unsupported-token`,e.NoEvmAddress=`no-evm-address`,e.NativeToWrappedNative=`native-to-wrapped-native`,e}({});export{e as RECURRING_FREQUENCY_UNITS,t as RECURRING_UNLIMITED_ORDERS_SENTINEL,r as RecurringEligibilityReason,n as RecurringOrderStatus};
2
2
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../../../../src/transfer-service/markr/recurring/types.ts"],"sourcesContent":["import type { Address as EvmAddress } from 'viem';\nimport type { Chain } from '../../../types/chain';\nimport type { GasSettings } from '../../../types/service';\nimport type { Hex } from '../../../types/signer';\n\n/**\n * Frequency units accepted by Markr's `/recurring/quote` and `/recurring/orders` endpoints.\n *\n * @see https://orchestrator-docs.markr.io/#/paths/~1recurring~1quote/post\n */\nexport const RECURRING_FREQUENCY_UNITS = ['minute', 'hour', 'day', 'week', 'month'] as const;\n\nexport type RecurringFrequencyUnit = (typeof RECURRING_FREQUENCY_UNITS)[number];\n\nexport interface RecurringFrequency {\n unit: RecurringFrequencyUnit;\n /**\n * Integer in `[1, 365]` (server-enforced upper bound). `validateFrequency`\n * surfaces violations as `{ ok: false, reason: 'invalid-value' }`.\n */\n value: number;\n}\n\n/**\n * Markr's \"unlimited orders\" sentinel. Sent to the server as `-1`, which the\n * router expands to `uint256` max on-chain. Callers can also pass `Infinity`\n * to {@link RecurringQuoteParams.numberOfOrders} for the same effect; the API\n * helpers translate to `-1` at the wire boundary.\n */\nexport const RECURRING_UNLIMITED_ORDERS_SENTINEL = -1;\n\n/**\n * Status values emitted by Markr for a recurring schedule. Treated as a\n * closed set — if Markr ever adds a new value server-side, the schema\n * will reject it loudly so the SDK update gates rendering changes\n * (instead of silently passing an unhandled state through to the UI).\n *\n * Mirrors the existing `TransferSignatureReason` enum pattern in\n * `constants.ts`: PascalCase members with kebab/lowercase wire values.\n */\nexport enum RecurringOrderStatus {\n Active = 'active',\n Completed = 'completed',\n Cancelled = 'cancelled',\n Paused = 'paused',\n}\n\nexport interface RecurringOrderFailure {\n /** 1-based index of the failed scheduled swap. */\n executionIndex: number;\n /** Reason strings supplied by the orchestrator (e.g. `\"Slippage tolerance exceeded\"`). */\n reasons: ReadonlyArray<string>;\n /** On-chain attempts before the execution was marked failed. */\n tryCount: number;\n /** Unix seconds. */\n failedAt: number;\n}\n\n/**\n * Server-side recurring-swap order returned by `GET /recurring/orders` and\n * `POST /recurring/orders/{orderId}/cancel`.\n *\n * @see https://orchestrator-docs.markr.io/#/Recurring%20Swaps\n */\nexport interface RecurringOrder {\n /**\n * bytes32 hex (`0x` + 64 hex chars). Used as the path param for cancellation.\n * Typed as a template-literal `0x`-prefixed string to catch the obvious\n * \"I forgot the `0x`\" mistake at compile time; the wire-level regex check\n * (in `markrCancelRecurringOrder`) enforces the full bytes32 shape.\n */\n orderId: `0x${string}`;\n /** EVM wallet that created the schedule. */\n owner: EvmAddress;\n chainId: number;\n tokenIn: EvmAddress;\n tokenOut: EvmAddress;\n /** Per-order input amount, in `tokenIn`'s smallest unit. */\n amount: bigint;\n /** -1 when unlimited; otherwise a positive integer (server-clamped to ≤ 365). */\n numberOfOrders: number;\n executedOrders: number;\n /**\n * `numberOfOrders - executedOrders` on finite schedules. `null` on\n * unlimited schedules (`numberOfOrders === -1`) — they have no finite\n * remainder to report. Per the Markr OpenAPI spec the field is\n * nullable; the schema also normalizes `undefined` to `null` so a\n * `=== null` check is sufficient.\n */\n remainingOrders: number | null;\n frequency: RecurringFrequency;\n /** `amount × numberOfOrders` — the ERC-20 allowance granted at setup. */\n totalAmountIn: bigint;\n /** Retry count for the *next* pending execution. `0` when none is pending. */\n tryCount: number;\n /** History of failed `executionIndex` values, newest last. */\n failures: ReadonlyArray<RecurringOrderFailure>;\n status: RecurringOrderStatus;\n /** Unix seconds. */\n createdAt: number;\n /**\n * Unix seconds. `null` once the schedule is completed / cancelled /\n * inactive. Per the Markr OpenAPI spec this field is optional + nullable;\n * the schema normalizes an omitted-field response to `null` so consumers\n * can branch on a single `=== null` check.\n */\n nextExecutionAt: number | null;\n /**\n * Unix seconds when the order was cancelled; `null` otherwise. Populated\n * with a number when `status === 'cancelled'`. Per the Markr OpenAPI spec\n * this field is optional + nullable; the schema normalizes both wire\n * shapes (`null` and omitted) to `null` for consumer ergonomics.\n */\n cancelledAt: number | null;\n}\n\n/**\n * Known fee types emitted by Markr today. Open at runtime — the schema\n * tolerates unknown values so a new fee category from the orchestrator doesn't\n * fail quote parsing. See {@link RecurringOrderStatus} for the widening\n * pattern.\n */\nexport type RecurringQuoteFeeType =\n | 'gas'\n | 'recurring'\n | 'protocol'\n | 'bridge'\n | 'slippage'\n | 'swap'\n | 'other'\n // See `RecurringOrderStatus` for why `Record<never, never>` replaces `{}`.\n | (string & Record<never, never>);\n\nexport interface RecurringQuoteFee {\n type: RecurringQuoteFeeType;\n name: string;\n amount: bigint;\n token: { chainId: number; address: EvmAddress };\n /**\n * Docs document `extra` as `boolean or object`. The boolean form is the\n * legacy \"additive one-time charge\" flag (e.g. the one-time native\n * schedule fee with `type: 'recurring'`); the object form is reserved\n * for future structured metadata. Consumers should treat any truthy\n * value as \"additive — balance-check separately.\"\n */\n extra?: boolean | Record<string, unknown>;\n}\n\nexport interface RecurringQuoteResponse {\n uuid: string;\n chainId: number;\n tokenIn: EvmAddress;\n tokenOut: EvmAddress;\n /** Per-order input. */\n amount: bigint;\n /** Server-side clamped value (may be 365 if the request was unlimited). */\n numberOfOrders: number;\n frequency: RecurringFrequency;\n /** Server-derived from `frequency`. */\n intervalSeconds: number;\n /** `amount × numberOfOrders` — the ERC-20 allowance the caller must grant. */\n totalAmountIn: bigint;\n /** First-fill output estimate. */\n amountOut: bigint;\n /** First-fill `minAmountOut` (slippage applied). */\n minAmountOut: bigint;\n fees: ReadonlyArray<RecurringQuoteFee>;\n /** Basis points. */\n recommendedSlippage: number;\n /** Unix seconds. */\n expiredAt: number;\n}\n\nexport interface RecurringQuoteParams {\n appId: string;\n chainId: number;\n tokenIn: EvmAddress;\n tokenInDecimals: number;\n tokenOut: EvmAddress;\n tokenOutDecimals: number;\n /**\n * Per-order input in smallest unit. `bigint` only — matches the rest of the\n * SDK's internal amount types (response amounts, `Quote.amountIn`, etc.).\n * Callers holding a decimal string should coerce with `BigInt(s)` at the\n * call site.\n */\n amount: bigint;\n /**\n * Number of orders. Accepts:\n * - `Infinity` or `-1` — translated to the unlimited sentinel (`-1`) on the wire.\n * - Integer in `[2, 365]` — Markr's documented finite bound.\n *\n * Anything else (`NaN`, `0`, `1`, negatives other than `-1`, non-integers,\n * values > 365) throws `InvalidParamsError` at the SDK boundary so a\n * misbehaving form parse (`parseInt('')` → `NaN`, or a stale \"minimum is 1\"\n * assumption) can't silently become an unlimited schedule or a guaranteed\n * server-side rejection.\n */\n numberOfOrders: number;\n frequency: RecurringFrequency;\n /** Basis points (matches `/quote` semantics). */\n slippage?: number;\n}\n\nexport interface RecurringSwapParams {\n uuid: string;\n appId: string;\n}\n\nexport interface ListRecurringOrdersParams {\n address: EvmAddress;\n chainId?: number;\n status?: RecurringOrderStatus;\n}\n\nexport interface ListRecurringOrdersResponse {\n address: EvmAddress;\n count: number;\n orders: ReadonlyArray<RecurringOrder>;\n}\n\n/**\n * Wire-level params for the internal `_api.ts` cancel/pause/unpause helpers\n * (`markrPrepareCancellation` etc.). Public consumers reach the same endpoints\n * via {@link RecurringNamespace.executeCancellation}/`executePause`/\n * `executeUnpause`, which take {@link RecurringExecuteOrderActionParams}\n * instead and derive `chainId` from the passed `sourceChain`.\n */\nexport interface RecurringOrderActionApiParams {\n /** See {@link RecurringOrder.orderId} for the shape. */\n orderId: `0x${string}`;\n address: EvmAddress;\n /**\n * Chain the schedule lives on — required by Markr's\n * `POST /recurring/orders/{orderId}/{action}` endpoints (the orchestrator\n * scopes orderIds per chain, so the same bytes32 could in principle exist\n * on multiple chains).\n */\n chainId: number;\n}\n\n/**\n * Shared params for the three order-action execute methods\n * ({@link RecurringNamespace.executeCancellation},\n * {@link RecurringNamespace.executePause},\n * {@link RecurringNamespace.executeUnpause}). The SDK derives the wire-level\n * `chainId` from `sourceChain`, estimates gas via the chain's RPC, then signs\n * and broadcasts via the configured `evmSigner`.\n */\nexport interface RecurringExecuteOrderActionParams {\n /** See {@link RecurringOrder.orderId} for the shape. */\n orderId: `0x${string}`;\n /** Owner address of the schedule — must match the order's `owner`. */\n address: EvmAddress;\n /**\n * Source chain the schedule lives on — pass the same `Chain` that backs\n * `sourceChain` on the recurring order (the SDK reads `rpcUrl` + multicall\n * for the on-chain gas estimate and uses `chainId` for the wire request).\n */\n sourceChain: Chain;\n /** Optional fee-margin + 1559 overrides forwarded to the signed TX. */\n gasSettings?: GasSettings;\n /**\n * Opaque payload forwarded unchanged onto the `step.signerContext` field\n * seen by the configured `EvmSigner`. Lets consumers correlate the wallet\n * prompt back to the specific cancel / pause / unpause request that\n * produced it (e.g. UI slot id, display label) without relying on an\n * action-type-keyed lookup map that two concurrent same-type actions\n * could clobber.\n */\n signerContext?: unknown;\n}\n\n/**\n * Params for {@link RecurringNamespace.executeFirstFill}. Replaces the\n * pre-signer `prepareFirstFill` shape; the SDK now reads the on-chain\n * allowance against `totalAmountIn`, signs an `approve` if needed (batched\n * one-click when `evmSigner.signBatch` is available and the swap is\n * same-chain), then signs and broadcasts the first-fill swap.\n */\nexport interface RecurringExecuteFirstFillParams {\n /** Full recurring quote — carries `uuid`, `totalAmountIn`, `expiredAt`. */\n quote: RecurringQuoteResponse;\n /** EVM address creating the schedule (and signing the first fill). */\n fromAddress: EvmAddress;\n /**\n * Source chain — same `Chain` used to obtain the recurring quote. The SDK\n * reads `rpcUrl` for allowance + gas calls; `chainId` is cross-checked\n * against `quote.chainId` to catch obvious wiring mistakes.\n */\n sourceChain: Chain;\n /** Optional fee-margin + 1559 overrides. */\n gasSettings?: GasSettings;\n /**\n * Mirrors the same flag on `TransferService.transferAsset`: when the\n * one-click batch (approval + first-fill) is attempted and the consumer's\n * wallet rejects the batch, fall back to two sequential signatures\n * (`approve`, then `swap`) instead of bubbling the batch error up.\n */\n fallbackToDefaultOnBatchFailure?: boolean;\n /**\n * Opaque payload forwarded unchanged onto the `step.signerContext` field\n * seen by the configured `EvmSigner` for both the optional approval step\n * and the first-fill swap step. See\n * {@link RecurringExecuteOrderActionParams.signerContext}.\n */\n signerContext?: unknown;\n}\n\n/** Result of any `recurring.execute*` method — broadcast TX hash. */\nexport interface RecurringExecuteResult {\n txHash: Hex;\n}\n\nexport interface RecurringChainInfoEntry {\n /** Server-published lower bound for `intervalSeconds` (today: 300s on enabled chains). */\n minFrequencySeconds: number;\n supportedTokens: ReadonlyArray<{\n address: EvmAddress;\n /**\n * Smallest-unit decimal string — must be `BigInt()`-parseable (i.e.\n * matches `/^\\d+$/`). The Zod schema enforces this on the wire, but the\n * TS type alone is plain `string`; consumers constructing this map by\n * hand (caching, tests) should pass a digits-only decimal string or\n * `BigInt(minimumAmount)` will throw downstream in `checkEligibility`.\n */\n minimumAmount: string;\n }>;\n}\n\n/**\n * Cached `/info/chains` recurring metadata keyed by EVM chainId. SVM chains\n * are omitted — Markr supports recurring on same-chain EVM only.\n */\nexport type RecurringChainInfoMap = ReadonlyMap<number, RecurringChainInfoEntry>;\n\n/**\n * Reasons surfaced when {@link checkRecurringEligibility} returns\n * `{ eligible: false, … }`. Mirrors the existing `TransferSignatureReason`\n * enum pattern (PascalCase member, kebab-case wire value) so external\n * consumers comparing the raw string still match.\n */\nexport enum RecurringEligibilityReason {\n CrossChain = 'cross-chain',\n UnsupportedSourceChain = 'unsupported-source-chain',\n UnsupportedToken = 'unsupported-token',\n NoEvmAddress = 'no-evm-address',\n AmountBelowMinimum = 'amount-below-minimum',\n}\n\nexport type RecurringEligibility =\n | { eligible: true; minimumAmount: string; minIntervalSeconds: number }\n // `AmountBelowMinimum` carries the floor so error UIs can say \"Min is X\"\n // without a second `getRecurringChainInfo()` lookup. The value is the same\n // smallest-unit decimal string as the success branch's `minimumAmount`.\n | { eligible: false; reason: RecurringEligibilityReason.AmountBelowMinimum; minimumAmount: string }\n | { eligible: false; reason: Exclude<RecurringEligibilityReason, RecurringEligibilityReason.AmountBelowMinimum> };\n\nexport interface CheckRecurringEligibilityParams {\n recurringChainInfo: RecurringChainInfoMap;\n fromTokenAddress: EvmAddress;\n toTokenAddress: EvmAddress;\n sourceChainId: number;\n targetChainId: number;\n ownerAddress?: EvmAddress;\n /** Per-order amount; when present, enables the `amount-below-minimum` check. */\n amount?: bigint;\n}\n\n/**\n * Params passed to `RecurringNamespace.checkEligibility`. Same as\n * `CheckRecurringEligibilityParams` minus the chain-info map, which the\n * namespace closure injects.\n */\nexport type RecurringNamespaceCheckEligibilityParams = Omit<CheckRecurringEligibilityParams, 'recurringChainInfo'>;\n\n/**\n * Params passed to `RecurringNamespace.quote`. Same as `RecurringQuoteParams`\n * minus `appId`, which the namespace closure injects.\n */\nexport type RecurringNamespaceQuoteParams = Omit<RecurringQuoteParams, 'appId'>;\n\n/**\n * High-level wrapper exposed as `MarkrService.recurring`. Methods curry\n * `apiOptions`, `appId`, and the cached `recurringChainInfo` so callers only\n * pass per-call inputs.\n */\nexport interface RecurringNamespace {\n /** POST `/recurring/quote` — full quote with `totalAmountIn`, fees, expiry, uuid. */\n quote(props: RecurringNamespaceQuoteParams): Promise<RecurringQuoteResponse>;\n\n /**\n * Creates the schedule on-chain by signing and broadcasting the first\n * `/recurring/swap` fill via the configured `evmSigner`. Mirrors\n * `TransferService.transferAsset`:\n *\n * 1. Reads on-chain `allowance(tokenIn → router)` against `quote.totalAmountIn`.\n * 2. If allowance is short, builds an `approve(router, totalAmountIn)` TX.\n * When the consumer's signer exposes `signBatch`, the SDK attempts a\n * one-click batch (approve + swap) — set\n * {@link RecurringExecuteFirstFillParams.fallbackToDefaultOnBatchFailure}\n * to fall back to two sequential signatures if the wallet rejects the\n * batch.\n * 3. Estimates gas (with `gasSettings.estimateGasMarginBps` margin) for\n * each TX before signing, and dispatches the signed serialized TX via\n * the chain's RPC.\n *\n * Quote-expiry guard mirrors the previous `prepareFirstFill` behavior —\n * `quote.expiredAt <= now` throws `InvalidParamsError(QUOTE_EXPIRED)` at\n * the SDK boundary before any HTTP / on-chain call.\n *\n * Returns the broadcast first-fill TX hash; the schedule transitions to\n * `'active'` once Markr observes the on-chain event (poll `listOrders`).\n */\n executeFirstFill(props: RecurringExecuteFirstFillParams): Promise<RecurringExecuteResult>;\n\n /**\n * GET `/recurring/orders?address=…&chainId?=…&status?=…` — returns the\n * full response (`{ address, count, orders }`) so callers can render the\n * server-echoed `address` (e.g. confirming the queried wallet matches the\n * current EVM signer) and `count` (pagination / \"you have N schedules\"\n * affordances) without an extra lookup. Consumers that only care about the\n * orders array can destructure: `const { orders } = await listOrders(…)`.\n */\n listOrders(props: ListRecurringOrdersParams): Promise<ListRecurringOrdersResponse>;\n\n /**\n * Cancels the recurring schedule identified by `orderId`: fetches the\n * `/recurring/orders/{orderId}/cancel` calldata, estimates gas, then signs\n * and broadcasts via the configured `evmSigner`. The schedule transitions\n * to `status: 'cancelled'` only once the TX confirms and Markr observes\n * the on-chain event.\n *\n * Eligibility: only `'active'` and `'paused'` orders can be cancelled per\n * Markr's docs. An attempt to cancel a `'completed'` order surfaces as\n * `HttpError(400)` from the orchestrator before signing.\n */\n executeCancellation(props: RecurringExecuteOrderActionParams): Promise<RecurringExecuteResult>;\n\n /**\n * Pauses the recurring schedule identified by `orderId`: fetches the\n * `/recurring/orders/{orderId}/pause` calldata, estimates gas, then signs\n * and broadcasts via the configured `evmSigner`. The schedule transitions\n * to `status: 'paused'` only once the TX confirms and Markr observes the\n * on-chain event.\n *\n * Eligibility: only `'active'` orders can be paused per Markr's docs.\n * Attempting to pause a non-`active` order surfaces as `HttpError(400)`.\n *\n * Pausing preserves the schedule's existing ERC-20 allowance — when the\n * user later unpauses, no re-approval and no new native schedule fee are\n * required (this is the key UX benefit of pause over cancel-and-recreate).\n *\n * @see https://orchestrator-docs.markr.io/#tag/Recurring-Swaps/paths/~1recurring~1orders~1{orderId}~1pause/post\n */\n executePause(props: RecurringExecuteOrderActionParams): Promise<RecurringExecuteResult>;\n\n /**\n * Unpauses (resumes) the recurring schedule identified by `orderId`:\n * fetches the `/recurring/orders/{orderId}/unpause` calldata, estimates\n * gas, then signs and broadcasts via the configured `evmSigner`. The\n * schedule transitions back to `status: 'active'` only once the TX\n * confirms and Markr observes the on-chain event.\n *\n * Eligibility: only `'paused'` orders can be unpaused per Markr's docs.\n * Attempting to unpause a non-`paused` order surfaces as `HttpError(400)`.\n *\n * Resumes execution from where the schedule left off — remaining fills\n * continue on the original `frequency` cadence. The orchestrator recomputes\n * `nextExecutionAt` after the TX confirms.\n *\n * @see https://orchestrator-docs.markr.io/#tag/Recurring-Swaps/paths/~1recurring~1orders~1{orderId}~1unpause/post\n */\n executeUnpause(props: RecurringExecuteOrderActionParams): Promise<RecurringExecuteResult>;\n\n /**\n * Pure (no fetch) — uses the cached `/info/chains` recurring metadata.\n *\n * **Covers:** chain support, token support, EVM-address presence, same-chain\n * (cross-chain rejected), and per-order minimum (when `amount` is passed —\n * failure carries `minimumAmount`).\n *\n * **Does NOT cover wallet balance.** This helper has no wallet/RPC context.\n * Checking that the user holds `amount × numberOfOrders` of `tokenIn` (plus\n * native gas for the first fill) is the consumer's responsibility, same as\n * the one-shot swap flow. There is no `InsufficientBalance` reason on\n * {@link RecurringEligibilityReason} by design.\n *\n * **Does NOT cover post-fill failures.** Once a schedule is live, on-chain\n * reverts (slippage, runtime insufficient balance, etc.) surface server-side\n * as open-ended strings on `RecurringOrder.failures[].reasons` — substring-\n * match those for client-driven auto-cancel (AC4 pattern) and call\n * {@link RecurringNamespace.prepareCancellation} when applicable.\n *\n * **Does NOT cover server-side quote rejection.** Slippage, target-token\n * unsupported, liquidity, etc. are decided at `/recurring/quote` time and\n * surface as `HttpError` from {@link RecurringNamespace.quote}.\n */\n checkEligibility(props: RecurringNamespaceCheckEligibilityParams): RecurringEligibility;\n\n /** Returns the cached `/info/chains` recurring metadata. */\n getRecurringChainInfo(): RecurringChainInfoMap;\n}\n"],"mappings":"AAUA,MAAa,EAA4B,CAAC,SAAU,OAAQ,MAAO,OAAQ,QAAQ,CAmBtE,EAAsC,GAWnD,IAAY,EAAL,SAAA,EAAA,OACL,GAAA,OAAA,SACA,EAAA,UAAA,YACA,EAAA,UAAA,YACA,EAAA,OAAA,eACD,CAySW,EAAL,SAAA,EAAA,OACL,GAAA,WAAA,cACA,EAAA,uBAAA,2BACA,EAAA,iBAAA,oBACA,EAAA,aAAA,iBACA,EAAA,mBAAA,6BACD"}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../../../src/transfer-service/markr/recurring/types.ts"],"sourcesContent":["import type { Address as EvmAddress } from 'viem';\nimport type { Chain } from '../../../types/chain';\nimport type { GasSettings } from '../../../types/service';\nimport type { Hex } from '../../../types/signer';\n\n/**\n * Frequency units accepted by Markr's `/recurring/quote` and `/recurring/orders` endpoints.\n *\n * @see https://orchestrator-docs.markr.io/#/paths/~1recurring~1quote/post\n */\nexport const RECURRING_FREQUENCY_UNITS = ['minute', 'hour', 'day', 'week', 'month'] as const;\n\nexport type RecurringFrequencyUnit = (typeof RECURRING_FREQUENCY_UNITS)[number];\n\nexport interface RecurringFrequency {\n unit: RecurringFrequencyUnit;\n /**\n * Integer in `[1, 365]` (server-enforced upper bound). `validateFrequency`\n * surfaces violations as `{ ok: false, reason: 'invalid-value' }`.\n */\n value: number;\n}\n\n/**\n * Markr's \"unlimited orders\" sentinel. Sent to the server as `-1`, which the\n * router expands to `uint256` max on-chain. Callers can also pass `Infinity`\n * to {@link RecurringQuoteParams.numberOfOrders} for the same effect; the API\n * helpers translate to `-1` at the wire boundary.\n */\nexport const RECURRING_UNLIMITED_ORDERS_SENTINEL = -1;\n\n/**\n * Status values emitted by Markr for a recurring schedule. Treated as a\n * closed set — if Markr ever adds a new value server-side, the schema\n * will reject it loudly so the SDK update gates rendering changes\n * (instead of silently passing an unhandled state through to the UI).\n *\n * Mirrors the existing `TransferSignatureReason` enum pattern in\n * `constants.ts`: PascalCase members with kebab/lowercase wire values.\n */\nexport enum RecurringOrderStatus {\n Active = 'active',\n Completed = 'completed',\n Cancelled = 'cancelled',\n Paused = 'paused',\n}\n\nexport interface RecurringOrderFailure {\n /** 1-based index of the failed scheduled swap. */\n executionIndex: number;\n /** Reason strings supplied by the orchestrator (e.g. `\"Slippage tolerance exceeded\"`). */\n reasons: ReadonlyArray<string>;\n /** On-chain attempts before the execution was marked failed. */\n tryCount: number;\n /** Unix seconds. */\n failedAt: number;\n}\n\n/**\n * Server-side recurring-swap order returned by `GET /recurring/orders` and\n * `POST /recurring/orders/{orderId}/cancel`.\n *\n * @see https://orchestrator-docs.markr.io/#/Recurring%20Swaps\n */\nexport interface RecurringOrder {\n /**\n * bytes32 hex (`0x` + 64 hex chars). Used as the path param for cancellation.\n * Typed as a template-literal `0x`-prefixed string to catch the obvious\n * \"I forgot the `0x`\" mistake at compile time; the wire-level regex check\n * (in `markrCancelRecurringOrder`) enforces the full bytes32 shape.\n */\n orderId: `0x${string}`;\n /** EVM wallet that created the schedule. */\n owner: EvmAddress;\n chainId: number;\n tokenIn: EvmAddress;\n tokenOut: EvmAddress;\n /** Per-order input amount, in `tokenIn`'s smallest unit. */\n amount: bigint;\n /** -1 when unlimited; otherwise a positive integer (server-clamped to ≤ 365). */\n numberOfOrders: number;\n executedOrders: number;\n /**\n * `numberOfOrders - executedOrders` on finite schedules. `null` on\n * unlimited schedules (`numberOfOrders === -1`) — they have no finite\n * remainder to report. Per the Markr OpenAPI spec the field is\n * nullable; the schema also normalizes `undefined` to `null` so a\n * `=== null` check is sufficient.\n */\n remainingOrders: number | null;\n frequency: RecurringFrequency;\n /** `amount × numberOfOrders` — the ERC-20 allowance granted at setup. */\n totalAmountIn: bigint;\n /** Retry count for the *next* pending execution. `0` when none is pending. */\n tryCount: number;\n /** History of failed `executionIndex` values, newest last. */\n failures: ReadonlyArray<RecurringOrderFailure>;\n status: RecurringOrderStatus;\n /** Unix seconds. */\n createdAt: number;\n /**\n * Unix seconds. `null` once the schedule is completed / cancelled /\n * inactive. Per the Markr OpenAPI spec this field is optional + nullable;\n * the schema normalizes an omitted-field response to `null` so consumers\n * can branch on a single `=== null` check.\n */\n nextExecutionAt: number | null;\n /**\n * Unix seconds when the order was cancelled; `null` otherwise. Populated\n * with a number when `status === 'cancelled'`. Per the Markr OpenAPI spec\n * this field is optional + nullable; the schema normalizes both wire\n * shapes (`null` and omitted) to `null` for consumer ergonomics.\n */\n cancelledAt: number | null;\n}\n\n/**\n * Known fee types emitted by Markr today. Open at runtime — the schema\n * tolerates unknown values so a new fee category from the orchestrator doesn't\n * fail quote parsing. See {@link RecurringOrderStatus} for the widening\n * pattern.\n */\nexport type RecurringQuoteFeeType =\n | 'gas'\n | 'recurring'\n | 'protocol'\n | 'bridge'\n | 'slippage'\n | 'swap'\n | 'other'\n // See `RecurringOrderStatus` for why `Record<never, never>` replaces `{}`.\n | (string & Record<never, never>);\n\nexport interface RecurringQuoteFee {\n type: RecurringQuoteFeeType;\n name: string;\n amount: bigint;\n token: { chainId: number; address: EvmAddress };\n /**\n * Docs document `extra` as `boolean or object`. The boolean form is the\n * legacy \"additive one-time charge\" flag (e.g. the one-time native\n * schedule fee with `type: 'recurring'`); the object form is reserved\n * for future structured metadata. Consumers should treat any truthy\n * value as \"additive — balance-check separately.\"\n */\n extra?: boolean | Record<string, unknown>;\n}\n\nexport interface RecurringQuoteResponse {\n uuid: string;\n chainId: number;\n tokenIn: EvmAddress;\n tokenOut: EvmAddress;\n /** Per-order input. */\n amount: bigint;\n /** Server-side clamped value (may be 365 if the request was unlimited). */\n numberOfOrders: number;\n frequency: RecurringFrequency;\n /** Server-derived from `frequency`. */\n intervalSeconds: number;\n /** `amount × numberOfOrders` — the ERC-20 allowance the caller must grant. */\n totalAmountIn: bigint;\n /** First-fill output estimate. */\n amountOut: bigint;\n /** First-fill `minAmountOut` (slippage applied). */\n minAmountOut: bigint;\n fees: ReadonlyArray<RecurringQuoteFee>;\n /** Basis points. */\n recommendedSlippage: number;\n /** Unix seconds. */\n expiredAt: number;\n}\n\nexport interface RecurringQuoteParams {\n appId: string;\n chainId: number;\n tokenIn: EvmAddress;\n tokenInDecimals: number;\n tokenOut: EvmAddress;\n tokenOutDecimals: number;\n /**\n * Per-order input in smallest unit. `bigint` only — matches the rest of the\n * SDK's internal amount types (response amounts, `Quote.amountIn`, etc.).\n * Callers holding a decimal string should coerce with `BigInt(s)` at the\n * call site.\n */\n amount: bigint;\n /**\n * Number of orders. Accepts:\n * - `Infinity` or `-1` — translated to the unlimited sentinel (`-1`) on the wire.\n * - Integer in `[2, 365]` — Markr's documented finite bound.\n *\n * Anything else (`NaN`, `0`, `1`, negatives other than `-1`, non-integers,\n * values > 365) throws `InvalidParamsError` at the SDK boundary so a\n * misbehaving form parse (`parseInt('')` → `NaN`, or a stale \"minimum is 1\"\n * assumption) can't silently become an unlimited schedule or a guaranteed\n * server-side rejection.\n */\n numberOfOrders: number;\n frequency: RecurringFrequency;\n /** Basis points (matches `/quote` semantics). */\n slippage?: number;\n}\n\nexport interface RecurringSwapParams {\n uuid: string;\n appId: string;\n}\n\n/**\n * Step type for entries in {@link RecurringSwapResponse}. Mirrors Markr's\n * `/recurring/swap` documented discriminator (`type: \"wrap\" | \"createOrder\"`).\n *\n * - `wrap`: `WAVAX.deposit{value: totalAmountIn}()` against the chain\n * wrapped-native contract. Only present when the recurring quote was\n * issued against a native `tokenIn` (`0x0…`); first leg in the array.\n * - `createOrder`: the RecurringSwaps router call that creates the on-chain\n * schedule. Always present. `value` is the one-time native schedule fee\n * (NOT the total funded amount — that comes from the wrap leg / prior\n * ERC-20 approval).\n */\nexport type RecurringSwapTransactionType = 'wrap' | 'createOrder';\n\n/**\n * Single ordered step in {@link RecurringSwapResponse}. Submitted to the\n * chain in array order; the consumer also signs an ERC-20 `approve` for the\n * wrapped-native between the `wrap` and `createOrder` legs (SDK-built —\n * Markr does not return an approval step).\n */\nexport interface RecurringSwapTransaction {\n type: RecurringSwapTransactionType;\n to: `0x${string}`;\n data: `0x${string}`;\n value: bigint;\n}\n\n/**\n * Response type for Markr's `/recurring/swap` endpoint. Always an array,\n * ordered:\n * - ERC-20 `tokenIn`: `[createOrder]` (1 element).\n * - Native `tokenIn` (`0x0…`): `[wrap, createOrder]` (2 elements).\n *\n * @see https://orchestrator-docs.markr.io/#tag/Recurring-Swaps/paths/~1recurring~1swap/post\n */\nexport type RecurringSwapResponse = ReadonlyArray<RecurringSwapTransaction>;\n\nexport interface ListRecurringOrdersParams {\n address: EvmAddress;\n chainId?: number;\n status?: RecurringOrderStatus;\n}\n\nexport interface ListRecurringOrdersResponse {\n address: EvmAddress;\n count: number;\n orders: ReadonlyArray<RecurringOrder>;\n}\n\n/**\n * Wire-level params for the internal `_api.ts` cancel/pause/unpause helpers\n * (`markrPrepareCancellation` etc.). Public consumers reach the same endpoints\n * via {@link RecurringNamespace.executeCancellation}/`executePause`/\n * `executeUnpause`, which take {@link RecurringExecuteOrderActionParams}\n * instead and derive `chainId` from the passed `sourceChain`.\n */\nexport interface RecurringOrderActionApiParams {\n /** See {@link RecurringOrder.orderId} for the shape. */\n orderId: `0x${string}`;\n address: EvmAddress;\n /**\n * Chain the schedule lives on — required by Markr's\n * `POST /recurring/orders/{orderId}/{action}` endpoints (the orchestrator\n * scopes orderIds per chain, so the same bytes32 could in principle exist\n * on multiple chains).\n */\n chainId: number;\n}\n\n/**\n * Shared params for the three order-action execute methods\n * ({@link RecurringNamespace.executeCancellation},\n * {@link RecurringNamespace.executePause},\n * {@link RecurringNamespace.executeUnpause}). The SDK derives the wire-level\n * `chainId` from `sourceChain`, estimates gas via the chain's RPC, then signs\n * and broadcasts via the configured `evmSigner`.\n */\nexport interface RecurringExecuteOrderActionParams {\n /** See {@link RecurringOrder.orderId} for the shape. */\n orderId: `0x${string}`;\n /** Owner address of the schedule — must match the order's `owner`. */\n address: EvmAddress;\n /**\n * Source chain the schedule lives on — pass the same `Chain` that backs\n * `sourceChain` on the recurring order (the SDK reads `rpcUrl` + multicall\n * for the on-chain gas estimate and uses `chainId` for the wire request).\n */\n sourceChain: Chain;\n /** Optional fee-margin + 1559 overrides forwarded to the signed TX. */\n gasSettings?: GasSettings;\n /**\n * Opaque payload forwarded unchanged onto the `step.signerContext` field\n * seen by the configured `EvmSigner`. Lets consumers correlate the wallet\n * prompt back to the specific cancel / pause / unpause request that\n * produced it (e.g. UI slot id, display label) without relying on an\n * action-type-keyed lookup map that two concurrent same-type actions\n * could clobber.\n */\n signerContext?: unknown;\n}\n\n/**\n * Params for {@link RecurringNamespace.executeFirstFill}. Replaces the\n * pre-signer `prepareFirstFill` shape; the SDK now reads the on-chain\n * allowance against `totalAmountIn`, signs an `approve` if needed (batched\n * one-click when `evmSigner.signBatch` is available and the swap is\n * same-chain), then signs and broadcasts the first-fill swap.\n */\nexport interface RecurringExecuteFirstFillParams {\n /** Full recurring quote — carries `uuid`, `totalAmountIn`, `expiredAt`. */\n quote: RecurringQuoteResponse;\n /** EVM address creating the schedule (and signing the first fill). */\n fromAddress: EvmAddress;\n /**\n * Source chain — same `Chain` used to obtain the recurring quote. The SDK\n * reads `rpcUrl` for allowance + gas calls; `chainId` is cross-checked\n * against `quote.chainId` to catch obvious wiring mistakes.\n */\n sourceChain: Chain;\n /** Optional fee-margin + 1559 overrides. */\n gasSettings?: GasSettings;\n /**\n * Mirrors the same flag on `TransferService.transferAsset`: when the\n * one-click batch (approval + first-fill) is attempted and the consumer's\n * wallet rejects the batch, fall back to two sequential signatures\n * (`approve`, then `swap`) instead of bubbling the batch error up.\n */\n fallbackToDefaultOnBatchFailure?: boolean;\n /**\n * Opaque payload forwarded unchanged onto the `step.signerContext` field\n * seen by the configured `EvmSigner` for both the optional approval step\n * and the first-fill swap step. See\n * {@link RecurringExecuteOrderActionParams.signerContext}.\n */\n signerContext?: unknown;\n}\n\n/** Result of any `recurring.execute*` method — broadcast TX hash. */\nexport interface RecurringExecuteResult {\n txHash: Hex;\n}\n\nexport interface RecurringChainInfoEntry {\n /** Server-published lower bound for `intervalSeconds` (today: 300s on enabled chains). */\n minFrequencySeconds: number;\n /**\n * Chain wrapped-native ERC-20 (e.g. WAVAX on 43114, WETH on 1). Sourced\n * from `/info/chains[].wrapped_token` so the SDK doesn't need its own\n * static wrapped-native map. Used by:\n * - `_eligibility.ts` — to reject the native → wrapped-native pairing\n * (e.g. AVAX → WAVAX) with the dedicated `NativeToWrappedNative` reason,\n * and to fail-closed when the chain has no known wrapped-native.\n * - `_namespace.ts` — to fail-fast at `quote()` for native input on a\n * chain Markr hasn't published a wrapped-native for, and to cross-check\n * `wrap.to` from `/recurring/swap` before granting the user's allowance.\n *\n * Undefined for chains where Markr did not return `wrapped_token` — the\n * SDK fails closed on native input in that case.\n */\n wrappedNativeAddress?: EvmAddress;\n}\n\n/**\n * Cached `/info/chains` recurring metadata keyed by EVM chainId. SVM chains\n * are omitted — Markr supports recurring on same-chain EVM only.\n */\nexport type RecurringChainInfoMap = ReadonlyMap<number, RecurringChainInfoEntry>;\n\n/**\n * Reasons surfaced when {@link checkRecurringEligibility} returns\n * `{ eligible: false, … }`. Mirrors the existing `TransferSignatureReason`\n * enum pattern (PascalCase member, kebab-case wire value) so external\n * consumers comparing the raw string still match.\n */\nexport enum RecurringEligibilityReason {\n CrossChain = 'cross-chain',\n UnsupportedSourceChain = 'unsupported-source-chain',\n UnsupportedToken = 'unsupported-token',\n NoEvmAddress = 'no-evm-address',\n /**\n * Caller asked for a recurring schedule from the chain's native asset to\n * its wrapped-native ERC-20 (e.g. AVAX → WAVAX on C-Chain). Economically\n * just a scheduled wrap, not a swap — Markr would have nothing to route\n * after the on-chain wrap leg. Surfaced as a dedicated reason (vs.\n * {@link RecurringEligibilityReason.UnsupportedToken}) so consumer UI can\n * steer the user to a one-shot wrap rather than failing with a generic\n * \"token not supported\" message.\n */\n NativeToWrappedNative = 'native-to-wrapped-native',\n}\n\nexport type RecurringEligibility =\n | { eligible: true; minIntervalSeconds: number }\n | { eligible: false; reason: RecurringEligibilityReason };\n\nexport interface CheckRecurringEligibilityParams {\n recurringChainInfo: RecurringChainInfoMap;\n fromTokenAddress: EvmAddress;\n toTokenAddress: EvmAddress;\n sourceChainId: number;\n targetChainId: number;\n ownerAddress?: EvmAddress;\n}\n\n/**\n * Params passed to `RecurringNamespace.checkEligibility`. Same as\n * `CheckRecurringEligibilityParams` minus the chain-info map, which the\n * namespace closure injects.\n */\nexport type RecurringNamespaceCheckEligibilityParams = Omit<CheckRecurringEligibilityParams, 'recurringChainInfo'>;\n\n/**\n * Params passed to `RecurringNamespace.quote`. Same as `RecurringQuoteParams`\n * minus `appId`, which the namespace closure injects.\n */\nexport type RecurringNamespaceQuoteParams = Omit<RecurringQuoteParams, 'appId'>;\n\n/**\n * High-level wrapper exposed as `MarkrService.recurring`. Methods curry\n * `apiOptions`, `appId`, and the cached `recurringChainInfo` so callers only\n * pass per-call inputs.\n */\nexport interface RecurringNamespace {\n /** POST `/recurring/quote` — full quote with `totalAmountIn`, fees, expiry, uuid. */\n quote(props: RecurringNamespaceQuoteParams): Promise<RecurringQuoteResponse>;\n\n /**\n * Creates the schedule on-chain by signing and broadcasting the first\n * `/recurring/swap` fill via the configured `evmSigner`. Mirrors\n * `TransferService.transferAsset`:\n *\n * 1. Reads on-chain `allowance(tokenIn → router)` against `quote.totalAmountIn`.\n * 2. If allowance is short, builds an `approve(router, totalAmountIn)` TX.\n * When the consumer's signer exposes `signBatch`, the SDK attempts a\n * one-click batch (approve + swap) — set\n * {@link RecurringExecuteFirstFillParams.fallbackToDefaultOnBatchFailure}\n * to fall back to two sequential signatures if the wallet rejects the\n * batch.\n * 3. Estimates gas (with `gasSettings.estimateGasMarginBps` margin) for\n * each TX before signing, and dispatches the signed serialized TX via\n * the chain's RPC.\n *\n * Quote-expiry guard mirrors the previous `prepareFirstFill` behavior —\n * `quote.expiredAt <= now` throws `InvalidParamsError(QUOTE_EXPIRED)` at\n * the SDK boundary before any HTTP / on-chain call.\n *\n * Returns the broadcast first-fill TX hash; the schedule transitions to\n * `'active'` once Markr observes the on-chain event (poll `listOrders`).\n */\n executeFirstFill(props: RecurringExecuteFirstFillParams): Promise<RecurringExecuteResult>;\n\n /**\n * GET `/recurring/orders?address=…&chainId?=…&status?=…` — returns the\n * full response (`{ address, count, orders }`) so callers can render the\n * server-echoed `address` (e.g. confirming the queried wallet matches the\n * current EVM signer) and `count` (pagination / \"you have N schedules\"\n * affordances) without an extra lookup. Consumers that only care about the\n * orders array can destructure: `const { orders } = await listOrders(…)`.\n */\n listOrders(props: ListRecurringOrdersParams): Promise<ListRecurringOrdersResponse>;\n\n /**\n * Cancels the recurring schedule identified by `orderId`: fetches the\n * `/recurring/orders/{orderId}/cancel` calldata, estimates gas, then signs\n * and broadcasts via the configured `evmSigner`. The schedule transitions\n * to `status: 'cancelled'` only once the TX confirms and Markr observes\n * the on-chain event.\n *\n * Eligibility: only `'active'` and `'paused'` orders can be cancelled per\n * Markr's docs. An attempt to cancel a `'completed'` order surfaces as\n * `HttpError(400)` from the orchestrator before signing.\n */\n executeCancellation(props: RecurringExecuteOrderActionParams): Promise<RecurringExecuteResult>;\n\n /**\n * Pauses the recurring schedule identified by `orderId`: fetches the\n * `/recurring/orders/{orderId}/pause` calldata, estimates gas, then signs\n * and broadcasts via the configured `evmSigner`. The schedule transitions\n * to `status: 'paused'` only once the TX confirms and Markr observes the\n * on-chain event.\n *\n * Eligibility: only `'active'` orders can be paused per Markr's docs.\n * Attempting to pause a non-`active` order surfaces as `HttpError(400)`.\n *\n * Pausing preserves the schedule's existing ERC-20 allowance — when the\n * user later unpauses, no re-approval and no new native schedule fee are\n * required (this is the key UX benefit of pause over cancel-and-recreate).\n *\n * @see https://orchestrator-docs.markr.io/#tag/Recurring-Swaps/paths/~1recurring~1orders~1{orderId}~1pause/post\n */\n executePause(props: RecurringExecuteOrderActionParams): Promise<RecurringExecuteResult>;\n\n /**\n * Unpauses (resumes) the recurring schedule identified by `orderId`:\n * fetches the `/recurring/orders/{orderId}/unpause` calldata, estimates\n * gas, then signs and broadcasts via the configured `evmSigner`. The\n * schedule transitions back to `status: 'active'` only once the TX\n * confirms and Markr observes the on-chain event.\n *\n * Eligibility: only `'paused'` orders can be unpaused per Markr's docs.\n * Attempting to unpause a non-`paused` order surfaces as `HttpError(400)`.\n *\n * Resumes execution from where the schedule left off — remaining fills\n * continue on the original `frequency` cadence. The orchestrator recomputes\n * `nextExecutionAt` after the TX confirms.\n *\n * @see https://orchestrator-docs.markr.io/#tag/Recurring-Swaps/paths/~1recurring~1orders~1{orderId}~1unpause/post\n */\n executeUnpause(props: RecurringExecuteOrderActionParams): Promise<RecurringExecuteResult>;\n\n /**\n * Pure (no fetch) — uses the cached `/info/chains` recurring metadata.\n *\n * **Covers:** chain support (recurring enabled on the source chain),\n * EVM-address presence, same-chain (cross-chain rejected), and the\n * native → wrapped-native rejection. Markr no longer publishes a\n * per-chain supported-token list, so every ERC-20 (and the chain's\n * native asset) is treated as recurring-eligible — token-level support is\n * decided server-side at `/recurring/quote` time.\n *\n * **Does NOT cover wallet balance.** This helper has no wallet/RPC context.\n * Checking that the user holds `amount × numberOfOrders` of `tokenIn` (plus\n * native gas for the first fill) is the consumer's responsibility, same as\n * the one-shot swap flow. There is no `InsufficientBalance` reason on\n * {@link RecurringEligibilityReason} by design.\n *\n * **Does NOT cover post-fill failures.** Once a schedule is live, on-chain\n * reverts (slippage, runtime insufficient balance, etc.) surface server-side\n * as open-ended strings on `RecurringOrder.failures[].reasons` — substring-\n * match those for client-driven auto-cancel (AC4 pattern) and call\n * {@link RecurringNamespace.prepareCancellation} when applicable.\n *\n * **Does NOT cover server-side quote rejection.** Slippage, target-token\n * unsupported, liquidity, etc. are decided at `/recurring/quote` time and\n * surface as `HttpError` from {@link RecurringNamespace.quote}.\n */\n checkEligibility(props: RecurringNamespaceCheckEligibilityParams): RecurringEligibility;\n\n /** Returns the cached `/info/chains` recurring metadata. */\n getRecurringChainInfo(): RecurringChainInfoMap;\n}\n"],"mappings":"AAUA,MAAa,EAA4B,CAAC,SAAU,OAAQ,MAAO,OAAQ,QAAQ,CAmBtE,EAAsC,GAWnD,IAAY,EAAL,SAAA,EAAA,OACL,GAAA,OAAA,SACA,EAAA,UAAA,YACA,EAAA,UAAA,YACA,EAAA,OAAA,eACD,CAkVW,EAAL,SAAA,EAAA,OACL,GAAA,WAAA,cACA,EAAA,uBAAA,2BACA,EAAA,iBAAA,oBACA,EAAA,aAAA,iBAUA,EAAA,sBAAA,iCACD"}
@@ -125,9 +125,11 @@ interface EstimateNativeFeeOptions {
125
125
  }
126
126
  interface ServiceQuoteOptions {
127
127
  /**
128
- * Dangerously allows cross-chain quotes where fromAddress and toAddress differ
128
+ * Dangerously allows quotes where fromAddress and toAddress differ,
129
129
  * even when a service would otherwise require them to match.
130
130
  *
131
+ * This applies to both same-chain and cross-chain quotes.
132
+ *
131
133
  * This is intended for explicit proxy-recipient funding flows. Services should
132
134
  * preserve their default address safety checks unless this is set.
133
135
  */
@@ -125,9 +125,11 @@ interface EstimateNativeFeeOptions {
125
125
  }
126
126
  interface ServiceQuoteOptions {
127
127
  /**
128
- * Dangerously allows cross-chain quotes where fromAddress and toAddress differ
128
+ * Dangerously allows quotes where fromAddress and toAddress differ,
129
129
  * even when a service would otherwise require them to match.
130
130
  *
131
+ * This applies to both same-chain and cross-chain quotes.
132
+ *
131
133
  * This is intended for explicit proxy-recipient funding flows. Services should
132
134
  * preserve their default address safety checks unless this is set.
133
135
  */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@avalabs/fusion-sdk",
3
3
  "license": "Limited Ecosystem License",
4
- "version": "0.23.1",
4
+ "version": "0.25.0",
5
5
  "type": "module",
6
6
  "main": "./dist/mod.cjs",
7
7
  "module": "./dist/mod.js",
@@ -49,8 +49,8 @@
49
49
  "vitest": "4.0.6",
50
50
  "tsdown": "0.21.4",
51
51
  "zod": "4.1.12",
52
- "@internal/tsdown-config": "0.0.1",
53
- "eslint-config-custom": "0.1.0"
52
+ "eslint-config-custom": "0.1.0",
53
+ "@internal/tsdown-config": "0.0.1"
54
54
  },
55
55
  "sideEffects": false,
56
56
  "scripts": {