@sodax/sdk 2.1.0 → 2.2.0-rc.1

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
@@ -3696,7 +3696,7 @@ var spokeChainConfig = {
3696
3696
  }
3697
3697
  },
3698
3698
  [ChainKeys.NEAR_MAINNET]: {
3699
- rpcUrl: "https://1rpc.io/near",
3699
+ rpcUrl: "https://free.rpc.fastnear.com",
3700
3700
  chain: baseChainInfo[ChainKeys.NEAR_MAINNET],
3701
3701
  nativeToken: "NEAR",
3702
3702
  addresses: {
@@ -4858,7 +4858,7 @@ function isValidWalletProviderForChainKey(chainKey, walletProvider) {
4858
4858
  }
4859
4859
 
4860
4860
  // ../types/dist/index.js
4861
- var CONFIG_VERSION = 230;
4861
+ var CONFIG_VERSION = 231;
4862
4862
 
4863
4863
  // src/shared/utils/resolveTimeoutMs.ts
4864
4864
  function resolveTimeoutMs(timeout, fallbackMs) {
@@ -5407,6 +5407,12 @@ function isFeatureError(feature) {
5407
5407
  function isCodeMember(codes) {
5408
5408
  return (e) => isSodaxError(e) && codes.has(e.code);
5409
5409
  }
5410
+ function isAuthStatus(status) {
5411
+ return status === 401 || status === 403;
5412
+ }
5413
+ function isAuthFailure(error) {
5414
+ return isSodaxError(error) && isAuthStatus(error.context?.status);
5415
+ }
5410
5416
 
5411
5417
  // src/errors/wrappers.ts
5412
5418
  function messageOf(error, fallback2) {
@@ -14464,6 +14470,13 @@ var ConfigService = class {
14464
14470
  * a client-side option set via `new Sodax({ fee })`. Per-feature overrides live on the feature config.
14465
14471
  */
14466
14472
  fee;
14473
+ /**
14474
+ * Global backend API key. Resolved once at construction and kept independent of {@link sodax} so
14475
+ * that {@link initialize}'s dynamic-config swap never clobbers it. The backend never supplies it —
14476
+ * it is a client-side option set via `new Sodax({ apiKey })`. Never logged; read here by the swap,
14477
+ * leverage-yield, and partner solver flows, whose transport does not go through `BackendApiService`.
14478
+ */
14479
+ apiKey;
14467
14480
  /**
14468
14481
  * RadFi/Bound request signer. Resolved once at construction and kept independent of {@link sodax}
14469
14482
  * so that {@link initialize}'s dynamic-config swap never clobbers it. Read by `BitcoinSpokeService`
@@ -14484,11 +14497,21 @@ var ConfigService = class {
14484
14497
  hubAssetToXTokenMap;
14485
14498
  // `api` / `userConfig` are accepted but unused while initialize()'s dynamic fetch is disabled
14486
14499
  // (see TODO(config-v2) below); restore their assignments when re-enabling.
14487
- constructor({ api, config, userConfig, logger, analytics, fee, radfiSigner }) {
14500
+ constructor({
14501
+ api,
14502
+ config,
14503
+ userConfig,
14504
+ logger,
14505
+ analytics,
14506
+ fee,
14507
+ apiKey,
14508
+ radfiSigner
14509
+ }) {
14488
14510
  this.sodax = config;
14489
14511
  this.logger = logger ?? resolveLogger(void 0);
14490
14512
  this.analytics = analytics ?? noopAnalytics;
14491
14513
  this.fee = fee;
14514
+ this.apiKey = apiKey;
14492
14515
  this.radfiSigner = radfiSigner;
14493
14516
  this.loadSodaxConfigDataStructures(config);
14494
14517
  }
@@ -14682,7 +14705,9 @@ var ConfigService = class {
14682
14705
  ])
14683
14706
  );
14684
14707
  this.loadSpokeChainConfigDataStructures(sodaxConfig2);
14685
- this.moneyMarketReserveAssetsSet = new Set(sodaxConfig2.moneyMarket.supportedReserveAssets);
14708
+ this.moneyMarketReserveAssetsSet = new Set(
14709
+ sodaxConfig2.moneyMarket.supportedReserveAssets.map((address) => address.toLowerCase())
14710
+ );
14686
14711
  this.stakedATokenAddressesSet = new Set(
14687
14712
  Object.keys(sodaxConfig2.dex.statATokenAddresses).map((address) => address.toLowerCase())
14688
14713
  );
@@ -27296,6 +27321,119 @@ var EvmHubProvider = class {
27296
27321
  }
27297
27322
  };
27298
27323
 
27324
+ // src/backendApi/api-utils.ts
27325
+ var API_KEY_HEADER = "x-api-key";
27326
+ function apiKeyHeader(apiKey) {
27327
+ return apiKey ? { [API_KEY_HEADER]: apiKey } : {};
27328
+ }
27329
+ function mergeHeaders(...sources) {
27330
+ const byName = /* @__PURE__ */ new Map();
27331
+ for (const source of sources) {
27332
+ for (const entry of Object.entries(source ?? {})) byName.set(entry[0].toLowerCase(), entry);
27333
+ }
27334
+ return Object.fromEntries(byName.values());
27335
+ }
27336
+ function withApiKey(config, apiKey) {
27337
+ return { ...config, headers: mergeHeaders(apiKeyHeader(apiKey), config.headers) };
27338
+ }
27339
+ function assignHeaders(target, source) {
27340
+ const merged = mergeHeaders(target, source);
27341
+ for (const name of Object.keys(target)) delete target[name];
27342
+ Object.assign(target, merged);
27343
+ }
27344
+ var BackendHttpError = class extends Error {
27345
+ status;
27346
+ bodyText;
27347
+ /** Parsed JSON, or `undefined` for empty or malformed bodies. */
27348
+ body;
27349
+ constructor(status, bodyText) {
27350
+ super("HTTP_REQUEST_FAILED", { cause: new Error(`HTTP ${status}: ${bodyText}`) });
27351
+ this.name = "BackendHttpError";
27352
+ this.status = status;
27353
+ this.bodyText = bodyText;
27354
+ this.body = safeJsonParse(bodyText);
27355
+ }
27356
+ };
27357
+ function isBackendHttpError(error) {
27358
+ if (error instanceof BackendHttpError) return true;
27359
+ return error instanceof Error && error.name === "BackendHttpError" && typeof error.status === "number";
27360
+ }
27361
+ function safeJsonParse(text) {
27362
+ if (text.length === 0) return void 0;
27363
+ try {
27364
+ return JSON.parse(text);
27365
+ } catch {
27366
+ return void 0;
27367
+ }
27368
+ }
27369
+ function trimTrailingSlashes(baseURL) {
27370
+ let end = baseURL.length;
27371
+ while (end > 0 && baseURL[end - 1] === "/") end -= 1;
27372
+ return baseURL.slice(0, end);
27373
+ }
27374
+ var toJsonBody = (value) => JSON.stringify(value, (_key, val) => typeof val === "bigint" ? val.toString() : val);
27375
+ async function makeRequest(params) {
27376
+ const { endpoint, config, overrideConfig = {}, logger, serviceLabel } = params;
27377
+ const baseURL = overrideConfig.baseURL || config.baseURL || "";
27378
+ const url = `${trimTrailingSlashes(baseURL)}${endpoint}`;
27379
+ const headers = mergeHeaders(config.headers, apiKeyHeader(overrideConfig.apiKey), overrideConfig.headers);
27380
+ const controller = new AbortController();
27381
+ const timeout = overrideConfig.timeout ?? config.timeout ?? DEFAULT_BACKEND_API_TIMEOUT;
27382
+ const timeoutId = setTimeout(() => controller.abort(), timeout);
27383
+ try {
27384
+ const response = await fetch(url, {
27385
+ method: config.method,
27386
+ headers,
27387
+ body: config.body,
27388
+ signal: controller.signal
27389
+ });
27390
+ if (!response.ok) {
27391
+ const errorText = await response.text();
27392
+ throw new BackendHttpError(response.status, errorText);
27393
+ }
27394
+ const data = await response.json();
27395
+ return data;
27396
+ } catch (error) {
27397
+ if (error instanceof Error) {
27398
+ if (error.name === "AbortError") {
27399
+ throw new Error("REQUEST_TIMEOUT", { cause: new Error(`Request timeout after ${timeout}ms`) });
27400
+ }
27401
+ logger.error(`[${serviceLabel}] Request error`, error);
27402
+ throw error;
27403
+ }
27404
+ logger.error(`[${serviceLabel}] Unknown error`, error);
27405
+ throw new Error("UNKNOWN_REQUEST_ERROR", { cause: error });
27406
+ } finally {
27407
+ clearTimeout(timeoutId);
27408
+ }
27409
+ }
27410
+ function resolveRequestConfig(config, defaults) {
27411
+ const { baseURL, timeout, headers, apiKey, ...rest } = config;
27412
+ return {
27413
+ ...rest,
27414
+ baseURL: baseURL || defaults.baseURL,
27415
+ timeout: timeout ?? defaults.timeout,
27416
+ headers: mergeHeaders(defaults.headers, apiKeyHeader(apiKey), headers)
27417
+ };
27418
+ }
27419
+ function toExternalApiError(params) {
27420
+ const { api, feature, endpoint, error } = params;
27421
+ const context = { api, endpoint };
27422
+ if (isBackendHttpError(error)) context.status = error.status;
27423
+ return new SodaxError(
27424
+ "EXTERNAL_API_ERROR",
27425
+ error instanceof Error ? error.message : `Request to ${endpoint} failed`,
27426
+ { feature, cause: error, context }
27427
+ );
27428
+ }
27429
+ function toInvalidResponseShapeError(params) {
27430
+ const { api, feature, endpoint, issues } = params;
27431
+ return new SodaxError("EXTERNAL_API_ERROR", `Invalid response shape from ${api} API for ${endpoint}`, {
27432
+ feature,
27433
+ context: { api, endpoint, reason: "invalid_response_shape", issues }
27434
+ });
27435
+ }
27436
+
27299
27437
  // src/swap/SolverApiService.ts
27300
27438
  var bigintReplacer = (_key, value) => typeof value === "bigint" ? value.toString() : value;
27301
27439
  var SolverApiService = class {
@@ -27342,9 +27480,7 @@ var SolverApiService = class {
27342
27480
  try {
27343
27481
  const response = await fetch(`${config.solverApiEndpoint}/quote`, {
27344
27482
  method: "POST",
27345
- headers: {
27346
- "Content-Type": "application/json"
27347
- },
27483
+ headers: mergeHeaders({ "Content-Type": "application/json" }, apiKeyHeader(configService.apiKey)),
27348
27484
  body: JSON.stringify({
27349
27485
  token_src: tokenSrc,
27350
27486
  token_dst: tokenDst,
@@ -27390,16 +27526,16 @@ var SolverApiService = class {
27390
27526
  *
27391
27527
  * @param request - Object containing `intent_tx_hash` (the hub-chain tx hash of the created intent).
27392
27528
  * @param config - Solver endpoint configuration.
27529
+ * @param logger - Diagnostics sink; defaults to the silent logger.
27530
+ * @param apiKey - Configured backend API key (`config.apiKey`), sent as the `x-api-key` header.
27393
27531
  * @returns A `Result` containing `{ answer: 'OK', intent_hash: Hex }` on success.
27394
27532
  */
27395
- static async postExecution(request, config, logger = silentLogger) {
27533
+ static async postExecution(request, config, logger = silentLogger, apiKey) {
27396
27534
  try {
27397
27535
  const response = await retry(
27398
27536
  () => fetch(`${config.solverApiEndpoint}/execute`, {
27399
27537
  method: "POST",
27400
- headers: {
27401
- "Content-Type": "application/json"
27402
- },
27538
+ headers: mergeHeaders({ "Content-Type": "application/json" }, apiKeyHeader(apiKey)),
27403
27539
  body: JSON.stringify(request)
27404
27540
  })
27405
27541
  );
@@ -27443,11 +27579,12 @@ var SolverApiService = class {
27443
27579
  * request instantly. A non-positive one is a real budget of zero: the request aborts at once.
27444
27580
  * The relay's `getTransactionPackets` takes the same parameter but degrades a non-finite value
27445
27581
  * to its own per-request budget instead; the divergence is deliberate, and explained inline.
27582
+ * @param apiKey - Configured backend API key (`config.apiKey`), sent as the `x-api-key` header.
27446
27583
  * @returns A `Result` containing `{ status: SolverIntentStatusCode, fill_tx_hash?: string }`.
27447
27584
  * `fill_tx_hash` is set only when `status === SolverIntentStatusCode.SOLVED (3)`.
27448
27585
  * @throws Invariant error if `intent_tx_hash` is empty (thrown before the async request).
27449
27586
  */
27450
- static async getStatus(request, config, logger = silentLogger, timeoutMs) {
27587
+ static async getStatus(request, config, logger = silentLogger, timeoutMs, apiKey) {
27451
27588
  invariant(request.intent_tx_hash.length > 0, "Empty intent_tx_hash");
27452
27589
  const budgetMs = timeoutMs !== void 0 && Number.isFinite(timeoutMs) ? Math.max(0, timeoutMs) : void 0;
27453
27590
  const controller = budgetMs === void 0 ? void 0 : new AbortController();
@@ -27455,9 +27592,7 @@ var SolverApiService = class {
27455
27592
  try {
27456
27593
  const response = await fetch(`${config.solverApiEndpoint}/status`, {
27457
27594
  method: "POST",
27458
- headers: {
27459
- "Content-Type": "application/json"
27460
- },
27595
+ headers: mergeHeaders({ "Content-Type": "application/json" }, apiKeyHeader(apiKey)),
27461
27596
  body: JSON.stringify(request),
27462
27597
  signal: controller?.signal
27463
27598
  });
@@ -27518,6 +27653,12 @@ async function pollBackendSubmitTx({
27518
27653
  }
27519
27654
  } else {
27520
27655
  lastStatusError = statusResult.error;
27656
+ if (isAuthFailure(statusResult.error)) {
27657
+ return {
27658
+ ok: false,
27659
+ cause: new Error("backend submit-tx status rejected the API key", { cause: statusResult.error })
27660
+ };
27661
+ }
27521
27662
  }
27522
27663
  if (attempt.remaining() <= intervalMs) break;
27523
27664
  await sleep(intervalMs);
@@ -27559,12 +27700,13 @@ async function runBackendSubmitTx({
27559
27700
  body,
27560
27701
  statusQuery,
27561
27702
  terminalStatus,
27562
- onExecuted
27703
+ onExecuted,
27704
+ overrideConfig
27563
27705
  }) {
27564
27706
  const serviceTimeoutMs = api.getTimeout();
27565
27707
  const requestTimeout = attempt.requestTimeout(serviceTimeoutMs);
27566
27708
  if (requestTimeout === null) return { ok: false, cause: noRequestBudgetCause(serviceTimeoutMs) };
27567
- const submitted = await api.submitTx(body, { timeout: requestTimeout });
27709
+ const submitted = await api.submitTx(body, { ...overrideConfig, timeout: requestTimeout });
27568
27710
  if (!submitted.ok) return { ok: false, cause: submitted.error };
27569
27711
  if (!submitted.value.success) {
27570
27712
  return { ok: false, cause: new Error(`backend submit-tx not accepted: ${submitted.value.data.message}`) };
@@ -27572,7 +27714,8 @@ async function runBackendSubmitTx({
27572
27714
  const polled = await pollBackendSubmitTx({
27573
27715
  attempt,
27574
27716
  terminalStatus,
27575
- getStatus: (override) => api.getSubmitTxStatus(statusQuery, override),
27717
+ // The poll's own override (its per-request timeout) wins over the per-action fields.
27718
+ getStatus: (override) => api.getSubmitTxStatus(statusQuery, { ...overrideConfig, ...override }),
27576
27719
  onExecuted,
27577
27720
  // While this ceiling is the smaller bound the poll retries within the attempt; once the attempt's
27578
27721
  // remainder falls below it, one stalled request can spend the rest.
@@ -27745,6 +27888,34 @@ function selectSolvedIntentPacket(packets, intentsContract) {
27745
27888
  return packets.reduce((highest, packet) => packet.conn_sn > highest.conn_sn ? packet : highest);
27746
27889
  }
27747
27890
 
27891
+ // src/swap/speed-tier.ts
27892
+ var SPEED_TIER_SECONDS = {
27893
+ /** Either token maps to a money-market-reserve (sodaAsset) hub asset. */
27894
+ sodaAsset: 15,
27895
+ /** Anything else / default. */
27896
+ default: 35,
27897
+ /** Added once when either src or dst is an Ethereum asset. */
27898
+ ethereumPenalty: 10
27899
+ };
27900
+ var SPEED_TIER_THRESHOLDS = {
27901
+ fast: 20,
27902
+ normal: 30
27903
+ };
27904
+ var isEthereumToken = (token) => token.chainKey === ChainKeys.ETHEREUM_MAINNET;
27905
+ var secondsToTier = (seconds) => {
27906
+ if (seconds <= SPEED_TIER_THRESHOLDS.fast) return "fast";
27907
+ if (seconds <= SPEED_TIER_THRESHOLDS.normal) return "normal";
27908
+ return "slow";
27909
+ };
27910
+ function estimateSwapSpeedTier({ srcToken, dstToken }, isSodaAssetRelated) {
27911
+ const eitherSodaAsset = isSodaAssetRelated(srcToken.hubAsset) || isSodaAssetRelated(dstToken.hubAsset);
27912
+ let estimatedSeconds = eitherSodaAsset ? SPEED_TIER_SECONDS.sodaAsset : SPEED_TIER_SECONDS.default;
27913
+ if (isEthereumToken(srcToken) || isEthereumToken(dstToken)) {
27914
+ estimatedSeconds += SPEED_TIER_SECONDS.ethereumPenalty;
27915
+ }
27916
+ return { tier: secondsToTier(estimatedSeconds), estimatedSeconds };
27917
+ }
27918
+
27748
27919
  // src/swap/detailedStatus.ts
27749
27920
  var DETAILED_STATUS_NOT_DELIVERED = "relay_not_delivered";
27750
27921
  function isBackendSubmitTxAbandoned(data) {
@@ -27901,7 +28072,13 @@ var SwapService = class {
27901
28072
  * falls through to carries its own {@link RECONCILE_TIMEOUT_MS}, so a bounded call can cost both.
27902
28073
  */
27903
28074
  async resolveSolverStatus(request, timeoutMs) {
27904
- const solverResult = await SolverApiService.getStatus(request, this.solver, this.config.logger, timeoutMs);
28075
+ const solverResult = await SolverApiService.getStatus(
28076
+ request,
28077
+ this.solver,
28078
+ this.config.logger,
28079
+ timeoutMs,
28080
+ this.config.apiKey
28081
+ );
27905
28082
  const forgotten = !solverResult.ok || solverResult.value.status === SolverIntentStatusCode.NOT_FOUND;
27906
28083
  if (!forgotten) return solverResult;
27907
28084
  const timeout = Math.min(RECONCILE_TIMEOUT_MS, this.backendApi.requestTimeoutMs);
@@ -28050,7 +28227,7 @@ var SwapService = class {
28050
28227
  */
28051
28228
  async postExecution(request) {
28052
28229
  try {
28053
- const result = await SolverApiService.postExecution(request, this.solver, this.config.logger);
28230
+ const result = await SolverApiService.postExecution(request, this.solver, this.config.logger, this.config.apiKey);
28054
28231
  if (result.ok) return result;
28055
28232
  const detail = result.error?.detail ?? {
28056
28233
  code: -999,
@@ -28281,6 +28458,9 @@ var SwapService = class {
28281
28458
  const outcome = await runBackendSubmitTx({
28282
28459
  attempt,
28283
28460
  api: this.backendApi.swaps,
28461
+ // The configured key is already baked into the SwapsApiService headers, so only this
28462
+ // per-action override (mirroring `extras.partnerFee`) travels per call.
28463
+ overrideConfig: { apiKey: _params.extras?.apiKey },
28284
28464
  body: {
28285
28465
  txHash: spokeTxHash,
28286
28466
  srcChainKey,
@@ -29029,6 +29209,19 @@ var SwapService = class {
29029
29209
  getSupportedSwapTokens() {
29030
29210
  return this.config.getSupportedSwapTokens();
29031
29211
  }
29212
+ /**
29213
+ * Offline, rule-based estimate of how fast a `srcToken`→`dstToken` swap will settle.
29214
+ *
29215
+ * Derived purely from SDK config (no network / on-chain / backend call): tokens tied to a
29216
+ * money-market-reserve sodaAsset settle faster, and an Ethereum leg adds a fixed penalty. See
29217
+ * {@link estimateSwapSpeedTier} for the rules.
29218
+ *
29219
+ * @param params `{ srcToken, dstToken }` spoke token pair to estimate
29220
+ * @returns the estimated `tier` bucket and `estimatedSeconds`
29221
+ */
29222
+ getSwapSpeedTier(params) {
29223
+ return estimateSwapSpeedTier(params, (hubAsset) => this.config.isMoneyMarketReserveHubAsset(hubAsset));
29224
+ }
29032
29225
  };
29033
29226
 
29034
29227
  // src/migration/errors.ts
@@ -31107,100 +31300,6 @@ var MigrationService = class {
31107
31300
  }
31108
31301
  };
31109
31302
 
31110
- // src/backendApi/api-utils.ts
31111
- var BackendHttpError = class extends Error {
31112
- status;
31113
- bodyText;
31114
- /** Parsed JSON, or `undefined` for empty or malformed bodies. */
31115
- body;
31116
- constructor(status, bodyText) {
31117
- super("HTTP_REQUEST_FAILED", { cause: new Error(`HTTP ${status}: ${bodyText}`) });
31118
- this.name = "BackendHttpError";
31119
- this.status = status;
31120
- this.bodyText = bodyText;
31121
- this.body = safeJsonParse(bodyText);
31122
- }
31123
- };
31124
- function isBackendHttpError(error) {
31125
- if (error instanceof BackendHttpError) return true;
31126
- return error instanceof Error && error.name === "BackendHttpError" && typeof error.status === "number";
31127
- }
31128
- function safeJsonParse(text) {
31129
- if (text.length === 0) return void 0;
31130
- try {
31131
- return JSON.parse(text);
31132
- } catch {
31133
- return void 0;
31134
- }
31135
- }
31136
- function trimTrailingSlashes(baseURL) {
31137
- let end = baseURL.length;
31138
- while (end > 0 && baseURL[end - 1] === "/") end -= 1;
31139
- return baseURL.slice(0, end);
31140
- }
31141
- var toJsonBody = (value) => JSON.stringify(value, (_key, val) => typeof val === "bigint" ? val.toString() : val);
31142
- async function makeRequest(params) {
31143
- const { endpoint, config, overrideConfig = {}, logger, serviceLabel } = params;
31144
- const baseURL = overrideConfig.baseURL || config.baseURL || "";
31145
- const url = `${trimTrailingSlashes(baseURL)}${endpoint}`;
31146
- const headers = { ...config.headers, ...overrideConfig.headers };
31147
- const controller = new AbortController();
31148
- const timeout = overrideConfig.timeout ?? config.timeout ?? DEFAULT_BACKEND_API_TIMEOUT;
31149
- const timeoutId = setTimeout(() => controller.abort(), timeout);
31150
- try {
31151
- const response = await fetch(url, {
31152
- method: config.method,
31153
- headers,
31154
- body: config.body,
31155
- signal: controller.signal
31156
- });
31157
- if (!response.ok) {
31158
- const errorText = await response.text();
31159
- throw new BackendHttpError(response.status, errorText);
31160
- }
31161
- const data = await response.json();
31162
- return data;
31163
- } catch (error) {
31164
- if (error instanceof Error) {
31165
- if (error.name === "AbortError") {
31166
- throw new Error("REQUEST_TIMEOUT", { cause: new Error(`Request timeout after ${timeout}ms`) });
31167
- }
31168
- logger.error(`[${serviceLabel}] Request error`, error);
31169
- throw error;
31170
- }
31171
- logger.error(`[${serviceLabel}] Unknown error`, error);
31172
- throw new Error("UNKNOWN_REQUEST_ERROR", { cause: error });
31173
- } finally {
31174
- clearTimeout(timeoutId);
31175
- }
31176
- }
31177
- function resolveRequestConfig(config, defaults) {
31178
- const { baseURL, timeout, headers, ...rest } = config;
31179
- return {
31180
- ...rest,
31181
- baseURL: baseURL || defaults.baseURL,
31182
- timeout: timeout ?? defaults.timeout,
31183
- headers: { ...defaults.headers, ...headers }
31184
- };
31185
- }
31186
- function toExternalApiError(params) {
31187
- const { api, feature, endpoint, error } = params;
31188
- const context = { api, endpoint };
31189
- if (isBackendHttpError(error)) context.status = error.status;
31190
- return new SodaxError(
31191
- "EXTERNAL_API_ERROR",
31192
- error instanceof Error ? error.message : `Request to ${endpoint} failed`,
31193
- { feature, cause: error, context }
31194
- );
31195
- }
31196
- function toInvalidResponseShapeError(params) {
31197
- const { api, feature, endpoint, issues } = params;
31198
- return new SodaxError("EXTERNAL_API_ERROR", `Invalid response shape from ${api} API for ${endpoint}`, {
31199
- feature,
31200
- context: { api, endpoint, reason: "invalid_response_shape", issues }
31201
- });
31202
- }
31203
-
31204
31303
  // src/backendApi/apiConfig.ts
31205
31304
  function flatLayer({ baseURL, timeout, headers }) {
31206
31305
  return { baseURL, timeout, headers };
@@ -31303,7 +31402,7 @@ var SwapsApiService = class _SwapsApiService {
31303
31402
  trimsLegacyOverrides;
31304
31403
  constructor(config, logger = consoleLogger, options = {}) {
31305
31404
  this.config = config;
31306
- this.headers = { ...config.headers };
31405
+ this.headers = mergeHeaders(config.headers);
31307
31406
  this.logger = logger;
31308
31407
  this.trimsLegacyOverrides = options.trimLegacyOverrides ?? true;
31309
31408
  }
@@ -31319,7 +31418,7 @@ var SwapsApiService = class _SwapsApiService {
31319
31418
  const override = overrideConfig?.baseURL;
31320
31419
  const baseUrl = override ? this.trimsLegacyOverrides ? stripLegacyBackendMount(override) : override : this.config.baseURL;
31321
31420
  const timeout = overrideConfig?.timeout ?? this.config.timeout ?? DEFAULT_BACKEND_API_TIMEOUT;
31322
- const headers = { ...this.headers, ...overrideConfig?.headers };
31421
+ const headers = mergeHeaders(this.headers, apiKeyHeader(overrideConfig?.apiKey), overrideConfig?.headers);
31323
31422
  return new SwapsApi({ baseUrl, headers, timeout });
31324
31423
  }
31325
31424
  /**
@@ -31345,6 +31444,11 @@ var SwapsApiService = class _SwapsApiService {
31345
31444
  context.issues = issues instanceof v.ValiError ? v.flatten(issues.issues) : issues;
31346
31445
  }
31347
31446
  if (error.context.status !== void 0) context.status = error.context.status;
31447
+ if (isAuthStatus(error.context.status)) {
31448
+ this.logger.warn(
31449
+ `[SwapsApiService] ${endpoint} was rejected by the swaps API key guard (${error.context.status}). Configure a valid partner API key \u2014 new Sodax({ apiKey }) \u2014 see docs/CONFIGURE_SDK.md.`
31450
+ );
31451
+ }
31348
31452
  }
31349
31453
  this.logger.error(`[SwapsApiService] Request to ${endpoint} failed`, error);
31350
31454
  return {
@@ -31496,9 +31600,7 @@ var SwapsApiService = class _SwapsApiService {
31496
31600
  * every subsequent call (the delegated client is rebuilt per call).
31497
31601
  */
31498
31602
  setHeaders(headers) {
31499
- Object.entries(headers).forEach(([key, value]) => {
31500
- this.headers[key] = value;
31501
- });
31603
+ assignHeaders(this.headers, headers);
31502
31604
  }
31503
31605
  /** Return the base URL the service is currently pointing at. */
31504
31606
  getBaseURL() {
@@ -31539,13 +31641,22 @@ var SponsoringApiService = class {
31539
31641
  config;
31540
31642
  headers;
31541
31643
  logger;
31542
- constructor(config, logger = consoleLogger) {
31644
+ inheritedApiKey;
31645
+ inheritedApiKeyBaseURLs;
31646
+ constructor(config, logger = consoleLogger, options = {}) {
31543
31647
  this.config = config;
31544
- this.headers = {
31545
- ...config.apiKey !== void 0 ? { "x-api-key": config.apiKey } : {},
31546
- ...config.headers
31547
- };
31648
+ this.headers = mergeHeaders(apiKeyHeader(config.apiKey), config.headers);
31548
31649
  this.logger = logger;
31650
+ this.inheritedApiKey = options.inheritedApiKey;
31651
+ this.inheritedApiKeyBaseURLs = (options.inheritedApiKeyBaseURLs ?? []).map(trimTrailingSlashes);
31652
+ }
31653
+ /**
31654
+ * The inherited instance key, but only for a request whose effective target is an allowed root.
31655
+ * Evaluated per call because a `RequestOverrideConfig.baseURL` retargets the request.
31656
+ */
31657
+ inheritedKeyFor(baseURL) {
31658
+ if (!this.inheritedApiKey) return void 0;
31659
+ return this.inheritedApiKeyBaseURLs.includes(trimTrailingSlashes(baseURL)) ? this.inheritedApiKey : void 0;
31549
31660
  }
31550
31661
  /**
31551
31662
  * Validate a response while preserving HTTP failures on `error.cause` for
@@ -31553,9 +31664,10 @@ var SponsoringApiService = class {
31553
31664
  */
31554
31665
  async request(endpoint, config, schema) {
31555
31666
  try {
31667
+ const inherited = apiKeyHeader(this.inheritedKeyFor(config.baseURL || this.config.baseURL));
31556
31668
  const raw = await makeRequest({
31557
31669
  endpoint,
31558
- config: resolveRequestConfig(config, { ...this.config, headers: this.headers }),
31670
+ config: resolveRequestConfig(config, { ...this.config, headers: mergeHeaders(inherited, this.headers) }),
31559
31671
  logger: this.logger,
31560
31672
  serviceLabel: "SponsoringApiService"
31561
31673
  });
@@ -31597,9 +31709,7 @@ var SponsoringApiService = class {
31597
31709
  );
31598
31710
  }
31599
31711
  setHeaders(headers) {
31600
- Object.entries(headers).forEach(([key, value]) => {
31601
- this.headers[key] = value;
31602
- });
31712
+ assignHeaders(this.headers, headers);
31603
31713
  }
31604
31714
  getBaseURL() {
31605
31715
  return this.config.baseURL;
@@ -31830,18 +31940,7 @@ var BridgeApiService = class {
31830
31940
  }
31831
31941
  return { ok: true, value: parsed.output };
31832
31942
  } catch (error) {
31833
- return {
31834
- ok: false,
31835
- error: new SodaxError(
31836
- "EXTERNAL_API_ERROR",
31837
- error instanceof Error ? error.message : `Request to ${endpoint} failed`,
31838
- {
31839
- feature: "backend",
31840
- cause: error,
31841
- context: { api: "bridge", endpoint }
31842
- }
31843
- )
31844
- };
31943
+ return { ok: false, error: toExternalApiError({ api: "bridge", feature: "backend", endpoint, error }) };
31845
31944
  }
31846
31945
  }
31847
31946
  // ──────────────────────────────────────────────────────────────────────
@@ -32000,9 +32099,7 @@ var BridgeApiService = class {
32000
32099
  * keys are overwritten; keys absent from `headers` are preserved.
32001
32100
  */
32002
32101
  setHeaders(headers) {
32003
- Object.entries(headers).forEach(([key, value]) => {
32004
- this.headers[key] = value;
32005
- });
32102
+ assignHeaders(this.headers, headers);
32006
32103
  }
32007
32104
  /** Return the base URL the service is currently pointing at. */
32008
32105
  getBaseURL() {
@@ -32047,8 +32144,8 @@ var BackendApiService = class {
32047
32144
  * left exactly as given rather than having a real path segment eaten.
32048
32145
  */
32049
32146
  trimsLegacyOverrides;
32050
- constructor(config, logger = consoleLogger) {
32051
- this.config = resolveBaseApiConfig(config);
32147
+ constructor(config, logger = consoleLogger, options = {}) {
32148
+ this.config = withApiKey(resolveBaseApiConfig(config), options.apiKey);
32052
32149
  this.headers = { ...this.config.headers };
32053
32150
  this.logger = logger;
32054
32151
  this.trimsLegacyOverrides = !hasExplicitBasePath(config);
@@ -32073,9 +32170,12 @@ var BackendApiService = class {
32073
32170
  );
32074
32171
  }
32075
32172
  const overrideOptions = { trimLegacyOverrides: this.trimsLegacyOverrides };
32076
- this.swaps = new SwapsApiService(swapsConfig2, this.logger, overrideOptions);
32077
- this.sponsoring = new SponsoringApiService(sponsoringConfig, this.logger);
32078
- this.bridge = new BridgeApiService(bridgeConfig2, this.logger, overrideOptions);
32173
+ this.swaps = new SwapsApiService(withApiKey(swapsConfig2, options.apiKey), this.logger, overrideOptions);
32174
+ this.sponsoring = new SponsoringApiService(sponsoringConfig, this.logger, {
32175
+ inheritedApiKey: options.apiKey,
32176
+ inheritedApiKeyBaseURLs: [DEFAULT_SPONSORING_API_ENDPOINT, this.config.baseURL]
32177
+ });
32178
+ this.bridge = new BridgeApiService(withApiKey(bridgeConfig2, options.apiKey), this.logger, overrideOptions);
32079
32179
  }
32080
32180
  /**
32081
32181
  * Issue the HTTP call for a route.
@@ -32446,9 +32546,7 @@ var BackendApiService = class {
32446
32546
  * @param headers - Key-value pairs to add or overwrite in the default headers.
32447
32547
  */
32448
32548
  setHeaders(headers) {
32449
- Object.entries(headers).forEach(([key, value]) => {
32450
- this.headers[key] = value;
32451
- });
32549
+ assignHeaders(this.headers, headers);
32452
32550
  this.swaps.setHeaders(headers);
32453
32551
  this.bridge.setHeaders(headers);
32454
32552
  }
@@ -32917,6 +33015,9 @@ var BridgeService = class {
32917
33015
  const outcome = await runBackendSubmitTx({
32918
33016
  attempt,
32919
33017
  api: this.backendApi.bridge,
33018
+ // The configured key is already baked into the BridgeApiService headers, so only this
33019
+ // per-action override (mirroring `extras.partnerFee`) travels per call.
33020
+ overrideConfig: { apiKey: _params.extras?.apiKey },
32920
33021
  body: {
32921
33022
  txHash: spokeTxHash,
32922
33023
  srcChainKey,
@@ -40929,7 +41030,8 @@ var PartnerFeeClaimService = class {
40929
41030
  const solverExecutionResponse = await SolverApiService.postExecution(
40930
41031
  { intent_tx_hash: intentTxHash },
40931
41032
  this.config.solver,
40932
- this.config.logger
41033
+ this.config.logger,
41034
+ this.config.apiKey
40933
41035
  );
40934
41036
  if (!solverExecutionResponse.ok) {
40935
41037
  return solverExecutionResponse;
@@ -41933,7 +42035,12 @@ var LeverageYieldService = class {
41933
42035
  */
41934
42036
  async notifySolver(request) {
41935
42037
  try {
41936
- const result = await SolverApiService.postExecution(request, this.config.solver, this.config.logger);
42038
+ const result = await SolverApiService.postExecution(
42039
+ request,
42040
+ this.config.solver,
42041
+ this.config.logger,
42042
+ this.config.apiKey
42043
+ );
41937
42044
  if (result.ok) return result;
41938
42045
  const detail = result.error?.detail ?? {
41939
42046
  code: -999,
@@ -42626,18 +42733,18 @@ var SponsoringService = class {
42626
42733
  return request;
42627
42734
  }
42628
42735
  /**
42629
- * Cache key for a config request: the resolved base URL plus any per-call
42630
- * headers. Headers can select a different response from the same URL — an API
42631
- * key scoped to another deployment, or a test harness's scenario header — so
42632
- * folding them in stops one caller's override from being served to, or
42633
- * overwriting, the default path. Kept in memory as a Map key only.
42736
+ * Cache key for a config request: the resolved base URL plus the per-call headers the request will
42737
+ * actually carry, `apiKey` included. Headers can select a different response from the same URL — an
42738
+ * API key scoped to another deployment, or a test harness's scenario header — so folding them in
42739
+ * stops one caller's override from being served to, or overwriting, the default path. Names are
42740
+ * lower-cased before sorting and serialized as JSON so casing and delimiters cannot collide two
42741
+ * distinct header sets onto one key. Kept in memory as a Map key only.
42634
42742
  */
42635
42743
  configCacheKey(requestConfig) {
42636
42744
  const baseURL = requestConfig?.baseURL || this.api.sponsoring.getBaseURL();
42637
- const headers = requestConfig?.headers;
42638
- if (!headers) return baseURL;
42639
- const normalized = Object.keys(headers).sort().map((name) => `${name.toLowerCase()}=${headers[name]}`).join("&");
42640
- return normalized.length === 0 ? baseURL : `${baseURL}|${normalized}`;
42745
+ const headers = mergeHeaders(apiKeyHeader(requestConfig?.apiKey), requestConfig?.headers);
42746
+ const entries = Object.entries(headers).map(([name, value]) => [name.toLowerCase(), value]).sort((a, b) => a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0);
42747
+ return entries.length === 0 ? baseURL : `${baseURL}|${JSON.stringify(entries)}`;
42641
42748
  }
42642
42749
  /**
42643
42750
  * Fetch sponsor config with per-endpoint caching and in-flight deduplication.
@@ -42863,17 +42970,20 @@ var Sodax = class {
42863
42970
  const logger = resolveLogger(options?.logger);
42864
42971
  const analytics = resolveAnalytics(options?.analytics);
42865
42972
  const fee = options?.fee;
42973
+ const apiKey = options?.apiKey || void 0;
42866
42974
  const radfiSigner = options?.radfi?.signRequest;
42867
- this.instanceConfig = options ? mergeSodaxConfig(sodaxConfig, options) : sodaxConfig;
42868
- this.backendApi = new BackendApiService(this.instanceConfig.api, logger);
42975
+ const mergeOptions = options ? { ...options, apiKey: void 0 } : void 0;
42976
+ this.instanceConfig = mergeOptions ? mergeSodaxConfig(sodaxConfig, mergeOptions) : sodaxConfig;
42977
+ this.backendApi = new BackendApiService(this.instanceConfig.api, logger, { apiKey });
42869
42978
  this.api = this.backendApi;
42870
42979
  this.config = new ConfigService({
42871
42980
  api: this.backendApi,
42872
42981
  config: this.instanceConfig,
42873
- userConfig: options,
42982
+ userConfig: mergeOptions,
42874
42983
  logger,
42875
42984
  analytics,
42876
42985
  fee,
42986
+ apiKey,
42877
42987
  radfiSigner
42878
42988
  });
42879
42989
  this.hubProvider = new EvmHubProvider({ config: this.config });
@@ -42967,4 +43077,4 @@ var isPartnerError = isCodeMember(PARTNER_CODES);
42967
43077
  (*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
42968
43078
  */
42969
43079
 
42970
- 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, DETAILED_STATUS_NOT_DELIVERED, 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, RELAY_REQUEST_TIMEOUT_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, SuiGrpcTransport, 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, isApprovalSupportedChainKeyType, isBackendHttpError, isBalnMigrateParams, isBitcoinChainKey, isBitcoinChainKeyType, isBitcoinWalletProviderType, isBridgeAllowanceCheckError, isBridgeApproveError, isBridgeCreateIntentError, isBridgeError, isBridgeLookupError, isBridgeOrchestrationError, isCodeMember, isDexApproveError, isDexCreateIntentError, isDexError, isEvmChainKey, isEvmChainKeyType, isEvmSpokeChainConfig, isEvmSpokeOnlyChainKey, isEvmSpokeOnlyChainKeyType, isEvmWalletProviderType, isFeatureError, isFillEvent, 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, robinhoodChain, robinhoodSupportedTokens, 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, toSuiExecutionResult, toSuiExecutionStatus, toSuiPaginatedCoins, tokenLogo, tokenLogoSlug, uiPoolDataAbi, universalRouterAbi, unknownFailed, usesBip322MessageSigning, valueToBigNumber, valueToZDBigNumber, variableDebtTokenAbi, vaultTokenAbi, verifyFailed, wadToRay, waitForStacksTransaction, waitForTransactionReceipt, waitUntilIntentExecuted, walletFactoryAbi, wrappedSonicAbi };
43080
+ 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, DETAILED_STATUS_NOT_DELIVERED, 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, RELAY_REQUEST_TIMEOUT_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, SPEED_TIER_SECONDS, SPEED_TIER_THRESHOLDS, 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, SuiGrpcTransport, 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, estimateSwapSpeedTier, 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, isApprovalSupportedChainKeyType, isAuthFailure, isAuthStatus, isBackendHttpError, isBalnMigrateParams, isBitcoinChainKey, isBitcoinChainKeyType, isBitcoinWalletProviderType, isBridgeAllowanceCheckError, isBridgeApproveError, isBridgeCreateIntentError, isBridgeError, isBridgeLookupError, isBridgeOrchestrationError, isCodeMember, isDexApproveError, isDexCreateIntentError, isDexError, isEvmChainKey, isEvmChainKeyType, isEvmSpokeChainConfig, isEvmSpokeOnlyChainKey, isEvmSpokeOnlyChainKeyType, isEvmWalletProviderType, isFeatureError, isFillEvent, 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, robinhoodChain, robinhoodSupportedTokens, 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, toSuiExecutionResult, toSuiExecutionStatus, toSuiPaginatedCoins, tokenLogo, tokenLogoSlug, uiPoolDataAbi, universalRouterAbi, unknownFailed, usesBip322MessageSigning, valueToBigNumber, valueToZDBigNumber, variableDebtTokenAbi, vaultTokenAbi, verifyFailed, wadToRay, waitForStacksTransaction, waitForTransactionReceipt, waitUntilIntentExecuted, walletFactoryAbi, wrappedSonicAbi };