@sodax/sdk 2.1.0-rc.3 → 2.1.0-rc.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -3337,7 +3337,7 @@ var spokeChainConfig = {
3337
3337
  supportedTokens: suiSupportedTokens,
3338
3338
  nativeToken: "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI",
3339
3339
  bnUSD: "0xff4de2b2b57dd7611d2812d231a467d007b702a101fd5c7ad3b278257cddb507::bnusd::BNUSD",
3340
- rpc_url: "https://fullnode.mainnet.sui.io:443",
3340
+ rpc_url: "https://sui-rpc.publicnode.com",
3341
3341
  chain: baseChainInfo[ChainKeys.SUI_MAINNET],
3342
3342
  pollingConfig: {
3343
3343
  pollingIntervalMs: 500,
@@ -3489,6 +3489,7 @@ var ICON_TX_RESULT_WAIT_MAX_RETRY = 10;
3489
3489
  var MAX_UINT256 = (1n << 256n) - 1n;
3490
3490
  var FEE_PERCENTAGE_SCALE = 10000n;
3491
3491
  var DEFAULT_DEADLINE_OFFSET = 300n;
3492
+ var DEFAULT_API_BASE_URL = "https://api.sodax.com/v1";
3492
3493
  var DEFAULT_BACKEND_API_ENDPOINT = "https://api.sodax.com/v1/be";
3493
3494
  var DEFAULT_BACKEND_API_TIMEOUT = 3e4;
3494
3495
  var DEFAULT_BACKEND_API_HEADERS = {
@@ -3499,8 +3500,9 @@ var DEFAULT_RELAYER_API_ENDPOINT = "https://xcall-relay.nw.iconblockchain.xyz";
3499
3500
  var VAULT_TOKEN_DECIMALS = 18;
3500
3501
  var DEFAULT_SPONSORING_API_ENDPOINT = "https://api.sodax.com/v1";
3501
3502
  var SPONSORING_API_STELLAR_BASE_PATH = "/sponsorships/stellar";
3503
+ var BACKEND_API_BASE_PATH = "/be";
3502
3504
  var apiConfig = {
3503
- baseURL: DEFAULT_BACKEND_API_ENDPOINT,
3505
+ baseURL: DEFAULT_API_BASE_URL,
3504
3506
  timeout: DEFAULT_BACKEND_API_TIMEOUT,
3505
3507
  headers: DEFAULT_BACKEND_API_HEADERS
3506
3508
  };
@@ -4428,7 +4430,13 @@ function isValidWalletProviderForChainKey(chainKey, walletProvider) {
4428
4430
  }
4429
4431
 
4430
4432
  // ../types/dist/index.js
4431
- var CONFIG_VERSION = 223;
4433
+ var CONFIG_VERSION = 225;
4434
+
4435
+ // src/shared/utils/resolveTimeoutMs.ts
4436
+ function resolveTimeoutMs(timeout, fallbackMs) {
4437
+ if (timeout === void 0 || !Number.isFinite(timeout)) return fallbackMs;
4438
+ return Math.max(0, timeout);
4439
+ }
4432
4440
  function isEvmSpokeChainConfig(value) {
4433
4441
  return typeof value === "object" && value !== null && value.chain.type === "EVM" && value.chain.key !== HUB_CHAIN_KEY;
4434
4442
  }
@@ -4855,7 +4863,7 @@ async function pollForExecutedPacket(payload, deadline) {
4855
4863
  }
4856
4864
  async function waitUntilIntentExecuted(payload) {
4857
4865
  try {
4858
- const timeout = payload.timeout ?? DEFAULT_RELAY_TX_TIMEOUT;
4866
+ const timeout = resolveTimeoutMs(payload.timeout, DEFAULT_RELAY_TX_TIMEOUT);
4859
4867
  const startTime = Date.now();
4860
4868
  const deadline = startTime + timeout;
4861
4869
  let lastPollingError;
@@ -4888,7 +4896,8 @@ async function waitUntilIntentExecuted(payload) {
4888
4896
  }
4889
4897
  async function relayTxAndWaitPacket(params) {
4890
4898
  try {
4891
- const { srcTxHash, data, chainKey, relayerApiEndpoint, timeout = DEFAULT_RELAY_TX_TIMEOUT, pollTxHash } = params;
4899
+ const { srcTxHash, data, chainKey, relayerApiEndpoint, pollTxHash } = params;
4900
+ const timeout = resolveTimeoutMs(params.timeout, DEFAULT_RELAY_TX_TIMEOUT);
4892
4901
  const intentRelayChainId = getIntentRelayChainId(chainKey).toString();
4893
4902
  const isSplitTxChain = isSolanaChainKeyType(chainKey) || isBitcoinChainKeyType(chainKey);
4894
4903
  invariant(!isSplitTxChain || data !== void 0, "Data is required for Solana and Bitcoin chain keys");
@@ -14296,6 +14305,17 @@ var ConfigService = class {
14296
14305
  get leverageYieldPartnerFee() {
14297
14306
  return this.leverageYield.partnerFee ?? this.fee;
14298
14307
  }
14308
+ // Effective backend submit-tx toggle per feature. Read live off the same `swaps` / `bridge` slots as
14309
+ // `partnerFee` so an omitted flag resolves to the ON default here, in one place, instead of leaving
14310
+ // `config.swaps.useBackendSubmitTx === undefined` while the backend path is actually active.
14311
+ // The deprecated `swapsOptions` / `bridgeOptions` keys are still honoured as a second-precedence
14312
+ // fallback, so a pre-existing explicit opt-out keeps the client-side path instead of silently flipping.
14313
+ get swapUseBackendSubmitTx() {
14314
+ return this.swaps.useBackendSubmitTx ?? this.sodax.swapsOptions?.useBackendSubmitTx ?? true;
14315
+ }
14316
+ get bridgeUseBackendSubmitTx() {
14317
+ return this.bridge.useBackendSubmitTx ?? this.sodax.bridgeOptions?.useBackendSubmitTx ?? true;
14318
+ }
14299
14319
  get dex() {
14300
14320
  return this.sodax.dex;
14301
14321
  }
@@ -26919,19 +26939,20 @@ var SolverApiService = class {
26919
26939
 
26920
26940
  // src/backendApi/pollBackendSubmitTx.ts
26921
26941
  async function pollBackendSubmitTx({
26922
- deadline,
26942
+ attempt,
26923
26943
  terminalStatus,
26924
26944
  getStatus,
26925
26945
  onExecuted,
26926
26946
  intervalMs = 1e3,
26927
26947
  requestTimeoutMs
26928
26948
  }) {
26929
- const reserveMs = Math.min(Math.ceil((deadline - Date.now()) / 3), 2e4);
26930
- const pollDeadline = deadline - reserveMs;
26931
- const requestOverride = () => requestTimeoutMs === void 0 ? void 0 : { timeout: Math.min(pollDeadline - Date.now(), requestTimeoutMs) };
26932
- while (Date.now() < pollDeadline) {
26933
- const statusResult = await getStatus(requestOverride());
26949
+ let polls = 0;
26950
+ let lastStatusError;
26951
+ for (let requestTimeout = attempt.requestTimeout(requestTimeoutMs); requestTimeout !== null; requestTimeout = attempt.requestTimeout(requestTimeoutMs)) {
26952
+ polls += 1;
26953
+ const statusResult = await getStatus({ timeout: requestTimeout });
26934
26954
  if (statusResult.ok) {
26955
+ lastStatusError = void 0;
26935
26956
  const { status, result, failureReason, abandonedAt } = statusResult.value.data;
26936
26957
  if (status === terminalStatus) {
26937
26958
  const value = onExecuted(result);
@@ -26941,11 +26962,70 @@ async function pollBackendSubmitTx({
26941
26962
  const reason = failureReason ? `: ${failureReason}` : "";
26942
26963
  return { ok: false, cause: new Error(`backend submit-tx ${status}${reason}`) };
26943
26964
  }
26965
+ } else {
26966
+ lastStatusError = statusResult.error;
26944
26967
  }
26945
- await new Promise((resolve) => setTimeout(resolve, Math.min(intervalMs, pollDeadline - Date.now())));
26968
+ if (attempt.remaining() <= intervalMs) break;
26969
+ await sleep(intervalMs);
26970
+ }
26971
+ if (polls === 0) {
26972
+ return { ok: false, cause: new Error("backend submit-tx submitted, but no budget was left to poll for status") };
26973
+ }
26974
+ if (lastStatusError !== void 0) {
26975
+ return {
26976
+ ok: false,
26977
+ cause: new Error(`backend submit-tx status polling failed before reaching ${terminalStatus}`, {
26978
+ cause: lastStatusError
26979
+ })
26980
+ };
26946
26981
  }
26947
26982
  return { ok: false, cause: new Error(`backend submit-tx polling timed out before reaching ${terminalStatus}`) };
26948
26983
  }
26984
+
26985
+ // src/backendApi/submitTxAttempt.ts
26986
+ function noRequestBudgetCause(serviceTimeoutMs) {
26987
+ return serviceTimeoutMs > 0 ? new Error("backend submit-tx skipped: the caller timeout left no budget for the attempt") : new Error(`backend submit-tx skipped: api timeout must be a positive number, got ${serviceTimeoutMs}`);
26988
+ }
26989
+ function createSubmitTxAttempt(callerTimeoutMs) {
26990
+ const deadline = Date.now() + resolveTimeoutMs(callerTimeoutMs, 0);
26991
+ const remaining = () => Math.max(0, deadline - Date.now());
26992
+ return {
26993
+ remaining,
26994
+ requestTimeout: (serviceTimeoutMs) => {
26995
+ const timeout = Math.min(remaining(), serviceTimeoutMs);
26996
+ return timeout > 0 ? timeout : null;
26997
+ }
26998
+ };
26999
+ }
27000
+
27001
+ // src/backendApi/runBackendSubmitTx.ts
27002
+ async function runBackendSubmitTx({
27003
+ attempt,
27004
+ api,
27005
+ body,
27006
+ statusQuery,
27007
+ terminalStatus,
27008
+ onExecuted
27009
+ }) {
27010
+ const serviceTimeoutMs = api.getTimeout();
27011
+ const requestTimeout = attempt.requestTimeout(serviceTimeoutMs);
27012
+ if (requestTimeout === null) return { ok: false, cause: noRequestBudgetCause(serviceTimeoutMs) };
27013
+ const submitted = await api.submitTx(body, { timeout: requestTimeout });
27014
+ if (!submitted.ok) return { ok: false, cause: submitted.error };
27015
+ if (!submitted.value.success) {
27016
+ return { ok: false, cause: new Error(`backend submit-tx not accepted: ${submitted.value.data.message}`) };
27017
+ }
27018
+ const polled = await pollBackendSubmitTx({
27019
+ attempt,
27020
+ terminalStatus,
27021
+ getStatus: (override) => api.getSubmitTxStatus(statusQuery, override),
27022
+ onExecuted,
27023
+ // While this ceiling is the smaller bound the poll retries within the attempt; once the attempt's
27024
+ // remainder falls below it, one stalled request can spend the rest.
27025
+ requestTimeoutMs: serviceTimeoutMs
27026
+ });
27027
+ return polled.ok ? { ok: true, value: polled.value } : { ok: false, cause: polled.cause };
27028
+ }
26949
27029
  function decodePacketIntentTarget(payload) {
26950
27030
  try {
26951
27031
  const hex = payload.startsWith("0x") ? payload.slice(2) : payload;
@@ -26996,20 +27076,33 @@ var SwapService = class {
26996
27076
  spoke;
26997
27077
  // swap config
26998
27078
  solver;
26999
- partnerFee;
27000
27079
  relayerApiEndpoint;
27001
- // backend swaps-API client + opt-in 2-step submit-tx flag
27080
+ // backend swaps-API client
27002
27081
  backendApi;
27003
- useBackendSubmitTx;
27004
- constructor({ config, hubProvider, spoke, backendApi, useBackendSubmitTx }) {
27082
+ /**
27083
+ * Effective 2-step submit-tx flow (`swaps.useBackendSubmitTx`, default on). Read live off
27084
+ * `ConfigService`, like {@link SwapService.partnerFee}, so the config object and the behavior can
27085
+ * never disagree.
27086
+ */
27087
+ get useBackendSubmitTx() {
27088
+ return this.config.swapUseBackendSubmitTx;
27089
+ }
27090
+ /**
27091
+ * Effective swap partner fee (`swaps.partnerFee`, else the global `fee`). Read live off
27092
+ * `ConfigService` rather than snapshotted in the constructor, so it cannot diverge from
27093
+ * `config.swapPartnerFee` if the config object is ever replaced (see `ConfigService.initialize`).
27094
+ * `BridgeService` and `LeverageYieldService` resolve their fees the same way.
27095
+ */
27096
+ get partnerFee() {
27097
+ return this.config.swapPartnerFee;
27098
+ }
27099
+ constructor({ config, hubProvider, spoke, backendApi }) {
27005
27100
  this.solver = config.solver;
27006
- this.partnerFee = config.swapPartnerFee;
27007
27101
  this.relayerApiEndpoint = config.relay.relayerApiEndpoint;
27008
27102
  this.config = config;
27009
27103
  this.hubProvider = hubProvider;
27010
27104
  this.spoke = spoke;
27011
27105
  this.backendApi = backendApi;
27012
- this.useBackendSubmitTx = useBackendSubmitTx ?? false;
27013
27106
  }
27014
27107
  /**
27015
27108
  * Estimates the gas cost for a raw (unsigned) transaction on a spoke chain.
@@ -27154,21 +27247,26 @@ var SwapService = class {
27154
27247
  * Executes a full end-to-end cross-chain swap.
27155
27248
  *
27156
27249
  * Orchestrates the complete swap lifecycle. `createIntent` first submits the intent transaction on
27157
- * the source spoke chain; completion then runs via one of two paths, both bounded by a single
27158
- * shared `timeout` budget:
27159
- *
27160
- * - **Client-side (default), {@link fallbackSwapSteps}:** verifies the spoke tx landed on-chain,
27161
- * relays it to the hub (Sonic) and waits for the packet — skipped when `srcChainKey` is the hub,
27162
- * where the spoke tx already is the hub tx — then calls `postExecution` to notify the solver,
27163
- * triggering it to fill the intent.
27164
- * - **Backend 2-step (opt-in via `swapsOptions.useBackendSubmitTx`), {@link submitTx}:** hands the
27250
+ * the source spoke chain; completion then runs via one of two paths, each bounded by its own `timeout`
27251
+ * budget:
27252
+ *
27253
+ * - **Client-side (opt-out via `swaps.useBackendSubmitTx: false`), {@link fallbackSwapSteps}:** verifies
27254
+ * the spoke tx landed on-chain, relays it to the hub (Sonic) and waits for the packet — skipped when
27255
+ * `srcChainKey` is the hub, where the spoke tx already is the hub tx — then calls `postExecution` to
27256
+ * notify the solver, triggering it to fill the intent.
27257
+ * - **Backend 2-step (default via `swaps.useBackendSubmitTx`), {@link submitTx}:** hands the
27165
27258
  * broadcast tx to the swaps API, which verifies, relays and post-executes server-side, then polls
27166
27259
  * for completion. On ANY non-success it transparently falls back to the client-side path above —
27167
27260
  * safe because re-relaying / re-posting an already-processed swap is idempotent (no double-fill).
27168
27261
  *
27169
27262
  * @param _params - Swap action params including intent parameters, wallet provider, and an optional
27170
- * `timeout` — the single shared budget for the whole completion flow (relay/poll plus any
27171
- * fallback), so total wall-clock never exceeds it.
27263
+ * `timeout` — a PER-ATTEMPT budget, not an end-to-end one. The backend attempt (submit POST + status
27264
+ * poll) gets it, and if that attempt does not complete the client-side relay wait gets a fresh one
27265
+ * starting after verification, so neither a stalled backend nor a slow source-chain confirmation can
27266
+ * shorten it. Worst-case wall-clock is `createIntent + timeout + verification +
27267
+ * max(timeout, RELAY_FALLBACK_FLOOR_MS) + postExecution`, where verification is bounded by the source
27268
+ * chain's `pollingConfig.maxTimeoutMs` and the first and last terms are not bounded by `timeout` at
27269
+ * all. See `docs/SWAPS.md` § How `timeout` bounds each attempt.
27172
27270
  * @returns A `Result<SwapResponse, SwapError>`. On success:
27173
27271
  * - `solverExecutionResponse` — solver acknowledgement (`{ answer: 'OK', intent_hash }`).
27174
27272
  * - `intent` — the on-chain intent object that was created.
@@ -27202,9 +27300,9 @@ var SwapService = class {
27202
27300
  return { ok: false, error: createIntentResult.error };
27203
27301
  }
27204
27302
  const created = createIntentResult.value;
27205
- const deadline = Date.now() + (_params.timeout ?? DEFAULT_RELAY_TX_TIMEOUT);
27303
+ const timeoutMs = resolveTimeoutMs(_params.timeout, DEFAULT_RELAY_TX_TIMEOUT);
27206
27304
  if (this.useBackendSubmitTx) {
27207
- const submitted = await this.submitTx(_params, created, deadline);
27305
+ const submitted = await this.submitTx(_params, created, createSubmitTxAttempt(timeoutMs));
27208
27306
  if (submitted.ok) return submitted;
27209
27307
  this.config.logger.warn(
27210
27308
  "[swap] backend submit-tx did not complete; falling back to the client-side relay",
@@ -27213,7 +27311,7 @@ var SwapService = class {
27213
27311
  }
27214
27312
  );
27215
27313
  }
27216
- return this.fallbackSwapSteps(_params, created, deadline);
27314
+ return this.fallbackSwapSteps(_params, created, timeoutMs);
27217
27315
  } catch (error) {
27218
27316
  if (isSwapError(error)) return { ok: false, error };
27219
27317
  return {
@@ -27240,12 +27338,16 @@ var SwapService = class {
27240
27338
  );
27241
27339
  }
27242
27340
  /**
27243
- * Client-side swap completion (the default path): relay the broadcast intent tx to the hub — or
27244
- * use it directly when the source IS the hub — then notify the solver via post-execution and
27245
- * build the {@link SwapResponse}. Extracted verbatim from `swap()` so the opt-in backend 2-step
27246
- * path ({@link submitTx}) can fall back to it on any non-success.
27341
+ * Client-side swap completion (opt-out via `swaps.useBackendSubmitTx: false`): verify the broadcast intent
27342
+ * tx landed, then relay it to the hub — or use it directly when the source IS the hub — then notify the
27343
+ * solver via post-execution and build the {@link SwapResponse}. Extracted verbatim from `swap()` so the
27344
+ * backend 2-step path ({@link submitTx}) can fall back to it on any non-success.
27345
+ *
27346
+ * Verification belongs to THIS path only: the backend runs its own, so verifying before handing over
27347
+ * would delay every backend success by the source chain's confirmation wait and could fail a swap the
27348
+ * backend would have completed.
27247
27349
  */
27248
- async fallbackSwapSteps(_params, created, deadline) {
27350
+ async fallbackSwapSteps(_params, created, timeoutMs) {
27249
27351
  const { params } = _params;
27250
27352
  const srcChainKey = params.srcChainKey;
27251
27353
  const baseCtx = { srcChainKey, dstChainKey: params.dstChainKey };
@@ -27266,9 +27368,12 @@ var SwapService = class {
27266
27368
  data: relayData,
27267
27369
  chainKey: srcChainKey,
27268
27370
  relayerApiEndpoint: this.relayerApiEndpoint,
27269
- // Remaining shared budget: ≈ full `timeout` on the flag-off path (called immediately), or
27270
- // the reserve `submitTx` left on the backend path. Floor keeps a stalled-backend fallback viable.
27271
- timeout: Math.max(deadline - Date.now(), RELAY_FALLBACK_FLOOR_MS)
27371
+ // The caller's full `timeout`, starting HERE — after verification, and whether this runs as the
27372
+ // only path or as the backend's fallback. Neither a stalled backend attempt nor a slow source-chain
27373
+ // confirmation may shorten the relay wait. The floor covers a sub-floor caller `timeout`:
27374
+ // `relayTxAndWaitPacket` SUBMITS before `timeout` bounds anything, so a zero budget would strand an
27375
+ // already-landed tx unrelayed. Re-relay is idempotent, so spending it is safe.
27376
+ timeout: Math.max(timeoutMs, RELAY_FALLBACK_FLOOR_MS)
27272
27377
  });
27273
27378
  if (!packet.ok) {
27274
27379
  return { ok: false, error: mapRelayFailure(packet.error, { feature: "swap", action: "swap", ...baseCtx }) };
@@ -27298,7 +27403,7 @@ var SwapService = class {
27298
27403
  };
27299
27404
  }
27300
27405
  /**
27301
- * Backend 2-step swap path (opt-in via `swapsOptions.useBackendSubmitTx`): hand the broadcast
27406
+ * Backend 2-step swap path (default via `swaps.useBackendSubmitTx`): hand the broadcast
27302
27407
  * intent tx to the swaps API (`POST /swaps/submit-tx`); the backend relays + post-executes
27303
27408
  * server-side. Polls `getSubmitTxStatus` until `solved`, then reconstructs the same
27304
27409
  * {@link SwapResponse} the client-side path returns (`result.dstIntentTxHash` → delivery info,
@@ -27309,32 +27414,36 @@ var SwapService = class {
27309
27414
  *
27310
27415
  * Falling back is safe: re-relaying / re-posting an already-processed swap is idempotent — the
27311
27416
  * relay dedups and returns the existing `executed` packet, and the solver re-affirms the intent
27312
- * (no double-fill). Verified live by `e2e-tests/e2e-relay.test.ts`. Polling stops at
27313
- * `deadline - reserve` so the fallback keeps a guaranteed slice of the shared `swap` budget.
27417
+ * (no double-fill). Verified live by `e2e-tests/e2e-relay.test.ts`. It is also load-bearing rather
27418
+ * than belt-and-braces: the backend keeps processing after this attempt gives up, so the fallback's
27419
+ * relay can race the backend's own.
27420
+ *
27421
+ * The attempt itself — POST, budget clamps, status poll — is {@link runBackendSubmitTx}, shared with
27422
+ * bridge. What is swap-specific and lives here: the request body, the `solved` terminal status, the
27423
+ * mapping from a terminal result to a {@link SwapResponse}, and the swap error taxonomy.
27424
+ *
27425
+ * `attempt` bounds this attempt alone — the POST and every status request draw on it, and the
27426
+ * client-side fallback holds a separate fresh `timeout`.
27314
27427
  */
27315
- async submitTx(_params, created, deadline) {
27428
+ async submitTx(_params, created, attempt) {
27316
27429
  const { params } = _params;
27317
27430
  const srcChainKey = params.srcChainKey;
27318
27431
  const baseCtx = { srcChainKey, dstChainKey: params.dstChainKey };
27319
27432
  const { tx: spokeTxHash, intent, relayData } = created;
27320
- const submitTxFailed = (cause) => ({
27321
- ok: false,
27322
- error: executionFailed("swap", cause, { ...baseCtx, action: "swap" })
27323
- });
27324
27433
  try {
27325
- const submitted = await this.backendApi.swaps.submitTx({
27326
- txHash: spokeTxHash,
27327
- srcChainKey,
27328
- walletAddress: params.srcAddress,
27329
- intent,
27330
- relayData: relayData.payload
27331
- });
27332
- if (!submitted.ok) return submitTxFailed(submitted.error);
27333
- const polled = await pollBackendSubmitTx({
27334
- deadline,
27434
+ const outcome = await runBackendSubmitTx({
27435
+ attempt,
27436
+ api: this.backendApi.swaps,
27437
+ body: {
27438
+ txHash: spokeTxHash,
27439
+ srcChainKey,
27440
+ walletAddress: params.srcAddress,
27441
+ intent,
27442
+ relayData: relayData.payload
27443
+ },
27444
+ statusQuery: { txHash: spokeTxHash, srcChainKey },
27335
27445
  // Swaps terminal success is `solved` (solver filled) — not the bridge `executed`.
27336
27446
  terminalStatus: "solved",
27337
- getStatus: () => this.backendApi.swaps.getSubmitTxStatus({ txHash: spokeTxHash, srcChainKey }),
27338
27447
  onExecuted: (result) => result?.dstIntentTxHash && result.intent_hash ? {
27339
27448
  // Backend serializes the hex intent_hash as a plain string; brand it at the boundary.
27340
27449
  solverExecutionResponse: { answer: "OK", intent_hash: result.intent_hash },
@@ -27349,7 +27458,7 @@ var SwapService = class {
27349
27458
  }
27350
27459
  } : void 0
27351
27460
  });
27352
- return polled.ok ? { ok: true, value: polled.value } : submitTxFailed(polled.cause);
27461
+ return outcome.ok ? { ok: true, value: outcome.value } : { ok: false, error: executionFailed("swap", outcome.cause, { ...baseCtx, action: "swap" }) };
27353
27462
  } catch (error) {
27354
27463
  return { ok: false, error: unknownFailed("swap", error, { ...baseCtx, action: "swap" }) };
27355
27464
  }
@@ -30198,7 +30307,6 @@ async function makeRequest(params) {
30198
30307
  body: config.body,
30199
30308
  signal: controller.signal
30200
30309
  });
30201
- clearTimeout(timeoutId);
30202
30310
  if (!response.ok) {
30203
30311
  const errorText = await response.text();
30204
30312
  throw new BackendHttpError(response.status, errorText);
@@ -30206,7 +30314,6 @@ async function makeRequest(params) {
30206
30314
  const data = await response.json();
30207
30315
  return data;
30208
30316
  } catch (error) {
30209
- clearTimeout(timeoutId);
30210
30317
  if (error instanceof Error) {
30211
30318
  if (error.name === "AbortError") {
30212
30319
  throw new Error("REQUEST_TIMEOUT", { cause: new Error(`Request timeout after ${timeout}ms`) });
@@ -30216,6 +30323,8 @@ async function makeRequest(params) {
30216
30323
  }
30217
30324
  logger.error(`[${serviceLabel}] Unknown error`, error);
30218
30325
  throw new Error("UNKNOWN_REQUEST_ERROR", { cause: error });
30326
+ } finally {
30327
+ clearTimeout(timeoutId);
30219
30328
  }
30220
30329
  }
30221
30330
  function resolveRequestConfig(config, defaults) {
@@ -30244,16 +30353,112 @@ function toInvalidResponseShapeError(params) {
30244
30353
  context: { api, endpoint, reason: "invalid_response_shape", issues }
30245
30354
  });
30246
30355
  }
30356
+
30357
+ // src/backendApi/apiConfig.ts
30358
+ function flatLayer({ baseURL, timeout, headers }) {
30359
+ return { baseURL, timeout, headers };
30360
+ }
30361
+ function layerConfigs(...slices) {
30362
+ return slices.reduce(
30363
+ (acc, slice) => slice ? {
30364
+ // Truthy (not nullish) so a set-but-empty env var falls back, matching `makeRequest`.
30365
+ baseURL: slice.baseURL || acc.baseURL,
30366
+ timeout: slice.timeout ?? acc.timeout,
30367
+ headers: { ...acc.headers, ...slice.headers }
30368
+ } : acc,
30369
+ {
30370
+ baseURL: DEFAULT_API_BASE_URL,
30371
+ timeout: DEFAULT_BACKEND_API_TIMEOUT,
30372
+ headers: { ...DEFAULT_BACKEND_API_HEADERS }
30373
+ }
30374
+ );
30375
+ }
30376
+ function isHttpUrl(value) {
30377
+ return value.startsWith("http://") || value.startsWith("https://");
30378
+ }
30379
+ function normalizeBaseURL(baseURL) {
30380
+ const trimmed = trimTrailingSlashes(baseURL);
30381
+ return isHttpUrl(trimmed) ? trimmed : baseURL;
30382
+ }
30383
+ function stripBackendMount(baseURL) {
30384
+ const trimmed = trimTrailingSlashes(baseURL);
30385
+ if (!trimmed.endsWith(BACKEND_API_BASE_PATH)) return void 0;
30386
+ const root = trimmed.slice(0, -BACKEND_API_BASE_PATH.length);
30387
+ return isHttpUrl(root) ? root : void 0;
30388
+ }
30389
+ function stripLegacyBackendMount(baseURL) {
30390
+ return stripBackendMount(baseURL) ?? baseURL;
30391
+ }
30392
+ function normalizeOverrideBaseURL(override) {
30393
+ if (!override?.baseURL) return override;
30394
+ return { ...override, baseURL: stripLegacyBackendMount(override.baseURL) };
30395
+ }
30396
+ function toGatewayRoot(baseURL) {
30397
+ return stripBackendMount(baseURL) ?? normalizeBaseURL(baseURL);
30398
+ }
30399
+ function configuredBasePath(layers) {
30400
+ return layers.baseApiConfig?.basePath ?? layers.basePath;
30401
+ }
30402
+ function hasExplicitBasePath(layers) {
30403
+ return configuredBasePath(layers) !== void 0;
30404
+ }
30405
+ function hasLegacyBackendBaseURL(layers) {
30406
+ if (configuredBasePath(layers) !== void 0) return false;
30407
+ return stripBackendMount(layerConfigs(flatLayer(layers), layers.baseApiConfig).baseURL) !== void 0;
30408
+ }
30409
+ var PACKAGED_API_ORIGIN = new URL(DEFAULT_API_BASE_URL).origin;
30410
+ function isOnPackagedOrigin(baseURL) {
30411
+ return baseURL === PACKAGED_API_ORIGIN || baseURL.startsWith(`${PACKAGED_API_ORIGIN}/`);
30412
+ }
30413
+ function isMissingVersionPrefix(baseURL) {
30414
+ const normalized = trimTrailingSlashes(baseURL);
30415
+ if (!isOnPackagedOrigin(normalized)) return false;
30416
+ return normalized !== DEFAULT_API_BASE_URL && !normalized.startsWith(`${DEFAULT_API_BASE_URL}/`);
30417
+ }
30418
+ function normalizeBasePath(basePath) {
30419
+ const trimmed = trimTrailingSlashes(basePath.trim());
30420
+ const withoutLeadingSlashes = trimmed.replace(/^\/+/, "");
30421
+ return withoutLeadingSlashes.length === 0 ? "" : `/${withoutLeadingSlashes}`;
30422
+ }
30423
+ function resolveSharedApiConfig(layers, slice) {
30424
+ const layered = layerConfigs(flatLayer(layers), layers.baseApiConfig, slice);
30425
+ const baseURL = configuredBasePath(layers) === void 0 ? toGatewayRoot(layered.baseURL) : normalizeBaseURL(layered.baseURL);
30426
+ return { ...layered, baseURL };
30427
+ }
30428
+ function resolveBaseApiConfig(layers) {
30429
+ return {
30430
+ ...resolveSharedApiConfig(layers),
30431
+ basePath: normalizeBasePath(configuredBasePath(layers) ?? BACKEND_API_BASE_PATH)
30432
+ };
30433
+ }
30434
+ function resolveSwapsApiConfig(layers) {
30435
+ return resolveSharedApiConfig(layers, layers.swapsApiConfig);
30436
+ }
30437
+ function resolveSponsoringApiConfig(layers) {
30438
+ const slice = layers.sponsoringApiConfig;
30439
+ return {
30440
+ baseURL: normalizeBaseURL(slice?.baseURL ?? DEFAULT_SPONSORING_API_ENDPOINT),
30441
+ timeout: slice?.timeout ?? resolveSharedApiConfig(layers).timeout,
30442
+ headers: { ...DEFAULT_BACKEND_API_HEADERS, ...slice?.headers },
30443
+ ...slice?.apiKey === void 0 ? {} : { apiKey: slice.apiKey }
30444
+ };
30445
+ }
30446
+ function resolveBridgeApiConfig(layers) {
30447
+ return resolveSharedApiConfig(layers);
30448
+ }
30247
30449
  var SwapsApiService = class _SwapsApiService {
30248
30450
  // Fully-resolved swaps-API config supplied by the caller (BackendApiService resolves the
30249
30451
  // `ApiConfig` union via `resolveSwapsApiConfig`); this service does not resolve the union.
30250
30452
  config;
30251
30453
  headers;
30252
30454
  logger;
30253
- constructor(config, logger = consoleLogger) {
30455
+ /** See {@link SwapsApiServiceOptions.trimLegacyOverrides}. */
30456
+ trimsLegacyOverrides;
30457
+ constructor(config, logger = consoleLogger, options = {}) {
30254
30458
  this.config = config;
30255
30459
  this.headers = { ...config.headers };
30256
30460
  this.logger = logger;
30461
+ this.trimsLegacyOverrides = options.trimLegacyOverrides ?? true;
30257
30462
  }
30258
30463
  /**
30259
30464
  * Build a `@sodax/swaps-api` client for a single call. Maps the SDK's `SwapsApiConfig`
@@ -30264,7 +30469,8 @@ var SwapsApiService = class _SwapsApiService {
30264
30469
  * overrides both take effect without caching stale state.
30265
30470
  */
30266
30471
  buildClient(overrideConfig) {
30267
- const baseUrl = overrideConfig?.baseURL || this.config.baseURL;
30472
+ const override = overrideConfig?.baseURL;
30473
+ const baseUrl = override ? this.trimsLegacyOverrides ? stripLegacyBackendMount(override) : override : this.config.baseURL;
30268
30474
  const timeout = overrideConfig?.timeout ?? this.config.timeout ?? DEFAULT_BACKEND_API_TIMEOUT;
30269
30475
  const headers = { ...this.headers, ...overrideConfig?.headers };
30270
30476
  return new SwapsApi({ baseUrl, headers, timeout });
@@ -30420,7 +30626,9 @@ var SwapsApiService = class _SwapsApiService {
30420
30626
  // ──────────────────────────────────────────────────────────────────────
30421
30627
  // Submit-tx state machine
30422
30628
  // ──────────────────────────────────────────────────────────────────────
30423
- /** Submit a swap transaction to be processed (relay, post-execution, etc.). Idempotent on `(txHash, srcChainKey)`. */
30629
+ /** Submit a swap transaction to be processed (relay, post-execution, etc.). Idempotent on `(txHash, srcChainKey)`.
30630
+ * Response is immediate after successful submission. Use getSubmitTxStatus to poll the status of the submission.
30631
+ */
30424
30632
  async submitTx(body, config) {
30425
30633
  return this.toResult(
30426
30634
  "/swaps/submit-tx",
@@ -30449,6 +30657,18 @@ var SwapsApiService = class _SwapsApiService {
30449
30657
  getBaseURL() {
30450
30658
  return this.config.baseURL;
30451
30659
  }
30660
+ /**
30661
+ * Return the effective per-request timeout (ms) — the same value {@link buildClient} resolves, so
30662
+ * `SwapsApiConfig.timeout` being optional never leaks an `undefined` ceiling.
30663
+ *
30664
+ * Callers bounding a request tighter than this need it as the CEILING, because a
30665
+ * `RequestOverrideConfig.timeout` REPLACES the service value rather than lowering it: an override
30666
+ * derived from a caller budget alone would raise the bound whenever that budget is the larger of the
30667
+ * two. `SubmitTxAttempt.requestTimeout` clamps against both (`min(budget left in the attempt, this)`).
30668
+ */
30669
+ getTimeout() {
30670
+ return this.config.timeout ?? DEFAULT_BACKEND_API_TIMEOUT;
30671
+ }
30452
30672
  };
30453
30673
  var StellarSponsorConfigSchema = v7.object({
30454
30674
  sponsorAccount: v7.string(),
@@ -30725,10 +30945,13 @@ var BridgeApiService = class {
30725
30945
  config;
30726
30946
  headers;
30727
30947
  logger;
30728
- constructor(config, logger = consoleLogger) {
30948
+ /** See {@link BridgeApiServiceOptions.trimLegacyOverrides}. */
30949
+ trimsLegacyOverrides;
30950
+ constructor(config, logger = consoleLogger, options = {}) {
30729
30951
  this.config = config;
30730
30952
  this.headers = { ...config.headers };
30731
30953
  this.logger = logger;
30954
+ this.trimsLegacyOverrides = options.trimLegacyOverrides ?? true;
30732
30955
  }
30733
30956
  /**
30734
30957
  * Issues a single HTTP request, validates the JSON body against `schema`, and
@@ -30741,7 +30964,10 @@ var BridgeApiService = class {
30741
30964
  const raw = await makeRequest({
30742
30965
  endpoint,
30743
30966
  config: { baseURL: this.config.baseURL, timeout: this.config.timeout, headers: this.headers, ...config },
30744
- overrideConfig,
30967
+ // Normalized like a configured base URL: the override is the gateway root, so a legacy
30968
+ // `/be`-suffixed value must not nest `/bridge/*` under the data API's mount — unless the config
30969
+ // opted out of the legacy trim, in which case the per-call value is left exactly as given.
30970
+ overrideConfig: this.trimsLegacyOverrides ? normalizeOverrideBaseURL(overrideConfig) : overrideConfig,
30745
30971
  logger: this.logger,
30746
30972
  serviceLabel: "BridgeApiService"
30747
30973
  });
@@ -30935,61 +31161,17 @@ var BridgeApiService = class {
30935
31161
  return this.config.baseURL;
30936
31162
  }
30937
31163
  /**
30938
- * Return the effective per-request timeout (ms). Callers that bound a request tighter than the
30939
- * service default (e.g. `pollBackendSubmitTx` clamping to its poll cutoff) need this as the ceiling,
30940
- * because a `RequestOverrideConfig.timeout` REPLACES the service value rather than lowering it.
31164
+ * Return the effective per-request timeout (ms).
31165
+ *
31166
+ * Callers bounding a request tighter than this need it as the CEILING, because a
31167
+ * `RequestOverrideConfig.timeout` REPLACES the service value rather than lowering it: an override
31168
+ * derived from a caller budget alone would raise the bound whenever that budget is the larger of the
31169
+ * two. `SubmitTxAttempt.requestTimeout` clamps against both (`min(budget left in the attempt, this)`).
30941
31170
  */
30942
31171
  getTimeout() {
30943
31172
  return this.config.timeout;
30944
31173
  }
30945
31174
  };
30946
-
30947
- // src/backendApi/apiConfig.ts
30948
- function flatLayer({ baseURL, timeout, headers }) {
30949
- return { baseURL, timeout, headers };
30950
- }
30951
- function layerConfigs(...slices) {
30952
- return slices.reduce(
30953
- (acc, slice) => slice ? {
30954
- baseURL: slice.baseURL ?? acc.baseURL,
30955
- timeout: slice.timeout ?? acc.timeout,
30956
- headers: { ...acc.headers, ...slice.headers }
30957
- } : acc,
30958
- {
30959
- baseURL: DEFAULT_BACKEND_API_ENDPOINT,
30960
- timeout: DEFAULT_BACKEND_API_TIMEOUT,
30961
- headers: { ...DEFAULT_BACKEND_API_HEADERS }
30962
- }
30963
- );
30964
- }
30965
- function resolveBaseApiConfig(config) {
30966
- const layers = config;
30967
- return layerConfigs(flatLayer(layers), layers.baseApiConfig);
30968
- }
30969
- function resolveSwapsApiConfig(config) {
30970
- const layers = config;
30971
- return layerConfigs(flatLayer(layers), layers.baseApiConfig, layers.swapsApiConfig);
30972
- }
30973
- function isHttpUrl(value) {
30974
- return value.startsWith("http://") || value.startsWith("https://");
30975
- }
30976
- function normalizeBaseURL(baseURL) {
30977
- const trimmed = trimTrailingSlashes(baseURL);
30978
- return isHttpUrl(trimmed) ? trimmed : baseURL;
30979
- }
30980
- function resolveSponsoringApiConfig(config) {
30981
- const layers = config;
30982
- const slice = layers.sponsoringApiConfig;
30983
- return {
30984
- baseURL: normalizeBaseURL(slice?.baseURL ?? DEFAULT_SPONSORING_API_ENDPOINT),
30985
- timeout: slice?.timeout ?? resolveBaseApiConfig(config).timeout,
30986
- headers: { ...DEFAULT_BACKEND_API_HEADERS, ...slice?.headers },
30987
- ...slice?.apiKey === void 0 ? {} : { apiKey: slice.apiKey }
30988
- };
30989
- }
30990
- function resolveBridgeApiConfig(config) {
30991
- return resolveBaseApiConfig(config);
30992
- }
30993
31175
  var ChainKeySchema = v7.custom((input) => typeof input === "string");
30994
31176
  var SpokeChainKeySchema = v7.custom((input) => typeof input === "string");
30995
31177
  var AddressSchema2 = v7.custom((input) => typeof input === "string");
@@ -31128,17 +31310,70 @@ var BackendApiService = class {
31128
31310
  swaps;
31129
31311
  sponsoring;
31130
31312
  bridge;
31131
- // resolved base-API config: the flat fields of the ApiConfig union with any `baseApiConfig` layered on top
31313
+ // resolved base-API config: the flat fields of the ApiConfig union with any `baseApiConfig` layered on
31314
+ // top. `baseURL` is the gateway root; `basePath` is this service's own mount below it.
31132
31315
  config;
31133
31316
  headers;
31134
31317
  logger;
31318
+ /**
31319
+ * Whether a legacy `/be` suffix is trimmed off a per-call `baseURL` override. Mirrors the config-level
31320
+ * decision: an explicit `basePath` means the consumer writes complete roots, so their per-call value is
31321
+ * left exactly as given rather than having a real path segment eaten.
31322
+ */
31323
+ trimsLegacyOverrides;
31135
31324
  constructor(config, logger = consoleLogger) {
31136
31325
  this.config = resolveBaseApiConfig(config);
31137
31326
  this.headers = { ...this.config.headers };
31138
31327
  this.logger = logger;
31139
- this.swaps = new SwapsApiService(resolveSwapsApiConfig(config), this.logger);
31140
- this.sponsoring = new SponsoringApiService(resolveSponsoringApiConfig(config), this.logger);
31141
- this.bridge = new BridgeApiService(resolveBridgeApiConfig(config), this.logger);
31328
+ this.trimsLegacyOverrides = !hasExplicitBasePath(config);
31329
+ const swapsConfig2 = resolveSwapsApiConfig(config);
31330
+ const sponsoringConfig = resolveSponsoringApiConfig(config);
31331
+ const bridgeConfig2 = resolveBridgeApiConfig(config);
31332
+ const shortRoots = [
31333
+ ["backendApi", this.config.baseURL],
31334
+ ["api.swaps", swapsConfig2.baseURL],
31335
+ ["api.bridge", bridgeConfig2.baseURL],
31336
+ ["api.sponsoring", sponsoringConfig.baseURL]
31337
+ ].filter(([, baseURL]) => isMissingVersionPrefix(baseURL));
31338
+ if (shortRoots.length > 0) {
31339
+ const named = shortRoots.map(([service, baseURL]) => `${service} ("${baseURL}")`).join(", ");
31340
+ this.logger.warn(
31341
+ `[BackendApiService] api.baseURL is missing the gateway's version prefix for ${named}: every route resolves one segment short. Use "${DEFAULT_API_BASE_URL}" \u2014 the prefix is deployment-owned, so it belongs in baseURL, and only the data API has a basePath to compensate.`
31342
+ );
31343
+ }
31344
+ if (hasLegacyBackendBaseURL(config)) {
31345
+ this.logger.warn(
31346
+ `[BackendApiService] api.baseURL should be the gateway root, not the backend data API's mount: trimmed "${BACKEND_API_BASE_PATH}" to "${this.config.baseURL}". Drop the suffix \u2014 the SDK appends it, and sibling services (/swaps, /bridge) must not sit under it.`
31347
+ );
31348
+ }
31349
+ const overrideOptions = { trimLegacyOverrides: this.trimsLegacyOverrides };
31350
+ this.swaps = new SwapsApiService(swapsConfig2, this.logger, overrideOptions);
31351
+ this.sponsoring = new SponsoringApiService(sponsoringConfig, this.logger);
31352
+ this.bridge = new BridgeApiService(bridgeConfig2, this.logger, overrideOptions);
31353
+ }
31354
+ /**
31355
+ * Issue the HTTP call for a route.
31356
+ *
31357
+ * The mount is applied here rather than at each route literal, so `error.context.endpoint` stays
31358
+ * route-relative and the mount survives a per-call `baseURL` override — that retargets the gateway
31359
+ * root, not which service the route belongs to. For the same reason an override is put through the
31360
+ * legacy-mount trim: without it, passing the old `…/v1/be` value per call would yield `/be/be/…`.
31361
+ *
31362
+ * Defaults are listed field by field so `basePath` cannot cross into `RequestConfig`, where it has no
31363
+ * meaning — a spread would pass it silently, since TypeScript skips excess-property checks on spreads.
31364
+ */
31365
+ async send(endpoint, config) {
31366
+ const { baseURL, ...rest } = config;
31367
+ const overrideBaseURL = baseURL !== void 0 && this.trimsLegacyOverrides ? stripLegacyBackendMount(baseURL) : baseURL;
31368
+ return makeRequest({
31369
+ endpoint: `${this.config.basePath}${endpoint}`,
31370
+ config: resolveRequestConfig(
31371
+ { ...rest, ...overrideBaseURL === void 0 ? {} : { baseURL: overrideBaseURL } },
31372
+ { baseURL: this.config.baseURL, timeout: this.config.timeout, headers: this.headers }
31373
+ ),
31374
+ logger: this.logger,
31375
+ serviceLabel: "BackendApiService"
31376
+ });
31142
31377
  }
31143
31378
  /**
31144
31379
  * Issue a request and validate the JSON body against `schema`, wrapping the result in `Result<T>`.
@@ -31149,12 +31384,7 @@ var BackendApiService = class {
31149
31384
  */
31150
31385
  async request(endpoint, config, schema) {
31151
31386
  try {
31152
- const raw = await makeRequest({
31153
- endpoint,
31154
- config: resolveRequestConfig(config, { ...this.config, headers: this.headers }),
31155
- logger: this.logger,
31156
- serviceLabel: "BackendApiService"
31157
- });
31387
+ const raw = await this.send(endpoint, config);
31158
31388
  const parsed = v7.safeParse(schema, raw);
31159
31389
  if (!parsed.success) {
31160
31390
  return {
@@ -31181,12 +31411,7 @@ var BackendApiService = class {
31181
31411
  */
31182
31412
  async requestUnvalidated(endpoint, config) {
31183
31413
  try {
31184
- const value = await makeRequest({
31185
- endpoint,
31186
- config: resolveRequestConfig(config, { ...this.config, headers: this.headers }),
31187
- logger: this.logger,
31188
- serviceLabel: "BackendApiService"
31189
- });
31414
+ const value = await this.send(endpoint, config);
31190
31415
  return { ok: true, value };
31191
31416
  } catch (error) {
31192
31417
  return { ok: false, error: toExternalApiError({ api: "backend", feature: "backend", endpoint, error }) };
@@ -31488,8 +31713,9 @@ var BackendApiService = class {
31488
31713
  * without constructing a new service instance. Existing header keys are
31489
31714
  * overwritten; keys absent from `headers` are preserved.
31490
31715
  *
31491
- * Headers also reach `swaps`, which shares this origin, but never `sponsoring`,
31492
- * whose separate origin must not receive base-API credentials.
31716
+ * Headers also reach `swaps` and `bridge`, but never `sponsoring`: it is configured independently, so
31717
+ * base-API credentials must not be forwarded to whatever origin it points at. Note `swaps` can also be
31718
+ * retargeted to another origin via `swapsApiConfig`, in which case a header set here follows it.
31493
31719
  *
31494
31720
  * @param headers - Key-value pairs to add or overwrite in the default headers.
31495
31721
  */
@@ -31501,13 +31727,22 @@ var BackendApiService = class {
31501
31727
  this.bridge.setHeaders(headers);
31502
31728
  }
31503
31729
  /**
31504
- * Return the base URL the service is currently pointing at.
31730
+ * Return the gateway root the service is currently pointing at — WITHOUT this service's own mount.
31731
+ * Requests go to `getBaseURL() + getBasePath() + <route>`.
31505
31732
  *
31506
- * @returns The `baseURL` from the `ApiConfig` this instance was constructed with.
31733
+ * @returns The resolved gateway root, i.e. the `baseURL` from the `ApiConfig` this instance was
31734
+ * constructed with, minus a legacy `/be` suffix if one was supplied.
31507
31735
  */
31508
31736
  getBaseURL() {
31509
31737
  return this.config.baseURL;
31510
31738
  }
31739
+ /**
31740
+ * Return the backend data API's mount below {@link getBaseURL} — `/be` by default, or whatever
31741
+ * `basePath` the `ApiConfig` supplied (`''` for a service addressed directly at its origin).
31742
+ */
31743
+ getBasePath() {
31744
+ return this.config.basePath;
31745
+ }
31511
31746
  };
31512
31747
 
31513
31748
  // src/bridge/errors.ts
@@ -31549,15 +31784,20 @@ var BridgeService = class {
31549
31784
  hubProvider;
31550
31785
  config;
31551
31786
  spoke;
31552
- // backend bridge-API client + opt-in backend submit-tx flag
31787
+ // backend bridge-API client
31553
31788
  backendApi;
31554
- useBackendSubmitTx;
31555
- constructor({ hubProvider, config, spoke, backendApi, useBackendSubmitTx }) {
31789
+ /**
31790
+ * Effective backend submit-tx flow (`bridge.useBackendSubmitTx`, default on). Read live off
31791
+ * `ConfigService` like `bridgePartnerFee`, so the config object and the behavior can never disagree.
31792
+ */
31793
+ get useBackendSubmitTx() {
31794
+ return this.config.bridgeUseBackendSubmitTx;
31795
+ }
31796
+ constructor({ hubProvider, config, spoke, backendApi }) {
31556
31797
  this.config = config;
31557
31798
  this.hubProvider = hubProvider;
31558
31799
  this.spoke = spoke;
31559
31800
  this.backendApi = backendApi;
31560
- this.useBackendSubmitTx = useBackendSubmitTx ?? false;
31561
31801
  }
31562
31802
  /**
31563
31803
  * Calculates the partner fee deducted from a given bridge input amount.
@@ -31722,15 +31962,27 @@ var BridgeService = class {
31722
31962
  /**
31723
31963
  * Executes a full end-to-end bridge transfer: spoke deposit → relay → hub settlement.
31724
31964
  *
31725
- * Internally calls `createBridgeIntent()` to submit the spoke-side deposit transaction,
31726
- * then waits for the cross-chain relay packet to be confirmed on the hub (Sonic).
31727
- * Use this method for the typical "fire and wait" bridge UX.
31965
+ * Internally calls `createBridgeIntent()` to submit the spoke-side deposit transaction, then
31966
+ * completes the transfer via one of two paths. Use this method for the typical "fire and wait" UX.
31967
+ *
31968
+ * - **Backend submit-tx (default, `bridge.useBackendSubmitTx`), {@link submitTx}:** hands the deposit
31969
+ * to the bridge API, which relays server-side, and polls until `executed`. On ANY non-success it
31970
+ * falls back to the path below — safe because re-relaying is idempotent.
31971
+ * - **Client-side (opt-out with `useBackendSubmitTx: false`), {@link fallbackBridgeSteps}:** verifies
31972
+ * the deposit landed on-chain, then relays it and waits for the settlement packet. `verifyTxHash`
31973
+ * runs on this path only; the backend runs its own.
31728
31974
  *
31729
31975
  * For manual relay control (e.g. monitoring or batching), use `createBridgeIntent()` directly
31730
31976
  * and handle the relay step yourself.
31731
31977
  *
31732
31978
  * @param _params - Bridge parameters including source/destination chain keys, token addresses,
31733
- * amount, recipient address, wallet provider, and optional timeout.
31979
+ * amount, recipient address, wallet provider, and an optional `timeout` — a PER-ATTEMPT budget,
31980
+ * not an end-to-end one. The backend attempt gets it, and if that attempt does not complete the
31981
+ * client-side relay wait gets a fresh one starting after verification, so neither a stalled backend
31982
+ * nor a slow source-chain confirmation can shorten it. Worst-case wall-clock is
31983
+ * `createBridgeIntent + timeout + verification + max(timeout, RELAY_FALLBACK_FLOOR_MS)`, where
31984
+ * verification is bounded by the source chain's `pollingConfig.maxTimeoutMs` and intent creation is
31985
+ * not bounded by `timeout` at all. See `docs/BRIDGE.md` § Completion paths and `timeout`.
31734
31986
  * @returns `Result<TxHashPair>` — `{ srcChainTxHash, dstChainTxHash }` on success,
31735
31987
  * where `srcChainTxHash` is the spoke deposit tx and `dstChainTxHash` is the hub settlement tx.
31736
31988
  *
@@ -31764,16 +32016,16 @@ var BridgeService = class {
31764
32016
  try {
31765
32017
  const created = await this.createBridgeIntent(_params);
31766
32018
  if (!created.ok) return { ok: false, error: created.error };
31767
- const deadline = Date.now() + (_params.timeout ?? DEFAULT_RELAY_TX_TIMEOUT);
32019
+ const timeoutMs = resolveTimeoutMs(_params.timeout, DEFAULT_RELAY_TX_TIMEOUT);
31768
32020
  if (this.useBackendSubmitTx) {
31769
- const submitted = await this.submitTx(_params, created.value, deadline);
32021
+ const submitted = await this.submitTx(_params, created.value, createSubmitTxAttempt(timeoutMs));
31770
32022
  if (submitted.ok) return submitted;
31771
32023
  this.config.logger.warn(
31772
32024
  "[bridge] backend submit-tx did not complete; falling back to the client-side relay",
31773
32025
  { error: submitted.error }
31774
32026
  );
31775
32027
  }
31776
- return this.fallbackBridgeSteps(_params, created.value, deadline);
32028
+ return this.fallbackBridgeSteps(_params, created.value, timeoutMs);
31777
32029
  } catch (error) {
31778
32030
  if (isBridgeOrchestrationError(error)) return { ok: false, error };
31779
32031
  return {
@@ -31801,12 +32053,16 @@ var BridgeService = class {
31801
32053
  );
31802
32054
  }
31803
32055
  /**
31804
- * Client-side bridge completion (the default path): verify the broadcast spoke-deposit tx, then
31805
- * relay it to the hub and wait for the settlement packet. Extracted verbatim from `bridge()` so the
31806
- * opt-in backend submit-tx path ({@link submitTx}) can fall back to it on any non-success. Bridge
31807
- * always relays — there is no hub-source short-circuit.
32056
+ * Client-side bridge completion (opt-out via `bridge.useBackendSubmitTx: false`): verify the broadcast
32057
+ * spoke-deposit tx, then relay it to the hub and wait for the settlement packet. Extracted verbatim from
32058
+ * `bridge()` so the backend submit-tx path ({@link submitTx}) can fall back to it on any non-success.
32059
+ * Bridge always relays — there is no hub-source short-circuit.
32060
+ *
32061
+ * Verification belongs to THIS path only: the backend runs its own, so verifying before handing over
32062
+ * would delay every backend success by the source chain's confirmation wait and could fail a bridge the
32063
+ * backend would have completed.
31808
32064
  */
31809
- async fallbackBridgeSteps(_params, created, deadline) {
32065
+ async fallbackBridgeSteps(_params, created, timeoutMs) {
31810
32066
  const { params } = _params;
31811
32067
  const baseCtx = { srcChainKey: params.srcChainKey, dstChainKey: params.dstChainKey };
31812
32068
  const verifyTxHashResult = await this.spoke.verifyTxHash({
@@ -31821,13 +32077,13 @@ var BridgeService = class {
31821
32077
  data: created.relayData,
31822
32078
  chainKey: params.srcChainKey,
31823
32079
  relayerApiEndpoint: this.config.relay.relayerApiEndpoint,
31824
- // Remaining shared budget: ≈ full `timeout` on the flag-off path minus the `verifyTxHash` wait,
31825
- // or the reserve `submitTx` left on the backend path (`pollBackendSubmitTx` holds back up to a
31826
- // third, capped at 20s). The floor matters because `relayTxAndWaitPacket` SUBMITS the tx to the
31827
- // relay before `timeout` bounds anything: a budget exhausted by a slow source-chain confirmation
31828
- // (Stacks polls for up to its full 120s `maxTimeoutMs`) would otherwise strand an already-landed
31829
- // deposit unrelayed. Re-relay is idempotent, so always spending the floor is safe.
31830
- timeout: Math.max(deadline - Date.now(), RELAY_FALLBACK_FLOOR_MS)
32080
+ // The caller's full `timeout`, starting HERE — after verification, and whether this runs as the only
32081
+ // path or as the backend's fallback. Neither a stalled backend attempt nor a slow source-chain
32082
+ // confirmation (Stacks polls for up to its full 120s `maxTimeoutMs`) may shorten the relay wait. The
32083
+ // floor covers a sub-floor caller `timeout`: `relayTxAndWaitPacket` SUBMITS the tx to the relay
32084
+ // before `timeout` bounds anything, so a zero budget would strand an already-landed deposit
32085
+ // unrelayed. Re-relay is idempotent, so always spending the floor is safe.
32086
+ timeout: Math.max(timeoutMs, RELAY_FALLBACK_FLOOR_MS)
31831
32087
  });
31832
32088
  if (!packetResult.ok) {
31833
32089
  return {
@@ -31846,7 +32102,7 @@ var BridgeService = class {
31846
32102
  };
31847
32103
  }
31848
32104
  /**
31849
- * Backend bridge path (opt-in via `bridgeOptions.useBackendSubmitTx`): hand the broadcast
32105
+ * Backend bridge path (default via `bridge.useBackendSubmitTx`): hand the broadcast
31850
32106
  * spoke-deposit tx to the bridge API (`POST /bridge/submit-tx`) with the FULL `relayData`
31851
32107
  * envelope; the backend relays server-side. Polls `getSubmitTxStatus` until `executed`, then
31852
32108
  * returns the same {@link TxHashPair} the client-side path returns (`result.dstIntentTxHash` →
@@ -31855,39 +32111,39 @@ var BridgeService = class {
31855
32111
  * Never throws — returns `{ ok: false }` on any non-success (submit `!ok`, terminal `failed` /
31856
32112
  * abandoned, or poll timeout) so `bridge()` falls back to {@link fallbackBridgeSteps}. Falling back
31857
32113
  * is safe: re-relaying an already-relayed bridge tx is idempotent — the relay dedups and returns the
31858
- * existing `executed` packet. Polling stops at `deadline - reserve` so the fallback keeps a
31859
- * guaranteed slice of the shared `bridge` budget.
32114
+ * existing `executed` packet. It is also load-bearing rather than belt-and-braces: the backend keeps
32115
+ * processing after this attempt gives up, so the fallback's relay can race the backend's own.
32116
+ *
32117
+ * The attempt itself — POST, budget clamps, status poll — is {@link runBackendSubmitTx}, shared with
32118
+ * swaps. What is bridge-specific and lives here: the request body (the FULL `relayData` envelope), the
32119
+ * `executed` terminal status, the mapping to a {@link TxHashPair}, and the bridge error taxonomy.
32120
+ *
32121
+ * `attempt` bounds this attempt alone — the POST and every status request draw on it, and the
32122
+ * client-side fallback holds a separate fresh `timeout`.
31860
32123
  */
31861
- async submitTx(_params, created, deadline) {
32124
+ async submitTx(_params, created, attempt) {
31862
32125
  const { params } = _params;
31863
32126
  const srcChainKey = params.srcChainKey;
31864
32127
  const baseCtx = { srcChainKey, dstChainKey: params.dstChainKey };
31865
32128
  const { tx: spokeTxHash, relayData } = created;
31866
- const submitTxFailed = (cause) => ({
31867
- ok: false,
31868
- error: executionFailed("bridge", cause, { ...baseCtx, action: "bridge" })
31869
- });
31870
32129
  try {
31871
- const submitted = await this.backendApi.bridge.submitTx({
31872
- txHash: spokeTxHash,
31873
- srcChainKey,
31874
- walletAddress: params.srcAddress,
31875
- // Send the FULL { address, payload } envelope — bridge has no intent.creator for the backend
31876
- // to rebuild the relay address, so dropping it would break split-tx-chain relay.
31877
- relayData
31878
- });
31879
- if (!submitted.ok) return submitTxFailed(submitted.error);
31880
- const polled = await pollBackendSubmitTx({
31881
- deadline,
32130
+ const outcome = await runBackendSubmitTx({
32131
+ attempt,
32132
+ api: this.backendApi.bridge,
32133
+ body: {
32134
+ txHash: spokeTxHash,
32135
+ srcChainKey,
32136
+ walletAddress: params.srcAddress,
32137
+ // Send the FULL { address, payload } envelope — bridge has no intent.creator for the backend
32138
+ // to rebuild the relay address, so dropping it would break split-tx-chain relay.
32139
+ relayData
32140
+ },
32141
+ statusQuery: { txHash: spokeTxHash, srcChainKey },
31882
32142
  // Bridge terminal success is `executed` (hub-settled) — not the swaps `solved`.
31883
32143
  terminalStatus: "executed",
31884
- getStatus: (override) => this.backendApi.bridge.getSubmitTxStatus({ txHash: spokeTxHash, srcChainKey }, override),
31885
- onExecuted: (result) => result?.dstIntentTxHash ? { srcChainTxHash: spokeTxHash, dstChainTxHash: result.dstIntentTxHash } : void 0,
31886
- // Bound each status request by the poll cutoff, never above the service default — so a stalled
31887
- // request can neither eat the fallback's reserve nor consume the window in one attempt.
31888
- requestTimeoutMs: this.backendApi.bridge.getTimeout()
32144
+ onExecuted: (result) => result?.dstIntentTxHash ? { srcChainTxHash: spokeTxHash, dstChainTxHash: result.dstIntentTxHash } : void 0
31889
32145
  });
31890
- return polled.ok ? { ok: true, value: polled.value } : submitTxFailed(polled.cause);
32146
+ return outcome.ok ? { ok: true, value: outcome.value } : { ok: false, error: executionFailed("bridge", outcome.cause, { ...baseCtx, action: "bridge" }) };
31891
32147
  } catch (error) {
31892
32148
  return { ok: false, error: unknownFailed("bridge", error, { ...baseCtx, action: "bridge" }) };
31893
32149
  }
@@ -38061,15 +38317,25 @@ var MoneyMarketService = class _MoneyMarketService {
38061
38317
  config;
38062
38318
  spoke;
38063
38319
  // money market config (hoisted from config for ergonomics, mirrors SwapService)
38064
- partnerFee;
38065
38320
  relayerApiEndpoint;
38066
38321
  // sub-service
38067
38322
  data;
38323
+ /**
38324
+ * Effective money-market partner fee (`moneyMarket.partnerFee`, else the global `fee`). Read live
38325
+ * off `ConfigService` rather than snapshotted in the constructor, so it cannot diverge from
38326
+ * `config.moneyMarketPartnerFee` if the config object is ever replaced. Mirrors
38327
+ * {@link SwapService.partnerFee}.
38328
+ *
38329
+ * Money market has no per-action override: unlike swap / bridge / leverage-yield, every flow here
38330
+ * charges this configured fee.
38331
+ */
38332
+ get partnerFee() {
38333
+ return this.config.moneyMarketPartnerFee;
38334
+ }
38068
38335
  constructor({ config, hubProvider, spoke }) {
38069
38336
  this.config = config;
38070
38337
  this.hubProvider = hubProvider;
38071
38338
  this.spoke = spoke;
38072
- this.partnerFee = config.moneyMarketPartnerFee;
38073
38339
  this.relayerApiEndpoint = config.relay.relayerApiEndpoint;
38074
38340
  this.data = new MoneyMarketDataService({ hubProvider, config });
38075
38341
  }
@@ -40382,6 +40648,68 @@ var LeverageYieldService = class {
40382
40648
  return { ok: false, error: lookupFailed("leverageYield", "resolveDeadline", error, { srcChainKey }) };
40383
40649
  }
40384
40650
  }
40651
+ /**
40652
+ * Quotes a vault deposit or withdraw. Vault shares are solver-tradeable, so this is the
40653
+ * generic solver quote with one difference that matters: the fee deducted before quoting is
40654
+ * the effective **leverage-yield** fee, matching what {@link LeverageYieldService.createVaultIntent}
40655
+ * will charge. `sodax.swaps.getQuote` deducts the effective *swap* fee instead, so quoting a
40656
+ * vault flow through it makes the quote and the intent disagree whenever the two feature fees
40657
+ * differ. Quoting a vault flow through the swap service can be made to agree — pass the same fee
40658
+ * explicitly, using a zero fee (`{ address, percentage: 0 }`) where the effective leverage-yield
40659
+ * fee is `undefined`, since an explicit `undefined` there falls back to the swap fee — but this
40660
+ * method resolves it for you and is the canonical way to quote a vault flow.
40661
+ *
40662
+ * Pass the vault address as `token_dst` to quote a deposit, or as `token_src` to quote a
40663
+ * withdraw; subtract your slippage tolerance from `quoted_amount` to get `minOutputAmount`.
40664
+ * When overriding the fee per intent, pass the same `partnerFee` here and to whichever builder
40665
+ * you use ({@link LeverageYieldService.deposit}, {@link LeverageYieldService.withdraw}) or
40666
+ * directly to {@link LeverageYieldService.vaultSwap} — omitting it everywhere is equally safe,
40667
+ * since each side then resolves the same effective leverage-yield fee. Both directions are
40668
+ * charged, so this applies to withdrawals as much as deposits.
40669
+ *
40670
+ * @returns `SolverIntentQuoteResponse` on success. On failure `result.error` is either the
40671
+ * solver's own `SolverErrorResponse` (no path, insufficient liquidity, …) or a SodaxError
40672
+ * with `VALIDATION_FAILED` (bad `amount`, or a partner fee that leaves nothing to quote),
40673
+ * `LOOKUP_FAILED` (unsupported token — the solver payload could not be assembled) or
40674
+ * `UNKNOWN`. Discriminate with `isSodaxError(error)`.
40675
+ */
40676
+ async getQuote(payload) {
40677
+ const { partnerFee = this.config.leverageYieldPartnerFee, ...request } = payload;
40678
+ const baseCtx = {
40679
+ method: "getQuote",
40680
+ tokenSrcChainKey: request.token_src_blockchain_id,
40681
+ tokenDstChainKey: request.token_dst_blockchain_id
40682
+ };
40683
+ try {
40684
+ leverageYieldInvariant(request.amount > 0n, "amount must be greater than 0", {
40685
+ ...baseCtx,
40686
+ field: "amount"
40687
+ });
40688
+ if (isPartnerFeeAmount(partnerFee)) {
40689
+ leverageYieldInvariant(
40690
+ partnerFee.amount < request.amount,
40691
+ `partnerFee amount (${partnerFee.amount}) must be less than the quote amount (${request.amount})`,
40692
+ { ...baseCtx, field: "partnerFee" }
40693
+ );
40694
+ } else if (isPartnerFeePercentage(partnerFee)) {
40695
+ leverageYieldInvariant(
40696
+ Number.isInteger(partnerFee.percentage) && partnerFee.percentage >= 0 && partnerFee.percentage <= Number(FEE_PERCENTAGE_SCALE),
40697
+ `partnerFee percentage must be a whole number of basis points between 0 and ${FEE_PERCENTAGE_SCALE} (got ${partnerFee.percentage})`,
40698
+ { ...baseCtx, field: "partnerFee" }
40699
+ );
40700
+ }
40701
+ const netAmount = adjustAmountByFee(request.amount, partnerFee, request.quote_type);
40702
+ leverageYieldInvariant(netAmount > 0n, "amount net of the partner fee must be greater than 0", {
40703
+ ...baseCtx,
40704
+ field: "partnerFee"
40705
+ });
40706
+ const adjustedPayload = { ...request, amount: netAmount };
40707
+ return await SolverApiService.getQuote(adjustedPayload, this.config.solver, this.config);
40708
+ } catch (error) {
40709
+ if (isLeverageYieldLookupError(error)) return { ok: false, error };
40710
+ return { ok: false, error: lookupFailed("leverageYield", "getQuote", error, baseCtx) };
40711
+ }
40712
+ }
40385
40713
  /**
40386
40714
  * Builds the {@link LeverageYieldSwapPayload} for a leverage-yield deposit (any token → lsoda*).
40387
40715
  * The lsoda* output is delivered to the user's hub wallet on Sonic so a later
@@ -40389,9 +40717,8 @@ var LeverageYieldService = class {
40389
40717
  * {@link LeverageYieldService.vaultSwap}: `vaultSwap({ ...payload, walletProvider })`.
40390
40718
  * An optional `partnerFee` is forwarded on the payload as the per-intent fee override.
40391
40719
  *
40392
- * For `minOutputAmount`, quote via `sodax.swaps.getQuote` with the vault address as the
40393
- * destination token (`token_dst`) — vault shares are solver-tradeable, so the generic swap
40394
- * quote applies; then subtract your slippage tolerance.
40720
+ * For `minOutputAmount`, quote via {@link LeverageYieldService.getQuote} with the vault
40721
+ * address as the destination token (`token_dst`), then subtract your slippage tolerance.
40395
40722
  */
40396
40723
  async deposit(params) {
40397
40724
  const baseCtx = { srcChainKey: params.srcChainKey, action: "deposit" };
@@ -40444,9 +40771,13 @@ var LeverageYieldService = class {
40444
40771
  * a call shape uniform with {@link LeverageYieldService.deposit}; async because the default
40445
40772
  * `deadline` is read from the hub block timestamp.
40446
40773
  *
40447
- * For `minOutputAmount`, quote via `sodax.swaps.getQuote` with the vault address as the
40448
- * source token (`token_src`) — vault shares are solver-tradeable, so the generic swap quote
40449
- * applies; then subtract your slippage tolerance.
40774
+ * An optional `partnerFee` is forwarded on the payload as the per-intent fee override; omit it
40775
+ * and the configured leverage-yield fee applies. Withdrawals **are** charged — the fee comes out
40776
+ * of `inputAmount`, which for a withdraw is the vault's own shares, so the receiver accrues
40777
+ * lsoda\* rather than the output token.
40778
+ *
40779
+ * For `minOutputAmount`, quote via {@link LeverageYieldService.getQuote} with the vault
40780
+ * address as the source token (`token_src`), then subtract your slippage tolerance.
40450
40781
  */
40451
40782
  async withdraw(params) {
40452
40783
  const baseCtx = { srcChainKey: params.srcChainKey, action: "withdraw" };
@@ -40480,7 +40811,10 @@ var LeverageYieldService = class {
40480
40811
  solver: params.solver ?? ANY_SOLVER_ADDRESS,
40481
40812
  data: "0x"
40482
40813
  },
40483
- hubWalletSwap: true
40814
+ hubWalletSwap: true,
40815
+ // Per-intent fee override — only included when the caller supplies one, so the
40816
+ // payload stays free of undefined-valued keys (mirrors `deposit`).
40817
+ ...params.partnerFee !== void 0 && { partnerFee: params.partnerFee }
40484
40818
  }
40485
40819
  };
40486
40820
  } catch (error) {
@@ -40513,7 +40847,7 @@ var LeverageYieldService = class {
40513
40847
  * `UNKNOWN` (defensive fallback).
40514
40848
  */
40515
40849
  async createVaultIntent(_params) {
40516
- const { params, skipSimulation, hubWalletSwap, partnerFee = this.config.swapPartnerFee } = _params;
40850
+ const { params, skipSimulation, hubWalletSwap, partnerFee = this.config.leverageYieldPartnerFee } = _params;
40517
40851
  const baseCtx = { srcChainKey: params.srcChainKey, dstChainKey: params.dstChainKey };
40518
40852
  try {
40519
40853
  leverageYieldInvariant(
@@ -41743,8 +42077,6 @@ var Sodax = class {
41743
42077
  const analytics = resolveAnalytics(options?.analytics);
41744
42078
  const fee = options?.fee;
41745
42079
  const radfiSigner = options?.radfi?.signRequest;
41746
- const useBackendSubmitTx = options?.swapsOptions?.useBackendSubmitTx ?? false;
41747
- const bridgeUseBackendSubmitTx = options?.bridgeOptions?.useBackendSubmitTx ?? false;
41748
42080
  this.instanceConfig = options ? mergeSodaxConfig(sodaxConfig, options) : sodaxConfig;
41749
42081
  this.backendApi = new BackendApiService(this.instanceConfig.api, logger);
41750
42082
  this.api = this.backendApi;
@@ -41763,8 +42095,7 @@ var Sodax = class {
41763
42095
  config: this.config,
41764
42096
  hubProvider: this.hubProvider,
41765
42097
  spoke: this.spoke,
41766
- backendApi: this.backendApi,
41767
- useBackendSubmitTx
42098
+ backendApi: this.backendApi
41768
42099
  });
41769
42100
  this.moneyMarket = new MoneyMarketService({
41770
42101
  config: this.config,
@@ -41785,8 +42116,7 @@ var Sodax = class {
41785
42116
  hubProvider: this.hubProvider,
41786
42117
  config: this.config,
41787
42118
  spoke: this.spoke,
41788
- backendApi: this.backendApi,
41789
- useBackendSubmitTx: bridgeUseBackendSubmitTx
42119
+ backendApi: this.backendApi
41790
42120
  });
41791
42121
  this.staking = new StakingService({ hubProvider: this.hubProvider, config: this.config, spoke: this.spoke });
41792
42122
  this.partners = new PartnerService({
@@ -41850,4 +42180,4 @@ var isPartnerError = isCodeMember(PARTNER_CODES);
41850
42180
  (*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
41851
42181
  */
41852
42182
 
41853
- export { ALLOWANCE_CHECK_CODES, APPROVE_CODES, AssetService, BITCOIN_CHAIN_KEYS, BITCOIN_CHAIN_KEYS_SET, BITCOIN_DUST_SATS, BTC_WALLET_ADDRESS_TYPES, BackendApiService, BackendHttpError, BalnSwapService, BigIntToHex, BigNumberZeroDecimal, BitcoinSpokeService, BnUSDMigrationService, BridgeApiService, BridgeService, CHAIN_KEYS, CHAIN_LOGO_BASE_URL, CONFIG_VERSION, CREATE_INTENT_CODES, ChainKeys, ChainTypeArr, ClService, ConfigService, CustomSorobanServer, CustomStellarAccount, DEFAULT_BACKEND_API_ENDPOINT, DEFAULT_BACKEND_API_HEADERS, DEFAULT_BACKEND_API_TIMEOUT, DEFAULT_DEADLINE_OFFSET, DEFAULT_MAX_RETRY, DEFAULT_RELAYER_API_ENDPOINT, DEFAULT_RELAY_TX_TIMEOUT, DEFAULT_RETRY_DELAY_MS, DEFAULT_SPONSORING_API_ENDPOINT, DexService, EVM_CHAIN_ID_TO_KEY, EVM_CHAIN_KEYS, EVM_CHAIN_KEYS_SET, EVM_SPOKE_ONLY_CHAIN_KEYS, EVM_SPOKE_ONLY_CHAIN_KEYS_SET, Erc20Service, Erc4626Service, EvmAssetManagerService, EvmHubProvider, EvmSolverService, EvmSpokeService, EvmVaultTokenService, FEE_PERCENTAGE_SCALE, GAS_ESTIMATION_CODES, HALF_RAY, HALF_WAD, HUB_CHAIN_KEY, HookKind, HookService, HttpRelayError, HubVaultSymbols, ICON_CHAIN_KEYS, ICON_CHAIN_KEYS_SET, ICON_TX_RESULT_WAIT_MAX_RETRY, INJECTIVE_CHAIN_KEYS, INJECTIVE_CHAIN_KEYS_SET, INTENT_CHAIN_IDS, IconSpokeService, IcxMigrationService, Injective20Token, InjectiveSpokeService, IntentCreatedEventAbi, IntentDataService, IntentDataType, IntentFilledEventAbi, IntentRelayChainIdToChainKey, IntentsAbi, LOOKUP_CODES, LTV_PRECISION, LendingPoolService, LeverageYieldService, LockupMultiplier, LockupPeriod, LsodaSymbols, LsodaTokens, MAX_UINT256, MigrationService, MintPositionEventAbi, MoneyMarketDataService, MoneyMarketService, NEAR_CHAIN_KEYS, NEAR_CHAIN_KEYS_SET, NEAR_DEFAULT_GAS, NEAR_STORAGE_DEPOSIT, NearSpokeService, PartnerFeeClaimService, PartnerService, Permit2Service, ProtocolIntentsAbi, RAY, RAY_DECIMALS, RELAY_ERROR_CODES, RELAY_FALLBACK_FLOOR_MS, RadfiApiError, RadfiProvider, RecoveryService, RelayChainIdMap, SECONDS_PER_YEAR, SODAX_ERROR_CODES, SODAX_FEATURES, SOLANA_CHAIN_KEYS, SOLANA_CHAIN_KEYS_SET, SONIC_CHAIN_KEYS, SONIC_CHAIN_KEYS_SET, SPONSORING_API_ERROR_CODES, SPONSORING_API_STELLAR_BASE_PATH, SPONSOR_CONFIG_TTL_MS, STACKS_CHAIN_KEYS, STACKS_CHAIN_KEYS_SET, STELLAR_BASE_RESERVE_TTL_MS, STELLAR_CHAIN_KEYS, STELLAR_CHAIN_KEYS_SET, STELLAR_TRUSTLINE_MIN_XLM_STROOPS, SUI_CHAIN_KEYS, SUI_CHAIN_KEYS_SET, SodaTokens, Sodax, SodaxError, SolanaSpokeService, SolverApiService, SolverIntentErrorCode, SolverIntentStatusCode, SonicSpokeService, SpokeService, SponsoringApiService, SponsoringService, StacksSpokeService, StakingLogic, StakingService, StatATokenAddresses, StellarSpokeService, SuiSpokeService, SupportedMigrationTokens, SwapService, SwapsApiService, TOKEN_LOGO_BASE_URL, USD_DECIMALS, UiPoolDataProviderService, VAULT_TOKEN_DECIMALS, WAD, WAD_RAY_RATIO, WEI_DECIMALS, adjustAmountByFee, allowanceCheckFailed, apiConfig, approveFailed, arbitrumSupportedTokens, assetManagerAbi, avalancheSupportedTokens, balnSwapAbi, baseChainInfo, baseSupportedTokens, binomialApproximatedRayPow, bitcoinSupportedTokens, bnUSDLegacySpokeChainIds, bnUSDLegacyTokens, bridgeConfig, bridgeInvariant, bscSupportedTokens, calcOpReturnOutputVbytes, calculateAllReserveIncentives, calculateAllUserIncentives, calculateAvailableBorrowsMarketReferenceCurrency, calculateCompoundedInterest, calculateCompoundedRate, calculateFeeAmount, calculateHealthFactorFromBalances, calculateHealthFactorFromBalancesBigUnits, calculateLinearInterest, calculatePercentageFeeAmount, clPoolAbi, clPoolManagerAbi, clPositionManagerAbi, clQuoterAbi, clRouterAbi, clTickLensAbi, classifySponsorError, concentratedLiquidityConfig, connectionAbi, consoleLogger, convertTransactionInstructionToRaw, createInvariant, deepMerge, defaultHookAbi, detectBitcoinAddressType, dexConfig, dexInvariant, dexPools, encodeAddress, encodeBtcPayloadToBytes, encodeContractCalls, erc20Abi, erc4626Abi, estimateBitcoinTxSize, ethereumSupportedTokens, executionFailed, formatBasisPoints, formatEModeCategory, formatEModes, formatPercentage, formatReserve, formatReserveUSD, formatReserves, formatReservesAndIncentives, formatUserSummary, formatUserSummaryAndIncentives, gasEstimationFailed, getAllLegacybnUSDTokens, getAndFormatReserveEModes, getAssetManagerIdl, getAssetManagerProgram, getChainKeyFromRelayChainId, getChainType, getCompoundedBalance, getConcentratedLiquidityConfig, getConnectionIdl, getConnectionProgram, getEvmChainKeyByChainId, getEvmViemChain, getIconAddressBytes, getIntentRelayChainId, getLinearBalance, getMarketReferenceCurrencyAndUsdBalance, getPacket, getProvider, getRandomBytes, getReserveNormalizedIncome, getReservesEModes, getSolanaAddressBytes, getSolverConfig, getSpokeHook, getSpokeHooks, getStagingSolverTokens, getSupportedSolverTokens, getTransactionPackets, getbnUSDToken, hederaSupportedTokens, hexToBigInt, hexToSolanaAddress, hubConfig, hyper, hyperevmSupportedTokens, iconSupportedTokens, injectiveSupportedTokens, intentCreationFailed, isBackendHttpError, isBalnMigrateParams, isBitcoinChainKey, isBitcoinChainKeyType, isBitcoinWalletProviderType, isBridgeAllowanceCheckError, isBridgeApproveError, isBridgeCreateIntentError, isBridgeError, isBridgeLookupError, isBridgeOrchestrationError, isCodeMember, isDexApproveError, isDexCreateIntentError, isDexError, isEvmChainKey, isEvmChainKeyType, isEvmSpokeChainConfig, isEvmSpokeOnlyChainKey, isEvmSpokeOnlyChainKeyType, isEvmWalletProviderType, isFeatureError, isHookSupportedToken, isHubChainKey, isHubChainKeyType, isIconAddress, isIconChainKey, isIconChainKeyType, isIcxCreateRevertMigrationParams, isIcxMigrateParams, isInjectiveChainKey, isInjectiveChainKeyType, isJsonRpcPayloadResponse, isLegacybnUSDChainId, isLegacybnUSDToken, isLeverageYieldAllowanceCheckError, isLeverageYieldApproveError, isLeverageYieldCreateIntentError, isLeverageYieldError, isLeverageYieldLookupError, isLeverageYieldPostExecutionError, isLeverageYieldSwapError, isMigrateOrchestrationError, isMigrationAllowanceCheckError, isMigrationApproveError, isMigrationCreateIntentError, isMigrationError, isMigrationLookupError, isMoneyMarketAllowanceCheckError, isMoneyMarketApproveError, isMoneyMarketCreateIntentError, isMoneyMarketError, isMoneyMarketGasEstimationError, isMoneyMarketOrchestrationError, isNativeBitcoinToken, isNativeBitcoinTransfer, isNativeToken, isNearChainKey, isNearChainKeyType, isNewbnUSDChainId, isNewbnUSDToken, isOptionalBitcoinWalletProviderType, isOptionalEvmWalletProviderType, isOptionalStellarWalletProviderType, isPartnerError, isPartnerFeeAmount, isPartnerFeePercentage, isPostExecutionError, isRawDestinationParams, isRecoveryError, isResponseAddressType, isResponseSigningType, isRevertMigrationOrchestrationError, isSodaxError, isSolanaChainKey, isSolanaChainKeyType, isSolanaNativeToken, isSonicChainKey, isSonicChainKeyType, isSpokeApproveParamsEvmSpoke, isSpokeApproveParamsHub, isSpokeApproveParamsStellar, isSpokeChainKey, isSpokeIsAllowanceValidParamsEvmSpoke, isSpokeIsAllowanceValidParamsHub, isSpokeIsAllowanceValidParamsStellar, isSponsoringConfigError, isSponsoringLookupError, isSponsoringOrchestrationError, isStacksChainKey, isStacksChainKeyType, isStakeOrchestrationError, isStakingAllowanceCheckError, isStakingApproveError, isStakingCreateIntentError, isStakingError, isStakingInfoFetchError, isStakingOrchestrationError, isStellarChainKey, isStellarChainKeyType, isStellarWalletProviderType, isSuiChainKey, isSuiChainKeyType, isSupportedBitcoinAddressType, isSwapCreateIntentError, isSwapError, isSwapSupportedToken, isUndefinedOrValidWalletProviderForChainKey, isUnifiedBnUSDMigrateParams, isValidWalletProviderForChainKey, kaiaSupportedTokens, leverageYieldConfig, leverageYieldInvariant, leverageYieldVaults, lightlinkSupportedTokens, lookupFailed, mapRelayFailure, mergeSodaxConfig, messageOf, migrationInvariant, mintPositionParamsAbi, mmInvariant, modifyLiquidityParamsAbi, moneyMarketConfig, moneyMarketReserveAssets, moneyMarketSupportedTokens, nativeToUSD, nearSupportedTokens, newbnUSDSpokeChainIds, noopAnalytics, normalize, normalizeBN, normalizePsbtToBase64, normalizeSignatureToBase64, normalizedToUsd, optimismSupportedTokens, pancakeSwapInfinityDefaultHookAbi, pancakeSwapInfinityPoolManagerAbi, pancakeSwapInfinityPositionManagerAbi, parseToStroops, parseTokenArrayFromJson, partnerInvariant, permit2Abi, polygonSupportedTokens, poolAbi, poolKeyAbi, randomUint256, rayDiv, rayMul, rayPow, rayToWad, recoveryInvariant, redbellySupportedTokens, relayConfig, relayTxAndWaitPacket, requestAddress, requestJsonRpc, requestSigning, resolveAnalytics, resolveLogger, retry, reverseEncodeAddress, serializeAddressData, silentLogger, sleep, sodaxConfig, sodaxInvariant, solanaSupportedTokens, solverConfig, sonicSupportedTokens, sonicWalletFactoryAbi, spokeAssetManagerAbi, spokeChainConfig, spokeChainKeysSet, spokeHooks, sponsoringInvariant, stacksSupportedTokens, stagingSwapSupportedTokens, stakedSodaAbi, stakingInvariant, stakingRouterAbi, stataTokenFactoryAbi, stellarSupportedTokens, submitTransaction, suiSupportedTokens, supportedSpokeChains, supportedTokensByChain, swapExactInSingleParamsAbi, swapInvariant, swapSupportedTokens, swapsConfig, toCreateBridgeIntentParamsV2, tokenLogo, tokenLogoSlug, uiPoolDataAbi, universalRouterAbi, unknownFailed, usesBip322MessageSigning, valueToBigNumber, valueToZDBigNumber, variableDebtTokenAbi, vaultTokenAbi, verifyFailed, wadToRay, waitForStacksTransaction, waitForTransactionReceipt, waitUntilIntentExecuted, walletFactoryAbi, wrappedSonicAbi };
42183
+ export { ALLOWANCE_CHECK_CODES, APPROVE_CODES, AssetService, BACKEND_API_BASE_PATH, BITCOIN_CHAIN_KEYS, BITCOIN_CHAIN_KEYS_SET, BITCOIN_DUST_SATS, BTC_WALLET_ADDRESS_TYPES, BackendApiService, BackendHttpError, BalnSwapService, BigIntToHex, BigNumberZeroDecimal, BitcoinSpokeService, BnUSDMigrationService, BridgeApiService, BridgeService, CHAIN_KEYS, CHAIN_LOGO_BASE_URL, CONFIG_VERSION, CREATE_INTENT_CODES, ChainKeys, ChainTypeArr, ClService, ConfigService, CustomSorobanServer, CustomStellarAccount, DEFAULT_API_BASE_URL, DEFAULT_BACKEND_API_ENDPOINT, DEFAULT_BACKEND_API_HEADERS, DEFAULT_BACKEND_API_TIMEOUT, DEFAULT_DEADLINE_OFFSET, DEFAULT_MAX_RETRY, DEFAULT_RELAYER_API_ENDPOINT, DEFAULT_RELAY_TX_TIMEOUT, DEFAULT_RETRY_DELAY_MS, DEFAULT_SPONSORING_API_ENDPOINT, DexService, EVM_CHAIN_ID_TO_KEY, EVM_CHAIN_KEYS, EVM_CHAIN_KEYS_SET, EVM_SPOKE_ONLY_CHAIN_KEYS, EVM_SPOKE_ONLY_CHAIN_KEYS_SET, Erc20Service, Erc4626Service, EvmAssetManagerService, EvmHubProvider, EvmSolverService, EvmSpokeService, EvmVaultTokenService, FEE_PERCENTAGE_SCALE, GAS_ESTIMATION_CODES, HALF_RAY, HALF_WAD, HUB_CHAIN_KEY, HookKind, HookService, HttpRelayError, HubVaultSymbols, ICON_CHAIN_KEYS, ICON_CHAIN_KEYS_SET, ICON_TX_RESULT_WAIT_MAX_RETRY, INJECTIVE_CHAIN_KEYS, INJECTIVE_CHAIN_KEYS_SET, INTENT_CHAIN_IDS, IconSpokeService, IcxMigrationService, Injective20Token, InjectiveSpokeService, IntentCreatedEventAbi, IntentDataService, IntentDataType, IntentFilledEventAbi, IntentRelayChainIdToChainKey, IntentsAbi, LOOKUP_CODES, LTV_PRECISION, LendingPoolService, LeverageYieldService, LockupMultiplier, LockupPeriod, LsodaSymbols, LsodaTokens, MAX_UINT256, MigrationService, MintPositionEventAbi, MoneyMarketDataService, MoneyMarketService, NEAR_CHAIN_KEYS, NEAR_CHAIN_KEYS_SET, NEAR_DEFAULT_GAS, NEAR_STORAGE_DEPOSIT, NearSpokeService, PartnerFeeClaimService, PartnerService, Permit2Service, ProtocolIntentsAbi, RAY, RAY_DECIMALS, RELAY_ERROR_CODES, RELAY_FALLBACK_FLOOR_MS, RadfiApiError, RadfiProvider, RecoveryService, RelayChainIdMap, SECONDS_PER_YEAR, SODAX_ERROR_CODES, SODAX_FEATURES, SOLANA_CHAIN_KEYS, SOLANA_CHAIN_KEYS_SET, SONIC_CHAIN_KEYS, SONIC_CHAIN_KEYS_SET, SPONSORING_API_ERROR_CODES, SPONSORING_API_STELLAR_BASE_PATH, SPONSOR_CONFIG_TTL_MS, STACKS_CHAIN_KEYS, STACKS_CHAIN_KEYS_SET, STELLAR_BASE_RESERVE_TTL_MS, STELLAR_CHAIN_KEYS, STELLAR_CHAIN_KEYS_SET, STELLAR_TRUSTLINE_MIN_XLM_STROOPS, SUI_CHAIN_KEYS, SUI_CHAIN_KEYS_SET, SodaTokens, Sodax, SodaxError, SolanaSpokeService, SolverApiService, SolverIntentErrorCode, SolverIntentStatusCode, SonicSpokeService, SpokeService, SponsoringApiService, SponsoringService, StacksSpokeService, StakingLogic, StakingService, StatATokenAddresses, StellarSpokeService, SuiSpokeService, SupportedMigrationTokens, SwapService, SwapsApiService, TOKEN_LOGO_BASE_URL, USD_DECIMALS, UiPoolDataProviderService, VAULT_TOKEN_DECIMALS, WAD, WAD_RAY_RATIO, WEI_DECIMALS, adjustAmountByFee, allowanceCheckFailed, apiConfig, approveFailed, arbitrumSupportedTokens, assetManagerAbi, avalancheSupportedTokens, balnSwapAbi, baseChainInfo, baseSupportedTokens, binomialApproximatedRayPow, bitcoinSupportedTokens, bnUSDLegacySpokeChainIds, bnUSDLegacyTokens, bridgeConfig, bridgeInvariant, bscSupportedTokens, calcOpReturnOutputVbytes, calculateAllReserveIncentives, calculateAllUserIncentives, calculateAvailableBorrowsMarketReferenceCurrency, calculateCompoundedInterest, calculateCompoundedRate, calculateFeeAmount, calculateHealthFactorFromBalances, calculateHealthFactorFromBalancesBigUnits, calculateLinearInterest, calculatePercentageFeeAmount, clPoolAbi, clPoolManagerAbi, clPositionManagerAbi, clQuoterAbi, clRouterAbi, clTickLensAbi, classifySponsorError, concentratedLiquidityConfig, connectionAbi, consoleLogger, convertTransactionInstructionToRaw, createInvariant, deepMerge, defaultHookAbi, detectBitcoinAddressType, dexConfig, dexInvariant, dexPools, encodeAddress, encodeBtcPayloadToBytes, encodeContractCalls, erc20Abi, erc4626Abi, estimateBitcoinTxSize, ethereumSupportedTokens, executionFailed, formatBasisPoints, formatEModeCategory, formatEModes, formatPercentage, formatReserve, formatReserveUSD, formatReserves, formatReservesAndIncentives, formatUserSummary, formatUserSummaryAndIncentives, gasEstimationFailed, getAllLegacybnUSDTokens, getAndFormatReserveEModes, getAssetManagerIdl, getAssetManagerProgram, getChainKeyFromRelayChainId, getChainType, getCompoundedBalance, getConcentratedLiquidityConfig, getConnectionIdl, getConnectionProgram, getEvmChainKeyByChainId, getEvmViemChain, getIconAddressBytes, getIntentRelayChainId, getLinearBalance, getMarketReferenceCurrencyAndUsdBalance, getPacket, getProvider, getRandomBytes, getReserveNormalizedIncome, getReservesEModes, getSolanaAddressBytes, getSolverConfig, getSpokeHook, getSpokeHooks, getStagingSolverTokens, getSupportedSolverTokens, getTransactionPackets, getbnUSDToken, hederaSupportedTokens, hexToBigInt, hexToSolanaAddress, hubConfig, hyper, hyperevmSupportedTokens, iconSupportedTokens, injectiveSupportedTokens, intentCreationFailed, isBackendHttpError, isBalnMigrateParams, isBitcoinChainKey, isBitcoinChainKeyType, isBitcoinWalletProviderType, isBridgeAllowanceCheckError, isBridgeApproveError, isBridgeCreateIntentError, isBridgeError, isBridgeLookupError, isBridgeOrchestrationError, isCodeMember, isDexApproveError, isDexCreateIntentError, isDexError, isEvmChainKey, isEvmChainKeyType, isEvmSpokeChainConfig, isEvmSpokeOnlyChainKey, isEvmSpokeOnlyChainKeyType, isEvmWalletProviderType, isFeatureError, isHookSupportedToken, isHubChainKey, isHubChainKeyType, isIconAddress, isIconChainKey, isIconChainKeyType, isIcxCreateRevertMigrationParams, isIcxMigrateParams, isInjectiveChainKey, isInjectiveChainKeyType, isJsonRpcPayloadResponse, isLegacybnUSDChainId, isLegacybnUSDToken, isLeverageYieldAllowanceCheckError, isLeverageYieldApproveError, isLeverageYieldCreateIntentError, isLeverageYieldError, isLeverageYieldLookupError, isLeverageYieldPostExecutionError, isLeverageYieldSwapError, isMigrateOrchestrationError, isMigrationAllowanceCheckError, isMigrationApproveError, isMigrationCreateIntentError, isMigrationError, isMigrationLookupError, isMoneyMarketAllowanceCheckError, isMoneyMarketApproveError, isMoneyMarketCreateIntentError, isMoneyMarketError, isMoneyMarketGasEstimationError, isMoneyMarketOrchestrationError, isNativeBitcoinToken, isNativeBitcoinTransfer, isNativeToken, isNearChainKey, isNearChainKeyType, isNewbnUSDChainId, isNewbnUSDToken, isOptionalBitcoinWalletProviderType, isOptionalEvmWalletProviderType, isOptionalStellarWalletProviderType, isPartnerError, isPartnerFeeAmount, isPartnerFeePercentage, isPostExecutionError, isRawDestinationParams, isRecoveryError, isResponseAddressType, isResponseSigningType, isRevertMigrationOrchestrationError, isSodaxError, isSolanaChainKey, isSolanaChainKeyType, isSolanaNativeToken, isSonicChainKey, isSonicChainKeyType, isSpokeApproveParamsEvmSpoke, isSpokeApproveParamsHub, isSpokeApproveParamsStellar, isSpokeChainKey, isSpokeIsAllowanceValidParamsEvmSpoke, isSpokeIsAllowanceValidParamsHub, isSpokeIsAllowanceValidParamsStellar, isSponsoringConfigError, isSponsoringLookupError, isSponsoringOrchestrationError, isStacksChainKey, isStacksChainKeyType, isStakeOrchestrationError, isStakingAllowanceCheckError, isStakingApproveError, isStakingCreateIntentError, isStakingError, isStakingInfoFetchError, isStakingOrchestrationError, isStellarChainKey, isStellarChainKeyType, isStellarWalletProviderType, isSuiChainKey, isSuiChainKeyType, isSupportedBitcoinAddressType, isSwapCreateIntentError, isSwapError, isSwapSupportedToken, isUndefinedOrValidWalletProviderForChainKey, isUnifiedBnUSDMigrateParams, isValidWalletProviderForChainKey, kaiaSupportedTokens, leverageYieldConfig, leverageYieldInvariant, leverageYieldVaults, lightlinkSupportedTokens, lookupFailed, mapRelayFailure, mergeSodaxConfig, messageOf, migrationInvariant, mintPositionParamsAbi, mmInvariant, modifyLiquidityParamsAbi, moneyMarketConfig, moneyMarketReserveAssets, moneyMarketSupportedTokens, nativeToUSD, nearSupportedTokens, newbnUSDSpokeChainIds, noopAnalytics, normalize, normalizeBN, normalizePsbtToBase64, normalizeSignatureToBase64, normalizedToUsd, optimismSupportedTokens, pancakeSwapInfinityDefaultHookAbi, pancakeSwapInfinityPoolManagerAbi, pancakeSwapInfinityPositionManagerAbi, parseToStroops, parseTokenArrayFromJson, partnerInvariant, permit2Abi, polygonSupportedTokens, poolAbi, poolKeyAbi, randomUint256, rayDiv, rayMul, rayPow, rayToWad, recoveryInvariant, redbellySupportedTokens, relayConfig, relayTxAndWaitPacket, requestAddress, requestJsonRpc, requestSigning, resolveAnalytics, resolveLogger, retry, reverseEncodeAddress, serializeAddressData, silentLogger, sleep, sodaxConfig, sodaxInvariant, solanaSupportedTokens, solverConfig, sonicSupportedTokens, sonicWalletFactoryAbi, spokeAssetManagerAbi, spokeChainConfig, spokeChainKeysSet, spokeHooks, sponsoringInvariant, stacksSupportedTokens, stagingSwapSupportedTokens, stakedSodaAbi, stakingInvariant, stakingRouterAbi, stataTokenFactoryAbi, stellarSupportedTokens, submitTransaction, suiSupportedTokens, supportedSpokeChains, supportedTokensByChain, swapExactInSingleParamsAbi, swapInvariant, swapSupportedTokens, swapsConfig, toCreateBridgeIntentParamsV2, tokenLogo, tokenLogoSlug, uiPoolDataAbi, universalRouterAbi, unknownFailed, usesBip322MessageSigning, valueToBigNumber, valueToZDBigNumber, variableDebtTokenAbi, vaultTokenAbi, verifyFailed, wadToRay, waitForStacksTransaction, waitForTransactionReceipt, waitUntilIntentExecuted, walletFactoryAbi, wrappedSonicAbi };