@sodax/sdk 2.1.0-rc.1 → 2.1.0-rc.2
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.cjs +927 -308
- package/dist/index.d.cts +273 -12
- package/dist/index.d.ts +273 -12
- package/dist/index.mjs +921 -308
- package/package.json +4 -4
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
|
|
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,
|
|
98
|
-
out[key] = sanitizeValue(
|
|
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((
|
|
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,
|
|
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((
|
|
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(
|
|
127
|
+
function safeString(v9) {
|
|
128
128
|
try {
|
|
129
|
-
return String(
|
|
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.
|
|
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
|
}
|
|
@@ -4403,7 +4408,7 @@ function isValidWalletProviderForChainKey(chainKey, walletProvider) {
|
|
|
4403
4408
|
}
|
|
4404
4409
|
|
|
4405
4410
|
// ../types/dist/index.js
|
|
4406
|
-
var CONFIG_VERSION =
|
|
4411
|
+
var CONFIG_VERSION = 222;
|
|
4407
4412
|
function isEvmSpokeChainConfig(value) {
|
|
4408
4413
|
return typeof value === "object" && value !== null && value.chain.type === "EVM" && value.chain.key !== HUB_CHAIN_KEY;
|
|
4409
4414
|
}
|
|
@@ -4514,6 +4519,9 @@ function isUndefinedOrValidWalletProviderForChainKey(chainKey, walletProvider) {
|
|
|
4514
4519
|
function isOptionalBitcoinWalletProviderType(walletProvider) {
|
|
4515
4520
|
return walletProvider === void 0 || isBitcoinWalletProviderType(walletProvider);
|
|
4516
4521
|
}
|
|
4522
|
+
function isNativeBitcoinTransfer(config, chainKey, token) {
|
|
4523
|
+
return isBitcoinChainKeyType(chainKey) && !!token && isNativeBitcoinToken(config.getChainConfig(chainKey), token.address);
|
|
4524
|
+
}
|
|
4517
4525
|
async function retry(action, retryCount = DEFAULT_MAX_RETRY, delayMs = DEFAULT_RETRY_DELAY_MS) {
|
|
4518
4526
|
do {
|
|
4519
4527
|
try {
|
|
@@ -4530,11 +4538,11 @@ async function retry(action, retryCount = DEFAULT_MAX_RETRY, delayMs = DEFAULT_R
|
|
|
4530
4538
|
throw new Error(`Retry exceeded MAX_RETRY_DEFAULT=${DEFAULT_MAX_RETRY}`);
|
|
4531
4539
|
}
|
|
4532
4540
|
function getRandomBytes(length) {
|
|
4533
|
-
const
|
|
4541
|
+
const array3 = new Uint8Array(length);
|
|
4534
4542
|
for (let i = 0; i < length; i++) {
|
|
4535
|
-
|
|
4543
|
+
array3[i] = Math.floor(Math.random() * 256);
|
|
4536
4544
|
}
|
|
4537
|
-
return
|
|
4545
|
+
return array3;
|
|
4538
4546
|
}
|
|
4539
4547
|
function randomUint256() {
|
|
4540
4548
|
const bytes = getRandomBytes(32);
|
|
@@ -4696,6 +4704,7 @@ var HttpRelayError = class extends Error {
|
|
|
4696
4704
|
}
|
|
4697
4705
|
};
|
|
4698
4706
|
var RELAY_REQUEST_TIMEOUT_MS = 15e3;
|
|
4707
|
+
var RELAY_FALLBACK_FLOOR_MS = 5e3;
|
|
4699
4708
|
function isAbortError(error) {
|
|
4700
4709
|
return error instanceof Error && error.name === "AbortError";
|
|
4701
4710
|
}
|
|
@@ -13994,6 +14003,13 @@ var ConfigService = class {
|
|
|
13994
14003
|
* a client-side option set via `new Sodax({ fee })`. Per-feature overrides live on the feature config.
|
|
13995
14004
|
*/
|
|
13996
14005
|
fee;
|
|
14006
|
+
/**
|
|
14007
|
+
* RadFi/Bound request signer. Resolved once at construction and kept independent of {@link sodax}
|
|
14008
|
+
* so that {@link initialize}'s dynamic-config swap never clobbers it. Read by `BitcoinSpokeService`
|
|
14009
|
+
* via `config.radfiSigner`; `undefined` unless the consumer passed `radfi.signRequest` to
|
|
14010
|
+
* `new Sodax(...)`. Holds the function reference only — never a credential.
|
|
14011
|
+
*/
|
|
14012
|
+
radfiSigner;
|
|
13997
14013
|
initialized = false;
|
|
13998
14014
|
// data structures for quick lookup
|
|
13999
14015
|
supportedHubAssetsSet;
|
|
@@ -14007,11 +14023,12 @@ var ConfigService = class {
|
|
|
14007
14023
|
hubAssetToXTokenMap;
|
|
14008
14024
|
// `api` / `userConfig` are accepted but unused while initialize()'s dynamic fetch is disabled
|
|
14009
14025
|
// (see TODO(config-v2) below); restore their assignments when re-enabling.
|
|
14010
|
-
constructor({ api, config, userConfig, logger, analytics, fee }) {
|
|
14026
|
+
constructor({ api, config, userConfig, logger, analytics, fee, radfiSigner }) {
|
|
14011
14027
|
this.sodax = config;
|
|
14012
14028
|
this.logger = logger ?? resolveLogger(void 0);
|
|
14013
14029
|
this.analytics = analytics ?? noopAnalytics;
|
|
14014
14030
|
this.fee = fee;
|
|
14031
|
+
this.radfiSigner = radfiSigner;
|
|
14015
14032
|
this.loadSodaxConfigDataStructures(config);
|
|
14016
14033
|
}
|
|
14017
14034
|
async initialize() {
|
|
@@ -14310,7 +14327,7 @@ function mergeSodaxConfig(base2, override) {
|
|
|
14310
14327
|
}
|
|
14311
14328
|
function encodeContractCalls(calls) {
|
|
14312
14329
|
return encodeAbiParameters(parseAbiParameters("(address,uint256,bytes)[]"), [
|
|
14313
|
-
calls.map((
|
|
14330
|
+
calls.map((v9) => [v9.address, v9.value, v9.data])
|
|
14314
14331
|
]);
|
|
14315
14332
|
}
|
|
14316
14333
|
async function waitForTransactionReceipt(hash, provider) {
|
|
@@ -15222,10 +15239,14 @@ var RadfiApiError = class extends Error {
|
|
|
15222
15239
|
};
|
|
15223
15240
|
var RadfiProvider = class {
|
|
15224
15241
|
config;
|
|
15242
|
+
// Client-side runtime signer (e.g. a backend's HMAC closure). Holds no credential itself — the SDK
|
|
15243
|
+
// only keeps the reference and invokes it per outbound `apiUrl` request. See `RadfiOptions` / gh-831.
|
|
15244
|
+
signer;
|
|
15225
15245
|
accessToken = "";
|
|
15226
15246
|
refreshToken = "";
|
|
15227
|
-
constructor(config) {
|
|
15247
|
+
constructor(config, options) {
|
|
15228
15248
|
this.config = config;
|
|
15249
|
+
this.signer = options?.signer;
|
|
15229
15250
|
this.accessToken = config.accessToken ?? "";
|
|
15230
15251
|
this.refreshToken = config.refreshToken ?? "";
|
|
15231
15252
|
if (config.apiUrl.endsWith("/")) {
|
|
@@ -15336,6 +15357,9 @@ var RadfiProvider = class {
|
|
|
15336
15357
|
}
|
|
15337
15358
|
return body.data;
|
|
15338
15359
|
}
|
|
15360
|
+
// UMS call: goes out unsigned even when a signer is configured. Bound scopes the backend
|
|
15361
|
+
// credential to the Sodax endpoints on `apiUrl`, so a signature here is unverified — this
|
|
15362
|
+
// deliberately does not go through `request()`. Same for `getExpiredUtxos` below. See gh-831.
|
|
15339
15363
|
async getBalance(address) {
|
|
15340
15364
|
if (!this.config.umsUrl) {
|
|
15341
15365
|
throw new Error("RadfiConfig.umsUrl is required for getBalance");
|
|
@@ -15413,6 +15437,9 @@ var RadfiProvider = class {
|
|
|
15413
15437
|
}
|
|
15414
15438
|
/**
|
|
15415
15439
|
* Fetch expired (or near-expiry) UTXOs for a trading wallet address from UMS API.
|
|
15440
|
+
*
|
|
15441
|
+
* UMS call — unsigned by design, like `getBalance`: the backend credential is scoped to the
|
|
15442
|
+
* Sodax endpoints on `apiUrl`, so a configured signer intentionally does not reach here.
|
|
15416
15443
|
*/
|
|
15417
15444
|
async getExpiredUtxos(tradingAddress, params) {
|
|
15418
15445
|
if (!this.config.umsUrl) {
|
|
@@ -15594,11 +15621,13 @@ var RadfiProvider = class {
|
|
|
15594
15621
|
}
|
|
15595
15622
|
}
|
|
15596
15623
|
async request(endpoint, options) {
|
|
15624
|
+
const signed = this.signer ? await this.signer({ method: options?.method ?? "GET", path: endpoint }) : void 0;
|
|
15597
15625
|
return fetch(`${this.config.apiUrl}${endpoint}`, {
|
|
15598
15626
|
...options,
|
|
15599
15627
|
headers: {
|
|
15600
15628
|
"Content-Type": "application/json",
|
|
15601
|
-
...options?.headers || {}
|
|
15629
|
+
...options?.headers || {},
|
|
15630
|
+
...signed
|
|
15602
15631
|
}
|
|
15603
15632
|
});
|
|
15604
15633
|
}
|
|
@@ -15661,7 +15690,7 @@ function normalizeSignatureToBase64(signature) {
|
|
|
15661
15690
|
// src/shared/services/spoke/BitcoinSpokeService.ts
|
|
15662
15691
|
initEccLib(ecc);
|
|
15663
15692
|
var BITCOIN_DEFAULT_FEE_RATE = 3;
|
|
15664
|
-
var DUST_THRESHOLD =
|
|
15693
|
+
var DUST_THRESHOLD = Number(BITCOIN_DUST_SATS);
|
|
15665
15694
|
var BitcoinSpokeService = class {
|
|
15666
15695
|
config;
|
|
15667
15696
|
rpcUrl;
|
|
@@ -15673,7 +15702,7 @@ var BitcoinSpokeService = class {
|
|
|
15673
15702
|
this.config = config;
|
|
15674
15703
|
const chainConfig = config.getChainConfig(ChainKeys.BITCOIN_MAINNET);
|
|
15675
15704
|
this.rpcUrl = chainConfig.rpcUrl;
|
|
15676
|
-
this.radfi = new RadfiProvider(chainConfig.radfi);
|
|
15705
|
+
this.radfi = new RadfiProvider(chainConfig.radfi, { signer: config.radfiSigner });
|
|
15677
15706
|
this.walletMode = chainConfig.radfi.walletMode ?? "TRADING";
|
|
15678
15707
|
this.pollingIntervalMs = chainConfig.pollingConfig.pollingIntervalMs;
|
|
15679
15708
|
this.maxTimeoutMs = chainConfig.pollingConfig.maxTimeoutMs;
|
|
@@ -16030,11 +16059,7 @@ var BitcoinSpokeService = class {
|
|
|
16030
16059
|
async buildDepositPsbt(walletAddress, walletProvider, srcChainKey, token, amount, data, utxos) {
|
|
16031
16060
|
const chainConfig = this.config.getChainConfig(srcChainKey);
|
|
16032
16061
|
const assetManagerAddress = chainConfig.addresses.assetManager;
|
|
16033
|
-
const
|
|
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);
|
|
16062
|
+
const isNativeBtc = isNativeBitcoinToken(chainConfig, token);
|
|
16038
16063
|
if (isNativeBtc) {
|
|
16039
16064
|
const OP_RETURN = opcodes.OP_RETURN;
|
|
16040
16065
|
const OP_12 = opcodes.OP_12;
|
|
@@ -16293,7 +16318,7 @@ function hexToBytes2(hex) {
|
|
|
16293
16318
|
const al = hl / 2;
|
|
16294
16319
|
if (hl % 2)
|
|
16295
16320
|
throw new Error("hex string expected, got unpadded hex of length " + hl);
|
|
16296
|
-
const
|
|
16321
|
+
const array3 = new Uint8Array(al);
|
|
16297
16322
|
for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) {
|
|
16298
16323
|
const n1 = asciiToBase16(hex.charCodeAt(hi));
|
|
16299
16324
|
const n2 = asciiToBase16(hex.charCodeAt(hi + 1));
|
|
@@ -16301,9 +16326,9 @@ function hexToBytes2(hex) {
|
|
|
16301
16326
|
const char = hex[hi] + hex[hi + 1];
|
|
16302
16327
|
throw new Error('hex string expected, got non-hex character "' + char + '" at index ' + hi);
|
|
16303
16328
|
}
|
|
16304
|
-
|
|
16329
|
+
array3[ai] = n1 * 16 + n2;
|
|
16305
16330
|
}
|
|
16306
|
-
return
|
|
16331
|
+
return array3;
|
|
16307
16332
|
}
|
|
16308
16333
|
function concatBytes(...arrays) {
|
|
16309
16334
|
let sum = 0;
|
|
@@ -16933,22 +16958,22 @@ function createHmacDrbg(hashLen, qByteLen, hmacFn) {
|
|
|
16933
16958
|
const byte0 = Uint8Array.of(0);
|
|
16934
16959
|
const byte1 = Uint8Array.of(1);
|
|
16935
16960
|
const _maxDrbgIters = 1e3;
|
|
16936
|
-
let
|
|
16961
|
+
let v9 = u8n(hashLen);
|
|
16937
16962
|
let k = u8n(hashLen);
|
|
16938
16963
|
let i = 0;
|
|
16939
16964
|
const reset = () => {
|
|
16940
|
-
|
|
16965
|
+
v9.fill(1);
|
|
16941
16966
|
k.fill(0);
|
|
16942
16967
|
i = 0;
|
|
16943
16968
|
};
|
|
16944
|
-
const h = (...msgs) => hmacFn(k, concatBytes(
|
|
16969
|
+
const h = (...msgs) => hmacFn(k, concatBytes(v9, ...msgs));
|
|
16945
16970
|
const reseed = (seed = NULL) => {
|
|
16946
16971
|
k = h(byte0, seed);
|
|
16947
|
-
|
|
16972
|
+
v9 = h();
|
|
16948
16973
|
if (seed.length === 0)
|
|
16949
16974
|
return;
|
|
16950
16975
|
k = h(byte1, seed);
|
|
16951
|
-
|
|
16976
|
+
v9 = h();
|
|
16952
16977
|
};
|
|
16953
16978
|
const gen = () => {
|
|
16954
16979
|
if (i++ >= _maxDrbgIters)
|
|
@@ -16956,10 +16981,10 @@ function createHmacDrbg(hashLen, qByteLen, hmacFn) {
|
|
|
16956
16981
|
let len = 0;
|
|
16957
16982
|
const out = [];
|
|
16958
16983
|
while (len < qByteLen) {
|
|
16959
|
-
|
|
16960
|
-
const sl =
|
|
16984
|
+
v9 = h();
|
|
16985
|
+
const sl = v9.slice();
|
|
16961
16986
|
out.push(sl);
|
|
16962
|
-
len +=
|
|
16987
|
+
len += v9.length;
|
|
16963
16988
|
}
|
|
16964
16989
|
return concatBytes(...out);
|
|
16965
16990
|
};
|
|
@@ -16974,18 +16999,18 @@ function createHmacDrbg(hashLen, qByteLen, hmacFn) {
|
|
|
16974
16999
|
};
|
|
16975
17000
|
return genUntil;
|
|
16976
17001
|
}
|
|
16977
|
-
function validateObject(
|
|
16978
|
-
if (!
|
|
17002
|
+
function validateObject(object5, fields = {}, optFields = {}) {
|
|
17003
|
+
if (!object5 || typeof object5 !== "object")
|
|
16979
17004
|
throw new Error("expected valid options object");
|
|
16980
17005
|
function checkField(fieldName, expectedType, isOpt) {
|
|
16981
|
-
const val =
|
|
17006
|
+
const val = object5[fieldName];
|
|
16982
17007
|
if (isOpt && val === void 0)
|
|
16983
17008
|
return;
|
|
16984
17009
|
const current = typeof val;
|
|
16985
17010
|
if (current !== expectedType || val === null)
|
|
16986
17011
|
throw new Error(`param "${fieldName}" is invalid: expected ${expectedType}, got ${current}`);
|
|
16987
17012
|
}
|
|
16988
|
-
const iter = (f, isOpt) => Object.entries(f).forEach(([k,
|
|
17013
|
+
const iter = (f, isOpt) => Object.entries(f).forEach(([k, v9]) => checkField(k, v9, isOpt));
|
|
16989
17014
|
iter(fields, false);
|
|
16990
17015
|
iter(optFields, true);
|
|
16991
17016
|
}
|
|
@@ -17024,12 +17049,12 @@ function pow2(x, power, modulo) {
|
|
|
17024
17049
|
}
|
|
17025
17050
|
return res;
|
|
17026
17051
|
}
|
|
17027
|
-
function invert(
|
|
17028
|
-
if (
|
|
17052
|
+
function invert(number5, modulo) {
|
|
17053
|
+
if (number5 === _0n2)
|
|
17029
17054
|
throw new Error("invert: expected non-zero number");
|
|
17030
17055
|
if (modulo <= _0n2)
|
|
17031
17056
|
throw new Error("invert: expected positive modulus, got " + modulo);
|
|
17032
|
-
let a = mod(
|
|
17057
|
+
let a = mod(number5, modulo);
|
|
17033
17058
|
let b = modulo;
|
|
17034
17059
|
let x = _0n2, u = _1n2;
|
|
17035
17060
|
while (a !== _0n2) {
|
|
@@ -17056,9 +17081,9 @@ function sqrt3mod4(Fp, n) {
|
|
|
17056
17081
|
function sqrt5mod8(Fp, n) {
|
|
17057
17082
|
const p5div8 = (Fp.ORDER - _5n) / _8n;
|
|
17058
17083
|
const n2 = Fp.mul(n, _2n);
|
|
17059
|
-
const
|
|
17060
|
-
const nv = Fp.mul(n,
|
|
17061
|
-
const i = Fp.mul(Fp.mul(nv, _2n),
|
|
17084
|
+
const v9 = Fp.pow(n2, p5div8);
|
|
17085
|
+
const nv = Fp.mul(n, v9);
|
|
17086
|
+
const i = Fp.mul(Fp.mul(nv, _2n), v9);
|
|
17062
17087
|
const root = Fp.mul(nv, Fp.sub(i, Fp.ONE));
|
|
17063
17088
|
assertIsSquare(Fp, root, n);
|
|
17064
17089
|
return root;
|
|
@@ -17533,27 +17558,27 @@ var wNAF = class {
|
|
|
17533
17558
|
assert0(n);
|
|
17534
17559
|
return acc;
|
|
17535
17560
|
}
|
|
17536
|
-
getPrecomputes(W, point,
|
|
17561
|
+
getPrecomputes(W, point, transform2) {
|
|
17537
17562
|
let comp = pointPrecomputes.get(point);
|
|
17538
17563
|
if (!comp) {
|
|
17539
17564
|
comp = this.precomputeWindow(point, W);
|
|
17540
17565
|
if (W !== 1) {
|
|
17541
|
-
if (typeof
|
|
17542
|
-
comp =
|
|
17566
|
+
if (typeof transform2 === "function")
|
|
17567
|
+
comp = transform2(comp);
|
|
17543
17568
|
pointPrecomputes.set(point, comp);
|
|
17544
17569
|
}
|
|
17545
17570
|
}
|
|
17546
17571
|
return comp;
|
|
17547
17572
|
}
|
|
17548
|
-
cached(point, scalar,
|
|
17573
|
+
cached(point, scalar, transform2) {
|
|
17549
17574
|
const W = getW(point);
|
|
17550
|
-
return this.wNAF(W, this.getPrecomputes(W, point,
|
|
17575
|
+
return this.wNAF(W, this.getPrecomputes(W, point, transform2), scalar);
|
|
17551
17576
|
}
|
|
17552
|
-
unsafe(point, scalar,
|
|
17577
|
+
unsafe(point, scalar, transform2, prev) {
|
|
17553
17578
|
const W = getW(point);
|
|
17554
17579
|
if (W === 1)
|
|
17555
17580
|
return this._unsafeLadder(point, scalar, prev);
|
|
17556
|
-
return this.wNAFUnsafe(W, this.getPrecomputes(W, point,
|
|
17581
|
+
return this.wNAFUnsafe(W, this.getPrecomputes(W, point, transform2), scalar, prev);
|
|
17557
17582
|
}
|
|
17558
17583
|
// We calculate precomputes for elliptic curve point multiplication
|
|
17559
17584
|
// using windowed method. This specifies window size and
|
|
@@ -17640,9 +17665,9 @@ function edwards(params, extraOpts = {}) {
|
|
|
17640
17665
|
validateObject(extraOpts, {}, { uvRatio: "function" });
|
|
17641
17666
|
const MASK = _2n2 << BigInt(Fn.BYTES * 8) - _1n4;
|
|
17642
17667
|
const modP = (n) => Fp.create(n);
|
|
17643
|
-
const uvRatio2 = extraOpts.uvRatio || ((u,
|
|
17668
|
+
const uvRatio2 = extraOpts.uvRatio || ((u, v9) => {
|
|
17644
17669
|
try {
|
|
17645
|
-
return { isValid: true, value: Fp.sqrt(Fp.div(u,
|
|
17670
|
+
return { isValid: true, value: Fp.sqrt(Fp.div(u, v9)) };
|
|
17646
17671
|
} catch (e) {
|
|
17647
17672
|
return { isValid: false, value: _0n4 };
|
|
17648
17673
|
}
|
|
@@ -17738,8 +17763,8 @@ function edwards(params, extraOpts = {}) {
|
|
|
17738
17763
|
aInRange("point.y", y, _0n4, max);
|
|
17739
17764
|
const y2 = modP(y * y);
|
|
17740
17765
|
const u = modP(y2 - _1n4);
|
|
17741
|
-
const
|
|
17742
|
-
let { isValid, value: x } = uvRatio2(u,
|
|
17766
|
+
const v9 = modP(d * y2 - a);
|
|
17767
|
+
let { isValid, value: x } = uvRatio2(u, v9);
|
|
17743
17768
|
if (!isValid)
|
|
17744
17769
|
throw new Error("bad point: invalid y coordinate");
|
|
17745
17770
|
const isXOdd = (x & _1n4) === _1n4;
|
|
@@ -18079,13 +18104,13 @@ function adjustScalarBytes(bytes) {
|
|
|
18079
18104
|
return bytes;
|
|
18080
18105
|
}
|
|
18081
18106
|
var ED25519_SQRT_M1 = /* @__PURE__ */ BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");
|
|
18082
|
-
function uvRatio(u,
|
|
18107
|
+
function uvRatio(u, v9) {
|
|
18083
18108
|
const P = ed25519_CURVE_p;
|
|
18084
|
-
const v32 = mod(
|
|
18085
|
-
const
|
|
18086
|
-
const pow = ed25519_pow_2_252_3(u *
|
|
18109
|
+
const v32 = mod(v9 * v9 * v9, P);
|
|
18110
|
+
const v72 = mod(v32 * v32 * v9, P);
|
|
18111
|
+
const pow = ed25519_pow_2_252_3(u * v72).pow_p_5_8;
|
|
18087
18112
|
let x = mod(u * v32 * pow, P);
|
|
18088
|
-
const vx2 = mod(
|
|
18113
|
+
const vx2 = mod(v9 * x * x, P);
|
|
18089
18114
|
const root1 = x;
|
|
18090
18115
|
const root2 = mod(x * ED25519_SQRT_M1, P);
|
|
18091
18116
|
const useRoot1 = vx2 === u;
|
|
@@ -18416,7 +18441,7 @@ function findSeatPrice(validators, maxNumberOfSeats, minimumStakeRatio, protocol
|
|
|
18416
18441
|
return findSeatPriceForProtocolAfter49(validators, maxNumberOfSeats, minimumStakeRatio);
|
|
18417
18442
|
}
|
|
18418
18443
|
function findSeatPriceForProtocolBefore49(validators, numSeats) {
|
|
18419
|
-
const stakes = validators.map((
|
|
18444
|
+
const stakes = validators.map((v9) => BigInt(v9.stake)).sort(sortBigIntAsc);
|
|
18420
18445
|
const num = BigInt(numSeats);
|
|
18421
18446
|
const stakesSum = stakes.reduce((a, b) => a + b);
|
|
18422
18447
|
if (stakesSum < num) {
|
|
@@ -18445,7 +18470,7 @@ function findSeatPriceForProtocolAfter49(validators, maxNumberOfSeats, minimumSt
|
|
|
18445
18470
|
if (minimumStakeRatio.length != 2) {
|
|
18446
18471
|
throw Error("minimumStakeRatio should have 2 elements");
|
|
18447
18472
|
}
|
|
18448
|
-
const stakes = validators.map((
|
|
18473
|
+
const stakes = validators.map((v9) => BigInt(v9.stake)).sort(sortBigIntAsc);
|
|
18449
18474
|
const stakesSum = stakes.reduce((a, b) => a + b);
|
|
18450
18475
|
if (validators.length < maxNumberOfSeats) {
|
|
18451
18476
|
return stakesSum * BigInt(minimumStakeRatio[0]) / BigInt(minimumStakeRatio[1]);
|
|
@@ -18617,10 +18642,10 @@ var DER = {
|
|
|
18617
18642
|
if (length < 128)
|
|
18618
18643
|
throw new E("tlv.decode(long): not minimal encoding");
|
|
18619
18644
|
}
|
|
18620
|
-
const
|
|
18621
|
-
if (
|
|
18645
|
+
const v9 = data.subarray(pos, pos + length);
|
|
18646
|
+
if (v9.length !== length)
|
|
18622
18647
|
throw new E("tlv.decode: wrong value length");
|
|
18623
|
-
return { v:
|
|
18648
|
+
return { v: v9, l: data.subarray(pos + length) };
|
|
18624
18649
|
}
|
|
18625
18650
|
},
|
|
18626
18651
|
// https://crypto.stackexchange.com/a/57734 Leftmost bit of first byte is 'negative' flag,
|
|
@@ -19188,9 +19213,9 @@ function ecdsa(Point, hash, ecdsaOpts = {}) {
|
|
|
19188
19213
|
extraEntropy: false
|
|
19189
19214
|
};
|
|
19190
19215
|
const hasLargeCofactor = CURVE_ORDER * _2n4 < Fp.ORDER;
|
|
19191
|
-
function isBiggerThanHalfOrder(
|
|
19216
|
+
function isBiggerThanHalfOrder(number5) {
|
|
19192
19217
|
const HALF = CURVE_ORDER >> _1n6;
|
|
19193
|
-
return
|
|
19218
|
+
return number5 > HALF;
|
|
19194
19219
|
}
|
|
19195
19220
|
function validateRS(title, num) {
|
|
19196
19221
|
if (!Fn.isValidNot0(num))
|
|
@@ -19373,8 +19398,8 @@ function ecdsa(Point, hash, ecdsaOpts = {}) {
|
|
|
19373
19398
|
const R = Point.BASE.multiplyUnsafe(u1).add(P.multiplyUnsafe(u2));
|
|
19374
19399
|
if (R.is0())
|
|
19375
19400
|
return false;
|
|
19376
|
-
const
|
|
19377
|
-
return
|
|
19401
|
+
const v9 = Fn.create(R.x);
|
|
19402
|
+
return v9 === r;
|
|
19378
19403
|
} catch (e) {
|
|
19379
19404
|
return false;
|
|
19380
19405
|
}
|
|
@@ -26668,6 +26693,36 @@ var SolverApiService = class {
|
|
|
26668
26693
|
}
|
|
26669
26694
|
}
|
|
26670
26695
|
};
|
|
26696
|
+
|
|
26697
|
+
// src/backendApi/pollBackendSubmitTx.ts
|
|
26698
|
+
async function pollBackendSubmitTx({
|
|
26699
|
+
deadline,
|
|
26700
|
+
terminalStatus,
|
|
26701
|
+
getStatus,
|
|
26702
|
+
onExecuted,
|
|
26703
|
+
intervalMs = 1e3,
|
|
26704
|
+
requestTimeoutMs
|
|
26705
|
+
}) {
|
|
26706
|
+
const reserveMs = Math.min(Math.ceil((deadline - Date.now()) / 3), 2e4);
|
|
26707
|
+
const pollDeadline = deadline - reserveMs;
|
|
26708
|
+
const requestOverride = () => requestTimeoutMs === void 0 ? void 0 : { timeout: Math.min(pollDeadline - Date.now(), requestTimeoutMs) };
|
|
26709
|
+
while (Date.now() < pollDeadline) {
|
|
26710
|
+
const statusResult = await getStatus(requestOverride());
|
|
26711
|
+
if (statusResult.ok) {
|
|
26712
|
+
const { status, result, failureReason, abandonedAt } = statusResult.value.data;
|
|
26713
|
+
if (status === terminalStatus) {
|
|
26714
|
+
const value = onExecuted(result);
|
|
26715
|
+
if (value !== void 0) return { ok: true, value };
|
|
26716
|
+
}
|
|
26717
|
+
if (status === "failed" || abandonedAt) {
|
|
26718
|
+
const reason = failureReason ? `: ${failureReason}` : "";
|
|
26719
|
+
return { ok: false, cause: new Error(`backend submit-tx ${status}${reason}`) };
|
|
26720
|
+
}
|
|
26721
|
+
}
|
|
26722
|
+
await new Promise((resolve) => setTimeout(resolve, Math.min(intervalMs, pollDeadline - Date.now())));
|
|
26723
|
+
}
|
|
26724
|
+
return { ok: false, cause: new Error(`backend submit-tx polling timed out before reaching ${terminalStatus}`) };
|
|
26725
|
+
}
|
|
26671
26726
|
function decodePacketIntentTarget(payload) {
|
|
26672
26727
|
try {
|
|
26673
26728
|
const hex = payload.startsWith("0x") ? payload.slice(2) : payload;
|
|
@@ -26990,7 +27045,7 @@ var SwapService = class {
|
|
|
26990
27045
|
relayerApiEndpoint: this.relayerApiEndpoint,
|
|
26991
27046
|
// Remaining shared budget: ≈ full `timeout` on the flag-off path (called immediately), or
|
|
26992
27047
|
// the reserve `submitTx` left on the backend path. Floor keeps a stalled-backend fallback viable.
|
|
26993
|
-
timeout: Math.max(deadline - Date.now(),
|
|
27048
|
+
timeout: Math.max(deadline - Date.now(), RELAY_FALLBACK_FLOOR_MS)
|
|
26994
27049
|
});
|
|
26995
27050
|
if (!packet.ok) {
|
|
26996
27051
|
return { ok: false, error: mapRelayFailure(packet.error, { feature: "swap", action: "swap", ...baseCtx }) };
|
|
@@ -27052,39 +27107,26 @@ var SwapService = class {
|
|
|
27052
27107
|
relayData: relayData.payload
|
|
27053
27108
|
});
|
|
27054
27109
|
if (!submitted.ok) return submitTxFailed(submitted.error);
|
|
27055
|
-
const
|
|
27056
|
-
|
|
27057
|
-
|
|
27058
|
-
|
|
27059
|
-
|
|
27060
|
-
|
|
27061
|
-
|
|
27062
|
-
|
|
27063
|
-
|
|
27064
|
-
|
|
27065
|
-
|
|
27066
|
-
|
|
27067
|
-
|
|
27068
|
-
|
|
27069
|
-
|
|
27070
|
-
|
|
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}`));
|
|
27110
|
+
const polled = await pollBackendSubmitTx({
|
|
27111
|
+
deadline,
|
|
27112
|
+
// Swaps terminal success is `solved` (solver filled) — not the bridge `executed`.
|
|
27113
|
+
terminalStatus: "solved",
|
|
27114
|
+
getStatus: () => this.backendApi.swaps.getSubmitTxStatus({ txHash: spokeTxHash, srcChainKey }),
|
|
27115
|
+
onExecuted: (result) => result?.dstIntentTxHash && result.intent_hash ? {
|
|
27116
|
+
// Backend serializes the hex intent_hash as a plain string; brand it at the boundary.
|
|
27117
|
+
solverExecutionResponse: { answer: "OK", intent_hash: result.intent_hash },
|
|
27118
|
+
intent,
|
|
27119
|
+
intentDeliveryInfo: {
|
|
27120
|
+
srcChainKey,
|
|
27121
|
+
srcTxHash: spokeTxHash,
|
|
27122
|
+
srcAddress: params.srcAddress,
|
|
27123
|
+
dstChainKey: params.dstChainKey,
|
|
27124
|
+
dstTxHash: result.dstIntentTxHash,
|
|
27125
|
+
dstAddress: params.dstAddress
|
|
27083
27126
|
}
|
|
27084
|
-
}
|
|
27085
|
-
|
|
27086
|
-
}
|
|
27087
|
-
return submitTxFailed(new Error("backend submit-tx polling timed out before reaching solved"));
|
|
27127
|
+
} : void 0
|
|
27128
|
+
});
|
|
27129
|
+
return polled.ok ? { ok: true, value: polled.value } : submitTxFailed(polled.cause);
|
|
27088
27130
|
} catch (error) {
|
|
27089
27131
|
return { ok: false, error: unknownFailed("swap", error, { ...baseCtx, action: "swap" }) };
|
|
27090
27132
|
}
|
|
@@ -27276,10 +27318,19 @@ var SwapService = class {
|
|
|
27276
27318
|
`Invalid spoke chain (params.dstChain): ${params.dstChainKey}`,
|
|
27277
27319
|
{ ...baseCtx, field: "dstChainKey" }
|
|
27278
27320
|
);
|
|
27279
|
-
|
|
27321
|
+
const inputTokenInfo = this.config.getSpokeTokenFromOriginalAssetAddress(params.srcChainKey, params.inputToken);
|
|
27322
|
+
if (isNativeBitcoinTransfer(this.config, params.srcChainKey, inputTokenInfo)) {
|
|
27280
27323
|
swapInvariant(
|
|
27281
|
-
params.
|
|
27282
|
-
`Invalid
|
|
27324
|
+
params.inputAmount >= BITCOIN_DUST_SATS,
|
|
27325
|
+
`Invalid inputAmount (${params.inputAmount}): below the Bitcoin dust limit of ${BITCOIN_DUST_SATS} sats`,
|
|
27326
|
+
{ ...baseCtx, field: "inputAmount" }
|
|
27327
|
+
);
|
|
27328
|
+
}
|
|
27329
|
+
const outputTokenInfo = this.config.getSpokeTokenFromOriginalAssetAddress(params.dstChainKey, params.outputToken);
|
|
27330
|
+
if (isNativeBitcoinTransfer(this.config, params.dstChainKey, outputTokenInfo)) {
|
|
27331
|
+
swapInvariant(
|
|
27332
|
+
params.minOutputAmount >= BITCOIN_DUST_SATS,
|
|
27333
|
+
`Invalid minOutputAmount (${params.minOutputAmount}): below the Bitcoin dust limit of ${BITCOIN_DUST_SATS} sats`,
|
|
27283
27334
|
{ ...baseCtx, field: "minOutputAmount" }
|
|
27284
27335
|
);
|
|
27285
27336
|
}
|
|
@@ -29848,6 +29899,7 @@ function trimTrailingSlashes(baseURL) {
|
|
|
29848
29899
|
while (end > 0 && baseURL[end - 1] === "/") end -= 1;
|
|
29849
29900
|
return baseURL.slice(0, end);
|
|
29850
29901
|
}
|
|
29902
|
+
var toJsonBody = (value) => JSON.stringify(value, (_key, val) => typeof val === "bigint" ? val.toString() : val);
|
|
29851
29903
|
async function makeRequest(params) {
|
|
29852
29904
|
const { endpoint, config, overrideConfig = {}, logger, serviceLabel } = params;
|
|
29853
29905
|
const baseURL = overrideConfig.baseURL || config.baseURL || "";
|
|
@@ -29954,7 +30006,7 @@ var SwapsApiService = class _SwapsApiService {
|
|
|
29954
30006
|
if (error.code === "VALIDATION_ERROR" && error.context.issues !== void 0) {
|
|
29955
30007
|
context.reason = "invalid_response_shape";
|
|
29956
30008
|
const issues = error.context.issues;
|
|
29957
|
-
context.issues = issues instanceof
|
|
30009
|
+
context.issues = issues instanceof v7.ValiError ? v7.flatten(issues.issues) : issues;
|
|
29958
30010
|
}
|
|
29959
30011
|
if (error.context.status !== void 0) context.status = error.context.status;
|
|
29960
30012
|
}
|
|
@@ -30115,21 +30167,21 @@ var SwapsApiService = class _SwapsApiService {
|
|
|
30115
30167
|
return this.config.baseURL;
|
|
30116
30168
|
}
|
|
30117
30169
|
};
|
|
30118
|
-
var StellarSponsorConfigSchema =
|
|
30119
|
-
sponsorAccount:
|
|
30120
|
-
networkPassphrase:
|
|
30121
|
-
minTotalFeeStroops:
|
|
30122
|
-
maxTotalFeeStroops:
|
|
30123
|
-
operationCount:
|
|
30124
|
-
minPerOperationFeeStroops:
|
|
30125
|
-
maxPerOperationFeeStroops:
|
|
30126
|
-
recommendedPerOperationFeeStroops:
|
|
30127
|
-
maxTimeboundSeconds:
|
|
30128
|
-
requiredStartingBalance:
|
|
30170
|
+
var StellarSponsorConfigSchema = v7.object({
|
|
30171
|
+
sponsorAccount: v7.string(),
|
|
30172
|
+
networkPassphrase: v7.string(),
|
|
30173
|
+
minTotalFeeStroops: v7.string(),
|
|
30174
|
+
maxTotalFeeStroops: v7.string(),
|
|
30175
|
+
operationCount: v7.number(),
|
|
30176
|
+
minPerOperationFeeStroops: v7.string(),
|
|
30177
|
+
maxPerOperationFeeStroops: v7.string(),
|
|
30178
|
+
recommendedPerOperationFeeStroops: v7.string(),
|
|
30179
|
+
maxTimeboundSeconds: v7.number(),
|
|
30180
|
+
requiredStartingBalance: v7.string()
|
|
30129
30181
|
});
|
|
30130
|
-
var StellarSponsoredAccountResponseSchema =
|
|
30131
|
-
|
|
30132
|
-
|
|
30182
|
+
var StellarSponsoredAccountResponseSchema = v7.variant("alreadyActive", [
|
|
30183
|
+
v7.object({ hash: v7.string(), alreadyActive: v7.literal(false) }),
|
|
30184
|
+
v7.object({ hash: v7.null(), alreadyActive: v7.literal(true) })
|
|
30133
30185
|
]);
|
|
30134
30186
|
|
|
30135
30187
|
// src/backendApi/SponsoringApiService.ts
|
|
@@ -30157,7 +30209,7 @@ var SponsoringApiService = class {
|
|
|
30157
30209
|
logger: this.logger,
|
|
30158
30210
|
serviceLabel: "SponsoringApiService"
|
|
30159
30211
|
});
|
|
30160
|
-
const parsed =
|
|
30212
|
+
const parsed = v7.safeParse(schema, raw);
|
|
30161
30213
|
if (!parsed.success) {
|
|
30162
30214
|
return {
|
|
30163
30215
|
ok: false,
|
|
@@ -30165,7 +30217,7 @@ var SponsoringApiService = class {
|
|
|
30165
30217
|
api: "sponsoring",
|
|
30166
30218
|
feature: "backend",
|
|
30167
30219
|
endpoint,
|
|
30168
|
-
issues:
|
|
30220
|
+
issues: v7.flatten(parsed.issues)
|
|
30169
30221
|
})
|
|
30170
30222
|
};
|
|
30171
30223
|
}
|
|
@@ -30203,6 +30255,411 @@ var SponsoringApiService = class {
|
|
|
30203
30255
|
return this.config.baseURL;
|
|
30204
30256
|
}
|
|
30205
30257
|
};
|
|
30258
|
+
var RelayExtraDataResponseSchema = v7.object({
|
|
30259
|
+
address: v7.string(),
|
|
30260
|
+
payload: v7.string()
|
|
30261
|
+
});
|
|
30262
|
+
var BridgeTokenSchema = v7.object({
|
|
30263
|
+
symbol: v7.string(),
|
|
30264
|
+
name: v7.string(),
|
|
30265
|
+
decimals: v7.number(),
|
|
30266
|
+
address: v7.string(),
|
|
30267
|
+
chainKey: v7.string(),
|
|
30268
|
+
hubAsset: v7.string(),
|
|
30269
|
+
vault: v7.string()
|
|
30270
|
+
});
|
|
30271
|
+
var BridgeTokensResponseSchema = v7.record(v7.string(), v7.array(BridgeTokenSchema));
|
|
30272
|
+
var BridgeTokensByChainResponseSchema = v7.array(BridgeTokenSchema);
|
|
30273
|
+
var BridgeAllowanceCheckResponseSchema = v7.object({
|
|
30274
|
+
valid: v7.boolean()
|
|
30275
|
+
});
|
|
30276
|
+
var makeBridgeApproveResponseSchema = (txSchema) => v7.object({ tx: txSchema });
|
|
30277
|
+
var makeCreateBridgeIntentResponseSchema = (txSchema) => v7.object({
|
|
30278
|
+
tx: txSchema,
|
|
30279
|
+
relayData: RelayExtraDataResponseSchema
|
|
30280
|
+
});
|
|
30281
|
+
var BridgeSubmitTxResponseSchema = v7.object({
|
|
30282
|
+
success: v7.boolean(),
|
|
30283
|
+
data: v7.object({
|
|
30284
|
+
status: v7.picklist(["inserted", "duplicate"]),
|
|
30285
|
+
message: v7.string()
|
|
30286
|
+
})
|
|
30287
|
+
});
|
|
30288
|
+
var BridgePacketDataSchema = v7.object({
|
|
30289
|
+
src_chain_id: v7.number(),
|
|
30290
|
+
src_tx_hash: v7.string(),
|
|
30291
|
+
src_address: v7.string(),
|
|
30292
|
+
status: v7.picklist(["pending", "validating", "executing", "executed"]),
|
|
30293
|
+
dst_chain_id: v7.number(),
|
|
30294
|
+
conn_sn: v7.number(),
|
|
30295
|
+
dst_address: v7.string(),
|
|
30296
|
+
dst_tx_hash: v7.string(),
|
|
30297
|
+
signatures: v7.array(v7.string()),
|
|
30298
|
+
payload: v7.string()
|
|
30299
|
+
});
|
|
30300
|
+
var BridgeSubmitTxStatusResultSchema = v7.object({
|
|
30301
|
+
dstIntentTxHash: v7.string(),
|
|
30302
|
+
packetData: v7.optional(BridgePacketDataSchema)
|
|
30303
|
+
});
|
|
30304
|
+
var BridgeSubmitTxStatusDataSchema = v7.object({
|
|
30305
|
+
txHash: v7.string(),
|
|
30306
|
+
srcChainKey: v7.string(),
|
|
30307
|
+
status: v7.string(),
|
|
30308
|
+
failedAtStep: v7.optional(v7.string()),
|
|
30309
|
+
failureReason: v7.optional(v7.string()),
|
|
30310
|
+
processingAttempts: v7.number(),
|
|
30311
|
+
abandonedAt: v7.optional(v7.string()),
|
|
30312
|
+
result: v7.optional(BridgeSubmitTxStatusResultSchema),
|
|
30313
|
+
userMessage: v7.optional(v7.string())
|
|
30314
|
+
});
|
|
30315
|
+
var BridgeSubmitTxStatusResponseSchema = v7.object({
|
|
30316
|
+
success: v7.boolean(),
|
|
30317
|
+
data: BridgeSubmitTxStatusDataSchema
|
|
30318
|
+
});
|
|
30319
|
+
var BridgeFeeResponseSchema = v7.object({ fee: v7.string() });
|
|
30320
|
+
var BridgeLimitSchema = v7.object({
|
|
30321
|
+
amount: v7.string(),
|
|
30322
|
+
decimals: v7.number(),
|
|
30323
|
+
type: v7.picklist(["DEPOSIT_LIMIT", "WITHDRAWAL_LIMIT"])
|
|
30324
|
+
});
|
|
30325
|
+
var BridgeableAmountResponseSchema = v7.object({ limit: BridgeLimitSchema });
|
|
30326
|
+
var BridgeableCheckResponseSchema = v7.object({ bridgeable: v7.boolean() });
|
|
30327
|
+
var AddressSchema = v7.custom((input) => typeof input === "string");
|
|
30328
|
+
var HexSchema = v7.custom((input) => typeof input === "string");
|
|
30329
|
+
var BigintFromString = v7.pipe(v7.string(), v7.toBigint());
|
|
30330
|
+
var BytesFromIndexRecord = v7.pipe(
|
|
30331
|
+
v7.record(v7.string(), v7.number()),
|
|
30332
|
+
v7.transform((indexed) => Uint8Array.from(Object.values(indexed)))
|
|
30333
|
+
);
|
|
30334
|
+
var EvmRawTxSchema = v7.object({
|
|
30335
|
+
from: AddressSchema,
|
|
30336
|
+
to: AddressSchema,
|
|
30337
|
+
value: BigintFromString,
|
|
30338
|
+
data: HexSchema
|
|
30339
|
+
});
|
|
30340
|
+
var SolanaRawTxSchema = v7.object({
|
|
30341
|
+
from: v7.string(),
|
|
30342
|
+
to: v7.string(),
|
|
30343
|
+
value: BigintFromString,
|
|
30344
|
+
data: v7.string()
|
|
30345
|
+
});
|
|
30346
|
+
var SuiRawTxSchema = v7.object({
|
|
30347
|
+
from: HexSchema,
|
|
30348
|
+
to: v7.string(),
|
|
30349
|
+
value: BigintFromString,
|
|
30350
|
+
data: v7.string()
|
|
30351
|
+
});
|
|
30352
|
+
var StellarRawTxSchema = v7.object({
|
|
30353
|
+
from: v7.string(),
|
|
30354
|
+
to: v7.string(),
|
|
30355
|
+
value: BigintFromString,
|
|
30356
|
+
data: v7.string()
|
|
30357
|
+
});
|
|
30358
|
+
var BitcoinRawTxSchema = v7.object({
|
|
30359
|
+
from: v7.string(),
|
|
30360
|
+
to: v7.string(),
|
|
30361
|
+
value: BigintFromString,
|
|
30362
|
+
data: v7.string()
|
|
30363
|
+
});
|
|
30364
|
+
var InjectiveRawTxSchema = v7.object({
|
|
30365
|
+
from: HexSchema,
|
|
30366
|
+
to: HexSchema,
|
|
30367
|
+
signedDoc: v7.object({
|
|
30368
|
+
bodyBytes: BytesFromIndexRecord,
|
|
30369
|
+
authInfoBytes: BytesFromIndexRecord,
|
|
30370
|
+
chainId: v7.string(),
|
|
30371
|
+
accountNumber: BigintFromString
|
|
30372
|
+
})
|
|
30373
|
+
});
|
|
30374
|
+
var NearRawTxSchema = v7.object({
|
|
30375
|
+
signerId: v7.string(),
|
|
30376
|
+
params: v7.object({
|
|
30377
|
+
contractId: v7.string(),
|
|
30378
|
+
method: v7.string(),
|
|
30379
|
+
args: v7.custom((input) => typeof input === "object" && input !== null),
|
|
30380
|
+
gas: v7.optional(BigintFromString),
|
|
30381
|
+
deposit: v7.optional(BigintFromString)
|
|
30382
|
+
})
|
|
30383
|
+
});
|
|
30384
|
+
var IconRawTxSchema = v7.record(
|
|
30385
|
+
v7.string(),
|
|
30386
|
+
v7.union([v7.string(), v7.custom((input) => typeof input === "object" && input !== null)])
|
|
30387
|
+
);
|
|
30388
|
+
var StacksRawTxSchema = v7.object({
|
|
30389
|
+
payload: v7.string(),
|
|
30390
|
+
estimatedLength: v7.optional(v7.number())
|
|
30391
|
+
});
|
|
30392
|
+
var AnyRawTxSchema = v7.custom((input) => typeof input === "object" && input !== null);
|
|
30393
|
+
function rawTxSchemaForChainKey(chainKey) {
|
|
30394
|
+
let chainType;
|
|
30395
|
+
try {
|
|
30396
|
+
chainType = getChainType(chainKey);
|
|
30397
|
+
} catch {
|
|
30398
|
+
chainType = void 0;
|
|
30399
|
+
}
|
|
30400
|
+
switch (chainType) {
|
|
30401
|
+
case "EVM":
|
|
30402
|
+
return EvmRawTxSchema;
|
|
30403
|
+
case "SOLANA":
|
|
30404
|
+
return SolanaRawTxSchema;
|
|
30405
|
+
case "SUI":
|
|
30406
|
+
return SuiRawTxSchema;
|
|
30407
|
+
case "STELLAR":
|
|
30408
|
+
return StellarRawTxSchema;
|
|
30409
|
+
case "INJECTIVE":
|
|
30410
|
+
return InjectiveRawTxSchema;
|
|
30411
|
+
case "ICON":
|
|
30412
|
+
return IconRawTxSchema;
|
|
30413
|
+
case "STACKS":
|
|
30414
|
+
return StacksRawTxSchema;
|
|
30415
|
+
case "NEAR":
|
|
30416
|
+
return NearRawTxSchema;
|
|
30417
|
+
case "BITCOIN":
|
|
30418
|
+
return BitcoinRawTxSchema;
|
|
30419
|
+
default:
|
|
30420
|
+
return AnyRawTxSchema;
|
|
30421
|
+
}
|
|
30422
|
+
}
|
|
30423
|
+
|
|
30424
|
+
// src/backendApi/BridgeApiService.ts
|
|
30425
|
+
function toCreateBridgeIntentParamsV2(params, extras) {
|
|
30426
|
+
return {
|
|
30427
|
+
srcChainKey: params.srcChainKey,
|
|
30428
|
+
dstChainKey: params.dstChainKey,
|
|
30429
|
+
inputToken: params.srcToken,
|
|
30430
|
+
outputToken: params.dstToken,
|
|
30431
|
+
inputAmount: params.amount.toString(),
|
|
30432
|
+
srcAddress: params.srcAddress,
|
|
30433
|
+
dstAddress: params.recipient,
|
|
30434
|
+
...extras?.srcPublicKey !== void 0 ? { srcPublicKey: extras.srcPublicKey } : {},
|
|
30435
|
+
...extras?.bound !== void 0 ? { bound: extras.bound } : {},
|
|
30436
|
+
...extras?.partnerFee !== void 0 ? { partnerFee: extras.partnerFee } : {}
|
|
30437
|
+
};
|
|
30438
|
+
}
|
|
30439
|
+
var BridgeApiService = class {
|
|
30440
|
+
// Fully-resolved bridge-API config supplied by the caller (BackendApiService resolves the
|
|
30441
|
+
// `ApiConfig` union via `resolveBridgeApiConfig`); this service does not resolve the union.
|
|
30442
|
+
config;
|
|
30443
|
+
headers;
|
|
30444
|
+
logger;
|
|
30445
|
+
constructor(config, logger = consoleLogger) {
|
|
30446
|
+
this.config = config;
|
|
30447
|
+
this.headers = { ...config.headers };
|
|
30448
|
+
this.logger = logger;
|
|
30449
|
+
}
|
|
30450
|
+
/**
|
|
30451
|
+
* Issues a single HTTP request, validates the JSON body against `schema`, and
|
|
30452
|
+
* wraps the result in `Result<T>`. The service-level `baseURL`/`timeout`/
|
|
30453
|
+
* `headers` are merged with the optional per-call `overrideConfig` (which takes
|
|
30454
|
+
* precedence) inside {@link makeRequest}. Every public method delegates here.
|
|
30455
|
+
*/
|
|
30456
|
+
async request(endpoint, config, schema, overrideConfig) {
|
|
30457
|
+
try {
|
|
30458
|
+
const raw = await makeRequest({
|
|
30459
|
+
endpoint,
|
|
30460
|
+
config: { baseURL: this.config.baseURL, timeout: this.config.timeout, headers: this.headers, ...config },
|
|
30461
|
+
overrideConfig,
|
|
30462
|
+
logger: this.logger,
|
|
30463
|
+
serviceLabel: "BridgeApiService"
|
|
30464
|
+
});
|
|
30465
|
+
const parsed = v7.safeParse(schema, raw);
|
|
30466
|
+
if (!parsed.success) {
|
|
30467
|
+
return {
|
|
30468
|
+
ok: false,
|
|
30469
|
+
error: new SodaxError("EXTERNAL_API_ERROR", `Invalid response shape from bridge API for ${endpoint}`, {
|
|
30470
|
+
feature: "backend",
|
|
30471
|
+
context: { api: "bridge", endpoint, reason: "invalid_response_shape", issues: v7.flatten(parsed.issues) }
|
|
30472
|
+
})
|
|
30473
|
+
};
|
|
30474
|
+
}
|
|
30475
|
+
return { ok: true, value: parsed.output };
|
|
30476
|
+
} catch (error) {
|
|
30477
|
+
return {
|
|
30478
|
+
ok: false,
|
|
30479
|
+
error: new SodaxError(
|
|
30480
|
+
"EXTERNAL_API_ERROR",
|
|
30481
|
+
error instanceof Error ? error.message : `Request to ${endpoint} failed`,
|
|
30482
|
+
{
|
|
30483
|
+
feature: "backend",
|
|
30484
|
+
cause: error,
|
|
30485
|
+
context: { api: "bridge", endpoint }
|
|
30486
|
+
}
|
|
30487
|
+
)
|
|
30488
|
+
};
|
|
30489
|
+
}
|
|
30490
|
+
}
|
|
30491
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
30492
|
+
// Tokens
|
|
30493
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
30494
|
+
/**
|
|
30495
|
+
* Fetch all supported bridge tokens grouped by SpokeChainKey.
|
|
30496
|
+
*
|
|
30497
|
+
* @returns `Result<GetBridgeTokensResponseV2>` — map of chain key → token list.
|
|
30498
|
+
*/
|
|
30499
|
+
async getTokens(config) {
|
|
30500
|
+
return this.request("/bridge/tokens", { method: "GET" }, BridgeTokensResponseSchema, config);
|
|
30501
|
+
}
|
|
30502
|
+
/**
|
|
30503
|
+
* Fetch supported bridge tokens for a single SpokeChainKey.
|
|
30504
|
+
*
|
|
30505
|
+
* @param chainKey - SODAX SpokeChainKey (e.g. `0xa4b1.arbitrum`, `solana`).
|
|
30506
|
+
* @returns `Result<GetBridgeTokensByChainResponseV2>` — token list for the chain.
|
|
30507
|
+
*/
|
|
30508
|
+
async getTokensByChain(chainKey, config) {
|
|
30509
|
+
return this.request(
|
|
30510
|
+
`/bridge/tokens/${chainKey}`,
|
|
30511
|
+
{ method: "GET" },
|
|
30512
|
+
BridgeTokensByChainResponseSchema,
|
|
30513
|
+
config
|
|
30514
|
+
);
|
|
30515
|
+
}
|
|
30516
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
30517
|
+
// Allowance · approve · create intent
|
|
30518
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
30519
|
+
/**
|
|
30520
|
+
* Check whether the source token allowance is already sufficient for the bridge.
|
|
30521
|
+
*
|
|
30522
|
+
* @returns `Result<BridgeAllowanceCheckResponseV2>` — `{ valid }`.
|
|
30523
|
+
*/
|
|
30524
|
+
async checkAllowance(body, config) {
|
|
30525
|
+
return this.request(
|
|
30526
|
+
"/bridge/allowance/check",
|
|
30527
|
+
{ method: "POST", body: toJsonBody(body) },
|
|
30528
|
+
BridgeAllowanceCheckResponseSchema,
|
|
30529
|
+
config
|
|
30530
|
+
);
|
|
30531
|
+
}
|
|
30532
|
+
/**
|
|
30533
|
+
* Build an unsigned token-approval transaction for the source token.
|
|
30534
|
+
*
|
|
30535
|
+
* @returns `Result<BridgeApproveResponseV2>` — `{ tx }` (chain-specific unsigned tx).
|
|
30536
|
+
*/
|
|
30537
|
+
async approve(body, config) {
|
|
30538
|
+
const txSchema = rawTxSchemaForChainKey(body.srcChainKey);
|
|
30539
|
+
return this.request(
|
|
30540
|
+
"/bridge/approve",
|
|
30541
|
+
{ method: "POST", body: toJsonBody(body) },
|
|
30542
|
+
makeBridgeApproveResponseSchema(txSchema),
|
|
30543
|
+
config
|
|
30544
|
+
);
|
|
30545
|
+
}
|
|
30546
|
+
/**
|
|
30547
|
+
* Build an unsigned spoke-deposit (create-bridge-intent) transaction.
|
|
30548
|
+
*
|
|
30549
|
+
* @returns `Result<CreateBridgeIntentResponseV2>` — `{ tx, relayData }` (no intent struct).
|
|
30550
|
+
*/
|
|
30551
|
+
async createBridgeIntent(body, config) {
|
|
30552
|
+
const txSchema = rawTxSchemaForChainKey(body.srcChainKey);
|
|
30553
|
+
return this.request(
|
|
30554
|
+
"/bridge/intents",
|
|
30555
|
+
{ method: "POST", body: toJsonBody(body) },
|
|
30556
|
+
makeCreateBridgeIntentResponseSchema(txSchema),
|
|
30557
|
+
config
|
|
30558
|
+
);
|
|
30559
|
+
}
|
|
30560
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
30561
|
+
// Submit-tx state machine
|
|
30562
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
30563
|
+
/**
|
|
30564
|
+
* Submit a broadcast bridge (spoke-deposit) transaction to be processed (relayed).
|
|
30565
|
+
* Carries the FULL `relayData { address, payload }` envelope. Idempotent on `(txHash, srcChainKey)`.
|
|
30566
|
+
*
|
|
30567
|
+
* @returns `Result<BridgeSubmitTxResponseV2>` — `{ success, data: { status, message } }`.
|
|
30568
|
+
*/
|
|
30569
|
+
async submitTx(body, config) {
|
|
30570
|
+
return this.request(
|
|
30571
|
+
"/bridge/submit-tx",
|
|
30572
|
+
{ method: "POST", body: toJsonBody(body) },
|
|
30573
|
+
BridgeSubmitTxResponseSchema,
|
|
30574
|
+
config
|
|
30575
|
+
);
|
|
30576
|
+
}
|
|
30577
|
+
/**
|
|
30578
|
+
* Get the processing status of a submitted bridge transaction by `(txHash, srcChainKey)`.
|
|
30579
|
+
*
|
|
30580
|
+
* @returns `Result<BridgeSubmitTxStatusResponseV2>` — `{ success, data }` (processing state).
|
|
30581
|
+
*/
|
|
30582
|
+
async getSubmitTxStatus(query, config) {
|
|
30583
|
+
const queryParams = new URLSearchParams({ txHash: query.txHash, srcChainKey: query.srcChainKey });
|
|
30584
|
+
return this.request(
|
|
30585
|
+
`/bridge/submit-tx/status?${queryParams.toString()}`,
|
|
30586
|
+
{ method: "GET" },
|
|
30587
|
+
BridgeSubmitTxStatusResponseSchema,
|
|
30588
|
+
config
|
|
30589
|
+
);
|
|
30590
|
+
}
|
|
30591
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
30592
|
+
// Fee · bridgeable quote (read-only; mirror the SDK-core client-side methods)
|
|
30593
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
30594
|
+
/**
|
|
30595
|
+
* Bridge partner fee for an input amount (per-request `partnerFee` override, else the configured default).
|
|
30596
|
+
* NOTE: this is a pure client-side computation
|
|
30597
|
+
* in the SDK core (`sodax.bridge.getFee`) — prefer that (no round-trip); this HTTP variant exists for
|
|
30598
|
+
* parity with the backend `/bridge/fee` endpoint (for consumers using only `sodax.api.bridge`).
|
|
30599
|
+
*
|
|
30600
|
+
* @returns `Result<BridgeFeeResponseV2>` — `{ fee }` (decimal string).
|
|
30601
|
+
*/
|
|
30602
|
+
async getFee(body, config) {
|
|
30603
|
+
return this.request(
|
|
30604
|
+
"/bridge/fee",
|
|
30605
|
+
{ method: "POST", body: toJsonBody(body) },
|
|
30606
|
+
BridgeFeeResponseSchema,
|
|
30607
|
+
config
|
|
30608
|
+
);
|
|
30609
|
+
}
|
|
30610
|
+
/**
|
|
30611
|
+
* Deposit capacity / withdrawal liquidity for a (from, to) token pair. Computable client-side in the
|
|
30612
|
+
* SDK core (`sodax.bridge.getBridgeableAmount`); this HTTP variant mirrors `/bridge/bridgeable-amount`.
|
|
30613
|
+
*
|
|
30614
|
+
* @returns `Result<BridgeableAmountResponseV2>` — `{ limit }`.
|
|
30615
|
+
*/
|
|
30616
|
+
async getBridgeableAmount(body, config) {
|
|
30617
|
+
return this.request(
|
|
30618
|
+
"/bridge/bridgeable-amount",
|
|
30619
|
+
{ method: "POST", body: toJsonBody(body) },
|
|
30620
|
+
BridgeableAmountResponseSchema,
|
|
30621
|
+
config
|
|
30622
|
+
);
|
|
30623
|
+
}
|
|
30624
|
+
/**
|
|
30625
|
+
* Whether a (from, to) token pair is bridgeable. Computable client-side in the SDK core
|
|
30626
|
+
* (`sodax.bridge.isBridgeable`); this HTTP variant mirrors `/bridge/bridgeable/check`.
|
|
30627
|
+
*
|
|
30628
|
+
* @returns `Result<BridgeableCheckResponseV2>` — `{ bridgeable }`.
|
|
30629
|
+
*/
|
|
30630
|
+
async isBridgeable(body, config) {
|
|
30631
|
+
return this.request(
|
|
30632
|
+
"/bridge/bridgeable/check",
|
|
30633
|
+
{ method: "POST", body: toJsonBody(body) },
|
|
30634
|
+
BridgeableCheckResponseSchema,
|
|
30635
|
+
config
|
|
30636
|
+
);
|
|
30637
|
+
}
|
|
30638
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
30639
|
+
// Utilities (parity with SwapsApiService)
|
|
30640
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
30641
|
+
/**
|
|
30642
|
+
* Merge additional headers into the service's default header set. Existing
|
|
30643
|
+
* keys are overwritten; keys absent from `headers` are preserved.
|
|
30644
|
+
*/
|
|
30645
|
+
setHeaders(headers) {
|
|
30646
|
+
Object.entries(headers).forEach(([key, value]) => {
|
|
30647
|
+
this.headers[key] = value;
|
|
30648
|
+
});
|
|
30649
|
+
}
|
|
30650
|
+
/** Return the base URL the service is currently pointing at. */
|
|
30651
|
+
getBaseURL() {
|
|
30652
|
+
return this.config.baseURL;
|
|
30653
|
+
}
|
|
30654
|
+
/**
|
|
30655
|
+
* Return the effective per-request timeout (ms). Callers that bound a request tighter than the
|
|
30656
|
+
* service default (e.g. `pollBackendSubmitTx` clamping to its poll cutoff) need this as the ceiling,
|
|
30657
|
+
* because a `RequestOverrideConfig.timeout` REPLACES the service value rather than lowering it.
|
|
30658
|
+
*/
|
|
30659
|
+
getTimeout() {
|
|
30660
|
+
return this.config.timeout;
|
|
30661
|
+
}
|
|
30662
|
+
};
|
|
30206
30663
|
|
|
30207
30664
|
// src/backendApi/apiConfig.ts
|
|
30208
30665
|
function flatLayer({ baseURL, timeout, headers }) {
|
|
@@ -30247,143 +30704,147 @@ function resolveSponsoringApiConfig(config) {
|
|
|
30247
30704
|
...slice?.apiKey === void 0 ? {} : { apiKey: slice.apiKey }
|
|
30248
30705
|
};
|
|
30249
30706
|
}
|
|
30250
|
-
|
|
30251
|
-
|
|
30252
|
-
|
|
30253
|
-
var
|
|
30254
|
-
|
|
30255
|
-
|
|
30256
|
-
|
|
30257
|
-
|
|
30707
|
+
function resolveBridgeApiConfig(config) {
|
|
30708
|
+
return resolveBaseApiConfig(config);
|
|
30709
|
+
}
|
|
30710
|
+
var ChainKeySchema = v7.custom((input) => typeof input === "string");
|
|
30711
|
+
var SpokeChainKeySchema = v7.custom((input) => typeof input === "string");
|
|
30712
|
+
var AddressSchema2 = v7.custom((input) => typeof input === "string");
|
|
30713
|
+
var XTokenSchema = v7.object({
|
|
30714
|
+
symbol: v7.string(),
|
|
30715
|
+
name: v7.string(),
|
|
30716
|
+
decimals: v7.number(),
|
|
30717
|
+
address: v7.string(),
|
|
30258
30718
|
chainKey: ChainKeySchema,
|
|
30259
|
-
hubAsset:
|
|
30260
|
-
vault:
|
|
30261
|
-
access:
|
|
30719
|
+
hubAsset: AddressSchema2,
|
|
30720
|
+
vault: AddressSchema2,
|
|
30721
|
+
access: v7.optional(v7.picklist(["withdrawOnly", "depositOnly"]))
|
|
30262
30722
|
});
|
|
30263
|
-
var IntentStructSchema =
|
|
30264
|
-
intentId:
|
|
30265
|
-
creator:
|
|
30266
|
-
inputToken:
|
|
30267
|
-
outputToken:
|
|
30268
|
-
inputAmount:
|
|
30269
|
-
minOutputAmount:
|
|
30270
|
-
deadline:
|
|
30271
|
-
allowPartialFill:
|
|
30272
|
-
srcChain:
|
|
30273
|
-
dstChain:
|
|
30274
|
-
srcAddress:
|
|
30275
|
-
dstAddress:
|
|
30276
|
-
solver:
|
|
30277
|
-
data:
|
|
30723
|
+
var IntentStructSchema = v7.object({
|
|
30724
|
+
intentId: v7.string(),
|
|
30725
|
+
creator: v7.string(),
|
|
30726
|
+
inputToken: v7.string(),
|
|
30727
|
+
outputToken: v7.string(),
|
|
30728
|
+
inputAmount: v7.string(),
|
|
30729
|
+
minOutputAmount: v7.string(),
|
|
30730
|
+
deadline: v7.string(),
|
|
30731
|
+
allowPartialFill: v7.boolean(),
|
|
30732
|
+
srcChain: v7.number(),
|
|
30733
|
+
dstChain: v7.number(),
|
|
30734
|
+
srcAddress: v7.string(),
|
|
30735
|
+
dstAddress: v7.string(),
|
|
30736
|
+
solver: v7.string(),
|
|
30737
|
+
data: v7.string()
|
|
30278
30738
|
});
|
|
30279
|
-
var IntentResponseSchema =
|
|
30280
|
-
intentHash:
|
|
30281
|
-
txHash:
|
|
30282
|
-
logIndex:
|
|
30283
|
-
chainId:
|
|
30284
|
-
blockNumber:
|
|
30285
|
-
open:
|
|
30739
|
+
var IntentResponseSchema = v7.object({
|
|
30740
|
+
intentHash: v7.string(),
|
|
30741
|
+
txHash: v7.string(),
|
|
30742
|
+
logIndex: v7.number(),
|
|
30743
|
+
chainId: v7.number(),
|
|
30744
|
+
blockNumber: v7.number(),
|
|
30745
|
+
open: v7.boolean(),
|
|
30286
30746
|
intent: IntentStructSchema,
|
|
30287
|
-
events:
|
|
30747
|
+
events: v7.array(v7.unknown())
|
|
30288
30748
|
});
|
|
30289
|
-
var UserIntentsResponseSchema =
|
|
30290
|
-
total:
|
|
30291
|
-
offset:
|
|
30292
|
-
limit:
|
|
30293
|
-
items:
|
|
30749
|
+
var UserIntentsResponseSchema = v7.object({
|
|
30750
|
+
total: v7.number(),
|
|
30751
|
+
offset: v7.number(),
|
|
30752
|
+
limit: v7.number(),
|
|
30753
|
+
items: v7.array(IntentResponseSchema)
|
|
30294
30754
|
});
|
|
30295
|
-
var OrderbookResponseSchema =
|
|
30296
|
-
total:
|
|
30297
|
-
data:
|
|
30298
|
-
|
|
30299
|
-
intentState:
|
|
30300
|
-
exists:
|
|
30301
|
-
remainingInput:
|
|
30302
|
-
receivedOutput:
|
|
30303
|
-
pendingPayment:
|
|
30755
|
+
var OrderbookResponseSchema = v7.object({
|
|
30756
|
+
total: v7.number(),
|
|
30757
|
+
data: v7.array(
|
|
30758
|
+
v7.object({
|
|
30759
|
+
intentState: v7.object({
|
|
30760
|
+
exists: v7.boolean(),
|
|
30761
|
+
remainingInput: v7.string(),
|
|
30762
|
+
receivedOutput: v7.string(),
|
|
30763
|
+
pendingPayment: v7.boolean()
|
|
30304
30764
|
}),
|
|
30305
|
-
intentData:
|
|
30306
|
-
intentId:
|
|
30307
|
-
creator:
|
|
30308
|
-
inputToken:
|
|
30309
|
-
outputToken:
|
|
30310
|
-
inputAmount:
|
|
30311
|
-
minOutputAmount:
|
|
30312
|
-
deadline:
|
|
30313
|
-
allowPartialFill:
|
|
30314
|
-
srcChain:
|
|
30315
|
-
dstChain:
|
|
30316
|
-
srcAddress:
|
|
30317
|
-
dstAddress:
|
|
30318
|
-
solver:
|
|
30319
|
-
data:
|
|
30320
|
-
intentHash:
|
|
30321
|
-
txHash:
|
|
30322
|
-
blockNumber:
|
|
30765
|
+
intentData: v7.object({
|
|
30766
|
+
intentId: v7.string(),
|
|
30767
|
+
creator: v7.string(),
|
|
30768
|
+
inputToken: v7.string(),
|
|
30769
|
+
outputToken: v7.string(),
|
|
30770
|
+
inputAmount: v7.string(),
|
|
30771
|
+
minOutputAmount: v7.string(),
|
|
30772
|
+
deadline: v7.string(),
|
|
30773
|
+
allowPartialFill: v7.boolean(),
|
|
30774
|
+
srcChain: v7.number(),
|
|
30775
|
+
dstChain: v7.number(),
|
|
30776
|
+
srcAddress: v7.string(),
|
|
30777
|
+
dstAddress: v7.string(),
|
|
30778
|
+
solver: v7.string(),
|
|
30779
|
+
data: v7.string(),
|
|
30780
|
+
intentHash: v7.string(),
|
|
30781
|
+
txHash: v7.string(),
|
|
30782
|
+
blockNumber: v7.number()
|
|
30323
30783
|
})
|
|
30324
30784
|
})
|
|
30325
30785
|
)
|
|
30326
30786
|
});
|
|
30327
|
-
var MoneyMarketPositionSchema =
|
|
30328
|
-
userAddress:
|
|
30329
|
-
positions:
|
|
30330
|
-
|
|
30331
|
-
reserveAddress:
|
|
30332
|
-
aTokenAddress:
|
|
30333
|
-
variableDebtTokenAddress:
|
|
30334
|
-
aTokenBalance:
|
|
30335
|
-
variableDebtTokenBalance:
|
|
30336
|
-
blockNumber:
|
|
30787
|
+
var MoneyMarketPositionSchema = v7.object({
|
|
30788
|
+
userAddress: v7.string(),
|
|
30789
|
+
positions: v7.array(
|
|
30790
|
+
v7.object({
|
|
30791
|
+
reserveAddress: v7.string(),
|
|
30792
|
+
aTokenAddress: v7.string(),
|
|
30793
|
+
variableDebtTokenAddress: v7.string(),
|
|
30794
|
+
aTokenBalance: v7.string(),
|
|
30795
|
+
variableDebtTokenBalance: v7.string(),
|
|
30796
|
+
blockNumber: v7.number()
|
|
30337
30797
|
})
|
|
30338
30798
|
)
|
|
30339
30799
|
});
|
|
30340
|
-
var MoneyMarketAssetSchema =
|
|
30341
|
-
reserveAddress:
|
|
30342
|
-
aTokenAddress:
|
|
30343
|
-
totalATokenBalance:
|
|
30344
|
-
variableDebtTokenAddress:
|
|
30345
|
-
totalVariableDebtTokenBalance:
|
|
30346
|
-
liquidityRate:
|
|
30347
|
-
symbol:
|
|
30348
|
-
totalSuppliers:
|
|
30349
|
-
totalBorrowers:
|
|
30350
|
-
variableBorrowRate:
|
|
30351
|
-
stableBorrowRate:
|
|
30352
|
-
liquidityIndex:
|
|
30353
|
-
variableBorrowIndex:
|
|
30354
|
-
blockNumber:
|
|
30800
|
+
var MoneyMarketAssetSchema = v7.object({
|
|
30801
|
+
reserveAddress: v7.string(),
|
|
30802
|
+
aTokenAddress: v7.string(),
|
|
30803
|
+
totalATokenBalance: v7.string(),
|
|
30804
|
+
variableDebtTokenAddress: v7.string(),
|
|
30805
|
+
totalVariableDebtTokenBalance: v7.string(),
|
|
30806
|
+
liquidityRate: v7.string(),
|
|
30807
|
+
symbol: v7.string(),
|
|
30808
|
+
totalSuppliers: v7.number(),
|
|
30809
|
+
totalBorrowers: v7.number(),
|
|
30810
|
+
variableBorrowRate: v7.string(),
|
|
30811
|
+
stableBorrowRate: v7.string(),
|
|
30812
|
+
liquidityIndex: v7.string(),
|
|
30813
|
+
variableBorrowIndex: v7.string(),
|
|
30814
|
+
blockNumber: v7.number()
|
|
30355
30815
|
});
|
|
30356
|
-
var MoneyMarketAssetsSchema =
|
|
30357
|
-
var MoneyMarketAssetBorrowersSchema =
|
|
30358
|
-
borrowers:
|
|
30359
|
-
total:
|
|
30360
|
-
offset:
|
|
30361
|
-
limit:
|
|
30816
|
+
var MoneyMarketAssetsSchema = v7.array(MoneyMarketAssetSchema);
|
|
30817
|
+
var MoneyMarketAssetBorrowersSchema = v7.object({
|
|
30818
|
+
borrowers: v7.array(v7.string()),
|
|
30819
|
+
total: v7.number(),
|
|
30820
|
+
offset: v7.number(),
|
|
30821
|
+
limit: v7.number()
|
|
30362
30822
|
});
|
|
30363
|
-
var MoneyMarketAssetSuppliersSchema =
|
|
30364
|
-
suppliers:
|
|
30365
|
-
total:
|
|
30366
|
-
offset:
|
|
30367
|
-
limit:
|
|
30823
|
+
var MoneyMarketAssetSuppliersSchema = v7.object({
|
|
30824
|
+
suppliers: v7.array(v7.string()),
|
|
30825
|
+
total: v7.number(),
|
|
30826
|
+
offset: v7.number(),
|
|
30827
|
+
limit: v7.number()
|
|
30368
30828
|
});
|
|
30369
|
-
var MoneyMarketBorrowersSchema =
|
|
30370
|
-
borrowers:
|
|
30371
|
-
total:
|
|
30372
|
-
offset:
|
|
30373
|
-
limit:
|
|
30829
|
+
var MoneyMarketBorrowersSchema = v7.object({
|
|
30830
|
+
borrowers: v7.array(v7.string()),
|
|
30831
|
+
total: v7.number(),
|
|
30832
|
+
offset: v7.number(),
|
|
30833
|
+
limit: v7.number()
|
|
30374
30834
|
});
|
|
30375
|
-
var GetChainsResponseSchema =
|
|
30376
|
-
var TokensByChainMapSchema =
|
|
30377
|
-
(input) => typeof input === "object" && input !== null && Object.values(input).every((tokens) => Array.isArray(tokens) && tokens.every((t) =>
|
|
30835
|
+
var GetChainsResponseSchema = v7.array(SpokeChainKeySchema);
|
|
30836
|
+
var TokensByChainMapSchema = v7.custom(
|
|
30837
|
+
(input) => typeof input === "object" && input !== null && Object.values(input).every((tokens) => Array.isArray(tokens) && tokens.every((t) => v7.is(XTokenSchema, t)))
|
|
30378
30838
|
);
|
|
30379
|
-
var TokensListSchema =
|
|
30380
|
-
var ReserveAssetsSchema =
|
|
30839
|
+
var TokensListSchema = v7.array(XTokenSchema);
|
|
30840
|
+
var ReserveAssetsSchema = v7.array(AddressSchema2);
|
|
30381
30841
|
|
|
30382
30842
|
// src/backendApi/BackendApiService.ts
|
|
30383
30843
|
var BackendApiService = class {
|
|
30384
30844
|
// sub-services exposing domain-specific APIs
|
|
30385
30845
|
swaps;
|
|
30386
30846
|
sponsoring;
|
|
30847
|
+
bridge;
|
|
30387
30848
|
// resolved base-API config: the flat fields of the ApiConfig union with any `baseApiConfig` layered on top
|
|
30388
30849
|
config;
|
|
30389
30850
|
headers;
|
|
@@ -30394,6 +30855,7 @@ var BackendApiService = class {
|
|
|
30394
30855
|
this.logger = logger;
|
|
30395
30856
|
this.swaps = new SwapsApiService(resolveSwapsApiConfig(config), this.logger);
|
|
30396
30857
|
this.sponsoring = new SponsoringApiService(resolveSponsoringApiConfig(config), this.logger);
|
|
30858
|
+
this.bridge = new BridgeApiService(resolveBridgeApiConfig(config), this.logger);
|
|
30397
30859
|
}
|
|
30398
30860
|
/**
|
|
30399
30861
|
* Issue a request and validate the JSON body against `schema`, wrapping the result in `Result<T>`.
|
|
@@ -30410,7 +30872,7 @@ var BackendApiService = class {
|
|
|
30410
30872
|
logger: this.logger,
|
|
30411
30873
|
serviceLabel: "BackendApiService"
|
|
30412
30874
|
});
|
|
30413
|
-
const parsed =
|
|
30875
|
+
const parsed = v7.safeParse(schema, raw);
|
|
30414
30876
|
if (!parsed.success) {
|
|
30415
30877
|
return {
|
|
30416
30878
|
ok: false,
|
|
@@ -30418,7 +30880,7 @@ var BackendApiService = class {
|
|
|
30418
30880
|
api: "backend",
|
|
30419
30881
|
feature: "backend",
|
|
30420
30882
|
endpoint,
|
|
30421
|
-
issues:
|
|
30883
|
+
issues: v7.flatten(parsed.issues)
|
|
30422
30884
|
})
|
|
30423
30885
|
};
|
|
30424
30886
|
}
|
|
@@ -30753,6 +31215,7 @@ var BackendApiService = class {
|
|
|
30753
31215
|
this.headers[key] = value;
|
|
30754
31216
|
});
|
|
30755
31217
|
this.swaps.setHeaders(headers);
|
|
31218
|
+
this.bridge.setHeaders(headers);
|
|
30756
31219
|
}
|
|
30757
31220
|
/**
|
|
30758
31221
|
* Return the base URL the service is currently pointing at.
|
|
@@ -30803,25 +31266,32 @@ var BridgeService = class {
|
|
|
30803
31266
|
hubProvider;
|
|
30804
31267
|
config;
|
|
30805
31268
|
spoke;
|
|
30806
|
-
|
|
31269
|
+
// backend bridge-API client + opt-in backend submit-tx flag
|
|
31270
|
+
backendApi;
|
|
31271
|
+
useBackendSubmitTx;
|
|
31272
|
+
constructor({ hubProvider, config, spoke, backendApi, useBackendSubmitTx }) {
|
|
30807
31273
|
this.config = config;
|
|
30808
31274
|
this.hubProvider = hubProvider;
|
|
30809
31275
|
this.spoke = spoke;
|
|
31276
|
+
this.backendApi = backendApi;
|
|
31277
|
+
this.useBackendSubmitTx = useBackendSubmitTx ?? false;
|
|
30810
31278
|
}
|
|
30811
31279
|
/**
|
|
30812
31280
|
* Calculates the partner fee deducted from a given bridge input amount.
|
|
30813
31281
|
*
|
|
30814
|
-
* Returns `0n` when no partner fee is configured.
|
|
30815
|
-
*
|
|
31282
|
+
* Returns `0n` when no partner fee is configured. `inputAmount` must be in 18-dp hub/vault
|
|
31283
|
+
* units — the units the hub deducts the fee in (see `buildBridgeData`) — NOT the spoke token's
|
|
31284
|
+
* native base units. This matters for a fixed `PartnerFee.amount`, which is wei-denominated
|
|
31285
|
+
* (18 dp); a percentage fee is unit-agnostic.
|
|
30816
31286
|
*
|
|
30817
|
-
* @param inputAmount - Gross amount being bridged, in vault
|
|
31287
|
+
* @param inputAmount - Gross amount being bridged, in 18-dp hub/vault units.
|
|
30818
31288
|
* @returns Fee amount to be deducted, in the same units as `inputAmount`.
|
|
30819
31289
|
*/
|
|
30820
|
-
getFee(inputAmount) {
|
|
30821
|
-
if (!
|
|
31290
|
+
getFee(inputAmount, partnerFee = this.config.bridgePartnerFee) {
|
|
31291
|
+
if (!partnerFee) {
|
|
30822
31292
|
return 0n;
|
|
30823
31293
|
}
|
|
30824
|
-
return calculateFeeAmount(inputAmount,
|
|
31294
|
+
return calculateFeeAmount(inputAmount, partnerFee);
|
|
30825
31295
|
}
|
|
30826
31296
|
/**
|
|
30827
31297
|
* Checks whether the caller has sufficient token allowance to execute the bridge.
|
|
@@ -31006,42 +31476,21 @@ var BridgeService = class {
|
|
|
31006
31476
|
"bridge",
|
|
31007
31477
|
"bridge",
|
|
31008
31478
|
async () => {
|
|
31009
|
-
const { params
|
|
31479
|
+
const { params } = _params;
|
|
31010
31480
|
const baseCtx = { srcChainKey: params.srcChainKey, dstChainKey: params.dstChainKey };
|
|
31011
31481
|
try {
|
|
31012
|
-
const
|
|
31013
|
-
if (!
|
|
31014
|
-
const
|
|
31015
|
-
|
|
31016
|
-
|
|
31017
|
-
|
|
31018
|
-
|
|
31019
|
-
|
|
31020
|
-
|
|
31021
|
-
|
|
31022
|
-
};
|
|
31482
|
+
const created = await this.createBridgeIntent(_params);
|
|
31483
|
+
if (!created.ok) return { ok: false, error: created.error };
|
|
31484
|
+
const deadline = Date.now() + (_params.timeout ?? DEFAULT_RELAY_TX_TIMEOUT);
|
|
31485
|
+
if (this.useBackendSubmitTx) {
|
|
31486
|
+
const submitted = await this.submitTx(_params, created.value, deadline);
|
|
31487
|
+
if (submitted.ok) return submitted;
|
|
31488
|
+
this.config.logger.warn(
|
|
31489
|
+
"[bridge] backend submit-tx did not complete; falling back to the client-side relay",
|
|
31490
|
+
{ error: submitted.error }
|
|
31491
|
+
);
|
|
31023
31492
|
}
|
|
31024
|
-
|
|
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
|
-
};
|
|
31493
|
+
return this.fallbackBridgeSteps(_params, created.value, deadline);
|
|
31045
31494
|
} catch (error) {
|
|
31046
31495
|
if (isBridgeOrchestrationError(error)) return { ok: false, error };
|
|
31047
31496
|
return {
|
|
@@ -31068,6 +31517,98 @@ var BridgeService = class {
|
|
|
31068
31517
|
}
|
|
31069
31518
|
);
|
|
31070
31519
|
}
|
|
31520
|
+
/**
|
|
31521
|
+
* Client-side bridge completion (the default path): verify the broadcast spoke-deposit tx, then
|
|
31522
|
+
* relay it to the hub and wait for the settlement packet. Extracted verbatim from `bridge()` so the
|
|
31523
|
+
* opt-in backend submit-tx path ({@link submitTx}) can fall back to it on any non-success. Bridge
|
|
31524
|
+
* always relays — there is no hub-source short-circuit.
|
|
31525
|
+
*/
|
|
31526
|
+
async fallbackBridgeSteps(_params, created, deadline) {
|
|
31527
|
+
const { params } = _params;
|
|
31528
|
+
const baseCtx = { srcChainKey: params.srcChainKey, dstChainKey: params.dstChainKey };
|
|
31529
|
+
const verifyTxHashResult = await this.spoke.verifyTxHash({
|
|
31530
|
+
txHash: created.tx,
|
|
31531
|
+
chainKey: params.srcChainKey
|
|
31532
|
+
});
|
|
31533
|
+
if (!verifyTxHashResult.ok) {
|
|
31534
|
+
return { ok: false, error: verifyFailed("bridge", verifyTxHashResult.error, baseCtx) };
|
|
31535
|
+
}
|
|
31536
|
+
const packetResult = await relayTxAndWaitPacket({
|
|
31537
|
+
srcTxHash: created.tx,
|
|
31538
|
+
data: created.relayData,
|
|
31539
|
+
chainKey: params.srcChainKey,
|
|
31540
|
+
relayerApiEndpoint: this.config.relay.relayerApiEndpoint,
|
|
31541
|
+
// Remaining shared budget: ≈ full `timeout` on the flag-off path minus the `verifyTxHash` wait,
|
|
31542
|
+
// or the reserve `submitTx` left on the backend path (`pollBackendSubmitTx` holds back up to a
|
|
31543
|
+
// third, capped at 20s). The floor matters because `relayTxAndWaitPacket` SUBMITS the tx to the
|
|
31544
|
+
// relay before `timeout` bounds anything: a budget exhausted by a slow source-chain confirmation
|
|
31545
|
+
// (Stacks polls for up to its full 120s `maxTimeoutMs`) would otherwise strand an already-landed
|
|
31546
|
+
// deposit unrelayed. Re-relay is idempotent, so always spending the floor is safe.
|
|
31547
|
+
timeout: Math.max(deadline - Date.now(), RELAY_FALLBACK_FLOOR_MS)
|
|
31548
|
+
});
|
|
31549
|
+
if (!packetResult.ok) {
|
|
31550
|
+
return {
|
|
31551
|
+
ok: false,
|
|
31552
|
+
error: mapRelayFailure(packetResult.error, {
|
|
31553
|
+
feature: "bridge",
|
|
31554
|
+
action: "bridge",
|
|
31555
|
+
srcChainKey: baseCtx.srcChainKey,
|
|
31556
|
+
dstChainKey: baseCtx.dstChainKey
|
|
31557
|
+
})
|
|
31558
|
+
};
|
|
31559
|
+
}
|
|
31560
|
+
return {
|
|
31561
|
+
ok: true,
|
|
31562
|
+
value: { srcChainTxHash: created.tx, dstChainTxHash: packetResult.value.dst_tx_hash }
|
|
31563
|
+
};
|
|
31564
|
+
}
|
|
31565
|
+
/**
|
|
31566
|
+
* Backend bridge path (opt-in via `bridgeOptions.useBackendSubmitTx`): hand the broadcast
|
|
31567
|
+
* spoke-deposit tx to the bridge API (`POST /bridge/submit-tx`) with the FULL `relayData`
|
|
31568
|
+
* envelope; the backend relays server-side. Polls `getSubmitTxStatus` until `executed`, then
|
|
31569
|
+
* returns the same {@link TxHashPair} the client-side path returns (`result.dstIntentTxHash` →
|
|
31570
|
+
* destination tx hash; bridge has no solver `intent_hash`).
|
|
31571
|
+
*
|
|
31572
|
+
* Never throws — returns `{ ok: false }` on any non-success (submit `!ok`, terminal `failed` /
|
|
31573
|
+
* abandoned, or poll timeout) so `bridge()` falls back to {@link fallbackBridgeSteps}. Falling back
|
|
31574
|
+
* is safe: re-relaying an already-relayed bridge tx is idempotent — the relay dedups and returns the
|
|
31575
|
+
* existing `executed` packet. Polling stops at `deadline - reserve` so the fallback keeps a
|
|
31576
|
+
* guaranteed slice of the shared `bridge` budget.
|
|
31577
|
+
*/
|
|
31578
|
+
async submitTx(_params, created, deadline) {
|
|
31579
|
+
const { params } = _params;
|
|
31580
|
+
const srcChainKey = params.srcChainKey;
|
|
31581
|
+
const baseCtx = { srcChainKey, dstChainKey: params.dstChainKey };
|
|
31582
|
+
const { tx: spokeTxHash, relayData } = created;
|
|
31583
|
+
const submitTxFailed = (cause) => ({
|
|
31584
|
+
ok: false,
|
|
31585
|
+
error: executionFailed("bridge", cause, { ...baseCtx, action: "bridge" })
|
|
31586
|
+
});
|
|
31587
|
+
try {
|
|
31588
|
+
const submitted = await this.backendApi.bridge.submitTx({
|
|
31589
|
+
txHash: spokeTxHash,
|
|
31590
|
+
srcChainKey,
|
|
31591
|
+
walletAddress: params.srcAddress,
|
|
31592
|
+
// Send the FULL { address, payload } envelope — bridge has no intent.creator for the backend
|
|
31593
|
+
// to rebuild the relay address, so dropping it would break split-tx-chain relay.
|
|
31594
|
+
relayData
|
|
31595
|
+
});
|
|
31596
|
+
if (!submitted.ok) return submitTxFailed(submitted.error);
|
|
31597
|
+
const polled = await pollBackendSubmitTx({
|
|
31598
|
+
deadline,
|
|
31599
|
+
// Bridge terminal success is `executed` (hub-settled) — not the swaps `solved`.
|
|
31600
|
+
terminalStatus: "executed",
|
|
31601
|
+
getStatus: (override) => this.backendApi.bridge.getSubmitTxStatus({ txHash: spokeTxHash, srcChainKey }, override),
|
|
31602
|
+
onExecuted: (result) => result?.dstIntentTxHash ? { srcChainTxHash: spokeTxHash, dstChainTxHash: result.dstIntentTxHash } : void 0,
|
|
31603
|
+
// Bound each status request by the poll cutoff, never above the service default — so a stalled
|
|
31604
|
+
// request can neither eat the fallback's reserve nor consume the window in one attempt.
|
|
31605
|
+
requestTimeoutMs: this.backendApi.bridge.getTimeout()
|
|
31606
|
+
});
|
|
31607
|
+
return polled.ok ? { ok: true, value: polled.value } : submitTxFailed(polled.cause);
|
|
31608
|
+
} catch (error) {
|
|
31609
|
+
return { ok: false, error: unknownFailed("bridge", error, { ...baseCtx, action: "bridge" }) };
|
|
31610
|
+
}
|
|
31611
|
+
}
|
|
31071
31612
|
/**
|
|
31072
31613
|
* Submits the spoke-side deposit transaction that initiates a bridge transfer,
|
|
31073
31614
|
* without waiting for the cross-chain relay to complete.
|
|
@@ -31091,9 +31632,15 @@ var BridgeService = class {
|
|
|
31091
31632
|
* contains the hub wallet address and encoded hub execution payload needed for relay.
|
|
31092
31633
|
*/
|
|
31093
31634
|
async createBridgeIntent(_params) {
|
|
31094
|
-
const { params, skipSimulation } = _params;
|
|
31635
|
+
const { params, skipSimulation, extras } = _params;
|
|
31636
|
+
const partnerFee = extras?.partnerFee ?? this.config.bridgePartnerFee;
|
|
31095
31637
|
const baseCtx = { srcChainKey: params.srcChainKey, dstChainKey: params.dstChainKey };
|
|
31096
31638
|
try {
|
|
31639
|
+
bridgeInvariant(
|
|
31640
|
+
isUndefinedOrValidWalletProviderForChainKey(params.srcChainKey, _params.walletProvider),
|
|
31641
|
+
`Invalid wallet provider for chain key: ${params.srcChainKey}`,
|
|
31642
|
+
baseCtx
|
|
31643
|
+
);
|
|
31097
31644
|
bridgeInvariant(params.amount > 0n, "Amount must be greater than 0", { ...baseCtx, field: "amount" });
|
|
31098
31645
|
const srcToken = this.resolveBridgeEndpointToken(params.srcChainKey, params.srcToken);
|
|
31099
31646
|
const dstToken = this.resolveBridgeEndpointToken(params.dstChainKey, params.dstToken);
|
|
@@ -31105,25 +31652,62 @@ var BridgeService = class {
|
|
|
31105
31652
|
...baseCtx,
|
|
31106
31653
|
field: "dstToken"
|
|
31107
31654
|
});
|
|
31108
|
-
|
|
31109
|
-
|
|
31110
|
-
|
|
31655
|
+
bridgeInvariant(
|
|
31656
|
+
this.config.isValidSpokeChainKey(params.srcChainKey),
|
|
31657
|
+
`Invalid spoke chain (srcChainKey): ${params.srcChainKey}`,
|
|
31658
|
+
{ ...baseCtx, field: "srcChainKey" }
|
|
31659
|
+
);
|
|
31660
|
+
bridgeInvariant(
|
|
31661
|
+
this.config.isValidSpokeChainKey(params.dstChainKey),
|
|
31662
|
+
`Invalid spoke chain (dstChainKey): ${params.dstChainKey}`,
|
|
31663
|
+
{ ...baseCtx, field: "dstChainKey" }
|
|
31664
|
+
);
|
|
31665
|
+
if (isNativeBitcoinTransfer(this.config, params.srcChainKey, srcToken)) {
|
|
31111
31666
|
bridgeInvariant(
|
|
31112
|
-
|
|
31113
|
-
`Invalid
|
|
31114
|
-
{ ...baseCtx, field: "
|
|
31667
|
+
params.amount >= BITCOIN_DUST_SATS,
|
|
31668
|
+
`Invalid amount (${params.amount}): below the Bitcoin dust limit of ${BITCOIN_DUST_SATS} sats`,
|
|
31669
|
+
{ ...baseCtx, field: "amount" }
|
|
31115
31670
|
);
|
|
31116
|
-
|
|
31117
|
-
|
|
31118
|
-
|
|
31671
|
+
}
|
|
31672
|
+
if (isNativeBitcoinTransfer(this.config, params.dstChainKey, dstToken)) {
|
|
31673
|
+
const { delivered } = this.computeBridgeAmounts(params.amount, srcToken, dstToken, partnerFee);
|
|
31674
|
+
bridgeInvariant(
|
|
31675
|
+
delivered >= BITCOIN_DUST_SATS,
|
|
31676
|
+
`Post-fee BTC delivery (${delivered}) is below the Bitcoin dust limit of ${BITCOIN_DUST_SATS} sats`,
|
|
31677
|
+
{ ...baseCtx, field: "amount" }
|
|
31678
|
+
);
|
|
31679
|
+
}
|
|
31680
|
+
if (isStacksChainKeyType(params.srcChainKey) && _params.raw === true) {
|
|
31681
|
+
bridgeInvariant(
|
|
31682
|
+
extras?.srcPublicKey !== void 0,
|
|
31683
|
+
"srcPublicKey is required for Stacks createBridgeIntent (raw) \u2014 the source tx is built unsigned and needs the signer public key",
|
|
31684
|
+
{ ...baseCtx, field: "srcPublicKey" }
|
|
31685
|
+
);
|
|
31686
|
+
}
|
|
31687
|
+
const personalAddress = params.srcAddress;
|
|
31688
|
+
let walletAddress = personalAddress;
|
|
31689
|
+
if (isBitcoinChainKeyType(params.srcChainKey)) {
|
|
31690
|
+
if (_params.raw === false) {
|
|
31691
|
+
bridgeInvariant(
|
|
31692
|
+
isBitcoinWalletProviderType(_params.walletProvider),
|
|
31693
|
+
`Invalid wallet provider for chain key: ${params.srcChainKey}. Expected bitcoin wallet provider.`,
|
|
31694
|
+
{ ...baseCtx, field: "walletProvider" }
|
|
31695
|
+
);
|
|
31696
|
+
if (this.spoke.bitcoin.walletMode === "TRADING") {
|
|
31697
|
+
await this.spoke.bitcoin.radfi.ensureRadfiAccessToken(_params.walletProvider);
|
|
31698
|
+
}
|
|
31119
31699
|
}
|
|
31700
|
+
walletAddress = await this.spoke.bitcoin.getEffectiveWalletAddress(personalAddress);
|
|
31120
31701
|
}
|
|
31121
31702
|
const hubWallet = await this.hubProvider.getUserHubWalletAddress(walletAddress, params.srcChainKey);
|
|
31122
31703
|
const effectiveSkipSimulation = skipSimulation || isBitcoinChainKeyType(params.srcChainKey) && this.spoke.bitcoin.walletMode === "USER";
|
|
31123
|
-
const data = this.buildBridgeData(params, srcToken, dstToken,
|
|
31704
|
+
const data = this.buildBridgeData(params, srcToken, dstToken, partnerFee);
|
|
31124
31705
|
const coreParams = {
|
|
31125
31706
|
srcChainKey: params.srcChainKey,
|
|
31126
31707
|
srcAddress: walletAddress,
|
|
31708
|
+
srcPublicKey: extras?.srcPublicKey,
|
|
31709
|
+
// Bitcoin Bound token; BitcoinSpokeService.deposit falls back to the RadfiProvider instance token when undefined.
|
|
31710
|
+
accessToken: extras?.bound?.accessToken,
|
|
31127
31711
|
to: hubWallet,
|
|
31128
31712
|
token: params.srcToken,
|
|
31129
31713
|
amount: params.amount,
|
|
@@ -31178,6 +31762,26 @@ var BridgeService = class {
|
|
|
31178
31762
|
if (spokeToken) return spokeToken;
|
|
31179
31763
|
return isHubChainKeyType(chainKey) ? this.config.getXTokenFromHubAsset(token) : void 0;
|
|
31180
31764
|
}
|
|
31765
|
+
/**
|
|
31766
|
+
* Post-fee amounts for a bridge, in the units each hub step operates in. Single source for the fee +
|
|
31767
|
+
* vault-decimal pipeline, so {@link buildBridgeData}'s encoded hub calls and the BTC-destination dust
|
|
31768
|
+
* guard in {@link createBridgeIntent} can never disagree about what actually gets delivered.
|
|
31769
|
+
*
|
|
31770
|
+
* A spoke endpoint's amount is translated INTO 18-dp vault units on the way in (skipped when the
|
|
31771
|
+
* endpoint already IS the vault asset), the partner fee is deducted there — so a fixed
|
|
31772
|
+
* `PartnerFee.amount` is wei-denominated, never spoke-denominated — and the remainder is translated
|
|
31773
|
+
* back OUT into the destination endpoint's own units.
|
|
31774
|
+
*
|
|
31775
|
+
* @returns `feeAmount` and `withdrawAmount` in 18-dp vault units (what the hub fee transfer and vault
|
|
31776
|
+
* withdrawal use), and `delivered` in the destination endpoint's units (what the recipient receives).
|
|
31777
|
+
*/
|
|
31778
|
+
computeBridgeAmounts(amount, srcToken, dstToken, partnerFee) {
|
|
31779
|
+
const translatedAmount = this.config.isSodaVaultHubAsset(srcToken.hubAsset) ? amount : EvmVaultTokenService.translateIncomingDecimals(srcToken.decimals, amount);
|
|
31780
|
+
const feeAmount = calculateFeeAmount(translatedAmount, partnerFee);
|
|
31781
|
+
const withdrawAmount = translatedAmount - feeAmount;
|
|
31782
|
+
const delivered = this.config.isSodaVaultHubAsset(dstToken.hubAsset) ? withdrawAmount : EvmVaultTokenService.translateOutgoingDecimals(dstToken.decimals, withdrawAmount);
|
|
31783
|
+
return { feeAmount, withdrawAmount, delivered };
|
|
31784
|
+
}
|
|
31181
31785
|
/**
|
|
31182
31786
|
* Encodes the hub-side execution payload for a bridge operation.
|
|
31183
31787
|
*
|
|
@@ -31201,23 +31805,23 @@ var BridgeService = class {
|
|
|
31201
31805
|
*/
|
|
31202
31806
|
buildBridgeData(params, srcToken, dstToken, partnerFee) {
|
|
31203
31807
|
const calls = [];
|
|
31204
|
-
|
|
31205
|
-
|
|
31808
|
+
const { feeAmount, withdrawAmount, delivered } = this.computeBridgeAmounts(
|
|
31809
|
+
params.amount,
|
|
31810
|
+
srcToken,
|
|
31811
|
+
dstToken,
|
|
31812
|
+
partnerFee
|
|
31813
|
+
);
|
|
31814
|
+
let srcVault = srcToken.hubAsset;
|
|
31206
31815
|
if (!this.config.isSodaVaultHubAsset(srcToken.hubAsset)) {
|
|
31207
31816
|
calls.push(Erc20Service.encodeApprove(srcToken.hubAsset, srcToken.vault, params.amount));
|
|
31208
31817
|
calls.push(EvmVaultTokenService.encodeDeposit(srcToken.vault, srcToken.hubAsset, params.amount));
|
|
31209
|
-
translatedAmount = EvmVaultTokenService.translateIncomingDecimals(srcToken.decimals, params.amount);
|
|
31210
31818
|
srcVault = srcToken.vault;
|
|
31211
31819
|
}
|
|
31212
|
-
const feeAmount = calculateFeeAmount(translatedAmount, partnerFee);
|
|
31213
31820
|
if (partnerFee && feeAmount > 0n) {
|
|
31214
31821
|
calls.push(Erc20Service.encodeTransfer(srcVault, partnerFee.address, feeAmount));
|
|
31215
31822
|
}
|
|
31216
|
-
const withdrawAmount = translatedAmount - feeAmount;
|
|
31217
|
-
let translatedWithdrawAmount = withdrawAmount;
|
|
31218
31823
|
if (!this.config.isSodaVaultHubAsset(dstToken.hubAsset)) {
|
|
31219
31824
|
calls.push(EvmVaultTokenService.encodeWithdraw(dstToken.vault, dstToken.hubAsset, withdrawAmount));
|
|
31220
|
-
translatedWithdrawAmount = EvmVaultTokenService.translateOutgoingDecimals(dstToken.decimals, withdrawAmount);
|
|
31221
31825
|
}
|
|
31222
31826
|
const encodedRecipientAddress = encodeAddress(params.dstChainKey, params.recipient);
|
|
31223
31827
|
if (isHubChainKey(params.dstChainKey)) {
|
|
@@ -31228,11 +31832,11 @@ var BridgeService = class {
|
|
|
31228
31832
|
data: encodeFunctionData({
|
|
31229
31833
|
abi: wrappedSonicAbi,
|
|
31230
31834
|
functionName: "withdrawTo",
|
|
31231
|
-
args: [encodedRecipientAddress,
|
|
31835
|
+
args: [encodedRecipientAddress, delivered]
|
|
31232
31836
|
})
|
|
31233
31837
|
});
|
|
31234
31838
|
} else {
|
|
31235
|
-
calls.push(Erc20Service.encodeTransfer(dstToken.hubAsset, encodedRecipientAddress,
|
|
31839
|
+
calls.push(Erc20Service.encodeTransfer(dstToken.hubAsset, encodedRecipientAddress, delivered));
|
|
31236
31840
|
}
|
|
31237
31841
|
} else {
|
|
31238
31842
|
bridgeInvariant(dstToken, `Unsupported hub chain (${params.dstChainKey}) token: ${params.dstToken}`, {
|
|
@@ -31243,7 +31847,7 @@ var BridgeService = class {
|
|
|
31243
31847
|
EvmAssetManagerService.encodeTransfer(
|
|
31244
31848
|
dstToken.hubAsset,
|
|
31245
31849
|
encodedRecipientAddress,
|
|
31246
|
-
|
|
31850
|
+
delivered,
|
|
31247
31851
|
this.hubProvider.chainConfig.addresses.assetManager
|
|
31248
31852
|
)
|
|
31249
31853
|
);
|
|
@@ -39462,7 +40066,7 @@ var LeverageYieldService = class {
|
|
|
39462
40066
|
}
|
|
39463
40067
|
/** Looks up a vault by its `name` field. Returns `undefined` when not registered. */
|
|
39464
40068
|
getVault(name) {
|
|
39465
|
-
return this.listVaults().find((
|
|
40069
|
+
return this.listVaults().find((v9) => v9.name === name);
|
|
39466
40070
|
}
|
|
39467
40071
|
/**
|
|
39468
40072
|
* Looks up a registered vault by its on-chain proxy address (case-insensitive).
|
|
@@ -39470,7 +40074,7 @@ var LeverageYieldService = class {
|
|
|
39470
40074
|
*/
|
|
39471
40075
|
getVaultByAddress(address) {
|
|
39472
40076
|
const normalized = address.toLowerCase();
|
|
39473
|
-
return this.listVaults().find((
|
|
40077
|
+
return this.listVaults().find((v9) => v9.vault.toLowerCase() === normalized);
|
|
39474
40078
|
}
|
|
39475
40079
|
/**
|
|
39476
40080
|
* Resolves the intent `deadline`: returns the caller-supplied value verbatim, otherwise
|
|
@@ -40277,12 +40881,12 @@ function toDomainCode(value) {
|
|
|
40277
40881
|
}
|
|
40278
40882
|
function readErrorBody(body) {
|
|
40279
40883
|
if (typeof body !== "object" || body === null) return {};
|
|
40280
|
-
const
|
|
40281
|
-
const retryAfterSeconds = typeof
|
|
40282
|
-
const sponsorSequence = typeof
|
|
40884
|
+
const record3 = body;
|
|
40885
|
+
const retryAfterSeconds = typeof record3.retryAfterSeconds === "number" && Number.isFinite(record3.retryAfterSeconds) && record3.retryAfterSeconds > 0 ? record3.retryAfterSeconds : void 0;
|
|
40886
|
+
const sponsorSequence = typeof record3.sponsorSequence === "string" && /^\d+$/.test(record3.sponsorSequence) ? record3.sponsorSequence : void 0;
|
|
40283
40887
|
return {
|
|
40284
|
-
message: typeof
|
|
40285
|
-
code: toDomainCode(
|
|
40888
|
+
message: typeof record3.message === "string" ? record3.message : void 0,
|
|
40889
|
+
code: toDomainCode(record3.error),
|
|
40286
40890
|
retryAfterSeconds,
|
|
40287
40891
|
sponsorSequence
|
|
40288
40892
|
};
|
|
@@ -40848,7 +41452,9 @@ var Sodax = class {
|
|
|
40848
41452
|
const logger = resolveLogger(options?.logger);
|
|
40849
41453
|
const analytics = resolveAnalytics(options?.analytics);
|
|
40850
41454
|
const fee = options?.fee;
|
|
41455
|
+
const radfiSigner = options?.radfi?.signRequest;
|
|
40851
41456
|
const useBackendSubmitTx = options?.swapsOptions?.useBackendSubmitTx ?? false;
|
|
41457
|
+
const bridgeUseBackendSubmitTx = options?.bridgeOptions?.useBackendSubmitTx ?? false;
|
|
40852
41458
|
this.instanceConfig = options ? mergeSodaxConfig(sodaxConfig, options) : sodaxConfig;
|
|
40853
41459
|
this.backendApi = new BackendApiService(this.instanceConfig.api, logger);
|
|
40854
41460
|
this.api = this.backendApi;
|
|
@@ -40858,7 +41464,8 @@ var Sodax = class {
|
|
|
40858
41464
|
userConfig: options,
|
|
40859
41465
|
logger,
|
|
40860
41466
|
analytics,
|
|
40861
|
-
fee
|
|
41467
|
+
fee,
|
|
41468
|
+
radfiSigner
|
|
40862
41469
|
});
|
|
40863
41470
|
this.hubProvider = new EvmHubProvider({ config: this.config });
|
|
40864
41471
|
this.spoke = new SpokeService({ config: this.config, hubProvider: this.hubProvider });
|
|
@@ -40884,7 +41491,13 @@ var Sodax = class {
|
|
|
40884
41491
|
config: this.config,
|
|
40885
41492
|
spoke: this.spoke
|
|
40886
41493
|
});
|
|
40887
|
-
this.bridge = new BridgeService({
|
|
41494
|
+
this.bridge = new BridgeService({
|
|
41495
|
+
hubProvider: this.hubProvider,
|
|
41496
|
+
config: this.config,
|
|
41497
|
+
spoke: this.spoke,
|
|
41498
|
+
backendApi: this.backendApi,
|
|
41499
|
+
useBackendSubmitTx: bridgeUseBackendSubmitTx
|
|
41500
|
+
});
|
|
40888
41501
|
this.staking = new StakingService({ hubProvider: this.hubProvider, config: this.config, spoke: this.spoke });
|
|
40889
41502
|
this.partners = new PartnerService({
|
|
40890
41503
|
hubProvider: this.hubProvider,
|
|
@@ -40947,4 +41560,4 @@ var isPartnerError = isCodeMember(PARTNER_CODES);
|
|
|
40947
41560
|
(*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
40948
41561
|
*/
|
|
40949
41562
|
|
|
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 };
|
|
41563
|
+
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 };
|