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

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
@@ -17,7 +17,7 @@ import * as IconSdkRaw from 'icon-sdk-js';
17
17
  import { ChainGrpcWasmApi, TxGrpcApi, toBase64, fromBase64, MsgExecuteContract, ChainRestAuthApi, BaseAccount, createTransaction } from '@injectivelabs/sdk-ts';
18
18
  import { TxRaw } from 'cosmjs-types/cosmos/tx/v1beta1/tx.js';
19
19
  import { getNetworkEndpoints, Network } from '@injectivelabs/networks';
20
- import * as v4 from 'valibot';
20
+ import * as v7 from 'valibot';
21
21
  import { SwapsApi, SwapsApiError } from '@sodax/swaps-api';
22
22
  export { SwapsApiError } from '@sodax/swaps-api';
23
23
  import BigNumber5, { BigNumber } from 'bignumber.js';
@@ -94,8 +94,8 @@ function serializeCause(cause, depth) {
94
94
  }
95
95
  function sanitizeContext(value, depth) {
96
96
  const out = {};
97
- for (const [key, v6] of Object.entries(value)) {
98
- out[key] = sanitizeValue(v6, depth + 1);
97
+ for (const [key, v9] of Object.entries(value)) {
98
+ out[key] = sanitizeValue(v9, depth + 1);
99
99
  }
100
100
  return out;
101
101
  }
@@ -106,13 +106,13 @@ function sanitizeValue(value, depth) {
106
106
  if (t === "bigint") return value.toString();
107
107
  if (t === "string" || t === "number" || t === "boolean") return value;
108
108
  if (t === "function" || t === "symbol") return safeString(value);
109
- if (Array.isArray(value)) return value.map((v6) => sanitizeValue(v6, depth + 1));
109
+ if (Array.isArray(value)) return value.map((v9) => sanitizeValue(v9, depth + 1));
110
110
  if (value instanceof Date) return value.toISOString();
111
111
  if (value instanceof Map) {
112
- return Array.from(value.entries()).map(([k, v6]) => [sanitizeValue(k, depth + 1), sanitizeValue(v6, depth + 1)]);
112
+ return Array.from(value.entries()).map(([k, v9]) => [sanitizeValue(k, depth + 1), sanitizeValue(v9, depth + 1)]);
113
113
  }
114
114
  if (value instanceof Set) {
115
- return Array.from(value.values()).map((v6) => sanitizeValue(v6, depth + 1));
115
+ return Array.from(value.values()).map((v9) => sanitizeValue(v9, depth + 1));
116
116
  }
117
117
  if (value instanceof Error) return { name: value.name, message: value.message };
118
118
  if (t === "object") {
@@ -124,9 +124,9 @@ function sanitizeValue(value, depth) {
124
124
  }
125
125
  return safeString(value);
126
126
  }
127
- function safeString(v6) {
127
+ function safeString(v9) {
128
128
  try {
129
- return String(v6);
129
+ return String(v9);
130
130
  } catch {
131
131
  return "[unserializable]";
132
132
  }
@@ -485,7 +485,7 @@ var SodaTokens = {
485
485
  name: "Soda RBNT",
486
486
  decimals: 18,
487
487
  address: "0x4B207114F9118dEAC56436e1aE3c45648783c7Ac",
488
- chainKey: ChainKeys.REDBELLY_MAINNET,
488
+ chainKey: ChainKeys.SONIC_MAINNET,
489
489
  hubAsset: "0x4B207114F9118dEAC56436e1aE3c45648783c7Ac",
490
490
  vault: "0x4B207114F9118dEAC56436e1aE3c45648783c7Ac"
491
491
  },
@@ -4244,6 +4244,11 @@ var SPONSORING_API_ERROR_CODES = [
4244
4244
  ];
4245
4245
 
4246
4246
  // ../types/dist/bitcoin/bitcoin.js
4247
+ var BITCOIN_DUST_SATS = 546n;
4248
+ function isNativeBitcoinToken(chainConfig, token) {
4249
+ const nativeBtcTokens = new Set(["btc", chainConfig.nativeToken, chainConfig.supportedTokens.BTC?.address].filter((value) => !!value).map((value) => value.toLowerCase()));
4250
+ return nativeBtcTokens.has(token.toLowerCase());
4251
+ }
4247
4252
  function isSupportedBitcoinAddressType(addressType) {
4248
4253
  return BTC_ADDRESS_TYPES.includes(addressType);
4249
4254
  }
@@ -4267,7 +4272,13 @@ var BTC_ADDRESS_TYPES = ["P2PKH", "P2SH", "P2WPKH", "P2TR"];
4267
4272
  // ../types/dist/hooks/hooks.js
4268
4273
  var HookKind = {
4269
4274
  /** Deposits delivered USDC into the recipient's HyperCore perps account (HyperEVM). */
4270
- HYPERCORE_DEPOSIT: "hyperCoreDeposit"
4275
+ HYPERCORE_DEPOSIT: "hyperCoreDeposit",
4276
+ /**
4277
+ * Requests an ERC-7540 deposit of delivered USDC into the Flint RWA vault (Ethereum), with the
4278
+ * recipient as the request's controller. Asynchronous: the request mints no shares — Flint's
4279
+ * curator settles a NAV and then claims the shares on the controller's behalf.
4280
+ */
4281
+ FLINT_DEPOSIT: "flintDeposit"
4271
4282
  };
4272
4283
  var spokeHooks = {
4273
4284
  [ChainKeys.HYPEREVM_MAINNET]: [
@@ -4278,6 +4289,20 @@ var spokeHooks = {
4278
4289
  // USDC on HyperEVM
4279
4290
  }
4280
4291
  ]
4292
+ // HookKind.FLINT_DEPOSIT is not registered yet: FlintDepositHook is not deployed to Ethereum
4293
+ // mainnet (icon-project/sodax-contracts#693). Registering it with a placeholder address would
4294
+ // route real intent output to that address, so the entry lands with the deployment:
4295
+ //
4296
+ // [ChainKeys.ETHEREUM_MAINNET]: [
4297
+ // {
4298
+ // kind: HookKind.FLINT_DEPOSIT,
4299
+ // address: '0x…',
4300
+ // supportedTokens: [spokeChainConfig[ChainKeys.ETHEREUM_MAINNET].supportedTokens.USDC.address],
4301
+ // },
4302
+ // ],
4303
+ //
4304
+ // Until then `getSpokeHook` returns undefined and `resolveDeliveryHook` throws, which is the
4305
+ // correct behaviour for a hook that does not exist on chain.
4281
4306
  };
4282
4307
  var getSpokeHook = (chainKey, kind) => spokeHooks[chainKey]?.find((h) => h.kind === kind);
4283
4308
  var getSpokeHooks = (chainKey) => spokeHooks[chainKey] ?? [];
@@ -4403,7 +4428,7 @@ function isValidWalletProviderForChainKey(chainKey, walletProvider) {
4403
4428
  }
4404
4429
 
4405
4430
  // ../types/dist/index.js
4406
- var CONFIG_VERSION = 221;
4431
+ var CONFIG_VERSION = 223;
4407
4432
  function isEvmSpokeChainConfig(value) {
4408
4433
  return typeof value === "object" && value !== null && value.chain.type === "EVM" && value.chain.key !== HUB_CHAIN_KEY;
4409
4434
  }
@@ -4514,6 +4539,9 @@ function isUndefinedOrValidWalletProviderForChainKey(chainKey, walletProvider) {
4514
4539
  function isOptionalBitcoinWalletProviderType(walletProvider) {
4515
4540
  return walletProvider === void 0 || isBitcoinWalletProviderType(walletProvider);
4516
4541
  }
4542
+ function isNativeBitcoinTransfer(config, chainKey, token) {
4543
+ return isBitcoinChainKeyType(chainKey) && !!token && isNativeBitcoinToken(config.getChainConfig(chainKey), token.address);
4544
+ }
4517
4545
  async function retry(action, retryCount = DEFAULT_MAX_RETRY, delayMs = DEFAULT_RETRY_DELAY_MS) {
4518
4546
  do {
4519
4547
  try {
@@ -4530,11 +4558,11 @@ async function retry(action, retryCount = DEFAULT_MAX_RETRY, delayMs = DEFAULT_R
4530
4558
  throw new Error(`Retry exceeded MAX_RETRY_DEFAULT=${DEFAULT_MAX_RETRY}`);
4531
4559
  }
4532
4560
  function getRandomBytes(length) {
4533
- const array2 = new Uint8Array(length);
4561
+ const array3 = new Uint8Array(length);
4534
4562
  for (let i = 0; i < length; i++) {
4535
- array2[i] = Math.floor(Math.random() * 256);
4563
+ array3[i] = Math.floor(Math.random() * 256);
4536
4564
  }
4537
- return array2;
4565
+ return array3;
4538
4566
  }
4539
4567
  function randomUint256() {
4540
4568
  const bytes = getRandomBytes(32);
@@ -4696,6 +4724,7 @@ var HttpRelayError = class extends Error {
4696
4724
  }
4697
4725
  };
4698
4726
  var RELAY_REQUEST_TIMEOUT_MS = 15e3;
4727
+ var RELAY_FALLBACK_FLOOR_MS = 5e3;
4699
4728
  function isAbortError(error) {
4700
4729
  return error instanceof Error && error.name === "AbortError";
4701
4730
  }
@@ -13994,6 +14023,13 @@ var ConfigService = class {
13994
14023
  * a client-side option set via `new Sodax({ fee })`. Per-feature overrides live on the feature config.
13995
14024
  */
13996
14025
  fee;
14026
+ /**
14027
+ * RadFi/Bound request signer. Resolved once at construction and kept independent of {@link sodax}
14028
+ * so that {@link initialize}'s dynamic-config swap never clobbers it. Read by `BitcoinSpokeService`
14029
+ * via `config.radfiSigner`; `undefined` unless the consumer passed `radfi.signRequest` to
14030
+ * `new Sodax(...)`. Holds the function reference only — never a credential.
14031
+ */
14032
+ radfiSigner;
13997
14033
  initialized = false;
13998
14034
  // data structures for quick lookup
13999
14035
  supportedHubAssetsSet;
@@ -14007,11 +14043,12 @@ var ConfigService = class {
14007
14043
  hubAssetToXTokenMap;
14008
14044
  // `api` / `userConfig` are accepted but unused while initialize()'s dynamic fetch is disabled
14009
14045
  // (see TODO(config-v2) below); restore their assignments when re-enabling.
14010
- constructor({ api, config, userConfig, logger, analytics, fee }) {
14046
+ constructor({ api, config, userConfig, logger, analytics, fee, radfiSigner }) {
14011
14047
  this.sodax = config;
14012
14048
  this.logger = logger ?? resolveLogger(void 0);
14013
14049
  this.analytics = analytics ?? noopAnalytics;
14014
14050
  this.fee = fee;
14051
+ this.radfiSigner = radfiSigner;
14015
14052
  this.loadSodaxConfigDataStructures(config);
14016
14053
  }
14017
14054
  async initialize() {
@@ -14310,7 +14347,7 @@ function mergeSodaxConfig(base2, override) {
14310
14347
  }
14311
14348
  function encodeContractCalls(calls) {
14312
14349
  return encodeAbiParameters(parseAbiParameters("(address,uint256,bytes)[]"), [
14313
- calls.map((v6) => [v6.address, v6.value, v6.data])
14350
+ calls.map((v9) => [v9.address, v9.value, v9.data])
14314
14351
  ]);
14315
14352
  }
14316
14353
  async function waitForTransactionReceipt(hash, provider) {
@@ -14586,7 +14623,7 @@ var EvmVaultTokenService = class {
14586
14623
  return amount * BigInt(10 ** (decimals - 18));
14587
14624
  }
14588
14625
  };
14589
- var Erc20Service = class {
14626
+ var Erc20Service = class _Erc20Service {
14590
14627
  constructor() {
14591
14628
  }
14592
14629
  static async getErc20Token(token, publicClient) {
@@ -14612,6 +14649,19 @@ var Erc20Service = class {
14612
14649
  });
14613
14650
  return { name, symbol, decimals, address: token };
14614
14651
  }
14652
+ /**
14653
+ * Read the current on-chain allowance of `spender` over `owner`'s balance.
14654
+ * @param params - Token, owner, spender, and publicClient for the chain.
14655
+ * @returns The raw allowance.
14656
+ */
14657
+ static async getAllowance(params) {
14658
+ return params.publicClient.readContract({
14659
+ address: params.token,
14660
+ abi: erc20Abi$1,
14661
+ functionName: "allowance",
14662
+ args: [params.owner, params.spender]
14663
+ });
14664
+ }
14615
14665
  /**
14616
14666
  * Check if spender has enough ERC20 allowance for given amount.
14617
14667
  * @param params - Token, amount, owner, spender, chainKey, and publicClient for the chain.
@@ -14625,12 +14675,7 @@ var Erc20Service = class {
14625
14675
  value: true
14626
14676
  };
14627
14677
  }
14628
- const allowedAmount = await params.publicClient.readContract({
14629
- address: params.token,
14630
- abi: erc20Abi$1,
14631
- functionName: "allowance",
14632
- args: [params.owner, params.spender]
14633
- });
14678
+ const allowedAmount = await _Erc20Service.getAllowance(params);
14634
14679
  return {
14635
14680
  ok: true,
14636
14681
  value: allowedAmount >= params.amount
@@ -14642,6 +14687,59 @@ var Erc20Service = class {
14642
14687
  };
14643
14688
  }
14644
14689
  }
14690
+ /**
14691
+ * Decide how many approve transactions this token needs for `amount`.
14692
+ *
14693
+ * Tokens of the 2017 TetherToken lineage reject an allowance change from one non-zero value to
14694
+ * another, so a wallet holding a stale allowance can never approve — every retry reverts the same
14695
+ * way. Such a token needs `approve(0)` first.
14696
+ *
14697
+ * Detection is behavioural: a simulated approve either reverts or it does not. That answers the
14698
+ * question that actually matters ("will this approve revert?") instead of "is this token USDT?",
14699
+ * so a token listed later, or upgraded later behind the same address, is covered without a code
14700
+ * change — and no token list is hardcoded.
14701
+ *
14702
+ * The probes only run once an allowance is already set. The common path (nothing approved yet)
14703
+ * costs a single read.
14704
+ */
14705
+ static async planApproval(params) {
14706
+ const single = (reason) => ({ approveAmount: params.amount, reason });
14707
+ if (params.token.toLowerCase() === params.nativeToken.toLowerCase()) {
14708
+ return single("native-token");
14709
+ }
14710
+ let allowance;
14711
+ try {
14712
+ allowance = await _Erc20Service.getAllowance(params);
14713
+ } catch {
14714
+ return single("allowance-read-failed");
14715
+ }
14716
+ if (allowance === 0n) {
14717
+ return single("zero-allowance");
14718
+ }
14719
+ if (await _Erc20Service.canApprove(params, params.amount)) {
14720
+ return single("probe-passed");
14721
+ }
14722
+ if (!await _Erc20Service.canApprove(params, 0n)) {
14723
+ return single("reset-not-viable");
14724
+ }
14725
+ return { resetAmount: 0n, approveAmount: params.amount, reason: "reset-required" };
14726
+ }
14727
+ /**
14728
+ * Simulate `approve(spender, amount)` as `owner`.
14729
+ *
14730
+ * `call` rather than `simulateContract`, because a TetherToken-lineage `approve` returns no value
14731
+ * and ABI decoding would fail even on a successful call. `account` is required: the guard reads
14732
+ * `allowed[msg.sender][spender]`.
14733
+ */
14734
+ static async canApprove(params, amount) {
14735
+ const { data } = _Erc20Service.encodeApprove(params.token, params.spender, amount);
14736
+ try {
14737
+ await params.publicClient.call({ account: params.owner, to: params.token, data });
14738
+ return true;
14739
+ } catch {
14740
+ return false;
14741
+ }
14742
+ }
14645
14743
  /**
14646
14744
  * Approve ERC20 amount spending
14647
14745
  * @param token - ERC20 token address
@@ -15222,10 +15320,14 @@ var RadfiApiError = class extends Error {
15222
15320
  };
15223
15321
  var RadfiProvider = class {
15224
15322
  config;
15323
+ // Client-side runtime signer (e.g. a backend's HMAC closure). Holds no credential itself — the SDK
15324
+ // only keeps the reference and invokes it per outbound `apiUrl` request. See `RadfiOptions` / gh-831.
15325
+ signer;
15225
15326
  accessToken = "";
15226
15327
  refreshToken = "";
15227
- constructor(config) {
15328
+ constructor(config, options) {
15228
15329
  this.config = config;
15330
+ this.signer = options?.signer;
15229
15331
  this.accessToken = config.accessToken ?? "";
15230
15332
  this.refreshToken = config.refreshToken ?? "";
15231
15333
  if (config.apiUrl.endsWith("/")) {
@@ -15336,6 +15438,9 @@ var RadfiProvider = class {
15336
15438
  }
15337
15439
  return body.data;
15338
15440
  }
15441
+ // UMS call: goes out unsigned even when a signer is configured. Bound scopes the backend
15442
+ // credential to the Sodax endpoints on `apiUrl`, so a signature here is unverified — this
15443
+ // deliberately does not go through `request()`. Same for `getExpiredUtxos` below. See gh-831.
15339
15444
  async getBalance(address) {
15340
15445
  if (!this.config.umsUrl) {
15341
15446
  throw new Error("RadfiConfig.umsUrl is required for getBalance");
@@ -15413,6 +15518,9 @@ var RadfiProvider = class {
15413
15518
  }
15414
15519
  /**
15415
15520
  * Fetch expired (or near-expiry) UTXOs for a trading wallet address from UMS API.
15521
+ *
15522
+ * UMS call — unsigned by design, like `getBalance`: the backend credential is scoped to the
15523
+ * Sodax endpoints on `apiUrl`, so a configured signer intentionally does not reach here.
15416
15524
  */
15417
15525
  async getExpiredUtxos(tradingAddress, params) {
15418
15526
  if (!this.config.umsUrl) {
@@ -15594,11 +15702,13 @@ var RadfiProvider = class {
15594
15702
  }
15595
15703
  }
15596
15704
  async request(endpoint, options) {
15705
+ const signed = this.signer ? await this.signer({ method: options?.method ?? "GET", path: endpoint }) : void 0;
15597
15706
  return fetch(`${this.config.apiUrl}${endpoint}`, {
15598
15707
  ...options,
15599
15708
  headers: {
15600
15709
  "Content-Type": "application/json",
15601
- ...options?.headers || {}
15710
+ ...options?.headers || {},
15711
+ ...signed
15602
15712
  }
15603
15713
  });
15604
15714
  }
@@ -15661,7 +15771,7 @@ function normalizeSignatureToBase64(signature) {
15661
15771
  // src/shared/services/spoke/BitcoinSpokeService.ts
15662
15772
  initEccLib(ecc);
15663
15773
  var BITCOIN_DEFAULT_FEE_RATE = 3;
15664
- var DUST_THRESHOLD = 546;
15774
+ var DUST_THRESHOLD = Number(BITCOIN_DUST_SATS);
15665
15775
  var BitcoinSpokeService = class {
15666
15776
  config;
15667
15777
  rpcUrl;
@@ -15673,7 +15783,7 @@ var BitcoinSpokeService = class {
15673
15783
  this.config = config;
15674
15784
  const chainConfig = config.getChainConfig(ChainKeys.BITCOIN_MAINNET);
15675
15785
  this.rpcUrl = chainConfig.rpcUrl;
15676
- this.radfi = new RadfiProvider(chainConfig.radfi);
15786
+ this.radfi = new RadfiProvider(chainConfig.radfi, { signer: config.radfiSigner });
15677
15787
  this.walletMode = chainConfig.radfi.walletMode ?? "TRADING";
15678
15788
  this.pollingIntervalMs = chainConfig.pollingConfig.pollingIntervalMs;
15679
15789
  this.maxTimeoutMs = chainConfig.pollingConfig.maxTimeoutMs;
@@ -16030,11 +16140,7 @@ var BitcoinSpokeService = class {
16030
16140
  async buildDepositPsbt(walletAddress, walletProvider, srcChainKey, token, amount, data, utxos) {
16031
16141
  const chainConfig = this.config.getChainConfig(srcChainKey);
16032
16142
  const assetManagerAddress = chainConfig.addresses.assetManager;
16033
- const normalizedToken = token.toLocaleLowerCase();
16034
- const nativeBtcTokens = new Set(
16035
- ["btc", chainConfig.nativeToken, chainConfig.supportedTokens.BTC?.address].filter((value) => !!value).map((value) => value.toLocaleLowerCase())
16036
- );
16037
- const isNativeBtc = nativeBtcTokens.has(normalizedToken);
16143
+ const isNativeBtc = isNativeBitcoinToken(chainConfig, token);
16038
16144
  if (isNativeBtc) {
16039
16145
  const OP_RETURN = opcodes.OP_RETURN;
16040
16146
  const OP_12 = opcodes.OP_12;
@@ -16293,7 +16399,7 @@ function hexToBytes2(hex) {
16293
16399
  const al = hl / 2;
16294
16400
  if (hl % 2)
16295
16401
  throw new Error("hex string expected, got unpadded hex of length " + hl);
16296
- const array2 = new Uint8Array(al);
16402
+ const array3 = new Uint8Array(al);
16297
16403
  for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) {
16298
16404
  const n1 = asciiToBase16(hex.charCodeAt(hi));
16299
16405
  const n2 = asciiToBase16(hex.charCodeAt(hi + 1));
@@ -16301,9 +16407,9 @@ function hexToBytes2(hex) {
16301
16407
  const char = hex[hi] + hex[hi + 1];
16302
16408
  throw new Error('hex string expected, got non-hex character "' + char + '" at index ' + hi);
16303
16409
  }
16304
- array2[ai] = n1 * 16 + n2;
16410
+ array3[ai] = n1 * 16 + n2;
16305
16411
  }
16306
- return array2;
16412
+ return array3;
16307
16413
  }
16308
16414
  function concatBytes(...arrays) {
16309
16415
  let sum = 0;
@@ -16933,22 +17039,22 @@ function createHmacDrbg(hashLen, qByteLen, hmacFn) {
16933
17039
  const byte0 = Uint8Array.of(0);
16934
17040
  const byte1 = Uint8Array.of(1);
16935
17041
  const _maxDrbgIters = 1e3;
16936
- let v6 = u8n(hashLen);
17042
+ let v9 = u8n(hashLen);
16937
17043
  let k = u8n(hashLen);
16938
17044
  let i = 0;
16939
17045
  const reset = () => {
16940
- v6.fill(1);
17046
+ v9.fill(1);
16941
17047
  k.fill(0);
16942
17048
  i = 0;
16943
17049
  };
16944
- const h = (...msgs) => hmacFn(k, concatBytes(v6, ...msgs));
17050
+ const h = (...msgs) => hmacFn(k, concatBytes(v9, ...msgs));
16945
17051
  const reseed = (seed = NULL) => {
16946
17052
  k = h(byte0, seed);
16947
- v6 = h();
17053
+ v9 = h();
16948
17054
  if (seed.length === 0)
16949
17055
  return;
16950
17056
  k = h(byte1, seed);
16951
- v6 = h();
17057
+ v9 = h();
16952
17058
  };
16953
17059
  const gen = () => {
16954
17060
  if (i++ >= _maxDrbgIters)
@@ -16956,10 +17062,10 @@ function createHmacDrbg(hashLen, qByteLen, hmacFn) {
16956
17062
  let len = 0;
16957
17063
  const out = [];
16958
17064
  while (len < qByteLen) {
16959
- v6 = h();
16960
- const sl = v6.slice();
17065
+ v9 = h();
17066
+ const sl = v9.slice();
16961
17067
  out.push(sl);
16962
- len += v6.length;
17068
+ len += v9.length;
16963
17069
  }
16964
17070
  return concatBytes(...out);
16965
17071
  };
@@ -16974,18 +17080,18 @@ function createHmacDrbg(hashLen, qByteLen, hmacFn) {
16974
17080
  };
16975
17081
  return genUntil;
16976
17082
  }
16977
- function validateObject(object3, fields = {}, optFields = {}) {
16978
- if (!object3 || typeof object3 !== "object")
17083
+ function validateObject(object5, fields = {}, optFields = {}) {
17084
+ if (!object5 || typeof object5 !== "object")
16979
17085
  throw new Error("expected valid options object");
16980
17086
  function checkField(fieldName, expectedType, isOpt) {
16981
- const val = object3[fieldName];
17087
+ const val = object5[fieldName];
16982
17088
  if (isOpt && val === void 0)
16983
17089
  return;
16984
17090
  const current = typeof val;
16985
17091
  if (current !== expectedType || val === null)
16986
17092
  throw new Error(`param "${fieldName}" is invalid: expected ${expectedType}, got ${current}`);
16987
17093
  }
16988
- const iter = (f, isOpt) => Object.entries(f).forEach(([k, v6]) => checkField(k, v6, isOpt));
17094
+ const iter = (f, isOpt) => Object.entries(f).forEach(([k, v9]) => checkField(k, v9, isOpt));
16989
17095
  iter(fields, false);
16990
17096
  iter(optFields, true);
16991
17097
  }
@@ -17024,12 +17130,12 @@ function pow2(x, power, modulo) {
17024
17130
  }
17025
17131
  return res;
17026
17132
  }
17027
- function invert(number3, modulo) {
17028
- if (number3 === _0n2)
17133
+ function invert(number5, modulo) {
17134
+ if (number5 === _0n2)
17029
17135
  throw new Error("invert: expected non-zero number");
17030
17136
  if (modulo <= _0n2)
17031
17137
  throw new Error("invert: expected positive modulus, got " + modulo);
17032
- let a = mod(number3, modulo);
17138
+ let a = mod(number5, modulo);
17033
17139
  let b = modulo;
17034
17140
  let x = _0n2, u = _1n2;
17035
17141
  while (a !== _0n2) {
@@ -17056,9 +17162,9 @@ function sqrt3mod4(Fp, n) {
17056
17162
  function sqrt5mod8(Fp, n) {
17057
17163
  const p5div8 = (Fp.ORDER - _5n) / _8n;
17058
17164
  const n2 = Fp.mul(n, _2n);
17059
- const v6 = Fp.pow(n2, p5div8);
17060
- const nv = Fp.mul(n, v6);
17061
- const i = Fp.mul(Fp.mul(nv, _2n), v6);
17165
+ const v9 = Fp.pow(n2, p5div8);
17166
+ const nv = Fp.mul(n, v9);
17167
+ const i = Fp.mul(Fp.mul(nv, _2n), v9);
17062
17168
  const root = Fp.mul(nv, Fp.sub(i, Fp.ONE));
17063
17169
  assertIsSquare(Fp, root, n);
17064
17170
  return root;
@@ -17533,27 +17639,27 @@ var wNAF = class {
17533
17639
  assert0(n);
17534
17640
  return acc;
17535
17641
  }
17536
- getPrecomputes(W, point, transform) {
17642
+ getPrecomputes(W, point, transform2) {
17537
17643
  let comp = pointPrecomputes.get(point);
17538
17644
  if (!comp) {
17539
17645
  comp = this.precomputeWindow(point, W);
17540
17646
  if (W !== 1) {
17541
- if (typeof transform === "function")
17542
- comp = transform(comp);
17647
+ if (typeof transform2 === "function")
17648
+ comp = transform2(comp);
17543
17649
  pointPrecomputes.set(point, comp);
17544
17650
  }
17545
17651
  }
17546
17652
  return comp;
17547
17653
  }
17548
- cached(point, scalar, transform) {
17654
+ cached(point, scalar, transform2) {
17549
17655
  const W = getW(point);
17550
- return this.wNAF(W, this.getPrecomputes(W, point, transform), scalar);
17656
+ return this.wNAF(W, this.getPrecomputes(W, point, transform2), scalar);
17551
17657
  }
17552
- unsafe(point, scalar, transform, prev) {
17658
+ unsafe(point, scalar, transform2, prev) {
17553
17659
  const W = getW(point);
17554
17660
  if (W === 1)
17555
17661
  return this._unsafeLadder(point, scalar, prev);
17556
- return this.wNAFUnsafe(W, this.getPrecomputes(W, point, transform), scalar, prev);
17662
+ return this.wNAFUnsafe(W, this.getPrecomputes(W, point, transform2), scalar, prev);
17557
17663
  }
17558
17664
  // We calculate precomputes for elliptic curve point multiplication
17559
17665
  // using windowed method. This specifies window size and
@@ -17640,9 +17746,9 @@ function edwards(params, extraOpts = {}) {
17640
17746
  validateObject(extraOpts, {}, { uvRatio: "function" });
17641
17747
  const MASK = _2n2 << BigInt(Fn.BYTES * 8) - _1n4;
17642
17748
  const modP = (n) => Fp.create(n);
17643
- const uvRatio2 = extraOpts.uvRatio || ((u, v6) => {
17749
+ const uvRatio2 = extraOpts.uvRatio || ((u, v9) => {
17644
17750
  try {
17645
- return { isValid: true, value: Fp.sqrt(Fp.div(u, v6)) };
17751
+ return { isValid: true, value: Fp.sqrt(Fp.div(u, v9)) };
17646
17752
  } catch (e) {
17647
17753
  return { isValid: false, value: _0n4 };
17648
17754
  }
@@ -17738,8 +17844,8 @@ function edwards(params, extraOpts = {}) {
17738
17844
  aInRange("point.y", y, _0n4, max);
17739
17845
  const y2 = modP(y * y);
17740
17846
  const u = modP(y2 - _1n4);
17741
- const v6 = modP(d * y2 - a);
17742
- let { isValid, value: x } = uvRatio2(u, v6);
17847
+ const v9 = modP(d * y2 - a);
17848
+ let { isValid, value: x } = uvRatio2(u, v9);
17743
17849
  if (!isValid)
17744
17850
  throw new Error("bad point: invalid y coordinate");
17745
17851
  const isXOdd = (x & _1n4) === _1n4;
@@ -18079,13 +18185,13 @@ function adjustScalarBytes(bytes) {
18079
18185
  return bytes;
18080
18186
  }
18081
18187
  var ED25519_SQRT_M1 = /* @__PURE__ */ BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");
18082
- function uvRatio(u, v6) {
18188
+ function uvRatio(u, v9) {
18083
18189
  const P = ed25519_CURVE_p;
18084
- const v32 = mod(v6 * v6 * v6, P);
18085
- const v7 = mod(v32 * v32 * v6, P);
18086
- const pow = ed25519_pow_2_252_3(u * v7).pow_p_5_8;
18190
+ const v32 = mod(v9 * v9 * v9, P);
18191
+ const v72 = mod(v32 * v32 * v9, P);
18192
+ const pow = ed25519_pow_2_252_3(u * v72).pow_p_5_8;
18087
18193
  let x = mod(u * v32 * pow, P);
18088
- const vx2 = mod(v6 * x * x, P);
18194
+ const vx2 = mod(v9 * x * x, P);
18089
18195
  const root1 = x;
18090
18196
  const root2 = mod(x * ED25519_SQRT_M1, P);
18091
18197
  const useRoot1 = vx2 === u;
@@ -18416,7 +18522,7 @@ function findSeatPrice(validators, maxNumberOfSeats, minimumStakeRatio, protocol
18416
18522
  return findSeatPriceForProtocolAfter49(validators, maxNumberOfSeats, minimumStakeRatio);
18417
18523
  }
18418
18524
  function findSeatPriceForProtocolBefore49(validators, numSeats) {
18419
- const stakes = validators.map((v6) => BigInt(v6.stake)).sort(sortBigIntAsc);
18525
+ const stakes = validators.map((v9) => BigInt(v9.stake)).sort(sortBigIntAsc);
18420
18526
  const num = BigInt(numSeats);
18421
18527
  const stakesSum = stakes.reduce((a, b) => a + b);
18422
18528
  if (stakesSum < num) {
@@ -18445,7 +18551,7 @@ function findSeatPriceForProtocolAfter49(validators, maxNumberOfSeats, minimumSt
18445
18551
  if (minimumStakeRatio.length != 2) {
18446
18552
  throw Error("minimumStakeRatio should have 2 elements");
18447
18553
  }
18448
- const stakes = validators.map((v6) => BigInt(v6.stake)).sort(sortBigIntAsc);
18554
+ const stakes = validators.map((v9) => BigInt(v9.stake)).sort(sortBigIntAsc);
18449
18555
  const stakesSum = stakes.reduce((a, b) => a + b);
18450
18556
  if (validators.length < maxNumberOfSeats) {
18451
18557
  return stakesSum * BigInt(minimumStakeRatio[0]) / BigInt(minimumStakeRatio[1]);
@@ -18617,10 +18723,10 @@ var DER = {
18617
18723
  if (length < 128)
18618
18724
  throw new E("tlv.decode(long): not minimal encoding");
18619
18725
  }
18620
- const v6 = data.subarray(pos, pos + length);
18621
- if (v6.length !== length)
18726
+ const v9 = data.subarray(pos, pos + length);
18727
+ if (v9.length !== length)
18622
18728
  throw new E("tlv.decode: wrong value length");
18623
- return { v: v6, l: data.subarray(pos + length) };
18729
+ return { v: v9, l: data.subarray(pos + length) };
18624
18730
  }
18625
18731
  },
18626
18732
  // https://crypto.stackexchange.com/a/57734 Leftmost bit of first byte is 'negative' flag,
@@ -19188,9 +19294,9 @@ function ecdsa(Point, hash, ecdsaOpts = {}) {
19188
19294
  extraEntropy: false
19189
19295
  };
19190
19296
  const hasLargeCofactor = CURVE_ORDER * _2n4 < Fp.ORDER;
19191
- function isBiggerThanHalfOrder(number3) {
19297
+ function isBiggerThanHalfOrder(number5) {
19192
19298
  const HALF = CURVE_ORDER >> _1n6;
19193
- return number3 > HALF;
19299
+ return number5 > HALF;
19194
19300
  }
19195
19301
  function validateRS(title, num) {
19196
19302
  if (!Fn.isValidNot0(num))
@@ -19373,8 +19479,8 @@ function ecdsa(Point, hash, ecdsaOpts = {}) {
19373
19479
  const R = Point.BASE.multiplyUnsafe(u1).add(P.multiplyUnsafe(u2));
19374
19480
  if (R.is0())
19375
19481
  return false;
19376
- const v6 = Fn.create(R.x);
19377
- return v6 === r;
19482
+ const v9 = Fn.create(R.x);
19483
+ return v9 === r;
19378
19484
  } catch (e) {
19379
19485
  return false;
19380
19486
  }
@@ -22390,7 +22496,17 @@ var IntentDataType = /* @__PURE__ */ ((IntentDataType2) => {
22390
22496
  })(IntentDataType || {});
22391
22497
  var HOOK_DELIVERY_ABI = {
22392
22498
  // HyperCoreDepositHook expects `abi.encode(address)` — the HyperCore account to credit.
22393
- [HookKind.HYPERCORE_DEPOSIT]: [{ name: "recipient", type: "address" }]
22499
+ [HookKind.HYPERCORE_DEPOSIT]: [{ name: "recipient", type: "address" }],
22500
+ // FlintDepositHook expects `abi.encode(address)` — the ERC-7540 controller the deposit request is
22501
+ // recorded against, i.e. the account that ends up owning the resulting flUSD shares. Same shape as
22502
+ // HyperCore's today; kept as its own entry so the two can diverge without touching each other.
22503
+ [HookKind.FLINT_DEPOSIT]: [{ name: "recipient", type: "address" }]
22504
+ };
22505
+ var ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
22506
+ var assertUnsupportedHook = (request) => {
22507
+ throw new Error(
22508
+ `[HookService.encodeDeliveryData] Unsupported delivery hook kind: ${request.kind}`
22509
+ );
22394
22510
  };
22395
22511
  var HookService = class _HookService {
22396
22512
  constructor() {
@@ -22399,17 +22515,28 @@ var HookService = class _HookService {
22399
22515
  * Encodes a hook's `deliveryData` payload. One common entry point for all hooks — the encoding is
22400
22516
  * selected by {@link HookRequest.kind} and uses that hook's schema from {@link HOOK_DELIVERY_ABI}.
22401
22517
  *
22518
+ * Rejects the zero address. Every hook treats its recipient as the account to credit, and a
22519
+ * zero recipient is unrecoverable on arrival: the receiver reverts, which rolls back the whole
22520
+ * cross-chain withdrawal inside `SpokeAssetManager.recvMessage` and leaves the message wedged —
22521
+ * every retry hits the same revert. Failing here keeps that mistake client-side, before an intent
22522
+ * exists. Malformed and non-EVM addresses already throw inside viem's encoder.
22523
+ *
22402
22524
  * @param request - The hook selection (and any hook-specific params).
22403
22525
  * @param recipient - The end recipient the hook should credit (the intent's `dstAddress`).
22404
22526
  */
22405
22527
  static encodeDeliveryData(request, recipient) {
22528
+ invariant(
22529
+ recipient.toLowerCase() !== ZERO_ADDRESS,
22530
+ "[HookService.encodeDeliveryData] recipient (dstAddress) must not be the zero address"
22531
+ );
22406
22532
  switch (request.kind) {
22407
22533
  case HookKind.HYPERCORE_DEPOSIT:
22408
22534
  return encodeAbiParameters(HOOK_DELIVERY_ABI[HookKind.HYPERCORE_DEPOSIT], [recipient]);
22535
+ case HookKind.FLINT_DEPOSIT:
22536
+ return encodeAbiParameters(HOOK_DELIVERY_ABI[HookKind.FLINT_DEPOSIT], [recipient]);
22537
+ default:
22538
+ return assertUnsupportedHook(request);
22409
22539
  }
22410
- throw new Error(
22411
- `[HookService.encodeDeliveryData] Unsupported delivery hook kind: ${request.kind}`
22412
- );
22413
22540
  }
22414
22541
  /**
22415
22542
  * Resolves a high-level {@link HookRequest} to the on-chain delivery pair: the deployed hook address
@@ -24777,6 +24904,12 @@ var SpokeService = class _SpokeService {
24777
24904
  /**
24778
24905
  * Approve ERC-20 spending on hub / EVM spoke or request a Stellar trustline using unified params.
24779
24906
  * Feature services map their action payloads into {@link SpokeApproveParams}.
24907
+ *
24908
+ * A signed ERC-20 approval can take **two** transactions: a token of the TetherToken lineage
24909
+ * rejects an allowance change from one non-zero value to another, so a stale allowance is zeroed
24910
+ * first and the user signs twice. The returned hash is always the last transaction's, so the
24911
+ * contract callers see is unchanged. An unsigned caller still gets exactly one transaction — use
24912
+ * {@link SpokeService.buildApproveTxs} to get the whole plan.
24780
24913
  */
24781
24914
  async approve(params) {
24782
24915
  try {
@@ -24784,53 +24917,168 @@ var SpokeService = class _SpokeService {
24784
24917
  isUndefinedOrValidWalletProviderForChainKey(params.srcChainKey, params.walletProvider),
24785
24918
  `Invalid wallet provider for chain key: ${params.srcChainKey}, walletProvider.chainType: ${params.walletProvider?.chainType}`
24786
24919
  );
24787
- if (isSpokeApproveParamsHub(params)) {
24788
- const result = await Erc20Service.approve({
24789
- ...params,
24790
- token: params.token,
24791
- amount: params.amount,
24792
- from: params.owner,
24793
- spender: params.spender
24794
- });
24920
+ if (isSpokeApproveParamsHub(params) || isSpokeApproveParamsEvmSpoke(params)) {
24921
+ if (params.raw) {
24922
+ const tx = await Erc20Service.approve({
24923
+ ...params,
24924
+ token: params.token,
24925
+ amount: params.amount,
24926
+ from: params.owner,
24927
+ spender: params.spender
24928
+ });
24929
+ return { ok: true, value: tx };
24930
+ }
24931
+ const result = await this.executeErc20ApprovalPlan(params);
24932
+ if (!result.ok) {
24933
+ return result;
24934
+ }
24795
24935
  return {
24796
24936
  ok: true,
24797
- value: result
24937
+ value: result.value
24798
24938
  };
24799
24939
  }
24800
- if (isSpokeApproveParamsEvmSpoke(params)) {
24801
- const result = await Erc20Service.approve({
24802
- ...params,
24803
- token: params.token,
24804
- amount: params.amount,
24805
- from: params.owner,
24806
- spender: params.spender
24807
- });
24940
+ if (isSpokeApproveParamsStellar(params)) {
24941
+ const result = await this.requestTrustlineForApproval(params);
24808
24942
  return {
24809
24943
  ok: true,
24810
24944
  value: result
24811
24945
  };
24812
24946
  }
24813
- if (isSpokeApproveParamsStellar(params)) {
24814
- const result = await this.stellar.requestTrustline({
24815
- ...params,
24816
- srcAddress: params.owner,
24817
- srcChainKey: params.srcChainKey,
24947
+ return {
24948
+ ok: false,
24949
+ error: new Error("[SpokeService.approve] Only hub (Sonic), EVM spokes, and Stellar are supported")
24950
+ };
24951
+ } catch (error) {
24952
+ return { ok: false, error };
24953
+ }
24954
+ }
24955
+ /**
24956
+ * The unsigned approval transactions, named rather than ordered (see {@link ApprovalTxs}).
24957
+ *
24958
+ * `resetTx` is present only when the token needs its stale allowance cleared first (see
24959
+ * {@link Erc20Service.planApproval}); broadcast it and wait for it to be mined before `approveTx`,
24960
+ * which is not valid until the reset has landed. Unsigned callers — the swaps API and the apps
24961
+ * built on it — need this, because {@link SpokeService.approve} can only hand back a single `tx`.
24962
+ *
24963
+ * Deliberately separate from {@link SpokeService.approve} rather than a mode of it: the two return
24964
+ * genuinely different shapes, and folding them together would put a union in the return type of
24965
+ * the method every feature approves through.
24966
+ */
24967
+ async buildApproveTxs(params) {
24968
+ try {
24969
+ if (isSpokeApproveParamsHub(params) || isSpokeApproveParamsEvmSpoke(params)) {
24970
+ const plan = await this.planErc20Approval(params, "buildApproveTxs");
24971
+ const encode3 = (amount) => Erc20Service.approve({
24818
24972
  token: params.token,
24819
- amount: params.amount
24973
+ amount,
24974
+ from: params.owner,
24975
+ spender: params.spender,
24976
+ raw: true
24820
24977
  });
24978
+ const resetTx = plan.resetAmount === void 0 ? void 0 : await encode3(plan.resetAmount);
24979
+ const approveTx = await encode3(plan.approveAmount);
24980
+ return { ok: true, value: resetTx === void 0 ? { approveTx } : { resetTx, approveTx } };
24981
+ }
24982
+ if (isSpokeApproveParamsStellar(params)) {
24983
+ const tx = await this.requestTrustlineForApproval({ ...params, raw: true });
24821
24984
  return {
24822
24985
  ok: true,
24823
- value: result
24986
+ value: { approveTx: tx }
24824
24987
  };
24825
24988
  }
24826
24989
  return {
24827
24990
  ok: false,
24828
- error: new Error("[SpokeService.approve] Only hub (Sonic), EVM spokes, and Stellar are supported")
24991
+ error: new Error("[SpokeService.buildApproveTxs] Only hub (Sonic), EVM spokes, and Stellar are supported")
24829
24992
  };
24830
24993
  } catch (error) {
24831
24994
  return { ok: false, error };
24832
24995
  }
24833
24996
  }
24997
+ /**
24998
+ * Sign and broadcast the approval plan for an ERC-20 on the hub or an EVM spoke.
24999
+ *
25000
+ * A token of the TetherToken lineage rejects an allowance change from one non-zero value to
25001
+ * another, so a wallet holding a stale allowance needs `approve(0)` first. The transactions cannot
25002
+ * be batched: each one is only valid once its predecessor has been mined. The hash of the last is
25003
+ * returned, so the contract callers see is unchanged.
25004
+ */
25005
+ async executeErc20ApprovalPlan(params) {
25006
+ const { walletProvider } = params;
25007
+ invariant(
25008
+ walletProvider !== void 0 && isEvmWalletProviderType(walletProvider),
25009
+ "[SpokeService.approve] Expected an EVM wallet provider for a signed approval"
25010
+ );
25011
+ const plan = await this.planErc20Approval(params, "approve");
25012
+ const sendApprove = (amount) => Erc20Service.approve({
25013
+ token: params.token,
25014
+ amount,
25015
+ from: params.owner,
25016
+ spender: params.spender,
25017
+ raw: false,
25018
+ walletProvider
25019
+ });
25020
+ if (plan.resetAmount !== void 0) {
25021
+ const resetHash = await sendApprove(plan.resetAmount);
25022
+ const receipt = await this.waitForTxReceipt({ txHash: resetHash, chainKey: params.srcChainKey });
25023
+ if (!receipt.ok || receipt.value.status !== "success") {
25024
+ return {
25025
+ ok: false,
25026
+ error: new Error(
25027
+ `[SpokeService.approve] allowance reset transaction ${resetHash} did not confirm. Retry the approval \u2014 once the reset has landed it takes a single transaction.`
25028
+ )
25029
+ };
25030
+ }
25031
+ }
25032
+ const txHash = await sendApprove(plan.approveAmount);
25033
+ return { ok: true, value: txHash };
25034
+ }
25035
+ /**
25036
+ * Stellar approves by adding a trustline — always a single transaction, with no allowance to plan
25037
+ * around. Shared by both entry points so the param mapping and its cast live in one place.
25038
+ */
25039
+ requestTrustlineForApproval(params) {
25040
+ return this.stellar.requestTrustline({
25041
+ ...params,
25042
+ srcAddress: params.owner,
25043
+ srcChainKey: params.srcChainKey,
25044
+ token: params.token,
25045
+ amount: params.amount
25046
+ });
25047
+ }
25048
+ /** Resolve the chain-specific inputs {@link Erc20Service.planApproval} needs, and record the plan. */
25049
+ async planErc20Approval(params, caller) {
25050
+ const plan = await Erc20Service.planApproval({
25051
+ token: params.token,
25052
+ owner: params.owner,
25053
+ spender: params.spender,
25054
+ amount: params.amount,
25055
+ nativeToken: this.config.getChainConfig(params.srcChainKey).nativeToken,
25056
+ publicClient: this.getEvmPublicClient(params.srcChainKey)
25057
+ });
25058
+ this.logApprovalPlan(caller, params.srcChainKey, params.token, plan);
25059
+ return plan;
25060
+ }
25061
+ /** The read client for an EVM chain, whether it is the hub or a spoke. */
25062
+ getEvmPublicClient(chainKey) {
25063
+ return isHubChainKeyType(chainKey) ? this.sonic.publicClient : this.evm.getPublicClient(chainKey);
25064
+ }
25065
+ /**
25066
+ * Log a plan only when it says something: an extra transaction the user will have to sign, or a
25067
+ * probe that could not reach a verdict. The ordinary single approve is the vast majority of calls
25068
+ * and stays silent.
25069
+ */
25070
+ logApprovalPlan(caller, chainKey, token, plan) {
25071
+ const isNoteworthy = plan.resetAmount !== void 0 || plan.reason === "reset-not-viable" || plan.reason === "allowance-read-failed";
25072
+ if (!isNoteworthy) {
25073
+ return;
25074
+ }
25075
+ this.config.logger.debug(`[SpokeService.${caller}] approval plan`, {
25076
+ chainKey,
25077
+ token,
25078
+ needsReset: plan.resetAmount !== void 0,
25079
+ reason: plan.reason
25080
+ });
25081
+ }
24834
25082
  /**
24835
25083
  * Estimate the gas for a raw transaction.
24836
25084
  * @param {TxReturnType<T, true>} params - The parameters for the raw transaction.
@@ -26668,6 +26916,36 @@ var SolverApiService = class {
26668
26916
  }
26669
26917
  }
26670
26918
  };
26919
+
26920
+ // src/backendApi/pollBackendSubmitTx.ts
26921
+ async function pollBackendSubmitTx({
26922
+ deadline,
26923
+ terminalStatus,
26924
+ getStatus,
26925
+ onExecuted,
26926
+ intervalMs = 1e3,
26927
+ requestTimeoutMs
26928
+ }) {
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());
26934
+ if (statusResult.ok) {
26935
+ const { status, result, failureReason, abandonedAt } = statusResult.value.data;
26936
+ if (status === terminalStatus) {
26937
+ const value = onExecuted(result);
26938
+ if (value !== void 0) return { ok: true, value };
26939
+ }
26940
+ if (status === "failed" || abandonedAt) {
26941
+ const reason = failureReason ? `: ${failureReason}` : "";
26942
+ return { ok: false, cause: new Error(`backend submit-tx ${status}${reason}`) };
26943
+ }
26944
+ }
26945
+ await new Promise((resolve) => setTimeout(resolve, Math.min(intervalMs, pollDeadline - Date.now())));
26946
+ }
26947
+ return { ok: false, cause: new Error(`backend submit-tx polling timed out before reaching ${terminalStatus}`) };
26948
+ }
26671
26949
  function decodePacketIntentTarget(payload) {
26672
26950
  try {
26673
26951
  const hex = payload.startsWith("0x") ? payload.slice(2) : payload;
@@ -26990,7 +27268,7 @@ var SwapService = class {
26990
27268
  relayerApiEndpoint: this.relayerApiEndpoint,
26991
27269
  // Remaining shared budget: ≈ full `timeout` on the flag-off path (called immediately), or
26992
27270
  // the reserve `submitTx` left on the backend path. Floor keeps a stalled-backend fallback viable.
26993
- timeout: Math.max(deadline - Date.now(), 5e3)
27271
+ timeout: Math.max(deadline - Date.now(), RELAY_FALLBACK_FLOOR_MS)
26994
27272
  });
26995
27273
  if (!packet.ok) {
26996
27274
  return { ok: false, error: mapRelayFailure(packet.error, { feature: "swap", action: "swap", ...baseCtx }) };
@@ -27052,39 +27330,26 @@ var SwapService = class {
27052
27330
  relayData: relayData.payload
27053
27331
  });
27054
27332
  if (!submitted.ok) return submitTxFailed(submitted.error);
27055
- const reserveMs = Math.min(Math.ceil((deadline - Date.now()) / 3), 2e4);
27056
- const pollDeadline = deadline - reserveMs;
27057
- const pollIntervalMs = 1e3;
27058
- while (Date.now() < pollDeadline) {
27059
- const statusResult = await this.backendApi.swaps.getSubmitTxStatus({ txHash: spokeTxHash, srcChainKey });
27060
- if (statusResult.ok) {
27061
- const { status, result, failureReason, abandonedAt } = statusResult.value.data;
27062
- if (status === "solved" && result?.dstIntentTxHash && result.intent_hash) {
27063
- return {
27064
- ok: true,
27065
- value: {
27066
- // Backend serializes the hex intent_hash as a plain string; brand it at the boundary.
27067
- solverExecutionResponse: { answer: "OK", intent_hash: result.intent_hash },
27068
- intent,
27069
- intentDeliveryInfo: {
27070
- srcChainKey,
27071
- srcTxHash: spokeTxHash,
27072
- srcAddress: params.srcAddress,
27073
- dstChainKey: params.dstChainKey,
27074
- dstTxHash: result.dstIntentTxHash,
27075
- dstAddress: params.dstAddress
27076
- }
27077
- }
27078
- };
27079
- }
27080
- if (status === "failed" || abandonedAt) {
27081
- const reason = failureReason ? `: ${failureReason}` : "";
27082
- return submitTxFailed(new Error(`backend submit-tx ${status}${reason}`));
27333
+ const polled = await pollBackendSubmitTx({
27334
+ deadline,
27335
+ // Swaps terminal success is `solved` (solver filled) — not the bridge `executed`.
27336
+ terminalStatus: "solved",
27337
+ getStatus: () => this.backendApi.swaps.getSubmitTxStatus({ txHash: spokeTxHash, srcChainKey }),
27338
+ onExecuted: (result) => result?.dstIntentTxHash && result.intent_hash ? {
27339
+ // Backend serializes the hex intent_hash as a plain string; brand it at the boundary.
27340
+ solverExecutionResponse: { answer: "OK", intent_hash: result.intent_hash },
27341
+ intent,
27342
+ intentDeliveryInfo: {
27343
+ srcChainKey,
27344
+ srcTxHash: spokeTxHash,
27345
+ srcAddress: params.srcAddress,
27346
+ dstChainKey: params.dstChainKey,
27347
+ dstTxHash: result.dstIntentTxHash,
27348
+ dstAddress: params.dstAddress
27083
27349
  }
27084
- }
27085
- await new Promise((resolve) => setTimeout(resolve, pollIntervalMs));
27086
- }
27087
- return submitTxFailed(new Error("backend submit-tx polling timed out before reaching solved"));
27350
+ } : void 0
27351
+ });
27352
+ return polled.ok ? { ok: true, value: polled.value } : submitTxFailed(polled.cause);
27088
27353
  } catch (error) {
27089
27354
  return { ok: false, error: unknownFailed("swap", error, { ...baseCtx, action: "swap" }) };
27090
27355
  }
@@ -27146,9 +27411,13 @@ var SwapService = class {
27146
27411
  * - Stellar: approves the trustline (adds/increases it).
27147
27412
  * - Other chain types: returns an error — approval is not supported.
27148
27413
  *
27149
- * When `raw: true`, returns unsigned transaction data instead of broadcasting.
27414
+ * When `raw: true`, returns unsigned transaction data instead of broadcasting. That is always a
27415
+ * single transaction, which cannot express the two-step approval a TetherToken-lineage token
27416
+ * needs when a stale allowance already exists — use {@link SwapService.buildApproveTxs} for the
27417
+ * whole plan.
27150
27418
  * When `raw: false`, a matching wallet provider for `K` must be supplied and the transaction
27151
- * is signed and broadcast immediately.
27419
+ * is signed and broadcast immediately. Such an approval can take **two** transactions, so the
27420
+ * user may sign twice; the returned hash is the last one's.
27152
27421
  *
27153
27422
  * @param _params - Swap action params including the source chain key, input token, amount, and wallet provider.
27154
27423
  * @returns A `Result` wrapping the chain-specific transaction return type (`TxReturnType<K, Raw>`).
@@ -27218,6 +27487,62 @@ var SwapService = class {
27218
27487
  return { ok: false, error };
27219
27488
  }
27220
27489
  }
27490
+ /**
27491
+ * The unsigned approval transactions for the swap's source token, in the order they must be
27492
+ * broadcast.
27493
+ *
27494
+ * Two transactions when the source token needs its stale allowance cleared first, one otherwise.
27495
+ * {@link SwapService.approve} is unchanged and still returns a single transaction; this is the
27496
+ * entry point for unsigned callers that need to handle the two-step case. When `resetTx` is
27497
+ * present, broadcast it and wait for it to be mined first — `approveTx` is not valid until the
27498
+ * reset has landed.
27499
+ */
27500
+ async buildApproveTxs(_params) {
27501
+ const { params } = _params;
27502
+ const wrapApproveFailure = (cause) => approveFailed("swap", cause);
27503
+ try {
27504
+ if (isHubChainKeyType(params.srcChainKey) || isEvmSpokeOnlyChainKeyType(params.srcChainKey)) {
27505
+ const spender = isHubChainKeyType(params.srcChainKey) ? this.solver.intentsContract : this.config.getChainConfig(params.srcChainKey).addresses.assetManager;
27506
+ const result = await this.spoke.buildApproveTxs({
27507
+ srcChainKey: params.srcChainKey,
27508
+ owner: params.srcAddress,
27509
+ token: params.inputToken,
27510
+ amount: params.inputAmount,
27511
+ spender,
27512
+ raw: true
27513
+ });
27514
+ if (!result.ok) {
27515
+ return { ok: false, error: wrapApproveFailure(result.error) };
27516
+ }
27517
+ return {
27518
+ ok: true,
27519
+ value: result.value
27520
+ };
27521
+ }
27522
+ if (isStellarChainKeyType(params.srcChainKey)) {
27523
+ const result = await this.spoke.buildApproveTxs({
27524
+ srcChainKey: params.srcChainKey,
27525
+ token: params.inputToken,
27526
+ amount: params.inputAmount,
27527
+ owner: params.srcAddress,
27528
+ raw: true
27529
+ });
27530
+ if (!result.ok) {
27531
+ return { ok: false, error: wrapApproveFailure(result.error) };
27532
+ }
27533
+ return {
27534
+ ok: true,
27535
+ value: result.value
27536
+ };
27537
+ }
27538
+ return {
27539
+ ok: false,
27540
+ error: new Error("Approve only supported for hub (Sonic), EVM spokes, and Stellar")
27541
+ };
27542
+ } catch (error) {
27543
+ return { ok: false, error };
27544
+ }
27545
+ }
27221
27546
  /**
27222
27547
  * Creates a swap intent on the user's source spoke chain without submitting it to the solver.
27223
27548
  *
@@ -27276,10 +27601,19 @@ var SwapService = class {
27276
27601
  `Invalid spoke chain (params.dstChain): ${params.dstChainKey}`,
27277
27602
  { ...baseCtx, field: "dstChainKey" }
27278
27603
  );
27279
- if (isBitcoinChainKey(params.dstChainKey) && params.outputToken === "BTC") {
27604
+ const inputTokenInfo = this.config.getSpokeTokenFromOriginalAssetAddress(params.srcChainKey, params.inputToken);
27605
+ if (isNativeBitcoinTransfer(this.config, params.srcChainKey, inputTokenInfo)) {
27280
27606
  swapInvariant(
27281
- params.minOutputAmount >= 546n,
27282
- `Invalid minOutputAmount (params.minOutputAmount): ${params.minOutputAmount}`,
27607
+ params.inputAmount >= BITCOIN_DUST_SATS,
27608
+ `Invalid inputAmount (${params.inputAmount}): below the Bitcoin dust limit of ${BITCOIN_DUST_SATS} sats`,
27609
+ { ...baseCtx, field: "inputAmount" }
27610
+ );
27611
+ }
27612
+ const outputTokenInfo = this.config.getSpokeTokenFromOriginalAssetAddress(params.dstChainKey, params.outputToken);
27613
+ if (isNativeBitcoinTransfer(this.config, params.dstChainKey, outputTokenInfo)) {
27614
+ swapInvariant(
27615
+ params.minOutputAmount >= BITCOIN_DUST_SATS,
27616
+ `Invalid minOutputAmount (${params.minOutputAmount}): below the Bitcoin dust limit of ${BITCOIN_DUST_SATS} sats`,
27283
27617
  { ...baseCtx, field: "minOutputAmount" }
27284
27618
  );
27285
27619
  }
@@ -29848,6 +30182,7 @@ function trimTrailingSlashes(baseURL) {
29848
30182
  while (end > 0 && baseURL[end - 1] === "/") end -= 1;
29849
30183
  return baseURL.slice(0, end);
29850
30184
  }
30185
+ var toJsonBody = (value) => JSON.stringify(value, (_key, val) => typeof val === "bigint" ? val.toString() : val);
29851
30186
  async function makeRequest(params) {
29852
30187
  const { endpoint, config, overrideConfig = {}, logger, serviceLabel } = params;
29853
30188
  const baseURL = overrideConfig.baseURL || config.baseURL || "";
@@ -29954,7 +30289,7 @@ var SwapsApiService = class _SwapsApiService {
29954
30289
  if (error.code === "VALIDATION_ERROR" && error.context.issues !== void 0) {
29955
30290
  context.reason = "invalid_response_shape";
29956
30291
  const issues = error.context.issues;
29957
- context.issues = issues instanceof v4.ValiError ? v4.flatten(issues.issues) : issues;
30292
+ context.issues = issues instanceof v7.ValiError ? v7.flatten(issues.issues) : issues;
29958
30293
  }
29959
30294
  if (error.context.status !== void 0) context.status = error.context.status;
29960
30295
  }
@@ -30115,21 +30450,21 @@ var SwapsApiService = class _SwapsApiService {
30115
30450
  return this.config.baseURL;
30116
30451
  }
30117
30452
  };
30118
- var StellarSponsorConfigSchema = v4.object({
30119
- sponsorAccount: v4.string(),
30120
- networkPassphrase: v4.string(),
30121
- minTotalFeeStroops: v4.string(),
30122
- maxTotalFeeStroops: v4.string(),
30123
- operationCount: v4.number(),
30124
- minPerOperationFeeStroops: v4.string(),
30125
- maxPerOperationFeeStroops: v4.string(),
30126
- recommendedPerOperationFeeStroops: v4.string(),
30127
- maxTimeboundSeconds: v4.number(),
30128
- requiredStartingBalance: v4.string()
30453
+ var StellarSponsorConfigSchema = v7.object({
30454
+ sponsorAccount: v7.string(),
30455
+ networkPassphrase: v7.string(),
30456
+ minTotalFeeStroops: v7.string(),
30457
+ maxTotalFeeStroops: v7.string(),
30458
+ operationCount: v7.number(),
30459
+ minPerOperationFeeStroops: v7.string(),
30460
+ maxPerOperationFeeStroops: v7.string(),
30461
+ recommendedPerOperationFeeStroops: v7.string(),
30462
+ maxTimeboundSeconds: v7.number(),
30463
+ requiredStartingBalance: v7.string()
30129
30464
  });
30130
- var StellarSponsoredAccountResponseSchema = v4.variant("alreadyActive", [
30131
- v4.object({ hash: v4.string(), alreadyActive: v4.literal(false) }),
30132
- v4.object({ hash: v4.null(), alreadyActive: v4.literal(true) })
30465
+ var StellarSponsoredAccountResponseSchema = v7.variant("alreadyActive", [
30466
+ v7.object({ hash: v7.string(), alreadyActive: v7.literal(false) }),
30467
+ v7.object({ hash: v7.null(), alreadyActive: v7.literal(true) })
30133
30468
  ]);
30134
30469
 
30135
30470
  // src/backendApi/SponsoringApiService.ts
@@ -30157,7 +30492,7 @@ var SponsoringApiService = class {
30157
30492
  logger: this.logger,
30158
30493
  serviceLabel: "SponsoringApiService"
30159
30494
  });
30160
- const parsed = v4.safeParse(schema, raw);
30495
+ const parsed = v7.safeParse(schema, raw);
30161
30496
  if (!parsed.success) {
30162
30497
  return {
30163
30498
  ok: false,
@@ -30165,7 +30500,7 @@ var SponsoringApiService = class {
30165
30500
  api: "sponsoring",
30166
30501
  feature: "backend",
30167
30502
  endpoint,
30168
- issues: v4.flatten(parsed.issues)
30503
+ issues: v7.flatten(parsed.issues)
30169
30504
  })
30170
30505
  };
30171
30506
  }
@@ -30203,6 +30538,411 @@ var SponsoringApiService = class {
30203
30538
  return this.config.baseURL;
30204
30539
  }
30205
30540
  };
30541
+ var RelayExtraDataResponseSchema = v7.object({
30542
+ address: v7.string(),
30543
+ payload: v7.string()
30544
+ });
30545
+ var BridgeTokenSchema = v7.object({
30546
+ symbol: v7.string(),
30547
+ name: v7.string(),
30548
+ decimals: v7.number(),
30549
+ address: v7.string(),
30550
+ chainKey: v7.string(),
30551
+ hubAsset: v7.string(),
30552
+ vault: v7.string()
30553
+ });
30554
+ var BridgeTokensResponseSchema = v7.record(v7.string(), v7.array(BridgeTokenSchema));
30555
+ var BridgeTokensByChainResponseSchema = v7.array(BridgeTokenSchema);
30556
+ var BridgeAllowanceCheckResponseSchema = v7.object({
30557
+ valid: v7.boolean()
30558
+ });
30559
+ var makeBridgeApproveResponseSchema = (txSchema) => v7.object({ tx: txSchema });
30560
+ var makeCreateBridgeIntentResponseSchema = (txSchema) => v7.object({
30561
+ tx: txSchema,
30562
+ relayData: RelayExtraDataResponseSchema
30563
+ });
30564
+ var BridgeSubmitTxResponseSchema = v7.object({
30565
+ success: v7.boolean(),
30566
+ data: v7.object({
30567
+ status: v7.picklist(["inserted", "duplicate"]),
30568
+ message: v7.string()
30569
+ })
30570
+ });
30571
+ var BridgePacketDataSchema = v7.object({
30572
+ src_chain_id: v7.number(),
30573
+ src_tx_hash: v7.string(),
30574
+ src_address: v7.string(),
30575
+ status: v7.picklist(["pending", "validating", "executing", "executed"]),
30576
+ dst_chain_id: v7.number(),
30577
+ conn_sn: v7.number(),
30578
+ dst_address: v7.string(),
30579
+ dst_tx_hash: v7.string(),
30580
+ signatures: v7.array(v7.string()),
30581
+ payload: v7.string()
30582
+ });
30583
+ var BridgeSubmitTxStatusResultSchema = v7.object({
30584
+ dstIntentTxHash: v7.string(),
30585
+ packetData: v7.optional(BridgePacketDataSchema)
30586
+ });
30587
+ var BridgeSubmitTxStatusDataSchema = v7.object({
30588
+ txHash: v7.string(),
30589
+ srcChainKey: v7.string(),
30590
+ status: v7.string(),
30591
+ failedAtStep: v7.optional(v7.string()),
30592
+ failureReason: v7.optional(v7.string()),
30593
+ processingAttempts: v7.number(),
30594
+ abandonedAt: v7.optional(v7.string()),
30595
+ result: v7.optional(BridgeSubmitTxStatusResultSchema),
30596
+ userMessage: v7.optional(v7.string())
30597
+ });
30598
+ var BridgeSubmitTxStatusResponseSchema = v7.object({
30599
+ success: v7.boolean(),
30600
+ data: BridgeSubmitTxStatusDataSchema
30601
+ });
30602
+ var BridgeFeeResponseSchema = v7.object({ fee: v7.string() });
30603
+ var BridgeLimitSchema = v7.object({
30604
+ amount: v7.string(),
30605
+ decimals: v7.number(),
30606
+ type: v7.picklist(["DEPOSIT_LIMIT", "WITHDRAWAL_LIMIT"])
30607
+ });
30608
+ var BridgeableAmountResponseSchema = v7.object({ limit: BridgeLimitSchema });
30609
+ var BridgeableCheckResponseSchema = v7.object({ bridgeable: v7.boolean() });
30610
+ var AddressSchema = v7.custom((input) => typeof input === "string");
30611
+ var HexSchema = v7.custom((input) => typeof input === "string");
30612
+ var BigintFromString = v7.pipe(v7.string(), v7.toBigint());
30613
+ var BytesFromIndexRecord = v7.pipe(
30614
+ v7.record(v7.string(), v7.number()),
30615
+ v7.transform((indexed) => Uint8Array.from(Object.values(indexed)))
30616
+ );
30617
+ var EvmRawTxSchema = v7.object({
30618
+ from: AddressSchema,
30619
+ to: AddressSchema,
30620
+ value: BigintFromString,
30621
+ data: HexSchema
30622
+ });
30623
+ var SolanaRawTxSchema = v7.object({
30624
+ from: v7.string(),
30625
+ to: v7.string(),
30626
+ value: BigintFromString,
30627
+ data: v7.string()
30628
+ });
30629
+ var SuiRawTxSchema = v7.object({
30630
+ from: HexSchema,
30631
+ to: v7.string(),
30632
+ value: BigintFromString,
30633
+ data: v7.string()
30634
+ });
30635
+ var StellarRawTxSchema = v7.object({
30636
+ from: v7.string(),
30637
+ to: v7.string(),
30638
+ value: BigintFromString,
30639
+ data: v7.string()
30640
+ });
30641
+ var BitcoinRawTxSchema = v7.object({
30642
+ from: v7.string(),
30643
+ to: v7.string(),
30644
+ value: BigintFromString,
30645
+ data: v7.string()
30646
+ });
30647
+ var InjectiveRawTxSchema = v7.object({
30648
+ from: HexSchema,
30649
+ to: HexSchema,
30650
+ signedDoc: v7.object({
30651
+ bodyBytes: BytesFromIndexRecord,
30652
+ authInfoBytes: BytesFromIndexRecord,
30653
+ chainId: v7.string(),
30654
+ accountNumber: BigintFromString
30655
+ })
30656
+ });
30657
+ var NearRawTxSchema = v7.object({
30658
+ signerId: v7.string(),
30659
+ params: v7.object({
30660
+ contractId: v7.string(),
30661
+ method: v7.string(),
30662
+ args: v7.custom((input) => typeof input === "object" && input !== null),
30663
+ gas: v7.optional(BigintFromString),
30664
+ deposit: v7.optional(BigintFromString)
30665
+ })
30666
+ });
30667
+ var IconRawTxSchema = v7.record(
30668
+ v7.string(),
30669
+ v7.union([v7.string(), v7.custom((input) => typeof input === "object" && input !== null)])
30670
+ );
30671
+ var StacksRawTxSchema = v7.object({
30672
+ payload: v7.string(),
30673
+ estimatedLength: v7.optional(v7.number())
30674
+ });
30675
+ var AnyRawTxSchema = v7.custom((input) => typeof input === "object" && input !== null);
30676
+ function rawTxSchemaForChainKey(chainKey) {
30677
+ let chainType;
30678
+ try {
30679
+ chainType = getChainType(chainKey);
30680
+ } catch {
30681
+ chainType = void 0;
30682
+ }
30683
+ switch (chainType) {
30684
+ case "EVM":
30685
+ return EvmRawTxSchema;
30686
+ case "SOLANA":
30687
+ return SolanaRawTxSchema;
30688
+ case "SUI":
30689
+ return SuiRawTxSchema;
30690
+ case "STELLAR":
30691
+ return StellarRawTxSchema;
30692
+ case "INJECTIVE":
30693
+ return InjectiveRawTxSchema;
30694
+ case "ICON":
30695
+ return IconRawTxSchema;
30696
+ case "STACKS":
30697
+ return StacksRawTxSchema;
30698
+ case "NEAR":
30699
+ return NearRawTxSchema;
30700
+ case "BITCOIN":
30701
+ return BitcoinRawTxSchema;
30702
+ default:
30703
+ return AnyRawTxSchema;
30704
+ }
30705
+ }
30706
+
30707
+ // src/backendApi/BridgeApiService.ts
30708
+ function toCreateBridgeIntentParamsV2(params, extras) {
30709
+ return {
30710
+ srcChainKey: params.srcChainKey,
30711
+ dstChainKey: params.dstChainKey,
30712
+ inputToken: params.srcToken,
30713
+ outputToken: params.dstToken,
30714
+ inputAmount: params.amount.toString(),
30715
+ srcAddress: params.srcAddress,
30716
+ dstAddress: params.recipient,
30717
+ ...extras?.srcPublicKey !== void 0 ? { srcPublicKey: extras.srcPublicKey } : {},
30718
+ ...extras?.bound !== void 0 ? { bound: extras.bound } : {},
30719
+ ...extras?.partnerFee !== void 0 ? { partnerFee: extras.partnerFee } : {}
30720
+ };
30721
+ }
30722
+ var BridgeApiService = class {
30723
+ // Fully-resolved bridge-API config supplied by the caller (BackendApiService resolves the
30724
+ // `ApiConfig` union via `resolveBridgeApiConfig`); this service does not resolve the union.
30725
+ config;
30726
+ headers;
30727
+ logger;
30728
+ constructor(config, logger = consoleLogger) {
30729
+ this.config = config;
30730
+ this.headers = { ...config.headers };
30731
+ this.logger = logger;
30732
+ }
30733
+ /**
30734
+ * Issues a single HTTP request, validates the JSON body against `schema`, and
30735
+ * wraps the result in `Result<T>`. The service-level `baseURL`/`timeout`/
30736
+ * `headers` are merged with the optional per-call `overrideConfig` (which takes
30737
+ * precedence) inside {@link makeRequest}. Every public method delegates here.
30738
+ */
30739
+ async request(endpoint, config, schema, overrideConfig) {
30740
+ try {
30741
+ const raw = await makeRequest({
30742
+ endpoint,
30743
+ config: { baseURL: this.config.baseURL, timeout: this.config.timeout, headers: this.headers, ...config },
30744
+ overrideConfig,
30745
+ logger: this.logger,
30746
+ serviceLabel: "BridgeApiService"
30747
+ });
30748
+ const parsed = v7.safeParse(schema, raw);
30749
+ if (!parsed.success) {
30750
+ return {
30751
+ ok: false,
30752
+ error: new SodaxError("EXTERNAL_API_ERROR", `Invalid response shape from bridge API for ${endpoint}`, {
30753
+ feature: "backend",
30754
+ context: { api: "bridge", endpoint, reason: "invalid_response_shape", issues: v7.flatten(parsed.issues) }
30755
+ })
30756
+ };
30757
+ }
30758
+ return { ok: true, value: parsed.output };
30759
+ } catch (error) {
30760
+ return {
30761
+ ok: false,
30762
+ error: new SodaxError(
30763
+ "EXTERNAL_API_ERROR",
30764
+ error instanceof Error ? error.message : `Request to ${endpoint} failed`,
30765
+ {
30766
+ feature: "backend",
30767
+ cause: error,
30768
+ context: { api: "bridge", endpoint }
30769
+ }
30770
+ )
30771
+ };
30772
+ }
30773
+ }
30774
+ // ──────────────────────────────────────────────────────────────────────
30775
+ // Tokens
30776
+ // ──────────────────────────────────────────────────────────────────────
30777
+ /**
30778
+ * Fetch all supported bridge tokens grouped by SpokeChainKey.
30779
+ *
30780
+ * @returns `Result<GetBridgeTokensResponseV2>` — map of chain key → token list.
30781
+ */
30782
+ async getTokens(config) {
30783
+ return this.request("/bridge/tokens", { method: "GET" }, BridgeTokensResponseSchema, config);
30784
+ }
30785
+ /**
30786
+ * Fetch supported bridge tokens for a single SpokeChainKey.
30787
+ *
30788
+ * @param chainKey - SODAX SpokeChainKey (e.g. `0xa4b1.arbitrum`, `solana`).
30789
+ * @returns `Result<GetBridgeTokensByChainResponseV2>` — token list for the chain.
30790
+ */
30791
+ async getTokensByChain(chainKey, config) {
30792
+ return this.request(
30793
+ `/bridge/tokens/${chainKey}`,
30794
+ { method: "GET" },
30795
+ BridgeTokensByChainResponseSchema,
30796
+ config
30797
+ );
30798
+ }
30799
+ // ──────────────────────────────────────────────────────────────────────
30800
+ // Allowance · approve · create intent
30801
+ // ──────────────────────────────────────────────────────────────────────
30802
+ /**
30803
+ * Check whether the source token allowance is already sufficient for the bridge.
30804
+ *
30805
+ * @returns `Result<BridgeAllowanceCheckResponseV2>` — `{ valid }`.
30806
+ */
30807
+ async checkAllowance(body, config) {
30808
+ return this.request(
30809
+ "/bridge/allowance/check",
30810
+ { method: "POST", body: toJsonBody(body) },
30811
+ BridgeAllowanceCheckResponseSchema,
30812
+ config
30813
+ );
30814
+ }
30815
+ /**
30816
+ * Build an unsigned token-approval transaction for the source token.
30817
+ *
30818
+ * @returns `Result<BridgeApproveResponseV2>` — `{ tx }` (chain-specific unsigned tx).
30819
+ */
30820
+ async approve(body, config) {
30821
+ const txSchema = rawTxSchemaForChainKey(body.srcChainKey);
30822
+ return this.request(
30823
+ "/bridge/approve",
30824
+ { method: "POST", body: toJsonBody(body) },
30825
+ makeBridgeApproveResponseSchema(txSchema),
30826
+ config
30827
+ );
30828
+ }
30829
+ /**
30830
+ * Build an unsigned spoke-deposit (create-bridge-intent) transaction.
30831
+ *
30832
+ * @returns `Result<CreateBridgeIntentResponseV2>` — `{ tx, relayData }` (no intent struct).
30833
+ */
30834
+ async createBridgeIntent(body, config) {
30835
+ const txSchema = rawTxSchemaForChainKey(body.srcChainKey);
30836
+ return this.request(
30837
+ "/bridge/intents",
30838
+ { method: "POST", body: toJsonBody(body) },
30839
+ makeCreateBridgeIntentResponseSchema(txSchema),
30840
+ config
30841
+ );
30842
+ }
30843
+ // ──────────────────────────────────────────────────────────────────────
30844
+ // Submit-tx state machine
30845
+ // ──────────────────────────────────────────────────────────────────────
30846
+ /**
30847
+ * Submit a broadcast bridge (spoke-deposit) transaction to be processed (relayed).
30848
+ * Carries the FULL `relayData { address, payload }` envelope. Idempotent on `(txHash, srcChainKey)`.
30849
+ *
30850
+ * @returns `Result<BridgeSubmitTxResponseV2>` — `{ success, data: { status, message } }`.
30851
+ */
30852
+ async submitTx(body, config) {
30853
+ return this.request(
30854
+ "/bridge/submit-tx",
30855
+ { method: "POST", body: toJsonBody(body) },
30856
+ BridgeSubmitTxResponseSchema,
30857
+ config
30858
+ );
30859
+ }
30860
+ /**
30861
+ * Get the processing status of a submitted bridge transaction by `(txHash, srcChainKey)`.
30862
+ *
30863
+ * @returns `Result<BridgeSubmitTxStatusResponseV2>` — `{ success, data }` (processing state).
30864
+ */
30865
+ async getSubmitTxStatus(query, config) {
30866
+ const queryParams = new URLSearchParams({ txHash: query.txHash, srcChainKey: query.srcChainKey });
30867
+ return this.request(
30868
+ `/bridge/submit-tx/status?${queryParams.toString()}`,
30869
+ { method: "GET" },
30870
+ BridgeSubmitTxStatusResponseSchema,
30871
+ config
30872
+ );
30873
+ }
30874
+ // ──────────────────────────────────────────────────────────────────────
30875
+ // Fee · bridgeable quote (read-only; mirror the SDK-core client-side methods)
30876
+ // ──────────────────────────────────────────────────────────────────────
30877
+ /**
30878
+ * Bridge partner fee for an input amount (per-request `partnerFee` override, else the configured default).
30879
+ * NOTE: this is a pure client-side computation
30880
+ * in the SDK core (`sodax.bridge.getFee`) — prefer that (no round-trip); this HTTP variant exists for
30881
+ * parity with the backend `/bridge/fee` endpoint (for consumers using only `sodax.api.bridge`).
30882
+ *
30883
+ * @returns `Result<BridgeFeeResponseV2>` — `{ fee }` (decimal string).
30884
+ */
30885
+ async getFee(body, config) {
30886
+ return this.request(
30887
+ "/bridge/fee",
30888
+ { method: "POST", body: toJsonBody(body) },
30889
+ BridgeFeeResponseSchema,
30890
+ config
30891
+ );
30892
+ }
30893
+ /**
30894
+ * Deposit capacity / withdrawal liquidity for a (from, to) token pair. Computable client-side in the
30895
+ * SDK core (`sodax.bridge.getBridgeableAmount`); this HTTP variant mirrors `/bridge/bridgeable-amount`.
30896
+ *
30897
+ * @returns `Result<BridgeableAmountResponseV2>` — `{ limit }`.
30898
+ */
30899
+ async getBridgeableAmount(body, config) {
30900
+ return this.request(
30901
+ "/bridge/bridgeable-amount",
30902
+ { method: "POST", body: toJsonBody(body) },
30903
+ BridgeableAmountResponseSchema,
30904
+ config
30905
+ );
30906
+ }
30907
+ /**
30908
+ * Whether a (from, to) token pair is bridgeable. Computable client-side in the SDK core
30909
+ * (`sodax.bridge.isBridgeable`); this HTTP variant mirrors `/bridge/bridgeable/check`.
30910
+ *
30911
+ * @returns `Result<BridgeableCheckResponseV2>` — `{ bridgeable }`.
30912
+ */
30913
+ async isBridgeable(body, config) {
30914
+ return this.request(
30915
+ "/bridge/bridgeable/check",
30916
+ { method: "POST", body: toJsonBody(body) },
30917
+ BridgeableCheckResponseSchema,
30918
+ config
30919
+ );
30920
+ }
30921
+ // ──────────────────────────────────────────────────────────────────────
30922
+ // Utilities (parity with SwapsApiService)
30923
+ // ──────────────────────────────────────────────────────────────────────
30924
+ /**
30925
+ * Merge additional headers into the service's default header set. Existing
30926
+ * keys are overwritten; keys absent from `headers` are preserved.
30927
+ */
30928
+ setHeaders(headers) {
30929
+ Object.entries(headers).forEach(([key, value]) => {
30930
+ this.headers[key] = value;
30931
+ });
30932
+ }
30933
+ /** Return the base URL the service is currently pointing at. */
30934
+ getBaseURL() {
30935
+ return this.config.baseURL;
30936
+ }
30937
+ /**
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.
30941
+ */
30942
+ getTimeout() {
30943
+ return this.config.timeout;
30944
+ }
30945
+ };
30206
30946
 
30207
30947
  // src/backendApi/apiConfig.ts
30208
30948
  function flatLayer({ baseURL, timeout, headers }) {
@@ -30247,143 +30987,147 @@ function resolveSponsoringApiConfig(config) {
30247
30987
  ...slice?.apiKey === void 0 ? {} : { apiKey: slice.apiKey }
30248
30988
  };
30249
30989
  }
30250
- var ChainKeySchema = v4.custom((input) => typeof input === "string");
30251
- var SpokeChainKeySchema = v4.custom((input) => typeof input === "string");
30252
- var AddressSchema = v4.custom((input) => typeof input === "string");
30253
- var XTokenSchema = v4.object({
30254
- symbol: v4.string(),
30255
- name: v4.string(),
30256
- decimals: v4.number(),
30257
- address: v4.string(),
30990
+ function resolveBridgeApiConfig(config) {
30991
+ return resolveBaseApiConfig(config);
30992
+ }
30993
+ var ChainKeySchema = v7.custom((input) => typeof input === "string");
30994
+ var SpokeChainKeySchema = v7.custom((input) => typeof input === "string");
30995
+ var AddressSchema2 = v7.custom((input) => typeof input === "string");
30996
+ var XTokenSchema = v7.object({
30997
+ symbol: v7.string(),
30998
+ name: v7.string(),
30999
+ decimals: v7.number(),
31000
+ address: v7.string(),
30258
31001
  chainKey: ChainKeySchema,
30259
- hubAsset: AddressSchema,
30260
- vault: AddressSchema,
30261
- access: v4.optional(v4.picklist(["withdrawOnly", "depositOnly"]))
31002
+ hubAsset: AddressSchema2,
31003
+ vault: AddressSchema2,
31004
+ access: v7.optional(v7.picklist(["withdrawOnly", "depositOnly"]))
30262
31005
  });
30263
- var IntentStructSchema = v4.object({
30264
- intentId: v4.string(),
30265
- creator: v4.string(),
30266
- inputToken: v4.string(),
30267
- outputToken: v4.string(),
30268
- inputAmount: v4.string(),
30269
- minOutputAmount: v4.string(),
30270
- deadline: v4.string(),
30271
- allowPartialFill: v4.boolean(),
30272
- srcChain: v4.number(),
30273
- dstChain: v4.number(),
30274
- srcAddress: v4.string(),
30275
- dstAddress: v4.string(),
30276
- solver: v4.string(),
30277
- data: v4.string()
31006
+ var IntentStructSchema = v7.object({
31007
+ intentId: v7.string(),
31008
+ creator: v7.string(),
31009
+ inputToken: v7.string(),
31010
+ outputToken: v7.string(),
31011
+ inputAmount: v7.string(),
31012
+ minOutputAmount: v7.string(),
31013
+ deadline: v7.string(),
31014
+ allowPartialFill: v7.boolean(),
31015
+ srcChain: v7.number(),
31016
+ dstChain: v7.number(),
31017
+ srcAddress: v7.string(),
31018
+ dstAddress: v7.string(),
31019
+ solver: v7.string(),
31020
+ data: v7.string()
30278
31021
  });
30279
- var IntentResponseSchema = v4.object({
30280
- intentHash: v4.string(),
30281
- txHash: v4.string(),
30282
- logIndex: v4.number(),
30283
- chainId: v4.number(),
30284
- blockNumber: v4.number(),
30285
- open: v4.boolean(),
31022
+ var IntentResponseSchema = v7.object({
31023
+ intentHash: v7.string(),
31024
+ txHash: v7.string(),
31025
+ logIndex: v7.number(),
31026
+ chainId: v7.number(),
31027
+ blockNumber: v7.number(),
31028
+ open: v7.boolean(),
30286
31029
  intent: IntentStructSchema,
30287
- events: v4.array(v4.unknown())
31030
+ events: v7.array(v7.unknown())
30288
31031
  });
30289
- var UserIntentsResponseSchema = v4.object({
30290
- total: v4.number(),
30291
- offset: v4.number(),
30292
- limit: v4.number(),
30293
- items: v4.array(IntentResponseSchema)
31032
+ var UserIntentsResponseSchema = v7.object({
31033
+ total: v7.number(),
31034
+ offset: v7.number(),
31035
+ limit: v7.number(),
31036
+ items: v7.array(IntentResponseSchema)
30294
31037
  });
30295
- var OrderbookResponseSchema = v4.object({
30296
- total: v4.number(),
30297
- data: v4.array(
30298
- v4.object({
30299
- intentState: v4.object({
30300
- exists: v4.boolean(),
30301
- remainingInput: v4.string(),
30302
- receivedOutput: v4.string(),
30303
- pendingPayment: v4.boolean()
31038
+ var OrderbookResponseSchema = v7.object({
31039
+ total: v7.number(),
31040
+ data: v7.array(
31041
+ v7.object({
31042
+ intentState: v7.object({
31043
+ exists: v7.boolean(),
31044
+ remainingInput: v7.string(),
31045
+ receivedOutput: v7.string(),
31046
+ pendingPayment: v7.boolean()
30304
31047
  }),
30305
- intentData: v4.object({
30306
- intentId: v4.string(),
30307
- creator: v4.string(),
30308
- inputToken: v4.string(),
30309
- outputToken: v4.string(),
30310
- inputAmount: v4.string(),
30311
- minOutputAmount: v4.string(),
30312
- deadline: v4.string(),
30313
- allowPartialFill: v4.boolean(),
30314
- srcChain: v4.number(),
30315
- dstChain: v4.number(),
30316
- srcAddress: v4.string(),
30317
- dstAddress: v4.string(),
30318
- solver: v4.string(),
30319
- data: v4.string(),
30320
- intentHash: v4.string(),
30321
- txHash: v4.string(),
30322
- blockNumber: v4.number()
31048
+ intentData: v7.object({
31049
+ intentId: v7.string(),
31050
+ creator: v7.string(),
31051
+ inputToken: v7.string(),
31052
+ outputToken: v7.string(),
31053
+ inputAmount: v7.string(),
31054
+ minOutputAmount: v7.string(),
31055
+ deadline: v7.string(),
31056
+ allowPartialFill: v7.boolean(),
31057
+ srcChain: v7.number(),
31058
+ dstChain: v7.number(),
31059
+ srcAddress: v7.string(),
31060
+ dstAddress: v7.string(),
31061
+ solver: v7.string(),
31062
+ data: v7.string(),
31063
+ intentHash: v7.string(),
31064
+ txHash: v7.string(),
31065
+ blockNumber: v7.number()
30323
31066
  })
30324
31067
  })
30325
31068
  )
30326
31069
  });
30327
- var MoneyMarketPositionSchema = v4.object({
30328
- userAddress: v4.string(),
30329
- positions: v4.array(
30330
- v4.object({
30331
- reserveAddress: v4.string(),
30332
- aTokenAddress: v4.string(),
30333
- variableDebtTokenAddress: v4.string(),
30334
- aTokenBalance: v4.string(),
30335
- variableDebtTokenBalance: v4.string(),
30336
- blockNumber: v4.number()
31070
+ var MoneyMarketPositionSchema = v7.object({
31071
+ userAddress: v7.string(),
31072
+ positions: v7.array(
31073
+ v7.object({
31074
+ reserveAddress: v7.string(),
31075
+ aTokenAddress: v7.string(),
31076
+ variableDebtTokenAddress: v7.string(),
31077
+ aTokenBalance: v7.string(),
31078
+ variableDebtTokenBalance: v7.string(),
31079
+ blockNumber: v7.number()
30337
31080
  })
30338
31081
  )
30339
31082
  });
30340
- var MoneyMarketAssetSchema = v4.object({
30341
- reserveAddress: v4.string(),
30342
- aTokenAddress: v4.string(),
30343
- totalATokenBalance: v4.string(),
30344
- variableDebtTokenAddress: v4.string(),
30345
- totalVariableDebtTokenBalance: v4.string(),
30346
- liquidityRate: v4.string(),
30347
- symbol: v4.string(),
30348
- totalSuppliers: v4.number(),
30349
- totalBorrowers: v4.number(),
30350
- variableBorrowRate: v4.string(),
30351
- stableBorrowRate: v4.string(),
30352
- liquidityIndex: v4.string(),
30353
- variableBorrowIndex: v4.string(),
30354
- blockNumber: v4.number()
31083
+ var MoneyMarketAssetSchema = v7.object({
31084
+ reserveAddress: v7.string(),
31085
+ aTokenAddress: v7.string(),
31086
+ totalATokenBalance: v7.string(),
31087
+ variableDebtTokenAddress: v7.string(),
31088
+ totalVariableDebtTokenBalance: v7.string(),
31089
+ liquidityRate: v7.string(),
31090
+ symbol: v7.string(),
31091
+ totalSuppliers: v7.number(),
31092
+ totalBorrowers: v7.number(),
31093
+ variableBorrowRate: v7.string(),
31094
+ stableBorrowRate: v7.string(),
31095
+ liquidityIndex: v7.string(),
31096
+ variableBorrowIndex: v7.string(),
31097
+ blockNumber: v7.number()
30355
31098
  });
30356
- var MoneyMarketAssetsSchema = v4.array(MoneyMarketAssetSchema);
30357
- var MoneyMarketAssetBorrowersSchema = v4.object({
30358
- borrowers: v4.array(v4.string()),
30359
- total: v4.number(),
30360
- offset: v4.number(),
30361
- limit: v4.number()
31099
+ var MoneyMarketAssetsSchema = v7.array(MoneyMarketAssetSchema);
31100
+ var MoneyMarketAssetBorrowersSchema = v7.object({
31101
+ borrowers: v7.array(v7.string()),
31102
+ total: v7.number(),
31103
+ offset: v7.number(),
31104
+ limit: v7.number()
30362
31105
  });
30363
- var MoneyMarketAssetSuppliersSchema = v4.object({
30364
- suppliers: v4.array(v4.string()),
30365
- total: v4.number(),
30366
- offset: v4.number(),
30367
- limit: v4.number()
31106
+ var MoneyMarketAssetSuppliersSchema = v7.object({
31107
+ suppliers: v7.array(v7.string()),
31108
+ total: v7.number(),
31109
+ offset: v7.number(),
31110
+ limit: v7.number()
30368
31111
  });
30369
- var MoneyMarketBorrowersSchema = v4.object({
30370
- borrowers: v4.array(v4.string()),
30371
- total: v4.number(),
30372
- offset: v4.number(),
30373
- limit: v4.number()
31112
+ var MoneyMarketBorrowersSchema = v7.object({
31113
+ borrowers: v7.array(v7.string()),
31114
+ total: v7.number(),
31115
+ offset: v7.number(),
31116
+ limit: v7.number()
30374
31117
  });
30375
- var GetChainsResponseSchema = v4.array(SpokeChainKeySchema);
30376
- var TokensByChainMapSchema = v4.custom(
30377
- (input) => typeof input === "object" && input !== null && Object.values(input).every((tokens) => Array.isArray(tokens) && tokens.every((t) => v4.is(XTokenSchema, t)))
31118
+ var GetChainsResponseSchema = v7.array(SpokeChainKeySchema);
31119
+ var TokensByChainMapSchema = v7.custom(
31120
+ (input) => typeof input === "object" && input !== null && Object.values(input).every((tokens) => Array.isArray(tokens) && tokens.every((t) => v7.is(XTokenSchema, t)))
30378
31121
  );
30379
- var TokensListSchema = v4.array(XTokenSchema);
30380
- var ReserveAssetsSchema = v4.array(AddressSchema);
31122
+ var TokensListSchema = v7.array(XTokenSchema);
31123
+ var ReserveAssetsSchema = v7.array(AddressSchema2);
30381
31124
 
30382
31125
  // src/backendApi/BackendApiService.ts
30383
31126
  var BackendApiService = class {
30384
31127
  // sub-services exposing domain-specific APIs
30385
31128
  swaps;
30386
31129
  sponsoring;
31130
+ bridge;
30387
31131
  // resolved base-API config: the flat fields of the ApiConfig union with any `baseApiConfig` layered on top
30388
31132
  config;
30389
31133
  headers;
@@ -30394,6 +31138,7 @@ var BackendApiService = class {
30394
31138
  this.logger = logger;
30395
31139
  this.swaps = new SwapsApiService(resolveSwapsApiConfig(config), this.logger);
30396
31140
  this.sponsoring = new SponsoringApiService(resolveSponsoringApiConfig(config), this.logger);
31141
+ this.bridge = new BridgeApiService(resolveBridgeApiConfig(config), this.logger);
30397
31142
  }
30398
31143
  /**
30399
31144
  * Issue a request and validate the JSON body against `schema`, wrapping the result in `Result<T>`.
@@ -30410,7 +31155,7 @@ var BackendApiService = class {
30410
31155
  logger: this.logger,
30411
31156
  serviceLabel: "BackendApiService"
30412
31157
  });
30413
- const parsed = v4.safeParse(schema, raw);
31158
+ const parsed = v7.safeParse(schema, raw);
30414
31159
  if (!parsed.success) {
30415
31160
  return {
30416
31161
  ok: false,
@@ -30418,7 +31163,7 @@ var BackendApiService = class {
30418
31163
  api: "backend",
30419
31164
  feature: "backend",
30420
31165
  endpoint,
30421
- issues: v4.flatten(parsed.issues)
31166
+ issues: v7.flatten(parsed.issues)
30422
31167
  })
30423
31168
  };
30424
31169
  }
@@ -30753,6 +31498,7 @@ var BackendApiService = class {
30753
31498
  this.headers[key] = value;
30754
31499
  });
30755
31500
  this.swaps.setHeaders(headers);
31501
+ this.bridge.setHeaders(headers);
30756
31502
  }
30757
31503
  /**
30758
31504
  * Return the base URL the service is currently pointing at.
@@ -30803,25 +31549,32 @@ var BridgeService = class {
30803
31549
  hubProvider;
30804
31550
  config;
30805
31551
  spoke;
30806
- constructor({ hubProvider, config, spoke }) {
31552
+ // backend bridge-API client + opt-in backend submit-tx flag
31553
+ backendApi;
31554
+ useBackendSubmitTx;
31555
+ constructor({ hubProvider, config, spoke, backendApi, useBackendSubmitTx }) {
30807
31556
  this.config = config;
30808
31557
  this.hubProvider = hubProvider;
30809
31558
  this.spoke = spoke;
31559
+ this.backendApi = backendApi;
31560
+ this.useBackendSubmitTx = useBackendSubmitTx ?? false;
30810
31561
  }
30811
31562
  /**
30812
31563
  * Calculates the partner fee deducted from a given bridge input amount.
30813
31564
  *
30814
- * Returns `0n` when no partner fee is configured. The fee is denominated in the
30815
- * same units as `inputAmount` (vault token decimals, 18 dp).
31565
+ * Returns `0n` when no partner fee is configured. `inputAmount` must be in 18-dp hub/vault
31566
+ * units — the units the hub deducts the fee in (see `buildBridgeData`) — NOT the spoke token's
31567
+ * native base units. This matters for a fixed `PartnerFee.amount`, which is wei-denominated
31568
+ * (18 dp); a percentage fee is unit-agnostic.
30816
31569
  *
30817
- * @param inputAmount - Gross amount being bridged, in vault token base units.
31570
+ * @param inputAmount - Gross amount being bridged, in 18-dp hub/vault units.
30818
31571
  * @returns Fee amount to be deducted, in the same units as `inputAmount`.
30819
31572
  */
30820
- getFee(inputAmount) {
30821
- if (!this.config.bridgePartnerFee) {
31573
+ getFee(inputAmount, partnerFee = this.config.bridgePartnerFee) {
31574
+ if (!partnerFee) {
30822
31575
  return 0n;
30823
31576
  }
30824
- return calculateFeeAmount(inputAmount, this.config.bridgePartnerFee);
31577
+ return calculateFeeAmount(inputAmount, partnerFee);
30825
31578
  }
30826
31579
  /**
30827
31580
  * Checks whether the caller has sufficient token allowance to execute the bridge.
@@ -31006,42 +31759,21 @@ var BridgeService = class {
31006
31759
  "bridge",
31007
31760
  "bridge",
31008
31761
  async () => {
31009
- const { params, timeout } = _params;
31762
+ const { params } = _params;
31010
31763
  const baseCtx = { srcChainKey: params.srcChainKey, dstChainKey: params.dstChainKey };
31011
31764
  try {
31012
- const txResult = await this.createBridgeIntent(_params);
31013
- if (!txResult.ok) return { ok: false, error: txResult.error };
31014
- const verifyTxHashResult = await this.spoke.verifyTxHash({
31015
- txHash: txResult.value.tx,
31016
- chainKey: params.srcChainKey
31017
- });
31018
- if (!verifyTxHashResult.ok) {
31019
- return {
31020
- ok: false,
31021
- error: verifyFailed("bridge", verifyTxHashResult.error, baseCtx)
31022
- };
31765
+ const created = await this.createBridgeIntent(_params);
31766
+ if (!created.ok) return { ok: false, error: created.error };
31767
+ const deadline = Date.now() + (_params.timeout ?? DEFAULT_RELAY_TX_TIMEOUT);
31768
+ if (this.useBackendSubmitTx) {
31769
+ const submitted = await this.submitTx(_params, created.value, deadline);
31770
+ if (submitted.ok) return submitted;
31771
+ this.config.logger.warn(
31772
+ "[bridge] backend submit-tx did not complete; falling back to the client-side relay",
31773
+ { error: submitted.error }
31774
+ );
31023
31775
  }
31024
- const packetResult = await relayTxAndWaitPacket({
31025
- srcTxHash: txResult.value.tx,
31026
- data: txResult.value.relayData,
31027
- chainKey: params.srcChainKey,
31028
- relayerApiEndpoint: this.config.relay.relayerApiEndpoint,
31029
- timeout
31030
- });
31031
- if (!packetResult.ok)
31032
- return {
31033
- ok: false,
31034
- error: mapRelayFailure(packetResult.error, {
31035
- feature: "bridge",
31036
- action: "bridge",
31037
- srcChainKey: baseCtx.srcChainKey,
31038
- dstChainKey: baseCtx.dstChainKey
31039
- })
31040
- };
31041
- return {
31042
- ok: true,
31043
- value: { srcChainTxHash: txResult.value.tx, dstChainTxHash: packetResult.value.dst_tx_hash }
31044
- };
31776
+ return this.fallbackBridgeSteps(_params, created.value, deadline);
31045
31777
  } catch (error) {
31046
31778
  if (isBridgeOrchestrationError(error)) return { ok: false, error };
31047
31779
  return {
@@ -31068,6 +31800,98 @@ var BridgeService = class {
31068
31800
  }
31069
31801
  );
31070
31802
  }
31803
+ /**
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.
31808
+ */
31809
+ async fallbackBridgeSteps(_params, created, deadline) {
31810
+ const { params } = _params;
31811
+ const baseCtx = { srcChainKey: params.srcChainKey, dstChainKey: params.dstChainKey };
31812
+ const verifyTxHashResult = await this.spoke.verifyTxHash({
31813
+ txHash: created.tx,
31814
+ chainKey: params.srcChainKey
31815
+ });
31816
+ if (!verifyTxHashResult.ok) {
31817
+ return { ok: false, error: verifyFailed("bridge", verifyTxHashResult.error, baseCtx) };
31818
+ }
31819
+ const packetResult = await relayTxAndWaitPacket({
31820
+ srcTxHash: created.tx,
31821
+ data: created.relayData,
31822
+ chainKey: params.srcChainKey,
31823
+ 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)
31831
+ });
31832
+ if (!packetResult.ok) {
31833
+ return {
31834
+ ok: false,
31835
+ error: mapRelayFailure(packetResult.error, {
31836
+ feature: "bridge",
31837
+ action: "bridge",
31838
+ srcChainKey: baseCtx.srcChainKey,
31839
+ dstChainKey: baseCtx.dstChainKey
31840
+ })
31841
+ };
31842
+ }
31843
+ return {
31844
+ ok: true,
31845
+ value: { srcChainTxHash: created.tx, dstChainTxHash: packetResult.value.dst_tx_hash }
31846
+ };
31847
+ }
31848
+ /**
31849
+ * Backend bridge path (opt-in via `bridgeOptions.useBackendSubmitTx`): hand the broadcast
31850
+ * spoke-deposit tx to the bridge API (`POST /bridge/submit-tx`) with the FULL `relayData`
31851
+ * envelope; the backend relays server-side. Polls `getSubmitTxStatus` until `executed`, then
31852
+ * returns the same {@link TxHashPair} the client-side path returns (`result.dstIntentTxHash` →
31853
+ * destination tx hash; bridge has no solver `intent_hash`).
31854
+ *
31855
+ * Never throws — returns `{ ok: false }` on any non-success (submit `!ok`, terminal `failed` /
31856
+ * abandoned, or poll timeout) so `bridge()` falls back to {@link fallbackBridgeSteps}. Falling back
31857
+ * 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.
31860
+ */
31861
+ async submitTx(_params, created, deadline) {
31862
+ const { params } = _params;
31863
+ const srcChainKey = params.srcChainKey;
31864
+ const baseCtx = { srcChainKey, dstChainKey: params.dstChainKey };
31865
+ const { tx: spokeTxHash, relayData } = created;
31866
+ const submitTxFailed = (cause) => ({
31867
+ ok: false,
31868
+ error: executionFailed("bridge", cause, { ...baseCtx, action: "bridge" })
31869
+ });
31870
+ 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,
31882
+ // Bridge terminal success is `executed` (hub-settled) — not the swaps `solved`.
31883
+ 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()
31889
+ });
31890
+ return polled.ok ? { ok: true, value: polled.value } : submitTxFailed(polled.cause);
31891
+ } catch (error) {
31892
+ return { ok: false, error: unknownFailed("bridge", error, { ...baseCtx, action: "bridge" }) };
31893
+ }
31894
+ }
31071
31895
  /**
31072
31896
  * Submits the spoke-side deposit transaction that initiates a bridge transfer,
31073
31897
  * without waiting for the cross-chain relay to complete.
@@ -31091,9 +31915,15 @@ var BridgeService = class {
31091
31915
  * contains the hub wallet address and encoded hub execution payload needed for relay.
31092
31916
  */
31093
31917
  async createBridgeIntent(_params) {
31094
- const { params, skipSimulation } = _params;
31918
+ const { params, skipSimulation, extras } = _params;
31919
+ const partnerFee = extras?.partnerFee ?? this.config.bridgePartnerFee;
31095
31920
  const baseCtx = { srcChainKey: params.srcChainKey, dstChainKey: params.dstChainKey };
31096
31921
  try {
31922
+ bridgeInvariant(
31923
+ isUndefinedOrValidWalletProviderForChainKey(params.srcChainKey, _params.walletProvider),
31924
+ `Invalid wallet provider for chain key: ${params.srcChainKey}`,
31925
+ baseCtx
31926
+ );
31097
31927
  bridgeInvariant(params.amount > 0n, "Amount must be greater than 0", { ...baseCtx, field: "amount" });
31098
31928
  const srcToken = this.resolveBridgeEndpointToken(params.srcChainKey, params.srcToken);
31099
31929
  const dstToken = this.resolveBridgeEndpointToken(params.dstChainKey, params.dstToken);
@@ -31105,25 +31935,62 @@ var BridgeService = class {
31105
31935
  ...baseCtx,
31106
31936
  field: "dstToken"
31107
31937
  });
31108
- const personalAddress = params.srcAddress;
31109
- let walletAddress = personalAddress;
31110
- if (isBitcoinChainKeyType(params.srcChainKey) && _params.raw === false) {
31938
+ bridgeInvariant(
31939
+ this.config.isValidSpokeChainKey(params.srcChainKey),
31940
+ `Invalid spoke chain (srcChainKey): ${params.srcChainKey}`,
31941
+ { ...baseCtx, field: "srcChainKey" }
31942
+ );
31943
+ bridgeInvariant(
31944
+ this.config.isValidSpokeChainKey(params.dstChainKey),
31945
+ `Invalid spoke chain (dstChainKey): ${params.dstChainKey}`,
31946
+ { ...baseCtx, field: "dstChainKey" }
31947
+ );
31948
+ if (isNativeBitcoinTransfer(this.config, params.srcChainKey, srcToken)) {
31111
31949
  bridgeInvariant(
31112
- isBitcoinWalletProviderType(_params.walletProvider),
31113
- `Invalid wallet provider for chain key: ${params.srcChainKey}. Expected bitcoin wallet provider.`,
31114
- { ...baseCtx, field: "walletProvider" }
31950
+ params.amount >= BITCOIN_DUST_SATS,
31951
+ `Invalid amount (${params.amount}): below the Bitcoin dust limit of ${BITCOIN_DUST_SATS} sats`,
31952
+ { ...baseCtx, field: "amount" }
31115
31953
  );
31116
- walletAddress = await this.spoke.bitcoin.getEffectiveWalletAddress(personalAddress);
31117
- if (this.spoke.bitcoin.walletMode === "TRADING") {
31118
- await this.spoke.bitcoin.radfi.ensureRadfiAccessToken(_params.walletProvider);
31954
+ }
31955
+ if (isNativeBitcoinTransfer(this.config, params.dstChainKey, dstToken)) {
31956
+ const { delivered } = this.computeBridgeAmounts(params.amount, srcToken, dstToken, partnerFee);
31957
+ bridgeInvariant(
31958
+ delivered >= BITCOIN_DUST_SATS,
31959
+ `Post-fee BTC delivery (${delivered}) is below the Bitcoin dust limit of ${BITCOIN_DUST_SATS} sats`,
31960
+ { ...baseCtx, field: "amount" }
31961
+ );
31962
+ }
31963
+ if (isStacksChainKeyType(params.srcChainKey) && _params.raw === true) {
31964
+ bridgeInvariant(
31965
+ extras?.srcPublicKey !== void 0,
31966
+ "srcPublicKey is required for Stacks createBridgeIntent (raw) \u2014 the source tx is built unsigned and needs the signer public key",
31967
+ { ...baseCtx, field: "srcPublicKey" }
31968
+ );
31969
+ }
31970
+ const personalAddress = params.srcAddress;
31971
+ let walletAddress = personalAddress;
31972
+ if (isBitcoinChainKeyType(params.srcChainKey)) {
31973
+ if (_params.raw === false) {
31974
+ bridgeInvariant(
31975
+ isBitcoinWalletProviderType(_params.walletProvider),
31976
+ `Invalid wallet provider for chain key: ${params.srcChainKey}. Expected bitcoin wallet provider.`,
31977
+ { ...baseCtx, field: "walletProvider" }
31978
+ );
31979
+ if (this.spoke.bitcoin.walletMode === "TRADING") {
31980
+ await this.spoke.bitcoin.radfi.ensureRadfiAccessToken(_params.walletProvider);
31981
+ }
31119
31982
  }
31983
+ walletAddress = await this.spoke.bitcoin.getEffectiveWalletAddress(personalAddress);
31120
31984
  }
31121
31985
  const hubWallet = await this.hubProvider.getUserHubWalletAddress(walletAddress, params.srcChainKey);
31122
31986
  const effectiveSkipSimulation = skipSimulation || isBitcoinChainKeyType(params.srcChainKey) && this.spoke.bitcoin.walletMode === "USER";
31123
- const data = this.buildBridgeData(params, srcToken, dstToken, this.config.bridgePartnerFee);
31987
+ const data = this.buildBridgeData(params, srcToken, dstToken, partnerFee);
31124
31988
  const coreParams = {
31125
31989
  srcChainKey: params.srcChainKey,
31126
31990
  srcAddress: walletAddress,
31991
+ srcPublicKey: extras?.srcPublicKey,
31992
+ // Bitcoin Bound token; BitcoinSpokeService.deposit falls back to the RadfiProvider instance token when undefined.
31993
+ accessToken: extras?.bound?.accessToken,
31127
31994
  to: hubWallet,
31128
31995
  token: params.srcToken,
31129
31996
  amount: params.amount,
@@ -31178,6 +32045,26 @@ var BridgeService = class {
31178
32045
  if (spokeToken) return spokeToken;
31179
32046
  return isHubChainKeyType(chainKey) ? this.config.getXTokenFromHubAsset(token) : void 0;
31180
32047
  }
32048
+ /**
32049
+ * Post-fee amounts for a bridge, in the units each hub step operates in. Single source for the fee +
32050
+ * vault-decimal pipeline, so {@link buildBridgeData}'s encoded hub calls and the BTC-destination dust
32051
+ * guard in {@link createBridgeIntent} can never disagree about what actually gets delivered.
32052
+ *
32053
+ * A spoke endpoint's amount is translated INTO 18-dp vault units on the way in (skipped when the
32054
+ * endpoint already IS the vault asset), the partner fee is deducted there — so a fixed
32055
+ * `PartnerFee.amount` is wei-denominated, never spoke-denominated — and the remainder is translated
32056
+ * back OUT into the destination endpoint's own units.
32057
+ *
32058
+ * @returns `feeAmount` and `withdrawAmount` in 18-dp vault units (what the hub fee transfer and vault
32059
+ * withdrawal use), and `delivered` in the destination endpoint's units (what the recipient receives).
32060
+ */
32061
+ computeBridgeAmounts(amount, srcToken, dstToken, partnerFee) {
32062
+ const translatedAmount = this.config.isSodaVaultHubAsset(srcToken.hubAsset) ? amount : EvmVaultTokenService.translateIncomingDecimals(srcToken.decimals, amount);
32063
+ const feeAmount = calculateFeeAmount(translatedAmount, partnerFee);
32064
+ const withdrawAmount = translatedAmount - feeAmount;
32065
+ const delivered = this.config.isSodaVaultHubAsset(dstToken.hubAsset) ? withdrawAmount : EvmVaultTokenService.translateOutgoingDecimals(dstToken.decimals, withdrawAmount);
32066
+ return { feeAmount, withdrawAmount, delivered };
32067
+ }
31181
32068
  /**
31182
32069
  * Encodes the hub-side execution payload for a bridge operation.
31183
32070
  *
@@ -31201,23 +32088,23 @@ var BridgeService = class {
31201
32088
  */
31202
32089
  buildBridgeData(params, srcToken, dstToken, partnerFee) {
31203
32090
  const calls = [];
31204
- let translatedAmount = params.amount;
31205
- let srcVault = params.srcToken;
32091
+ const { feeAmount, withdrawAmount, delivered } = this.computeBridgeAmounts(
32092
+ params.amount,
32093
+ srcToken,
32094
+ dstToken,
32095
+ partnerFee
32096
+ );
32097
+ let srcVault = srcToken.hubAsset;
31206
32098
  if (!this.config.isSodaVaultHubAsset(srcToken.hubAsset)) {
31207
32099
  calls.push(Erc20Service.encodeApprove(srcToken.hubAsset, srcToken.vault, params.amount));
31208
32100
  calls.push(EvmVaultTokenService.encodeDeposit(srcToken.vault, srcToken.hubAsset, params.amount));
31209
- translatedAmount = EvmVaultTokenService.translateIncomingDecimals(srcToken.decimals, params.amount);
31210
32101
  srcVault = srcToken.vault;
31211
32102
  }
31212
- const feeAmount = calculateFeeAmount(translatedAmount, partnerFee);
31213
32103
  if (partnerFee && feeAmount > 0n) {
31214
32104
  calls.push(Erc20Service.encodeTransfer(srcVault, partnerFee.address, feeAmount));
31215
32105
  }
31216
- const withdrawAmount = translatedAmount - feeAmount;
31217
- let translatedWithdrawAmount = withdrawAmount;
31218
32106
  if (!this.config.isSodaVaultHubAsset(dstToken.hubAsset)) {
31219
32107
  calls.push(EvmVaultTokenService.encodeWithdraw(dstToken.vault, dstToken.hubAsset, withdrawAmount));
31220
- translatedWithdrawAmount = EvmVaultTokenService.translateOutgoingDecimals(dstToken.decimals, withdrawAmount);
31221
32108
  }
31222
32109
  const encodedRecipientAddress = encodeAddress(params.dstChainKey, params.recipient);
31223
32110
  if (isHubChainKey(params.dstChainKey)) {
@@ -31228,11 +32115,11 @@ var BridgeService = class {
31228
32115
  data: encodeFunctionData({
31229
32116
  abi: wrappedSonicAbi,
31230
32117
  functionName: "withdrawTo",
31231
- args: [encodedRecipientAddress, translatedWithdrawAmount]
32118
+ args: [encodedRecipientAddress, delivered]
31232
32119
  })
31233
32120
  });
31234
32121
  } else {
31235
- calls.push(Erc20Service.encodeTransfer(dstToken.hubAsset, encodedRecipientAddress, translatedWithdrawAmount));
32122
+ calls.push(Erc20Service.encodeTransfer(dstToken.hubAsset, encodedRecipientAddress, delivered));
31236
32123
  }
31237
32124
  } else {
31238
32125
  bridgeInvariant(dstToken, `Unsupported hub chain (${params.dstChainKey}) token: ${params.dstToken}`, {
@@ -31243,7 +32130,7 @@ var BridgeService = class {
31243
32130
  EvmAssetManagerService.encodeTransfer(
31244
32131
  dstToken.hubAsset,
31245
32132
  encodedRecipientAddress,
31246
- translatedWithdrawAmount,
32133
+ delivered,
31247
32134
  this.hubProvider.chainConfig.addresses.assetManager
31248
32135
  )
31249
32136
  );
@@ -39462,7 +40349,7 @@ var LeverageYieldService = class {
39462
40349
  }
39463
40350
  /** Looks up a vault by its `name` field. Returns `undefined` when not registered. */
39464
40351
  getVault(name) {
39465
- return this.listVaults().find((v6) => v6.name === name);
40352
+ return this.listVaults().find((v9) => v9.name === name);
39466
40353
  }
39467
40354
  /**
39468
40355
  * Looks up a registered vault by its on-chain proxy address (case-insensitive).
@@ -39470,7 +40357,7 @@ var LeverageYieldService = class {
39470
40357
  */
39471
40358
  getVaultByAddress(address) {
39472
40359
  const normalized = address.toLowerCase();
39473
- return this.listVaults().find((v6) => v6.vault.toLowerCase() === normalized);
40360
+ return this.listVaults().find((v9) => v9.vault.toLowerCase() === normalized);
39474
40361
  }
39475
40362
  /**
39476
40363
  * Resolves the intent `deadline`: returns the caller-supplied value verbatim, otherwise
@@ -39971,15 +40858,22 @@ var LeverageYieldService = class {
39971
40858
  spender: params.vault
39972
40859
  };
39973
40860
  if (params.raw) {
39974
- const tx2 = await Erc20Service.approve({ ...baseApprove, raw: true });
39975
- return { ok: true, value: tx2 };
39976
- }
39977
- const tx = await Erc20Service.approve({
39978
- ...baseApprove,
40861
+ const tx = await Erc20Service.approve({ ...baseApprove, raw: true });
40862
+ return { ok: true, value: tx };
40863
+ }
40864
+ const result = await this.spoke.approve({
40865
+ srcChainKey: this.hubProvider.chainConfig.chain.key,
40866
+ token: baseApprove.token,
40867
+ amount: baseApprove.amount,
40868
+ owner: from,
40869
+ spender: baseApprove.spender,
39979
40870
  raw: false,
39980
40871
  walletProvider: params.walletProvider
39981
40872
  });
39982
- return { ok: true, value: tx };
40873
+ if (!result.ok) {
40874
+ return { ok: false, error: approveFailed("leverageYield", result.error, baseCtx) };
40875
+ }
40876
+ return { ok: true, value: result.value };
39983
40877
  } catch (error) {
39984
40878
  if (isLeverageYieldApproveError(error)) return { ok: false, error };
39985
40879
  return { ok: false, error: approveFailed("leverageYield", error, baseCtx) };
@@ -40277,12 +41171,12 @@ function toDomainCode(value) {
40277
41171
  }
40278
41172
  function readErrorBody(body) {
40279
41173
  if (typeof body !== "object" || body === null) return {};
40280
- const record = body;
40281
- const retryAfterSeconds = typeof record.retryAfterSeconds === "number" && Number.isFinite(record.retryAfterSeconds) && record.retryAfterSeconds > 0 ? record.retryAfterSeconds : void 0;
40282
- const sponsorSequence = typeof record.sponsorSequence === "string" && /^\d+$/.test(record.sponsorSequence) ? record.sponsorSequence : void 0;
41174
+ const record3 = body;
41175
+ const retryAfterSeconds = typeof record3.retryAfterSeconds === "number" && Number.isFinite(record3.retryAfterSeconds) && record3.retryAfterSeconds > 0 ? record3.retryAfterSeconds : void 0;
41176
+ const sponsorSequence = typeof record3.sponsorSequence === "string" && /^\d+$/.test(record3.sponsorSequence) ? record3.sponsorSequence : void 0;
40283
41177
  return {
40284
- message: typeof record.message === "string" ? record.message : void 0,
40285
- code: toDomainCode(record.error),
41178
+ message: typeof record3.message === "string" ? record3.message : void 0,
41179
+ code: toDomainCode(record3.error),
40286
41180
  retryAfterSeconds,
40287
41181
  sponsorSequence
40288
41182
  };
@@ -40848,7 +41742,9 @@ var Sodax = class {
40848
41742
  const logger = resolveLogger(options?.logger);
40849
41743
  const analytics = resolveAnalytics(options?.analytics);
40850
41744
  const fee = options?.fee;
41745
+ const radfiSigner = options?.radfi?.signRequest;
40851
41746
  const useBackendSubmitTx = options?.swapsOptions?.useBackendSubmitTx ?? false;
41747
+ const bridgeUseBackendSubmitTx = options?.bridgeOptions?.useBackendSubmitTx ?? false;
40852
41748
  this.instanceConfig = options ? mergeSodaxConfig(sodaxConfig, options) : sodaxConfig;
40853
41749
  this.backendApi = new BackendApiService(this.instanceConfig.api, logger);
40854
41750
  this.api = this.backendApi;
@@ -40858,7 +41754,8 @@ var Sodax = class {
40858
41754
  userConfig: options,
40859
41755
  logger,
40860
41756
  analytics,
40861
- fee
41757
+ fee,
41758
+ radfiSigner
40862
41759
  });
40863
41760
  this.hubProvider = new EvmHubProvider({ config: this.config });
40864
41761
  this.spoke = new SpokeService({ config: this.config, hubProvider: this.hubProvider });
@@ -40884,7 +41781,13 @@ var Sodax = class {
40884
41781
  config: this.config,
40885
41782
  spoke: this.spoke
40886
41783
  });
40887
- this.bridge = new BridgeService({ hubProvider: this.hubProvider, config: this.config, spoke: this.spoke });
41784
+ this.bridge = new BridgeService({
41785
+ hubProvider: this.hubProvider,
41786
+ config: this.config,
41787
+ spoke: this.spoke,
41788
+ backendApi: this.backendApi,
41789
+ useBackendSubmitTx: bridgeUseBackendSubmitTx
41790
+ });
40888
41791
  this.staking = new StakingService({ hubProvider: this.hubProvider, config: this.config, spoke: this.spoke });
40889
41792
  this.partners = new PartnerService({
40890
41793
  hubProvider: this.hubProvider,
@@ -40947,4 +41850,4 @@ var isPartnerError = isCodeMember(PARTNER_CODES);
40947
41850
  (*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
40948
41851
  */
40949
41852
 
40950
- export { ALLOWANCE_CHECK_CODES, APPROVE_CODES, AssetService, BITCOIN_CHAIN_KEYS, BITCOIN_CHAIN_KEYS_SET, BTC_WALLET_ADDRESS_TYPES, BackendApiService, BackendHttpError, BalnSwapService, BigIntToHex, BigNumberZeroDecimal, BitcoinSpokeService, BnUSDMigrationService, 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, 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, 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, tokenLogo, tokenLogoSlug, uiPoolDataAbi, universalRouterAbi, unknownFailed, usesBip322MessageSigning, valueToBigNumber, valueToZDBigNumber, variableDebtTokenAbi, vaultTokenAbi, verifyFailed, wadToRay, waitForStacksTransaction, waitForTransactionReceipt, waitUntilIntentExecuted, walletFactoryAbi, wrappedSonicAbi };
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 };