@anywalletkit/protocol-swap2-across 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/README.md +177 -2
- package/dist/activity.cjs +142 -0
- package/dist/activity.cjs.map +1 -0
- package/dist/activity.d.cts +16 -0
- package/dist/activity.d.ts +16 -0
- package/dist/activity.js +10 -0
- package/dist/activity.js.map +1 -0
- package/dist/api.cjs +441 -0
- package/dist/api.cjs.map +1 -0
- package/dist/api.d.cts +207 -0
- package/dist/api.d.ts +207 -0
- package/dist/api.js +35 -0
- package/dist/api.js.map +1 -0
- package/dist/build.cjs +776 -0
- package/dist/build.cjs.map +1 -0
- package/dist/build.d.cts +93 -0
- package/dist/build.d.ts +93 -0
- package/dist/build.js +14 -0
- package/dist/build.js.map +1 -0
- package/dist/chunk-32YJEBZX.js +125 -0
- package/dist/chunk-32YJEBZX.js.map +1 -0
- package/dist/chunk-3UBRQ3ZE.js +255 -0
- package/dist/chunk-3UBRQ3ZE.js.map +1 -0
- package/dist/chunk-5BDZXOOP.js +21 -0
- package/dist/chunk-5BDZXOOP.js.map +1 -0
- package/dist/chunk-6Z4GXNLE.js +102 -0
- package/dist/chunk-6Z4GXNLE.js.map +1 -0
- package/dist/chunk-AWQT5S4V.js +101 -0
- package/dist/chunk-AWQT5S4V.js.map +1 -0
- package/dist/chunk-E5WFOPN2.js +16 -0
- package/dist/chunk-E5WFOPN2.js.map +1 -0
- package/dist/chunk-GX67FRPG.js +194 -0
- package/dist/chunk-GX67FRPG.js.map +1 -0
- package/dist/chunk-KATEONJQ.js +396 -0
- package/dist/chunk-KATEONJQ.js.map +1 -0
- package/dist/chunk-P32AW6XS.js +27 -0
- package/dist/chunk-P32AW6XS.js.map +1 -0
- package/dist/chunk-PPPZIG7S.js +265 -0
- package/dist/chunk-PPPZIG7S.js.map +1 -0
- package/dist/chunk-SJOFLM27.js +138 -0
- package/dist/chunk-SJOFLM27.js.map +1 -0
- package/dist/chunk-YGNP7KPL.js +311 -0
- package/dist/chunk-YGNP7KPL.js.map +1 -0
- package/dist/config.cjs +214 -0
- package/dist/config.cjs.map +1 -0
- package/dist/config.d.cts +119 -0
- package/dist/config.d.ts +119 -0
- package/dist/config.js +47 -0
- package/dist/config.js.map +1 -0
- package/dist/deposit.cjs +252 -0
- package/dist/deposit.cjs.map +1 -0
- package/dist/deposit.d.cts +95 -0
- package/dist/deposit.d.ts +95 -0
- package/dist/deposit.js +19 -0
- package/dist/deposit.js.map +1 -0
- package/dist/index.cjs +1789 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +34 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.js +242 -0
- package/dist/index.js.map +1 -0
- package/dist/pricing.cjs +132 -0
- package/dist/pricing.cjs.map +1 -0
- package/dist/pricing.d.cts +123 -0
- package/dist/pricing.d.ts +123 -0
- package/dist/pricing.js +42 -0
- package/dist/pricing.js.map +1 -0
- package/dist/protocol.cjs +1596 -0
- package/dist/protocol.cjs.map +1 -0
- package/dist/protocol.d.cts +20 -0
- package/dist/protocol.d.ts +20 -0
- package/dist/protocol.js +17 -0
- package/dist/protocol.js.map +1 -0
- package/dist/provider.cjs +1581 -0
- package/dist/provider.cjs.map +1 -0
- package/dist/provider.d.cts +45 -0
- package/dist/provider.d.ts +45 -0
- package/dist/provider.js +18 -0
- package/dist/provider.js.map +1 -0
- package/dist/remote.cjs +1659 -0
- package/dist/remote.cjs.map +1 -0
- package/dist/remote.d.cts +55 -0
- package/dist/remote.d.ts +55 -0
- package/dist/remote.js +17 -0
- package/dist/remote.js.map +1 -0
- package/dist/status.cjs +443 -0
- package/dist/status.cjs.map +1 -0
- package/dist/status.d.cts +109 -0
- package/dist/status.d.ts +109 -0
- package/dist/status.js +26 -0
- package/dist/status.js.map +1 -0
- package/dist/verify.cjs +690 -0
- package/dist/verify.cjs.map +1 -0
- package/dist/verify.d.cts +245 -0
- package/dist/verify.d.ts +245 -0
- package/dist/verify.js +69 -0
- package/dist/verify.js.map +1 -0
- package/module.json +32 -0
- package/package.json +124 -3
package/dist/api.cjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/api.ts","../src/config.ts","../src/refusal.ts"],"sourcesContent":["/**\n * The two Across APIs this module reads — for NUMBERS only. Nothing either one answers is signed or executed: the\n * deposit is encoded on the device from the pins and the user's request (`build.ts`) and verified (`verify.ts`).\n *\n * - **Across API V5** (`POST https://api.across.to/v1/quotes`, a key from dashboard.across.to, server-side only) is\n * the price source. A V5 quote prices V5's own route — an execution step on the origin chain (Across's Gateway),\n * sometimes another rail (CCTP, an OFT) — and funds it through `nextActions` that pay an escrow keyed by an order\n * id the device cannot open (the recipient, the destination and the floor are not in anything it would sign). So\n * `nextActions`, `orderId`, `minAmount` and the attestation are never read: only the fee, its gas legs, the fill\n * estimate and the USD prices, each read strictly ({@link readAcrossV5Quote}).\n * - **`/suggested-fees`** (`GET https://app.across.to/api/suggested-fees`, keyless, the Across app's own relayer-fee\n * quote — Across calls it legacy) is the independent statement of what an Across relayer needs to fill a plain\n * SpokePool deposit, and the `timestamp` its LP fee was priced at ({@link readAcrossSuggestedFees}).\n *\n * `pricing.ts` turns the two into the deposit's numbers. Sources: Across's V5 integration skills\n * (github.com/across-protocol/skills @ f4d425e6, `quote-and-execute`, `security`) and real answers of both APIs\n * recorded 2026-11-15 (fixtures/api).\n */\nimport {httpRefusal, type Swap2RefusalInfo, type Swap2RefusalReason} from \"@anywalletkit/protocol-swap2-core/errors\";\nimport {anySignal, timeoutSignal} from \"@anywalletkit/protocol-swap2-core/util\";\nimport {ACROSS_API, acrossChain, type AcrossRoute} from \"./config.js\";\nimport {AcrossRefusal} from \"./refusal.js\";\nimport type {AcrossRequest} from \"./verify.js\";\n\n/** The V5 base (`ACROSS_API` + `/v1`). */\nexport const ACROSS_API_V1 = `${ACROSS_API}/v1`;\n/** Across's keyless relayer-fee quote (the Across app's own `/suggested-fees`). */\nexport const ACROSS_SUGGESTED_FEES_URL = \"https://app.across.to/api/suggested-fees\";\n/**\n * `maxFee.bps` sent with every V5 quote request: the widest V5 takes. It only bounds V5's own guaranteed minimum,\n * which is never used here (V5's estimate does not move with it: 24 962 036 / 24 962 140 / 24 963 399 base units for\n * the same 25 USDC at three caps, 2026-11-14); at 1000 V5 refused Ethereum-origin transfers under ~$16.5–19 because\n * its own origin gas alone was over the cap. The user's own cap is held on the deposit, by the verifier.\n */\nexport const ACROSS_V5_PRICING_MAX_FEE_BPS = 5_000;\n/** Longest answer read from either API, in characters (a V5 quote is ~12 kB). */\nconst MAX_ANSWER_CHARS = 512 * 1024;\n\nexport interface AcrossV5Token {\n chainId: number;\n address: string;\n}\n\n/** `POST /v1/quotes` body, exactly the fields this module sends (the API refuses any field it does not know). */\nexport interface AcrossV5QuoteRequest {\n origin: {token: AcrossV5Token; depositor: string; amount: string};\n destination: {token: AcrossV5Token; recipient: string};\n amountType: \"exact_input\";\n /** What the client can do: approve a token and send a transaction on an EVM chain. No typed data, no submissions. */\n capabilities: {operations: readonly {kind: \"approve_token\" | \"send_transaction\"; ecosystem: \"evm\"}[]};\n /** An approval of exactly the funded amount — never `infinite`. */\n authorizationPolicy: {allowedTypes: readonly [\"approval\"]; approvalAmount: \"exact\"};\n /** {@link ACROSS_V5_PRICING_MAX_FEE_BPS}. */\n maxFee: {bps: number};\n}\n\n/**\n * The `POST /v1/quotes` body for a request. Pure. Native ETH is the zero address on both sides, as V5 names it; the\n * funding is the plain approval flow (`approve_token` + `send_transaction`, exact amount) — the one whose price was\n * studied; nothing it returns is executed.\n */\nexport function acrossV5QuoteRequest(request: AcrossRequest): AcrossV5QuoteRequest {\n const src = acrossChain(request.sourceChain);\n const dst = acrossChain(request.destChain);\n if (!src || !dst) throw new Error(\"across: the request's chains are not pinned\");\n return {\n origin: {token: {chainId: src.chainId, address: request.sourceToken.toLowerCase()}, depositor: request.depositor.toLowerCase(), amount: request.amount.toString(10)},\n destination: {token: {chainId: dst.chainId, address: request.destToken.toLowerCase()}, recipient: request.recipient.toLowerCase()},\n amountType: \"exact_input\",\n capabilities: {operations: [{kind: \"approve_token\", ecosystem: \"evm\"}, {kind: \"send_transaction\", ecosystem: \"evm\"}]},\n authorizationPolicy: {allowedTypes: [\"approval\"], approvalAmount: \"exact\"},\n maxFee: {bps: ACROSS_V5_PRICING_MAX_FEE_BPS},\n };\n}\n\n// ── reading answers ────────────────────────────────────────────────────────────\n\nconst ADDRESS = /^0x[0-9a-fA-F]{40}$/;\nconst ZERO = /^0x0{40}$/;\nconst UINT = /^(?:0|[1-9]\\d{0,77})$/;\n/** A non-negative decimal as V5 writes USD amounts (\"0.012048778559999999\"). */\nconst DECIMAL = /^(?:0|[1-9]\\d{0,15})(?:\\.\\d{1,30})?$/;\nconst plain = (v: unknown): v is Record<string, unknown> => v !== null && typeof v === \"object\" && !Array.isArray(v);\nconst own = (o: Record<string, unknown>, key: string): unknown => (Object.prototype.hasOwnProperty.call(o, key) ? o[key] : undefined);\nconst uint = (v: unknown): bigint | null => (typeof v === \"string\" && UINT.test(v) ? BigInt(v) : null);\nconst sameAddress = (a: unknown, b: string): boolean => typeof a === \"string\" && ADDRESS.test(a) && a.toLowerCase() === b.toLowerCase();\n\n/** A decimal string as an integer scaled by 10^`scale`, rounded down; null when it is not one. */\nfunction scaled(text: string, scale: number): bigint | null {\n if (!DECIMAL.test(text)) return null;\n const [whole, frac = \"\"] = text.split(\".\");\n return BigInt(whole! + frac.slice(0, scale).padEnd(scale, \"0\"));\n}\n\nconst USD_SCALE = 18;\nconst PRICE_SCALE = 12;\n\n/**\n * A USD amount as base units of a token priced at `priceUsd`, rounded down — integer math only (no `Number` of a big\n * value): `amountUsd × 10^decimals / priceUsd`. Null when either is not a usable number.\n */\nexport function acrossUsdToUnits(amountUsd: unknown, priceUsd: unknown, decimals: number): bigint | null {\n if (typeof amountUsd !== \"string\" || typeof priceUsd !== \"number\" || !Number.isFinite(priceUsd) || priceUsd <= 0 || priceUsd >= 1e12) return null;\n if (!Number.isInteger(decimals) || decimals < 0 || decimals > 36) return null;\n const usd = scaled(amountUsd, USD_SCALE);\n const price = scaled(priceUsd.toFixed(PRICE_SCALE), PRICE_SCALE);\n if (usd === null || price === null || price === 0n) return null;\n return (usd * 10n ** BigInt(decimals) * 10n ** BigInt(PRICE_SCALE)) / (price * 10n ** BigInt(USD_SCALE));\n}\n\n/** What a V5 quote says that the pricing rule reads — every amount in base units of the input token. */\nexport interface AcrossV5Price {\n /** `fee.totalFee.amount`: input − `destination.amount` (checked to add up). */\n totalFee: bigint;\n /** V5's estimate of what arrives (`destination.amount`). */\n destinationAmount: bigint;\n /**\n * Σ `gasEstimates[leg = \"origin\", effect = \"included_in_transfer_fee\"]`: V5's own execution step on the origin\n * chain, charged inside its fee. Exact wei on an ETH route; a token route converts its USD figure at the\n * destination token's price, rounded down. A leg that cannot be read adds nothing (the fee stays higher).\n */\n originGas: bigint;\n /** Σ `gasEstimates[leg = \"destination\", effect = \"included_in_transfer_fee\"]`, converted alike; null when a leg cannot be. */\n destinationGas: bigint | null;\n /** `expectedFillTimeMs`. Over a minute it is not an Across relayer fill: V5 prices another rail (`acrossV5OtherRail`). */\n expectedFillTimeMs: number;\n /** `origin.amountUsd`, when given: the transfer's size in dollars (the floor curve for ETH from an L2 is by size). */\n amountUsd?: number;\n}\n\n/**\n * A V5 quote answer, read strictly against the request it was asked for. Throws {@link AcrossRefusal} `api-answer`:\n * `policy_refused` for an answer about another transfer (tokens, chains, amount, an app fee nobody asked for),\n * `upstream_unavailable` for one that does not read or does not add up. `nextActions`, `orderId`, `minAmount` and any\n * attestation are not read.\n */\nexport function readAcrossV5Quote(request: AcrossRequest, route: AcrossRoute, body: unknown): AcrossV5Price {\n const malformed = (what: string): never => { throw new AcrossRefusal(\"api-answer\", `the V5 quote ${what}`, \"upstream_unavailable\"); };\n const other = (what: string): never => { throw new AcrossRefusal(\"api-answer\", `the V5 quote ${what}`, \"policy_refused\"); };\n if (!plain(body)) return malformed(\"is not a JSON object\");\n const amountType = own(body, \"amountType\");\n if (amountType !== undefined && amountType !== \"exact_input\") other(`is ${String(amountType).slice(0, 20)}, not exact input`);\n const src = route.input.chain;\n const dst = route.output.chain;\n\n const origin = own(body, \"origin\");\n const destination = own(body, \"destination\");\n if (!plain(origin) || !plain(destination)) return malformed(\"has no origin or destination\");\n const oToken = own(origin, \"token\");\n const dToken = own(destination, \"token\");\n if (!plain(oToken) || !plain(dToken)) return malformed(\"names no tokens\");\n if (own(oToken, \"chainId\") !== src.chainId || !sameAddress(own(oToken, \"address\"), request.sourceToken)) other(\"is for another input token or chain\");\n if (own(dToken, \"chainId\") !== dst.chainId || !sameAddress(own(dToken, \"address\"), request.destToken)) other(\"is for another output token or chain\");\n const amountIn = uint(own(origin, \"amount\"));\n if (amountIn === null) return malformed(\"states no input amount\");\n if (amountIn !== request.amount) other(`sends ${amountIn}, the request ${request.amount}`);\n const destinationAmount = uint(own(destination, \"amount\"));\n if (destinationAmount === null) return malformed(\"states no output estimate\");\n if (destinationAmount > request.amount) other(\"expects more to arrive than goes in\");\n\n const fee = own(body, \"fee\");\n if (!plain(fee)) return malformed(\"has no fee\");\n const total = own(fee, \"totalFee\");\n if (!plain(total)) return malformed(\"has no total fee\");\n const totalFee = uint(own(total, \"amount\"));\n if (totalFee === null) return malformed(\"states a total fee that is not a base-unit integer\");\n const feeToken = own(total, \"token\");\n if (!plain(feeToken) || own(feeToken, \"chainId\") !== dst.chainId || !sameAddress(own(feeToken, \"address\"), request.destToken) || own(feeToken, \"decimals\") !== route.output.decimals) {\n malformed(\"states its fee in another token\");\n }\n if (totalFee !== request.amount - destinationAmount) malformed(`fee ${totalFee} is not its input minus its estimate (${request.amount - destinationAmount})`);\n const appFee = own(fee, \"appFee\");\n if (appFee !== undefined && appFee !== null) {\n const app = plain(appFee) ? uint(own(appFee, \"amount\")) : null;\n if (app === null) return malformed(\"states an app fee that does not read\");\n if (app > 0n) other(\"carries an app fee this module never asks for\");\n }\n\n const fill = own(body, \"expectedFillTimeMs\");\n if (typeof fill !== \"number\" || !Number.isFinite(fill) || fill < 0) return malformed(\"states no fill time\");\n const priceUsd = own(dToken, \"priceUsd\");\n const legs = own(body, \"gasEstimates\");\n if (!Array.isArray(legs) || legs.length > 16) return malformed(\"has no gas estimates\");\n let originGas = 0n;\n let destinationGas: bigint | null = 0n;\n for (const leg of legs as unknown[]) {\n if (!plain(leg)) return malformed(\"has a gas estimate that is not an object\");\n if (own(leg, \"effect\") !== \"included_in_transfer_fee\") continue;\n const side = own(leg, \"leg\");\n if (side !== \"origin\" && side !== \"destination\") continue;\n const units = legUnits(leg, route, priceUsd);\n if (side === \"origin\") originGas += units ?? 0n;\n else destinationGas = units === null || destinationGas === null ? null : destinationGas + units;\n }\n // An add-back is never more than the fee it is taken from.\n if (originGas > totalFee) originGas = totalFee;\n\n const usdText = own(origin, \"amountUsd\");\n const amountUsd = typeof usdText === \"string\" && DECIMAL.test(usdText) ? Number(usdText) : undefined;\n return {totalFee, destinationAmount, originGas, destinationGas, expectedFillTimeMs: fill, ...(amountUsd !== undefined && Number.isFinite(amountUsd) ? {amountUsd} : {})};\n}\n\n/**\n * One gas leg in base units of the input token. On an ETH route a leg paid in the native ether of either chain is\n * exact (wei is the bridged asset's own unit); anything else is its `amountUsd` at the destination token's price.\n */\nfunction legUnits(leg: Record<string, unknown>, route: AcrossRoute, priceUsd: unknown): bigint | null {\n const token = own(leg, \"token\");\n const amount = uint(own(leg, \"amount\"));\n if (route.asset === \"ETH\" && plain(token) && amount !== null && ZERO.test(String(own(token, \"address\"))) && own(token, \"decimals\") === 18) {\n const chainId = own(token, \"chainId\");\n const side = chainId === route.input.chain.chainId ? route.input.chain : chainId === route.output.chain.chainId ? route.output.chain : undefined;\n if (side?.nativeIsEth) return amount;\n }\n return acrossUsdToUnits(own(leg, \"amountUsd\"), priceUsd, route.input.decimals);\n}\n\n/** What `/suggested-fees` answered, as the pricing rule reads it. */\nexport type AcrossSuggestedFees =\n /** A relayer fee for this exact deposit. */\n | {kind: \"fees\"; totalRelayFee: bigint; timestamp: number; estimatedFillTimeSec: number}\n /** Across says relayers will not take this deposit (too small, too large, the route not enabled): refuse. */\n | {kind: \"refused\"; detail: string; reason: Swap2RefusalReason}\n /** No usable answer (unreachable, another shape, stale): the pinned floor stands in. */\n | {kind: \"unavailable\"; detail: string};\n\n/** The `/suggested-fees` query for a request: the deposit's own tokens (the wrapped native token for ETH) and recipient. */\nexport function acrossSuggestedFeesQuery(request: AcrossRequest, route: AcrossRoute): string {\n const q: [string, string][] = [\n [\"inputToken\", route.input.token],\n [\"outputToken\", route.output.token],\n [\"originChainId\", String(route.input.chain.chainId)],\n [\"destinationChainId\", String(route.output.chain.chainId)],\n [\"amount\", request.amount.toString(10)],\n [\"recipient\", request.recipient.toLowerCase()],\n ];\n return q.map(([k, v]) => `${k}=${encodeURIComponent(v)}`).join(\"&\");\n}\n\n/**\n * How old a `/suggested-fees` timestamp may be (s). It becomes the deposit's quote time, so it is never taken from\n * ahead of the reader's clock: the SpokePool reverts a quote time ahead of its block, and Across's are HubPool block\n * times minutes in the past (217–245 s on every recorded answer).\n */\nexport const ACROSS_SUGGESTED_FEES_MAX_AGE_S = 600;\nexport const ACROSS_SUGGESTED_FEES_MAX_AHEAD_S = 0;\n\n/**\n * A `/suggested-fees` answer for a request, at `nowS`. Across's own refusals of the deposit — any 400 it answers\n * (`AMOUNT_TOO_LOW`, `AMOUNT_TOO_HIGH`, `ROUTE_NOT_ENABLED`, `INVALID_PARAM` for a token or a chain it does not serve,\n * or a code this module does not know), `isAmountTooLow`, an amount outside `limits` — and a SpokePool other than the\n * pinned one are `refused`; no answer, another status, or one that is not a clean, consistent, fresh answer is\n * `unavailable` (the pinned floor may then stand in).\n */\nexport function readAcrossSuggestedFees(request: AcrossRequest, route: AcrossRoute, status: number, body: unknown, nowS: number): AcrossSuggestedFees {\n const unavailable = (detail: string): AcrossSuggestedFees => ({kind: \"unavailable\", detail});\n const refused = (detail: string, reason: Swap2RefusalReason): AcrossSuggestedFees => ({kind: \"refused\", detail, reason});\n if (status !== 200) {\n const code = plain(body) ? own(body, \"code\") : undefined;\n const label = typeof code === \"string\" ? ` ${code.slice(0, 40)}` : \"\";\n if (status === 400) {\n if (code === \"AMOUNT_TOO_LOW\") return refused(\"Across's relayer fee quote says the amount is too low relative to fees\", \"amount_too_small\");\n if (code === \"AMOUNT_TOO_HIGH\") return refused(\"Across's relayer fee quote says the amount is higher than relayer liquidity\", \"amount_too_large\");\n if (code === \"ROUTE_NOT_ENABLED\") return refused(\"Across's relayer fee quote says this route is not enabled for relayers\", \"unsupported_pair\");\n // Only pinned tokens and chains are asked for: one Across calls invalid (\"Unsupported token on given origin\n // chain\") is one its relayers do not serve — a deposit priced on the floor for it would never be filled.\n const param = plain(body) ? own(body, \"param\") : undefined;\n const message = plain(body) ? own(body, \"message\") : undefined;\n if (code === \"INVALID_PARAM\" && /token|chain/i.test(`${typeof param === \"string\" ? param : \"\"} ${typeof message === \"string\" ? message : \"\"}`)) {\n return refused(`Across's relayer fee quote does not serve this token or chain (INVALID_PARAM${typeof param === \"string\" ? ` ${param.slice(0, 40)}` : \"\"})`, \"unsupported_pair\");\n }\n // Any other refusal of this exact deposit: Across said no, so nothing stands in for its price.\n return refused(`Across's relayer fee quote refused the deposit (HTTP 400${label})`, \"upstream_unavailable\");\n }\n return unavailable(`it answered HTTP ${status}${label}`);\n }\n if (!plain(body)) return unavailable(\"its answer is not a JSON object\");\n const inputToken = own(body, \"inputToken\");\n const outputToken = own(body, \"outputToken\");\n if (!plain(inputToken) || !plain(outputToken)) return unavailable(\"its answer names no tokens\");\n if (!sameAddress(own(inputToken, \"address\"), route.input.token) || own(inputToken, \"chainId\") !== route.input.chain.chainId\n || !sameAddress(own(outputToken, \"address\"), route.output.token) || own(outputToken, \"chainId\") !== route.output.chain.chainId) {\n return unavailable(\"its answer is for another route\");\n }\n // The SpokePools relayers watch for this route: the pinned ones, or the pins are out of date.\n const spoke = own(body, \"spokePoolAddress\");\n const destSpoke = own(body, \"destinationSpokePoolAddress\");\n const spokeMoved = spoke !== undefined && !sameAddress(spoke, route.input.chain.spokePool);\n if (spokeMoved || (destSpoke !== undefined && !sameAddress(destSpoke, route.output.chain.spokePool))) {\n return refused(`Across quotes this route on another SpokePool than the one pinned for ${spokeMoved ? route.input.chain.name : route.output.chain.name} — the pins need a review`, \"vault_mismatch\");\n }\n const totalRelay = own(body, \"totalRelayFee\");\n const total = plain(totalRelay) ? uint(own(totalRelay, \"total\")) : null;\n const outputAmount = uint(own(body, \"outputAmount\"));\n if (total === null || outputAmount === null) return unavailable(\"its answer states no relayer fee\");\n if (outputAmount + total !== request.amount) return unavailable(\"its fee is not the amount minus its output\");\n if (own(body, \"isAmountTooLow\") === true || total >= request.amount) return refused(\"Across's relayer fee quote says the amount is too low relative to fees\", \"amount_too_small\");\n const limits = own(body, \"limits\");\n if (plain(limits)) {\n const min = uint(own(limits, \"minDeposit\"));\n const max = uint(own(limits, \"maxDeposit\"));\n if (min !== null && request.amount < min) return refused(`Across's relayers take at least ${min} base units on this route`, \"amount_too_small\");\n if (max !== null && request.amount > max) return refused(`Across's relayers take at most ${max} base units on this route`, \"amount_too_large\");\n }\n const ts = own(body, \"timestamp\");\n const timestamp = typeof ts === \"string\" && /^[1-9]\\d{8,9}$/.test(ts) ? Number(ts) : NaN;\n if (!Number.isInteger(timestamp)) return unavailable(\"its answer states no quote time\");\n if (timestamp - nowS > ACROSS_SUGGESTED_FEES_MAX_AHEAD_S) return unavailable(`its quote time is ${timestamp - nowS} s ahead of this clock`);\n if (nowS - timestamp > ACROSS_SUGGESTED_FEES_MAX_AGE_S) return unavailable(`its quote time is ${nowS - timestamp} s old`);\n const eta = own(body, \"estimatedFillTimeSec\");\n return {kind: \"fees\", totalRelayFee: total, timestamp, estimatedFillTimeSec: typeof eta === \"number\" && Number.isFinite(eta) && eta >= 0 ? eta : 2};\n}\n\n// ── V5 errors ──────────────────────────────────────────────────────────────────\n\n/** A V5 error answer, read from either envelope, with its classification. */\nexport interface AcrossV5Error {\n /** HTTP status of the answer. */\n status: number;\n /** `error.code`, else the top-level `code` (`unauthenticated`, `policy.amount_out_of_range`, …). */\n code?: string;\n /** `error.type` (nested envelope only). */\n type?: string;\n message?: string;\n /** The field the error names (`error.param`). */\n param?: string;\n /** Across's id for the request, for support (`error.requestId`). */\n requestId?: string;\n /** `error.details.amountLimits`: which bound the amount crossed and where it lies, base units of the input token. */\n amountLimit?: {side: \"min\" | \"max\"; amount?: string};\n /** The CS-13 classification; undefined when neither the code nor the status says what it is. */\n info?: Swap2RefusalInfo;\n /**\n * `409 conflict.submission_state_unknown`: the execution's outcome is unknown — retry the SAME request with backoff,\n * never quote again (a new quote could fund the transfer twice). Quoting never meets it; kept for completeness.\n */\n retrySameRequest: boolean;\n}\n\nconst text = (v: unknown, max: number): string | undefined => (typeof v === \"string\" && v.length > 0 ? v.slice(0, max) : undefined);\n\n/**\n * A refusal over the `maxFee` cap, in Across's wording or near it: the cap named (`maxFee`, \"maximum fee\", \"fee cap\"),\n * or a fee said to be above something. \"Amount too low to cover fees\" is not one — that is the amount's own direction.\n */\nconst FEE_CAP = /\\bmax[ _-]?fee\\b|\\bmaximum (?:total |transfer )?fee\\b|\\bfee (?:cap|limit)\\b|\\bfees? (?:is |are )?(?:above|exceeds?|over|greater than|more than)\\b/;\n\n/** What an error code says on its own (Across's documented codes), before the HTTP status is consulted. */\nfunction reasonOfCode(code: string, message: string | undefined, param: string | undefined, side: \"min\" | \"max\" | undefined, status: number): Swap2RefusalInfo | undefined {\n switch (code) {\n case \"unauthenticated\":\n case \"auth.missing_credentials\":\n case \"auth.invalid_credentials\":\n // A feature the key is not entitled to (a permission Across grants per integration).\n case \"permission.not_entitled\":\n return {reason: \"key_rejected\", httpStatus: status};\n case \"policy.amount_out_of_range\": {\n // The bound V5 names is the answer: the real fee-cap refusal reads \"quote value loss exceeds the allowance of\n // 1000 bps plus $0; raise the amount above N base units\" with `amountLimits.side = \"min\"` — its \"above\" names\n // the amount the user must reach, not an amount that is too large.\n if (side === \"min\") return {reason: \"amount_too_small\"};\n if (side === \"max\") return {reason: \"amount_too_large\"};\n const m = (message ?? \"\").toLowerCase();\n if (/\\b(?:raise|increase) the amount\\b/.test(m)) return {reason: \"amount_too_small\"};\n if (/\\b(?:lower|reduce|decrease) the amount\\b/.test(m)) return {reason: \"amount_too_large\"};\n if (FEE_CAP.test(m)) return {reason: \"price_check_failed\"};\n if (/\\b(?:too low|too small|below|minimum|min)\\b/.test(m)) return {reason: \"amount_too_small\"};\n if (/\\b(?:too high|too large|above|maximum|max|liquidity)\\b/.test(m)) return {reason: \"amount_too_large\"};\n return {reason: \"price_check_failed\"};\n }\n // The API no longer takes what this module sends (a field it does not know, or one it now requires): an API of\n // another shape than the one this module was built against.\n case \"request.unsupported_param\":\n case \"request.missing_field\":\n return {reason: \"upstream_unavailable\", httpStatus: status};\n // Only pinned tokens and chains are sent: one V5 calls invalid (\"unknown token … is not a known token\") is one it\n // does not serve. Any other value it no longer takes is, like the codes above, an API of another shape.\n case \"request.invalid_field\":\n return /token|chain/i.test(`${param ?? \"\"} ${message ?? \"\"}`) ? {reason: \"unsupported_pair\"} : {reason: \"upstream_unavailable\", httpStatus: status};\n case \"system.unavailable\":\n case \"conflict.submission_state_unknown\":\n return {reason: \"upstream_unavailable\", httpStatus: status};\n default:\n return undefined;\n }\n}\n\n/**\n * Read a non-2xx V5 answer: the two envelopes Across uses — flat `{code, message, details}` (the gateway's 401) and\n * nested `{error: {type, code, message, param, requestId, details}}` — and its CS-13 classification. A 429 is\n * `rate_limited` with its Retry-After first; then the code (with `details.amountLimits.side` for\n * `policy.amount_out_of_range`); then the status (401 / 403 → `key_rejected`, 408 / 425 / 5xx →\n * `upstream_unavailable`); a JSON refusal neither names is a quote the API does not have (`no_route`).\n */\nexport function parseAcrossV5Error(status: number, body: unknown, retryAfter?: string | null, nowMs: number = Date.now()): AcrossV5Error {\n const o = plain(body) ? body : undefined;\n const nested = o !== undefined && plain(o[\"error\"]) ? o[\"error\"] : undefined;\n const code = text(nested?.[\"code\"], 80) ?? text(o?.[\"code\"], 80);\n const type = text(nested?.[\"type\"], 80);\n const message = text(nested?.[\"message\"], 240) ?? text(o?.[\"message\"], 240);\n const param = text(nested?.[\"param\"], 80);\n const requestId = text(nested?.[\"requestId\"], 120);\n const details = nested !== undefined && plain(nested[\"details\"]) ? nested[\"details\"] : o !== undefined && plain(o[\"details\"]) ? o[\"details\"] : undefined;\n const limits = details !== undefined && plain(details[\"amountLimits\"]) ? details[\"amountLimits\"] : undefined;\n const rawSide = limits?.[\"side\"];\n const side = rawSide === \"min\" || rawSide === \"max\" ? rawSide : undefined;\n const rawBound = limits?.[\"amount\"];\n const bound = typeof rawBound === \"string\" && UINT.test(rawBound) ? rawBound : undefined;\n const byStatus = httpRefusal(status, retryAfter, nowMs);\n let info: Swap2RefusalInfo | undefined;\n if (byStatus?.reason === \"rate_limited\") info = byStatus;\n else info = (code !== undefined ? reasonOfCode(code, message, param, side, status) : undefined) ?? byStatus ?? (o !== undefined && status >= 400 && status < 500 && status !== 404 ? {reason: \"no_route\"} : undefined);\n return {\n status,\n ...(code !== undefined ? {code} : {}),\n ...(type !== undefined ? {type} : {}),\n ...(message !== undefined ? {message} : {}),\n ...(param !== undefined ? {param} : {}),\n ...(requestId !== undefined ? {requestId} : {}),\n ...(side !== undefined ? {amountLimit: {side, ...(bound !== undefined ? {amount: bound} : {})}} : {}),\n ...(info !== undefined ? {info} : {}),\n retrySameRequest: status === 409 && code === \"conflict.submission_state_unknown\",\n };\n}\n\n// ── HTTP ───────────────────────────────────────────────────────────────────────\n\n/** An API URL, trailing slashes trimmed; throws a plain `Error` unless https (or http on this machine). */\nexport function acrossApiUrl(url: string, what: string): string {\n const u = String(url).trim().replace(/\\/+$/, \"\");\n if (/^https:\\/\\/[^\\s/?#@]+(?:\\/[^\\s?#]*)?$/i.test(u)) return u;\n if (/^http:\\/\\/(?:localhost|127\\.0\\.0\\.1)(?::[0-9]{1,5})?(?:\\/[^\\s?#]*)?$/i.test(u)) return u;\n throw new Error(`across: ${what} must be an https:// URL (http only for localhost)`);\n}\n\n/** `scheme://host[:port]` of a URL, lowercase; \"\" when it has none. No URL class: React Native's lacks `origin`. */\nexport const acrossOriginOf = (url: string): string => (/^[a-z][a-z0-9+.-]*:\\/\\/[^/?#]*/i.exec(url)?.[0] ?? \"\").toLowerCase();\n\n/** An answer as read: status, parsed body (undefined when not JSON), Retry-After. */\nexport interface AcrossHttpAnswer {\n status: number;\n body: unknown;\n retryAfter: string | null;\n}\n\n/**\n * One request to an Across API, bounded by `timeoutMs` (and the caller's signal). An answer that came through a\n * redirect, or from another origin than the URL's, is refused (`policy_refused`) — a key header must not follow one,\n * and React Native's fetch follows redirects whatever `redirect` says. Throws {@link AcrossRefusal} `api-answer` for a\n * redirect, an answer larger than any quote, or no answer (`upstream_unavailable`; unclassified when the caller's own\n * signal fired).\n */\nexport async function acrossHttp(\n url: string,\n init: {method: \"GET\" | \"POST\"; headers: Record<string, string>; body?: string},\n opts: {fetchImpl?: typeof fetch | undefined; timeoutMs: number; signal?: AbortSignal | undefined; what: string},\n): Promise<AcrossHttpAnswer> {\n const expected = acrossOriginOf(url);\n let status: number;\n let raw: string;\n let retryAfter: string | null = null;\n try {\n const timeout = timeoutSignal(opts.timeoutMs);\n const res = await (opts.fetchImpl ?? fetch)(url, {...init, redirect: \"error\", signal: opts.signal ? anySignal([opts.signal, timeout]) : timeout});\n if (res.redirected === true || (typeof res.url === \"string\" && res.url !== \"\" && acrossOriginOf(res.url) !== expected)) {\n throw new AcrossRefusal(\"api-answer\", `${opts.what} answered through a redirect or from another origin — refused (a key must not follow one)`, \"policy_refused\");\n }\n status = res.status;\n retryAfter = res.headers?.get?.(\"retry-after\") ?? null;\n raw = await res.text();\n } catch (err) {\n if (err instanceof AcrossRefusal) throw err;\n const name = err instanceof Error ? err.name.slice(0, 40) : \"error\";\n throw new AcrossRefusal(\"api-answer\", `${opts.what} did not answer (${name})`, opts.signal?.aborted ? undefined : \"upstream_unavailable\");\n }\n if (raw.length > MAX_ANSWER_CHARS) throw new AcrossRefusal(\"api-answer\", `${opts.what} answered more than any quote`, \"upstream_unavailable\");\n let body: unknown;\n try {\n body = JSON.parse(raw);\n } catch {\n body = undefined;\n }\n return {status, body, retryAfter};\n}\n","// Across Protocol — the pins this module signs against. Nothing here is read from an API at run time: the Across API\n// (or an app's own proxy in front of it) is untrusted, and a deposit is signed only for a SpokePool, a chain and a\n// token written in this file.\n//\n// Sources, all read on 2026-11-15:\n// - github.com/across-protocol/contracts @ d652689f67cd9835b9c1ab0acc2f99236902e299, `broadcast/deployed-addresses.json`\n// (\"the current source of truth for deployed contract addresses\", deployments/README.md): `chains.<id>.contracts.\n// SpokePool.address` for every row below, `chains.1.contracts.HubPool.address` for the hub.\n// - On chain, Ethereum: `HubPool.crossChainContracts(chainId)` (selector 0x09474ae2) answers the same SpokePool for\n// every row (publicnode, block 26415696; eth.drpc.org one block later agreed on every row).\n// - On chain, each row over a public RPC: `eth_chainId` and the SpokePool's own `chainId()` are the row's id; the\n// EIP-1967 implementation slot is set (UUPS proxy, upgraded through the HubPool); `crossDomainAdmin()` is the\n// HubPool; `wrappedNativeToken()` is the value pinned below; `depositQuoteTimeBuffer()` = 3600,\n// `fillDeadlineBuffer()` = 21600 and `pausedDeposits()` = false. The implementation carries the `deposit` selector\n// as PUSH4 on every EVM-bytecode chain. zkSync Era runs EraVM bytecode, where that scan does not apply: there a real\n// deposit was traced instead (tx 0x21c702af…f0d96, `debug_traceTransaction` callTracer): a successful call into the\n// SpokePool with selector 0xad5425c6, 420 bytes (empty message), which emitted FundsDeposited.\n// - The contract: contracts/spoke-pools/SpokePool.sol and contracts/interfaces/V3SpokePoolInterface.sol at the same\n// commit (selectors, event, relay hash, fill statuses, the native-coin rules quoted where they are used).\n// - Tokens: Across's own route list (`GET /available-routes`) and token list (`GET /swap/tokens`), read 2026-11-14,\n// intersected with the SDK's asset catalog (`@anywalletkit/swap2-assets`) by address. A token is pinned only when\n// Across bridges it to the SAME asset on another pinned chain with the same decimals; routes Across lists between\n// different assets (USDC → USDC.e, USDC-BNB → USDC, USDT → USDC, USDG → USDC) are not served.\n//\n// Chains Across serves that are NOT pinned, and why:\n// - Scroll (534352): `pausedDeposits()` is true on chain (as on Lens, Mode and Zora, which the SDK does not carry) and\n// it is gone from Across's own chain page.\n// - BNB Chain (56): Across bridges its Binance-Peg USDC and USDT (18 decimals) only into other assets, and its ETH is an\n// ERC-20 the catalog does not list — no same-asset route is left.\n// - Lisk, Soneium, Tempo, Blast, Boba, Solana, Tron, HyperCore, Lighter: not EVM chains of the SDK's catalog.\n// SDK chains Across does not serve: Gnosis, Sonic, Berachain, Celo, Mantle, Katana, Morph, Flare, Elysium, Sei, Plume,\n// X Layer.\n\n/** What a token is across chains. A deposit only ever moves an asset to the same asset. */\nexport type AcrossAsset = \"USDC\" | \"USDT\" | \"ETH\" | \"WBTC\";\n\nexport interface AcrossToken {\n asset: AcrossAsset;\n /** ERC-20 contract on this chain, lowercase. */\n address: string;\n /** The catalog's symbol on this chain (Tether's USDT is `USDT0` where it is issued as USDT0). */\n symbol: string;\n decimals: number;\n}\n\nexport interface AcrossChain {\n caip2: string;\n chainId: number;\n /** The SDK's chain key (`@anywalletkit/swap2-assets`). */\n key: string;\n name: string;\n /** SpokePool proxy on that chain: the only contract a deposit calls and the only spender an approval names. */\n spokePool: string;\n /**\n * `wrappedNativeToken()` of that SpokePool. A deposit that sends the native coin names it as `inputToken`; a fill of\n * it is paid out as the native coin to an EOA. Null where the SpokePool reports the zero address (Arc).\n */\n wrappedNative: string | null;\n /** The chain's native coin is ether, bridged as the ETH asset. */\n nativeIsEth: boolean;\n /** ERC-20s Across bridges to the same asset on another pinned chain. ETH's ERC-20 is the wrapped native token. */\n tokens: readonly AcrossToken[];\n}\n\nconst USDC = (address: string, symbol = \"USDC\"): AcrossToken => Object.freeze({asset: \"USDC\", address, symbol, decimals: 6});\nconst USDT = (address: string, symbol = \"USDT\"): AcrossToken => Object.freeze({asset: \"USDT\", address, symbol, decimals: 6});\nconst WETH = (address: string): AcrossToken => Object.freeze({asset: \"ETH\", address, symbol: \"WETH\", decimals: 18});\nconst WBTC = (address: string): AcrossToken => Object.freeze({asset: \"WBTC\", address, symbol: \"WBTC\", decimals: 8});\n\n/** The OP-stack predeploy WETH9. */\nconst OP_WETH = \"0x4200000000000000000000000000000000000006\";\n\nfunction chain(\n chainId: number, key: string, name: string, spokePool: string, wrappedNative: string | null, nativeIsEth: boolean, tokens: AcrossToken[],\n): AcrossChain {\n return Object.freeze({caip2: `eip155:${chainId}`, chainId, key, name, spokePool, wrappedNative, nativeIsEth, tokens: Object.freeze(tokens)});\n}\n\n/** CAIP-2 → the chain as Across serves it. A null-prototype map: `ACROSS_CHAINS[\"constructor\"]` is undefined. */\nexport const ACROSS_CHAINS: Readonly<Record<string, AcrossChain>> = Object.freeze(Object.assign(Object.create(null) as Record<string, AcrossChain>, Object.fromEntries([\n chain(1, \"ethereum\", \"Ethereum\", \"0x5c7bcd6e7de5423a257d81b442095a1a6ced35c5\", \"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2\", true, [\n USDC(\"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48\"),\n USDT(\"0xdac17f958d2ee523a2206206994597c13d831ec7\"),\n WETH(\"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2\"),\n WBTC(\"0x2260fac5e5542a773aa44fbcfedf7c193bc2c599\"),\n ]),\n chain(10, \"optimism\", \"Optimism\", \"0x6f26bf09b1c792e3228e5467807a900a503c0281\", OP_WETH, true, [\n USDC(\"0x0b2c639c533813f4aa9d7837caf62653d097ff85\"),\n USDT(\"0x94b008aa00579c1307b0ef2c499ad98a8ce58e58\"),\n WETH(OP_WETH),\n ]),\n chain(130, \"unichain\", \"Unichain\", \"0x09aea4b2242abc8bb4bb78d537a67a245a7bec64\", OP_WETH, true, [\n USDC(\"0x078d782b760474a361dda0af3839290b0ef57ad6\"),\n USDT(\"0x9151434b16b9763660705744891fa906f660ecc5\", \"USDT0\"),\n WETH(OP_WETH),\n ]),\n chain(137, \"polygon\", \"Polygon\", \"0x9295ee1d8c5b022be115a2ad3c30c72e34e7f096\", \"0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270\", false, [\n USDC(\"0x3c499c542cef5e3811e1192ce70d8cc03d5c3359\"),\n USDT(\"0xc2132d05d31c914a87c6611c10748aeb04b58e8f\"),\n WBTC(\"0x1bfd67037b42cf73acf2047067bd4f2c47d9bfd6\"),\n ]),\n chain(143, \"monad\", \"Monad\", \"0xd2ecb3afe598b746f8123cae365a598da831a449\", \"0x3bd359c1119da7da1d913d1c4d2b7c461115433a\", false, [\n USDC(\"0x754704bc059f8c67012fed69bc8a327a5aafb603\"),\n USDT(\"0xe7cd86e13ac4309349f30b3435a9d337750fc82d\", \"USDT0\"),\n ]),\n chain(324, \"zksync\", \"zkSync Era\", \"0xe0b015e54d54fc84a6cb9b666099c46ade9335ff\", \"0x5aea5775959fbc2557cc8789bc1bf90a239d9a91\", true, [\n USDT(\"0x493257fd37edb34451f62edf8d2a0c418852ba4c\"),\n WETH(\"0x5aea5775959fbc2557cc8789bc1bf90a239d9a91\"),\n WBTC(\"0xbbeb516fb02a01611cbbe0453fe3c580d7281011\"),\n ]),\n chain(480, \"worldchain\", \"World Chain\", \"0x09aea4b2242abc8bb4bb78d537a67a245a7bec64\", OP_WETH, true, [\n USDC(\"0x79a02482a880bce3f13e09da970dc34db4cd24d1\"),\n WETH(OP_WETH),\n WBTC(\"0x03c7054bcb39f7b2e5b2c7acb37583e32d70cfa3\"),\n ]),\n chain(999, \"hyperevm\", \"HyperEVM\", \"0x35e63ea3eb0fb7a3bc543c71fb66412e1f6b0e04\", \"0x5555555555555555555555555555555555555555\", false, [\n USDC(\"0xb88339cb7199b77e23db6e890353e22632ba630f\"),\n USDT(\"0xb8ce59fc3717ada4c02eadf9682a9e934f625ebb\", \"USDT0\"),\n ]),\n chain(4326, \"megaeth\", \"MegaETH\", \"0x3db06da8f0a24a525f314eec954fc5c6a973d40e\", OP_WETH, true, [\n USDT(\"0xb8ce59fc3717ada4c02eadf9682a9e934f625ebb\", \"USDT0\"),\n WETH(OP_WETH),\n ]),\n chain(4663, \"robinhood\", \"Robinhood Chain\", \"0xd29c85f15df544ba632c9e25829fd29d767d7978\", \"0x0bd7d308f8e1639fab988df18a8011f41eacad73\", true, [\n WETH(\"0x0bd7d308f8e1639fab988df18a8011f41eacad73\"),\n ]),\n // Arc's gas coin is USDC; 0x3600… is its 6-decimal ERC-20 interface, which is what Across moves. The SpokePool\n // reports no wrapped native token, so no deposit or fill on Arc involves the native coin.\n chain(5042, \"arc\", \"Arc\", \"0x9b4a302a548c7e313c2b74c461db7b84d3074a84\", null, false, [\n USDC(\"0x3600000000000000000000000000000000000000\"),\n ]),\n chain(8453, \"base\", \"Base\", \"0x09aea4b2242abc8bb4bb78d537a67a245a7bec64\", OP_WETH, true, [\n USDC(\"0x833589fcd6edb6e08f4c7c32d4f71b54bda02913\"),\n USDT(\"0xfde4c96c8593536e31f229ea8f37b2ada2699bb2\"),\n WETH(OP_WETH),\n ]),\n chain(9745, \"plasma\", \"Plasma\", \"0x50039faefebef707cfd94d6d462fe6d10b39207a\", \"0x6100e367285b01f48d07953803a2d8dca5d19873\", false, [\n USDT(\"0xb8ce59fc3717ada4c02eadf9682a9e934f625ebb\", \"USDT0\"),\n ]),\n chain(42161, \"arbitrum\", \"Arbitrum\", \"0xe35e9842fceaca96570b734083f4a58e8f7c5f2a\", \"0x82af49447d8a07e3bd95bd0d56f35241523fbab1\", true, [\n USDC(\"0xaf88d065e77c8cc2239327c5edb3a432268e5831\"),\n USDT(\"0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9\", \"USDT0\"),\n WETH(\"0x82af49447d8a07e3bd95bd0d56f35241523fbab1\"),\n WBTC(\"0x2f2a2543b76a4166549f7aab2e75bef0aefc5b0f\"),\n ]),\n chain(43114, \"avalanche\", \"Avalanche\", \"0xfe9d541c92e4e90437c7152a00244886de37a658\", \"0xb31f66aa3c1e785363f0875a1b74e27b85fd66c7\", false, [\n USDC(\"0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e\"),\n USDT(\"0x9702230a8ea53601f5cd2dc00fdbc13d4df4a8c7\"),\n ]),\n chain(57073, \"ink\", \"Ink\", \"0xef684c38f94f48775959ecf2012d7e864ffb9dd4\", OP_WETH, true, [\n USDC(\"0x2d270e6886d130d724215a266106e6832161eaed\"),\n USDT(\"0x0200c29006150606b650577bbe7b6248f58470c1\", \"USDT0\"),\n WETH(OP_WETH),\n ]),\n chain(59144, \"linea\", \"Linea\", \"0x7e63a5f1a8f0b4d0934b2f2327daed3f6bb2ee75\", \"0xe5d7c2a44ffddf6b295a15c148167daaaf5cf34f\", true, [\n USDC(\"0x176211869ca2b568f2a7d4ee941e073a821ee1ff\"),\n USDT(\"0xa219439258ca9da29e9cc4ce5596924745e12b93\"),\n WETH(\"0xe5d7c2a44ffddf6b295a15c148167daaaf5cf34f\"),\n WBTC(\"0x3aab2285ddcddad8edf438c1bab47e1a9d05a9b4\"),\n ]),\n].map((x) => [x.caip2, x]))));\n\n/** The chain for a CAIP-2 id, or undefined — own keys only. */\nexport function acrossChain(caip2: string): AcrossChain | undefined {\n return typeof caip2 === \"string\" && Object.prototype.hasOwnProperty.call(ACROSS_CHAINS, caip2) ? ACROSS_CHAINS[caip2] : undefined;\n}\n\n/** The pinned token at `address` on `chain` (any casing), or undefined. */\nexport function acrossToken(chain: AcrossChain, address: string): AcrossToken | undefined {\n if (typeof address !== \"string\") return undefined;\n const a = address.toLowerCase();\n return chain.tokens.find((t) => t.address === a);\n}\n\n/**\n * The HubPool on Ethereum: `crossChainContracts(chainId)` is the registry every pinned SpokePool was checked against.\n * Not a proxy; owned by a 3-of-5 Safe that can re-point the registry and upgrade every SpokePool — a watched fact.\n */\nexport const ACROSS_HUB_POOL = \"0xc186fa914353c44b2e33ebe05f21846f1048beda\";\n/** `crossChainContracts(uint256)` on the HubPool → `(address adapter, address spokePool)`. */\nexport const ACROSS_HUB_CROSS_CHAIN_CONTRACTS = \"0x09474ae2\";\n\n/**\n * `deposit(bytes32 depositor, bytes32 recipient, bytes32 inputToken, bytes32 outputToken, uint256 inputAmount,\n * uint256 outputAmount, uint256 destinationChainId, bytes32 exclusiveRelayer, uint32 quoteTimestamp,\n * uint32 fillDeadline, uint32 exclusivityParameter, bytes message)` payable — the only call this module builds or signs.\n */\nexport const ACROSS_DEPOSIT = \"0xad5425c6\";\n/** `depositV3(address …)`: the address-typed wrapper of `deposit`. Read in history, never built or signed. */\nexport const ACROSS_DEPOSIT_V3 = \"0x7b939232\";\n/**\n * Calls on a SpokePool that are always refused: `unsafeDeposit` (a caller-chosen deposit id that can collide),\n * `depositNow` / `depositV3Now` (the fill deadline set on chain), `speedUpDeposit` / `speedUpV3Deposit` (a depositor\n * signature that lets a relayer pay another recipient or a lower amount), and `multicall`.\n */\nexport const ACROSS_REFUSED_SELECTORS: Readonly<Record<string, string>> = Object.freeze({\n \"0x8b15788e\": \"unsafeDeposit\",\n \"0xea86bd46\": \"depositNow\",\n \"0x7aef642c\": \"depositV3Now\",\n \"0xbabb6aac\": \"speedUpDeposit\",\n \"0x577f51f8\": \"speedUpV3Deposit\",\n \"0xac9650d8\": \"multicall\",\n});\n\n/**\n * `UpdateDepositDetails(uint256 depositId,uint256 originChainId,uint256 updatedOutputAmount,bytes32 updatedRecipient,\n * bytes updatedMessage)` under the domain `ACROSS-V2` / `1.0.0`: the speed-up signature. It can move a deposit's\n * output to another recipient, so nothing carrying this type (or that domain) is ever signed through this module.\n */\nexport const ACROSS_SPEED_UP_TYPEHASH = \"0x8d1994e2bbbd77564cdca06dd819e7ee2a5efa06c80dcb59a4a7b6e39edc538f\";\nexport const ACROSS_SPEED_UP_TYPE = \"UpdateDepositDetails\";\nexport const ACROSS_SPEED_UP_DOMAIN = \"ACROSS-V2\";\n\n/**\n * `FundsDeposited(bytes32 inputToken, bytes32 outputToken, uint256 inputAmount, uint256 outputAmount,\n * uint256 indexed destinationChainId, uint256 indexed depositId, uint32 quoteTimestamp, uint32 fillDeadline,\n * uint32 exclusivityDeadline, bytes32 indexed depositor, bytes32 recipient, bytes32 exclusiveRelayer, bytes message)`.\n */\nexport const ACROSS_FUNDS_DEPOSITED = \"0x32ed1a409ef04c7b0227189c3a103dc5ac10e775a15b785dcc510201f7c25ad3\";\n/** `fillStatuses(bytes32 relayHash)` → 0 unfilled, 1 slow fill requested, 2 filled. */\nexport const ACROSS_FILL_STATUSES = \"0xc35c83fc\";\n\n/**\n * `keccak256(\"AcrossV5MessagePrefix.V1\")`: a deposit message starting with these 32 bytes is an Across V5 witness,\n * consumable only through the Gateway's V5 fill entry points (SpokePool.sol `V5_MAGIC_PREFIX`). Refused by name —\n * this module signs empty messages only.\n */\nexport const ACROSS_V5_MESSAGE_PREFIX = \"0x89ae4bc75915265a3f10e926c3894a29534f1d6362ee8959cb0e5be00f3527fd\";\n\n/** `depositQuoteTimeBuffer()` on every pinned SpokePool: a deposit's `quoteTimestamp` may be at most this old. */\nexport const ACROSS_DEPOSIT_QUOTE_TIME_BUFFER_S = 3600;\n/** `fillDeadlineBuffer()` on every pinned SpokePool: a deposit's `fillDeadline` may be at most this far ahead. */\nexport const ACROSS_FILL_DEADLINE_BUFFER_S = 21_600;\n/** SpokePool `MAX_EXCLUSIVITY_PERIOD_SECONDS`: an `exclusivityParameter` up to this is an offset, above it a timestamp. */\nexport const ACROSS_MAX_EXCLUSIVITY_PERIOD_S = 31_536_000;\n\n/** The native coin in a request (and in Across's own token lists): twenty zero bytes. */\nexport const ACROSS_NATIVE = \"0x0000000000000000000000000000000000000000\";\n\n/** Across API V5: the price source (`api.ts`), with a key from dashboard.across.to kept on a server. */\nexport const ACROSS_API = \"https://api.across.to\";\n\nconst ZERO = /^0x0{40}$/;\nconst isNativeRef = (token: string): boolean => ZERO.test(token);\n\n/** One side of a route: the token as the deposit names it, and whether the user's side of it is the native coin. */\nexport interface AcrossRouteSide {\n chain: AcrossChain;\n /** The token the deposit names: the ERC-20, or the wrapped native token when `native`. */\n token: string;\n native: boolean;\n decimals: number;\n}\n\nexport interface AcrossRoute {\n asset: AcrossAsset;\n input: AcrossRouteSide;\n output: AcrossRouteSide;\n}\n\n/** Why a pair is not served, for a refusal. */\nexport interface AcrossRouteMiss {\n code: \"chain-unsupported\" | \"token-unsupported\" | \"pair-unsupported\" | \"native-unsupported\" | \"wrapped-native-destination\";\n detail: string;\n}\n\n/**\n * The route a request names, or why it is not served. `sourceToken` / `destToken` are contracts (any casing) or the\n * zero address for the native coin. Served: two different pinned chains, the same asset on both sides, the native coin\n * only where it is ether and the SpokePool wraps it, and never the wrapped native token as a destination ERC-20 — an\n * empty-message fill of it pays an EOA the native coin, which is not what was asked for.\n */\nexport function acrossRouteOf(sourceChain: string, sourceToken: string, destChain: string, destToken: string): AcrossRoute | AcrossRouteMiss {\n const src = acrossChain(sourceChain);\n const dst = acrossChain(destChain);\n if (!src) return {code: \"chain-unsupported\", detail: `source chain ${String(sourceChain)} is not a pinned Across chain`};\n if (!dst) return {code: \"chain-unsupported\", detail: `destination chain ${String(destChain)} is not a pinned Across chain`};\n if (src === dst) return {code: \"chain-unsupported\", detail: \"source and destination are the same chain\"};\n if (typeof sourceToken !== \"string\" || typeof destToken !== \"string\") return {code: \"token-unsupported\", detail: \"the tokens are not addresses\"};\n let input: AcrossRouteSide;\n let asset: AcrossAsset;\n if (isNativeRef(sourceToken)) {\n if (!src.nativeIsEth || !src.wrappedNative) return {code: \"native-unsupported\", detail: `${src.name}'s native coin is not bridged by Across`};\n input = {chain: src, token: src.wrappedNative, native: true, decimals: 18};\n asset = \"ETH\";\n } else {\n const t = acrossToken(src, sourceToken);\n if (!t) return {code: \"token-unsupported\", detail: `${sourceToken.toLowerCase()} is not a token pinned on ${src.name}`};\n input = {chain: src, token: t.address, native: false, decimals: t.decimals};\n asset = t.asset;\n }\n let output: AcrossRouteSide;\n if (isNativeRef(destToken)) {\n if (!dst.nativeIsEth || !dst.wrappedNative) return {code: \"native-unsupported\", detail: `${dst.name}'s native coin is not bridged by Across`};\n if (asset !== \"ETH\") return {code: \"pair-unsupported\", detail: `${asset} on ${src.name} is not bridged to ${dst.name}'s native coin`};\n output = {chain: dst, token: dst.wrappedNative, native: true, decimals: 18};\n } else {\n const t = acrossToken(dst, destToken);\n if (!t) return {code: \"token-unsupported\", detail: `${destToken.toLowerCase()} is not a token pinned on ${dst.name}`};\n if (dst.wrappedNative !== null && t.address === dst.wrappedNative) {\n return {code: \"wrapped-native-destination\", detail: `a fill of ${t.symbol} on ${dst.name} pays an EOA the native coin, not ${t.symbol} — ask for the native coin`};\n }\n if (t.asset !== asset) return {code: \"pair-unsupported\", detail: `${asset} is only bridged to ${asset}, not to ${t.symbol}`};\n output = {chain: dst, token: t.address, native: false, decimals: t.decimals};\n }\n if (input.decimals !== output.decimals) return {code: \"pair-unsupported\", detail: \"the two sides have different decimals\"};\n return {asset, input, output};\n}\n\nexport const across = {\n supportsChain(chain: string): boolean {\n return acrossChain(chain) !== undefined;\n },\n /** Two different pinned EVM chains. */\n supports(from: string, to: string): boolean {\n return from !== to && acrossChain(from) !== undefined && acrossChain(to) !== undefined;\n },\n};\n","import {withReason, type Swap2RefusalReason} from \"@anywalletkit/protocol-swap2-core/errors\";\n\n/** Why a request, a deposit, a quote or an API answer was refused. One code per check; the message says what was found. */\nexport type AcrossRefusalCode =\n | \"request-invalid\"\n | \"chain-unsupported\"\n | \"token-unsupported\"\n | \"pair-unsupported\"\n | \"native-unsupported\"\n | \"wrapped-native-destination\"\n | \"route-unpriced\"\n | \"quote-unavailable\"\n | \"quote-normalized\"\n | \"tx-shape\"\n | \"tx-chain\"\n | \"tx-target\"\n | \"tx-selector\"\n | \"tx-calldata\"\n | \"tx-depositor\"\n | \"tx-recipient\"\n | \"tx-input-token\"\n | \"tx-output-token\"\n | \"tx-input-amount\"\n | \"tx-output-amount\"\n | \"tx-fee\"\n | \"tx-destination\"\n | \"tx-message\"\n | \"tx-message-v5\"\n | \"tx-exclusivity\"\n | \"tx-quote-time\"\n | \"tx-fill-deadline\"\n | \"tx-value\"\n | \"tx-approval\"\n | \"speed-up\"\n | \"quote-shape\"\n | \"quote-amounts\"\n | \"quote-expiry\"\n | \"quote-gas\"\n | \"quote-intent\"\n | \"api-error\"\n | \"api-answer\"\n | \"relayer-price\";\n\n/**\n * `code` names the check; `reason` (a `Swap2RefusalReason` from `@anywalletkit/protocol-swap2-core`) is the stable\n * classification an app switches on. It is set where the refusal is raised, so one code can carry different reasons\n * (a fill deadline too far ahead is `policy_refused`, one already too close is `quote_expired`); a malformed request\n * from the caller (a programming error) carries none.\n */\nexport class AcrossRefusal extends Error {\n readonly code: AcrossRefusalCode;\n declare readonly reason?: Swap2RefusalReason;\n constructor(code: AcrossRefusalCode, detail: string, reason?: Swap2RefusalReason) {\n super(`across: ${detail} [${code}]`);\n this.name = \"AcrossRefusal\";\n this.code = code;\n if (reason !== undefined) withReason(this, reason);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAkBA,IAAAA,iBAA0E;AAC1E,kBAAuC;;;AC6CvC,IAAM,OAAO,CAAC,SAAiB,SAAS,WAAwB,OAAO,OAAO,EAAC,OAAO,QAAQ,SAAS,QAAQ,UAAU,EAAC,CAAC;AAC3H,IAAM,OAAO,CAAC,SAAiB,SAAS,WAAwB,OAAO,OAAO,EAAC,OAAO,QAAQ,SAAS,QAAQ,UAAU,EAAC,CAAC;AAC3H,IAAM,OAAO,CAAC,YAAiC,OAAO,OAAO,EAAC,OAAO,OAAO,SAAS,QAAQ,QAAQ,UAAU,GAAE,CAAC;AAClH,IAAM,OAAO,CAAC,YAAiC,OAAO,OAAO,EAAC,OAAO,QAAQ,SAAS,QAAQ,QAAQ,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|
1
|
+
import { Swap2RefusalReason, Swap2RefusalInfo } from '@anywalletkit/protocol-swap2-core/errors';
|
|
2
|
+
import { AcrossRoute } from './config.cjs';
|
|
3
|
+
import { AcrossRequest } from './verify.cjs';
|
|
4
|
+
import 'viem';
|
|
5
|
+
import '@anywalletkit/protocol-swap2-core/types';
|
|
6
|
+
import './deposit.cjs';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The two Across APIs this module reads — for NUMBERS only. Nothing either one answers is signed or executed: the
|
|
10
|
+
* deposit is encoded on the device from the pins and the user's request (`build.ts`) and verified (`verify.ts`).
|
|
11
|
+
*
|
|
12
|
+
* - **Across API V5** (`POST https://api.across.to/v1/quotes`, a key from dashboard.across.to, server-side only) is
|
|
13
|
+
* the price source. A V5 quote prices V5's own route — an execution step on the origin chain (Across's Gateway),
|
|
14
|
+
* sometimes another rail (CCTP, an OFT) — and funds it through `nextActions` that pay an escrow keyed by an order
|
|
15
|
+
* id the device cannot open (the recipient, the destination and the floor are not in anything it would sign). So
|
|
16
|
+
* `nextActions`, `orderId`, `minAmount` and the attestation are never read: only the fee, its gas legs, the fill
|
|
17
|
+
* estimate and the USD prices, each read strictly ({@link readAcrossV5Quote}).
|
|
18
|
+
* - **`/suggested-fees`** (`GET https://app.across.to/api/suggested-fees`, keyless, the Across app's own relayer-fee
|
|
19
|
+
* quote — Across calls it legacy) is the independent statement of what an Across relayer needs to fill a plain
|
|
20
|
+
* SpokePool deposit, and the `timestamp` its LP fee was priced at ({@link readAcrossSuggestedFees}).
|
|
21
|
+
*
|
|
22
|
+
* `pricing.ts` turns the two into the deposit's numbers. Sources: Across's V5 integration skills
|
|
23
|
+
* (github.com/across-protocol/skills @ f4d425e6, `quote-and-execute`, `security`) and real answers of both APIs
|
|
24
|
+
* recorded 2026-11-15 (fixtures/api).
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
/** The V5 base (`ACROSS_API` + `/v1`). */
|
|
28
|
+
declare const ACROSS_API_V1 = "https://api.across.to/v1";
|
|
29
|
+
/** Across's keyless relayer-fee quote (the Across app's own `/suggested-fees`). */
|
|
30
|
+
declare const ACROSS_SUGGESTED_FEES_URL = "https://app.across.to/api/suggested-fees";
|
|
31
|
+
/**
|
|
32
|
+
* `maxFee.bps` sent with every V5 quote request: the widest V5 takes. It only bounds V5's own guaranteed minimum,
|
|
33
|
+
* which is never used here (V5's estimate does not move with it: 24 962 036 / 24 962 140 / 24 963 399 base units for
|
|
34
|
+
* the same 25 USDC at three caps, 2026-11-14); at 1000 V5 refused Ethereum-origin transfers under ~$16.5–19 because
|
|
35
|
+
* its own origin gas alone was over the cap. The user's own cap is held on the deposit, by the verifier.
|
|
36
|
+
*/
|
|
37
|
+
declare const ACROSS_V5_PRICING_MAX_FEE_BPS = 5000;
|
|
38
|
+
interface AcrossV5Token {
|
|
39
|
+
chainId: number;
|
|
40
|
+
address: string;
|
|
41
|
+
}
|
|
42
|
+
/** `POST /v1/quotes` body, exactly the fields this module sends (the API refuses any field it does not know). */
|
|
43
|
+
interface AcrossV5QuoteRequest {
|
|
44
|
+
origin: {
|
|
45
|
+
token: AcrossV5Token;
|
|
46
|
+
depositor: string;
|
|
47
|
+
amount: string;
|
|
48
|
+
};
|
|
49
|
+
destination: {
|
|
50
|
+
token: AcrossV5Token;
|
|
51
|
+
recipient: string;
|
|
52
|
+
};
|
|
53
|
+
amountType: "exact_input";
|
|
54
|
+
/** What the client can do: approve a token and send a transaction on an EVM chain. No typed data, no submissions. */
|
|
55
|
+
capabilities: {
|
|
56
|
+
operations: readonly {
|
|
57
|
+
kind: "approve_token" | "send_transaction";
|
|
58
|
+
ecosystem: "evm";
|
|
59
|
+
}[];
|
|
60
|
+
};
|
|
61
|
+
/** An approval of exactly the funded amount — never `infinite`. */
|
|
62
|
+
authorizationPolicy: {
|
|
63
|
+
allowedTypes: readonly ["approval"];
|
|
64
|
+
approvalAmount: "exact";
|
|
65
|
+
};
|
|
66
|
+
/** {@link ACROSS_V5_PRICING_MAX_FEE_BPS}. */
|
|
67
|
+
maxFee: {
|
|
68
|
+
bps: number;
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* The `POST /v1/quotes` body for a request. Pure. Native ETH is the zero address on both sides, as V5 names it; the
|
|
73
|
+
* funding is the plain approval flow (`approve_token` + `send_transaction`, exact amount) — the one whose price was
|
|
74
|
+
* studied; nothing it returns is executed.
|
|
75
|
+
*/
|
|
76
|
+
declare function acrossV5QuoteRequest(request: AcrossRequest): AcrossV5QuoteRequest;
|
|
77
|
+
/**
|
|
78
|
+
* A USD amount as base units of a token priced at `priceUsd`, rounded down — integer math only (no `Number` of a big
|
|
79
|
+
* value): `amountUsd × 10^decimals / priceUsd`. Null when either is not a usable number.
|
|
80
|
+
*/
|
|
81
|
+
declare function acrossUsdToUnits(amountUsd: unknown, priceUsd: unknown, decimals: number): bigint | null;
|
|
82
|
+
/** What a V5 quote says that the pricing rule reads — every amount in base units of the input token. */
|
|
83
|
+
interface AcrossV5Price {
|
|
84
|
+
/** `fee.totalFee.amount`: input − `destination.amount` (checked to add up). */
|
|
85
|
+
totalFee: bigint;
|
|
86
|
+
/** V5's estimate of what arrives (`destination.amount`). */
|
|
87
|
+
destinationAmount: bigint;
|
|
88
|
+
/**
|
|
89
|
+
* Σ `gasEstimates[leg = "origin", effect = "included_in_transfer_fee"]`: V5's own execution step on the origin
|
|
90
|
+
* chain, charged inside its fee. Exact wei on an ETH route; a token route converts its USD figure at the
|
|
91
|
+
* destination token's price, rounded down. A leg that cannot be read adds nothing (the fee stays higher).
|
|
92
|
+
*/
|
|
93
|
+
originGas: bigint;
|
|
94
|
+
/** Σ `gasEstimates[leg = "destination", effect = "included_in_transfer_fee"]`, converted alike; null when a leg cannot be. */
|
|
95
|
+
destinationGas: bigint | null;
|
|
96
|
+
/** `expectedFillTimeMs`. Over a minute it is not an Across relayer fill: V5 prices another rail (`acrossV5OtherRail`). */
|
|
97
|
+
expectedFillTimeMs: number;
|
|
98
|
+
/** `origin.amountUsd`, when given: the transfer's size in dollars (the floor curve for ETH from an L2 is by size). */
|
|
99
|
+
amountUsd?: number;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* A V5 quote answer, read strictly against the request it was asked for. Throws {@link AcrossRefusal} `api-answer`:
|
|
103
|
+
* `policy_refused` for an answer about another transfer (tokens, chains, amount, an app fee nobody asked for),
|
|
104
|
+
* `upstream_unavailable` for one that does not read or does not add up. `nextActions`, `orderId`, `minAmount` and any
|
|
105
|
+
* attestation are not read.
|
|
106
|
+
*/
|
|
107
|
+
declare function readAcrossV5Quote(request: AcrossRequest, route: AcrossRoute, body: unknown): AcrossV5Price;
|
|
108
|
+
/** What `/suggested-fees` answered, as the pricing rule reads it. */
|
|
109
|
+
type AcrossSuggestedFees =
|
|
110
|
+
/** A relayer fee for this exact deposit. */
|
|
111
|
+
{
|
|
112
|
+
kind: "fees";
|
|
113
|
+
totalRelayFee: bigint;
|
|
114
|
+
timestamp: number;
|
|
115
|
+
estimatedFillTimeSec: number;
|
|
116
|
+
}
|
|
117
|
+
/** Across says relayers will not take this deposit (too small, too large, the route not enabled): refuse. */
|
|
118
|
+
| {
|
|
119
|
+
kind: "refused";
|
|
120
|
+
detail: string;
|
|
121
|
+
reason: Swap2RefusalReason;
|
|
122
|
+
}
|
|
123
|
+
/** No usable answer (unreachable, another shape, stale): the pinned floor stands in. */
|
|
124
|
+
| {
|
|
125
|
+
kind: "unavailable";
|
|
126
|
+
detail: string;
|
|
127
|
+
};
|
|
128
|
+
/** The `/suggested-fees` query for a request: the deposit's own tokens (the wrapped native token for ETH) and recipient. */
|
|
129
|
+
declare function acrossSuggestedFeesQuery(request: AcrossRequest, route: AcrossRoute): string;
|
|
130
|
+
/**
|
|
131
|
+
* How old a `/suggested-fees` timestamp may be (s). It becomes the deposit's quote time, so it is never taken from
|
|
132
|
+
* ahead of the reader's clock: the SpokePool reverts a quote time ahead of its block, and Across's are HubPool block
|
|
133
|
+
* times minutes in the past (217–245 s on every recorded answer).
|
|
134
|
+
*/
|
|
135
|
+
declare const ACROSS_SUGGESTED_FEES_MAX_AGE_S = 600;
|
|
136
|
+
declare const ACROSS_SUGGESTED_FEES_MAX_AHEAD_S = 0;
|
|
137
|
+
/**
|
|
138
|
+
* A `/suggested-fees` answer for a request, at `nowS`. Across's own refusals of the deposit — any 400 it answers
|
|
139
|
+
* (`AMOUNT_TOO_LOW`, `AMOUNT_TOO_HIGH`, `ROUTE_NOT_ENABLED`, `INVALID_PARAM` for a token or a chain it does not serve,
|
|
140
|
+
* or a code this module does not know), `isAmountTooLow`, an amount outside `limits` — and a SpokePool other than the
|
|
141
|
+
* pinned one are `refused`; no answer, another status, or one that is not a clean, consistent, fresh answer is
|
|
142
|
+
* `unavailable` (the pinned floor may then stand in).
|
|
143
|
+
*/
|
|
144
|
+
declare function readAcrossSuggestedFees(request: AcrossRequest, route: AcrossRoute, status: number, body: unknown, nowS: number): AcrossSuggestedFees;
|
|
145
|
+
/** A V5 error answer, read from either envelope, with its classification. */
|
|
146
|
+
interface AcrossV5Error {
|
|
147
|
+
/** HTTP status of the answer. */
|
|
148
|
+
status: number;
|
|
149
|
+
/** `error.code`, else the top-level `code` (`unauthenticated`, `policy.amount_out_of_range`, …). */
|
|
150
|
+
code?: string;
|
|
151
|
+
/** `error.type` (nested envelope only). */
|
|
152
|
+
type?: string;
|
|
153
|
+
message?: string;
|
|
154
|
+
/** The field the error names (`error.param`). */
|
|
155
|
+
param?: string;
|
|
156
|
+
/** Across's id for the request, for support (`error.requestId`). */
|
|
157
|
+
requestId?: string;
|
|
158
|
+
/** `error.details.amountLimits`: which bound the amount crossed and where it lies, base units of the input token. */
|
|
159
|
+
amountLimit?: {
|
|
160
|
+
side: "min" | "max";
|
|
161
|
+
amount?: string;
|
|
162
|
+
};
|
|
163
|
+
/** The CS-13 classification; undefined when neither the code nor the status says what it is. */
|
|
164
|
+
info?: Swap2RefusalInfo;
|
|
165
|
+
/**
|
|
166
|
+
* `409 conflict.submission_state_unknown`: the execution's outcome is unknown — retry the SAME request with backoff,
|
|
167
|
+
* never quote again (a new quote could fund the transfer twice). Quoting never meets it; kept for completeness.
|
|
168
|
+
*/
|
|
169
|
+
retrySameRequest: boolean;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Read a non-2xx V5 answer: the two envelopes Across uses — flat `{code, message, details}` (the gateway's 401) and
|
|
173
|
+
* nested `{error: {type, code, message, param, requestId, details}}` — and its CS-13 classification. A 429 is
|
|
174
|
+
* `rate_limited` with its Retry-After first; then the code (with `details.amountLimits.side` for
|
|
175
|
+
* `policy.amount_out_of_range`); then the status (401 / 403 → `key_rejected`, 408 / 425 / 5xx →
|
|
176
|
+
* `upstream_unavailable`); a JSON refusal neither names is a quote the API does not have (`no_route`).
|
|
177
|
+
*/
|
|
178
|
+
declare function parseAcrossV5Error(status: number, body: unknown, retryAfter?: string | null, nowMs?: number): AcrossV5Error;
|
|
179
|
+
/** An API URL, trailing slashes trimmed; throws a plain `Error` unless https (or http on this machine). */
|
|
180
|
+
declare function acrossApiUrl(url: string, what: string): string;
|
|
181
|
+
/** `scheme://host[:port]` of a URL, lowercase; "" when it has none. No URL class: React Native's lacks `origin`. */
|
|
182
|
+
declare const acrossOriginOf: (url: string) => string;
|
|
183
|
+
/** An answer as read: status, parsed body (undefined when not JSON), Retry-After. */
|
|
184
|
+
interface AcrossHttpAnswer {
|
|
185
|
+
status: number;
|
|
186
|
+
body: unknown;
|
|
187
|
+
retryAfter: string | null;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* One request to an Across API, bounded by `timeoutMs` (and the caller's signal). An answer that came through a
|
|
191
|
+
* redirect, or from another origin than the URL's, is refused (`policy_refused`) — a key header must not follow one,
|
|
192
|
+
* and React Native's fetch follows redirects whatever `redirect` says. Throws {@link AcrossRefusal} `api-answer` for a
|
|
193
|
+
* redirect, an answer larger than any quote, or no answer (`upstream_unavailable`; unclassified when the caller's own
|
|
194
|
+
* signal fired).
|
|
195
|
+
*/
|
|
196
|
+
declare function acrossHttp(url: string, init: {
|
|
197
|
+
method: "GET" | "POST";
|
|
198
|
+
headers: Record<string, string>;
|
|
199
|
+
body?: string;
|
|
200
|
+
}, opts: {
|
|
201
|
+
fetchImpl?: typeof fetch | undefined;
|
|
202
|
+
timeoutMs: number;
|
|
203
|
+
signal?: AbortSignal | undefined;
|
|
204
|
+
what: string;
|
|
205
|
+
}): Promise<AcrossHttpAnswer>;
|
|
206
|
+
|
|
207
|
+
export { ACROSS_API_V1, ACROSS_SUGGESTED_FEES_MAX_AGE_S, ACROSS_SUGGESTED_FEES_MAX_AHEAD_S, ACROSS_SUGGESTED_FEES_URL, ACROSS_V5_PRICING_MAX_FEE_BPS, type AcrossHttpAnswer, type AcrossSuggestedFees, type AcrossV5Error, type AcrossV5Price, type AcrossV5QuoteRequest, type AcrossV5Token, acrossApiUrl, acrossHttp, acrossOriginOf, acrossSuggestedFeesQuery, acrossUsdToUnits, acrossV5QuoteRequest, parseAcrossV5Error, readAcrossSuggestedFees, readAcrossV5Quote };
|
package/dist/api.d.ts
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { Swap2RefusalReason, Swap2RefusalInfo } from '@anywalletkit/protocol-swap2-core/errors';
|
|
2
|
+
import { AcrossRoute } from './config.js';
|
|
3
|
+
import { AcrossRequest } from './verify.js';
|
|
4
|
+
import 'viem';
|
|
5
|
+
import '@anywalletkit/protocol-swap2-core/types';
|
|
6
|
+
import './deposit.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The two Across APIs this module reads — for NUMBERS only. Nothing either one answers is signed or executed: the
|
|
10
|
+
* deposit is encoded on the device from the pins and the user's request (`build.ts`) and verified (`verify.ts`).
|
|
11
|
+
*
|
|
12
|
+
* - **Across API V5** (`POST https://api.across.to/v1/quotes`, a key from dashboard.across.to, server-side only) is
|
|
13
|
+
* the price source. A V5 quote prices V5's own route — an execution step on the origin chain (Across's Gateway),
|
|
14
|
+
* sometimes another rail (CCTP, an OFT) — and funds it through `nextActions` that pay an escrow keyed by an order
|
|
15
|
+
* id the device cannot open (the recipient, the destination and the floor are not in anything it would sign). So
|
|
16
|
+
* `nextActions`, `orderId`, `minAmount` and the attestation are never read: only the fee, its gas legs, the fill
|
|
17
|
+
* estimate and the USD prices, each read strictly ({@link readAcrossV5Quote}).
|
|
18
|
+
* - **`/suggested-fees`** (`GET https://app.across.to/api/suggested-fees`, keyless, the Across app's own relayer-fee
|
|
19
|
+
* quote — Across calls it legacy) is the independent statement of what an Across relayer needs to fill a plain
|
|
20
|
+
* SpokePool deposit, and the `timestamp` its LP fee was priced at ({@link readAcrossSuggestedFees}).
|
|
21
|
+
*
|
|
22
|
+
* `pricing.ts` turns the two into the deposit's numbers. Sources: Across's V5 integration skills
|
|
23
|
+
* (github.com/across-protocol/skills @ f4d425e6, `quote-and-execute`, `security`) and real answers of both APIs
|
|
24
|
+
* recorded 2026-11-15 (fixtures/api).
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
/** The V5 base (`ACROSS_API` + `/v1`). */
|
|
28
|
+
declare const ACROSS_API_V1 = "https://api.across.to/v1";
|
|
29
|
+
/** Across's keyless relayer-fee quote (the Across app's own `/suggested-fees`). */
|
|
30
|
+
declare const ACROSS_SUGGESTED_FEES_URL = "https://app.across.to/api/suggested-fees";
|
|
31
|
+
/**
|
|
32
|
+
* `maxFee.bps` sent with every V5 quote request: the widest V5 takes. It only bounds V5's own guaranteed minimum,
|
|
33
|
+
* which is never used here (V5's estimate does not move with it: 24 962 036 / 24 962 140 / 24 963 399 base units for
|
|
34
|
+
* the same 25 USDC at three caps, 2026-11-14); at 1000 V5 refused Ethereum-origin transfers under ~$16.5–19 because
|
|
35
|
+
* its own origin gas alone was over the cap. The user's own cap is held on the deposit, by the verifier.
|
|
36
|
+
*/
|
|
37
|
+
declare const ACROSS_V5_PRICING_MAX_FEE_BPS = 5000;
|
|
38
|
+
interface AcrossV5Token {
|
|
39
|
+
chainId: number;
|
|
40
|
+
address: string;
|
|
41
|
+
}
|
|
42
|
+
/** `POST /v1/quotes` body, exactly the fields this module sends (the API refuses any field it does not know). */
|
|
43
|
+
interface AcrossV5QuoteRequest {
|
|
44
|
+
origin: {
|
|
45
|
+
token: AcrossV5Token;
|
|
46
|
+
depositor: string;
|
|
47
|
+
amount: string;
|
|
48
|
+
};
|
|
49
|
+
destination: {
|
|
50
|
+
token: AcrossV5Token;
|
|
51
|
+
recipient: string;
|
|
52
|
+
};
|
|
53
|
+
amountType: "exact_input";
|
|
54
|
+
/** What the client can do: approve a token and send a transaction on an EVM chain. No typed data, no submissions. */
|
|
55
|
+
capabilities: {
|
|
56
|
+
operations: readonly {
|
|
57
|
+
kind: "approve_token" | "send_transaction";
|
|
58
|
+
ecosystem: "evm";
|
|
59
|
+
}[];
|
|
60
|
+
};
|
|
61
|
+
/** An approval of exactly the funded amount — never `infinite`. */
|
|
62
|
+
authorizationPolicy: {
|
|
63
|
+
allowedTypes: readonly ["approval"];
|
|
64
|
+
approvalAmount: "exact";
|
|
65
|
+
};
|
|
66
|
+
/** {@link ACROSS_V5_PRICING_MAX_FEE_BPS}. */
|
|
67
|
+
maxFee: {
|
|
68
|
+
bps: number;
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* The `POST /v1/quotes` body for a request. Pure. Native ETH is the zero address on both sides, as V5 names it; the
|
|
73
|
+
* funding is the plain approval flow (`approve_token` + `send_transaction`, exact amount) — the one whose price was
|
|
74
|
+
* studied; nothing it returns is executed.
|
|
75
|
+
*/
|
|
76
|
+
declare function acrossV5QuoteRequest(request: AcrossRequest): AcrossV5QuoteRequest;
|
|
77
|
+
/**
|
|
78
|
+
* A USD amount as base units of a token priced at `priceUsd`, rounded down — integer math only (no `Number` of a big
|
|
79
|
+
* value): `amountUsd × 10^decimals / priceUsd`. Null when either is not a usable number.
|
|
80
|
+
*/
|
|
81
|
+
declare function acrossUsdToUnits(amountUsd: unknown, priceUsd: unknown, decimals: number): bigint | null;
|
|
82
|
+
/** What a V5 quote says that the pricing rule reads — every amount in base units of the input token. */
|
|
83
|
+
interface AcrossV5Price {
|
|
84
|
+
/** `fee.totalFee.amount`: input − `destination.amount` (checked to add up). */
|
|
85
|
+
totalFee: bigint;
|
|
86
|
+
/** V5's estimate of what arrives (`destination.amount`). */
|
|
87
|
+
destinationAmount: bigint;
|
|
88
|
+
/**
|
|
89
|
+
* Σ `gasEstimates[leg = "origin", effect = "included_in_transfer_fee"]`: V5's own execution step on the origin
|
|
90
|
+
* chain, charged inside its fee. Exact wei on an ETH route; a token route converts its USD figure at the
|
|
91
|
+
* destination token's price, rounded down. A leg that cannot be read adds nothing (the fee stays higher).
|
|
92
|
+
*/
|
|
93
|
+
originGas: bigint;
|
|
94
|
+
/** Σ `gasEstimates[leg = "destination", effect = "included_in_transfer_fee"]`, converted alike; null when a leg cannot be. */
|
|
95
|
+
destinationGas: bigint | null;
|
|
96
|
+
/** `expectedFillTimeMs`. Over a minute it is not an Across relayer fill: V5 prices another rail (`acrossV5OtherRail`). */
|
|
97
|
+
expectedFillTimeMs: number;
|
|
98
|
+
/** `origin.amountUsd`, when given: the transfer's size in dollars (the floor curve for ETH from an L2 is by size). */
|
|
99
|
+
amountUsd?: number;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* A V5 quote answer, read strictly against the request it was asked for. Throws {@link AcrossRefusal} `api-answer`:
|
|
103
|
+
* `policy_refused` for an answer about another transfer (tokens, chains, amount, an app fee nobody asked for),
|
|
104
|
+
* `upstream_unavailable` for one that does not read or does not add up. `nextActions`, `orderId`, `minAmount` and any
|
|
105
|
+
* attestation are not read.
|
|
106
|
+
*/
|
|
107
|
+
declare function readAcrossV5Quote(request: AcrossRequest, route: AcrossRoute, body: unknown): AcrossV5Price;
|
|
108
|
+
/** What `/suggested-fees` answered, as the pricing rule reads it. */
|
|
109
|
+
type AcrossSuggestedFees =
|
|
110
|
+
/** A relayer fee for this exact deposit. */
|
|
111
|
+
{
|
|
112
|
+
kind: "fees";
|
|
113
|
+
totalRelayFee: bigint;
|
|
114
|
+
timestamp: number;
|
|
115
|
+
estimatedFillTimeSec: number;
|
|
116
|
+
}
|
|
117
|
+
/** Across says relayers will not take this deposit (too small, too large, the route not enabled): refuse. */
|
|
118
|
+
| {
|
|
119
|
+
kind: "refused";
|
|
120
|
+
detail: string;
|
|
121
|
+
reason: Swap2RefusalReason;
|
|
122
|
+
}
|
|
123
|
+
/** No usable answer (unreachable, another shape, stale): the pinned floor stands in. */
|
|
124
|
+
| {
|
|
125
|
+
kind: "unavailable";
|
|
126
|
+
detail: string;
|
|
127
|
+
};
|
|
128
|
+
/** The `/suggested-fees` query for a request: the deposit's own tokens (the wrapped native token for ETH) and recipient. */
|
|
129
|
+
declare function acrossSuggestedFeesQuery(request: AcrossRequest, route: AcrossRoute): string;
|
|
130
|
+
/**
|
|
131
|
+
* How old a `/suggested-fees` timestamp may be (s). It becomes the deposit's quote time, so it is never taken from
|
|
132
|
+
* ahead of the reader's clock: the SpokePool reverts a quote time ahead of its block, and Across's are HubPool block
|
|
133
|
+
* times minutes in the past (217–245 s on every recorded answer).
|
|
134
|
+
*/
|
|
135
|
+
declare const ACROSS_SUGGESTED_FEES_MAX_AGE_S = 600;
|
|
136
|
+
declare const ACROSS_SUGGESTED_FEES_MAX_AHEAD_S = 0;
|
|
137
|
+
/**
|
|
138
|
+
* A `/suggested-fees` answer for a request, at `nowS`. Across's own refusals of the deposit — any 400 it answers
|
|
139
|
+
* (`AMOUNT_TOO_LOW`, `AMOUNT_TOO_HIGH`, `ROUTE_NOT_ENABLED`, `INVALID_PARAM` for a token or a chain it does not serve,
|
|
140
|
+
* or a code this module does not know), `isAmountTooLow`, an amount outside `limits` — and a SpokePool other than the
|
|
141
|
+
* pinned one are `refused`; no answer, another status, or one that is not a clean, consistent, fresh answer is
|
|
142
|
+
* `unavailable` (the pinned floor may then stand in).
|
|
143
|
+
*/
|
|
144
|
+
declare function readAcrossSuggestedFees(request: AcrossRequest, route: AcrossRoute, status: number, body: unknown, nowS: number): AcrossSuggestedFees;
|
|
145
|
+
/** A V5 error answer, read from either envelope, with its classification. */
|
|
146
|
+
interface AcrossV5Error {
|
|
147
|
+
/** HTTP status of the answer. */
|
|
148
|
+
status: number;
|
|
149
|
+
/** `error.code`, else the top-level `code` (`unauthenticated`, `policy.amount_out_of_range`, …). */
|
|
150
|
+
code?: string;
|
|
151
|
+
/** `error.type` (nested envelope only). */
|
|
152
|
+
type?: string;
|
|
153
|
+
message?: string;
|
|
154
|
+
/** The field the error names (`error.param`). */
|
|
155
|
+
param?: string;
|
|
156
|
+
/** Across's id for the request, for support (`error.requestId`). */
|
|
157
|
+
requestId?: string;
|
|
158
|
+
/** `error.details.amountLimits`: which bound the amount crossed and where it lies, base units of the input token. */
|
|
159
|
+
amountLimit?: {
|
|
160
|
+
side: "min" | "max";
|
|
161
|
+
amount?: string;
|
|
162
|
+
};
|
|
163
|
+
/** The CS-13 classification; undefined when neither the code nor the status says what it is. */
|
|
164
|
+
info?: Swap2RefusalInfo;
|
|
165
|
+
/**
|
|
166
|
+
* `409 conflict.submission_state_unknown`: the execution's outcome is unknown — retry the SAME request with backoff,
|
|
167
|
+
* never quote again (a new quote could fund the transfer twice). Quoting never meets it; kept for completeness.
|
|
168
|
+
*/
|
|
169
|
+
retrySameRequest: boolean;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Read a non-2xx V5 answer: the two envelopes Across uses — flat `{code, message, details}` (the gateway's 401) and
|
|
173
|
+
* nested `{error: {type, code, message, param, requestId, details}}` — and its CS-13 classification. A 429 is
|
|
174
|
+
* `rate_limited` with its Retry-After first; then the code (with `details.amountLimits.side` for
|
|
175
|
+
* `policy.amount_out_of_range`); then the status (401 / 403 → `key_rejected`, 408 / 425 / 5xx →
|
|
176
|
+
* `upstream_unavailable`); a JSON refusal neither names is a quote the API does not have (`no_route`).
|
|
177
|
+
*/
|
|
178
|
+
declare function parseAcrossV5Error(status: number, body: unknown, retryAfter?: string | null, nowMs?: number): AcrossV5Error;
|
|
179
|
+
/** An API URL, trailing slashes trimmed; throws a plain `Error` unless https (or http on this machine). */
|
|
180
|
+
declare function acrossApiUrl(url: string, what: string): string;
|
|
181
|
+
/** `scheme://host[:port]` of a URL, lowercase; "" when it has none. No URL class: React Native's lacks `origin`. */
|
|
182
|
+
declare const acrossOriginOf: (url: string) => string;
|
|
183
|
+
/** An answer as read: status, parsed body (undefined when not JSON), Retry-After. */
|
|
184
|
+
interface AcrossHttpAnswer {
|
|
185
|
+
status: number;
|
|
186
|
+
body: unknown;
|
|
187
|
+
retryAfter: string | null;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* One request to an Across API, bounded by `timeoutMs` (and the caller's signal). An answer that came through a
|
|
191
|
+
* redirect, or from another origin than the URL's, is refused (`policy_refused`) — a key header must not follow one,
|
|
192
|
+
* and React Native's fetch follows redirects whatever `redirect` says. Throws {@link AcrossRefusal} `api-answer` for a
|
|
193
|
+
* redirect, an answer larger than any quote, or no answer (`upstream_unavailable`; unclassified when the caller's own
|
|
194
|
+
* signal fired).
|
|
195
|
+
*/
|
|
196
|
+
declare function acrossHttp(url: string, init: {
|
|
197
|
+
method: "GET" | "POST";
|
|
198
|
+
headers: Record<string, string>;
|
|
199
|
+
body?: string;
|
|
200
|
+
}, opts: {
|
|
201
|
+
fetchImpl?: typeof fetch | undefined;
|
|
202
|
+
timeoutMs: number;
|
|
203
|
+
signal?: AbortSignal | undefined;
|
|
204
|
+
what: string;
|
|
205
|
+
}): Promise<AcrossHttpAnswer>;
|
|
206
|
+
|
|
207
|
+
export { ACROSS_API_V1, ACROSS_SUGGESTED_FEES_MAX_AGE_S, ACROSS_SUGGESTED_FEES_MAX_AHEAD_S, ACROSS_SUGGESTED_FEES_URL, ACROSS_V5_PRICING_MAX_FEE_BPS, type AcrossHttpAnswer, type AcrossSuggestedFees, type AcrossV5Error, type AcrossV5Price, type AcrossV5QuoteRequest, type AcrossV5Token, acrossApiUrl, acrossHttp, acrossOriginOf, acrossSuggestedFeesQuery, acrossUsdToUnits, acrossV5QuoteRequest, parseAcrossV5Error, readAcrossSuggestedFees, readAcrossV5Quote };
|
package/dist/api.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ACROSS_API_V1,
|
|
3
|
+
ACROSS_SUGGESTED_FEES_MAX_AGE_S,
|
|
4
|
+
ACROSS_SUGGESTED_FEES_MAX_AHEAD_S,
|
|
5
|
+
ACROSS_SUGGESTED_FEES_URL,
|
|
6
|
+
ACROSS_V5_PRICING_MAX_FEE_BPS,
|
|
7
|
+
acrossApiUrl,
|
|
8
|
+
acrossHttp,
|
|
9
|
+
acrossOriginOf,
|
|
10
|
+
acrossSuggestedFeesQuery,
|
|
11
|
+
acrossUsdToUnits,
|
|
12
|
+
acrossV5QuoteRequest,
|
|
13
|
+
parseAcrossV5Error,
|
|
14
|
+
readAcrossSuggestedFees,
|
|
15
|
+
readAcrossV5Quote
|
|
16
|
+
} from "./chunk-YGNP7KPL.js";
|
|
17
|
+
import "./chunk-GX67FRPG.js";
|
|
18
|
+
import "./chunk-E5WFOPN2.js";
|
|
19
|
+
export {
|
|
20
|
+
ACROSS_API_V1,
|
|
21
|
+
ACROSS_SUGGESTED_FEES_MAX_AGE_S,
|
|
22
|
+
ACROSS_SUGGESTED_FEES_MAX_AHEAD_S,
|
|
23
|
+
ACROSS_SUGGESTED_FEES_URL,
|
|
24
|
+
ACROSS_V5_PRICING_MAX_FEE_BPS,
|
|
25
|
+
acrossApiUrl,
|
|
26
|
+
acrossHttp,
|
|
27
|
+
acrossOriginOf,
|
|
28
|
+
acrossSuggestedFeesQuery,
|
|
29
|
+
acrossUsdToUnits,
|
|
30
|
+
acrossV5QuoteRequest,
|
|
31
|
+
parseAcrossV5Error,
|
|
32
|
+
readAcrossSuggestedFees,
|
|
33
|
+
readAcrossV5Quote
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=api.js.map
|
package/dist/api.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|