From c09d8bea242bfbc5b373ba090c1c2d9ec4a1165d Mon Sep 17 00:00:00 2001
From: That guy <120946193+ezedike-evan@users.noreply.github.com>
Date: Thu, 26 Nov 2026 11:28:56 +0100
Subject: [PATCH 1/7] Fee table per route, with a capped rebalance price for
named market makers (#303)
* Fee table per route, with a capped rebalance price for market makers (#297)
Off-contract routes (EVM, Solana, Sui and Aptos sources) now price Xebra's
fee from one table in the SDK core (FEE_TABLE) through one pure function,
priceFee, used by both /v1 (quote and build) and the page's build routes.
Rules match on product, API key, source and destination domain; the most
specific wins. The default rule is today's 0.01% + 0.01 USDC, unchanged.
A rebalance with a valid API key is priced at 0.01% capped at 2 USDC a
move, plus 0.01: 100,000 USDC costs 2.01 instead of 10.01, 1,000 USDC
stays 0.11. Without a key, a rebalance is priced as a transfer.
- /v1/quote and /v1/transfers take an optional product; quotes carry
feeRule, the rule that priced them (null where a contract prices it).
- The handler passes the guard's gate to the service, so the partner is
the caller's verified key id, never something the request claims.
- createRebalancer sends product "rebalance" on its quotes and builds;
estimate returns feeRule.
- flatFeeFor and amountForBurn price through the default rule with the
same results; checkFeeTable refuses a table with no default, a free
rule, or a rebalance price without a key.
- Stellar and Arc contract routes are untouched.
* Fee table: the rebalance price only for market-maker keys the server names
Any valid API key earned the capped rebalance price, so an integrator
holding an ordinary key could label a user's transfer a rebalance and
pay 2.01 on 1M instead of 100.01.
- FeeRule.partner ("any" or one key) becomes partners: a list of key
ids. ANY_PARTNER is gone; checkFeeTable refuses a rebalance rule that
names no keys.
- FEE_TABLE ships the default rule only. withRebalancePartners(keyIds)
adds the capped rule for the keys a server names, so key ids never
ship in the SDK.
- The web server builds its table from XEBRA_REBALANCE_KEY_IDS
(comma-separated key ids, server-only; unset = nobody gets the cap)
and passes it to the service as deps.feeTable.
- Tests: a valid key not on the list pays the default for a rebalance;
an empty list names nobody; the env list is parsed.
- Docs, changelog, schema text and openapi.json say the price is for
keys set up for market-maker rebalances.
---
apps/docs/content/docs/changelog.mdx | 22 ++
apps/docs/content/docs/concepts/fees.mdx | 21 +
apps/docs/content/docs/guides/api-keys.mdx | 7 +-
apps/docs/content/docs/sdk/intents.mdx | 23 +-
apps/web/lib/api/deps.ts | 7 +
apps/web/lib/api/endpoints.ts | 28 +-
apps/web/lib/api/fee-table.test.ts | 437 +++++++++++++++++++++
apps/web/lib/api/http.ts | 8 +-
apps/web/lib/api/service.ts | 105 ++++-
apps/web/lib/api/wire.ts | 1 +
apps/web/lib/api/wiring.ts | 2 +
apps/web/lib/server/fee-table.test.ts | 28 ++
apps/web/lib/server/fee-table.ts | 20 +
apps/web/lib/server/flat-fee.ts | 24 +-
packages/sdk/openapi.json | 26 ++
packages/sdk/src/api/schemas.ts | 17 +
packages/sdk/src/client/index.test.ts | 11 +
packages/sdk/src/client/index.ts | 2 +-
packages/sdk/src/core/fees/flat.ts | 16 +-
packages/sdk/src/core/fees/table.test.ts | 250 ++++++++++++
packages/sdk/src/core/fees/table.ts | 208 ++++++++++
packages/sdk/src/core/index.ts | 1 +
packages/sdk/src/intents/index.ts | 6 +
packages/sdk/src/intents/rebalance.test.ts | 21 +
packages/sdk/src/intents/rebalance.ts | 19 +-
25 files changed, 1264 insertions(+), 46 deletions(-)
create mode 100644 apps/web/lib/api/fee-table.test.ts
create mode 100644 apps/web/lib/server/fee-table.test.ts
create mode 100644 apps/web/lib/server/fee-table.ts
create mode 100644 packages/sdk/src/core/fees/table.test.ts
create mode 100644 packages/sdk/src/core/fees/table.ts
diff --git a/apps/docs/content/docs/changelog.mdx b/apps/docs/content/docs/changelog.mdx
index d02a4a27..625fc9a1 100644
--- a/apps/docs/content/docs/changelog.mdx
+++ b/apps/docs/content/docs/changelog.mdx
@@ -7,6 +7,16 @@ description: What changed in the Xebra API and SDK, newest first.
**API**:
+- Market-maker rebalances: `GET /v1/quote` and `POST /v1/transfers` take an optional
+ `product`, `"transfer"` (the default) or `"rebalance"`. A rebalance with an API key that Xebra
+ has set up for market-maker rebalances is priced at 0.01% capped at 2 USDC a move, plus
+ 0.01 USDC: 100,000 USDC costs 2.01 instead of 10.01, 1,000 USDC still 0.11. Without such a key it
+ is priced as a transfer. Every other price is
+ unchanged. See [Fees](/docs/concepts/fees#market-maker-rebalances).
+- Quotes (and the quote in a build) carry `feeRule`, the fee rule that priced Xebra's fee:
+ `"default"`, `"rebalance-capped"`, or null where a Xebra contract prices it on-chain (Stellar
+ sources, EVM sources through Xebra's contract).
+
- Every route without a Xebra fee contract carries Xebra's fee: 0.01 USDC plus 0.01% of the
amount, whether the transfer arrives by itself (Circle's Forwarding Service, or Xebra's relayer
into Stellar) or the recipient claims it. `fees.xebra` shows it; `amount` is what leaves the wallet
@@ -26,6 +36,18 @@ description: What changed in the Xebra API and SDK, newest first.
**SDK**, `@xebra/sdk`:
+- `createRebalancer` asks for the rebalance price: its quotes and builds send
+ `product: "rebalance"`, and with a market-maker API key on the Xebra client
+ (`createXebraClient({ apiKey })`) a move costs Xebra 0.01% capped at 2 USDC, plus 0.01. `estimate` returns `feeRule`.
+- `QuoteRequest` and `TransferRequest` take `product`; `Quote` has `feeRule` (optional, so answers
+ from an older server still parse). `ProductSchema`.
+- `@xebra/sdk/core` (additive): the fee table, `FEE_TABLE`, and the function that prices from it,
+ `priceFee(amount, { product, partner, from, to })`, which returns the fee and the rule's id. Also
+ `feeRuleFor`, `feeUnder`, `amountForBurnUnder`, `checkFeeTable`, and `withRebalancePartners`,
+ which adds the market-maker price for the key ids a server names (the shipped table names none). `flatFeeFor` and
+ `amountForBurn` now price through the table's default rule, with the same results.
+- The intents router's `buildDeposit` takes `product`.
+
- `planEvmFee` takes `xebraFee`; `FeePlan` gains `burn`. `XEBRA_FLAT_FEE`, `flatFeeFor`,
`flatFeeKind`, `CLAIM_ONLY_DOMAINS`; `buildEvmFeeStep`, `buildAptosFeeStep`.
- `TransferStep.id` can be `"fee"`; `UnsignedTx` can be `aptos_call`.
diff --git a/apps/docs/content/docs/concepts/fees.mdx b/apps/docs/content/docs/concepts/fees.mdx
index 26ff227f..e7e73faa 100644
--- a/apps/docs/content/docs/concepts/fees.mdx
+++ b/apps/docs/content/docs/concepts/fees.mdx
@@ -93,6 +93,27 @@ smallest amount is about 1.0102.
Out of Arc, while Xebra's fee contract there is switched on for the site, the contract's own rule
applies, the same as Stellar's above, and there is no flat fee.
+### Market-maker rebalances
+
+A market maker moving its own USDC between chains (the SDK's
+[rebalancer](/docs/sdk/intents)) pays **0.01% capped at 2 USDC a move, plus 0.01 USDC**, on these
+same routes. It is never free.
+
+```text
+xebra = 0.01 + min(0.01% × amount, 2)
+```
+
+The capped price needs both: the request says `product: "rebalance"` (on `GET /v1/quote` and
+`POST /v1/transfers`), and it carries an [API key](/docs/guides/api-keys) that Xebra has set up
+for market-maker rebalances. Ask for that when you ask for the key. A rebalance without such a key,
+including one sent with an ordinary integration key, is priced as any other transfer. 100,000 USDC costs 2.01 instead of 10.01; up to
+20,000 USDC the two prices are the same.
+
+Every quote names the rule that priced Xebra's fee in `feeRule` (`"default"` or
+`"rebalance-capped"`; null where a Xebra contract prices it), and the build charges the fee the
+same request is quoted. Pass `maxTotalFee` to refuse a build whose fees rose above what you were
+shown.
+
## Circle's delivery fee
Circle's Forwarding Service charges for minting on the destination and paying the gas there. It
diff --git a/apps/docs/content/docs/guides/api-keys.mdx b/apps/docs/content/docs/guides/api-keys.mdx
index 0fec493b..46ca375f 100644
--- a/apps/docs/content/docs/guides/api-keys.mdx
+++ b/apps/docs/content/docs/guides/api-keys.mdx
@@ -11,8 +11,11 @@ own, higher limit and is not counted with everyone else's.
| No key | 60 requests | The calling address |
| With a key | 600 requests | The key |
-Both limits apply to every `/v1` endpoint. A key changes the limit and nothing else: the API stays
-non-custodial, still builds unsigned transactions, and never asks for or accepts a private key.
+Both limits apply to every `/v1` endpoint. A key changes the limit. A key that Xebra sets up for a
+market maker also changes the price of that market maker's rebalances (`product: "rebalance"`):
+0.01% capped at 2 USDC a move, plus 0.01 (see [Fees](/docs/concepts/fees#market-maker-rebalances)).
+Say so when you ask for the key; other keys pay the ordinary price. Nothing else: the API stays non-custodial,
+still builds unsigned transactions, and never asks for or accepts a private key.
## Get a key
diff --git a/apps/docs/content/docs/sdk/intents.mdx b/apps/docs/content/docs/sdk/intents.mdx
index 147da5c0..8d73d4d9 100644
--- a/apps/docs/content/docs/sdk/intents.mdx
+++ b/apps/docs/content/docs/sdk/intents.mdx
@@ -16,7 +16,8 @@ import { createXebraClient } from "@xebra/sdk";
import { createRebalancer } from "@xebra/sdk/intents";
const rb = createRebalancer({
- xebra: createXebraClient(),
+ // A Xebra market-maker key earns the rebalance price (below).
+ xebra: createXebraClient({ apiKey: "xk_live_your Xebra key" }),
oneClick: { apiKey: "your 1Click partner key" },
});
```
@@ -39,6 +40,23 @@ The withdrawal is the only step that needs a 1Click partner API key: `generate-i
`oneClick.apiKey` and only ever sent to 1Click. Quotes, estimates and the deposit step work
without it.
+## What Xebra charges
+
+Every quote and burn the rebalancer asks Xebra for says `product: "rebalance"`. With a
+[Xebra API key](/docs/guides/api-keys) that Xebra has set up for market-maker rebalances on the
+client, Xebra prices it as a rebalance: **0.01% of the amount capped at 2 USDC a move, plus 0.01
+USDC**. Without one it is an ordinary transfer, 0.01% plus 0.01 with no cap.
+
+| Move | With a market-maker key | Without |
+|---|---|---|
+| 100,000 USDC | 2.01 | 10.01 |
+| 50,000 USDC | 2.01 | 5.01 |
+| 1,000 USDC | 0.11 | 0.11 |
+
+That is Xebra's part of `fees.cctp`; Circle's delivery fee and NEAR Intents' withdrawal are on top.
+`estimate` names the rule that priced it in `feeRule`: `"rebalance-capped"` with a key,
+`"default"` without. See [Fees](/docs/concepts/fees#market-maker-rebalances).
+
## The request
`estimate`, `startWithdrawal` and `prepareDeposit` all take the same `RebalanceRequest`.
@@ -49,7 +67,7 @@ without it.
| Option | Type | Meaning |
|---|---|---|
-| `xebra` | `Pick` | A client from `createXebraClient()`. Its `routes()` decides whether the route is offered. |
+| `xebra` | `Pick` | A client from `createXebraClient()`. Its `routes()` decides whether the route is offered; its API key earns the rebalance price. |
| `oneClick.apiKey` | `string` | Your 1Click partner key. Needed to withdraw, and only sent to 1Click. |
| `oneClick.baseUrl` | `string` | Where 1Click answers. Default `https://1click.chaindefuser.com`. |
| `oneClick.referral` | `string` | The distribution-channel tag in NEAR Intents' records. Default `"xebra"`. |
@@ -80,6 +98,7 @@ const e = await rb.estimate(req);
console.log(`${e.amount} out of ${e.to}, ${e.arrives} back on ${e.to}`);
console.log(`withdrawal ${e.fees.withdraw}, CCTP ${e.fees.cctp}, total ${e.fees.total}`);
+console.log(`Xebra's fee priced by the ${e.feeRule} rule`);
console.log(`about ${Math.round(e.seconds / 60)} minutes end to end, ${e.better} is cheaper`);
if (e.direct.arrives === null) console.log(`no market maker quotes it: ${e.direct.reason}`);
diff --git a/apps/web/lib/api/deps.ts b/apps/web/lib/api/deps.ts
index 65ee0dd0..79f80348 100644
--- a/apps/web/lib/api/deps.ts
+++ b/apps/web/lib/api/deps.ts
@@ -7,6 +7,7 @@ import type {
EvmChain,
EvmChainId,
FeeParams,
+ FeeRule,
} from "@xebra/sdk/core";
import type { AptosBuildAnswer } from "../aptos/build";
import type { AptosDestination } from "../aptos/config";
@@ -90,6 +91,12 @@ export interface Deps {
* Xebra contract. A null entry turns that family's routes off; absent, no flat fee is charged
* (tests of the older figures only: production always sets it).
*/
+ /**
+ * The fee table off-contract routes are priced from. Absent: `FEE_TABLE`, which names no
+ * market-maker key. Production adds the market-maker price for the keys named in
+ * `XEBRA_REBALANCE_KEY_IDS` (`lib/server/fee-table.ts`).
+ */
+ feeTable?: readonly FeeRule[];
feeAddresses?: {
evm: string | null;
solana: string | null;
diff --git a/apps/web/lib/api/endpoints.ts b/apps/web/lib/api/endpoints.ts
index 929d6d51..5681d06f 100644
--- a/apps/web/lib/api/endpoints.ts
+++ b/apps/web/lib/api/endpoints.ts
@@ -11,11 +11,18 @@ import {
TransferRequestSchema,
TransferStatusSchema,
} from "@xebra/sdk";
-import { parseUsdcAmount } from "@xebra/sdk/core";
-import type { Guard } from "./auth";
+import { type FeeProduct, parseUsdcAmount } from "@xebra/sdk/core";
+import type { Gate, Guard } from "./auth";
import { ApiError } from "./errors";
import { handle } from "./http";
-import { type DestId, type Service, type SourceId, isDestId, isSourceId } from "./service";
+import {
+ type DestId,
+ type Pricing,
+ type Service,
+ type SourceId,
+ isDestId,
+ isSourceId,
+} from "./service";
import { buildToWire, claimToWire, quoteToWire, routesToWire, statusToWire } from "./wire";
/**
@@ -43,6 +50,15 @@ function route(from: string, to: string): { from: SourceId; to: DestId } {
return { from, to };
}
+/**
+ * Who is asking and for what, for Xebra's fee table. The partner is the id of the caller's valid
+ * API key, as the guard found it; a request without one is priced as anyone's, whatever it says it
+ * is for.
+ */
+function pricingOf(product: FeeProduct | undefined, gate: Gate): Pricing {
+ return { product: product ?? "transfer", partner: gate.keyId };
+}
+
function source(chain: string): SourceId {
if (!isSourceId(chain)) {
throw new ApiError("invalid_request", `Transfers do not start on ${chain}.`);
@@ -79,7 +95,7 @@ export function endpoints(service: EndpointService, guard: Guard) {
guard,
from: "query",
input: QuoteRequestSchema,
- run: async (q) => {
+ run: async (q, gate) => {
const r = route(q.from, q.to);
// Only Solana's price depends on the recipient (opening its USDC account costs more).
const opensAccount =
@@ -91,6 +107,7 @@ export function endpoints(service: EndpointService, guard: Guard) {
amount: units(q.amount),
...(q.speed ? { speed: q.speed } : {}),
opensAccount,
+ pricing: pricingOf(q.product, gate),
});
return quoteToWire(priced.quote);
},
@@ -102,7 +119,7 @@ export function endpoints(service: EndpointService, guard: Guard) {
guard,
from: "body",
input: TransferRequestSchema,
- run: async (r) =>
+ run: async (r, gate) =>
buildToWire(
await service.buildTransfer({
...route(r.from, r.to),
@@ -113,6 +130,7 @@ export function endpoints(service: EndpointService, guard: Guard) {
...(r.maxTotalFee !== undefined
? { maxTotalFee: parseUsdcAmount(r.maxTotalFee) ?? 0n }
: {}),
+ pricing: pricingOf(r.product, gate),
}),
),
output: TransferBuildSchema,
diff --git a/apps/web/lib/api/fee-table.test.ts b/apps/web/lib/api/fee-table.test.ts
new file mode 100644
index 00000000..0fb23645
--- /dev/null
+++ b/apps/web/lib/api/fee-table.test.ts
@@ -0,0 +1,437 @@
+import { ZERO_BYTES32 } from "@xebra/cctp-evm";
+import { QuoteSchema, TransferBuildSchema, createXebraClient } from "@xebra/sdk";
+import { APTOS_BURN_SCRIPT, APTOS_CCTP, type TransferStep } from "@xebra/sdk/build";
+import { EVM_CHAINS } from "@xebra/sdk/core";
+import { createRebalancer } from "@xebra/sdk/intents";
+import { decodeFunctionData, parseAbi } from "viem";
+import { describe, expect, it, vi } from "vitest";
+import type { AptosBuildAnswer } from "../aptos/build";
+import { feeTableFrom } from "../server/fee-table";
+import { flatFeeOn } from "../server/flat-fee";
+import { createGuard, createMemoryKeyStore, hashKey } from "./auth";
+import type { BuildDeps, Deps } from "./deps";
+import { endpoints } from "./endpoints";
+import {
+ EVM_SENDER,
+ RECIPIENT,
+ SOLANA_WALLET,
+ STELLAR_RECIPIENT,
+ SUI_SENDER,
+ SUI_STEP,
+ buildDeps,
+ deps,
+} from "./fakes";
+import { ANYONE, type DestId, type Pricing, type SourceId, createService } from "./service";
+
+/**
+ * Xebra's fee table (`FEE_TABLE`, `priceFee`) as the API and the page's build routes use it: what
+ * a quote shows is what the build charges, a rebalance is priced as one only with a named market-maker key, and
+ * everything else keeps today's price.
+ */
+
+const FEES = {
+ evm: "0x32e95718A4D9B60F2e4Fb1d371189ac5DD28211A",
+ solana: "2GiJjxVmqSSTL2yfUbVnBBDkTeXEn1DM8QM2ZrRGumte",
+ sui: `0x${"fe".repeat(32)}`,
+ aptos: `0x${"fa".repeat(32)}`,
+};
+const SOLANA_SENDER = "4UXmtLwyV5tRyzuCFtQccrHkepyVDnL29GLsg5LwFN82";
+const APTOS_SENDER = `0x${"74".repeat(32)}`;
+const ERC20 = parseAbi(["function transfer(address to, uint256 value) returns (bool)"]);
+const USDC = 1_000_000n;
+const KEY = `xk_live_${"A".repeat(32)}`;
+const KEY_ID = "key_mm";
+/** A valid key that is not named as a market maker: an ordinary integrator. */
+const OTHER_KEY = `xk_live_${"B".repeat(32)}`;
+const OTHER_KEY_ID = "key_wallet";
+/** The table as production builds it with `XEBRA_REBALANCE_KEY_IDS=key_mm`. */
+const TABLE = feeTableFrom(KEY_ID);
+
+const REBALANCE: Pricing = { product: "rebalance", partner: KEY_ID };
+const REBALANCE_NO_KEY: Pricing = { product: "rebalance", partner: null };
+const TRANSFER_WITH_KEY: Pricing = { product: "transfer", partner: KEY_ID };
+
+/** Today's price: 0.01 plus 0.01% of the amount, rounded down. */
+const today = (amount: bigint) => 10_000n + amount / 10_000n;
+
+const APTOS_BUILT: AptosBuildAnswer = {
+ status: 200,
+ body: {
+ transaction: {
+ kind: "aptos",
+ chainId: 1,
+ bytecode: APTOS_BURN_SCRIPT,
+ arguments: {
+ amount: "1",
+ destinationDomain: 27,
+ mintRecipient: ZERO_BYTES32,
+ destinationCaller: ZERO_BYTES32,
+ burnToken: APTOS_CCTP.usdc,
+ maxFee: "0",
+ minFinalityThreshold: 2000,
+ hookData: "0x",
+ },
+ },
+ envelope: {
+ sequenceNumber: "1",
+ maxGasAmount: "2000",
+ gasUnitPrice: "100",
+ expirationTimestampSecs: "1800000600",
+ },
+ maxFee: "0",
+ received: "1",
+ },
+};
+
+function mocks() {
+ return {
+ solanaBurn: vi.fn(async (_p: Parameters>[0]) => ({
+ ...SUI_STEP,
+ chain: "solana" as const,
+ })),
+ suiBurn: vi.fn(async (_p: Parameters[0]) => SUI_STEP),
+ suiForwardBurn: vi.fn(async (_p: Parameters[0]) => SUI_STEP),
+ aptosBuild: vi.fn(async () => APTOS_BUILT),
+ };
+}
+
+function svc(m = mocks(), top: Partial = {}) {
+ return createService(
+ deps({
+ build: buildDeps({
+ ...m,
+ // Enough USDC for the largest move below.
+ evmUsdc: async () => ({ balance: 100_000_000n * USDC, allowance: 0n }),
+ }),
+ evmRoutes: {
+ arcSendsTo: [],
+ arcReceivesFrom: [],
+ evmMesh: ["base", "arbitrum", "injective"],
+ evmToStellar: ["base"],
+ },
+ suiStellar: { enabled: true, maxUnits: null, sendsTo: ["base"] },
+ solanaSource: { evm: ["base"], stellar: true, maxUnits: null },
+ aptos: { destinations: ["stellar", "base"], maxUnits: null },
+ feeAddresses: FEES,
+ feeTable: TABLE,
+ ...top,
+ }),
+ );
+}
+
+/** Every off-contract route kind: EVM direct, EVM into Stellar, a claim-only chain, and the rest. */
+const ROUTES: Array<{ from: SourceId; to: DestId; sender: string; recipient: string }> = [
+ { from: "base", to: "arbitrum", sender: EVM_SENDER, recipient: RECIPIENT },
+ { from: "base", to: "stellar", sender: EVM_SENDER, recipient: STELLAR_RECIPIENT },
+ { from: "base", to: "injective", sender: EVM_SENDER, recipient: RECIPIENT },
+ { from: "solana", to: "stellar", sender: SOLANA_SENDER, recipient: STELLAR_RECIPIENT },
+ { from: "solana", to: "base", sender: SOLANA_SENDER, recipient: RECIPIENT },
+ { from: "sui", to: "stellar", sender: SUI_SENDER, recipient: STELLAR_RECIPIENT },
+ { from: "sui", to: "base", sender: SUI_SENDER, recipient: RECIPIENT },
+ { from: "aptos", to: "stellar", sender: APTOS_SENDER, recipient: STELLAR_RECIPIENT },
+ { from: "aptos", to: "base", sender: APTOS_SENDER, recipient: RECIPIENT },
+];
+
+/** What the built transfer actually pays Xebra, read from what the wallet will sign. */
+function charged(steps: TransferStep[], m: ReturnType): bigint {
+ const step = steps.find((s) => s.id === "fee");
+ if (step?.tx.kind === "evm") {
+ const call = decodeFunctionData({ abi: ERC20, data: step.tx.data });
+ expect(call.args[0]).toBe(FEES.evm);
+ return call.args[1];
+ }
+ if (step?.tx.kind === "aptos_call") {
+ expect(step.tx.functionArguments[1]).toBe(FEES.aptos);
+ return BigInt(step.tx.functionArguments[2] ?? "0");
+ }
+ // Solana and Sui pay the fee inside the burn's own transaction.
+ const solana = m.solanaBurn.mock.calls.at(-1)?.[0]?.fee;
+ if (solana) return solana.amount;
+ const sui = (m.suiBurn.mock.calls.at(-1)?.[0] ?? m.suiForwardBurn.mock.calls.at(-1)?.[0])?.fee;
+ if (sui) return sui.amount;
+ throw new Error("no fee in this build");
+}
+
+describe("quote and build, priced by the fee table", () => {
+ it("charge in the build exactly the fee the quote showed, on every off-contract route", async () => {
+ for (const route of ROUTES) {
+ for (const pricing of [ANYONE, REBALANCE, REBALANCE_NO_KEY, TRANSFER_WITH_KEY]) {
+ for (const amount of [25n * USDC, 1_000n * USDC, 100_000n * USDC]) {
+ const m = mocks();
+ const s = svc(m);
+ const shown = await s.quote({ from: route.from, to: route.to, amount, pricing });
+ const built = await s.buildTransfer({ ...route, amount, pricing });
+ const fee = charged(built.steps, m);
+ const what = `${route.from}->${route.to} ${amount} ${JSON.stringify(pricing)}`;
+ expect(fee, what).toBe(shown.quote.fees.xebra);
+ expect(built.quote.fees.xebra, what).toBe(shown.quote.fees.xebra);
+ expect(built.quote.feeRule, what).toBe(shown.quote.feeRule);
+ // The fee never exceeds a tenth of what is sent, and is never zero.
+ expect(fee * 10n <= amount, what).toBe(true);
+ expect(fee > 0n, what).toBe(true);
+ const expected =
+ pricing === REBALANCE
+ ? {
+ fee: 10_000n + (amount / 10_000n > 2n * USDC ? 2n * USDC : amount / 10_000n),
+ rule: "rebalance-capped",
+ }
+ : { fee: today(amount), rule: "default" };
+ expect({ fee, rule: shown.quote.feeRule }, what).toEqual(expected);
+ }
+ }
+ }
+ }, 120_000);
+
+ it("a contract-priced route names no rule", async () => {
+ const q = await svc().quote({ from: "stellar", to: "base", amount: 10n * USDC });
+ expect(q.quote.feeRule).toBeNull();
+ });
+
+ it("the page's build routes price an ordinary transfer, as the default rule does", () => {
+ for (const amount of [1n, 25n * USDC, 100_000n * USDC, 10_000_000n * USDC]) {
+ for (const [family, to] of [
+ ["solana", 27],
+ ["sui", 27],
+ ["sui", 6],
+ ["aptos", 6],
+ ["aptos", 30],
+ ] as const) {
+ expect(flatFeeOn(family, to, amount, FEES)).toEqual({
+ fee: today(amount),
+ address: FEES[family],
+ kind: to === 30 ? "claim" : "deliver",
+ rule: "default",
+ });
+ }
+ }
+ });
+});
+
+describe("/v1 with and without an API key", () => {
+ async function keyStore() {
+ const store = createMemoryKeyStore([]);
+ store.keys.set(await hashKey(KEY), { id: KEY_ID, integrator: "mm", revokedAt: null });
+ store.keys.set(await hashKey(OTHER_KEY), {
+ id: OTHER_KEY_ID,
+ integrator: "wallet",
+ revokedAt: null,
+ });
+ return store;
+ }
+ async function api() {
+ return endpoints(svc(), createGuard({ store: await keyStore() }));
+ }
+ const BASE = "https://api.xebra.exchange/v1";
+ const quote = (query: string, key?: string) =>
+ new Request(
+ `${BASE}/quote?${query}`,
+ key ? { headers: { Authorization: `Bearer ${key}` } } : {},
+ );
+ const transfer = (body: Record, key?: string) =>
+ new Request(`${BASE}/transfers`, {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ ...(key ? { Authorization: `Bearer ${key}` } : {}),
+ },
+ body: JSON.stringify(body),
+ });
+ const move = "from=base&to=arbitrum&amount=100000";
+
+ it("prices a keyed 100,000 USDC rebalance at 2.01, and the same request without a key at 10.01", async () => {
+ const v1 = await api();
+ const keyed = QuoteSchema.parse(
+ await (await v1.quote(quote(`${move}&product=rebalance`, KEY))).json(),
+ );
+ expect(keyed.fees.xebra).toBe("2.01");
+ expect(keyed.feeRule).toBe("rebalance-capped");
+
+ const anonymous = QuoteSchema.parse(
+ await (await v1.quote(quote(`${move}&product=rebalance`))).json(),
+ );
+ expect(anonymous.fees.xebra).toBe("10.01");
+ expect(anonymous.feeRule).toBe("default");
+
+ // A valid key that is not named as a market maker pays the default for a rebalance.
+ const otherKey = QuoteSchema.parse(
+ await (await v1.quote(quote(`${move}&product=rebalance`, OTHER_KEY))).json(),
+ );
+ expect(otherKey.fees.xebra).toBe("10.01");
+ expect(otherKey.feeRule).toBe("default");
+
+ // With no key named at all, the market maker's key pays the default too.
+ const unnamed = endpoints(
+ svc(mocks(), { feeTable: feeTableFrom(undefined) }),
+ createGuard({ store: await keyStore() }),
+ );
+ const notListed = QuoteSchema.parse(
+ await (await unnamed.quote(quote(`${move}&product=rebalance`, KEY))).json(),
+ );
+ expect(notListed.feeRule).toBe("default");
+
+ // A key alone does not make a transfer a rebalance.
+ const transferWithKey = QuoteSchema.parse(await (await v1.quote(quote(move, KEY))).json());
+ expect(transferWithKey.fees.xebra).toBe("10.01");
+ expect(transferWithKey.feeRule).toBe("default");
+
+ // 1,000 USDC: 0.11 either way.
+ const small = QuoteSchema.parse(
+ await (
+ await v1.quote(quote("from=base&to=arbitrum&amount=1000&product=rebalance", KEY))
+ ).json(),
+ );
+ expect(small.fees.xebra).toBe("0.11");
+ expect(small.feeRule).toBe("rebalance-capped");
+ });
+
+ it("builds a keyed rebalance with the fee its quote showed", async () => {
+ const v1 = await api();
+ const res = await v1.createTransfer(
+ transfer(
+ {
+ from: "base",
+ to: "arbitrum",
+ amount: "100000",
+ sender: EVM_SENDER,
+ recipient: RECIPIENT,
+ product: "rebalance",
+ maxTotalFee: "2.03",
+ },
+ KEY,
+ ),
+ );
+ expect(res.status).toBe(200);
+ const built = TransferBuildSchema.parse(await res.json());
+ expect(built.quote.fees.xebra).toBe("2.01");
+ expect(built.quote.feeRule).toBe("rebalance-capped");
+ const fee = built.steps.find((s) => s.id === "fee");
+ if (fee?.tx.kind !== "evm") throw new Error("no EVM fee step");
+ expect(decodeFunctionData({ abi: ERC20, data: fee.tx.data as `0x${string}` }).args).toEqual([
+ FEES.evm,
+ 2_010_000n,
+ ]);
+ });
+
+ it("without a key, a rebalance build is priced as a transfer, and a fee cap set from the keyed price refuses it", async () => {
+ const v1 = await api();
+ const res = await v1.createTransfer(
+ transfer({
+ from: "base",
+ to: "arbitrum",
+ amount: "100000",
+ sender: EVM_SENDER,
+ recipient: RECIPIENT,
+ product: "rebalance",
+ maxTotalFee: "2.03",
+ }),
+ );
+ expect(res.status).toBe(422);
+ expect((await res.json()).code).toBe("fee_above_limit");
+ });
+
+ it("refuses a product it does not know", async () => {
+ const v1 = await api();
+ const res = await v1.quote(quote(`${move}&product=free`, KEY));
+ expect(res.status).toBe(400);
+ });
+});
+
+describe("the EVM chains these tests name", () => {
+ it("are the ones they mean", () => {
+ expect(EVM_CHAINS.base.cctpDomainId).toBe(6);
+ expect(EVM_CHAINS.arbitrum.cctpDomainId).toBe(3);
+ expect(EVM_CHAINS.injective.cctpDomainId).toBe(29);
+ });
+});
+
+describe("the SDK's rebalancer, end to end against /v1", () => {
+ /** 1Click: a same-asset withdrawal costs 0.07, a deposit is free, a direct swap finds no one. */
+ const oneClick = (async (url: string | URL | Request, init?: RequestInit) => {
+ const path = new URL(String(url)).pathname;
+ const body = init?.body ? (JSON.parse(String(init.body)) as Record) : {};
+ const json = (v: unknown, status = 200) => Response.json(v, { status });
+ if (path === "/v0/tokens") {
+ return json([
+ {
+ assetId: "nep141:base-usdc",
+ blockchain: "base",
+ symbol: "USDC",
+ decimals: 6,
+ contractAddress: EVM_CHAINS.base.usdcAddress.toLowerCase(),
+ },
+ {
+ assetId: "nep141:arb-usdc",
+ blockchain: "arb",
+ symbol: "USDC",
+ decimals: 6,
+ contractAddress: EVM_CHAINS.arbitrum.usdcAddress.toLowerCase(),
+ },
+ ]);
+ }
+ if (body.originAsset !== body.destinationAsset) return json({ message: "No liquidity" }, 400);
+ const amount = BigInt(String(body.amount));
+ const out = body.depositType === "INTENTS" ? amount - 70_000n : amount;
+ return json({
+ quote: {
+ ...(body.dry ? {} : { depositAddress: "0x4444444444444444444444444444444444444444" }),
+ amountIn: String(amount),
+ amountInFormatted: "",
+ amountOut: String(out),
+ amountOutFormatted: "",
+ minAmountOut: String(out),
+ timeEstimate: 10,
+ },
+ });
+ }) as typeof fetch;
+
+ async function rebalancer(apiKey?: string) {
+ const store = createMemoryKeyStore([]);
+ store.keys.set(await hashKey(KEY), { id: KEY_ID, integrator: "mm", revokedAt: null });
+ const v1 = endpoints(svc(), createGuard({ store }));
+ const xebra = createXebraClient({
+ baseUrl: "https://api.xebra.exchange",
+ ...(apiKey ? { apiKey } : {}),
+ fetch: (async (url: string | URL | Request, init?: RequestInit) => {
+ const req = new Request(String(url), init);
+ const path = new URL(req.url).pathname;
+ if (path === "/v1/routes") return v1.routes(req);
+ if (path === "/v1/quote") return v1.quote(req);
+ return v1.createTransfer(req);
+ }) as typeof fetch,
+ });
+ return createRebalancer({ xebra, fetch: oneClick });
+ }
+ const REQUEST = {
+ intentsAccount: "mm.near",
+ from: "base",
+ to: "arb",
+ amount: "100000",
+ fromWallet: EVM_SENDER,
+ toWallet: RECIPIENT,
+ };
+
+ it("100,000 USDC Base to Arbitrum: Xebra takes 2.01 with a key, 10.01 without", async () => {
+ const keyed = await (await rebalancer(KEY)).estimate(REQUEST);
+ const anonymous = await (await rebalancer()).estimate(REQUEST);
+ expect(keyed.feeRule).toBe("rebalance-capped");
+ expect(anonymous.feeRule).toBe("default");
+ expect(keyed.fees.withdraw).toBe("0.07");
+ // Xebra prices what the withdrawal leaves, 99,999.93: 0.01 + 9.999993 without a key, 2.01
+ // with one. The withdrawal and Circle's fee are the same either way.
+ const units = (v: string) => BigInt(Math.round(Number(v) * 1e6));
+ expect(units(anonymous.fees.cctp) - units(keyed.fees.cctp)).toBe(10_009_993n - 2_010_000n);
+ expect(units(anonymous.fees.total) - units(keyed.fees.total)).toBe(7_999_993n);
+ expect(units(keyed.fees.cctp)).toBeGreaterThanOrEqual(2_010_000n);
+ });
+
+ it("prepares the burn at the price it quoted, with the fee step to Xebra at 2.01", async () => {
+ const d = await (await rebalancer(KEY)).prepareDeposit(REQUEST, { amount: "99999.93" });
+ expect(d.xebra.fees.xebra).toBe("2.01");
+ expect(d.build.quote.fees.xebra).toBe("2.01");
+ const fee = d.build.steps.find((s) => s.id === "fee");
+ if (fee?.tx.kind !== "evm") throw new Error("no EVM fee step");
+ expect(decodeFunctionData({ abi: ERC20, data: fee.tx.data as `0x${string}` }).args[1]).toBe(
+ 2_010_000n,
+ );
+ });
+});
diff --git a/apps/web/lib/api/http.ts b/apps/web/lib/api/http.ts
index 8bf58583..8d8a0667 100644
--- a/apps/web/lib/api/http.ts
+++ b/apps/web/lib/api/http.ts
@@ -157,7 +157,8 @@ export async function handle(
from: "none" | "query" | "body" | "params";
params?: Record;
input?: Parser;
- run(input: I): Promise;
+ /** `gate` is who the guard says is asking: a valid API key's id, or null without one. */
+ run(input: I, gate: Gate): Promise;
output: Parser;
/** `Cache-Control` for a success. */
cache?: string;
@@ -167,7 +168,8 @@ export async function handle(
): Promise {
let gate: Gate | null = null;
try {
- gate = await opts.guard(req);
+ const caller = await opts.guard(req);
+ gate = caller;
let raw: unknown = {};
if (opts.from === "query") raw = Object.fromEntries(new URL(req.url).searchParams);
if (opts.from === "body") raw = await readBody(req);
@@ -179,7 +181,7 @@ export async function handle(
input = parsed.data;
}
- const result = await opts.run(input);
+ const result = await opts.run(input, caller);
const checked = opts.output.safeParse(result);
if (!checked.success) {
// Our bug, not the caller's: say so plainly, and log what was wrong.
diff --git a/apps/web/lib/api/service.ts b/apps/web/lib/api/service.ts
index 3245a1c6..e5aa3eef 100644
--- a/apps/web/lib/api/service.ts
+++ b/apps/web/lib/api/service.ts
@@ -15,11 +15,13 @@ import {
CLAIM_ONLY_DOMAINS,
EVM_CHAINS,
type EvmChainId,
+ FEE_TABLE,
type FeePlan,
+ type FeeProduct,
type FeeTier,
STELLAR_CCTP_DOMAIN,
type WrapperTerms,
- amountForBurn,
+ amountForBurnUnder,
bytesToHex,
checkAddressOn,
checkSolanaAddress,
@@ -28,7 +30,7 @@ import {
evmDestinationsFrom,
evmSendsToStellar,
evmSources,
- flatFeeFor,
+ feeRuleFor,
formatUsdc,
formatUsdcAmount,
forwardBoundHolds,
@@ -38,6 +40,7 @@ import {
minimumWrapperAmount,
planEvmFee,
planWrapperFee,
+ priceFee,
solanaAddressToBytes32,
stellarBurnRecipient,
stellarDestination,
@@ -95,8 +98,25 @@ export interface Quote {
circleStatus: "ok" | "degraded" | null;
/** Fees move; after this the quote should be asked for again. */
expiresAt: string;
+ /**
+ * The fee-table rule that priced Xebra's fee (`FEE_TABLE`), or null where a Xebra contract
+ * prices it on-chain (Stellar sources, EVM sources through Xebra's wrapper).
+ */
+ feeRule: string | null;
+}
+
+/**
+ * Who is asking and for what, for Xebra's fee table: the product the request names, and the id of
+ * the caller's valid API key (null without one). A rebalance is priced as one only with a key.
+ */
+export interface Pricing {
+ product: FeeProduct;
+ partner: string | null;
}
+/** An ordinary transfer from anyone: what every surface without a key (the page, MCP) asks. */
+export const ANYONE: Pricing = { product: "transfer", partner: null };
+
/** A quote plus what produced it, for the surfaces that explain the figures. */
export interface PricedQuote {
quote: Quote;
@@ -109,7 +129,7 @@ export interface PricedQuote {
* Xebra's flat fee on a route without a Xebra contract, and the address it is paid to on the
* source chain. The burn is the amount less this fee.
*/
- flat?: { fee: bigint; address: string } | null;
+ flat?: { fee: bigint; address: string; rule: string } | null;
}
export type QuoteOption =
@@ -262,6 +282,7 @@ const floorToUnits = (stroops: bigint) => stroops / STROOPS_PER_UNIT;
const WRAPPER_DEADLINE_SECS = 1_800;
export function createService(deps: Deps, now: () => number = Date.now) {
+ const feeTable = deps.feeTable ?? FEE_TABLE;
async function routes(): Promise<{ routes: RouteGroup[]; stellarContractRead: boolean }> {
const stellar = await deps.stellarRoutes();
const groups: RouteGroup[] = [
@@ -357,6 +378,8 @@ export function createService(deps: Deps, now: () => number = Date.now) {
fees: Omit;
minimum: bigint;
maximum: bigint | null;
+ /** The fee rule that priced Xebra's fee; null where a contract prices it. */
+ feeRule?: string | null;
},
health: CircleHealth | null,
): Quote {
@@ -372,6 +395,7 @@ export function createService(deps: Deps, now: () => number = Date.now) {
maximum: p.maximum,
circleStatus: health ? (health.status === "ok" ? "ok" : "degraded") : null,
expiresAt: new Date(now() + QUOTE_TTL_MS).toISOString(),
+ feeRule: p.feeRule ?? null,
};
}
@@ -558,7 +582,8 @@ export function createService(deps: Deps, now: () => number = Date.now) {
from: SourceId,
to: DestId,
amount: bigint,
- ): { fee: bigint; address: string } | null {
+ pricing: Pricing,
+ ): { fee: bigint; address: string; rule: string } | null {
const family = feeFamily(from);
if (!family || !deps.feeAddresses) return null;
const address = deps.feeAddresses[family];
@@ -568,7 +593,18 @@ export function createService(deps: Deps, now: () => number = Date.now) {
`Transfers from ${SOURCE_NAME(from)} are off for now: Xebra's fee address there is not set up.`,
);
}
- return { fee: flatFeeFor(destinationDomain(to), amount), address };
+ const price = priceFee(amount, feeContext(from, to, pricing), feeTable);
+ return { fee: price.fee, address, rule: price.rule };
+ }
+
+ /** What the fee table matches a request on. */
+ function feeContext(from: SourceId, to: DestId, pricing: Pricing) {
+ return {
+ product: pricing.product,
+ partner: pricing.partner,
+ from: sourceDomainOf(from),
+ to: destinationDomain(to),
+ };
}
/**
@@ -580,8 +616,9 @@ export function createService(deps: Deps, now: () => number = Date.now) {
amount: bigint,
minBurn: bigint,
maximum: bigint | null,
+ pricing: Pricing,
): { health: CircleHealth | null; options: QuoteOption[] } {
- return unforwarded(from, "stellar", amount, minBurn, maximum);
+ return unforwarded(from, "stellar", amount, minBurn, maximum, pricing);
}
/**
@@ -595,10 +632,13 @@ export function createService(deps: Deps, now: () => number = Date.now) {
amount: bigint,
minBurn: bigint,
maximum: bigint | null,
+ pricing: Pricing,
): { health: CircleHealth | null; options: QuoteOption[] } {
- const flat = flatFee(from, to, amount);
+ const flat = flatFee(from, to, amount, pricing);
const fee = flat?.fee ?? 0n;
- const minimum = flat ? amountForBurn(destinationDomain(to), minBurn) : minBurn;
+ const minimum = flat
+ ? amountForBurnUnder(feeRuleFor(feeContext(from, to, pricing), feeTable), minBurn)
+ : minBurn;
const quote = quoteOf(
from,
to,
@@ -609,6 +649,7 @@ export function createService(deps: Deps, now: () => number = Date.now) {
fees: { xebra: fee, circle: 0n, delivery: 0n },
minimum,
maximum,
+ feeRule: flat?.rule ?? null,
},
null,
);
@@ -636,10 +677,11 @@ export function createService(deps: Deps, now: () => number = Date.now) {
health: CircleHealth,
opensAccount: boolean,
wrapper: { address: string; terms: WrapperTerms } | null,
+ pricing: Pricing,
): QuoteOption {
const dest = routeDestination(to as Exclude);
const destination = feeDestination(dest, opensAccount);
- const flat = wrapper ? null : flatFee(from, to, units);
+ const flat = wrapper ? null : flatFee(from, to, units, pricing);
const xebraFee = flat?.fee ?? 0n;
const plan = wrapper
? planWrapperFee({
@@ -680,6 +722,7 @@ export function createService(deps: Deps, now: () => number = Date.now) {
fees: { xebra: plan.xebraFee, circle: plan.speedFee, delivery: plan.deliveryFee },
minimum,
maximum: wrapper ? wrapper.terms.maxTransfer : null,
+ feeRule: flat?.rule ?? null,
},
health,
),
@@ -723,8 +766,11 @@ export function createService(deps: Deps, now: () => number = Date.now) {
amount: bigint;
/** Solana: Circle also opens the recipient's USDC account, which costs more. */
opensAccount?: boolean;
+ /** Who is asking and for what. Default: an ordinary transfer from anyone. */
+ pricing?: Pricing;
}): Promise<{ health: CircleHealth | null; options: QuoteOption[] }> {
const opensAccount = q.opensAccount ?? false;
+ const pricing = q.pricing ?? ANYONE;
if (q.amount <= 0n) throw new ApiError("invalid_amount", "The amount must be more than zero.");
await checkRoute(q.from, q.to);
@@ -740,7 +786,7 @@ export function createService(deps: Deps, now: () => number = Date.now) {
if (q.to === "stellar") {
// Nothing forwards into Stellar, so Circle is paid nothing; Xebra's relayer completes it,
// from 1 USDC (what it accepts from every source but Sui).
- return relayedToStellar("aptos", q.amount, RELAYED_MIN_UNITS, cap);
+ return relayedToStellar("aptos", q.amount, RELAYED_MIN_UNITS, cap, pricing);
}
// Circle's Forwarding Service delivers, priced as every direct route is; no wrapper.
const health = await circleFor("aptos", q.to, opensAccount);
@@ -753,7 +799,9 @@ export function createService(deps: Deps, now: () => number = Date.now) {
}
return {
health,
- options: [evmOption("aptos", q.to, q.amount, "standard", tier, health, opensAccount, null)],
+ options: [
+ evmOption("aptos", q.to, q.amount, "standard", tier, health, opensAccount, null, pricing),
+ ],
};
}
@@ -778,25 +826,35 @@ export function createService(deps: Deps, now: () => number = Date.now) {
`Circle is not quoting Sui to ${DEST_NAME(q.to)} right now. Try again shortly.`,
);
}
- const option = evmOption("sui", q.to, q.amount, "standard", tier, health, opensAccount, null);
+ const option = evmOption(
+ "sui",
+ q.to,
+ q.amount,
+ "standard",
+ tier,
+ health,
+ opensAccount,
+ null,
+ pricing,
+ );
if (option.ok) option.priced.quote.maximum = deps.suiStellar.maxUnits;
return { health, options: [option] };
}
if (q.from === "sui") {
// Standard finality and no fee from Circle; Xebra's flat fee beside the burn.
- return relayedToStellar("sui", q.amount, 1n, deps.suiStellar.maxUnits);
+ return relayedToStellar("sui", q.amount, 1n, deps.suiStellar.maxUnits, pricing);
}
- if (q.from === "solana") return solanaOptions(q.to, q.amount);
+ if (q.from === "solana") return solanaOptions(q.to, q.amount, pricing);
if (q.from !== "stellar" && isClaimOnly(q.to)) {
// Circle does not deliver there: no hook, no Circle fee, the recipient claims it. Fees
// within a tenth of the amount, so about 0.10 at least with Xebra's 0.01.
- return unforwarded(q.from, q.to, q.amount, CLAIM_ONLY_MIN_BURN, null);
+ return unforwarded(q.from, q.to, q.amount, CLAIM_ONLY_MIN_BURN, null, pricing);
}
if (q.to === "stellar" && q.from !== "stellar") {
// An EVM chain into Stellar: no Circle fee, Standard only; Xebra's relayer completes it from
// a 1 USDC burn. Never through the wrapper, whose burn cannot name Stellar's forwarder.
- return relayedToStellar(q.from, q.amount, RELAYED_MIN_UNITS, null);
+ return relayedToStellar(q.from, q.amount, RELAYED_MIN_UNITS, null, pricing);
}
const health = await circleFor(q.from, q.to, opensAccount);
@@ -812,7 +870,7 @@ export function createService(deps: Deps, now: () => number = Date.now) {
const options = tiers
.filter((t): t is [Speed, FeeTier] => t[1] !== null)
.map(([speed, tier]) =>
- evmOption(from, q.to, q.amount, speed, tier, health, opensAccount, wrapper),
+ evmOption(from, q.to, q.amount, speed, tier, health, opensAccount, wrapper, pricing),
);
return { health, options };
}
@@ -825,6 +883,7 @@ export function createService(deps: Deps, now: () => number = Date.now) {
async function solanaOptions(
to: DestId,
amount: bigint,
+ pricing: Pricing,
): Promise<{ health: CircleHealth | null; options: QuoteOption[] }> {
const cap = deps.solanaSource?.maxUnits ?? null;
if (cap !== null && amount > cap) {
@@ -834,7 +893,9 @@ export function createService(deps: Deps, now: () => number = Date.now) {
{ maximum: cap },
);
}
- if (to === "stellar") return relayedToStellar("solana", amount, RELAYED_MIN_UNITS, cap);
+ if (to === "stellar") {
+ return relayedToStellar("solana", amount, RELAYED_MIN_UNITS, cap, pricing);
+ }
const health = await circleFor("solana", to, false);
const tier = health.tiers.standard;
if (!tier) {
@@ -844,7 +905,7 @@ export function createService(deps: Deps, now: () => number = Date.now) {
);
}
const chain = EVM_CHAINS[to as EvmChainId];
- const flat = flatFee("solana", to, amount);
+ const flat = flatFee("solana", to, amount, pricing);
const xebraFee = flat?.fee ?? 0n;
const plan = planEvmFee({ amount, tier, destination: chain, xebraFee });
const minimum = suggestedEvmMinimum(minimumEvmAmount(tier, xebraFee));
@@ -881,6 +942,7 @@ export function createService(deps: Deps, now: () => number = Date.now) {
fees: { xebra: plan.xebraFee, circle: plan.speedFee, delivery: plan.deliveryFee },
minimum,
maximum: cap,
+ feeRule: flat?.rule ?? null,
},
health,
),
@@ -900,6 +962,8 @@ export function createService(deps: Deps, now: () => number = Date.now) {
amount: bigint;
speed?: Speed;
opensAccount?: boolean;
+ /** Who is asking and for what. Default: an ordinary transfer from anyone. */
+ pricing?: Pricing;
}): Promise {
const speed = q.speed ?? "standard";
const { options } = await quoteOptions(q);
@@ -1092,6 +1156,8 @@ export function createService(deps: Deps, now: () => number = Date.now) {
speed?: Speed;
/** The most the caller will let fees come to, typically the total it showed its user. */
maxTotalFee?: bigint;
+ /** Priced exactly as `quote` prices the same request, so the build charges what it showed. */
+ pricing?: Pricing;
}): Promise<{ quote: Quote; steps: TransferStep[] }> {
const b = deps.build;
if (!b) throw new Error("buildTransfer needs the build dependencies");
@@ -1147,6 +1213,7 @@ export function createService(deps: Deps, now: () => number = Date.now) {
amount: r.amount,
...(r.speed ? { speed: r.speed } : {}),
opensAccount,
+ ...(r.pricing ? { pricing: r.pricing } : {}),
});
if (r.maxTotalFee !== undefined && priced.quote.fees.total > r.maxTotalFee) {
throw new ApiError(
diff --git a/apps/web/lib/api/wire.ts b/apps/web/lib/api/wire.ts
index 79b059c9..af8c7a45 100644
--- a/apps/web/lib/api/wire.ts
+++ b/apps/web/lib/api/wire.ts
@@ -39,6 +39,7 @@ export function quoteToWire(q: Quote): WireQuote {
maximum: q.maximum === null ? null : amount(q.maximum),
circleStatus: q.circleStatus,
expiresAt: q.expiresAt,
+ feeRule: q.feeRule,
};
}
diff --git a/apps/web/lib/api/wiring.ts b/apps/web/lib/api/wiring.ts
index cf95c895..a1bb796e 100644
--- a/apps/web/lib/api/wiring.ts
+++ b/apps/web/lib/api/wiring.ts
@@ -23,6 +23,7 @@ import { env } from "../env";
import { getAllowance, getUsdcBalance6 } from "../evm-bridge";
import { checkClaim, isAlreadyMinted } from "../evm-claim";
import { type WrapperState, parseWrapperState } from "../evm-wrapper";
+import { liveFeeTable } from "../server/fee-table";
import { createTtlCache } from "../server/ttl-cache";
import { SolanaSourceError } from "../solana-source/checks";
import { SOLANA_CCTP_DOMAIN, solanaMaxUsdcBase, solanaSends } from "../solana-source/config";
@@ -140,6 +141,7 @@ export const liveDeps: Deps = {
aptos: { destinations: aptosDestinations(), maxUnits: aptosMaxUsdcBase() },
evmRoutes: env.evmRoutes,
feeAddresses: env.feeAddresses,
+ feeTable: liveFeeTable,
stellarRoutes,
evmWrapperAddress: (chain) => wrapperFor(chain, env.arcUseWrapper),
async evmWrapperSettings(chain) {
diff --git a/apps/web/lib/server/fee-table.test.ts b/apps/web/lib/server/fee-table.test.ts
new file mode 100644
index 00000000..031d6736
--- /dev/null
+++ b/apps/web/lib/server/fee-table.test.ts
@@ -0,0 +1,28 @@
+import { DEFAULT_FEE_RULE_ID, FEE_TABLE, priceFee } from "@xebra/sdk/core";
+import { describe, expect, it } from "vitest";
+import { feeTableFrom, rebalanceKeyIds } from "./fee-table";
+
+describe("the server's fee table", () => {
+ it("reads the market-maker key ids from a comma-separated list", () => {
+ expect(rebalanceKeyIds(undefined)).toEqual([]);
+ expect(rebalanceKeyIds("")).toEqual([]);
+ expect(rebalanceKeyIds(" key_a , ,key_b,")).toEqual(["key_a", "key_b"]);
+ });
+
+ it("names nobody when the variable is unset, so every rebalance pays the default", () => {
+ expect(feeTableFrom(undefined)).toBe(FEE_TABLE);
+ expect(
+ priceFee(100_000_000_000n, { product: "rebalance", partner: "key_a" }, feeTableFrom("")).rule,
+ ).toBe(DEFAULT_FEE_RULE_ID);
+ });
+
+ it("gives the capped price only to the keys it names", () => {
+ const table = feeTableFrom("key_a,key_b");
+ const price = (partner: string | null) =>
+ priceFee(100_000_000_000n, { product: "rebalance", partner }, table);
+ expect(price("key_a")).toEqual({ fee: 2_010_000n, rule: "rebalance-capped" });
+ expect(price("key_b").fee).toBe(2_010_000n);
+ expect(price("key_c")).toEqual({ fee: 10_010_000n, rule: "default" });
+ expect(price(null).rule).toBe("default");
+ });
+});
diff --git a/apps/web/lib/server/fee-table.ts b/apps/web/lib/server/fee-table.ts
new file mode 100644
index 00000000..ae8a6749
--- /dev/null
+++ b/apps/web/lib/server/fee-table.ts
@@ -0,0 +1,20 @@
+import { type FeeRule, withRebalancePartners } from "@xebra/sdk/core";
+
+/**
+ * The fee table the server prices from: `FEE_TABLE` plus the market-maker rebalance price for the
+ * API keys named in `XEBRA_REBALANCE_KEY_IDS` (comma-separated key ids, as the key store records
+ * them). Only those keys get it; any other key, and every caller without one, pays the default.
+ * Server-only, so the ids never reach a page or the published SDK.
+ */
+export function rebalanceKeyIds(raw: string | undefined): string[] {
+ return (raw ?? "")
+ .split(",")
+ .map((id) => id.trim())
+ .filter((id) => id !== "");
+}
+
+export function feeTableFrom(raw: string | undefined): readonly FeeRule[] {
+ return withRebalancePartners(rebalanceKeyIds(raw));
+}
+
+export const liveFeeTable: readonly FeeRule[] = feeTableFrom(process.env.XEBRA_REBALANCE_KEY_IDS);
diff --git a/apps/web/lib/server/flat-fee.ts b/apps/web/lib/server/flat-fee.ts
index 2dd330e0..14f61bb6 100644
--- a/apps/web/lib/server/flat-fee.ts
+++ b/apps/web/lib/server/flat-fee.ts
@@ -1,11 +1,12 @@
-import { type FlatFeeKind, flatFeeFor, flatFeeKind } from "@xebra/sdk/core";
+import { type FlatFeeKind, flatFeeKind, priceFee } from "@xebra/sdk/core";
import { type FeeAddresses, parseFeeAddresses } from "../fee-addresses";
/**
* Xebra's flat fee for the page's own build routes (`/api/solana-source/build`, `/api/sui-*`,
- * `/api/aptos/build`), decided on the server so a page cannot leave it out. The same figures as
- * `/v1` (`lib/api/service.ts`): the amount a person enters is what leaves the wallet, the burn is
- * the rest.
+ * `/api/aptos/build`), decided on the server so a page cannot leave it out. Priced by the same
+ * function and table as `/v1` (`priceFee`, `FEE_TABLE`): the amount a person enters is what leaves
+ * the wallet, the burn is the rest. The page carries no API key, so it is always an ordinary
+ * transfer at the default rule's price.
*/
export class FeeAddressMissing extends Error {
readonly status = 503;
@@ -28,8 +29,13 @@ export interface FlatFee {
fee: bigint;
address: string;
kind: FlatFeeKind;
+ /** The fee-table rule that priced it. */
+ rule: string;
}
+/** The CCTP domain each non-EVM family burns on; an EVM source has one per chain. */
+const FAMILY_DOMAIN: Partial> = { solana: 5, sui: 8, aptos: 9 };
+
export function flatFeeOn(
family: keyof FeeAddresses,
destinationDomain: number,
@@ -39,10 +45,18 @@ export function flatFeeOn(
): FlatFee {
const address = addresses[family];
if (!address) throw new FeeAddressMissing(family);
+ const from = FAMILY_DOMAIN[family];
+ const price = priceFee(amount, {
+ product: "transfer",
+ partner: null,
+ ...(from !== undefined ? { from } : {}),
+ to: destinationDomain,
+ });
return {
- fee: flatFeeFor(destinationDomain, amount),
+ fee: price.fee,
address,
kind: flatFeeKind(destinationDomain),
+ rule: price.rule,
};
}
diff --git a/packages/sdk/openapi.json b/packages/sdk/openapi.json
index 30b025b2..db59d9c9 100644
--- a/packages/sdk/openapi.json
+++ b/packages/sdk/openapi.json
@@ -160,6 +160,13 @@
"maxLength": 128
},
"description": "Optional. For Solana, pass it: a wallet with no USDC account yet costs more to deliver to, and the quote includes that."
+ },
+ {
+ "in": "query",
+ "name": "product",
+ "schema": {
+ "$ref": "#/components/schemas/Product"
+ }
}
],
"responses": {
@@ -612,6 +619,14 @@
],
"description": "Standard waits for finality; Fast is attested sooner for Circle's fee."
},
+ "Product": {
+ "type": "string",
+ "enum": [
+ "transfer",
+ "rebalance"
+ ],
+ "description": "What the transfer is for. `rebalance` is a market maker moving its own USDC between chains: with an API key Xebra has set up for market-maker rebalances it is priced at 0.01% capped at 2 USDC a move, plus 0.01. Otherwise it is priced as a transfer."
+ },
"TransferRequest": {
"type": "object",
"properties": {
@@ -642,6 +657,9 @@
"maxTotalFee": {
"description": "Refuse if fees have risen above this, typically the total you showed.",
"$ref": "#/components/schemas/AmountOut"
+ },
+ "product": {
+ "$ref": "#/components/schemas/Product"
}
},
"required": [
@@ -888,6 +906,14 @@
"type": "string",
"format": "date-time",
"pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
+ },
+ "feeRule": {
+ "description": "The fee rule that priced Xebra's fee (default, rebalance-capped), or null where a Xebra contract prices it on-chain.",
+ "example": "default",
+ "type": [
+ "string",
+ "null"
+ ]
}
},
"required": [
diff --git a/packages/sdk/src/api/schemas.ts b/packages/sdk/src/api/schemas.ts
index 4ba81128..7ea6b783 100644
--- a/packages/sdk/src/api/schemas.ts
+++ b/packages/sdk/src/api/schemas.ts
@@ -53,6 +53,12 @@ export const RoutesSchema = z
})
.meta({ id: "Routes" });
+export const ProductSchema = z.enum(["transfer", "rebalance"]).meta({
+ id: "Product",
+ description:
+ "What the transfer is for. `rebalance` is a market maker moving its own USDC between chains: with an API key Xebra has set up for market-maker rebalances it is priced at 0.01% capped at 2 USDC a move, plus 0.01. Otherwise it is priced as a transfer.",
+});
+
export const QuoteRequestSchema = z.object({
from: ChainIdSchema,
to: ChainIdSchema,
@@ -62,6 +68,7 @@ export const QuoteRequestSchema = z.object({
description:
"Optional. For Solana, pass it: a wallet with no USDC account yet costs more to deliver to, and the quote includes that.",
}),
+ product: ProductSchema.optional(),
});
export const FeesSchema = z
@@ -102,6 +109,15 @@ export const QuoteSchema = z
circleStatus: z.enum(["ok", "degraded"]).nullable(),
/** ISO 8601. Fees move; after this, ask again. */
expiresAt: z.iso.datetime(),
+ /**
+ * The fee rule that priced Xebra's fee, such as "default" or "rebalance-capped", or null where
+ * a Xebra contract prices it on-chain (Stellar sources, EVM sources through Xebra's contract).
+ */
+ feeRule: z.string().nullable().optional().meta({
+ description:
+ "The fee rule that priced Xebra's fee (default, rebalance-capped), or null where a Xebra contract prices it on-chain.",
+ example: "default",
+ }),
})
.meta({ id: "Quote" });
@@ -170,6 +186,7 @@ export const TransferRequestSchema = z
maxTotalFee: AmountOutSchema.optional().meta({
description: "Refuse if fees have risen above this, typically the total you showed.",
}),
+ product: ProductSchema.optional(),
})
.meta({ id: "TransferRequest" });
diff --git a/packages/sdk/src/client/index.test.ts b/packages/sdk/src/client/index.test.ts
index f8cd7591..67f05883 100644
--- a/packages/sdk/src/client/index.test.ts
+++ b/packages/sdk/src/client/index.test.ts
@@ -60,6 +60,17 @@ describe("createXebraClient", () => {
);
});
+ it("sends the product, so a keyed rebalance can be priced as one", async () => {
+ const fetch = vi.fn(async () => json(200, {}));
+ const client = createXebraClient({ baseUrl: "https://example.test", apiKey: "k", fetch });
+ await client
+ .quote({ from: "base", to: "arbitrum", amount: "100000", product: "rebalance" })
+ .catch(() => {});
+ expect((fetch.mock.calls[0] as unknown as [string])[0]).toBe(
+ "https://example.test/v1/quote?from=base&to=arbitrum&amount=100000&product=rebalance",
+ );
+ });
+
it("turns a problem into an XebraApiError carrying its code and figures", async () => {
const client = createXebraClient({
fetch: async () => problem(422, "amount_above_maximum", { maximum: "100" }),
diff --git a/packages/sdk/src/client/index.ts b/packages/sdk/src/client/index.ts
index 48390bad..fd853774 100644
--- a/packages/sdk/src/client/index.ts
+++ b/packages/sdk/src/client/index.ts
@@ -381,7 +381,7 @@ export function createXebraClient(opts: XebraClientOptions = {}) {
quote: async (q: QuoteRequest, o?: XebraCallOptions): Promise => {
checkInput(QuoteRequestSchema, q);
return call(
- `/v1/quote?${query({ from: q.from, to: q.to, amount: q.amount, speed: q.speed, recipient: q.recipient })}`,
+ `/v1/quote?${query({ from: q.from, to: q.to, amount: q.amount, speed: q.speed, recipient: q.recipient, product: q.product })}`,
QuoteSchema,
passed(o),
);
diff --git a/packages/sdk/src/core/fees/flat.ts b/packages/sdk/src/core/fees/flat.ts
index 31e5082b..e0ce284a 100644
--- a/packages/sdk/src/core/fees/flat.ts
+++ b/packages/sdk/src/core/fees/flat.ts
@@ -9,8 +9,14 @@
*
* The Arc and Stellar contracts take their own fee and are not priced here.
* All amounts are 6-decimal USDC units.
+ *
+ * These figures are the fee table's default rule (`FEE_TABLE` in `table.ts`); `flatFeeFor` prices
+ * an ordinary transfer through it. A market maker's rebalance, with its API key, is priced by its
+ * own rule: call `priceFee` with the request's context instead.
*/
+import { amountForBurnUnder, feeRuleFor, priceFee } from "./table.js";
+
/** The fixed part of Xebra's fee, 0.01 USDC, by kind. */
export const XEBRA_FLAT_FEE = {
deliver: 10_000n,
@@ -39,8 +45,7 @@ export function flatFeeKind(destinationDomain: number): FlatFeeKind {
* fixed part alone.
*/
export function flatFeeFor(destinationDomain: number, amount = 0n): bigint {
- const pct = amount > 0n ? (amount * XEBRA_FEE_BPS) / 10_000n : 0n;
- return XEBRA_FLAT_FEE[flatFeeKind(destinationDomain)] + pct;
+ return priceFee(amount, { to: destinationDomain }).fee;
}
/**
@@ -48,10 +53,5 @@ export function flatFeeFor(destinationDomain: number, amount = 0n): bigint {
* is taken out of it. For minimums: `burn + 0.01` alone falls short by the 0.01% part.
*/
export function amountForBurn(destinationDomain: number, burn: bigint): bigint {
- const fixed = XEBRA_FLAT_FEE[flatFeeKind(destinationDomain)];
- let amount = ((burn + fixed) * 10_000n) / (10_000n - XEBRA_FEE_BPS);
- while (amount - flatFeeFor(destinationDomain, amount) < burn) amount += 1n;
- while (amount > 0n && amount - 1n - flatFeeFor(destinationDomain, amount - 1n) >= burn)
- amount -= 1n;
- return amount;
+ return amountForBurnUnder(feeRuleFor({ to: destinationDomain }), burn);
}
diff --git a/packages/sdk/src/core/fees/table.test.ts b/packages/sdk/src/core/fees/table.test.ts
new file mode 100644
index 00000000..25877298
--- /dev/null
+++ b/packages/sdk/src/core/fees/table.test.ts
@@ -0,0 +1,250 @@
+import { describe, expect, it } from "vitest";
+import { EVM_CHAINS } from "../chains/evm.js";
+import { CLAIM_ONLY_DOMAINS, XEBRA_FEE_BPS, XEBRA_FLAT_FEE, flatFeeFor } from "./flat.js";
+import {
+ DEFAULT_FEE_RULE_ID,
+ FEE_PRODUCTS,
+ FEE_TABLE,
+ type FeeContext,
+ type FeeRule,
+ amountForBurnUnder,
+ checkFeeTable,
+ feeRuleFor,
+ feeUnder,
+ priceFee,
+ withRebalancePartners,
+} from "./table.js";
+
+/** A small seeded generator, so a failure names amounts that can be run again. */
+function amounts(seed: number, n: number, max: bigint): bigint[] {
+ let x = seed >>> 0 || 1;
+ const next = () => {
+ x ^= x << 13;
+ x >>>= 0;
+ x ^= x >>> 17;
+ x ^= x << 5;
+ x >>>= 0;
+ return BigInt(x);
+ };
+ const out: bigint[] = [1n, 99n, 9_999n, 10_000n, 100_000n, 1_000_000n, max];
+ for (let i = 0; i < n; i++) {
+ // Spread over every magnitude, not only near `max`.
+ const digits = 1n + (next() % BigInt(max.toString().length));
+ out.push(1n + ((next() * 4_294_967_296n + next()) % 10n ** digits));
+ }
+ return out;
+}
+
+/** 10 million USDC, the largest transfer the Stellar side takes; amounts are 6-decimal units. */
+const MAX = 10_000_000_000_000n;
+const SAMPLE = amounts(297, 400, MAX);
+
+/** Every CCTP domain an off-contract route starts or ends on. */
+const DOMAINS = [
+ ...new Set([
+ ...Object.values(EVM_CHAINS).map((c) => c.cctpDomainId),
+ 5, // Solana
+ 8, // Sui
+ 9, // Aptos
+ 27, // Stellar
+ ...CLAIM_ONLY_DOMAINS,
+ ]),
+];
+
+/** Today's price, written out independently of the table: 0.01 plus 0.01%, rounded down. */
+const today = (amount: bigint) => 10_000n + amount / 10_000n;
+
+const PARTNER = "jd7abc123keyid";
+/** A key that is valid but not named as a market maker: an ordinary integrator. */
+const OTHER_KEY = "jd7zzz999otherkey";
+/** The table as the server builds it, with one market-maker key named. */
+const SERVER_TABLE = withRebalancePartners([PARTNER]);
+const CONTEXTS: FeeContext[] = FEE_PRODUCTS.flatMap((product) =>
+ [null, PARTNER, OTHER_KEY].map((partner) => ({ product, partner })),
+);
+
+describe("the fee table", () => {
+ it("is valid: one default, never free, rebalance only for named keys", () => {
+ expect(() => checkFeeTable(FEE_TABLE)).not.toThrow();
+ expect(() => checkFeeTable(SERVER_TABLE)).not.toThrow();
+ });
+
+ it("ships no market-maker price: the server names the keys", () => {
+ expect(FEE_TABLE.map((r) => r.id)).toEqual([DEFAULT_FEE_RULE_ID]);
+ expect(withRebalancePartners([])).toBe(FEE_TABLE);
+ expect(withRebalancePartners([" ", ""])).toBe(FEE_TABLE);
+ const two = withRebalancePartners([" a ", "b", "a"]);
+ expect(two.find((r) => r.id === "rebalance-capped")?.partners).toEqual(["a", "b"]);
+ });
+
+ it("its default rule is today's 0.01% + 0.01 USDC, the figures `flat.ts` names", () => {
+ const rule = feeRuleFor();
+ expect(rule.id).toBe(DEFAULT_FEE_RULE_ID);
+ expect(rule).toMatchObject({ bps: XEBRA_FEE_BPS, cap: null, min: 0n });
+ expect(rule.fixed).toBe(XEBRA_FLAT_FEE.deliver);
+ expect(rule.fixed).toBe(XEBRA_FLAT_FEE.claim);
+ });
+
+ it("refuses tables that would misprice", () => {
+ const base: FeeRule = { id: "default", bps: 1n, fixed: 10_000n, cap: null, min: 0n };
+ expect(() => checkFeeTable([])).toThrow(/default/);
+ expect(() => checkFeeTable([base, { ...base, id: "again" }])).toThrow(/earlier rule/);
+ expect(() => checkFeeTable([base, { ...base, to: 6 }, { ...base, to: 6 }])).toThrow(/twice/);
+ expect(() => checkFeeTable([{ ...base, fixed: 0n }])).toThrow(/free/);
+ expect(() => checkFeeTable([{ ...base, bps: 1_001n }])).toThrow(/10%/);
+ expect(() => checkFeeTable([base, { ...base, id: "r", product: "rebalance" }])).toThrow(
+ /naming the keys/,
+ );
+ expect(() =>
+ checkFeeTable([base, { ...base, id: "r", product: "rebalance", partners: [] }]),
+ ).toThrow(/naming the keys/);
+ });
+});
+
+describe("priceFee", () => {
+ it("reproduces today's numbers for every amount and every off-contract route", () => {
+ // Collected rather than asserted one by one: tens of thousands of cases.
+ const wrong: string[] = [];
+ for (const to of DOMAINS) {
+ for (const from of DOMAINS) {
+ if (from === to) continue;
+ for (const amount of SAMPLE.slice(0, 60)) {
+ for (const ctx of [
+ { from, to },
+ { from, to, product: "transfer" as const, partner: PARTNER },
+ ]) {
+ const p = priceFee(amount, ctx, SERVER_TABLE);
+ if (p.fee !== today(amount) || p.rule !== "default") {
+ wrong.push(`${JSON.stringify(ctx)} ${amount}: ${p.fee} by ${p.rule}`);
+ }
+ }
+ }
+ }
+ for (const amount of SAMPLE) {
+ if (flatFeeFor(to, amount) !== today(amount)) wrong.push(`flatFeeFor(${to}, ${amount})`);
+ }
+ if (flatFeeFor(to) !== 10_000n) wrong.push(`flatFeeFor(${to})`);
+ }
+ expect(wrong).toEqual([]);
+ });
+
+ it("a rebalance without a named market-maker key is priced as the default", () => {
+ for (const amount of SAMPLE) {
+ for (const partner of [null, OTHER_KEY]) {
+ expect(priceFee(amount, { product: "rebalance", partner }, SERVER_TABLE)).toEqual({
+ fee: today(amount),
+ rule: "default",
+ });
+ }
+ expect(priceFee(amount, { product: "rebalance" }, SERVER_TABLE)).toEqual(priceFee(amount));
+ // The shipped table names nobody, so even the market maker's key gets the default there.
+ expect(priceFee(amount, { product: "rebalance", partner: PARTNER })).toEqual(
+ priceFee(amount),
+ );
+ }
+ });
+
+ it("a rebalance with a named market-maker key: 0.01% capped at 2 USDC, plus 0.01", () => {
+ const rebalance = { product: "rebalance" as const, partner: PARTNER, from: 6, to: 3 };
+ const price = (amount: bigint) => priceFee(amount, rebalance, SERVER_TABLE);
+ // 100,000 USDC Base to Arbitrum: 2.01, not 10.01.
+ expect(price(100_000_000_000n)).toEqual({ fee: 2_010_000n, rule: "rebalance-capped" });
+ // 1,000 USDC: 0.11, as before.
+ expect(price(1_000_000_000n)).toEqual({ fee: 110_000n, rule: "rebalance-capped" });
+ // The cap starts to bite at 20,000 USDC.
+ expect(price(20_000_000_000n).fee).toBe(2_010_000n);
+ expect(price(19_999_990_000n).fee).toBe(2_009_999n);
+ expect(price(MAX).fee).toBe(2_010_000n);
+ // The same key sending an ordinary transfer pays the default.
+ expect(priceFee(MAX, { ...rebalance, product: "transfer" }, SERVER_TABLE).fee).toBe(today(MAX));
+ // Never dearer than the default, and never free.
+ for (const amount of SAMPLE) {
+ const fee = price(amount).fee;
+ expect(fee).toBeLessThanOrEqual(today(amount));
+ expect(fee).toBeGreaterThanOrEqual(10_000n);
+ }
+ });
+
+ it("never takes more than a tenth of any amount from 0.11 USDC, under every rule", () => {
+ for (const ctx of CONTEXTS) {
+ for (const amount of SAMPLE) {
+ if (amount < 110_000n) continue;
+ expect(priceFee(amount, ctx, SERVER_TABLE).fee * 10n).toBeLessThanOrEqual(amount);
+ }
+ }
+ });
+
+ it("every rule's cap always holds, its minimum too, and no rule is ever free", () => {
+ for (const rule of SERVER_TABLE) {
+ for (const amount of SAMPLE) {
+ const fee = feeUnder(rule, amount);
+ const ceiling = rule.fixed + (rule.cap ?? 0n);
+ if (rule.cap !== null)
+ expect(fee).toBeLessThanOrEqual(ceiling > rule.min ? ceiling : rule.min);
+ expect(fee).toBeGreaterThanOrEqual(rule.min);
+ expect(fee).toBeGreaterThan(0n);
+ // Each unit sent adds at most one unit of fee, which `amountForBurnUnder` relies on.
+ expect(feeUnder(rule, amount + 1n) - fee).toBeLessThanOrEqual(1n);
+ expect(feeUnder(rule, amount + 1n)).toBeGreaterThanOrEqual(fee);
+ }
+ }
+ });
+
+ it("picks the most specific matching rule, the earlier one on a tie", () => {
+ const table: FeeRule[] = [
+ { id: "default", bps: 1n, fixed: 10_000n, cap: null, min: 0n },
+ { id: "to-base", to: 6, bps: 2n, fixed: 10_000n, cap: null, min: 0n },
+ { id: "from-arb", from: 3, bps: 3n, fixed: 10_000n, cap: null, min: 0n },
+ {
+ id: "two-key-rebalance",
+ product: "rebalance",
+ partners: [PARTNER, "other"],
+ bps: 1n,
+ fixed: 10_000n,
+ cap: 1n,
+ min: 0n,
+ },
+ {
+ id: "one-key-rebalance-to-base",
+ product: "rebalance",
+ partners: [PARTNER],
+ to: 6,
+ bps: 1n,
+ fixed: 5_000n,
+ cap: 1n,
+ min: 0n,
+ },
+ ];
+ checkFeeTable(table);
+ expect(feeRuleFor({}, table).id).toBe("default");
+ expect(feeRuleFor({ to: 6 }, table).id).toBe("to-base");
+ // Two rules of one field each: the earlier wins.
+ expect(feeRuleFor({ from: 3, to: 6 }, table).id).toBe("to-base");
+ expect(feeRuleFor({ product: "rebalance", partner: "other" }, table).id).toBe(
+ "two-key-rebalance",
+ );
+ expect(feeRuleFor({ product: "rebalance", partner: "other", to: 6 }, table).id).toBe(
+ "two-key-rebalance",
+ );
+ expect(feeRuleFor({ product: "rebalance", partner: OTHER_KEY, to: 6 }, table).id).toBe(
+ "to-base",
+ );
+ expect(feeRuleFor({ product: "rebalance", partner: PARTNER, to: 6 }, table).id).toBe(
+ "one-key-rebalance-to-base",
+ );
+ expect(feeRuleFor({ product: "rebalance", partner: null, to: 6 }, table).id).toBe("to-base");
+ expect(() => feeRuleFor({}, table.slice(1))).toThrow(/default/);
+ });
+});
+
+describe("amountForBurnUnder", () => {
+ it("is the least amount that leaves at least the burn, under every rule", () => {
+ for (const rule of SERVER_TABLE) {
+ for (const burn of SAMPLE.slice(0, 150)) {
+ const a = amountForBurnUnder(rule, burn);
+ expect(a - feeUnder(rule, a)).toBeGreaterThanOrEqual(burn);
+ expect(a - 1n - feeUnder(rule, a - 1n)).toBeLessThan(burn);
+ }
+ }
+ });
+});
diff --git a/packages/sdk/src/core/fees/table.ts b/packages/sdk/src/core/fees/table.ts
new file mode 100644
index 00000000..a097fe89
--- /dev/null
+++ b/packages/sdk/src/core/fees/table.ts
@@ -0,0 +1,208 @@
+/**
+ * Xebra's fee table for the routes that run without a Xebra contract (EVM, Solana, Sui and Aptos
+ * sources), and the one function that prices a transfer from it. The `/v1` API and the page's own
+ * build routes both price through `priceFee`, on the server, so what a person is shown is what
+ * they sign.
+ *
+ * A rule matches on the product (`transfer` or `rebalance`), the caller's API key (`partners`),
+ * and the CCTP source and destination domains. A field a rule leaves out matches anything. The most
+ * specific matching rule wins; the default rule, which sets nothing, is today's 0.01% + 0.01 USDC.
+ *
+ * The Arc and Stellar contracts take their own fee on-chain and are not priced here.
+ * All amounts are 6-decimal USDC units.
+ */
+
+/** What a request is for. A rebalance is a market maker moving its own USDC between chains. */
+export type FeeProduct = "transfer" | "rebalance";
+
+export const FEE_PRODUCTS: readonly FeeProduct[] = ["transfer", "rebalance"];
+
+export interface FeeRule {
+ /** Named in the quote that this rule priced, so revenue can be read per rule. */
+ id: string;
+ /** Left out: any product. */
+ product?: FeeProduct;
+ /**
+ * Left out: any caller, with or without an API key. A list: only callers whose valid API key's
+ * id is on it. Keys are named one by one, so a price meant for market makers cannot be claimed by
+ * any other integrator who holds a key.
+ */
+ partners?: readonly string[];
+ /** CCTP domain the burn is made on. Left out: any. */
+ from?: number;
+ /** CCTP domain the USDC arrives on. Left out: any. */
+ to?: number;
+ /** The percentage part, in basis points of the amount: 1 is 0.01%. Rounded down. */
+ bps: bigint;
+ /** The fixed part, added to the percentage part. */
+ fixed: bigint;
+ /** The most the percentage part comes to, or null for no cap. The fixed part is on top. */
+ cap: bigint | null;
+ /** The least the whole fee comes to. */
+ min: bigint;
+}
+
+export const DEFAULT_FEE_RULE_ID = "default";
+export const REBALANCE_CAPPED_RULE_ID = "rebalance-capped";
+
+/**
+ * The table every caller is priced from. Changes go through review, with tests (`table.test.ts`).
+ * Every rule must keep the table valid (`checkFeeTable`): one default rule, never free, rebalance
+ * prices only for named keys. The market-maker price is added by the server for the keys it names
+ * (`withRebalancePartners`), so key ids never ship in this package.
+ */
+export const FEE_TABLE: readonly FeeRule[] = [
+ // Today's price for every transfer: 0.01% of the amount plus 0.01 USDC.
+ { id: DEFAULT_FEE_RULE_ID, bps: 1n, fixed: 10_000n, cap: null, min: 0n },
+];
+
+/**
+ * `table` plus the market-maker price for the API keys named in `keyIds`: a rebalance of the
+ * market maker's own USDC costs 0.01% capped at 2 USDC a move, plus the same 0.01. 100,000 USDC
+ * costs 2.01 instead of 10.01; 1,000 USDC costs 0.11 either way. With no keys named, nobody gets
+ * it and `table` comes back unchanged.
+ */
+export function withRebalancePartners(
+ keyIds: readonly string[],
+ table: readonly FeeRule[] = FEE_TABLE,
+): readonly FeeRule[] {
+ const partners = [...new Set(keyIds.map((k) => k.trim()).filter((k) => k !== ""))];
+ if (partners.length === 0) return table;
+ const out: readonly FeeRule[] = [
+ ...table,
+ {
+ id: REBALANCE_CAPPED_RULE_ID,
+ product: "rebalance",
+ partners,
+ bps: 1n,
+ fixed: 10_000n,
+ cap: 2_000_000n,
+ min: 0n,
+ },
+ ];
+ checkFeeTable(out);
+ return out;
+}
+
+/** Who is asking and for what. Everything left out is an ordinary transfer from anyone. */
+export interface FeeContext {
+ /** Default "transfer". */
+ product?: FeeProduct;
+ /** The id of the caller's valid API key, or null/absent without one. */
+ partner?: string | null;
+ from?: number;
+ to?: number;
+}
+
+export interface FeePrice {
+ /** Xebra's fee, in 6-decimal units. */
+ fee: bigint;
+ /** The id of the rule that priced it. */
+ rule: string;
+}
+
+function matches(rule: FeeRule, ctx: FeeContext): boolean {
+ if (rule.product !== undefined && rule.product !== (ctx.product ?? "transfer")) return false;
+ if (rule.partners !== undefined) {
+ const partner = ctx.partner ?? null;
+ if (partner === null || !rule.partners.includes(partner)) return false;
+ }
+ if (rule.from !== undefined && rule.from !== ctx.from) return false;
+ if (rule.to !== undefined && rule.to !== ctx.to) return false;
+ return true;
+}
+
+/** How specific a rule is: one point per field it sets, two for a list of named keys. */
+function specificity(rule: FeeRule): number {
+ return (
+ (rule.product !== undefined ? 1 : 0) +
+ (rule.partners === undefined ? 0 : 2) +
+ (rule.from !== undefined ? 1 : 0) +
+ (rule.to !== undefined ? 1 : 0)
+ );
+}
+
+/** The rule that prices `ctx`: the most specific match, the earlier one on a tie. */
+export function feeRuleFor(ctx: FeeContext = {}, table: readonly FeeRule[] = FEE_TABLE): FeeRule {
+ let best: FeeRule | null = null;
+ for (const rule of table) {
+ if (!matches(rule, ctx)) continue;
+ if (best === null || specificity(rule) > specificity(best)) best = rule;
+ }
+ if (!best) throw new Error("The fee table has no rule for this transfer: it needs a default.");
+ return best;
+}
+
+/** What one rule charges on `amount`. With no amount, the fixed part (or the minimum) alone. */
+export function feeUnder(rule: FeeRule, amount = 0n): bigint {
+ let pct = amount > 0n ? (amount * rule.bps) / 10_000n : 0n;
+ if (rule.cap !== null && pct > rule.cap) pct = rule.cap;
+ const fee = rule.fixed + pct;
+ return fee < rule.min ? rule.min : fee;
+}
+
+/**
+ * Xebra's fee for sending `amount` (what leaves the wallet), and the rule that priced it. The
+ * burn is the amount less this fee.
+ */
+export function priceFee(
+ amount: bigint,
+ ctx: FeeContext = {},
+ table: readonly FeeRule[] = FEE_TABLE,
+): FeePrice {
+ const rule = feeRuleFor(ctx, table);
+ return { fee: feeUnder(rule, amount), rule: rule.id };
+}
+
+/**
+ * The least amount to send under `rule` so that at least `burn` is left once the fee is taken out
+ * of it. `amount - fee` never falls as the amount rises (each unit adds at most one unit of fee),
+ * so a binary search finds it.
+ */
+export function amountForBurnUnder(rule: FeeRule, burn: bigint): bigint {
+ const left = (a: bigint) => a - feeUnder(rule, a);
+ let lo = burn > 0n ? burn : 0n;
+ if (left(lo) >= burn) return lo;
+ // Comfortably enough: the fee is at most fixed + min + a tenth (`checkFeeTable` bounds bps).
+ let hi = 2n * (lo + rule.fixed + rule.min) + 1n;
+ while (left(hi) < burn) hi *= 2n;
+ while (hi - lo > 1n) {
+ const mid = (lo + hi) / 2n;
+ if (left(mid) >= burn) hi = mid;
+ else lo = mid;
+ }
+ return hi;
+}
+
+/**
+ * Refuses a table that would price something wrong: no default rule (one that sets no match
+ * field), duplicate ids or match sets, a rule that could be free, a percentage over 10%, a negative
+ * figure, or a rebalance price that does not name the API keys it is for.
+ */
+export function checkFeeTable(table: readonly FeeRule[]): void {
+ const ids = new Set();
+ const shapes = new Set();
+ let defaults = 0;
+ for (const r of table) {
+ if (ids.has(r.id)) throw new Error(`Fee rule ${r.id} appears twice.`);
+ ids.add(r.id);
+ const shape = JSON.stringify([
+ r.product,
+ r.partners === undefined ? undefined : [...r.partners].sort(),
+ r.from,
+ r.to,
+ ]);
+ if (shapes.has(shape)) throw new Error(`Fee rule ${r.id} matches what an earlier rule does.`);
+ shapes.add(shape);
+ if (specificity(r) === 0) defaults += 1;
+ if (r.bps < 0n || r.fixed < 0n || r.min < 0n || (r.cap !== null && r.cap < 0n)) {
+ throw new Error(`Fee rule ${r.id} has a negative figure.`);
+ }
+ if (r.bps > 1_000n) throw new Error(`Fee rule ${r.id} takes more than 10%.`);
+ if (r.fixed <= 0n && r.min <= 0n) throw new Error(`Fee rule ${r.id} could be free.`);
+ if (r.product === "rebalance" && (r.partners === undefined || r.partners.length === 0)) {
+ throw new Error(`Fee rule ${r.id} prices rebalances without naming the keys it is for.`);
+ }
+ }
+ if (defaults !== 1) throw new Error("The fee table needs exactly one default rule.");
+}
diff --git a/packages/sdk/src/core/index.ts b/packages/sdk/src/core/index.ts
index da7a9d66..f66424c7 100644
--- a/packages/sdk/src/core/index.ts
+++ b/packages/sdk/src/core/index.ts
@@ -15,4 +15,5 @@ export * from "./deep-link.js";
export * from "./fees/evm.js";
export * from "./fees/flat.js";
export * from "./fees/stellar.js";
+export * from "./fees/table.js";
export * from "./tag.js";
diff --git a/packages/sdk/src/intents/index.ts b/packages/sdk/src/intents/index.ts
index af30dd06..2c394ae6 100644
--- a/packages/sdk/src/intents/index.ts
+++ b/packages/sdk/src/intents/index.ts
@@ -176,6 +176,11 @@ export interface DepositRequest {
amount: string;
/** Refuse to build if Xebra's and Circle's fees together exceed this decimal USDC amount. */
maxTotalFee?: string;
+ /**
+ * What the transfer is for. `createRebalancer` sends "rebalance", priced by the capped rule when
+ * the Xebra client carries an API key. Default: an ordinary transfer.
+ */
+ product?: "transfer" | "rebalance";
}
export function createIntentsRouter(opts: IntentsRouterOptions) {
@@ -248,6 +253,7 @@ export function createIntentsRouter(opts: IntentsRouterOptions) {
sender: r.sender,
recipient: r.depositAddress,
...(r.maxTotalFee !== undefined ? { maxTotalFee: r.maxTotalFee } : {}),
+ ...(r.product ? { product: r.product } : {}),
});
}
diff --git a/packages/sdk/src/intents/rebalance.test.ts b/packages/sdk/src/intents/rebalance.test.ts
index bb9bc9de..459c74b2 100644
--- a/packages/sdk/src/intents/rebalance.test.ts
+++ b/packages/sdk/src/intents/rebalance.test.ts
@@ -224,6 +224,24 @@ describe("estimate", () => {
for (const c of one.calls.filter((c) => c.path === "/v0/quote")) expect(c.body?.dry).toBe(true);
});
+ it("asks Xebra for the rebalance price and names the rule that priced it", async () => {
+ const one = fake1Click();
+ const x = fakeXebra();
+ x.quote.mockImplementation(async (q: { amount: string }) => ({
+ ...xebraQuote(q.amount),
+ feeRule: "rebalance-capped",
+ }));
+ const rb = createRebalancer({ xebra: x, fetch: one.fetch, now: () => NOW });
+ const e = await rb.estimate(REQ);
+ expect(x.quote).toHaveBeenCalledWith(
+ expect.objectContaining({ from: "base", to: "avalanche", product: "rebalance" }),
+ );
+ expect(e.feeRule).toBe("rebalance-capped");
+ // A server too old to name the rule: null, not a guess.
+ x.quote.mockImplementation(async (q: { amount: string }) => xebraQuote(q.amount));
+ expect((await rb.estimate(REQ)).feeRule).toBeNull();
+ });
+
it("says when one swap inside NEAR Intents leaves more", async () => {
const one = fake1Click({ directSwap: "99999990000" });
const rb = createRebalancer({ xebra: fakeXebra(), fetch: one.fetch, now: () => NOW });
@@ -423,7 +441,10 @@ describe("prepareDeposit", () => {
sender: REQ.fromWallet,
recipient: "0xdep",
maxTotalFee: "0.0625",
+ product: "rebalance",
});
+ // The quote it priced the burn from asked for the rebalance price too.
+ expect(x.quote).toHaveBeenCalledWith(expect.objectContaining({ product: "rebalance" }));
});
it("refuses when CCTP fees rose above the cap, before any deposit address is issued", async () => {
diff --git a/packages/sdk/src/intents/rebalance.ts b/packages/sdk/src/intents/rebalance.ts
index 97a37068..49b1d0d0 100644
--- a/packages/sdk/src/intents/rebalance.ts
+++ b/packages/sdk/src/intents/rebalance.ts
@@ -20,6 +20,11 @@
* The withdrawal is the one step that needs a 1Click partner API key (`generate-intent` and
* `submit-intent` are partner endpoints). Market makers onboarded through partners.near-intents.org
* have one; it is passed in and only ever sent to 1Click.
+ *
+ * Xebra prices the burn as a rebalance: every quote and build here says `product: "rebalance"`.
+ * With a Xebra market-maker API key on the client (`createXebraClient({ apiKey })`) that is 0.01%
+ * capped at 2 USDC a move, plus 0.01; without one, the ordinary 0.01% plus 0.01. `estimate` names the rule
+ * that priced it (`feeRule`).
*/
import type { TransferBuild, Quote as XebraQuote } from "../api/schemas.js";
@@ -49,7 +54,11 @@ export interface OneClickOptions {
}
export interface RebalancerOptions {
- /** A Xebra client (`createXebraClient()`). */
+ /**
+ * A Xebra client (`createXebraClient({ apiKey })`). A key Xebra has set up for market-maker
+ * rebalances earns the rebalance price: 0.01% capped at 2 USDC a move, plus 0.01. Without one,
+ * moves are priced as ordinary transfers.
+ */
xebra: Pick;
oneClick?: OneClickOptions;
fetch?: typeof fetch;
@@ -117,6 +126,11 @@ export interface RebalanceEstimate {
cctp: string;
total: string;
};
+ /**
+ * The Xebra fee rule that priced the CCTP leg: "rebalance-capped" when the client's market-maker
+ * key earned the rebalance price, "default" when it did not. Null from a server too old to say.
+ */
+ feeRule: string | null;
/** Rough seconds end to end: withdrawal plus CCTP plus deposit. */
seconds: number;
/**
@@ -459,6 +473,7 @@ export function createRebalancer(opts: RebalancerOptions) {
to,
amount: floorTo(amount, 6),
...(speed ? { speed } : {}),
+ product: "rebalance",
} as Parameters[0]);
}
@@ -517,6 +532,7 @@ export function createRebalancer(opts: RebalancerOptions) {
amount: r.amount,
arrives,
fees: { withdraw: withdrawFee, cctp: cctpFee, total: sub(r.amount, arrives) },
+ feeRule: x.feeRule ?? null,
seconds: w.timeEstimate + d.timeEstimate + (r.speed === "fast" ? 30 : 20 * 60),
direct,
better,
@@ -647,6 +663,7 @@ export function createRebalancer(opts: RebalancerOptions) {
sender: r.fromWallet,
amount: floorTo(amount, 6),
maxTotalFee: r.maxTotalFee ?? x.fees.total,
+ product: "rebalance",
});
return { depositAddress: q.depositAddress, quote: q, xebra: x, build };
}
From e4ccb123078309acb0922023bee093235f28f905 Mon Sep 17 00:00:00 2001
From: That guy <120946193+ezedike-evan@users.noreply.github.com>
Date: Thu, 26 Nov 2026 11:59:15 +0100
Subject: [PATCH 2/7] Arc wrapper: test every revert path; docs: remove_domain
is the kill switch (#304)
Adds eight tests to XebraCctpWrapper (computeSplit and quote refusals,
zero-address roles, unknown-domain tighten/remove, ceiling checks on
proposals, pending getters, and the solvency post-check with a token
that can seize). Branch coverage goes from 67.7% to 95.4%.
forwarding-wrapper.md called tighten_domain(forward=false) a kill switch,
but bridge still burns on the plain path with it off; the doc now points
to remove_domain or pause. GOVERNANCE.md said a higher min_fee is
stricter; tighten_params only accepts lower fees.
---
contracts/arc-evm/test/XebraCctpWrapper.t.sol | 109 ++++++++++++++++++
contracts/arc-evm/test/mocks/ClawbackUSDC.sol | 32 +++++
docs/GOVERNANCE.md | 7 +-
docs/forwarding-wrapper.md | 10 +-
4 files changed, 150 insertions(+), 8 deletions(-)
create mode 100644 contracts/arc-evm/test/mocks/ClawbackUSDC.sol
diff --git a/contracts/arc-evm/test/XebraCctpWrapper.t.sol b/contracts/arc-evm/test/XebraCctpWrapper.t.sol
index 5eed1ba2..32d03bb5 100644
--- a/contracts/arc-evm/test/XebraCctpWrapper.t.sol
+++ b/contracts/arc-evm/test/XebraCctpWrapper.t.sol
@@ -8,6 +8,7 @@ import {ITokenMessengerV2, XebraCctpWrapper} from "../src/XebraCctpWrapper.sol";
import {MockTokenMessengerV2, ReentrantTokenMessengerV2} from "./mocks/MockTokenMessengerV2.sol";
import {MockUSDC} from "./mocks/MockUSDC.sol";
import {ShortChangeUSDC} from "./mocks/ShortChangeUSDC.sol";
+import {ClawbackUSDC, SeizingTokenMessengerV2} from "./mocks/ClawbackUSDC.sol";
contract XebraCctpWrapperTest is Test {
uint32 internal constant ARC = 26;
@@ -609,6 +610,114 @@ contract XebraCctpWrapperTest is Test {
vm.stopPrank();
}
+ // ---------------------------------------------------------------------------------------------
+ // Edges the earlier tests left unexercised (audit prep, 2026-11-25)
+ // ---------------------------------------------------------------------------------------------
+
+ function test_computeSplitRefusesImpossibleInputs() public {
+ vm.expectRevert(XebraCctpWrapper.AmountNotPositive.selector);
+ wrapper.computeSplit(0, 10, 300_000, 100_000);
+ vm.expectRevert(XebraCctpWrapper.FeeBpsTooHigh.selector);
+ wrapper.computeSplit(1_000_000, 101, 300_000, 100_000);
+ vm.expectRevert(XebraCctpWrapper.MinFeeTooHigh.selector);
+ wrapper.computeSplit(10_000_000, 10, 5_000_001, 100_000);
+ vm.expectRevert(XebraCctpWrapper.ForwardFeeZero.selector);
+ wrapper.computeSplit(1_000_000, 10, 300_000, 0);
+ // The floor alone would take the whole amount.
+ vm.expectRevert(XebraCctpWrapper.MaxFeeExceedsNet.selector);
+ wrapper.computeSplit(1_000_000, 10, 1_000_000, 100_000);
+ }
+
+ function test_quoteRefusesWhatBridgeRefuses() public {
+ vm.expectRevert(XebraCctpWrapper.AmountBelowMin.selector);
+ wrapper.quote(999_999, BASE, 100_000, 2000, false);
+ vm.expectRevert(XebraCctpWrapper.AmountAboveMax.selector);
+ wrapper.quote(100_000_001, BASE, 100_000, 2000, false);
+ vm.expectRevert(XebraCctpWrapper.DomainNotAllowed.selector);
+ wrapper.quote(10_000_000, POLYGON, 100_000, 2000, false);
+ vm.expectRevert(XebraCctpWrapper.BadFinalityThreshold.selector);
+ wrapper.quote(10_000_000, BASE, 100_000, 1500, false);
+ vm.expectRevert(XebraCctpWrapper.RecipientOwnerUnexpected.selector);
+ wrapper.quote(10_000_000, BASE, 100_000, 2000, true);
+ }
+
+ function test_refusesZeroAddressesForEveryRole() public {
+ vm.startPrank(admin);
+ vm.expectRevert(XebraCctpWrapper.ZeroAddress.selector);
+ wrapper.proposeAdmin(address(0));
+ vm.expectRevert(XebraCctpWrapper.ZeroAddress.selector);
+ wrapper.proposePauser(address(0));
+ vm.expectRevert(XebraCctpWrapper.ZeroAddress.selector);
+ wrapper.proposeFeeRecipient(address(0));
+ vm.stopPrank();
+ }
+
+ function test_tightenAndRemoveNeedAListedDomain() public {
+ vm.startPrank(pauser);
+ vm.expectRevert(XebraCctpWrapper.DomainNotAllowed.selector);
+ wrapper.tightenDomain(POLYGON, 100_000, false, 0);
+ vm.expectRevert(XebraCctpWrapper.DomainNotAllowed.selector);
+ wrapper.removeDomain(POLYGON);
+ vm.stopPrank();
+ }
+
+ function test_refusesAnAccountCapAboveTheCeiling() public {
+ XebraCctpWrapper.DomainCfg memory cfg = solanaCfg();
+ cfg.maxForwardFeeNewAccount = wrapper.MAX_FORWARD_FEE_CEILING() + 1;
+ vm.prank(admin);
+ vm.expectRevert(XebraCctpWrapper.BadForwardConfig.selector);
+ wrapper.proposeDomain(cfg);
+ }
+
+ function test_proposedParamsMeetEveryCeiling() public {
+ XebraCctpWrapper.Params memory p = params();
+ vm.startPrank(admin);
+ p.minFee = wrapper.MAX_MIN_FEE_CEILING() + 1;
+ vm.expectRevert(XebraCctpWrapper.MinFeeTooHigh.selector);
+ wrapper.proposeParams(p);
+ p = params();
+ p.maxTransfer = wrapper.MAX_TRANSFER_CEILING() + 1;
+ vm.expectRevert(XebraCctpWrapper.MaxTransferTooHigh.selector);
+ wrapper.proposeParams(p);
+ p = params();
+ p.minTransfer = p.maxTransfer;
+ vm.expectRevert(XebraCctpWrapper.BadTransferRange.selector);
+ wrapper.proposeParams(p);
+ vm.stopPrank();
+ }
+
+ function test_pendingChangesAreReadable() public {
+ address next = makeAddr("next");
+ vm.startPrank(admin);
+ uint64 eta = wrapper.proposeAdmin(next);
+ wrapper.proposePauser(next);
+ wrapper.proposeFeeRecipient(next);
+ XebraCctpWrapper.DomainCfg memory cfg = baseCfg();
+ cfg.domain = POLYGON;
+ wrapper.proposeDomain(cfg);
+ vm.stopPrank();
+ assertEq(wrapper.pendingAdmin().addr, next);
+ assertEq(wrapper.pendingAdmin().eta, eta);
+ assertEq(wrapper.pendingPauser().addr, next);
+ assertEq(wrapper.pendingFeeRecipient().addr, next);
+ assertEq(wrapper.pendingDomain().cfg.domain, POLYGON);
+ assertEq(wrapper.pendingDomain().eta, eta);
+ }
+
+ /// Circle's FiatToken cannot seize, but if any token ever took USDC from the wrapper during a
+ /// burn, the wrapper must refuse rather than carry on owing more than it holds.
+ function test_failsClosedIfItsBalanceDropsBelowWhatItOwes() public {
+ ClawbackUSDC token = new ClawbackUSDC();
+ SeizingTokenMessengerV2 tm = new SeizingTokenMessengerV2(ARC);
+ XebraCctpWrapper w = deploy(IERC20(address(token)), ITokenMessengerV2(address(tm)));
+ token.mint(user, 100_000_000);
+ vm.startPrank(user);
+ token.approve(address(w), type(uint256).max);
+ vm.expectRevert(XebraCctpWrapper.InvariantViolated.selector);
+ w.bridge(req(10_000_000, BASE, evmRecipient, 100_000));
+ vm.stopPrank();
+ }
+
// ---------------------------------------------------------------------------------------------
// Properties
// ---------------------------------------------------------------------------------------------
diff --git a/contracts/arc-evm/test/mocks/ClawbackUSDC.sol b/contracts/arc-evm/test/mocks/ClawbackUSDC.sol
new file mode 100644
index 00000000..fcf0c912
--- /dev/null
+++ b/contracts/arc-evm/test/mocks/ClawbackUSDC.sol
@@ -0,0 +1,32 @@
+// SPDX-License-Identifier: MIT
+pragma solidity 0.8.26;
+
+import {MockUSDC} from "./MockUSDC.sol";
+import {MockTokenMessengerV2} from "./MockTokenMessengerV2.sol";
+
+/// @notice A USDC whose issuer can take tokens from any holder. Real Circle FiatToken cannot; this
+/// exists only to prove the wrapper fails closed if its balance ever drops below what it owes.
+contract ClawbackUSDC is MockUSDC {
+ function seize(address from, uint256 amount) external {
+ _burn(from, amount);
+ }
+}
+
+/// @notice Burns as Circle does, then has the token take one unit from the wrapper mid-transaction.
+contract SeizingTokenMessengerV2 is MockTokenMessengerV2 {
+ constructor(uint32 localDomain_) MockTokenMessengerV2(localDomain_) {}
+
+ function depositForBurnWithHook(
+ uint256 amount,
+ uint32,
+ bytes32,
+ address burnToken,
+ bytes32,
+ uint256,
+ uint32,
+ bytes calldata
+ ) external override {
+ ClawbackUSDC(burnToken).transferFrom(msg.sender, MINTER, amount);
+ ClawbackUSDC(burnToken).seize(msg.sender, 1);
+ }
+}
diff --git a/docs/GOVERNANCE.md b/docs/GOVERNANCE.md
index 0c070433..93ced092 100644
--- a/docs/GOVERNANCE.md
+++ b/docs/GOVERNANCE.md
@@ -34,9 +34,10 @@ Every admin action except pausing follows the same two-step, 48-hour pattern
`cancel_pending` lets `ADMIN` or `PAUSER` withdraw every pending proposal before it commits.
`tighten_params` and `tighten_domain` are the exceptions: they can only make limits *stricter*
-(lower `max_transfer`, higher `min_fee`, forwarding off, a lower forward-fee cap, etc.), never looser,
-so they skip the timelock — a safety ratchet, not a bypass. `remove_domain` is instant for the same
-reason.
+(a lower `max_transfer`, a higher `min_transfer`, a lower `fee_bps`, `min_fee` or `account_fee`, a lower
+forward-fee cap, forwarding off, etc.), never looser, so they skip the timelock — a safety ratchet,
+not a bypass. A lower fee counts as stricter because it can only cost the sender less, which is what
+the timelock protects. `remove_domain` is instant for the same reason.
**Pausing is immediate and untimelocked, on purpose.** `pause(caller)` checks `caller` is either
`ADMIN` or `PAUSER` and takes effect in the same transaction. Everything else that is not a
diff --git a/docs/forwarding-wrapper.md b/docs/forwarding-wrapper.md
index 2f1b02c2..71fb02dd 100644
--- a/docs/forwarding-wrapper.md
+++ b/docs/forwarding-wrapper.md
@@ -160,10 +160,10 @@ $1.13, live Iris quotes).
- `tighten_domain(caller, domain, forward, max_forward_fee, account_creation,
max_forward_fee_new_account)`: instant, admin **or pauser**, may only turn things off or lower a cap,
never the reverse. Account creation rides on forwarding, so turning `forward` off turns it off too
- and zeroes its cap: the kill switch is one call and cannot leave a half-configured domain. This is
- the switch if Circle's service misbehaves or the hook format changes: forwarding
- stops, and new transfers on that domain must be refused by the web app until it is turned back on
- (they would burn with nobody to mint them).
+ and zeroes its cap, which cannot leave a half-configured domain. **It is not a kill switch:** with
+ `forward` off, `bridge` still accepts transfers to that domain and burns them on the plain path,
+ which nobody mints, so each recipient has to claim at `/claim`. To stop transfers to a domain,
+ use `remove_domain` (admin or pauser, instant) or `pause`.
## Failure modes
@@ -171,7 +171,7 @@ $1.13, live Iris quotes).
|---|---|---|
| `M` below Circle's requirement (quote moved) | Iris `FAILED / INSUFFICIENT_FEE`, no fee, unminted | owner claims at `/claim` |
| Circle's forwarder is down or slow | burn attested, unminted | owner claims at `/claim` |
-| Circle changes the hook format | forwards fail like the above | `tighten_domain(forward=false)` stops new transfers; owners of affected ones claim |
+| Circle changes the hook format | forwards fail like the above | `remove_domain` (or `pause`) stops new transfers; owners of affected ones claim |
| Owner and Circle both mint the same message | second reverts on `used_nonce`, costs ~1 cent | none needed |
| User overpays `M` | recipient pays the difference | bounded by the caps above |
From 259a0467a95472a85ae9a9bd1c95253f7b2740a2 Mon Sep 17 00:00:00 2001
From: That guy <120946193+ezedike-evan@users.noreply.github.com>
Date: Thu, 26 Nov 2026 14:06:30 +0100
Subject: [PATCH 3/7] Web: hide "Not enough USDC" once the transfer is sent
(#305)
After a burn the form re-reads the wallet balance, which the burn just
spent, while the quote or amount stays. The shortfall notice then showed
under the "Burn submitted" receipt (0.00 held, 8.00 short). Hide it once
a transfer has gone out, like the Circle health notices already do. Same
fix in the Stellar and EVM forms.
---
apps/web/components/bridge/evm-bridge-form.tsx | 4 +++-
apps/web/components/bridge/stellar-bridge-form.tsx | 4 +++-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/apps/web/components/bridge/evm-bridge-form.tsx b/apps/web/components/bridge/evm-bridge-form.tsx
index e9640ec2..1bf61728 100644
--- a/apps/web/components/bridge/evm-bridge-form.tsx
+++ b/apps/web/components/bridge/evm-bridge-form.tsx
@@ -865,7 +865,9 @@ export function EvmBridgeForm({
destinationName={dest.name}
/>
- {short && balance !== null && amount !== null && (
+ {/* After a send the balance re-reads lower (the burn spent it) while the amount stays, so
+ the shortfall must not show under the receipt. */}
+ {!txHash && short && balance !== null && amount !== null && (
This wallet holds {formatUsdc6(balance)} USDC on{" "}
{source.name}
diff --git a/apps/web/components/bridge/stellar-bridge-form.tsx b/apps/web/components/bridge/stellar-bridge-form.tsx
index 11cc94d5..7508be71 100644
--- a/apps/web/components/bridge/stellar-bridge-form.tsx
+++ b/apps/web/components/bridge/stellar-bridge-form.tsx
@@ -1275,7 +1275,9 @@ export function StellarBridgeForm({
claimOnly={dest.claimOnly}
/>
- {shortfall !== null && (
+ {/* After a send the balance re-reads lower (the burn spent it) while the quote stays, so
+ the shortfall must not show under the receipt. */}
+ {!txHash && shortfall !== null && (
This wallet holds {formatUsdc(balance ?? 0n)} USDC, and
this transfer needs {formatUsdc(quote?.amount ?? 0n)}{" "}
From b7f0948b9b31bf8682fcc1771e31a3e564a8e336 Mon Sep 17 00:00:00 2001
From: That guy <120946193+ezedike-evan@users.noreply.github.com>
Date: Thu, 26 Nov 2026 15:09:47 +0100
Subject: [PATCH 4/7] Stellar batch router: many transfers in one signature,
all or nothing (#306)
* Stellar batch router: many transfers in one signature, all or nothing
A Soroban contract that takes a list of transfers and calls the live v2
wrapper's bridge for each, under one auth. If any transfer fails, the
whole batch reverts. No admin and no state beyond the wrapper address.
Limit is 5 transfers per transaction: Soroban's 16,384-byte events
budget, which the return value also counts toward. simulateTransaction
does not enforce it (6 simulated fine and then failed on chain).
Tests run against the mainnet v2 wrapper WASM in wasm/ and are added to
CI. Proven on testnet, including one 5-chain batch (Arc, Base,
Avalanche, Optimism, Solana) delivered on every chain.
Not deployed to mainnet. No site or SDK support yet.
* Batch router script: drop an unused import, format
---
.github/workflows/ci.yml | 4 +
.gitignore | 2 +
contracts/stellar-batch-router/Cargo.lock | 2121 +++++++++++++++++
contracts/stellar-batch-router/Cargo.toml | 25 +
contracts/stellar-batch-router/README.md | 74 +
contracts/stellar-batch-router/src/lib.rs | 155 ++
contracts/stellar-batch-router/src/test.rs | 500 ++++
.../wasm/xebra_cctp_wrapper_v2_mainnet.wasm | Bin 0 -> 57448 bytes
scripts/batch-router-testnet.mjs | 226 ++
9 files changed, 3107 insertions(+)
create mode 100644 contracts/stellar-batch-router/Cargo.lock
create mode 100644 contracts/stellar-batch-router/Cargo.toml
create mode 100644 contracts/stellar-batch-router/README.md
create mode 100644 contracts/stellar-batch-router/src/lib.rs
create mode 100644 contracts/stellar-batch-router/src/test.rs
create mode 100644 contracts/stellar-batch-router/wasm/xebra_cctp_wrapper_v2_mainnet.wasm
create mode 100644 scripts/batch-router-testnet.mjs
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 84f939a4..2cd04e2d 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -107,6 +107,7 @@ jobs:
workspaces: |
contracts/stellar-cctp-wrapper -> target
contracts/stellar-cctp-wrapper-v2 -> target
+ contracts/stellar-batch-router -> target
# v1 is the retired wrapper; v2 below inherits its suite. These tests cover the fee
# arithmetic, the parameter ceilings a compromised admin cannot exceed, and the no-hang
@@ -115,6 +116,9 @@ jobs:
# v2 is the forwarding wrapper (docs/forwarding-wrapper.md), live on mainnet. It inherits v1's
# suite and adds the tests that bound the one new risk: Circle charges the whole `max_fee`.
- run: cargo test --manifest-path contracts/stellar-cctp-wrapper-v2/Cargo.toml
+ # Batch router: many transfers through the v2 wrapper in one signature, all or nothing. Runs
+ # against the wrapper WASM fetched from mainnet (contracts/stellar-batch-router/wasm/).
+ - run: cargo test --manifest-path contracts/stellar-batch-router/Cargo.toml
- run: cargo test --manifest-path contracts/stellar-soroban/Cargo.toml
evm:
diff --git a/.gitignore b/.gitignore
index 17b42bc5..0c8cd722 100644
--- a/.gitignore
+++ b/.gitignore
@@ -46,6 +46,8 @@ contracts/stellar-cctp-wrapper/target/
contracts/stellar-cctp-wrapper/test_snapshots/
contracts/stellar-cctp-wrapper-v2/target/
contracts/stellar-cctp-wrapper-v2/test_snapshots/
+contracts/stellar-batch-router/target/
+contracts/stellar-batch-router/test_snapshots/
# solana
test-ledger/
diff --git a/contracts/stellar-batch-router/Cargo.lock b/contracts/stellar-batch-router/Cargo.lock
new file mode 100644
index 00000000..6fbb6f7c
--- /dev/null
+++ b/contracts/stellar-batch-router/Cargo.lock
@@ -0,0 +1,2121 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+version = 4
+
+[[package]]
+name = "ahash"
+version = "0.8.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5a15f179cd60c4584b8a8c596927aadc462e27f2ca70c04e0071964a73ba7a75"
+dependencies = [
+ "cfg-if",
+ "once_cell",
+ "version_check",
+ "zerocopy",
+]
+
+[[package]]
+name = "allocator-api2"
+version = "0.2.21"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923"
+
+[[package]]
+name = "android_system_properties"
+version = "0.1.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ae221649c9976a6f6c56ae1facf410f3ddb33cc661c4b7b61020a912d4237fbc"
+dependencies = [
+ "libc",
+]
+
+[[package]]
+name = "arbitrary"
+version = "1.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7d5a26814d8dcb93b0e5a0ff3c6d80a8843bafb21b39e8e18a6f05471870e110"
+dependencies = [
+ "derive_arbitrary",
+]
+
+[[package]]
+name = "ark-bls12-381"
+version = "0.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3df4dcc01ff89867cd86b0da835f23c3f02738353aaee7dde7495af71363b8d5"
+dependencies = [
+ "ark-ec",
+ "ark-ff",
+ "ark-serialize",
+ "ark-std",
+]
+
+[[package]]
+name = "ark-bn254"
+version = "0.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d69eab57e8d2663efa5c63135b2af4f396d66424f88954c21104125ab6b3e6bc"
+dependencies = [
+ "ark-ec",
+ "ark-ff",
+ "ark-std",
+]
+
+[[package]]
+name = "ark-ec"
+version = "0.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "43d68f2d516162846c1238e755a7c4d131b892b70cc70c471a8e3ca3ed818fce"
+dependencies = [
+ "ahash",
+ "ark-ff",
+ "ark-poly",
+ "ark-serialize",
+ "ark-std",
+ "educe",
+ "fnv",
+ "hashbrown 0.15.5",
+ "itertools",
+ "num-bigint",
+ "num-integer",
+ "num-traits",
+ "zeroize",
+]
+
+[[package]]
+name = "ark-ff"
+version = "0.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a177aba0ed1e0fbb62aa9f6d0502e9b46dad8c2eab04c14258a1212d2557ea70"
+dependencies = [
+ "ark-ff-asm",
+ "ark-ff-macros",
+ "ark-serialize",
+ "ark-std",
+ "arrayvec",
+ "digest 0.10.7",
+ "educe",
+ "itertools",
+ "num-bigint",
+ "num-traits",
+ "paste",
+ "zeroize",
+]
+
+[[package]]
+name = "ark-ff-asm"
+version = "0.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "62945a2f7e6de02a31fe400aa489f0e0f5b2502e69f95f853adb82a96c7a6b60"
+dependencies = [
+ "quote",
+ "syn 2.0.119",
+]
+
+[[package]]
+name = "ark-ff-macros"
+version = "0.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "09be120733ee33f7693ceaa202ca41accd5653b779563608f1234f78ae07c4b3"
+dependencies = [
+ "num-bigint",
+ "num-traits",
+ "proc-macro2",
+ "quote",
+ "syn 2.0.119",
+]
+
+[[package]]
+name = "ark-poly"
+version = "0.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "579305839da207f02b89cd1679e50e67b4331e2f9294a57693e5051b7703fe27"
+dependencies = [
+ "ahash",
+ "ark-ff",
+ "ark-serialize",
+ "ark-std",
+ "educe",
+ "fnv",
+ "hashbrown 0.15.5",
+]
+
+[[package]]
+name = "ark-serialize"
+version = "0.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3f4d068aaf107ebcd7dfb52bc748f8030e0fc930ac8e360146ca54c1203088f7"
+dependencies = [
+ "ark-serialize-derive",
+ "ark-std",
+ "arrayvec",
+ "digest 0.10.7",
+ "num-bigint",
+]
+
+[[package]]
+name = "ark-serialize-derive"
+version = "0.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "213888f660fddcca0d257e88e54ac05bca01885f258ccdf695bafd77031bb69d"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.119",
+]
+
+[[package]]
+name = "ark-std"
+version = "0.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "246a225cc6131e9ee4f24619af0f19d67761fff15d7ccc22e42b80846e69449a"
+dependencies = [
+ "num-traits",
+ "rand",
+]
+
+[[package]]
+name = "arrayvec"
+version = "0.7.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d3fb67a6e08acf24fdeccbac2cb6ac4305825bd1f117462e0e6f2f193345ad56"
+
+[[package]]
+name = "autocfg"
+version = "1.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53"
+
+[[package]]
+name = "base16ct"
+version = "0.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf"
+
+[[package]]
+name = "base64"
+version = "0.22.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
+
+[[package]]
+name = "base64ct"
+version = "1.8.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2af50177e190e07a26ab74f8b1efbfe2ef87da2116221318cb1c2e82baf7de06"
+
+[[package]]
+name = "bitflags"
+version = "1.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
+
+[[package]]
+name = "block-buffer"
+version = "0.10.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71"
+dependencies = [
+ "generic-array",
+]
+
+[[package]]
+name = "block-buffer"
+version = "0.12.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d2f6c7dbe95a6ed67ad9f18e57daf93a2f034c524b99fd2b76d18fdfeb6660aa"
+dependencies = [
+ "hybrid-array",
+]
+
+[[package]]
+name = "bs58"
+version = "0.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bf88ba1141d185c399bee5288d850d63b8369520c1eafc32a0430b5b6c287bf4"
+dependencies = [
+ "tinyvec",
+]
+
+[[package]]
+name = "bumpalo"
+version = "3.20.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649"
+
+[[package]]
+name = "byteorder"
+version = "1.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
+
+[[package]]
+name = "bytes-lit"
+version = "0.0.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9b04f2b1d34cb428043f14aa4c853d14294532e8bbde3b6a3bc2faaaae31a1dd"
+dependencies = [
+ "num-bigint",
+ "proc-macro2",
+ "quote",
+ "syn 2.0.119",
+]
+
+[[package]]
+name = "cc"
+version = "1.4.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "005ec2760ca554fae18df7a11195552ec576cd665632a881bc011d5bb2fd4d80"
+dependencies = [
+ "find-msvc-tools",
+ "shlex",
+]
+
+[[package]]
+name = "cfg-if"
+version = "1.0.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
+
+[[package]]
+name = "cfg_eval"
+version = "0.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "45565fc9416b9896014f5732ac776f810ee53a66730c17e4020c3ec064a8f88f"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.119",
+]
+
+[[package]]
+name = "chrono"
+version = "0.4.45"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1aa79e62e7697b8e29b513a68abacf485adcd1fe8284a4316c5ae868e6633327"
+dependencies = [
+ "iana-time-zone",
+ "num-traits",
+ "serde",
+ "windows-link",
+]
+
+[[package]]
+name = "const-oid"
+version = "0.9.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8"
+
+[[package]]
+name = "core-foundation-sys"
+version = "0.8.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b"
+
+[[package]]
+name = "cpufeatures"
+version = "0.2.17"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280"
+dependencies = [
+ "libc",
+]
+
+[[package]]
+name = "cpufeatures"
+version = "0.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5ca28b0ae3115b884660db4118d803791fd6756b6e88f39c0f3f7859060d7566"
+dependencies = [
+ "libc",
+]
+
+[[package]]
+name = "crate-git-revision"
+version = "0.0.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c521bf1f43d31ed2f73441775ed31935d77901cb3451e44b38a1c1612fcbaf98"
+dependencies = [
+ "serde",
+ "serde_derive",
+ "serde_json",
+]
+
+[[package]]
+name = "crate-git-revision"
+version = "0.0.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "54851b5b3f24621804b1cded2820975623c205e3055d2d44031cdb1237339ac8"
+dependencies = [
+ "serde",
+ "serde_derive",
+ "serde_json",
+]
+
+[[package]]
+name = "crypto-bigint"
+version = "0.5.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76"
+dependencies = [
+ "generic-array",
+ "rand_core",
+ "subtle",
+ "zeroize",
+]
+
+[[package]]
+name = "crypto-common"
+version = "0.1.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3"
+dependencies = [
+ "generic-array",
+ "typenum",
+]
+
+[[package]]
+name = "crypto-common"
+version = "0.2.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ce6e4c961d6cd6c9a86db418387425e8bdeaf05b3c8bc1411e6dca4c252f1453"
+dependencies = [
+ "hybrid-array",
+]
+
+[[package]]
+name = "ctor"
+version = "0.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "67773048316103656a637612c4a62477603b777d91d9c62ff2290f9cde178fdb"
+dependencies = [
+ "ctor-proc-macro",
+ "dtor",
+]
+
+[[package]]
+name = "ctor-proc-macro"
+version = "0.0.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e2931af7e13dc045d8e9d26afccc6fa115d64e115c9c84b1166288b46f6782c2"
+
+[[package]]
+name = "curve25519-dalek"
+version = "4.1.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "97fb8b7c4503de7d6ae7b42ab72a5a59857b4c937ec27a3d4539dba95b5ab2be"
+dependencies = [
+ "cfg-if",
+ "cpufeatures 0.2.17",
+ "curve25519-dalek-derive",
+ "digest 0.10.7",
+ "fiat-crypto 0.2.9",
+ "rustc_version",
+ "subtle",
+ "zeroize",
+]
+
+[[package]]
+name = "curve25519-dalek"
+version = "5.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b5eed333089e2e1c1ac8c6c0398e5e2497b4c9926ca6d0365ed1e099afa5bc23"
+dependencies = [
+ "cfg-if",
+ "cpufeatures 0.3.1",
+ "curve25519-dalek-derive",
+ "digest 0.11.3",
+ "fiat-crypto 0.3.0",
+ "rustc_version",
+ "subtle",
+]
+
+[[package]]
+name = "curve25519-dalek-derive"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.119",
+]
+
+[[package]]
+name = "darling"
+version = "0.20.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fc7f46116c46ff9ab3eb1597a45688b6715c6e628b5c133e288e709a29bcb4ee"
+dependencies = [
+ "darling_core 0.20.11",
+ "darling_macro 0.20.11",
+]
+
+[[package]]
+name = "darling"
+version = "0.23.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "25ae13da2f202d56bd7f91c25fba009e7717a1e4a1cc98a76d844b65ae912e9d"
+dependencies = [
+ "darling_core 0.23.0",
+ "darling_macro 0.23.0",
+]
+
+[[package]]
+name = "darling_core"
+version = "0.20.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0d00b9596d185e565c2207a0b01f8bd1a135483d02d9b7b0a54b11da8d53412e"
+dependencies = [
+ "fnv",
+ "ident_case",
+ "proc-macro2",
+ "quote",
+ "strsim",
+ "syn 2.0.119",
+]
+
+[[package]]
+name = "darling_core"
+version = "0.23.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9865a50f7c335f53564bb694ef660825eb8610e0a53d3e11bf1b0d3df31e03b0"
+dependencies = [
+ "ident_case",
+ "proc-macro2",
+ "quote",
+ "strsim",
+ "syn 2.0.119",
+]
+
+[[package]]
+name = "darling_macro"
+version = "0.20.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fc34b93ccb385b40dc71c6fceac4b2ad23662c7eeb248cf10d529b7e055b6ead"
+dependencies = [
+ "darling_core 0.20.11",
+ "quote",
+ "syn 2.0.119",
+]
+
+[[package]]
+name = "darling_macro"
+version = "0.23.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ac3984ec7bd6cfa798e62b4a642426a5be0e68f9401cfc2a01e3fa9ea2fcdb8d"
+dependencies = [
+ "darling_core 0.23.0",
+ "quote",
+ "syn 2.0.119",
+]
+
+[[package]]
+name = "data-encoding"
+version = "2.11.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4583a4551df46e2792f82ceeac45e850d2e2d5debba0b91f102385cda5b11f06"
+
+[[package]]
+name = "defmt"
+version = "1.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e2953bfe4f93bbd20cc71198842756f77d161884c99ebbabc41d80231ded88d1"
+dependencies = [
+ "bitflags",
+ "defmt-macros",
+]
+
+[[package]]
+name = "defmt-macros"
+version = "1.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bad9c72e7ca2137e0dc3813245a0d282fd6daad32fd800af018306a9169b5fe8"
+dependencies = [
+ "defmt-parser",
+ "proc-macro2",
+ "quote",
+ "syn 2.0.119",
+]
+
+[[package]]
+name = "defmt-parser"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "10d60334b3b2e7c9d91ef8150abfb6fa4c1c39ebbcf4a81c2e346aad939fee3e"
+dependencies = [
+ "thiserror 2.0.20",
+]
+
+[[package]]
+name = "der"
+version = "0.7.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e7c1832837b905bbfb5101e07cc24c8deddf52f93225eee6ead5f4d63d53ddcb"
+dependencies = [
+ "const-oid",
+ "zeroize",
+]
+
+[[package]]
+name = "deranged"
+version = "0.5.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7cd812cc2bc1d69d4764bd80df88b4317eaef9e773c75226407d9bc0876b211c"
+dependencies = [
+ "serde_core",
+]
+
+[[package]]
+name = "derive_arbitrary"
+version = "1.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.119",
+]
+
+[[package]]
+name = "digest"
+version = "0.10.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292"
+dependencies = [
+ "block-buffer 0.10.4",
+ "const-oid",
+ "crypto-common 0.1.6",
+ "subtle",
+]
+
+[[package]]
+name = "digest"
+version = "0.11.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f1dd6dbb5841937940781866fa1281a1ff7bd3bf827091440879f9994983d5c2"
+dependencies = [
+ "block-buffer 0.12.1",
+ "crypto-common 0.2.2",
+]
+
+[[package]]
+name = "downcast-rs"
+version = "1.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "75b325c5dbd37f80359721ad39aca5a29fb04c89279657cffdda8736d0c0b9d2"
+
+[[package]]
+name = "dtor"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "404d02eeb088a82cfd873006cb713fe411306c7d182c344905e101fb1167d301"
+dependencies = [
+ "dtor-proc-macro",
+]
+
+[[package]]
+name = "dtor-proc-macro"
+version = "0.0.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f678cf4a922c215c63e0de95eb1ff08a958a81d47e485cf9da1e27bf6305cfa5"
+
+[[package]]
+name = "dyn-clone"
+version = "1.0.20"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d0881ea181b1df73ff77ffaaf9c7544ecc11e82fba9b5f27b262a3c73a332555"
+
+[[package]]
+name = "ecdsa"
+version = "0.16.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca"
+dependencies = [
+ "der",
+ "digest 0.10.7",
+ "elliptic-curve",
+ "rfc6979",
+ "signature",
+]
+
+[[package]]
+name = "ed25519"
+version = "2.2.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53"
+dependencies = [
+ "pkcs8",
+ "signature",
+]
+
+[[package]]
+name = "ed25519-dalek"
+version = "2.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "70e796c081cee67dc755e1a36a0a172b897fab85fc3f6bc48307991f64e4eca9"
+dependencies = [
+ "curve25519-dalek 4.1.3",
+ "ed25519",
+ "rand_core",
+ "serde",
+ "sha2",
+ "subtle",
+ "zeroize",
+]
+
+[[package]]
+name = "educe"
+version = "0.6.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1d7bc049e1bd8cdeb31b68bbd586a9464ecf9f3944af3958a7a9d0f8b9799417"
+dependencies = [
+ "enum-ordinalize",
+ "proc-macro2",
+ "quote",
+ "syn 2.0.119",
+]
+
+[[package]]
+name = "either"
+version = "1.18.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "252afb9ae5eaa683babdc6a068b3f5726eb19e05070c731f9b2a23a7c3e8ed34"
+
+[[package]]
+name = "elliptic-curve"
+version = "0.13.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47"
+dependencies = [
+ "base16ct",
+ "crypto-bigint",
+ "digest 0.10.7",
+ "ff",
+ "generic-array",
+ "group",
+ "rand_core",
+ "sec1",
+ "subtle",
+ "zeroize",
+]
+
+[[package]]
+name = "enum-ordinalize"
+version = "4.4.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "89dd01549b09589510cf0647475075d12071456586d70f5c75c98ae2a5537677"
+dependencies = [
+ "enum-ordinalize-derive",
+]
+
+[[package]]
+name = "enum-ordinalize-derive"
+version = "4.4.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a65863d15a4ce2888bd2f0f543cc963d3879c3a022c8ee43f6141d479a3ac815"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 3.0.5",
+]
+
+[[package]]
+name = "equivalent"
+version = "1.0.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f"
+
+[[package]]
+name = "escape-bytes"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2bfcf67fea2815c2fc3b90873fae90957be12ff417335dfadc7f52927feb03b2"
+
+[[package]]
+name = "ethnum"
+version = "1.5.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "40404c3f5f511ec4da6fe866ddf6a717c309fdbb69fbbad7b0f3edab8f2e835f"
+
+[[package]]
+name = "ff"
+version = "0.13.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c0b50bfb653653f9ca9095b427bed08ab8d75a137839d9ad64eb11810d5b6393"
+dependencies = [
+ "rand_core",
+ "subtle",
+]
+
+[[package]]
+name = "fiat-crypto"
+version = "0.2.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d"
+
+[[package]]
+name = "fiat-crypto"
+version = "0.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "64cd1e32ddd350061ae6edb1b082d7c54915b5c672c389143b9a63403a109f24"
+
+[[package]]
+name = "find-msvc-tools"
+version = "0.1.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3e0f1c7c3a72c66fd80abe965175f7523475c0489a87d3ff9d6e8c87d87a9d2d"
+
+[[package]]
+name = "fnv"
+version = "1.0.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
+
+[[package]]
+name = "futures-core"
+version = "0.3.34"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "92d699e522242e69e3003b94ecc1f960f3a5e015aa7c5d7486e65ad01dd94f5e"
+
+[[package]]
+name = "futures-task"
+version = "0.3.34"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cd417de3d1d015fc3bfd2b1ea46dfc7bab72ef86f1cc7cc9c78e728b34a6d1fd"
+
+[[package]]
+name = "futures-util"
+version = "0.3.34"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0d50a92467f8ba5dd6e3ee5d4bd04d73ab2e4e1c44474a0674821dfce14b79bc"
+dependencies = [
+ "futures-core",
+ "futures-task",
+ "pin-project-lite",
+ "slab",
+]
+
+[[package]]
+name = "generic-array"
+version = "0.14.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4bb6743198531e02858aeaea5398fcc883e71851fcbcb5a2f773e2fb6cb1edf2"
+dependencies = [
+ "typenum",
+ "version_check",
+ "zeroize",
+]
+
+[[package]]
+name = "getrandom"
+version = "0.2.17"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0"
+dependencies = [
+ "cfg-if",
+ "js-sys",
+ "libc",
+ "wasi",
+ "wasm-bindgen",
+]
+
+[[package]]
+name = "group"
+version = "0.13.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63"
+dependencies = [
+ "ff",
+ "rand_core",
+ "subtle",
+]
+
+[[package]]
+name = "hash32"
+version = "0.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "47d60b12902ba28e2730cd37e95b8c9223af2808df9e902d4df49588d1470606"
+dependencies = [
+ "byteorder",
+]
+
+[[package]]
+name = "hashbrown"
+version = "0.12.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
+
+[[package]]
+name = "hashbrown"
+version = "0.15.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1"
+dependencies = [
+ "allocator-api2",
+]
+
+[[package]]
+name = "hashbrown"
+version = "0.17.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a"
+
+[[package]]
+name = "heapless"
+version = "0.8.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0bfb9eb618601c89945a70e254898da93b13be0388091d42117462b265bb3fad"
+dependencies = [
+ "hash32",
+ "stable_deref_trait",
+]
+
+[[package]]
+name = "heck"
+version = "0.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
+
+[[package]]
+name = "hex"
+version = "0.4.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
+dependencies = [
+ "serde",
+]
+
+[[package]]
+name = "hex-literal"
+version = "0.4.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46"
+
+[[package]]
+name = "hmac"
+version = "0.12.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e"
+dependencies = [
+ "digest 0.10.7",
+]
+
+[[package]]
+name = "hybrid-array"
+version = "0.4.14"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "707114b52a152fa7bdb290cd7cd5912d9467273b6d74e21b8d81aca1f8533f6b"
+dependencies = [
+ "typenum",
+]
+
+[[package]]
+name = "iana-time-zone"
+version = "0.1.65"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e31bc9ad994ba00e440a8aa5c9ef0ec67d5cb5e5cb0cc7f8b744a35b389cc470"
+dependencies = [
+ "android_system_properties",
+ "core-foundation-sys",
+ "iana-time-zone-haiku",
+ "js-sys",
+ "log",
+ "wasm-bindgen",
+ "windows-core",
+]
+
+[[package]]
+name = "iana-time-zone-haiku"
+version = "0.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f"
+dependencies = [
+ "cc",
+]
+
+[[package]]
+name = "ident_case"
+version = "1.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39"
+
+[[package]]
+name = "indexmap"
+version = "1.9.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99"
+dependencies = [
+ "autocfg",
+ "hashbrown 0.12.3",
+ "serde",
+]
+
+[[package]]
+name = "indexmap"
+version = "2.14.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cc4e190f5d26ca7051642629da2c52fc03bde85a03197c99408dcd291734c855"
+dependencies = [
+ "equivalent",
+ "hashbrown 0.17.1",
+ "serde",
+ "serde_core",
+]
+
+[[package]]
+name = "indexmap-nostd"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8e04e2fd2b8188ea827b32ef11de88377086d690286ab35747ef7f9bf3ccb590"
+
+[[package]]
+name = "itertools"
+version = "0.13.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186"
+dependencies = [
+ "either",
+]
+
+[[package]]
+name = "itoa"
+version = "1.0.18"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682"
+
+[[package]]
+name = "jiff"
+version = "0.2.35"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "668b7183bd07af9a4885f5c35b0cc5c83c4607a913c16b7e17291832910d2dcc"
+dependencies = [
+ "defmt",
+ "jiff-core",
+ "jiff-static",
+ "jiff-tzdb-platform",
+ "log",
+ "portable-atomic",
+ "portable-atomic-util",
+ "serde_core",
+ "windows-link",
+]
+
+[[package]]
+name = "jiff-core"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7feca88439efe53da3754500c1851dedf3cb36c524dd5cf8225cc0794de95d09"
+dependencies = [
+ "defmt",
+]
+
+[[package]]
+name = "jiff-static"
+version = "0.2.35"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3a69dcb3a21cfb32ce1cd056169337ca284af0766dd766e7878819b251a49204"
+dependencies = [
+ "jiff-core",
+ "proc-macro2",
+ "quote",
+ "syn 2.0.119",
+]
+
+[[package]]
+name = "jiff-tzdb"
+version = "0.1.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "142bd39932ad231f10513df9ab62661fead8719872150b7ad02a2df79f4e141e"
+
+[[package]]
+name = "jiff-tzdb-platform"
+version = "0.1.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "875a5a69ac2bab1a891711cf5eccbec1ce0341ea805560dcd90b7a2e925132e8"
+dependencies = [
+ "jiff-tzdb",
+]
+
+[[package]]
+name = "js-sys"
+version = "0.3.105"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ce57d20d1ea864ce2ac172ab472d409214f4fd359f0b2a2775abdf522e2af99e"
+dependencies = [
+ "cfg-if",
+ "futures-util",
+ "wasm-bindgen",
+]
+
+[[package]]
+name = "k256"
+version = "0.13.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f6e3919bbaa2945715f0bb6d3934a173d1e9a59ac23767fbaaef277265a7411b"
+dependencies = [
+ "cfg-if",
+ "ecdsa",
+ "elliptic-curve",
+ "sha2",
+]
+
+[[package]]
+name = "keccak"
+version = "0.1.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cb26cec98cce3a3d96cbb7bced3c4b16e3d13f27ec56dbd62cbc8f39cfb9d653"
+dependencies = [
+ "cpufeatures 0.2.17",
+]
+
+[[package]]
+name = "libc"
+version = "0.2.189"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3eaf3ede3fee6db1a4c2ee091bf8a8b4dccdc6d17f656fb07896ee72867612f2"
+
+[[package]]
+name = "libm"
+version = "0.2.16"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981"
+
+[[package]]
+name = "log"
+version = "0.4.34"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f9f8bd3e56ce4dfc153cf470fffbfa98c7620958b312ca5c3a4b8d5181fd13c6"
+
+[[package]]
+name = "macro-string"
+version = "0.1.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1b27834086c65ec3f9387b096d66e99f221cf081c2b738042aa252bcd41204e3"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.119",
+]
+
+[[package]]
+name = "memchr"
+version = "2.8.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98"
+
+[[package]]
+name = "num-bigint"
+version = "0.4.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c89e69e7e0f03bea5ef08013795c25018e101932225a656383bd384495ecc367"
+dependencies = [
+ "num-integer",
+ "num-traits",
+]
+
+[[package]]
+name = "num-conv"
+version = "0.2.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "521739c6d2bac4aa25192232afe6841231376b2b26d4d9fae5ecf8ca5772e441"
+
+[[package]]
+name = "num-derive"
+version = "0.4.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.119",
+]
+
+[[package]]
+name = "num-integer"
+version = "0.1.47"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7ce2d95d4b3734dc35aa2f45e1aa22cd416814592a4f9d9205e11affd5b8e10b"
+dependencies = [
+ "num-traits",
+]
+
+[[package]]
+name = "num-traits"
+version = "0.2.19"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
+dependencies = [
+ "autocfg",
+]
+
+[[package]]
+name = "once_cell"
+version = "1.21.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
+
+[[package]]
+name = "p256"
+version = "0.13.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c9863ad85fa8f4460f9c48cb909d38a0d689dba1f6f6988a5e3e0d31071bcd4b"
+dependencies = [
+ "ecdsa",
+ "elliptic-curve",
+ "primeorder",
+ "sha2",
+]
+
+[[package]]
+name = "paste"
+version = "1.0.15"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a"
+
+[[package]]
+name = "pin-project-lite"
+version = "0.2.17"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd"
+
+[[package]]
+name = "pkcs8"
+version = "0.10.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7"
+dependencies = [
+ "der",
+ "spki",
+]
+
+[[package]]
+name = "portable-atomic"
+version = "1.15.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "05c8b63e8d9609db387f0324918f81d68fe27748f084ef092fb35954d0539a85"
+
+[[package]]
+name = "portable-atomic-util"
+version = "0.2.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "10ab3eb7f3becc3a1cbc4f2c6f20267996cfc1a6467a873763411b136a122715"
+dependencies = [
+ "portable-atomic",
+]
+
+[[package]]
+name = "powerfmt"
+version = "0.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391"
+
+[[package]]
+name = "ppv-lite86"
+version = "0.2.21"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9"
+dependencies = [
+ "zerocopy",
+]
+
+[[package]]
+name = "prettyplease"
+version = "0.2.37"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b"
+dependencies = [
+ "proc-macro2",
+ "syn 2.0.119",
+]
+
+[[package]]
+name = "primeorder"
+version = "0.13.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "353e1ca18966c16d9deb1c69278edbc5f194139612772bd9537af60ac231e1e6"
+dependencies = [
+ "elliptic-curve",
+]
+
+[[package]]
+name = "proc-macro2"
+version = "1.0.107"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
+dependencies = [
+ "unicode-ident",
+]
+
+[[package]]
+name = "quote"
+version = "1.0.47"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
+dependencies = [
+ "proc-macro2",
+]
+
+[[package]]
+name = "rand"
+version = "0.8.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e058c7de0b26af77780c769414d6257830bb240f3c38477dbc2c16e5f54d6d4c"
+dependencies = [
+ "libc",
+ "rand_chacha",
+ "rand_core",
+]
+
+[[package]]
+name = "rand_chacha"
+version = "0.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
+dependencies = [
+ "ppv-lite86",
+ "rand_core",
+]
+
+[[package]]
+name = "rand_core"
+version = "0.6.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
+dependencies = [
+ "getrandom",
+]
+
+[[package]]
+name = "ref-cast"
+version = "1.0.27"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7e440fb4e4b4147295338efb76001ab9e4efc0e5839df2c47fc5ac2381d365c3"
+dependencies = [
+ "ref-cast-impl",
+]
+
+[[package]]
+name = "ref-cast-impl"
+version = "1.0.27"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "92ecd8964f8453721699a1ed72037b0db49ce2f5a5138486ee89bed6f67cdf3a"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 3.0.5",
+]
+
+[[package]]
+name = "rfc6979"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2"
+dependencies = [
+ "hmac",
+ "subtle",
+]
+
+[[package]]
+name = "rustc_version"
+version = "0.4.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92"
+dependencies = [
+ "semver",
+]
+
+[[package]]
+name = "rustversion"
+version = "1.0.23"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f"
+
+[[package]]
+name = "schemars"
+version = "0.8.22"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3fbf2ae1b8bc8e02df939598064d22402220cd5bbcca1c76f7d6a310974d5615"
+dependencies = [
+ "dyn-clone",
+ "serde",
+ "serde_json",
+]
+
+[[package]]
+name = "schemars"
+version = "0.9.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4cd191f9397d57d581cddd31014772520aa448f65ef991055d7f61582c65165f"
+dependencies = [
+ "dyn-clone",
+ "ref-cast",
+ "serde",
+ "serde_json",
+]
+
+[[package]]
+name = "schemars"
+version = "1.2.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "687274d293b6cdc6e73e0fee520bf2049650090d7164f87672d212a3c530cf4a"
+dependencies = [
+ "dyn-clone",
+ "ref-cast",
+ "serde",
+ "serde_json",
+]
+
+[[package]]
+name = "sec1"
+version = "0.7.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc"
+dependencies = [
+ "base16ct",
+ "der",
+ "generic-array",
+ "subtle",
+ "zeroize",
+]
+
+[[package]]
+name = "semver"
+version = "1.0.28"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd"
+
+[[package]]
+name = "serde"
+version = "1.0.229"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba"
+dependencies = [
+ "serde_core",
+ "serde_derive",
+]
+
+[[package]]
+name = "serde_core"
+version = "1.0.229"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48"
+dependencies = [
+ "serde_derive",
+]
+
+[[package]]
+name = "serde_derive"
+version = "1.0.229"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 3.0.5",
+]
+
+[[package]]
+name = "serde_json"
+version = "1.0.151"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c841b55ecdae098c80dcae9cf767f6f8a0c2cdb3416bbef72181df4d0fe73f14"
+dependencies = [
+ "itoa",
+ "memchr",
+ "serde",
+ "serde_core",
+ "zmij",
+]
+
+[[package]]
+name = "serde_with"
+version = "3.22.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ee78f1fbe43ac4a0e47aadb3dbd357b69eb0d3793e948624cd03dd2750ab1c0a"
+dependencies = [
+ "base64",
+ "bs58",
+ "chrono",
+ "hex",
+ "indexmap 1.9.3",
+ "indexmap 2.14.2",
+ "jiff",
+ "schemars 0.8.22",
+ "schemars 0.9.0",
+ "schemars 1.2.2",
+ "serde_core",
+ "serde_json",
+ "serde_with_macros",
+ "time",
+]
+
+[[package]]
+name = "serde_with_macros"
+version = "3.22.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8705578779c2b6bd90d84d66eb2e206b708b1a4d7b9f17641b293545bf1c7e46"
+dependencies = [
+ "darling 0.23.0",
+ "proc-macro2",
+ "quote",
+ "syn 2.0.119",
+]
+
+[[package]]
+name = "sha2"
+version = "0.10.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283"
+dependencies = [
+ "cfg-if",
+ "cpufeatures 0.2.17",
+ "digest 0.10.7",
+]
+
+[[package]]
+name = "sha3"
+version = "0.10.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "77fd7028345d415a4034cf8777cd4f8ab1851274233b45f84e3d955502d93874"
+dependencies = [
+ "digest 0.10.7",
+ "keccak",
+]
+
+[[package]]
+name = "shlex"
+version = "2.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba"
+
+[[package]]
+name = "signature"
+version = "2.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de"
+dependencies = [
+ "digest 0.10.7",
+ "rand_core",
+]
+
+[[package]]
+name = "slab"
+version = "0.4.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5"
+
+[[package]]
+name = "smallvec"
+version = "1.16.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b9be42f50aa861c555654aa3a37f52f4b1074bacf4e48fe0ef7fa584e80f1f0f"
+
+[[package]]
+name = "soroban-builtin-sdk-macros"
+version = "27.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b77bc93d930032c487cb1506b6ed166b2af49db76d52678ec4887ac621ecce01"
+dependencies = [
+ "itertools",
+ "proc-macro2",
+ "quote",
+ "syn 2.0.119",
+]
+
+[[package]]
+name = "soroban-env-common"
+version = "27.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6b22e9981cdd444f3aa6734bc58d76195bf7eca3ccf1dd432b875af5d02da068"
+dependencies = [
+ "arbitrary",
+ "crate-git-revision 0.0.6",
+ "ethnum",
+ "num-derive",
+ "num-traits",
+ "serde",
+ "soroban-env-macros",
+ "soroban-wasmi",
+ "static_assertions",
+ "stellar-xdr",
+ "wasmparser",
+]
+
+[[package]]
+name = "soroban-env-guest"
+version = "27.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2b6072f99ca6bf8e8d5b04e05d083dac785e5357d9c0f36a6658f819c2fd7d67"
+dependencies = [
+ "soroban-env-common",
+ "static_assertions",
+]
+
+[[package]]
+name = "soroban-env-host"
+version = "27.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2c06afd7c75ce150ce53e4d77a77645b18e3fb61856a0ddc42bfcecdc39fa3b9"
+dependencies = [
+ "ark-bls12-381",
+ "ark-bn254",
+ "ark-ec",
+ "ark-ff",
+ "ark-serialize",
+ "curve25519-dalek 5.0.0",
+ "ecdsa",
+ "ed25519-dalek",
+ "elliptic-curve",
+ "generic-array",
+ "getrandom",
+ "hex-literal",
+ "hmac",
+ "k256",
+ "num-derive",
+ "num-integer",
+ "num-traits",
+ "p256",
+ "rand",
+ "rand_chacha",
+ "sec1",
+ "sha2",
+ "sha3",
+ "soroban-builtin-sdk-macros",
+ "soroban-env-common",
+ "soroban-wasmi",
+ "static_assertions",
+ "stellar-strkey 0.0.13",
+ "wasmparser",
+]
+
+[[package]]
+name = "soroban-env-macros"
+version = "27.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "647811bdd28a3ec40296987f6635781e5e1141c8f5affbbd53ba12b6295b7bb6"
+dependencies = [
+ "itertools",
+ "proc-macro2",
+ "quote",
+ "serde",
+ "serde_json",
+ "stellar-xdr",
+ "syn 2.0.119",
+]
+
+[[package]]
+name = "soroban-ledger-snapshot"
+version = "27.0.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b59883d8bd0d1aed8d57579a9974ab88eaf787dd0a1af104f6881b5707450558"
+dependencies = [
+ "serde",
+ "serde_json",
+ "serde_with",
+ "soroban-env-common",
+ "soroban-env-host",
+ "thiserror 1.0.69",
+]
+
+[[package]]
+name = "soroban-sdk"
+version = "27.0.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6c3f21971c84fcfb08957e3e8f5a9a70f134cb07ad9ee053ac7e6d7a887a82af"
+dependencies = [
+ "arbitrary",
+ "bytes-lit",
+ "crate-git-revision 0.0.9",
+ "ctor",
+ "derive_arbitrary",
+ "ed25519-dalek",
+ "rand",
+ "rustc_version",
+ "serde",
+ "serde_json",
+ "soroban-env-guest",
+ "soroban-env-host",
+ "soroban-ledger-snapshot",
+ "soroban-sdk-macros",
+ "stellar-strkey 0.0.16",
+ "visibility",
+]
+
+[[package]]
+name = "soroban-sdk-macros"
+version = "27.0.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3bd4a847273d749807fe2eb52e2b9c1917ee482cd6a39465cad5c389548996ad"
+dependencies = [
+ "darling 0.20.11",
+ "heck",
+ "itertools",
+ "macro-string",
+ "proc-macro2",
+ "quote",
+ "sha2",
+ "soroban-env-common",
+ "soroban-spec",
+ "soroban-spec-rust",
+ "stellar-xdr",
+ "syn 2.0.119",
+]
+
+[[package]]
+name = "soroban-spec"
+version = "27.0.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "473404322827b285cbcd87517f365986bd63af7842c78b2a86ee061715fda61e"
+dependencies = [
+ "base64",
+ "sha2",
+ "stellar-xdr",
+ "thiserror 1.0.69",
+ "wasmparser",
+]
+
+[[package]]
+name = "soroban-spec-rust"
+version = "27.0.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2f25698b6ce2125850a9ef075cf9ba1e8d25b4cfa0c46aca42dadd80cc29d881"
+dependencies = [
+ "prettyplease",
+ "proc-macro2",
+ "quote",
+ "sha2",
+ "soroban-spec",
+ "stellar-xdr",
+ "syn 2.0.119",
+ "thiserror 1.0.69",
+]
+
+[[package]]
+name = "soroban-wasmi"
+version = "0.31.1-soroban.20.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "710403de32d0e0c35375518cb995d4fc056d0d48966f2e56ea471b8cb8fc9719"
+dependencies = [
+ "smallvec",
+ "spin",
+ "wasmi_arena",
+ "wasmi_core",
+ "wasmparser-nostd",
+]
+
+[[package]]
+name = "spin"
+version = "0.9.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3763264f6b73151db08c50ff20d7d8a0b8796e021cdea7ceedad07b80155fa0e"
+
+[[package]]
+name = "spki"
+version = "0.7.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d"
+dependencies = [
+ "base64ct",
+ "der",
+]
+
+[[package]]
+name = "stable_deref_trait"
+version = "1.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596"
+
+[[package]]
+name = "static_assertions"
+version = "1.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
+
+[[package]]
+name = "stellar-strkey"
+version = "0.0.13"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ee1832fb50c651ad10f734aaf5d31ca5acdfb197a6ecda64d93fcdb8885af913"
+dependencies = [
+ "crate-git-revision 0.0.6",
+ "data-encoding",
+]
+
+[[package]]
+name = "stellar-strkey"
+version = "0.0.16"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "084afcb0d458c3d5d5baa2d294b18f881e62cc258ef539d8fdf68be7dbe45520"
+dependencies = [
+ "crate-git-revision 0.0.6",
+ "data-encoding",
+ "heapless",
+]
+
+[[package]]
+name = "stellar-xdr"
+version = "27.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "05ff843326969bdf1ef673dcdba94c08f4a3c8f1e58d6e6ef39b1bd4f749179a"
+dependencies = [
+ "arbitrary",
+ "base64",
+ "cfg_eval",
+ "crate-git-revision 0.0.6",
+ "escape-bytes",
+ "ethnum",
+ "hex",
+ "serde",
+ "serde_with",
+ "sha2",
+ "stellar-strkey 0.0.13",
+]
+
+[[package]]
+name = "strsim"
+version = "0.11.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
+
+[[package]]
+name = "subtle"
+version = "2.6.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
+
+[[package]]
+name = "syn"
+version = "2.0.119"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "unicode-ident",
+]
+
+[[package]]
+name = "syn"
+version = "3.0.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "12df2e0110f65b775f769bb17ef989067a1d931b2eb822bd4346631eeada89f9"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "unicode-ident",
+]
+
+[[package]]
+name = "thiserror"
+version = "1.0.69"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52"
+dependencies = [
+ "thiserror-impl 1.0.69",
+]
+
+[[package]]
+name = "thiserror"
+version = "2.0.20"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ec86235f5fcc2a73650310756d2ac5b138a5780bbbdfae3eeccec992c435ba4f"
+dependencies = [
+ "thiserror-impl 2.0.20",
+]
+
+[[package]]
+name = "thiserror-impl"
+version = "1.0.69"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.119",
+]
+
+[[package]]
+name = "thiserror-impl"
+version = "2.0.20"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bc04cd3e1236dd4a98afca4569f2deb3f120e5422a4023be2cb683f8486292af"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 3.0.5",
+]
+
+[[package]]
+name = "time"
+version = "0.3.55"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cdb87b95ec50ddfa440816d227a17b2ccbdda963a316a727fda0fc4334f7d134"
+dependencies = [
+ "deranged",
+ "num-conv",
+ "powerfmt",
+ "serde_core",
+ "time-core",
+ "time-macros",
+]
+
+[[package]]
+name = "time-core"
+version = "0.1.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9e1c906769ad99c88eaa54e728060edef082f8e358ff32030cb7c7d315e81109"
+
+[[package]]
+name = "time-macros"
+version = "0.2.32"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7e689342a48d2ea927c87ea50cabf8594854bf940e9310208848d680d668ed85"
+dependencies = [
+ "num-conv",
+ "time-core",
+]
+
+[[package]]
+name = "tinyvec"
+version = "1.13.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4cf0ded5c4e56918d8f8a339e1bb67d038d3bc6d144ac407904015ba2e4cde9b"
+dependencies = [
+ "tinyvec_macros",
+]
+
+[[package]]
+name = "tinyvec_macros"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
+
+[[package]]
+name = "typenum"
+version = "1.20.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20"
+
+[[package]]
+name = "unicode-ident"
+version = "1.0.24"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
+
+[[package]]
+name = "version_check"
+version = "0.9.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
+
+[[package]]
+name = "visibility"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d674d135b4a8c1d7e813e2f8d1c9a58308aee4a680323066025e53132218bd91"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.119",
+]
+
+[[package]]
+name = "wasi"
+version = "0.11.1+wasi-snapshot-preview1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b"
+
+[[package]]
+name = "wasm-bindgen"
+version = "0.2.128"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "aecb87a33d3b0c5e3b7aa46336eaf486cffafbd281b195e4c8b80d50df2351bf"
+dependencies = [
+ "cfg-if",
+ "once_cell",
+ "rustversion",
+ "wasm-bindgen-macro",
+ "wasm-bindgen-shared",
+]
+
+[[package]]
+name = "wasm-bindgen-macro"
+version = "0.2.128"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a690d511e3c1a8b3a55e33511e3c2c00c78415cd23650f32b808627f5696b9ed"
+dependencies = [
+ "quote",
+ "wasm-bindgen-macro-support",
+]
+
+[[package]]
+name = "wasm-bindgen-macro-support"
+version = "0.2.128"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "411e4887f0071ef2d2164a9d5fdf2d20efbef78fccd3a78b0c10a1dc5295e48a"
+dependencies = [
+ "bumpalo",
+ "proc-macro2",
+ "quote",
+ "syn 3.0.5",
+ "wasm-bindgen-shared",
+]
+
+[[package]]
+name = "wasm-bindgen-shared"
+version = "0.2.128"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "81941cd78d0c92026c33e5e01312845a4cb1e9af3407f9134b100dd03144103e"
+dependencies = [
+ "unicode-ident",
+]
+
+[[package]]
+name = "wasmi_arena"
+version = "0.4.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "104a7f73be44570cac297b3035d76b169d6599637631cf37a1703326a0727073"
+
+[[package]]
+name = "wasmi_core"
+version = "0.13.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "dcf1a7db34bff95b85c261002720c00c3a6168256dcb93041d3fa2054d19856a"
+dependencies = [
+ "downcast-rs",
+ "libm",
+ "num-traits",
+ "paste",
+]
+
+[[package]]
+name = "wasmparser"
+version = "0.116.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a58e28b80dd8340cb07b8242ae654756161f6fc8d0038123d679b7b99964fa50"
+dependencies = [
+ "indexmap 2.14.2",
+ "semver",
+]
+
+[[package]]
+name = "wasmparser-nostd"
+version = "0.100.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d5a015fe95f3504a94bb1462c717aae75253e39b9dd6c3fb1062c934535c64aa"
+dependencies = [
+ "indexmap-nostd",
+]
+
+[[package]]
+name = "windows-core"
+version = "0.62.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb"
+dependencies = [
+ "windows-implement",
+ "windows-interface",
+ "windows-link",
+ "windows-result",
+ "windows-strings",
+]
+
+[[package]]
+name = "windows-implement"
+version = "0.60.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.119",
+]
+
+[[package]]
+name = "windows-interface"
+version = "0.59.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.119",
+]
+
+[[package]]
+name = "windows-link"
+version = "0.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
+
+[[package]]
+name = "windows-result"
+version = "0.4.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5"
+dependencies = [
+ "windows-link",
+]
+
+[[package]]
+name = "windows-strings"
+version = "0.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091"
+dependencies = [
+ "windows-link",
+]
+
+[[package]]
+name = "xebra-batch-router"
+version = "0.0.0"
+dependencies = [
+ "soroban-sdk",
+]
+
+[[package]]
+name = "zerocopy"
+version = "0.8.56"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "556764e583adb45a9f8d413c2a147fa7e8d821e48e12b14fd560b607998b75eb"
+dependencies = [
+ "zerocopy-derive",
+]
+
+[[package]]
+name = "zerocopy-derive"
+version = "0.8.56"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f2ab42fc20575779bd240faa45f94a74256f755c0fa9e89f0ede20d91d0cdfc1"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.119",
+]
+
+[[package]]
+name = "zeroize"
+version = "1.9.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e13c156562582aa81c60cb29407084cdb54c4164760106ab78e6c5b0858cf64e"
+dependencies = [
+ "zeroize_derive",
+]
+
+[[package]]
+name = "zeroize_derive"
+version = "1.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3c50655cbb0fe3fc43170059e702f1ce5e19b84cec58dc87b037a09935c2f328"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.119",
+]
+
+[[package]]
+name = "zmij"
+version = "1.0.23"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b"
diff --git a/contracts/stellar-batch-router/Cargo.toml b/contracts/stellar-batch-router/Cargo.toml
new file mode 100644
index 00000000..aaab548c
--- /dev/null
+++ b/contracts/stellar-batch-router/Cargo.toml
@@ -0,0 +1,25 @@
+[package]
+name = "xebra-batch-router"
+version = "0.0.0"
+edition = "2021"
+publish = false
+
+[lib]
+crate-type = ["cdylib", "rlib"]
+doctest = false
+
+[dependencies]
+soroban-sdk = "27.0.6"
+
+[dev-dependencies]
+soroban-sdk = { version = "27.0.6", features = ["testutils"] }
+
+[profile.release]
+opt-level = "z"
+overflow-checks = true
+debug = 0
+strip = "symbols"
+debug-assertions = false
+panic = "abort"
+codegen-units = 1
+lto = true
diff --git a/contracts/stellar-batch-router/README.md b/contracts/stellar-batch-router/README.md
new file mode 100644
index 00000000..939837bc
--- /dev/null
+++ b/contracts/stellar-batch-router/README.md
@@ -0,0 +1,74 @@
+# XebraBatchRouter (Stellar)
+
+Several transfers, one signature, all or nothing. It covers two cases:
+
+- **One send to many wallets**: up to 5 recipients, any mix of destination chains.
+- **Splitting a transfer above Circle's per-message limit**: 20M becomes two 10M transfers.
+
+The router calls the deployed wrapper's `bridge` (v2, `CCPVTWII…`, which cannot be upgraded) once
+per request, inside one invocation. If any one transfer fails, the whole batch fails and nothing
+moves. The router has no admin, no fee, no upgrade path and holds no funds. Every per-transfer check
+belongs to the wrapper. The router adds three of its own: the batch is not empty, it has at most
+`MAX_BATCH` requests, and every request belongs to the signer. Error codes start at 100 so they never
+collide with the wrapper's.
+
+`batch(user, reqs)` returns nothing on purpose (see "Limit" below). Each transfer's quote is in the
+wrapper's `bridge_initiated` event.
+
+## Limit: 5 transfers per transaction
+
+Stellar caps a transaction's contract events **plus its return value** at 16,384 bytes
+(`tx_max_contract_events_size_bytes`, the same on testnet and mainnet as of 2026-11-18). Events are
+the only limit that binds. Compute (about 4.4M instructions per transfer against 400M) and writes are
+nowhere near their caps.
+
+Measured against Circle's real testnet contracts, with the wrapper running the exact mainnet WASM:
+
+| Destination path | Event bytes per transfer | Fits |
+|---|---|---|
+| EVM, forwarded (Arc) | 2,976 | 5 (14,880) |
+| Solana, forwarded, existing token account | 2,732 | 5 (13,660; 6 would be 16,392) |
+
+**`simulateTransaction` does not enforce this limit.** Batches of 6, 8, 10 and 11 all simulated OK,
+and a real 6-transfer batch then failed on chain with `resource_limit_exceeded`. Clients must count
+the bytes themselves, or cap batches at 5. `MAX_BATCH` (16) is only a loop guard: the event limit is
+a network setting that validators can raise, and this contract cannot change.
+
+## Testnet record (2026-11-18)
+
+Wrapper `CBCS76J4AEOSZXQCC22NJDJKXLS3ZPH3BHWRXNLKJH3BEQS7ZWX2OM7A` (mainnet WASM b5227c30…, Circle
+testnet TokenMessengerMinter `CDNG7HXA…`), router `CCFQXRS5FF6SNY32DRQXR4FGTLNCFLWMPMUHRANBWNFJKOOU7Z42N4KM`
+(WASM sha256 3f1c2461…), signer `xebra-fwdtest`, 1 USDC per transfer, Standard finality.
+
+| Tx | What | Result |
+|---|---|---|
+| `c05d2c03…` | 6 to Arc, first router (returned quotes) | FAILED `resource_limit_exceeded`, nothing moved (wrapper seq stayed 0) |
+| `ead53789…` | 5 to Arc, first router | FAILED: "return value pushes events size above network config maximum" 16592 > 16384 |
+| `fdadc044…` | 5 to Arc, router without return value | SUCCESS; Iris shows 5 messages, all forwarded `COMPLETE` to 5 recipients |
+| `de459798…` | 2 byte-identical requests (the split case) | SUCCESS |
+| `48742283…` | 4 chains in one batch: Arc, Base, Avalanche, Optimism (second wrapper `CAXATPSB…`, router `CCIKNA5S…`) | SUCCESS; Circle delivered on all 4 (forward txs checked on Base Sepolia and OP Sepolia: status 1) |
+| `bd600a02…` | 5 chains in one batch: Arc, Base, Avalanche, Optimism, Solana (2 USDC each) | SUCCESS; all 5 delivered (Base and OP receipts status 1, Solana devnet finalized) |
+
+Reproduce: `node scripts/batch-router-testnet.mjs [arc|solana] [amount] [--same] [--send]`, or
+`BATCH_ENV=.secrets/batch-router-testnet-mixed.env node scripts/batch-router-testnet.mjs 5 mix:arc,base,avalanche,optimism,solana --send`
+(the ids live in `.secrets/`).
+
+## Tests
+
+`cargo test` (16 tests) runs the router against the deployed wrapper WASM
+(`wasm/xebra_cctp_wrapper_v2_mainnet.wasm`, fetched from mainnet, sha256 matches
+`deployments/mainnet.json`), with a mock Circle messenger that pulls the burn with `transfer_from`.
+The tests cover: many recipients, the 20M split, mixed forwarded and relay paths, atomic rollback
+when the wrapper, Circle or the balance refuses any one transfer, the router's own checks, a single
+root authorization with one `bridge` under it per request, and that the router's copies of
+`BridgeRequest` and `Quote` encode exactly as the deployed WASM decodes them.
+
+Locally, reuse the v2 crate's build cache: `CARGO_TARGET_DIR=../stellar-cctp-wrapper-v2/target cargo test`.
+
+## Not done
+
+- Mainnet deploy. The contract has had no external audit.
+- Front end and SDK: build the batch, cap it at 5, and quote each transfer with the wrapper's `quote`.
+- A real signature with address credentials (smart wallet, or a fee sponsor). Every test above used
+ the source account's signature, which is what Freighter-style wallets do today.
+- The Solana account-creation path (65-byte hook) was not measured. It should still fit 5.
diff --git a/contracts/stellar-batch-router/src/lib.rs b/contracts/stellar-batch-router/src/lib.rs
new file mode 100644
index 00000000..87c7b063
--- /dev/null
+++ b/contracts/stellar-batch-router/src/lib.rs
@@ -0,0 +1,155 @@
+//! XebraBatchRouter: many transfers, one signature, all or nothing.
+//!
+//! The wrapper (`contracts/stellar-cctp-wrapper-v2`, deployed `CCPVTWII…`) cannot be upgraded, and a
+//! Stellar transaction carries exactly one contract invocation. So "send to many wallets" and "split
+//! a transfer above Circle's per-message limit" both need one entry point that calls the wrapper's
+//! `bridge` several times inside a single invocation. That is all this contract does.
+//!
+//! Atomic by construction: `bridge` is called with the panicking client, so if any one transfer is
+//! rejected (by the wrapper or by Circle) the whole invocation fails and every earlier transfer in
+//! the batch is rolled back with it. There is no partial batch.
+//!
+//! What it deliberately does not have: no admin, no state besides the wrapper address, no fee, no
+//! upgrade path, and it never holds funds. USDC moves from the user to the wrapper and Circle
+//! exactly as it does for a single transfer; every per-transfer check (amount bounds, fee caps,
+//! domain allowlist, recipient shape, deadline, approval window) stays the wrapper's, applied to
+//! each request unchanged. The router adds three checks of its own: the batch is not empty, not
+//! longer than `MAX_BATCH`, and every request belongs to the one signer.
+//!
+//! Authorization: the user signs `batch(user, reqs)` once. Each nested `bridge` asks for the user's
+//! auth on its own request, which the host matches as a sub-invocation of that one signed call, so a
+//! wallet shows a single approval covering every transfer.
+#![no_std]
+
+use soroban_sdk::{
+ contract, contractclient, contracterror, contractimpl, contracttype, Address, BytesN, Env, Vec,
+};
+
+/// The deployed wrapper's WASM (sha256 b5227c305b916c80a81d675dd8fbd8103e7d62e91c501e044ec93e365e686cd8,
+/// the `wasmSha256` in `deployments/mainnet.json`). Tests run against it, and a test proves the two
+/// types below encode exactly as that binary decodes them, so they cannot drift.
+#[cfg(test)]
+pub mod wrapper {
+ soroban_sdk::contractimport!(file = "wasm/xebra_cctp_wrapper_v2_mainnet.wasm");
+}
+
+/// Field-for-field copy of the wrapper's `BridgeRequest` (see `stellar-cctp-wrapper-v2` for what
+/// each field means). Declared here, not imported, so it is part of this contract's own interface:
+/// wallets and the CLI encode `batch` arguments from it.
+#[contracttype]
+#[derive(Clone, Debug, Eq, PartialEq)]
+pub struct BridgeRequest {
+ pub user: Address,
+ pub amount: i128,
+ pub destination_domain: u32,
+ pub mint_recipient: BytesN<32>,
+ pub max_fee: i128,
+ pub min_finality_threshold: u32,
+ pub approval_expiration_ledger: u32,
+ pub recipient_needs_account: bool,
+ pub recipient_owner: BytesN<32>,
+ pub max_wrapper_fee: i128,
+ pub deadline: u64,
+}
+
+/// Field-for-field copy of the wrapper's `Quote`.
+#[contracttype]
+#[derive(Clone, Debug, Eq, PartialEq)]
+pub struct Quote {
+ pub amount: i128,
+ pub fee: i128,
+ pub account_fee: i128,
+ pub net_burned: i128,
+ pub remainder: i128,
+ pub forward_fee: i128,
+ pub wrapper_take: i128,
+ pub forwarded: bool,
+ pub account_created: bool,
+}
+
+#[contractclient(name = "WrapperClient")]
+pub trait Wrapper {
+ fn bridge(env: Env, req: BridgeRequest) -> Quote;
+}
+
+/// Upper bound on transfers per batch: a loop guard, not the working limit. The working limit is the
+/// network's 16 KiB per-transaction event budget, which allowed 5 forwarded transfers on testnet
+/// (see README). It is a network setting that validators can raise, and this contract cannot be
+/// upgraded, so the clients enforce the measured figure and this constant leaves room above it.
+pub const MAX_BATCH: u32 = 16;
+
+const INSTANCE_TTL_THRESHOLD: u32 = 518_400; // ~30 days at 5 s ledgers
+const INSTANCE_TTL_EXTEND_TO: u32 = 3_110_400; // ~180 days
+
+/// Codes start at 100 so they never collide with the wrapper's (1..45): when a batch fails, the
+/// code alone says whether the router or the wrapper refused it.
+#[contracterror]
+#[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord)]
+#[repr(u32)]
+pub enum Error {
+ EmptyBatch = 100,
+ BatchTooLarge = 101,
+ UserMismatch = 102,
+}
+
+#[contracttype]
+pub enum DataKey {
+ Wrapper,
+}
+
+#[contract]
+pub struct XebraBatchRouter;
+
+#[contractimpl]
+impl XebraBatchRouter {
+ pub fn __constructor(env: Env, wrapper: Address) {
+ let s = env.storage().instance();
+ s.set(&DataKey::Wrapper, &wrapper);
+ s.extend_ttl(INSTANCE_TTL_THRESHOLD, INSTANCE_TTL_EXTEND_TO);
+ }
+
+ /// Bridges every request in order, in one invocation. Fails, and changes nothing, if any one of
+ /// them fails.
+ ///
+ /// Returns nothing on purpose. Stellar counts a transaction's return value against the same
+ /// 16 KiB budget as its events (`tx_max_contract_events_size_bytes`), and each transfer already
+ /// spends about 2.9 KiB of it on the wrapper's, Circle's and the token's events. Returning the
+ /// quotes cost a whole transfer per batch on testnet (5 failed with "return value pushes events
+ /// size above network config maximum", 16592 > 16384). Each quote is in the wrapper's
+ /// `bridge_initiated` event anyway.
+ pub fn batch(env: Env, user: Address, reqs: Vec) -> Result<(), Error> {
+ let n = reqs.len();
+ if n == 0 {
+ return Err(Error::EmptyBatch);
+ }
+ if n > MAX_BATCH {
+ return Err(Error::BatchTooLarge);
+ }
+ for r in reqs.iter() {
+ if r.user != user {
+ return Err(Error::UserMismatch);
+ }
+ }
+
+ // One signature over the whole list: the nested `bridge` auths are its sub-invocations.
+ user.require_auth();
+
+ env.storage()
+ .instance()
+ .extend_ttl(INSTANCE_TTL_THRESHOLD, INSTANCE_TTL_EXTEND_TO);
+
+ let client = WrapperClient::new(&env, &Self::get_wrapper(env.clone()));
+ for r in reqs.iter() {
+ // Panicking client on purpose: any refusal aborts the whole batch.
+ client.bridge(&r);
+ }
+ Ok(())
+ }
+
+ pub fn get_wrapper(env: Env) -> Address {
+ env.storage().instance().get(&DataKey::Wrapper).unwrap()
+ }
+}
+
+#[cfg(test)]
+mod test;
diff --git a/contracts/stellar-batch-router/src/test.rs b/contracts/stellar-batch-router/src/test.rs
new file mode 100644
index 00000000..e780a33d
--- /dev/null
+++ b/contracts/stellar-batch-router/src/test.rs
@@ -0,0 +1,500 @@
+//! Tests run the router against the wrapper WASM deployed on mainnet (imported in `lib.rs`), with a
+//! mock Circle messenger that pulls the burn with `transfer_from` exactly as Circle's does. So the
+//! allowance each nested `bridge` creates must really exist and really be consumed.
+//!
+//! `mock_all_auths()` satisfies `require_auth` without signatures. The auth-tree test inspects what
+//! the host recorded, and the testnet run in the README checks a real signature end to end.
+
+use soroban_sdk::testutils::{Address as _, AuthorizedFunction, Ledger as _};
+use soroban_sdk::{
+ contract, contractimpl, contracttype, symbol_short, token, vec, Address, BytesN, Env,
+ IntoVal, Symbol, TryFromVal, Val, Vec,
+};
+
+use crate::wrapper::{self, DomainCfg, Params};
+use crate::{BridgeRequest, Error, Quote, XebraBatchRouter, XebraBatchRouterClient, MAX_BATCH};
+
+const DOMAIN_SOLANA: u32 = 5;
+const DOMAIN_ARC: u32 = 26;
+
+// ---------------------------------------------------------------------------
+// Mock Circle TokenMessengerMinter
+// ---------------------------------------------------------------------------
+
+#[contracttype]
+pub enum MockKey {
+ PanicOnAmount,
+ Burns,
+}
+
+#[contract]
+pub struct MockMessenger;
+
+#[contractimpl]
+impl MockMessenger {
+ /// `panic_on_amount`: a burn of exactly this amount is refused, which is how a test makes
+ /// Circle reject one transfer in the middle of a batch. Zero disables it.
+ pub fn __constructor(env: Env, panic_on_amount: i128) {
+ env.storage()
+ .instance()
+ .set(&MockKey::PanicOnAmount, &panic_on_amount);
+ }
+
+ #[allow(clippy::too_many_arguments)]
+ pub fn deposit_for_burn(
+ env: Env,
+ caller: Address,
+ amount: i128,
+ _destination_domain: u32,
+ _mint_recipient: BytesN<32>,
+ burn_token: Address,
+ _destination_caller: BytesN<32>,
+ _max_fee: i128,
+ _min_finality_threshold: u32,
+ ) {
+ Self::burn(env, caller, amount, burn_token);
+ }
+
+ #[allow(clippy::too_many_arguments)]
+ pub fn deposit_for_burn_with_hook(
+ env: Env,
+ caller: Address,
+ amount: i128,
+ _destination_domain: u32,
+ _mint_recipient: BytesN<32>,
+ burn_token: Address,
+ _destination_caller: BytesN<32>,
+ _max_fee: i128,
+ _min_finality_threshold: u32,
+ hook_data: soroban_sdk::Bytes,
+ ) {
+ if hook_data.is_empty() {
+ panic!("HookDataEmpty");
+ }
+ Self::burn(env, caller, amount, burn_token);
+ }
+
+ fn burn(env: Env, caller: Address, amount: i128, burn_token: Address) {
+ let p: i128 = env
+ .storage()
+ .instance()
+ .get(&MockKey::PanicOnAmount)
+ .unwrap_or(0);
+ if p != 0 && amount == p {
+ panic!("circle rejected the burn");
+ }
+ // Circle's `deposit_and_burn` pulls with transfer_from: needs a real allowance.
+ token::Client::new(&env, &burn_token).transfer_from(
+ &env.current_contract_address(),
+ &caller,
+ &env.current_contract_address(),
+ &amount,
+ );
+ let n: u32 = env.storage().instance().get(&MockKey::Burns).unwrap_or(0);
+ env.storage().instance().set(&MockKey::Burns, &(n + 1));
+ }
+
+ pub fn burns(env: Env) -> u32 {
+ env.storage().instance().get(&MockKey::Burns).unwrap_or(0)
+ }
+}
+
+// ---------------------------------------------------------------------------
+// Fixture
+// ---------------------------------------------------------------------------
+
+const USDC: i128 = 1_0000000; // 7 decimals on Stellar
+const FEE_BPS: u32 = 5;
+const MIN_FEE: i128 = 1_000_000; // 0.10
+const MAX_TRANSFER: i128 = 10_000_000 * USDC; // Circle's per-message limit, as live on mainnet
+const ARC_FORWARD_CAP: i128 = 1_000_000;
+
+struct Setup<'a> {
+ env: Env,
+ router: XebraBatchRouterClient<'a>,
+ wrapper: wrapper::Client<'a>,
+ messenger: MockMessengerClient<'a>,
+ token: token::Client<'a>,
+ user: Address,
+}
+
+fn setup() -> Setup<'static> {
+ setup_with(0)
+}
+
+fn setup_with(panic_on_amount: i128) -> Setup<'static> {
+ let env = Env::default();
+ env.mock_all_auths();
+ env.cost_estimate().budget().reset_unlimited();
+ env.ledger().set_timestamp(1_000_000);
+
+ let issuer = Address::generate(&env);
+ let usdc = env.register_stellar_asset_contract_v2(issuer).address();
+ let token = token::Client::new(&env, &usdc);
+ let token_admin = token::StellarAssetClient::new(&env, &usdc);
+
+ let messenger_id = env.register(MockMessenger, (panic_on_amount,));
+ let params = Params {
+ fee_bps: FEE_BPS,
+ min_fee: MIN_FEE,
+ min_transfer: USDC,
+ max_transfer: MAX_TRANSFER,
+ max_cctp_fee_bps: 20,
+ account_fee: 0,
+ };
+ let domains: Vec = vec![
+ &env,
+ DomainCfg {
+ domain: DOMAIN_SOLANA,
+ evm_style: false,
+ forward: false,
+ max_forward_fee: 0,
+ account_creation: false,
+ max_forward_fee_new_account: 0,
+ },
+ DomainCfg {
+ domain: DOMAIN_ARC,
+ evm_style: true,
+ forward: true,
+ max_forward_fee: ARC_FORWARD_CAP,
+ account_creation: false,
+ max_forward_fee_new_account: 0,
+ },
+ ];
+ let wrapper_id = env.register(
+ wrapper::WASM,
+ (
+ usdc.clone(),
+ messenger_id.clone(),
+ Address::generate(&env),
+ Address::generate(&env),
+ Address::generate(&env),
+ params,
+ domains,
+ ),
+ );
+ let router_id = env.register(XebraBatchRouter, (wrapper_id.clone(),));
+
+ let user = Address::generate(&env);
+ token_admin.mint(&user, &(30_000_000 * USDC));
+
+ Setup {
+ router: XebraBatchRouterClient::new(&env, &router_id),
+ wrapper: wrapper::Client::new(&env, &wrapper_id),
+ messenger: MockMessengerClient::new(&env, &messenger_id),
+ token,
+ user,
+ env,
+ }
+}
+
+fn solana(env: &Env, tag: u8) -> BytesN<32> {
+ BytesN::from_array(env, &[tag; 32])
+}
+
+fn evm(env: &Env, tag: u8) -> BytesN<32> {
+ let mut b = [0u8; 32];
+ for x in b.iter_mut().skip(12) {
+ *x = tag;
+ }
+ BytesN::from_array(env, &b)
+}
+
+/// A Solana relay-path request (the wrapper's simplest path).
+fn req(s: &Setup, amount: i128, recipient: BytesN<32>) -> BridgeRequest {
+ BridgeRequest {
+ user: s.user.clone(),
+ amount,
+ destination_domain: DOMAIN_SOLANA,
+ mint_recipient: recipient,
+ // Bounded by the wrapper at 20 bps of net; 1 bp is always inside it.
+ max_fee: amount / 10_000,
+ min_finality_threshold: 2000,
+ max_wrapper_fee: amount,
+ recipient_needs_account: false,
+ recipient_owner: BytesN::from_array(&s.env, &[0u8; 32]),
+ approval_expiration_ledger: s.env.ledger().sequence() + 30,
+ deadline: s.env.ledger().timestamp() + 600,
+ }
+}
+
+fn fee(amount: i128) -> i128 {
+ core::cmp::max(amount * FEE_BPS as i128 / 10_000, MIN_FEE)
+}
+
+// ---------------------------------------------------------------------------
+// The two use cases
+// ---------------------------------------------------------------------------
+
+#[test]
+fn one_send_to_many_wallets() {
+ let s = setup();
+ let before = s.token.balance(&s.user);
+ let reqs = vec![
+ &s.env,
+ req(&s, 100 * USDC, solana(&s.env, 1)),
+ req(&s, 250 * USDC, solana(&s.env, 2)),
+ req(&s, 40 * USDC, solana(&s.env, 3)),
+ ];
+ s.router.batch(&s.user, &reqs);
+
+ assert_eq!(s.messenger.burns(), 3);
+ assert_eq!(s.wrapper.get_seq(), 3);
+ // Relay path, whole-unit amounts: each transfer debits exactly its amount (fee + net).
+ assert_eq!(s.token.balance(&s.user), before - 390 * USDC);
+ assert_eq!(
+ s.wrapper.get_accrued_fees(),
+ fee(100 * USDC) + fee(250 * USDC) + fee(40 * USDC)
+ );
+ assert_eq!(
+ s.token.balance(&s.messenger.address),
+ 390 * USDC - s.wrapper.get_accrued_fees()
+ );
+ // The router never holds anything.
+ assert_eq!(s.token.balance(&s.router.address), 0);
+}
+
+#[test]
+fn twenty_million_splits_into_two_identical_transfers() {
+ // Two byte-identical requests: the auth tree has two identical children and the host must
+ // match each to its own `bridge`. This is the "split above the per-message limit" case.
+ let s = setup();
+ let half = 10_000_000 * USDC;
+ let r = req(&s, half, solana(&s.env, 9));
+ s.router.batch(&s.user, &vec![&s.env, r.clone(), r]);
+
+ assert_eq!(s.messenger.burns(), 2);
+ assert_eq!(s.wrapper.get_seq(), 2);
+ assert_eq!(s.token.balance(&s.messenger.address), 2 * (half - fee(half)));
+}
+
+#[test]
+fn mixed_paths_in_one_batch() {
+ // A forwarded EVM transfer next to a relay-path Solana one.
+ let s = setup();
+ let mut arc = req(&s, 50 * USDC, evm(&s.env, 4));
+ arc.destination_domain = DOMAIN_ARC;
+ arc.max_fee = 200_000; // 0.02, under the 0.10 forward cap
+ let arc_q = s.wrapper.quote(&arc.amount, &false, &DOMAIN_ARC, &arc.max_fee);
+ assert!(arc_q.forwarded);
+ s.router
+ .batch(&s.user, &vec![&s.env, arc, req(&s, 50 * USDC, solana(&s.env, 5))]);
+ assert_eq!(s.messenger.burns(), 2);
+ // Forwarded: we keep fee - forward_fee. Relay path: we keep the whole fee.
+ assert_eq!(
+ s.wrapper.get_accrued_fees(),
+ arc_q.wrapper_take + fee(50 * USDC)
+ );
+}
+
+// ---------------------------------------------------------------------------
+// Atomicity: one refusal undoes the whole batch
+// ---------------------------------------------------------------------------
+
+fn assert_nothing_moved(s: &Setup, before: i128) {
+ assert_eq!(s.token.balance(&s.user), before);
+ assert_eq!(s.messenger.burns(), 0);
+ assert_eq!(s.wrapper.get_seq(), 0);
+ assert_eq!(s.wrapper.get_accrued_fees(), 0);
+ assert_eq!(s.token.balance(&s.wrapper.address), 0);
+}
+
+#[test]
+fn wrapper_refusing_the_last_transfer_reverts_the_first() {
+ let s = setup();
+ let before = s.token.balance(&s.user);
+ let reqs = vec![
+ &s.env,
+ req(&s, 100 * USDC, solana(&s.env, 1)),
+ req(&s, 100 * USDC, solana(&s.env, 2)),
+ req(&s, MAX_TRANSFER + 1, solana(&s.env, 3)), // above the wrapper's cap
+ ];
+ assert!(s.router.try_batch(&s.user, &reqs).is_err());
+ assert_nothing_moved(&s, before);
+}
+
+#[test]
+fn circle_refusing_a_middle_transfer_reverts_all() {
+ let bad = 77 * USDC;
+ let s = setup_with(bad - fee(bad)); // the mock refuses this net burn
+ let before = s.token.balance(&s.user);
+ let reqs = vec![
+ &s.env,
+ req(&s, 100 * USDC, solana(&s.env, 1)),
+ req(&s, bad, solana(&s.env, 2)),
+ req(&s, 100 * USDC, solana(&s.env, 3)),
+ ];
+ assert!(s.router.try_batch(&s.user, &reqs).is_err());
+ assert_nothing_moved(&s, before);
+}
+
+#[test]
+fn unknown_destination_in_batch_reverts_all() {
+ let s = setup();
+ let before = s.token.balance(&s.user);
+ let mut bad = req(&s, 100 * USDC, solana(&s.env, 2));
+ bad.destination_domain = 99;
+ let reqs = vec![&s.env, req(&s, 100 * USDC, solana(&s.env, 1)), bad];
+ assert!(s.router.try_batch(&s.user, &reqs).is_err());
+ assert_nothing_moved(&s, before);
+}
+
+#[test]
+fn insufficient_balance_for_the_whole_batch_reverts_all() {
+ let s = setup();
+ let before = s.token.balance(&s.user); // 30M
+ let r = req(&s, MAX_TRANSFER, solana(&s.env, 1));
+ // The user holds 30M: three 10M transfers fit exactly (fees come out of each amount), so a
+ // fourth must fail, and the three before it must not stand.
+ let reqs = vec![&s.env, r.clone(), r.clone(), r.clone(), r];
+ assert!(s.router.try_batch(&s.user, &reqs).is_err());
+ assert_nothing_moved(&s, before);
+}
+
+// ---------------------------------------------------------------------------
+// The router's own checks
+// ---------------------------------------------------------------------------
+
+#[test]
+fn empty_batch_is_refused() {
+ let s = setup();
+ let empty: Vec = Vec::new(&s.env);
+ assert_eq!(
+ s.router.try_batch(&s.user, &empty),
+ Err(Ok(Error::EmptyBatch))
+ );
+}
+
+#[test]
+fn oversized_batch_is_refused() {
+ let s = setup();
+ let mut reqs = Vec::new(&s.env);
+ for i in 0..=MAX_BATCH {
+ reqs.push_back(req(&s, 10 * USDC, solana(&s.env, i as u8 + 1)));
+ }
+ assert_eq!(
+ s.router.try_batch(&s.user, &reqs),
+ Err(Ok(Error::BatchTooLarge))
+ );
+}
+
+/// Five is what fit in one transaction against Circle's real testnet contracts (README). The mock
+/// emits fewer events than Circle, so this proves the loop, not the limit.
+#[test]
+fn five_transfers_in_one_batch() {
+ let s = setup();
+ let mut reqs = Vec::new(&s.env);
+ for i in 0..5u8 {
+ reqs.push_back(req(&s, 10 * USDC, solana(&s.env, i + 1)));
+ }
+ s.router.batch(&s.user, &reqs);
+ assert_eq!(s.messenger.burns(), 5);
+ assert_eq!(s.wrapper.get_seq(), 5);
+}
+
+#[test]
+fn request_for_another_user_is_refused() {
+ let s = setup();
+ let mut other = req(&s, 100 * USDC, solana(&s.env, 2));
+ other.user = Address::generate(&s.env);
+ let reqs = vec![&s.env, req(&s, 100 * USDC, solana(&s.env, 1)), other];
+ assert_eq!(
+ s.router.try_batch(&s.user, &reqs),
+ Err(Ok(Error::UserMismatch))
+ );
+ assert_eq!(s.messenger.burns(), 0);
+}
+
+#[test]
+fn router_error_codes_do_not_collide_with_the_wrapper() {
+ assert!(Error::EmptyBatch as u32 >= 100);
+ assert!(Error::BatchTooLarge as u32 >= 100);
+ assert!(Error::UserMismatch as u32 >= 100);
+}
+
+// ---------------------------------------------------------------------------
+// Authorization
+// ---------------------------------------------------------------------------
+
+#[test]
+fn one_signature_covers_every_transfer() {
+ let s = setup();
+ let reqs = vec![
+ &s.env,
+ req(&s, 100 * USDC, solana(&s.env, 1)),
+ req(&s, 200 * USDC, solana(&s.env, 2)),
+ ];
+ s.router.batch(&s.user, &reqs);
+
+ let auths = s.env.auths();
+ // Exactly one root authorization, for the user, on `batch(user, reqs)`.
+ assert_eq!(auths.len(), 1);
+ let (who, root) = &auths[0];
+ assert_eq!(who, &s.user);
+ let AuthorizedFunction::Contract((contract, name, args)) = &root.function else {
+ panic!("root is not a contract call");
+ };
+ assert_eq!(contract, &s.router.address);
+ assert_eq!(name, &Symbol::new(&s.env, "batch"));
+ assert_eq!(args, &(s.user.clone(), reqs.clone()).into_val(&s.env));
+
+ // Under it: one `bridge` per request, each carrying exactly that request.
+ assert_eq!(root.sub_invocations.len(), 2);
+ for (i, sub) in root.sub_invocations.iter().enumerate() {
+ let AuthorizedFunction::Contract((c, n, a)) = &sub.function else {
+ panic!("sub is not a contract call");
+ };
+ assert_eq!(c, &s.wrapper.address);
+ assert_eq!(n, &symbol_short!("bridge"));
+ assert_eq!(a, &(reqs.get(i as u32).unwrap(),).into_val(&s.env));
+ }
+}
+
+#[test]
+#[should_panic]
+fn no_signature_no_batch() {
+ let s = setup();
+ let reqs = vec![&s.env, req(&s, 100 * USDC, solana(&s.env, 1))];
+ s.env.set_auths(&[]);
+ s.router.batch(&s.user, &reqs);
+}
+
+// ---------------------------------------------------------------------------
+// The router's copies of the wrapper's types must encode exactly as the deployed WASM decodes
+// ---------------------------------------------------------------------------
+
+#[test]
+fn bridge_request_round_trips_through_the_deployed_type() {
+ let s = setup();
+ let mut r = req(&s, 123 * USDC, solana(&s.env, 7));
+ r.recipient_needs_account = true;
+ r.recipient_owner = solana(&s.env, 8);
+ let v: Val = r.clone().into_val(&s.env);
+ let theirs = wrapper::BridgeRequest::try_from_val(&s.env, &v).unwrap();
+ assert_eq!(theirs.amount, r.amount);
+ assert_eq!(theirs.recipient_owner, r.recipient_owner);
+ assert_eq!(theirs.deadline, r.deadline);
+ let back: Val = theirs.into_val(&s.env);
+ assert_eq!(BridgeRequest::try_from_val(&s.env, &back).unwrap(), r);
+}
+
+#[test]
+fn quote_round_trips_through_the_deployed_type() {
+ let env = Env::default();
+ let q = Quote {
+ amount: 1,
+ fee: 2,
+ account_fee: 3,
+ net_burned: 4,
+ remainder: 5,
+ forward_fee: 6,
+ wrapper_take: 7,
+ forwarded: true,
+ account_created: false,
+ };
+ let v: Val = q.clone().into_val(&env);
+ let theirs = wrapper::Quote::try_from_val(&env, &v).unwrap();
+ assert_eq!(theirs.wrapper_take, 7);
+ let back: Val = theirs.into_val(&env);
+ assert_eq!(Quote::try_from_val(&env, &back).unwrap(), q);
+}
diff --git a/contracts/stellar-batch-router/wasm/xebra_cctp_wrapper_v2_mainnet.wasm b/contracts/stellar-batch-router/wasm/xebra_cctp_wrapper_v2_mainnet.wasm
new file mode 100644
index 0000000000000000000000000000000000000000..70896badfd6537f2dd66bcc78bc31cab6d9265c3
GIT binary patch
literal 57448
zcmdqKdwd+%b>~@C{X{na7WJe_$*OL>K#3s1Cm_nPP>?87wq;QwB`X>408OAtg2ap6
z4L)pAq-{x-6UU|<$5Cu&qRlw5GHZ>UoowPf_7i5ulaKbZ$wag3`K)F?o%Q4G^>yXY$7`B;r=xy3g}I=bkEfjrP3nd7l4VaOafgKQ-k)#joJP
z1^>cS@Kkc`P5Bq7&0Vl+|AIG_e~KSfB?V7B>%{=-n!msUPd)gZ=P8fN)Tx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;X20gh9Q?FTNZ{tR66
z(gr&{I1z6Vn_yX8kZJVaVSs6fsLGWe#|m&6Y!ziZ%r+YXt>0V`Q$ft@_sG6e=?qDS
zR@me6+DIzGeUvyhTqH$xO;MIndE(n1b$;e{=7By-R!5GSnWlC)894%RofGHfSDI;a
z4F=BPGE!0IN$0f!JgtvlMEr@j{>iH-mHw?VXX~NBr@g+L9IiGm{
z=!MVfZ!gZFx-L8S5)s%)rlMIs1{}1`OcwF@`1~d6h}FAX7{egec)+se?{Qv6l!5J_
z?$v@#?qy7t+(uh!t3oEiX|>NIjbMD#13&K|1uy@-sI`O-cLI>2SX~$%j^!pHIo@|llMc?fvY>Ebv3#gX1
z&!6u1y~8exO#o{rzg(_xS-Om%p}#+Tyx;c&{(iMwvBkWf{?Rv@|9;RL9t@@jy;*-g
focE@K!Ep9yp2NLmOT+oYgK7Uk?_l10)w}f{Po1e<
literal 0
HcmV?d00001
diff --git a/scripts/batch-router-testnet.mjs b/scripts/batch-router-testnet.mjs
new file mode 100644
index 00000000..43479b15
--- /dev/null
+++ b/scripts/batch-router-testnet.mjs
@@ -0,0 +1,226 @@
+#!/usr/bin/env node
+// Measures and (optionally) sends a batch through XebraBatchRouter on Stellar TESTNET.
+//
+// node scripts/batch-router-testnet.mjs [arc|solana] [amount_usdc] [--send] [--same]
+// node scripts/batch-router-testnet.mjs 5 mix:arc,base,avalanche,optimism,solana [--send]
+//
+// mix: one transfer per listed chain, each to our own wallet there (one EVM key is the same address on
+// every EVM chain; Solana goes to the devnet token account below). BATCH_ENV picks the ids file.
+//
+// Without --send it only simulates and prints what the transaction would cost against the
+// network's per-transaction limits. --same makes every request byte-identical (the "split one big
+// transfer" case); otherwise each request goes to a different recipient ("one send to many").
+//
+// Testnet only, by construction: the network passphrase, RPC and contract ids are fixed below or
+// read from .secrets/batch-router-testnet.env (written when the contracts were deployed).
+import { execFileSync } from "node:child_process";
+import { readFileSync } from "node:fs";
+import { createRequire } from "node:module";
+import { dirname, join } from "node:path";
+import { fileURLToPath } from "node:url";
+
+const ROOT = join(dirname(fileURLToPath(import.meta.url)), "..");
+const require = createRequire(join(ROOT, "packages/sdk/package.json"));
+const {
+ Address,
+ Contract,
+ Keypair,
+ Networks,
+ TransactionBuilder,
+ nativeToScVal,
+ rpc,
+ xdr,
+} = require("@stellar/stellar-sdk");
+
+const RPC_URL = "https://soroban-testnet.stellar.org";
+const PASSPHRASE = Networks.TESTNET;
+const IDENTITY = "xebra-fwdtest";
+const env = Object.fromEntries(
+ readFileSync(join(ROOT, process.env.BATCH_ENV ?? ".secrets/batch-router-testnet.env"), "utf8")
+ .trim()
+ .split("\n")
+ .map((l) => l.split("=")),
+);
+
+const args = process.argv.slice(2);
+const count = Number(args[0] ?? 2);
+const dest = args.find((a) => a === "arc" || a === "solana") ?? "arc";
+const amountUsdc = Number(args.find((a) => /^\d+(\.\d+)?$/.test(a) && a !== args[0]) ?? 1);
+const SEND = args.includes("--send");
+const SAME = args.includes("--same");
+const DOMAINS = {
+ ethereum: 0,
+ avalanche: 1,
+ optimism: 2,
+ arbitrum: 3,
+ solana: 5,
+ base: 6,
+ polygon: 7,
+ unichain: 10,
+ arc: 26,
+};
+const MIX = (args.find((a) => a.startsWith("mix:")) ?? "").slice(4).split(",").filter(Boolean);
+const DOMAIN = DOMAINS[dest];
+// Per transfer: [domain, chain name]. A mix ignores and sends one per listed chain.
+const plan = MIX.length
+ ? MIX.map((c) => [DOMAINS[c], c])
+ : Array.from({ length: count }, () => [DOMAIN, dest]);
+
+const secret = execFileSync("stellar", ["keys", "show", IDENTITY]).toString().trim();
+const kp = Keypair.fromSecret(secret);
+const user = kp.publicKey();
+
+function ownEvm() {
+ const own = JSON.parse(readFileSync(join(ROOT, ".secrets/arc-testnet-recipient.json"), "utf8"));
+ return Buffer.concat([
+ Buffer.alloc(12),
+ Buffer.from((Array.isArray(own) ? own[0] : own).address.slice(2), "hex"),
+ ]);
+}
+
+function recipientBytes(i, chain) {
+ if (MIX.length) {
+ if (chain !== "solana") return ownEvm();
+ return Buffer.from("000b95cfcf91874cf7d5116f5955ba91ba66639628c42a567b1c9f359c073a1b", "hex");
+ }
+ if (dest === "arc") {
+ // i = 0 is our own Arc testnet wallet (so a sent batch is observable); the rest are distinct
+ // throwaway addresses (testnet USDC only).
+ const own = JSON.parse(readFileSync(join(ROOT, ".secrets/arc-testnet-recipient.json"), "utf8"));
+ const ownAddr = (Array.isArray(own) ? own[0] : own).address.slice(2);
+ const hex = SAME || i === 0 ? ownAddr : i.toString(16).padStart(2, "0").repeat(20);
+ return Buffer.concat([Buffer.alloc(12), Buffer.from(hex, "hex")]);
+ }
+ // Solana devnet: the faucet-claimant token account proven to accept forwarded mints.
+ // 1BFGaohSJcK9rDJubEetAthshXTLfSbMfcZWAtQNGRx, base58-decoded.
+ return Buffer.from("000b95cfcf91874cf7d5116f5955ba91ba66639628c42a567b1c9f359c073a1b", "hex");
+}
+
+function encodeReq(r) {
+ return nativeToScVal(
+ {
+ user: new Address(r.user),
+ amount: r.amount,
+ destination_domain: r.destinationDomain,
+ mint_recipient: r.mintRecipient,
+ max_fee: r.maxFee,
+ min_finality_threshold: r.minFinalityThreshold,
+ recipient_needs_account: false,
+ recipient_owner: Buffer.alloc(32),
+ approval_expiration_ledger: r.approvalExpirationLedger,
+ max_wrapper_fee: r.maxWrapperFee,
+ deadline: r.deadline,
+ },
+ {
+ type: {
+ user: ["symbol", null],
+ amount: ["symbol", "i128"],
+ destination_domain: ["symbol", "u32"],
+ mint_recipient: ["symbol", "bytes"],
+ max_fee: ["symbol", "i128"],
+ min_finality_threshold: ["symbol", "u32"],
+ recipient_needs_account: ["symbol", "bool"],
+ recipient_owner: ["symbol", "bytes"],
+ approval_expiration_ledger: ["symbol", "u32"],
+ max_wrapper_fee: ["symbol", "i128"],
+ deadline: ["symbol", "u64"],
+ },
+ },
+ );
+}
+
+const server = new rpc.Server(RPC_URL);
+async function maxFeeFor(domain) {
+ const quote = await (
+ await fetch(`https://iris-api-sandbox.circle.com/v2/burn/USDC/fees/27/${domain}?forward=true`)
+ ).json();
+ const tier = quote.find((q) => q.finalityThreshold === 2000);
+ return BigInt(tier.forwardFee.high) * 10n; // 6-dec units -> 7-dec stroops, 1.0x high
+}
+const fees = {};
+for (const [d] of plan) fees[d] ??= await maxFeeFor(d);
+const maxFee = fees[plan[0][0]];
+const { sequence } = await server.getLatestLedger();
+const deadline = BigInt(Math.floor(Date.now() / 1000) + 1200);
+const amount = BigInt(Math.round(amountUsdc * 1e7));
+
+const reqs = [];
+for (let i = 0; i < plan.length; i++) {
+ const [domain, chain] = plan[i];
+ // Circle's fee may be at most a tenth of the burn: Solana's ~0.107 needs more than 1 USDC.
+ const amt = chain === "solana" && amount < 13_000_000n ? 13_000_000n : amount;
+ reqs.push(
+ encodeReq({
+ user,
+ amount: amt,
+ destinationDomain: domain,
+ mintRecipient: recipientBytes(i, chain),
+ maxFee: fees[domain],
+ minFinalityThreshold: 2000,
+ approvalExpirationLedger: sequence + 50,
+ maxWrapperFee: amt,
+ deadline,
+ }),
+ );
+}
+
+const account = await server.getAccount(user);
+const tx = new TransactionBuilder(account, { fee: "1000000", networkPassphrase: PASSPHRASE })
+ .addOperation(
+ new Contract(env.ROUTER).call("batch", new Address(user).toScVal(), xdr.ScVal.scvVec(reqs)),
+ )
+ .setTimeout(300)
+ .build();
+
+const sim = await server.simulateTransaction(tx);
+const tag = `n=${plan.length} dest=${MIX.length ? MIX.join("+") : dest} amount=${amountUsdc} ${SAME ? "same" : "distinct"} maxFee=${maxFee}`;
+if (rpc.Api.isSimulationError(sim)) {
+ const m = sim.error.match(
+ /(contract events size bytes: \d+ > \d+|Error\([A-Za-z]+, #?[A-Za-z0-9]+\)|exceeded[^"\n]*)/,
+ );
+ console.log(`${tag} FAIL ${m ? m[0] : sim.error.slice(0, 300)}`);
+ process.exit(SEND ? 1 : 0);
+}
+
+const data = sim.transactionData.build();
+const res = data.resources();
+const eventsBytes = (sim.events ?? [])
+ .filter((e) => e.event().type().name === "contract")
+ .reduce((n, e) => n + e.event().toXDR().length, 0);
+const fp = res.footprint();
+console.log(
+ `${tag} OK instr=${res.instructions()} readB=${(res.diskReadBytes ?? res.readBytes).call(res)} writeB=${res.writeBytes()} ` +
+ `footprint=${fp.readOnly().length}+${fp.readWrite().length} events~${eventsBytes}B ` +
+ `resourceFee=${sim.minResourceFee} stroops (${Number(sim.minResourceFee) / 1e7} XLM)`,
+);
+
+if (!SEND) process.exit(0);
+
+// SDK 13 cannot parse protocol-23 TransactionMeta v4, so read the status over raw JSON-RPC.
+async function rawGetTx(hash) {
+ const r = await fetch(RPC_URL, {
+ method: "POST",
+ headers: { "content-type": "application/json" },
+ body: JSON.stringify({ jsonrpc: "2.0", id: 1, method: "getTransaction", params: { hash } }),
+ });
+ return (await r.json()).result;
+}
+
+const prepared = rpc.assembleTransaction(tx, sim).build();
+prepared.sign(kp);
+const sent = await server.sendTransaction(prepared);
+if (sent.status !== "PENDING") {
+ console.log("send failed:", sent.status, JSON.stringify(sent.errorResult ?? sent));
+ process.exit(1);
+}
+console.log("hash", sent.hash);
+for (let i = 0; i < 30; i++) {
+ await new Promise((r) => setTimeout(r, 2000));
+ const got = await rawGetTx(sent.hash);
+ if (got.status === "NOT_FOUND") continue;
+ console.log("status", got.status);
+ if (got.status !== "SUCCESS") console.log(" result", got.resultXdr);
+ process.exit(got.status === "SUCCESS" ? 0 : 1);
+}
+console.log("timed out waiting for", sent.hash);
+process.exit(1);
From 1bc133e515664e6efa857bccb9de356c6779dfd2 Mon Sep 17 00:00:00 2001
From: That guy <120946193+ezedike-evan@users.noreply.github.com>
Date: Thu, 26 Nov 2026 15:14:13 +0100
Subject: [PATCH 5/7] SDK: CommonJS require, and a 1Click JWT for the
rebalancer (#307)
Adds a default export condition to every subpath so CommonJS on Node
22.12+ can require() the package (found wiring createRebalancer into a
CommonJS NEAR Intents solver), and oneClick.jwt, sent as Authorization:
Bearer, which 1Click accepts on generate-intent and submit-intent as it
does X-API-Key.
Listed under Unreleased; no version bump here. The 0.4.1 release commit
from 15 Nov was never pushed, and dev has gained other SDK changes since.
---
apps/docs/content/docs/changelog.mdx | 4 ++++
apps/docs/content/docs/sdk/intents.mdx | 3 ++-
packages/sdk/package.json | 15 ++++++++++-----
packages/sdk/src/intents/rebalance.test.ts | 14 ++++++++++++++
packages/sdk/src/intents/rebalance.ts | 13 ++++++++++---
5 files changed, 40 insertions(+), 9 deletions(-)
diff --git a/apps/docs/content/docs/changelog.mdx b/apps/docs/content/docs/changelog.mdx
index 625fc9a1..288d6980 100644
--- a/apps/docs/content/docs/changelog.mdx
+++ b/apps/docs/content/docs/changelog.mdx
@@ -36,6 +36,10 @@ description: What changed in the Xebra API and SDK, newest first.
**SDK**, `@xebra/sdk`:
+- CommonJS code on Node 22.12 or later can `require("@xebra/sdk")` and its subpaths; before, only
+ `import` resolved them.
+- `createRebalancer({ oneClick: { jwt } })` (additive): a 1Click partner JWT works for the
+ withdrawal, as an API key does. It is sent as `Authorization: Bearer`.
- `createRebalancer` asks for the rebalance price: its quotes and builds send
`product: "rebalance"`, and with a market-maker API key on the Xebra client
(`createXebraClient({ apiKey })`) a move costs Xebra 0.01% capped at 2 USDC, plus 0.01. `estimate` returns `feeRule`.
diff --git a/apps/docs/content/docs/sdk/intents.mdx b/apps/docs/content/docs/sdk/intents.mdx
index 8d73d4d9..15214d5b 100644
--- a/apps/docs/content/docs/sdk/intents.mdx
+++ b/apps/docs/content/docs/sdk/intents.mdx
@@ -69,6 +69,7 @@ That is Xebra's part of `fees.cctp`; Circle's delivery fee and NEAR Intents' wit
|---|---|---|
| `xebra` | `Pick` | A client from `createXebraClient()`. Its `routes()` decides whether the route is offered; its API key earns the rebalance price. |
| `oneClick.apiKey` | `string` | Your 1Click partner key. Needed to withdraw, and only sent to 1Click. |
+| `oneClick.jwt` | `string` | A 1Click partner JWT, sent as `Authorization: Bearer`. Works for the withdrawal in place of `apiKey`. |
| `oneClick.baseUrl` | `string` | Where 1Click answers. Default `https://1click.chaindefuser.com`. |
| `oneClick.referral` | `string` | The distribution-channel tag in NEAR Intents' records. Default `"xebra"`. |
| `fetch` | `typeof fetch` | A fetch to use instead of the global one, for tests or a custom agent. |
@@ -285,7 +286,7 @@ exists, so a fix costs nothing but another call.
`startWithdrawal` and `submitWithdrawal` also refuse to run without a key:
-`OneClickError: Withdrawing from NEAR Intents needs a 1Click partner API key (oneClick.apiKey).`,
+`OneClickError: Withdrawing from NEAR Intents needs a 1Click partner API key (oneClick.apiKey or oneClick.jwt).`,
with `status` `0`. Nothing is signed; the withdrawal cannot go ahead without the partner key that
`generate-intent` and `submit-intent` require. `estimate` and `prepareDeposit` do not need it.
diff --git a/packages/sdk/package.json b/packages/sdk/package.json
index df8d2bc2..9461ebbb 100644
--- a/packages/sdk/package.json
+++ b/packages/sdk/package.json
@@ -10,23 +10,28 @@
"exports": {
".": {
"types": "./dist/index.d.ts",
- "import": "./dist/index.js"
+ "import": "./dist/index.js",
+ "default": "./dist/index.js"
},
"./core": {
"types": "./dist/core/index.d.ts",
- "import": "./dist/core/index.js"
+ "import": "./dist/core/index.js",
+ "default": "./dist/core/index.js"
},
"./build": {
"types": "./dist/build/index.d.ts",
- "import": "./dist/build/index.js"
+ "import": "./dist/build/index.js",
+ "default": "./dist/build/index.js"
},
"./intents": {
"types": "./dist/intents/index.d.ts",
- "import": "./dist/intents/index.js"
+ "import": "./dist/intents/index.js",
+ "default": "./dist/intents/index.js"
},
"./openapi": {
"types": "./dist/api/openapi.d.ts",
- "import": "./dist/api/openapi.js"
+ "import": "./dist/api/openapi.js",
+ "default": "./dist/api/openapi.js"
},
"./openapi.json": "./openapi.json",
"./package.json": "./package.json"
diff --git a/packages/sdk/src/intents/rebalance.test.ts b/packages/sdk/src/intents/rebalance.test.ts
index 459c74b2..a1fb9de3 100644
--- a/packages/sdk/src/intents/rebalance.test.ts
+++ b/packages/sdk/src/intents/rebalance.test.ts
@@ -365,6 +365,20 @@ describe("withdrawal", () => {
expect((err2 as OneClickError).body).toBe("bad gateway");
});
+ it("withdraws with a 1Click partner JWT instead of an API key", async () => {
+ const one = fake1Click();
+ const rb = createRebalancer({
+ xebra: fakeXebra(),
+ fetch: one.fetch,
+ now: () => NOW,
+ oneClick: { jwt: "j" },
+ });
+ await rb.startWithdrawal(REQ);
+ const g = one.calls.find((c) => c.path === "/v0/generate-intent");
+ expect(g?.headers.Authorization).toBe("Bearer j");
+ expect(g?.headers["X-API-Key"]).toBeUndefined();
+ });
+
it("quotes same asset out to the market maker's own wallet, refund to its own account", async () => {
const one = fake1Click();
const rb = createRebalancer({
diff --git a/packages/sdk/src/intents/rebalance.ts b/packages/sdk/src/intents/rebalance.ts
index 49b1d0d0..a1bbea4f 100644
--- a/packages/sdk/src/intents/rebalance.ts
+++ b/packages/sdk/src/intents/rebalance.ts
@@ -17,7 +17,7 @@
* never holds anything. If the deposit address expires before Circle's mint lands, 1Click refunds
* to `toWallet`, the market maker's own address on `to`.
*
- * The withdrawal is the one step that needs a 1Click partner API key (`generate-intent` and
+ * The withdrawal is the one step that needs a 1Click partner API key or JWT (`generate-intent` and
* `submit-intent` are partner endpoints). Market makers onboarded through partners.near-intents.org
* have one; it is passed in and only ever sent to 1Click.
*
@@ -48,6 +48,11 @@ export type IntentSigningStandard =
export interface OneClickOptions {
/** Partner API key from partners.near-intents.org. Needed to withdraw; quotes work without. */
apiKey?: string;
+ /**
+ * A 1Click partner JWT, the older form of the same credential, sent as `Authorization: Bearer`.
+ * Either this or `apiKey` lets the market maker withdraw; with both, both are sent.
+ */
+ jwt?: string;
baseUrl?: string;
/** Distribution-channel tag shown in NEAR Intents' records. Default "xebra". */
referral?: string;
@@ -316,13 +321,14 @@ export function createRebalancer(opts: RebalancerOptions) {
const base = (opts.oneClick?.baseUrl ?? ONECLICK_BASE_URL).replace(/\/+$/, "");
const referral = opts.oneClick?.referral ?? "xebra";
const apiKey = opts.oneClick?.apiKey;
+ const jwt = opts.oneClick?.jwt;
const router = createIntentsRouter({ client: opts.xebra });
let tokenCache: { at: number; list: IntentsToken[] } | null = null;
function requireKey(): void {
- if (!apiKey) {
+ if (!apiKey && !jwt) {
throw new OneClickError(
- "Withdrawing from NEAR Intents needs a 1Click partner API key (oneClick.apiKey).",
+ "Withdrawing from NEAR Intents needs a 1Click partner API key (oneClick.apiKey or oneClick.jwt).",
0,
{ code: "missing_api_key" },
);
@@ -345,6 +351,7 @@ export function createRebalancer(opts: RebalancerOptions) {
Accept: "application/json",
...(body !== undefined ? { "Content-Type": "application/json" } : {}),
...(apiKey ? { "X-API-Key": apiKey } : {}),
+ ...(jwt ? { Authorization: `Bearer ${jwt}` } : {}),
},
...(body !== undefined ? { body: JSON.stringify(body) } : {}),
signal: AbortSignal.timeout(timeoutMs),
From 1ca1844e9a5a5506a4dd325ced93d7c6ef2b6793 Mon Sep 17 00:00:00 2001
From: That guy <120946193+ezedike-evan@users.noreply.github.com>
Date: Thu, 26 Nov 2026 15:15:05 +0100
Subject: [PATCH 6/7] Web: a Stellar transfer survives a refresh or a closed
tab (#308)
The burn hash lived only in the page's memory, so a refresh lost the
transfer, and the only way back (above all to Sui, which ends at /claim)
was digging the hash out of the wallet's history.
The form now saves the transfer it is following (hash, destination,
recipient, time bound, and whether Xebra's relayer finishes it) in this
browser the moment the wallet returns the hash, and brings it back on
load. It re-enters as "waiting for Stellar", so the same Horizon check
decides where it stands. Cleared when Stellar refuses it, when Circle
reports it delivered, or on Start over. A relayed Sui transfer comes back
relayed, so the page keeps asking the relayer to finish it. If the
browser will not save, the receipt says so and offers the hash to copy.
---
.../components/bridge/stellar-bridge-form.tsx | 138 +++++++++++++++---
apps/web/lib/stellar-transfer.test.ts | 133 +++++++++++++++++
apps/web/lib/stellar-transfer.ts | 117 +++++++++++++++
3 files changed, 367 insertions(+), 21 deletions(-)
create mode 100644 apps/web/lib/stellar-transfer.test.ts
create mode 100644 apps/web/lib/stellar-transfer.ts
diff --git a/apps/web/components/bridge/stellar-bridge-form.tsx b/apps/web/components/bridge/stellar-bridge-form.tsx
index 7508be71..52d39436 100644
--- a/apps/web/components/bridge/stellar-bridge-form.tsx
+++ b/apps/web/components/bridge/stellar-bridge-form.tsx
@@ -37,6 +37,7 @@ import { formatError, reportError } from "../../lib/format-error";
import { unitsToInput } from "../../lib/max-amount";
import { type RecipientResolution, resolveRecipient } from "../../lib/solana-recipient";
import { relayToSui, suiRelayAvailable } from "../../lib/stellar-sui-relay";
+import { recallStellarTransfer, rememberStellarTransfer } from "../../lib/stellar-transfer";
import {
type ErrorContext,
type UserError,
@@ -405,6 +406,12 @@ export function StellarBridgeForm({
const stopWith = (text: string, opts?: { title?: string; steps?: string[] }) =>
setSubmitError(messageError(text, opts));
const [burnReceipt, setBurnReceipt] = useState(null);
+ // False when the browser would not save the transfer: the receipt then asks the person to keep
+ // the hash themselves, because a refresh would lose it.
+ const [saved, setSaved] = useState(true);
+ // Set when a saved transfer comes back on screen, so Horizon is asked at once instead of after
+ // the usual pause.
+ const recheckNow = useRef(false);
const txHash =
// An unconfirmed burn may have landed, so it keeps the form locked like a pending one.
burnReceipt &&
@@ -464,6 +471,25 @@ export function StellarBridgeForm({
if (prefill.recipient && (!prefill.to || target)) setDestination(prefill.recipient);
}, [prefill, domains, destinations]);
+ // A transfer this browser was following comes back on screen after a refresh or a closed tab. It
+ // re-enters as "waiting for Stellar", so the same Horizon check that follows a fresh burn decides
+ // what it is now, and a confirmed burn goes on to Circle's delivery tracking from there. A saved
+ // transfer wins over a link's prefill: the money already moving matters more than a new form.
+ useEffect(() => {
+ const r = recallStellarTransfer();
+ if (!r) return;
+ prefillApplied.current = true;
+ setSentTo(r.to);
+ // A relayed Sui transfer is only finished while the page keeps asking the relayer.
+ setSentRelayed(r.relayed === true);
+ setDestId(r.to);
+ setDestination(r.recipient);
+ recheckNow.current = true;
+ setBurnReceipt(
+ mapStellarBurnResult("timeout", r.tx, env.stellarNetworkPassphrase, r.deadlineMs),
+ );
+ }, []);
+
// Always present. With no wrapper configured, `wrapperContractId` is null and nothing can be
// sent: there is no direct path around the wrapper (see `lib/cctp-bridge.ts`).
const wrapper = useMemo(
@@ -730,16 +756,19 @@ export function StellarBridgeForm({
if (cancelled) return;
if (next.kind !== "waiting-stellar") {
setBurnReceipt(next);
+ if (next.kind === "failed" || next.kind === "not-sent") rememberStellarTransfer(null);
if (next.kind === "burned") {
- const target = stellarDestination(sentTo);
- book.remember(target.evm ? "evm" : "solana", destination);
+ // A Sui address is never saved to the address book (its family has no list).
+ const family = addressFamily(sentTo);
+ if (family !== "sui") book.remember(family, destination);
}
return;
}
timer = setTimeout(recheck, 5_000);
};
- timer = setTimeout(recheck, 5_000);
+ timer = setTimeout(recheck, recheckNow.current ? 0 : 5_000);
+ recheckNow.current = false;
return () => {
cancelled = true;
clearTimeout(timer);
@@ -784,6 +813,10 @@ export function StellarBridgeForm({
setDelivery(result);
}
+ // Delivered is the end: nothing left to come back for. Failed and claimable stay saved, since
+ // those still need the owner to finish them at `/claim`.
+ if (result.status === "known" && result.state === "delivered") rememberStellarTransfer(null);
+
const settled =
result.status === "known" &&
(result.state === "delivered" || result.state === "failed" || result.state === "claimable");
@@ -947,7 +980,8 @@ export function StellarBridgeForm({
if (!kit || !address || !quote || !mintRecipient) return;
setSubmitting(true);
setSentTo(destId);
- setSentRelayed(dest.claimOnly && suiRelayOffered && paySuiGas);
+ const relayed = dest.claimOnly && suiRelayOffered && paySuiGas;
+ setSentRelayed(relayed);
setSubmitError(null);
setBurnReceipt(null);
setPollError(null);
@@ -1063,6 +1097,18 @@ export function StellarBridgeForm({
// contract rejects rather than charging more than was displayed.
maxWrapperFee: quote.fee,
});
+ // Saved before Stellar confirms it: a burn that lands while this tab waits, or after it is
+ // closed, must still be on screen when the person comes back.
+ setSaved(
+ rememberStellarTransfer({
+ tx: hash,
+ to: destId,
+ recipient: destination.trim(),
+ at: Date.now(),
+ ...(maxTimeMs === undefined ? {} : { deadlineMs: maxTimeMs }),
+ ...(relayed ? { relayed: true } : {}),
+ }),
+ );
// Soroban `PENDING` only guarantees queueing. Wait for Horizon ledger confirmation before
// handing the hash to Circle so an on-chain `FAILED` tx never sits at "Waiting for Circle".
setStep("Waiting for Stellar to confirm");
@@ -1082,6 +1128,10 @@ export function StellarBridgeForm({
maxTimeMs,
);
setBurnReceipt(nextReceipt);
+ // Stellar refused it or it never went out: no USDC moved, so there is nothing to come back to.
+ if (nextReceipt.kind === "failed" || nextReceipt.kind === "not-sent") {
+ rememberStellarTransfer(null);
+ }
if (nextReceipt.kind === "burned") {
// Remembered once the burn is on chain, not when the field is filled: only an address that was
// actually sent to belongs in the list.
@@ -1102,6 +1152,22 @@ export function StellarBridgeForm({
setStep(null);
}
}
+
+ // Clears the receipt for a new transfer. The address and amount stay, so sending the same again is
+ // one click. Only offered once the burn is confirmed on Stellar: before that the form stays locked,
+ // because a second send could move the USDC twice.
+ function startOver() {
+ rememberStellarTransfer(null);
+ setSaved(true);
+ setBurnReceipt(null);
+ setDelivery(null);
+ setPollError(null);
+ setStalled(false);
+ setSubmitError(null);
+ }
+
+ const delivered = delivery?.status === "known" && delivery.state === "delivered";
+
return (
<>
@@ -1317,23 +1383,28 @@ export function StellarBridgeForm({
Check it on stellar.expert
-
+
+
+ {/* The way out once stellar.expert has answered: a refresh no longer clears this. */}
+
+
)}
@@ -1427,6 +1498,31 @@ export function StellarBridgeForm({
)}
+
+ {!delivered &&
+ (saved ? (
+
+ Safe to close this tab. Come back on the same browser and it picks up where it
+ left off.
+
+ ) : (
+
+ This browser could not save your transfer. Keep this hash to find it again:{" "}
+
+ {burnReceipt.txHash.slice(0, 6)}...{burnReceipt.txHash.slice(-4)}
+ {" "}
+
+
+ ))}
+
+
>
) : burnReceipt?.kind === "waiting-stellar" ? (
diff --git a/apps/web/lib/stellar-transfer.test.ts b/apps/web/lib/stellar-transfer.test.ts
new file mode 100644
index 00000000..4d81b3d7
--- /dev/null
+++ b/apps/web/lib/stellar-transfer.test.ts
@@ -0,0 +1,133 @@
+import { describe, expect, it } from "vitest";
+import {
+ MAX_AGE_MS,
+ type RememberedStellarTransfer,
+ STELLAR_TRANSFER_KEY,
+ parseStellarTransfer,
+ recallStellarTransfer,
+ rememberStellarTransfer,
+} from "./stellar-transfer";
+
+const TX = "04d2687602447b63b186354dd77fbd25c0c98a1247dc20888d11c2074256805d";
+const NOW = 1_795_000_000_000;
+
+function memoryStorage(): Storage & { data: Map } {
+ const data = new Map();
+ return {
+ data,
+ get length() {
+ return data.size;
+ },
+ clear: () => data.clear(),
+ getItem: (k) => data.get(k) ?? null,
+ key: (i) => [...data.keys()][i] ?? null,
+ removeItem: (k) => {
+ data.delete(k);
+ },
+ setItem: (k, v) => {
+ data.set(k, v);
+ },
+ };
+}
+
+const record: RememberedStellarTransfer = {
+ tx: TX,
+ to: "sui",
+ recipient: "0xc38bb6275219b5c559d1c098622c3b3c2f883772cf1ae7038e58ad661e86285e",
+ at: NOW - 60_000,
+ deadlineMs: NOW + 540_000,
+};
+
+describe("rememberStellarTransfer / recallStellarTransfer", () => {
+ it("brings back a saved transfer exactly as it was saved", () => {
+ const s = memoryStorage();
+ expect(rememberStellarTransfer(record, s)).toBe(true);
+ expect(recallStellarTransfer(s, NOW)).toEqual(record);
+ });
+
+ it("forgets the transfer when cleared", () => {
+ const s = memoryStorage();
+ rememberStellarTransfer(record, s);
+ expect(rememberStellarTransfer(null, s)).toBe(true);
+ expect(s.data.has(STELLAR_TRANSFER_KEY)).toBe(false);
+ expect(recallStellarTransfer(s, NOW)).toBeNull();
+ });
+
+ it("says so when the browser will not store anything, instead of throwing", () => {
+ const blocked = {
+ ...memoryStorage(),
+ setItem: () => {
+ throw new Error("QuotaExceededError");
+ },
+ };
+ expect(rememberStellarTransfer(record, blocked)).toBe(false);
+ });
+
+ it("returns nothing when storage itself cannot be read", () => {
+ const blocked = {
+ ...memoryStorage(),
+ getItem: () => {
+ throw new Error("SecurityError");
+ },
+ };
+ expect(recallStellarTransfer(blocked, NOW)).toBeNull();
+ });
+
+ it("keeps an EVM and a Solana destination too", () => {
+ const s = memoryStorage();
+ for (const to of ["base", "solana"] as const) {
+ rememberStellarTransfer({ ...record, to }, s);
+ expect(recallStellarTransfer(s, NOW)?.to).toBe(to);
+ }
+ });
+
+ it("drops a record older than the limit, so an old hash is never re-checked against a Horizon that no longer keeps it", () => {
+ const s = memoryStorage();
+ rememberStellarTransfer({ ...record, at: NOW - MAX_AGE_MS - 1 }, s);
+ expect(recallStellarTransfer(s, NOW)).toBeNull();
+ });
+});
+
+describe("parseStellarTransfer", () => {
+ it("refuses anything that is not a whole record", () => {
+ const bad = [
+ null,
+ "",
+ "not json",
+ "null",
+ "[]",
+ JSON.stringify({ ...record, tx: "abc" }),
+ JSON.stringify({ ...record, tx: TX.toUpperCase().replace(/./, "Z") }),
+ JSON.stringify({ ...record, to: "mars" }),
+ JSON.stringify({ ...record, recipient: 7 }),
+ JSON.stringify({ ...record, recipient: "x".repeat(200) }),
+ JSON.stringify({ ...record, at: "yesterday" }),
+ ];
+ for (const raw of bad) expect(parseStellarTransfer(raw, NOW)).toBeNull();
+ });
+
+ it("accepts an upper-case hash and stores it lower-case", () => {
+ const raw = JSON.stringify({ ...record, tx: TX.toUpperCase() });
+ expect(parseStellarTransfer(raw, NOW)?.tx).toBe(TX);
+ });
+
+ it("ignores a deadline that is not a number rather than refusing the record", () => {
+ const raw = JSON.stringify({ ...record, deadlineMs: "soon" });
+ const parsed = parseStellarTransfer(raw, NOW);
+ expect(parsed?.tx).toBe(TX);
+ expect(parsed && "deadlineMs" in parsed).toBe(false);
+ });
+
+ it("keeps a relayed Sui transfer relayed, so a refresh still asks the relayer to finish it", () => {
+ const raw = JSON.stringify({ ...record, to: "sui", relayed: true });
+ expect(parseStellarTransfer(raw, NOW)?.relayed).toBe(true);
+ });
+
+ it("treats anything but true as not relayed", () => {
+ for (const relayed of ["true", 1, null]) {
+ const parsed = parseStellarTransfer(JSON.stringify({ ...record, relayed }), NOW);
+ expect(parsed?.tx).toBe(TX);
+ expect(parsed && "relayed" in parsed).toBe(false);
+ }
+ });
+});
diff --git a/apps/web/lib/stellar-transfer.ts b/apps/web/lib/stellar-transfer.ts
new file mode 100644
index 00000000..47643061
--- /dev/null
+++ b/apps/web/lib/stellar-transfer.ts
@@ -0,0 +1,117 @@
+import { type DestinationId, isEvmChainId } from "@xebra/sdk/core";
+
+/**
+ * The Stellar transfer this browser is following, kept so a refresh or a closed tab does not lose
+ * it. Without this the burn hash lived only in the page's memory, and the one way back to a transfer
+ * (above all to Sui, which nobody delivers and which ends at `/claim`) was digging the hash out of a
+ * wallet's history.
+ *
+ * Saved the moment the wallet hands back the hash, before Stellar confirms it: a burn that lands
+ * while the tab is closing must not be lost. Cleared when Stellar refuses it, when Circle reports it
+ * delivered, or when the person starts over. Only public facts are kept: the hash, the chain, the
+ * address it goes to, and the transaction's time bound.
+ */
+
+export const STELLAR_TRANSFER_KEY = "xebra.stellar.transfer";
+
+/**
+ * Older records are dropped instead of re-checked. A restored transfer is first looked up on Horizon,
+ * and a Horizon that has pruned an old transaction answers 404, which after the time bound reads as
+ * "not sent": the one wrong thing this must never say about a burn that went through.
+ */
+export const MAX_AGE_MS = 30 * 24 * 60 * 60_000;
+
+const TX_HASH = /^[0-9a-fA-F]{64}$/;
+/** The longest address any destination takes is Sui's: 0x and 64 hex. */
+const MAX_RECIPIENT_LENGTH = 128;
+
+export interface RememberedStellarTransfer {
+ tx: string;
+ to: DestinationId;
+ /** The address the person typed, to show again. */
+ recipient: string;
+ /** When it was signed, ms since epoch. */
+ at: number;
+ /** The signed transaction's upper time bound, ms since epoch, when it has one. */
+ deadlineMs?: number;
+ /**
+ * Sui with "pay the Sui network fee for me": the page asks Xebra's relayer, and asking is what
+ * makes it finish the transfer. Kept so a transfer that comes back after a refresh asks it again.
+ */
+ relayed?: boolean;
+}
+
+function isDestinationId(v: unknown): v is DestinationId {
+ return typeof v === "string" && (v === "solana" || v === "sui" || isEvmChainId(v));
+}
+
+/** A stored record, checked field by field. Anything else is treated as nothing stored. */
+export function parseStellarTransfer(
+ raw: string | null,
+ nowMs: number,
+): RememberedStellarTransfer | null {
+ if (!raw) return null;
+ let v: unknown;
+ try {
+ v = JSON.parse(raw);
+ } catch {
+ return null;
+ }
+ if (typeof v !== "object" || v === null || Array.isArray(v)) return null;
+ const r = v as Record;
+ if (typeof r.tx !== "string" || !TX_HASH.test(r.tx)) return null;
+ if (!isDestinationId(r.to)) return null;
+ if (typeof r.recipient !== "string" || r.recipient.length > MAX_RECIPIENT_LENGTH) return null;
+ if (typeof r.at !== "number" || !Number.isFinite(r.at)) return null;
+ if (nowMs - r.at > MAX_AGE_MS) return null;
+ const out: RememberedStellarTransfer = {
+ tx: r.tx.toLowerCase(),
+ to: r.to,
+ recipient: r.recipient,
+ at: r.at,
+ };
+ if (typeof r.deadlineMs === "number" && Number.isFinite(r.deadlineMs)) {
+ out.deadlineMs = r.deadlineMs;
+ }
+ if (r.relayed === true) out.relayed = true;
+ return out;
+}
+
+function browserStorage(): Storage | null {
+ try {
+ return typeof window === "undefined" ? null : window.localStorage;
+ } catch {
+ return null;
+ }
+}
+
+/**
+ * Saves the transfer, or forgets it with `null`. False when the browser would not store it (private
+ * mode, blocked storage): the transfer still works, it just cannot be picked up again here.
+ */
+export function rememberStellarTransfer(
+ t: RememberedStellarTransfer | null,
+ storage: Storage | null = browserStorage(),
+): boolean {
+ if (!storage) return false;
+ try {
+ if (t) storage.setItem(STELLAR_TRANSFER_KEY, JSON.stringify(t));
+ else storage.removeItem(STELLAR_TRANSFER_KEY);
+ return true;
+ } catch {
+ return false;
+ }
+}
+
+/** The Stellar transfer this browser was following, if any. */
+export function recallStellarTransfer(
+ storage: Storage | null = browserStorage(),
+ nowMs: number = Date.now(),
+): RememberedStellarTransfer | null {
+ if (!storage) return null;
+ try {
+ return parseStellarTransfer(storage.getItem(STELLAR_TRANSFER_KEY), nowMs);
+ } catch {
+ return null;
+ }
+}
From a2efdb3f1dcc1f70f7fc8dc4a54c6b12b78bab5f Mon Sep 17 00:00:00 2001
From: That guy <120946193+ezedike-evan@users.noreply.github.com>
Date: Thu, 26 Nov 2026 15:16:34 +0100
Subject: [PATCH 7/7] Sui send: check the chain after a wallet error before
allowing a retry (#309)
A wallet can send the burn through its own RPC and still report a failure
(the 11-15 pilot: Android UnknownHostException, then a retry that sent).
After a wallet error the form now reads the sender's last burn on Sui
(new /api/sui-stellar/last-burn, Sui GraphQL) and, if a new one landed,
follows it and says the transfer went through instead of inviting a
second send. Network errors get plain wording; when Sui cannot be read
the message says to check the wallet's activity first.
Also: a bare "closed" (connection closed) no longer counts as a decline,
a decline is checked twice, and the relayer loop no longer restarts on
"completing", which dropped the relayer's answer and posted the mint
again.
---
.../app/api/sui-stellar/last-burn/route.ts | 22 +++
apps/web/app/sui/sui-client.tsx | 109 +++++++++----
apps/web/app/sui/sui-evm.tsx | 57 ++++++-
apps/web/lib/sui-send-check.test.ts | 143 ++++++++++++++++++
apps/web/lib/sui-send-check.ts | 101 +++++++++++++
apps/web/lib/sui-stellar/last-burn.test.ts | 61 ++++++++
apps/web/lib/sui-stellar/last-burn.ts | 87 +++++++++++
7 files changed, 544 insertions(+), 36 deletions(-)
create mode 100644 apps/web/app/api/sui-stellar/last-burn/route.ts
create mode 100644 apps/web/lib/sui-send-check.test.ts
create mode 100644 apps/web/lib/sui-send-check.ts
create mode 100644 apps/web/lib/sui-stellar/last-burn.test.ts
create mode 100644 apps/web/lib/sui-stellar/last-burn.ts
diff --git a/apps/web/app/api/sui-stellar/last-burn/route.ts b/apps/web/app/api/sui-stellar/last-burn/route.ts
new file mode 100644
index 00000000..988c6f9d
--- /dev/null
+++ b/apps/web/app/api/sui-stellar/last-burn/route.ts
@@ -0,0 +1,22 @@
+import { notFound, suiStellarEnabled } from "../../../../lib/sui-stellar/config";
+import { SUI_ADDRESS, lastBurn } from "../../../../lib/sui-stellar/last-burn";
+
+/**
+ * The newest CCTP burn a Sui address has sent: `{ burn: { digest, destinationDomain } | null }`.
+ * The Sui page reads it before signing and again after a wallet error, to tell a transfer that went
+ * through anyway from one that did not. Public data; 502 when Sui does not answer.
+ */
+export const dynamic = "force-dynamic";
+
+export async function GET(request: Request): Promise {
+ if (!suiStellarEnabled()) return notFound();
+ const sender = new URL(request.url).searchParams.get("sender")?.trim() ?? "";
+ if (!SUI_ADDRESS.test(sender)) {
+ return Response.json({ error: "That is not a Sui address." }, { status: 400 });
+ }
+ try {
+ return Response.json({ burn: await lastBurn(sender) });
+ } catch {
+ return Response.json({ error: "Sui did not answer" }, { status: 502 });
+ }
+}
diff --git a/apps/web/app/sui/sui-client.tsx b/apps/web/app/sui/sui-client.tsx
index f453f6af..7dcb7c1e 100644
--- a/apps/web/app/sui/sui-client.tsx
+++ b/apps/web/app/sui/sui-client.tsx
@@ -13,9 +13,21 @@ import { ArrowRight, Check } from "../../components/ui/icons";
import { Notice } from "../../components/ui/notice";
import { useWallets } from "../../components/wallet/wallet-provider";
import { reportError } from "../../lib/format-error";
+import {
+ findBurnAfterFailure,
+ isDeclined,
+ lastSuiBurn,
+ sendFailureMessage,
+} from "../../lib/sui-send-check";
import { claimOnStellar } from "../../lib/sui-stellar/claim-client";
import { signAndExecuteSui } from "../../lib/wallets/sui";
-import { type SuiDestination, SuiDestinationPicker, SuiForwarded, recallSuiEvm } from "./sui-evm";
+import {
+ RecoveredNotice,
+ type SuiDestination,
+ SuiDestinationPicker,
+ SuiForwarded,
+ recallSuiEvm,
+} from "./sui-evm";
/**
* Sui to Stellar: connect a Sui wallet, burn USDC, and watch it arrive.
@@ -29,6 +41,8 @@ import { type SuiDestination, SuiDestinationPicker, SuiForwarded, recallSuiEvm }
const STORAGE_KEY = "xebra.sui-stellar.digest";
const POLL_MS = 4000;
const DIGEST = /^[1-9A-HJ-NP-Za-km-z]{32,64}$/;
+/** Stellar's CCTP domain: the only burn this form follows itself. */
+const STELLAR_DOMAIN = 27;
export type Delivery =
| { kind: "idle" }
@@ -66,12 +80,9 @@ const short = (s: string) => `${s.slice(0, 6)}...${s.slice(-4)}`;
type Problem = { text: string; declined: boolean };
-// Wallets word a declined request differently ("User rejected the request", "Cancelled", ...).
-const DECLINED = /reject|declin|den(y|ied)|cancel|closed|dismiss/i;
-
function problem(label: string, err: unknown): Problem {
const text = reportError(label, err);
- return { text, declined: DECLINED.test(text) };
+ return { text, declined: isDeclined(text) };
}
/** The standalone `/sui` page: a heading around the same transfer the bridge screen embeds. */
@@ -147,8 +158,10 @@ export function SuiTransfer({
}) {
const [amount, setAmount] = useState("");
const [recipient, setRecipient] = useState("");
- const [step, setStep] = useState<"idle" | "preparing" | "signing">("idle");
+ const [step, setStep] = useState<"idle" | "preparing" | "signing" | "checking">("idle");
const [error, setError] = useState(null);
+ // The wallet reported an error, but the burn was on Sui anyway.
+ const [recovered, setRecovered] = useState(false);
const [to, setTo] = useState("stellar");
const forwardedKey = [...evmDestinations, ...(solana ? ["solana"] : [])].join(",");
@@ -208,7 +221,11 @@ export function SuiTransfer({
async function send() {
if (!wallet || !account) return;
setError(null);
+ setRecovered(false);
setStep("preparing");
+ // The newest burn before this one, read alongside the build, to recognise this one after an error.
+ const before = lastSuiBurn(account.address);
+ let signing = false;
try {
const res = await fetch("/api/sui-stellar/build", {
method: "POST",
@@ -224,23 +241,53 @@ export function SuiTransfer({
setError({ text: body.error ?? "Could not prepare the transfer.", declined: false });
return;
}
+ await before;
setStep("signing");
+ signing = true;
const tx = await signAndExecuteSui(wallet, account, body.transaction);
- remember(tx);
- setAttest("unknown");
- setDelivery({ kind: "idle" });
- setDigest(tx);
+ follow(tx);
} catch (err) {
- setError(problem("sui burn failed", err));
+ const p = problem("sui burn failed", err);
+ if (!signing) {
+ setError(p);
+ return;
+ }
+ // Nothing is said until Sui has been checked: the wallet may have sent it before failing.
+ setStep("checking");
+ const check = await findBurnAfterFailure(account.address, await before, {
+ // A decline is checked twice, not once: some wallets report one after sending anyway.
+ ...(p.declined ? { delaysMs: [0, 3000] } : {}),
+ });
+ if (check.kind === "found" && check.burn.destinationDomain === STELLAR_DOMAIN) {
+ setRecovered(true);
+ follow(check.burn.digest);
+ return;
+ }
+ const outcome = check.kind === "none" ? "none" : "unknown";
+ setError(
+ p.declined && outcome === "none"
+ ? p
+ : { text: sendFailureMessage(p.text, outcome), declined: false },
+ );
} finally {
setStep("idle");
}
}
+ function follow(tx: string) {
+ remember(tx);
+ setAttest("unknown");
+ setDelivery({ kind: "idle" });
+ setDigest(tx);
+ }
+
// Follow a burn: ask Circle until it attests, then ask the relayer to finish the mint.
+ // The loop restarts only when the transfer settles, not on every delivery change: restarting on
+ // "completing" dropped the relayer's answer and posted the mint a second time.
const completing = useRef(false);
+ const settled = delivery.kind === "done" || delivery.kind === "stuck";
useEffect(() => {
- if (!digest || delivery.kind === "done" || delivery.kind === "stuck") return;
+ if (!digest || settled) return;
let cancelled = false;
let timer: ReturnType;
@@ -310,7 +357,7 @@ export function SuiTransfer({
cancelled = true;
clearTimeout(timer);
};
- }, [digest, delivery.kind, relayerEnabled]);
+ }, [digest, settled, relayerEnabled]);
function startOver() {
remember(null);
@@ -321,6 +368,7 @@ export function SuiTransfer({
setError(null);
setClaimError(null);
setRecipientSeen(null);
+ setRecovered(false);
}
async function claim() {
@@ -339,20 +387,23 @@ export function SuiTransfer({
}
const progress = digest ? (
-