@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.cjs
CHANGED
|
@@ -19,7 +19,7 @@ var IconSdkRaw = require('icon-sdk-js');
|
|
|
19
19
|
var sdkTs = require('@injectivelabs/sdk-ts');
|
|
20
20
|
var tx_js = require('cosmjs-types/cosmos/tx/v1beta1/tx.js');
|
|
21
21
|
var networks = require('@injectivelabs/networks');
|
|
22
|
-
var
|
|
22
|
+
var v7 = require('valibot');
|
|
23
23
|
var swapsApi = require('@sodax/swaps-api');
|
|
24
24
|
var BigNumber5 = require('bignumber.js');
|
|
25
25
|
var swapSdkCore = require('@pancakeswap/swap-sdk-core');
|
|
@@ -49,7 +49,7 @@ var rlp__namespace = /*#__PURE__*/_interopNamespace(rlp);
|
|
|
49
49
|
var ecc__namespace = /*#__PURE__*/_interopNamespace(ecc);
|
|
50
50
|
var BN__default = /*#__PURE__*/_interopDefault(BN);
|
|
51
51
|
var IconSdkRaw__namespace = /*#__PURE__*/_interopNamespace(IconSdkRaw);
|
|
52
|
-
var
|
|
52
|
+
var v7__namespace = /*#__PURE__*/_interopNamespace(v7);
|
|
53
53
|
var BigNumber5__default = /*#__PURE__*/_interopDefault(BigNumber5);
|
|
54
54
|
|
|
55
55
|
// src/errors/SodaxError.ts
|
|
@@ -122,8 +122,8 @@ function serializeCause(cause, depth) {
|
|
|
122
122
|
}
|
|
123
123
|
function sanitizeContext(value, depth) {
|
|
124
124
|
const out = {};
|
|
125
|
-
for (const [key,
|
|
126
|
-
out[key] = sanitizeValue(
|
|
125
|
+
for (const [key, v9] of Object.entries(value)) {
|
|
126
|
+
out[key] = sanitizeValue(v9, depth + 1);
|
|
127
127
|
}
|
|
128
128
|
return out;
|
|
129
129
|
}
|
|
@@ -134,13 +134,13 @@ function sanitizeValue(value, depth) {
|
|
|
134
134
|
if (t === "bigint") return value.toString();
|
|
135
135
|
if (t === "string" || t === "number" || t === "boolean") return value;
|
|
136
136
|
if (t === "function" || t === "symbol") return safeString(value);
|
|
137
|
-
if (Array.isArray(value)) return value.map((
|
|
137
|
+
if (Array.isArray(value)) return value.map((v9) => sanitizeValue(v9, depth + 1));
|
|
138
138
|
if (value instanceof Date) return value.toISOString();
|
|
139
139
|
if (value instanceof Map) {
|
|
140
|
-
return Array.from(value.entries()).map(([k,
|
|
140
|
+
return Array.from(value.entries()).map(([k, v9]) => [sanitizeValue(k, depth + 1), sanitizeValue(v9, depth + 1)]);
|
|
141
141
|
}
|
|
142
142
|
if (value instanceof Set) {
|
|
143
|
-
return Array.from(value.values()).map((
|
|
143
|
+
return Array.from(value.values()).map((v9) => sanitizeValue(v9, depth + 1));
|
|
144
144
|
}
|
|
145
145
|
if (value instanceof Error) return { name: value.name, message: value.message };
|
|
146
146
|
if (t === "object") {
|
|
@@ -152,9 +152,9 @@ function sanitizeValue(value, depth) {
|
|
|
152
152
|
}
|
|
153
153
|
return safeString(value);
|
|
154
154
|
}
|
|
155
|
-
function safeString(
|
|
155
|
+
function safeString(v9) {
|
|
156
156
|
try {
|
|
157
|
-
return String(
|
|
157
|
+
return String(v9);
|
|
158
158
|
} catch {
|
|
159
159
|
return "[unserializable]";
|
|
160
160
|
}
|
|
@@ -513,7 +513,7 @@ var SodaTokens = {
|
|
|
513
513
|
name: "Soda RBNT",
|
|
514
514
|
decimals: 18,
|
|
515
515
|
address: "0x4B207114F9118dEAC56436e1aE3c45648783c7Ac",
|
|
516
|
-
chainKey: ChainKeys.
|
|
516
|
+
chainKey: ChainKeys.SONIC_MAINNET,
|
|
517
517
|
hubAsset: "0x4B207114F9118dEAC56436e1aE3c45648783c7Ac",
|
|
518
518
|
vault: "0x4B207114F9118dEAC56436e1aE3c45648783c7Ac"
|
|
519
519
|
},
|
|
@@ -4272,6 +4272,11 @@ var SPONSORING_API_ERROR_CODES = [
|
|
|
4272
4272
|
];
|
|
4273
4273
|
|
|
4274
4274
|
// ../types/dist/bitcoin/bitcoin.js
|
|
4275
|
+
var BITCOIN_DUST_SATS = 546n;
|
|
4276
|
+
function isNativeBitcoinToken(chainConfig, token) {
|
|
4277
|
+
const nativeBtcTokens = new Set(["btc", chainConfig.nativeToken, chainConfig.supportedTokens.BTC?.address].filter((value) => !!value).map((value) => value.toLowerCase()));
|
|
4278
|
+
return nativeBtcTokens.has(token.toLowerCase());
|
|
4279
|
+
}
|
|
4275
4280
|
function isSupportedBitcoinAddressType(addressType) {
|
|
4276
4281
|
return BTC_ADDRESS_TYPES.includes(addressType);
|
|
4277
4282
|
}
|
|
@@ -4431,7 +4436,7 @@ function isValidWalletProviderForChainKey(chainKey, walletProvider) {
|
|
|
4431
4436
|
}
|
|
4432
4437
|
|
|
4433
4438
|
// ../types/dist/index.js
|
|
4434
|
-
var CONFIG_VERSION =
|
|
4439
|
+
var CONFIG_VERSION = 222;
|
|
4435
4440
|
function isEvmSpokeChainConfig(value) {
|
|
4436
4441
|
return typeof value === "object" && value !== null && value.chain.type === "EVM" && value.chain.key !== HUB_CHAIN_KEY;
|
|
4437
4442
|
}
|
|
@@ -4542,6 +4547,9 @@ function isUndefinedOrValidWalletProviderForChainKey(chainKey, walletProvider) {
|
|
|
4542
4547
|
function isOptionalBitcoinWalletProviderType(walletProvider) {
|
|
4543
4548
|
return walletProvider === void 0 || isBitcoinWalletProviderType(walletProvider);
|
|
4544
4549
|
}
|
|
4550
|
+
function isNativeBitcoinTransfer(config, chainKey, token) {
|
|
4551
|
+
return isBitcoinChainKeyType(chainKey) && !!token && isNativeBitcoinToken(config.getChainConfig(chainKey), token.address);
|
|
4552
|
+
}
|
|
4545
4553
|
async function retry(action, retryCount = DEFAULT_MAX_RETRY, delayMs = DEFAULT_RETRY_DELAY_MS) {
|
|
4546
4554
|
do {
|
|
4547
4555
|
try {
|
|
@@ -4558,11 +4566,11 @@ async function retry(action, retryCount = DEFAULT_MAX_RETRY, delayMs = DEFAULT_R
|
|
|
4558
4566
|
throw new Error(`Retry exceeded MAX_RETRY_DEFAULT=${DEFAULT_MAX_RETRY}`);
|
|
4559
4567
|
}
|
|
4560
4568
|
function getRandomBytes(length) {
|
|
4561
|
-
const
|
|
4569
|
+
const array3 = new Uint8Array(length);
|
|
4562
4570
|
for (let i = 0; i < length; i++) {
|
|
4563
|
-
|
|
4571
|
+
array3[i] = Math.floor(Math.random() * 256);
|
|
4564
4572
|
}
|
|
4565
|
-
return
|
|
4573
|
+
return array3;
|
|
4566
4574
|
}
|
|
4567
4575
|
function randomUint256() {
|
|
4568
4576
|
const bytes = getRandomBytes(32);
|
|
@@ -4724,6 +4732,7 @@ var HttpRelayError = class extends Error {
|
|
|
4724
4732
|
}
|
|
4725
4733
|
};
|
|
4726
4734
|
var RELAY_REQUEST_TIMEOUT_MS = 15e3;
|
|
4735
|
+
var RELAY_FALLBACK_FLOOR_MS = 5e3;
|
|
4727
4736
|
function isAbortError(error) {
|
|
4728
4737
|
return error instanceof Error && error.name === "AbortError";
|
|
4729
4738
|
}
|
|
@@ -14022,6 +14031,13 @@ var ConfigService = class {
|
|
|
14022
14031
|
* a client-side option set via `new Sodax({ fee })`. Per-feature overrides live on the feature config.
|
|
14023
14032
|
*/
|
|
14024
14033
|
fee;
|
|
14034
|
+
/**
|
|
14035
|
+
* RadFi/Bound request signer. Resolved once at construction and kept independent of {@link sodax}
|
|
14036
|
+
* so that {@link initialize}'s dynamic-config swap never clobbers it. Read by `BitcoinSpokeService`
|
|
14037
|
+
* via `config.radfiSigner`; `undefined` unless the consumer passed `radfi.signRequest` to
|
|
14038
|
+
* `new Sodax(...)`. Holds the function reference only — never a credential.
|
|
14039
|
+
*/
|
|
14040
|
+
radfiSigner;
|
|
14025
14041
|
initialized = false;
|
|
14026
14042
|
// data structures for quick lookup
|
|
14027
14043
|
supportedHubAssetsSet;
|
|
@@ -14035,11 +14051,12 @@ var ConfigService = class {
|
|
|
14035
14051
|
hubAssetToXTokenMap;
|
|
14036
14052
|
// `api` / `userConfig` are accepted but unused while initialize()'s dynamic fetch is disabled
|
|
14037
14053
|
// (see TODO(config-v2) below); restore their assignments when re-enabling.
|
|
14038
|
-
constructor({ api, config, userConfig, logger, analytics, fee }) {
|
|
14054
|
+
constructor({ api, config, userConfig, logger, analytics, fee, radfiSigner }) {
|
|
14039
14055
|
this.sodax = config;
|
|
14040
14056
|
this.logger = logger ?? resolveLogger(void 0);
|
|
14041
14057
|
this.analytics = analytics ?? noopAnalytics;
|
|
14042
14058
|
this.fee = fee;
|
|
14059
|
+
this.radfiSigner = radfiSigner;
|
|
14043
14060
|
this.loadSodaxConfigDataStructures(config);
|
|
14044
14061
|
}
|
|
14045
14062
|
async initialize() {
|
|
@@ -14338,7 +14355,7 @@ function mergeSodaxConfig(base2, override) {
|
|
|
14338
14355
|
}
|
|
14339
14356
|
function encodeContractCalls(calls) {
|
|
14340
14357
|
return viem.encodeAbiParameters(viem.parseAbiParameters("(address,uint256,bytes)[]"), [
|
|
14341
|
-
calls.map((
|
|
14358
|
+
calls.map((v9) => [v9.address, v9.value, v9.data])
|
|
14342
14359
|
]);
|
|
14343
14360
|
}
|
|
14344
14361
|
async function waitForTransactionReceipt(hash, provider) {
|
|
@@ -15250,10 +15267,14 @@ var RadfiApiError = class extends Error {
|
|
|
15250
15267
|
};
|
|
15251
15268
|
var RadfiProvider = class {
|
|
15252
15269
|
config;
|
|
15270
|
+
// Client-side runtime signer (e.g. a backend's HMAC closure). Holds no credential itself — the SDK
|
|
15271
|
+
// only keeps the reference and invokes it per outbound `apiUrl` request. See `RadfiOptions` / gh-831.
|
|
15272
|
+
signer;
|
|
15253
15273
|
accessToken = "";
|
|
15254
15274
|
refreshToken = "";
|
|
15255
|
-
constructor(config) {
|
|
15275
|
+
constructor(config, options) {
|
|
15256
15276
|
this.config = config;
|
|
15277
|
+
this.signer = options?.signer;
|
|
15257
15278
|
this.accessToken = config.accessToken ?? "";
|
|
15258
15279
|
this.refreshToken = config.refreshToken ?? "";
|
|
15259
15280
|
if (config.apiUrl.endsWith("/")) {
|
|
@@ -15364,6 +15385,9 @@ var RadfiProvider = class {
|
|
|
15364
15385
|
}
|
|
15365
15386
|
return body.data;
|
|
15366
15387
|
}
|
|
15388
|
+
// UMS call: goes out unsigned even when a signer is configured. Bound scopes the backend
|
|
15389
|
+
// credential to the Sodax endpoints on `apiUrl`, so a signature here is unverified — this
|
|
15390
|
+
// deliberately does not go through `request()`. Same for `getExpiredUtxos` below. See gh-831.
|
|
15367
15391
|
async getBalance(address) {
|
|
15368
15392
|
if (!this.config.umsUrl) {
|
|
15369
15393
|
throw new Error("RadfiConfig.umsUrl is required for getBalance");
|
|
@@ -15441,6 +15465,9 @@ var RadfiProvider = class {
|
|
|
15441
15465
|
}
|
|
15442
15466
|
/**
|
|
15443
15467
|
* Fetch expired (or near-expiry) UTXOs for a trading wallet address from UMS API.
|
|
15468
|
+
*
|
|
15469
|
+
* UMS call — unsigned by design, like `getBalance`: the backend credential is scoped to the
|
|
15470
|
+
* Sodax endpoints on `apiUrl`, so a configured signer intentionally does not reach here.
|
|
15444
15471
|
*/
|
|
15445
15472
|
async getExpiredUtxos(tradingAddress, params) {
|
|
15446
15473
|
if (!this.config.umsUrl) {
|
|
@@ -15622,11 +15649,13 @@ var RadfiProvider = class {
|
|
|
15622
15649
|
}
|
|
15623
15650
|
}
|
|
15624
15651
|
async request(endpoint, options) {
|
|
15652
|
+
const signed = this.signer ? await this.signer({ method: options?.method ?? "GET", path: endpoint }) : void 0;
|
|
15625
15653
|
return fetch(`${this.config.apiUrl}${endpoint}`, {
|
|
15626
15654
|
...options,
|
|
15627
15655
|
headers: {
|
|
15628
15656
|
"Content-Type": "application/json",
|
|
15629
|
-
...options?.headers || {}
|
|
15657
|
+
...options?.headers || {},
|
|
15658
|
+
...signed
|
|
15630
15659
|
}
|
|
15631
15660
|
});
|
|
15632
15661
|
}
|
|
@@ -15689,7 +15718,7 @@ function normalizeSignatureToBase64(signature) {
|
|
|
15689
15718
|
// src/shared/services/spoke/BitcoinSpokeService.ts
|
|
15690
15719
|
bitcoinjsLib.initEccLib(ecc__namespace);
|
|
15691
15720
|
var BITCOIN_DEFAULT_FEE_RATE = 3;
|
|
15692
|
-
var DUST_THRESHOLD =
|
|
15721
|
+
var DUST_THRESHOLD = Number(BITCOIN_DUST_SATS);
|
|
15693
15722
|
var BitcoinSpokeService = class {
|
|
15694
15723
|
config;
|
|
15695
15724
|
rpcUrl;
|
|
@@ -15701,7 +15730,7 @@ var BitcoinSpokeService = class {
|
|
|
15701
15730
|
this.config = config;
|
|
15702
15731
|
const chainConfig = config.getChainConfig(ChainKeys.BITCOIN_MAINNET);
|
|
15703
15732
|
this.rpcUrl = chainConfig.rpcUrl;
|
|
15704
|
-
this.radfi = new RadfiProvider(chainConfig.radfi);
|
|
15733
|
+
this.radfi = new RadfiProvider(chainConfig.radfi, { signer: config.radfiSigner });
|
|
15705
15734
|
this.walletMode = chainConfig.radfi.walletMode ?? "TRADING";
|
|
15706
15735
|
this.pollingIntervalMs = chainConfig.pollingConfig.pollingIntervalMs;
|
|
15707
15736
|
this.maxTimeoutMs = chainConfig.pollingConfig.maxTimeoutMs;
|
|
@@ -16058,11 +16087,7 @@ var BitcoinSpokeService = class {
|
|
|
16058
16087
|
async buildDepositPsbt(walletAddress, walletProvider, srcChainKey, token, amount, data, utxos) {
|
|
16059
16088
|
const chainConfig = this.config.getChainConfig(srcChainKey);
|
|
16060
16089
|
const assetManagerAddress = chainConfig.addresses.assetManager;
|
|
16061
|
-
const
|
|
16062
|
-
const nativeBtcTokens = new Set(
|
|
16063
|
-
["btc", chainConfig.nativeToken, chainConfig.supportedTokens.BTC?.address].filter((value) => !!value).map((value) => value.toLocaleLowerCase())
|
|
16064
|
-
);
|
|
16065
|
-
const isNativeBtc = nativeBtcTokens.has(normalizedToken);
|
|
16090
|
+
const isNativeBtc = isNativeBitcoinToken(chainConfig, token);
|
|
16066
16091
|
if (isNativeBtc) {
|
|
16067
16092
|
const OP_RETURN = bitcoinjsLib.opcodes.OP_RETURN;
|
|
16068
16093
|
const OP_12 = bitcoinjsLib.opcodes.OP_12;
|
|
@@ -16321,7 +16346,7 @@ function hexToBytes2(hex) {
|
|
|
16321
16346
|
const al = hl / 2;
|
|
16322
16347
|
if (hl % 2)
|
|
16323
16348
|
throw new Error("hex string expected, got unpadded hex of length " + hl);
|
|
16324
|
-
const
|
|
16349
|
+
const array3 = new Uint8Array(al);
|
|
16325
16350
|
for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) {
|
|
16326
16351
|
const n1 = asciiToBase16(hex.charCodeAt(hi));
|
|
16327
16352
|
const n2 = asciiToBase16(hex.charCodeAt(hi + 1));
|
|
@@ -16329,9 +16354,9 @@ function hexToBytes2(hex) {
|
|
|
16329
16354
|
const char = hex[hi] + hex[hi + 1];
|
|
16330
16355
|
throw new Error('hex string expected, got non-hex character "' + char + '" at index ' + hi);
|
|
16331
16356
|
}
|
|
16332
|
-
|
|
16357
|
+
array3[ai] = n1 * 16 + n2;
|
|
16333
16358
|
}
|
|
16334
|
-
return
|
|
16359
|
+
return array3;
|
|
16335
16360
|
}
|
|
16336
16361
|
function concatBytes(...arrays) {
|
|
16337
16362
|
let sum = 0;
|
|
@@ -16961,22 +16986,22 @@ function createHmacDrbg(hashLen, qByteLen, hmacFn) {
|
|
|
16961
16986
|
const byte0 = Uint8Array.of(0);
|
|
16962
16987
|
const byte1 = Uint8Array.of(1);
|
|
16963
16988
|
const _maxDrbgIters = 1e3;
|
|
16964
|
-
let
|
|
16989
|
+
let v9 = u8n(hashLen);
|
|
16965
16990
|
let k = u8n(hashLen);
|
|
16966
16991
|
let i = 0;
|
|
16967
16992
|
const reset = () => {
|
|
16968
|
-
|
|
16993
|
+
v9.fill(1);
|
|
16969
16994
|
k.fill(0);
|
|
16970
16995
|
i = 0;
|
|
16971
16996
|
};
|
|
16972
|
-
const h = (...msgs) => hmacFn(k, concatBytes(
|
|
16997
|
+
const h = (...msgs) => hmacFn(k, concatBytes(v9, ...msgs));
|
|
16973
16998
|
const reseed = (seed = NULL) => {
|
|
16974
16999
|
k = h(byte0, seed);
|
|
16975
|
-
|
|
17000
|
+
v9 = h();
|
|
16976
17001
|
if (seed.length === 0)
|
|
16977
17002
|
return;
|
|
16978
17003
|
k = h(byte1, seed);
|
|
16979
|
-
|
|
17004
|
+
v9 = h();
|
|
16980
17005
|
};
|
|
16981
17006
|
const gen = () => {
|
|
16982
17007
|
if (i++ >= _maxDrbgIters)
|
|
@@ -16984,10 +17009,10 @@ function createHmacDrbg(hashLen, qByteLen, hmacFn) {
|
|
|
16984
17009
|
let len = 0;
|
|
16985
17010
|
const out = [];
|
|
16986
17011
|
while (len < qByteLen) {
|
|
16987
|
-
|
|
16988
|
-
const sl =
|
|
17012
|
+
v9 = h();
|
|
17013
|
+
const sl = v9.slice();
|
|
16989
17014
|
out.push(sl);
|
|
16990
|
-
len +=
|
|
17015
|
+
len += v9.length;
|
|
16991
17016
|
}
|
|
16992
17017
|
return concatBytes(...out);
|
|
16993
17018
|
};
|
|
@@ -17002,18 +17027,18 @@ function createHmacDrbg(hashLen, qByteLen, hmacFn) {
|
|
|
17002
17027
|
};
|
|
17003
17028
|
return genUntil;
|
|
17004
17029
|
}
|
|
17005
|
-
function validateObject(
|
|
17006
|
-
if (!
|
|
17030
|
+
function validateObject(object5, fields = {}, optFields = {}) {
|
|
17031
|
+
if (!object5 || typeof object5 !== "object")
|
|
17007
17032
|
throw new Error("expected valid options object");
|
|
17008
17033
|
function checkField(fieldName, expectedType, isOpt) {
|
|
17009
|
-
const val =
|
|
17034
|
+
const val = object5[fieldName];
|
|
17010
17035
|
if (isOpt && val === void 0)
|
|
17011
17036
|
return;
|
|
17012
17037
|
const current = typeof val;
|
|
17013
17038
|
if (current !== expectedType || val === null)
|
|
17014
17039
|
throw new Error(`param "${fieldName}" is invalid: expected ${expectedType}, got ${current}`);
|
|
17015
17040
|
}
|
|
17016
|
-
const iter = (f, isOpt) => Object.entries(f).forEach(([k,
|
|
17041
|
+
const iter = (f, isOpt) => Object.entries(f).forEach(([k, v9]) => checkField(k, v9, isOpt));
|
|
17017
17042
|
iter(fields, false);
|
|
17018
17043
|
iter(optFields, true);
|
|
17019
17044
|
}
|
|
@@ -17052,12 +17077,12 @@ function pow2(x, power, modulo) {
|
|
|
17052
17077
|
}
|
|
17053
17078
|
return res;
|
|
17054
17079
|
}
|
|
17055
|
-
function invert(
|
|
17056
|
-
if (
|
|
17080
|
+
function invert(number5, modulo) {
|
|
17081
|
+
if (number5 === _0n2)
|
|
17057
17082
|
throw new Error("invert: expected non-zero number");
|
|
17058
17083
|
if (modulo <= _0n2)
|
|
17059
17084
|
throw new Error("invert: expected positive modulus, got " + modulo);
|
|
17060
|
-
let a = mod(
|
|
17085
|
+
let a = mod(number5, modulo);
|
|
17061
17086
|
let b = modulo;
|
|
17062
17087
|
let x = _0n2, u = _1n2;
|
|
17063
17088
|
while (a !== _0n2) {
|
|
@@ -17084,9 +17109,9 @@ function sqrt3mod4(Fp, n) {
|
|
|
17084
17109
|
function sqrt5mod8(Fp, n) {
|
|
17085
17110
|
const p5div8 = (Fp.ORDER - _5n) / _8n;
|
|
17086
17111
|
const n2 = Fp.mul(n, _2n);
|
|
17087
|
-
const
|
|
17088
|
-
const nv = Fp.mul(n,
|
|
17089
|
-
const i = Fp.mul(Fp.mul(nv, _2n),
|
|
17112
|
+
const v9 = Fp.pow(n2, p5div8);
|
|
17113
|
+
const nv = Fp.mul(n, v9);
|
|
17114
|
+
const i = Fp.mul(Fp.mul(nv, _2n), v9);
|
|
17090
17115
|
const root = Fp.mul(nv, Fp.sub(i, Fp.ONE));
|
|
17091
17116
|
assertIsSquare(Fp, root, n);
|
|
17092
17117
|
return root;
|
|
@@ -17561,27 +17586,27 @@ var wNAF = class {
|
|
|
17561
17586
|
assert0(n);
|
|
17562
17587
|
return acc;
|
|
17563
17588
|
}
|
|
17564
|
-
getPrecomputes(W, point,
|
|
17589
|
+
getPrecomputes(W, point, transform2) {
|
|
17565
17590
|
let comp = pointPrecomputes.get(point);
|
|
17566
17591
|
if (!comp) {
|
|
17567
17592
|
comp = this.precomputeWindow(point, W);
|
|
17568
17593
|
if (W !== 1) {
|
|
17569
|
-
if (typeof
|
|
17570
|
-
comp =
|
|
17594
|
+
if (typeof transform2 === "function")
|
|
17595
|
+
comp = transform2(comp);
|
|
17571
17596
|
pointPrecomputes.set(point, comp);
|
|
17572
17597
|
}
|
|
17573
17598
|
}
|
|
17574
17599
|
return comp;
|
|
17575
17600
|
}
|
|
17576
|
-
cached(point, scalar,
|
|
17601
|
+
cached(point, scalar, transform2) {
|
|
17577
17602
|
const W = getW(point);
|
|
17578
|
-
return this.wNAF(W, this.getPrecomputes(W, point,
|
|
17603
|
+
return this.wNAF(W, this.getPrecomputes(W, point, transform2), scalar);
|
|
17579
17604
|
}
|
|
17580
|
-
unsafe(point, scalar,
|
|
17605
|
+
unsafe(point, scalar, transform2, prev) {
|
|
17581
17606
|
const W = getW(point);
|
|
17582
17607
|
if (W === 1)
|
|
17583
17608
|
return this._unsafeLadder(point, scalar, prev);
|
|
17584
|
-
return this.wNAFUnsafe(W, this.getPrecomputes(W, point,
|
|
17609
|
+
return this.wNAFUnsafe(W, this.getPrecomputes(W, point, transform2), scalar, prev);
|
|
17585
17610
|
}
|
|
17586
17611
|
// We calculate precomputes for elliptic curve point multiplication
|
|
17587
17612
|
// using windowed method. This specifies window size and
|
|
@@ -17668,9 +17693,9 @@ function edwards(params, extraOpts = {}) {
|
|
|
17668
17693
|
validateObject(extraOpts, {}, { uvRatio: "function" });
|
|
17669
17694
|
const MASK = _2n2 << BigInt(Fn.BYTES * 8) - _1n4;
|
|
17670
17695
|
const modP = (n) => Fp.create(n);
|
|
17671
|
-
const uvRatio2 = extraOpts.uvRatio || ((u,
|
|
17696
|
+
const uvRatio2 = extraOpts.uvRatio || ((u, v9) => {
|
|
17672
17697
|
try {
|
|
17673
|
-
return { isValid: true, value: Fp.sqrt(Fp.div(u,
|
|
17698
|
+
return { isValid: true, value: Fp.sqrt(Fp.div(u, v9)) };
|
|
17674
17699
|
} catch (e) {
|
|
17675
17700
|
return { isValid: false, value: _0n4 };
|
|
17676
17701
|
}
|
|
@@ -17766,8 +17791,8 @@ function edwards(params, extraOpts = {}) {
|
|
|
17766
17791
|
aInRange("point.y", y, _0n4, max);
|
|
17767
17792
|
const y2 = modP(y * y);
|
|
17768
17793
|
const u = modP(y2 - _1n4);
|
|
17769
|
-
const
|
|
17770
|
-
let { isValid, value: x } = uvRatio2(u,
|
|
17794
|
+
const v9 = modP(d * y2 - a);
|
|
17795
|
+
let { isValid, value: x } = uvRatio2(u, v9);
|
|
17771
17796
|
if (!isValid)
|
|
17772
17797
|
throw new Error("bad point: invalid y coordinate");
|
|
17773
17798
|
const isXOdd = (x & _1n4) === _1n4;
|
|
@@ -18107,13 +18132,13 @@ function adjustScalarBytes(bytes) {
|
|
|
18107
18132
|
return bytes;
|
|
18108
18133
|
}
|
|
18109
18134
|
var ED25519_SQRT_M1 = /* @__PURE__ */ BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");
|
|
18110
|
-
function uvRatio(u,
|
|
18135
|
+
function uvRatio(u, v9) {
|
|
18111
18136
|
const P = ed25519_CURVE_p;
|
|
18112
|
-
const v32 = mod(
|
|
18113
|
-
const
|
|
18114
|
-
const pow = ed25519_pow_2_252_3(u *
|
|
18137
|
+
const v32 = mod(v9 * v9 * v9, P);
|
|
18138
|
+
const v72 = mod(v32 * v32 * v9, P);
|
|
18139
|
+
const pow = ed25519_pow_2_252_3(u * v72).pow_p_5_8;
|
|
18115
18140
|
let x = mod(u * v32 * pow, P);
|
|
18116
|
-
const vx2 = mod(
|
|
18141
|
+
const vx2 = mod(v9 * x * x, P);
|
|
18117
18142
|
const root1 = x;
|
|
18118
18143
|
const root2 = mod(x * ED25519_SQRT_M1, P);
|
|
18119
18144
|
const useRoot1 = vx2 === u;
|
|
@@ -18444,7 +18469,7 @@ function findSeatPrice(validators, maxNumberOfSeats, minimumStakeRatio, protocol
|
|
|
18444
18469
|
return findSeatPriceForProtocolAfter49(validators, maxNumberOfSeats, minimumStakeRatio);
|
|
18445
18470
|
}
|
|
18446
18471
|
function findSeatPriceForProtocolBefore49(validators, numSeats) {
|
|
18447
|
-
const stakes = validators.map((
|
|
18472
|
+
const stakes = validators.map((v9) => BigInt(v9.stake)).sort(sortBigIntAsc);
|
|
18448
18473
|
const num = BigInt(numSeats);
|
|
18449
18474
|
const stakesSum = stakes.reduce((a, b) => a + b);
|
|
18450
18475
|
if (stakesSum < num) {
|
|
@@ -18473,7 +18498,7 @@ function findSeatPriceForProtocolAfter49(validators, maxNumberOfSeats, minimumSt
|
|
|
18473
18498
|
if (minimumStakeRatio.length != 2) {
|
|
18474
18499
|
throw Error("minimumStakeRatio should have 2 elements");
|
|
18475
18500
|
}
|
|
18476
|
-
const stakes = validators.map((
|
|
18501
|
+
const stakes = validators.map((v9) => BigInt(v9.stake)).sort(sortBigIntAsc);
|
|
18477
18502
|
const stakesSum = stakes.reduce((a, b) => a + b);
|
|
18478
18503
|
if (validators.length < maxNumberOfSeats) {
|
|
18479
18504
|
return stakesSum * BigInt(minimumStakeRatio[0]) / BigInt(minimumStakeRatio[1]);
|
|
@@ -18645,10 +18670,10 @@ var DER = {
|
|
|
18645
18670
|
if (length < 128)
|
|
18646
18671
|
throw new E("tlv.decode(long): not minimal encoding");
|
|
18647
18672
|
}
|
|
18648
|
-
const
|
|
18649
|
-
if (
|
|
18673
|
+
const v9 = data.subarray(pos, pos + length);
|
|
18674
|
+
if (v9.length !== length)
|
|
18650
18675
|
throw new E("tlv.decode: wrong value length");
|
|
18651
|
-
return { v:
|
|
18676
|
+
return { v: v9, l: data.subarray(pos + length) };
|
|
18652
18677
|
}
|
|
18653
18678
|
},
|
|
18654
18679
|
// https://crypto.stackexchange.com/a/57734 Leftmost bit of first byte is 'negative' flag,
|
|
@@ -19216,9 +19241,9 @@ function ecdsa(Point, hash, ecdsaOpts = {}) {
|
|
|
19216
19241
|
extraEntropy: false
|
|
19217
19242
|
};
|
|
19218
19243
|
const hasLargeCofactor = CURVE_ORDER * _2n4 < Fp.ORDER;
|
|
19219
|
-
function isBiggerThanHalfOrder(
|
|
19244
|
+
function isBiggerThanHalfOrder(number5) {
|
|
19220
19245
|
const HALF = CURVE_ORDER >> _1n6;
|
|
19221
|
-
return
|
|
19246
|
+
return number5 > HALF;
|
|
19222
19247
|
}
|
|
19223
19248
|
function validateRS(title, num) {
|
|
19224
19249
|
if (!Fn.isValidNot0(num))
|
|
@@ -19401,8 +19426,8 @@ function ecdsa(Point, hash, ecdsaOpts = {}) {
|
|
|
19401
19426
|
const R = Point.BASE.multiplyUnsafe(u1).add(P.multiplyUnsafe(u2));
|
|
19402
19427
|
if (R.is0())
|
|
19403
19428
|
return false;
|
|
19404
|
-
const
|
|
19405
|
-
return
|
|
19429
|
+
const v9 = Fn.create(R.x);
|
|
19430
|
+
return v9 === r;
|
|
19406
19431
|
} catch (e) {
|
|
19407
19432
|
return false;
|
|
19408
19433
|
}
|
|
@@ -26696,6 +26721,36 @@ var SolverApiService = class {
|
|
|
26696
26721
|
}
|
|
26697
26722
|
}
|
|
26698
26723
|
};
|
|
26724
|
+
|
|
26725
|
+
// src/backendApi/pollBackendSubmitTx.ts
|
|
26726
|
+
async function pollBackendSubmitTx({
|
|
26727
|
+
deadline,
|
|
26728
|
+
terminalStatus,
|
|
26729
|
+
getStatus,
|
|
26730
|
+
onExecuted,
|
|
26731
|
+
intervalMs = 1e3,
|
|
26732
|
+
requestTimeoutMs
|
|
26733
|
+
}) {
|
|
26734
|
+
const reserveMs = Math.min(Math.ceil((deadline - Date.now()) / 3), 2e4);
|
|
26735
|
+
const pollDeadline = deadline - reserveMs;
|
|
26736
|
+
const requestOverride = () => requestTimeoutMs === void 0 ? void 0 : { timeout: Math.min(pollDeadline - Date.now(), requestTimeoutMs) };
|
|
26737
|
+
while (Date.now() < pollDeadline) {
|
|
26738
|
+
const statusResult = await getStatus(requestOverride());
|
|
26739
|
+
if (statusResult.ok) {
|
|
26740
|
+
const { status, result, failureReason, abandonedAt } = statusResult.value.data;
|
|
26741
|
+
if (status === terminalStatus) {
|
|
26742
|
+
const value = onExecuted(result);
|
|
26743
|
+
if (value !== void 0) return { ok: true, value };
|
|
26744
|
+
}
|
|
26745
|
+
if (status === "failed" || abandonedAt) {
|
|
26746
|
+
const reason = failureReason ? `: ${failureReason}` : "";
|
|
26747
|
+
return { ok: false, cause: new Error(`backend submit-tx ${status}${reason}`) };
|
|
26748
|
+
}
|
|
26749
|
+
}
|
|
26750
|
+
await new Promise((resolve) => setTimeout(resolve, Math.min(intervalMs, pollDeadline - Date.now())));
|
|
26751
|
+
}
|
|
26752
|
+
return { ok: false, cause: new Error(`backend submit-tx polling timed out before reaching ${terminalStatus}`) };
|
|
26753
|
+
}
|
|
26699
26754
|
function decodePacketIntentTarget(payload) {
|
|
26700
26755
|
try {
|
|
26701
26756
|
const hex = payload.startsWith("0x") ? payload.slice(2) : payload;
|
|
@@ -27018,7 +27073,7 @@ var SwapService = class {
|
|
|
27018
27073
|
relayerApiEndpoint: this.relayerApiEndpoint,
|
|
27019
27074
|
// Remaining shared budget: ≈ full `timeout` on the flag-off path (called immediately), or
|
|
27020
27075
|
// the reserve `submitTx` left on the backend path. Floor keeps a stalled-backend fallback viable.
|
|
27021
|
-
timeout: Math.max(deadline - Date.now(),
|
|
27076
|
+
timeout: Math.max(deadline - Date.now(), RELAY_FALLBACK_FLOOR_MS)
|
|
27022
27077
|
});
|
|
27023
27078
|
if (!packet.ok) {
|
|
27024
27079
|
return { ok: false, error: mapRelayFailure(packet.error, { feature: "swap", action: "swap", ...baseCtx }) };
|
|
@@ -27080,39 +27135,26 @@ var SwapService = class {
|
|
|
27080
27135
|
relayData: relayData.payload
|
|
27081
27136
|
});
|
|
27082
27137
|
if (!submitted.ok) return submitTxFailed(submitted.error);
|
|
27083
|
-
const
|
|
27084
|
-
|
|
27085
|
-
|
|
27086
|
-
|
|
27087
|
-
|
|
27088
|
-
|
|
27089
|
-
|
|
27090
|
-
|
|
27091
|
-
|
|
27092
|
-
|
|
27093
|
-
|
|
27094
|
-
|
|
27095
|
-
|
|
27096
|
-
|
|
27097
|
-
|
|
27098
|
-
|
|
27099
|
-
srcTxHash: spokeTxHash,
|
|
27100
|
-
srcAddress: params.srcAddress,
|
|
27101
|
-
dstChainKey: params.dstChainKey,
|
|
27102
|
-
dstTxHash: result.dstIntentTxHash,
|
|
27103
|
-
dstAddress: params.dstAddress
|
|
27104
|
-
}
|
|
27105
|
-
}
|
|
27106
|
-
};
|
|
27107
|
-
}
|
|
27108
|
-
if (status === "failed" || abandonedAt) {
|
|
27109
|
-
const reason = failureReason ? `: ${failureReason}` : "";
|
|
27110
|
-
return submitTxFailed(new Error(`backend submit-tx ${status}${reason}`));
|
|
27138
|
+
const polled = await pollBackendSubmitTx({
|
|
27139
|
+
deadline,
|
|
27140
|
+
// Swaps terminal success is `solved` (solver filled) — not the bridge `executed`.
|
|
27141
|
+
terminalStatus: "solved",
|
|
27142
|
+
getStatus: () => this.backendApi.swaps.getSubmitTxStatus({ txHash: spokeTxHash, srcChainKey }),
|
|
27143
|
+
onExecuted: (result) => result?.dstIntentTxHash && result.intent_hash ? {
|
|
27144
|
+
// Backend serializes the hex intent_hash as a plain string; brand it at the boundary.
|
|
27145
|
+
solverExecutionResponse: { answer: "OK", intent_hash: result.intent_hash },
|
|
27146
|
+
intent,
|
|
27147
|
+
intentDeliveryInfo: {
|
|
27148
|
+
srcChainKey,
|
|
27149
|
+
srcTxHash: spokeTxHash,
|
|
27150
|
+
srcAddress: params.srcAddress,
|
|
27151
|
+
dstChainKey: params.dstChainKey,
|
|
27152
|
+
dstTxHash: result.dstIntentTxHash,
|
|
27153
|
+
dstAddress: params.dstAddress
|
|
27111
27154
|
}
|
|
27112
|
-
}
|
|
27113
|
-
|
|
27114
|
-
}
|
|
27115
|
-
return submitTxFailed(new Error("backend submit-tx polling timed out before reaching solved"));
|
|
27155
|
+
} : void 0
|
|
27156
|
+
});
|
|
27157
|
+
return polled.ok ? { ok: true, value: polled.value } : submitTxFailed(polled.cause);
|
|
27116
27158
|
} catch (error) {
|
|
27117
27159
|
return { ok: false, error: unknownFailed("swap", error, { ...baseCtx, action: "swap" }) };
|
|
27118
27160
|
}
|
|
@@ -27304,10 +27346,19 @@ var SwapService = class {
|
|
|
27304
27346
|
`Invalid spoke chain (params.dstChain): ${params.dstChainKey}`,
|
|
27305
27347
|
{ ...baseCtx, field: "dstChainKey" }
|
|
27306
27348
|
);
|
|
27307
|
-
|
|
27349
|
+
const inputTokenInfo = this.config.getSpokeTokenFromOriginalAssetAddress(params.srcChainKey, params.inputToken);
|
|
27350
|
+
if (isNativeBitcoinTransfer(this.config, params.srcChainKey, inputTokenInfo)) {
|
|
27308
27351
|
swapInvariant(
|
|
27309
|
-
params.
|
|
27310
|
-
`Invalid
|
|
27352
|
+
params.inputAmount >= BITCOIN_DUST_SATS,
|
|
27353
|
+
`Invalid inputAmount (${params.inputAmount}): below the Bitcoin dust limit of ${BITCOIN_DUST_SATS} sats`,
|
|
27354
|
+
{ ...baseCtx, field: "inputAmount" }
|
|
27355
|
+
);
|
|
27356
|
+
}
|
|
27357
|
+
const outputTokenInfo = this.config.getSpokeTokenFromOriginalAssetAddress(params.dstChainKey, params.outputToken);
|
|
27358
|
+
if (isNativeBitcoinTransfer(this.config, params.dstChainKey, outputTokenInfo)) {
|
|
27359
|
+
swapInvariant(
|
|
27360
|
+
params.minOutputAmount >= BITCOIN_DUST_SATS,
|
|
27361
|
+
`Invalid minOutputAmount (${params.minOutputAmount}): below the Bitcoin dust limit of ${BITCOIN_DUST_SATS} sats`,
|
|
27311
27362
|
{ ...baseCtx, field: "minOutputAmount" }
|
|
27312
27363
|
);
|
|
27313
27364
|
}
|
|
@@ -29876,6 +29927,7 @@ function trimTrailingSlashes(baseURL) {
|
|
|
29876
29927
|
while (end > 0 && baseURL[end - 1] === "/") end -= 1;
|
|
29877
29928
|
return baseURL.slice(0, end);
|
|
29878
29929
|
}
|
|
29930
|
+
var toJsonBody = (value) => JSON.stringify(value, (_key, val) => typeof val === "bigint" ? val.toString() : val);
|
|
29879
29931
|
async function makeRequest(params) {
|
|
29880
29932
|
const { endpoint, config, overrideConfig = {}, logger, serviceLabel } = params;
|
|
29881
29933
|
const baseURL = overrideConfig.baseURL || config.baseURL || "";
|
|
@@ -29982,7 +30034,7 @@ var SwapsApiService = class _SwapsApiService {
|
|
|
29982
30034
|
if (error.code === "VALIDATION_ERROR" && error.context.issues !== void 0) {
|
|
29983
30035
|
context.reason = "invalid_response_shape";
|
|
29984
30036
|
const issues = error.context.issues;
|
|
29985
|
-
context.issues = issues instanceof
|
|
30037
|
+
context.issues = issues instanceof v7__namespace.ValiError ? v7__namespace.flatten(issues.issues) : issues;
|
|
29986
30038
|
}
|
|
29987
30039
|
if (error.context.status !== void 0) context.status = error.context.status;
|
|
29988
30040
|
}
|
|
@@ -30143,21 +30195,21 @@ var SwapsApiService = class _SwapsApiService {
|
|
|
30143
30195
|
return this.config.baseURL;
|
|
30144
30196
|
}
|
|
30145
30197
|
};
|
|
30146
|
-
var StellarSponsorConfigSchema =
|
|
30147
|
-
sponsorAccount:
|
|
30148
|
-
networkPassphrase:
|
|
30149
|
-
minTotalFeeStroops:
|
|
30150
|
-
maxTotalFeeStroops:
|
|
30151
|
-
operationCount:
|
|
30152
|
-
minPerOperationFeeStroops:
|
|
30153
|
-
maxPerOperationFeeStroops:
|
|
30154
|
-
recommendedPerOperationFeeStroops:
|
|
30155
|
-
maxTimeboundSeconds:
|
|
30156
|
-
requiredStartingBalance:
|
|
30198
|
+
var StellarSponsorConfigSchema = v7__namespace.object({
|
|
30199
|
+
sponsorAccount: v7__namespace.string(),
|
|
30200
|
+
networkPassphrase: v7__namespace.string(),
|
|
30201
|
+
minTotalFeeStroops: v7__namespace.string(),
|
|
30202
|
+
maxTotalFeeStroops: v7__namespace.string(),
|
|
30203
|
+
operationCount: v7__namespace.number(),
|
|
30204
|
+
minPerOperationFeeStroops: v7__namespace.string(),
|
|
30205
|
+
maxPerOperationFeeStroops: v7__namespace.string(),
|
|
30206
|
+
recommendedPerOperationFeeStroops: v7__namespace.string(),
|
|
30207
|
+
maxTimeboundSeconds: v7__namespace.number(),
|
|
30208
|
+
requiredStartingBalance: v7__namespace.string()
|
|
30157
30209
|
});
|
|
30158
|
-
var StellarSponsoredAccountResponseSchema =
|
|
30159
|
-
|
|
30160
|
-
|
|
30210
|
+
var StellarSponsoredAccountResponseSchema = v7__namespace.variant("alreadyActive", [
|
|
30211
|
+
v7__namespace.object({ hash: v7__namespace.string(), alreadyActive: v7__namespace.literal(false) }),
|
|
30212
|
+
v7__namespace.object({ hash: v7__namespace.null(), alreadyActive: v7__namespace.literal(true) })
|
|
30161
30213
|
]);
|
|
30162
30214
|
|
|
30163
30215
|
// src/backendApi/SponsoringApiService.ts
|
|
@@ -30185,7 +30237,7 @@ var SponsoringApiService = class {
|
|
|
30185
30237
|
logger: this.logger,
|
|
30186
30238
|
serviceLabel: "SponsoringApiService"
|
|
30187
30239
|
});
|
|
30188
|
-
const parsed =
|
|
30240
|
+
const parsed = v7__namespace.safeParse(schema, raw);
|
|
30189
30241
|
if (!parsed.success) {
|
|
30190
30242
|
return {
|
|
30191
30243
|
ok: false,
|
|
@@ -30193,7 +30245,7 @@ var SponsoringApiService = class {
|
|
|
30193
30245
|
api: "sponsoring",
|
|
30194
30246
|
feature: "backend",
|
|
30195
30247
|
endpoint,
|
|
30196
|
-
issues:
|
|
30248
|
+
issues: v7__namespace.flatten(parsed.issues)
|
|
30197
30249
|
})
|
|
30198
30250
|
};
|
|
30199
30251
|
}
|
|
@@ -30231,6 +30283,411 @@ var SponsoringApiService = class {
|
|
|
30231
30283
|
return this.config.baseURL;
|
|
30232
30284
|
}
|
|
30233
30285
|
};
|
|
30286
|
+
var RelayExtraDataResponseSchema = v7__namespace.object({
|
|
30287
|
+
address: v7__namespace.string(),
|
|
30288
|
+
payload: v7__namespace.string()
|
|
30289
|
+
});
|
|
30290
|
+
var BridgeTokenSchema = v7__namespace.object({
|
|
30291
|
+
symbol: v7__namespace.string(),
|
|
30292
|
+
name: v7__namespace.string(),
|
|
30293
|
+
decimals: v7__namespace.number(),
|
|
30294
|
+
address: v7__namespace.string(),
|
|
30295
|
+
chainKey: v7__namespace.string(),
|
|
30296
|
+
hubAsset: v7__namespace.string(),
|
|
30297
|
+
vault: v7__namespace.string()
|
|
30298
|
+
});
|
|
30299
|
+
var BridgeTokensResponseSchema = v7__namespace.record(v7__namespace.string(), v7__namespace.array(BridgeTokenSchema));
|
|
30300
|
+
var BridgeTokensByChainResponseSchema = v7__namespace.array(BridgeTokenSchema);
|
|
30301
|
+
var BridgeAllowanceCheckResponseSchema = v7__namespace.object({
|
|
30302
|
+
valid: v7__namespace.boolean()
|
|
30303
|
+
});
|
|
30304
|
+
var makeBridgeApproveResponseSchema = (txSchema) => v7__namespace.object({ tx: txSchema });
|
|
30305
|
+
var makeCreateBridgeIntentResponseSchema = (txSchema) => v7__namespace.object({
|
|
30306
|
+
tx: txSchema,
|
|
30307
|
+
relayData: RelayExtraDataResponseSchema
|
|
30308
|
+
});
|
|
30309
|
+
var BridgeSubmitTxResponseSchema = v7__namespace.object({
|
|
30310
|
+
success: v7__namespace.boolean(),
|
|
30311
|
+
data: v7__namespace.object({
|
|
30312
|
+
status: v7__namespace.picklist(["inserted", "duplicate"]),
|
|
30313
|
+
message: v7__namespace.string()
|
|
30314
|
+
})
|
|
30315
|
+
});
|
|
30316
|
+
var BridgePacketDataSchema = v7__namespace.object({
|
|
30317
|
+
src_chain_id: v7__namespace.number(),
|
|
30318
|
+
src_tx_hash: v7__namespace.string(),
|
|
30319
|
+
src_address: v7__namespace.string(),
|
|
30320
|
+
status: v7__namespace.picklist(["pending", "validating", "executing", "executed"]),
|
|
30321
|
+
dst_chain_id: v7__namespace.number(),
|
|
30322
|
+
conn_sn: v7__namespace.number(),
|
|
30323
|
+
dst_address: v7__namespace.string(),
|
|
30324
|
+
dst_tx_hash: v7__namespace.string(),
|
|
30325
|
+
signatures: v7__namespace.array(v7__namespace.string()),
|
|
30326
|
+
payload: v7__namespace.string()
|
|
30327
|
+
});
|
|
30328
|
+
var BridgeSubmitTxStatusResultSchema = v7__namespace.object({
|
|
30329
|
+
dstIntentTxHash: v7__namespace.string(),
|
|
30330
|
+
packetData: v7__namespace.optional(BridgePacketDataSchema)
|
|
30331
|
+
});
|
|
30332
|
+
var BridgeSubmitTxStatusDataSchema = v7__namespace.object({
|
|
30333
|
+
txHash: v7__namespace.string(),
|
|
30334
|
+
srcChainKey: v7__namespace.string(),
|
|
30335
|
+
status: v7__namespace.string(),
|
|
30336
|
+
failedAtStep: v7__namespace.optional(v7__namespace.string()),
|
|
30337
|
+
failureReason: v7__namespace.optional(v7__namespace.string()),
|
|
30338
|
+
processingAttempts: v7__namespace.number(),
|
|
30339
|
+
abandonedAt: v7__namespace.optional(v7__namespace.string()),
|
|
30340
|
+
result: v7__namespace.optional(BridgeSubmitTxStatusResultSchema),
|
|
30341
|
+
userMessage: v7__namespace.optional(v7__namespace.string())
|
|
30342
|
+
});
|
|
30343
|
+
var BridgeSubmitTxStatusResponseSchema = v7__namespace.object({
|
|
30344
|
+
success: v7__namespace.boolean(),
|
|
30345
|
+
data: BridgeSubmitTxStatusDataSchema
|
|
30346
|
+
});
|
|
30347
|
+
var BridgeFeeResponseSchema = v7__namespace.object({ fee: v7__namespace.string() });
|
|
30348
|
+
var BridgeLimitSchema = v7__namespace.object({
|
|
30349
|
+
amount: v7__namespace.string(),
|
|
30350
|
+
decimals: v7__namespace.number(),
|
|
30351
|
+
type: v7__namespace.picklist(["DEPOSIT_LIMIT", "WITHDRAWAL_LIMIT"])
|
|
30352
|
+
});
|
|
30353
|
+
var BridgeableAmountResponseSchema = v7__namespace.object({ limit: BridgeLimitSchema });
|
|
30354
|
+
var BridgeableCheckResponseSchema = v7__namespace.object({ bridgeable: v7__namespace.boolean() });
|
|
30355
|
+
var AddressSchema = v7__namespace.custom((input) => typeof input === "string");
|
|
30356
|
+
var HexSchema = v7__namespace.custom((input) => typeof input === "string");
|
|
30357
|
+
var BigintFromString = v7__namespace.pipe(v7__namespace.string(), v7__namespace.toBigint());
|
|
30358
|
+
var BytesFromIndexRecord = v7__namespace.pipe(
|
|
30359
|
+
v7__namespace.record(v7__namespace.string(), v7__namespace.number()),
|
|
30360
|
+
v7__namespace.transform((indexed) => Uint8Array.from(Object.values(indexed)))
|
|
30361
|
+
);
|
|
30362
|
+
var EvmRawTxSchema = v7__namespace.object({
|
|
30363
|
+
from: AddressSchema,
|
|
30364
|
+
to: AddressSchema,
|
|
30365
|
+
value: BigintFromString,
|
|
30366
|
+
data: HexSchema
|
|
30367
|
+
});
|
|
30368
|
+
var SolanaRawTxSchema = v7__namespace.object({
|
|
30369
|
+
from: v7__namespace.string(),
|
|
30370
|
+
to: v7__namespace.string(),
|
|
30371
|
+
value: BigintFromString,
|
|
30372
|
+
data: v7__namespace.string()
|
|
30373
|
+
});
|
|
30374
|
+
var SuiRawTxSchema = v7__namespace.object({
|
|
30375
|
+
from: HexSchema,
|
|
30376
|
+
to: v7__namespace.string(),
|
|
30377
|
+
value: BigintFromString,
|
|
30378
|
+
data: v7__namespace.string()
|
|
30379
|
+
});
|
|
30380
|
+
var StellarRawTxSchema = v7__namespace.object({
|
|
30381
|
+
from: v7__namespace.string(),
|
|
30382
|
+
to: v7__namespace.string(),
|
|
30383
|
+
value: BigintFromString,
|
|
30384
|
+
data: v7__namespace.string()
|
|
30385
|
+
});
|
|
30386
|
+
var BitcoinRawTxSchema = v7__namespace.object({
|
|
30387
|
+
from: v7__namespace.string(),
|
|
30388
|
+
to: v7__namespace.string(),
|
|
30389
|
+
value: BigintFromString,
|
|
30390
|
+
data: v7__namespace.string()
|
|
30391
|
+
});
|
|
30392
|
+
var InjectiveRawTxSchema = v7__namespace.object({
|
|
30393
|
+
from: HexSchema,
|
|
30394
|
+
to: HexSchema,
|
|
30395
|
+
signedDoc: v7__namespace.object({
|
|
30396
|
+
bodyBytes: BytesFromIndexRecord,
|
|
30397
|
+
authInfoBytes: BytesFromIndexRecord,
|
|
30398
|
+
chainId: v7__namespace.string(),
|
|
30399
|
+
accountNumber: BigintFromString
|
|
30400
|
+
})
|
|
30401
|
+
});
|
|
30402
|
+
var NearRawTxSchema = v7__namespace.object({
|
|
30403
|
+
signerId: v7__namespace.string(),
|
|
30404
|
+
params: v7__namespace.object({
|
|
30405
|
+
contractId: v7__namespace.string(),
|
|
30406
|
+
method: v7__namespace.string(),
|
|
30407
|
+
args: v7__namespace.custom((input) => typeof input === "object" && input !== null),
|
|
30408
|
+
gas: v7__namespace.optional(BigintFromString),
|
|
30409
|
+
deposit: v7__namespace.optional(BigintFromString)
|
|
30410
|
+
})
|
|
30411
|
+
});
|
|
30412
|
+
var IconRawTxSchema = v7__namespace.record(
|
|
30413
|
+
v7__namespace.string(),
|
|
30414
|
+
v7__namespace.union([v7__namespace.string(), v7__namespace.custom((input) => typeof input === "object" && input !== null)])
|
|
30415
|
+
);
|
|
30416
|
+
var StacksRawTxSchema = v7__namespace.object({
|
|
30417
|
+
payload: v7__namespace.string(),
|
|
30418
|
+
estimatedLength: v7__namespace.optional(v7__namespace.number())
|
|
30419
|
+
});
|
|
30420
|
+
var AnyRawTxSchema = v7__namespace.custom((input) => typeof input === "object" && input !== null);
|
|
30421
|
+
function rawTxSchemaForChainKey(chainKey) {
|
|
30422
|
+
let chainType;
|
|
30423
|
+
try {
|
|
30424
|
+
chainType = getChainType(chainKey);
|
|
30425
|
+
} catch {
|
|
30426
|
+
chainType = void 0;
|
|
30427
|
+
}
|
|
30428
|
+
switch (chainType) {
|
|
30429
|
+
case "EVM":
|
|
30430
|
+
return EvmRawTxSchema;
|
|
30431
|
+
case "SOLANA":
|
|
30432
|
+
return SolanaRawTxSchema;
|
|
30433
|
+
case "SUI":
|
|
30434
|
+
return SuiRawTxSchema;
|
|
30435
|
+
case "STELLAR":
|
|
30436
|
+
return StellarRawTxSchema;
|
|
30437
|
+
case "INJECTIVE":
|
|
30438
|
+
return InjectiveRawTxSchema;
|
|
30439
|
+
case "ICON":
|
|
30440
|
+
return IconRawTxSchema;
|
|
30441
|
+
case "STACKS":
|
|
30442
|
+
return StacksRawTxSchema;
|
|
30443
|
+
case "NEAR":
|
|
30444
|
+
return NearRawTxSchema;
|
|
30445
|
+
case "BITCOIN":
|
|
30446
|
+
return BitcoinRawTxSchema;
|
|
30447
|
+
default:
|
|
30448
|
+
return AnyRawTxSchema;
|
|
30449
|
+
}
|
|
30450
|
+
}
|
|
30451
|
+
|
|
30452
|
+
// src/backendApi/BridgeApiService.ts
|
|
30453
|
+
function toCreateBridgeIntentParamsV2(params, extras) {
|
|
30454
|
+
return {
|
|
30455
|
+
srcChainKey: params.srcChainKey,
|
|
30456
|
+
dstChainKey: params.dstChainKey,
|
|
30457
|
+
inputToken: params.srcToken,
|
|
30458
|
+
outputToken: params.dstToken,
|
|
30459
|
+
inputAmount: params.amount.toString(),
|
|
30460
|
+
srcAddress: params.srcAddress,
|
|
30461
|
+
dstAddress: params.recipient,
|
|
30462
|
+
...extras?.srcPublicKey !== void 0 ? { srcPublicKey: extras.srcPublicKey } : {},
|
|
30463
|
+
...extras?.bound !== void 0 ? { bound: extras.bound } : {},
|
|
30464
|
+
...extras?.partnerFee !== void 0 ? { partnerFee: extras.partnerFee } : {}
|
|
30465
|
+
};
|
|
30466
|
+
}
|
|
30467
|
+
var BridgeApiService = class {
|
|
30468
|
+
// Fully-resolved bridge-API config supplied by the caller (BackendApiService resolves the
|
|
30469
|
+
// `ApiConfig` union via `resolveBridgeApiConfig`); this service does not resolve the union.
|
|
30470
|
+
config;
|
|
30471
|
+
headers;
|
|
30472
|
+
logger;
|
|
30473
|
+
constructor(config, logger = consoleLogger) {
|
|
30474
|
+
this.config = config;
|
|
30475
|
+
this.headers = { ...config.headers };
|
|
30476
|
+
this.logger = logger;
|
|
30477
|
+
}
|
|
30478
|
+
/**
|
|
30479
|
+
* Issues a single HTTP request, validates the JSON body against `schema`, and
|
|
30480
|
+
* wraps the result in `Result<T>`. The service-level `baseURL`/`timeout`/
|
|
30481
|
+
* `headers` are merged with the optional per-call `overrideConfig` (which takes
|
|
30482
|
+
* precedence) inside {@link makeRequest}. Every public method delegates here.
|
|
30483
|
+
*/
|
|
30484
|
+
async request(endpoint, config, schema, overrideConfig) {
|
|
30485
|
+
try {
|
|
30486
|
+
const raw = await makeRequest({
|
|
30487
|
+
endpoint,
|
|
30488
|
+
config: { baseURL: this.config.baseURL, timeout: this.config.timeout, headers: this.headers, ...config },
|
|
30489
|
+
overrideConfig,
|
|
30490
|
+
logger: this.logger,
|
|
30491
|
+
serviceLabel: "BridgeApiService"
|
|
30492
|
+
});
|
|
30493
|
+
const parsed = v7__namespace.safeParse(schema, raw);
|
|
30494
|
+
if (!parsed.success) {
|
|
30495
|
+
return {
|
|
30496
|
+
ok: false,
|
|
30497
|
+
error: new SodaxError("EXTERNAL_API_ERROR", `Invalid response shape from bridge API for ${endpoint}`, {
|
|
30498
|
+
feature: "backend",
|
|
30499
|
+
context: { api: "bridge", endpoint, reason: "invalid_response_shape", issues: v7__namespace.flatten(parsed.issues) }
|
|
30500
|
+
})
|
|
30501
|
+
};
|
|
30502
|
+
}
|
|
30503
|
+
return { ok: true, value: parsed.output };
|
|
30504
|
+
} catch (error) {
|
|
30505
|
+
return {
|
|
30506
|
+
ok: false,
|
|
30507
|
+
error: new SodaxError(
|
|
30508
|
+
"EXTERNAL_API_ERROR",
|
|
30509
|
+
error instanceof Error ? error.message : `Request to ${endpoint} failed`,
|
|
30510
|
+
{
|
|
30511
|
+
feature: "backend",
|
|
30512
|
+
cause: error,
|
|
30513
|
+
context: { api: "bridge", endpoint }
|
|
30514
|
+
}
|
|
30515
|
+
)
|
|
30516
|
+
};
|
|
30517
|
+
}
|
|
30518
|
+
}
|
|
30519
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
30520
|
+
// Tokens
|
|
30521
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
30522
|
+
/**
|
|
30523
|
+
* Fetch all supported bridge tokens grouped by SpokeChainKey.
|
|
30524
|
+
*
|
|
30525
|
+
* @returns `Result<GetBridgeTokensResponseV2>` — map of chain key → token list.
|
|
30526
|
+
*/
|
|
30527
|
+
async getTokens(config) {
|
|
30528
|
+
return this.request("/bridge/tokens", { method: "GET" }, BridgeTokensResponseSchema, config);
|
|
30529
|
+
}
|
|
30530
|
+
/**
|
|
30531
|
+
* Fetch supported bridge tokens for a single SpokeChainKey.
|
|
30532
|
+
*
|
|
30533
|
+
* @param chainKey - SODAX SpokeChainKey (e.g. `0xa4b1.arbitrum`, `solana`).
|
|
30534
|
+
* @returns `Result<GetBridgeTokensByChainResponseV2>` — token list for the chain.
|
|
30535
|
+
*/
|
|
30536
|
+
async getTokensByChain(chainKey, config) {
|
|
30537
|
+
return this.request(
|
|
30538
|
+
`/bridge/tokens/${chainKey}`,
|
|
30539
|
+
{ method: "GET" },
|
|
30540
|
+
BridgeTokensByChainResponseSchema,
|
|
30541
|
+
config
|
|
30542
|
+
);
|
|
30543
|
+
}
|
|
30544
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
30545
|
+
// Allowance · approve · create intent
|
|
30546
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
30547
|
+
/**
|
|
30548
|
+
* Check whether the source token allowance is already sufficient for the bridge.
|
|
30549
|
+
*
|
|
30550
|
+
* @returns `Result<BridgeAllowanceCheckResponseV2>` — `{ valid }`.
|
|
30551
|
+
*/
|
|
30552
|
+
async checkAllowance(body, config) {
|
|
30553
|
+
return this.request(
|
|
30554
|
+
"/bridge/allowance/check",
|
|
30555
|
+
{ method: "POST", body: toJsonBody(body) },
|
|
30556
|
+
BridgeAllowanceCheckResponseSchema,
|
|
30557
|
+
config
|
|
30558
|
+
);
|
|
30559
|
+
}
|
|
30560
|
+
/**
|
|
30561
|
+
* Build an unsigned token-approval transaction for the source token.
|
|
30562
|
+
*
|
|
30563
|
+
* @returns `Result<BridgeApproveResponseV2>` — `{ tx }` (chain-specific unsigned tx).
|
|
30564
|
+
*/
|
|
30565
|
+
async approve(body, config) {
|
|
30566
|
+
const txSchema = rawTxSchemaForChainKey(body.srcChainKey);
|
|
30567
|
+
return this.request(
|
|
30568
|
+
"/bridge/approve",
|
|
30569
|
+
{ method: "POST", body: toJsonBody(body) },
|
|
30570
|
+
makeBridgeApproveResponseSchema(txSchema),
|
|
30571
|
+
config
|
|
30572
|
+
);
|
|
30573
|
+
}
|
|
30574
|
+
/**
|
|
30575
|
+
* Build an unsigned spoke-deposit (create-bridge-intent) transaction.
|
|
30576
|
+
*
|
|
30577
|
+
* @returns `Result<CreateBridgeIntentResponseV2>` — `{ tx, relayData }` (no intent struct).
|
|
30578
|
+
*/
|
|
30579
|
+
async createBridgeIntent(body, config) {
|
|
30580
|
+
const txSchema = rawTxSchemaForChainKey(body.srcChainKey);
|
|
30581
|
+
return this.request(
|
|
30582
|
+
"/bridge/intents",
|
|
30583
|
+
{ method: "POST", body: toJsonBody(body) },
|
|
30584
|
+
makeCreateBridgeIntentResponseSchema(txSchema),
|
|
30585
|
+
config
|
|
30586
|
+
);
|
|
30587
|
+
}
|
|
30588
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
30589
|
+
// Submit-tx state machine
|
|
30590
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
30591
|
+
/**
|
|
30592
|
+
* Submit a broadcast bridge (spoke-deposit) transaction to be processed (relayed).
|
|
30593
|
+
* Carries the FULL `relayData { address, payload }` envelope. Idempotent on `(txHash, srcChainKey)`.
|
|
30594
|
+
*
|
|
30595
|
+
* @returns `Result<BridgeSubmitTxResponseV2>` — `{ success, data: { status, message } }`.
|
|
30596
|
+
*/
|
|
30597
|
+
async submitTx(body, config) {
|
|
30598
|
+
return this.request(
|
|
30599
|
+
"/bridge/submit-tx",
|
|
30600
|
+
{ method: "POST", body: toJsonBody(body) },
|
|
30601
|
+
BridgeSubmitTxResponseSchema,
|
|
30602
|
+
config
|
|
30603
|
+
);
|
|
30604
|
+
}
|
|
30605
|
+
/**
|
|
30606
|
+
* Get the processing status of a submitted bridge transaction by `(txHash, srcChainKey)`.
|
|
30607
|
+
*
|
|
30608
|
+
* @returns `Result<BridgeSubmitTxStatusResponseV2>` — `{ success, data }` (processing state).
|
|
30609
|
+
*/
|
|
30610
|
+
async getSubmitTxStatus(query, config) {
|
|
30611
|
+
const queryParams = new URLSearchParams({ txHash: query.txHash, srcChainKey: query.srcChainKey });
|
|
30612
|
+
return this.request(
|
|
30613
|
+
`/bridge/submit-tx/status?${queryParams.toString()}`,
|
|
30614
|
+
{ method: "GET" },
|
|
30615
|
+
BridgeSubmitTxStatusResponseSchema,
|
|
30616
|
+
config
|
|
30617
|
+
);
|
|
30618
|
+
}
|
|
30619
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
30620
|
+
// Fee · bridgeable quote (read-only; mirror the SDK-core client-side methods)
|
|
30621
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
30622
|
+
/**
|
|
30623
|
+
* Bridge partner fee for an input amount (per-request `partnerFee` override, else the configured default).
|
|
30624
|
+
* NOTE: this is a pure client-side computation
|
|
30625
|
+
* in the SDK core (`sodax.bridge.getFee`) — prefer that (no round-trip); this HTTP variant exists for
|
|
30626
|
+
* parity with the backend `/bridge/fee` endpoint (for consumers using only `sodax.api.bridge`).
|
|
30627
|
+
*
|
|
30628
|
+
* @returns `Result<BridgeFeeResponseV2>` — `{ fee }` (decimal string).
|
|
30629
|
+
*/
|
|
30630
|
+
async getFee(body, config) {
|
|
30631
|
+
return this.request(
|
|
30632
|
+
"/bridge/fee",
|
|
30633
|
+
{ method: "POST", body: toJsonBody(body) },
|
|
30634
|
+
BridgeFeeResponseSchema,
|
|
30635
|
+
config
|
|
30636
|
+
);
|
|
30637
|
+
}
|
|
30638
|
+
/**
|
|
30639
|
+
* Deposit capacity / withdrawal liquidity for a (from, to) token pair. Computable client-side in the
|
|
30640
|
+
* SDK core (`sodax.bridge.getBridgeableAmount`); this HTTP variant mirrors `/bridge/bridgeable-amount`.
|
|
30641
|
+
*
|
|
30642
|
+
* @returns `Result<BridgeableAmountResponseV2>` — `{ limit }`.
|
|
30643
|
+
*/
|
|
30644
|
+
async getBridgeableAmount(body, config) {
|
|
30645
|
+
return this.request(
|
|
30646
|
+
"/bridge/bridgeable-amount",
|
|
30647
|
+
{ method: "POST", body: toJsonBody(body) },
|
|
30648
|
+
BridgeableAmountResponseSchema,
|
|
30649
|
+
config
|
|
30650
|
+
);
|
|
30651
|
+
}
|
|
30652
|
+
/**
|
|
30653
|
+
* Whether a (from, to) token pair is bridgeable. Computable client-side in the SDK core
|
|
30654
|
+
* (`sodax.bridge.isBridgeable`); this HTTP variant mirrors `/bridge/bridgeable/check`.
|
|
30655
|
+
*
|
|
30656
|
+
* @returns `Result<BridgeableCheckResponseV2>` — `{ bridgeable }`.
|
|
30657
|
+
*/
|
|
30658
|
+
async isBridgeable(body, config) {
|
|
30659
|
+
return this.request(
|
|
30660
|
+
"/bridge/bridgeable/check",
|
|
30661
|
+
{ method: "POST", body: toJsonBody(body) },
|
|
30662
|
+
BridgeableCheckResponseSchema,
|
|
30663
|
+
config
|
|
30664
|
+
);
|
|
30665
|
+
}
|
|
30666
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
30667
|
+
// Utilities (parity with SwapsApiService)
|
|
30668
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
30669
|
+
/**
|
|
30670
|
+
* Merge additional headers into the service's default header set. Existing
|
|
30671
|
+
* keys are overwritten; keys absent from `headers` are preserved.
|
|
30672
|
+
*/
|
|
30673
|
+
setHeaders(headers) {
|
|
30674
|
+
Object.entries(headers).forEach(([key, value]) => {
|
|
30675
|
+
this.headers[key] = value;
|
|
30676
|
+
});
|
|
30677
|
+
}
|
|
30678
|
+
/** Return the base URL the service is currently pointing at. */
|
|
30679
|
+
getBaseURL() {
|
|
30680
|
+
return this.config.baseURL;
|
|
30681
|
+
}
|
|
30682
|
+
/**
|
|
30683
|
+
* Return the effective per-request timeout (ms). Callers that bound a request tighter than the
|
|
30684
|
+
* service default (e.g. `pollBackendSubmitTx` clamping to its poll cutoff) need this as the ceiling,
|
|
30685
|
+
* because a `RequestOverrideConfig.timeout` REPLACES the service value rather than lowering it.
|
|
30686
|
+
*/
|
|
30687
|
+
getTimeout() {
|
|
30688
|
+
return this.config.timeout;
|
|
30689
|
+
}
|
|
30690
|
+
};
|
|
30234
30691
|
|
|
30235
30692
|
// src/backendApi/apiConfig.ts
|
|
30236
30693
|
function flatLayer({ baseURL, timeout, headers }) {
|
|
@@ -30275,143 +30732,147 @@ function resolveSponsoringApiConfig(config) {
|
|
|
30275
30732
|
...slice?.apiKey === void 0 ? {} : { apiKey: slice.apiKey }
|
|
30276
30733
|
};
|
|
30277
30734
|
}
|
|
30278
|
-
|
|
30279
|
-
|
|
30280
|
-
|
|
30281
|
-
var
|
|
30282
|
-
|
|
30283
|
-
|
|
30284
|
-
|
|
30285
|
-
|
|
30735
|
+
function resolveBridgeApiConfig(config) {
|
|
30736
|
+
return resolveBaseApiConfig(config);
|
|
30737
|
+
}
|
|
30738
|
+
var ChainKeySchema = v7__namespace.custom((input) => typeof input === "string");
|
|
30739
|
+
var SpokeChainKeySchema = v7__namespace.custom((input) => typeof input === "string");
|
|
30740
|
+
var AddressSchema2 = v7__namespace.custom((input) => typeof input === "string");
|
|
30741
|
+
var XTokenSchema = v7__namespace.object({
|
|
30742
|
+
symbol: v7__namespace.string(),
|
|
30743
|
+
name: v7__namespace.string(),
|
|
30744
|
+
decimals: v7__namespace.number(),
|
|
30745
|
+
address: v7__namespace.string(),
|
|
30286
30746
|
chainKey: ChainKeySchema,
|
|
30287
|
-
hubAsset:
|
|
30288
|
-
vault:
|
|
30289
|
-
access:
|
|
30747
|
+
hubAsset: AddressSchema2,
|
|
30748
|
+
vault: AddressSchema2,
|
|
30749
|
+
access: v7__namespace.optional(v7__namespace.picklist(["withdrawOnly", "depositOnly"]))
|
|
30290
30750
|
});
|
|
30291
|
-
var IntentStructSchema =
|
|
30292
|
-
intentId:
|
|
30293
|
-
creator:
|
|
30294
|
-
inputToken:
|
|
30295
|
-
outputToken:
|
|
30296
|
-
inputAmount:
|
|
30297
|
-
minOutputAmount:
|
|
30298
|
-
deadline:
|
|
30299
|
-
allowPartialFill:
|
|
30300
|
-
srcChain:
|
|
30301
|
-
dstChain:
|
|
30302
|
-
srcAddress:
|
|
30303
|
-
dstAddress:
|
|
30304
|
-
solver:
|
|
30305
|
-
data:
|
|
30751
|
+
var IntentStructSchema = v7__namespace.object({
|
|
30752
|
+
intentId: v7__namespace.string(),
|
|
30753
|
+
creator: v7__namespace.string(),
|
|
30754
|
+
inputToken: v7__namespace.string(),
|
|
30755
|
+
outputToken: v7__namespace.string(),
|
|
30756
|
+
inputAmount: v7__namespace.string(),
|
|
30757
|
+
minOutputAmount: v7__namespace.string(),
|
|
30758
|
+
deadline: v7__namespace.string(),
|
|
30759
|
+
allowPartialFill: v7__namespace.boolean(),
|
|
30760
|
+
srcChain: v7__namespace.number(),
|
|
30761
|
+
dstChain: v7__namespace.number(),
|
|
30762
|
+
srcAddress: v7__namespace.string(),
|
|
30763
|
+
dstAddress: v7__namespace.string(),
|
|
30764
|
+
solver: v7__namespace.string(),
|
|
30765
|
+
data: v7__namespace.string()
|
|
30306
30766
|
});
|
|
30307
|
-
var IntentResponseSchema =
|
|
30308
|
-
intentHash:
|
|
30309
|
-
txHash:
|
|
30310
|
-
logIndex:
|
|
30311
|
-
chainId:
|
|
30312
|
-
blockNumber:
|
|
30313
|
-
open:
|
|
30767
|
+
var IntentResponseSchema = v7__namespace.object({
|
|
30768
|
+
intentHash: v7__namespace.string(),
|
|
30769
|
+
txHash: v7__namespace.string(),
|
|
30770
|
+
logIndex: v7__namespace.number(),
|
|
30771
|
+
chainId: v7__namespace.number(),
|
|
30772
|
+
blockNumber: v7__namespace.number(),
|
|
30773
|
+
open: v7__namespace.boolean(),
|
|
30314
30774
|
intent: IntentStructSchema,
|
|
30315
|
-
events:
|
|
30775
|
+
events: v7__namespace.array(v7__namespace.unknown())
|
|
30316
30776
|
});
|
|
30317
|
-
var UserIntentsResponseSchema =
|
|
30318
|
-
total:
|
|
30319
|
-
offset:
|
|
30320
|
-
limit:
|
|
30321
|
-
items:
|
|
30777
|
+
var UserIntentsResponseSchema = v7__namespace.object({
|
|
30778
|
+
total: v7__namespace.number(),
|
|
30779
|
+
offset: v7__namespace.number(),
|
|
30780
|
+
limit: v7__namespace.number(),
|
|
30781
|
+
items: v7__namespace.array(IntentResponseSchema)
|
|
30322
30782
|
});
|
|
30323
|
-
var OrderbookResponseSchema =
|
|
30324
|
-
total:
|
|
30325
|
-
data:
|
|
30326
|
-
|
|
30327
|
-
intentState:
|
|
30328
|
-
exists:
|
|
30329
|
-
remainingInput:
|
|
30330
|
-
receivedOutput:
|
|
30331
|
-
pendingPayment:
|
|
30783
|
+
var OrderbookResponseSchema = v7__namespace.object({
|
|
30784
|
+
total: v7__namespace.number(),
|
|
30785
|
+
data: v7__namespace.array(
|
|
30786
|
+
v7__namespace.object({
|
|
30787
|
+
intentState: v7__namespace.object({
|
|
30788
|
+
exists: v7__namespace.boolean(),
|
|
30789
|
+
remainingInput: v7__namespace.string(),
|
|
30790
|
+
receivedOutput: v7__namespace.string(),
|
|
30791
|
+
pendingPayment: v7__namespace.boolean()
|
|
30332
30792
|
}),
|
|
30333
|
-
intentData:
|
|
30334
|
-
intentId:
|
|
30335
|
-
creator:
|
|
30336
|
-
inputToken:
|
|
30337
|
-
outputToken:
|
|
30338
|
-
inputAmount:
|
|
30339
|
-
minOutputAmount:
|
|
30340
|
-
deadline:
|
|
30341
|
-
allowPartialFill:
|
|
30342
|
-
srcChain:
|
|
30343
|
-
dstChain:
|
|
30344
|
-
srcAddress:
|
|
30345
|
-
dstAddress:
|
|
30346
|
-
solver:
|
|
30347
|
-
data:
|
|
30348
|
-
intentHash:
|
|
30349
|
-
txHash:
|
|
30350
|
-
blockNumber:
|
|
30793
|
+
intentData: v7__namespace.object({
|
|
30794
|
+
intentId: v7__namespace.string(),
|
|
30795
|
+
creator: v7__namespace.string(),
|
|
30796
|
+
inputToken: v7__namespace.string(),
|
|
30797
|
+
outputToken: v7__namespace.string(),
|
|
30798
|
+
inputAmount: v7__namespace.string(),
|
|
30799
|
+
minOutputAmount: v7__namespace.string(),
|
|
30800
|
+
deadline: v7__namespace.string(),
|
|
30801
|
+
allowPartialFill: v7__namespace.boolean(),
|
|
30802
|
+
srcChain: v7__namespace.number(),
|
|
30803
|
+
dstChain: v7__namespace.number(),
|
|
30804
|
+
srcAddress: v7__namespace.string(),
|
|
30805
|
+
dstAddress: v7__namespace.string(),
|
|
30806
|
+
solver: v7__namespace.string(),
|
|
30807
|
+
data: v7__namespace.string(),
|
|
30808
|
+
intentHash: v7__namespace.string(),
|
|
30809
|
+
txHash: v7__namespace.string(),
|
|
30810
|
+
blockNumber: v7__namespace.number()
|
|
30351
30811
|
})
|
|
30352
30812
|
})
|
|
30353
30813
|
)
|
|
30354
30814
|
});
|
|
30355
|
-
var MoneyMarketPositionSchema =
|
|
30356
|
-
userAddress:
|
|
30357
|
-
positions:
|
|
30358
|
-
|
|
30359
|
-
reserveAddress:
|
|
30360
|
-
aTokenAddress:
|
|
30361
|
-
variableDebtTokenAddress:
|
|
30362
|
-
aTokenBalance:
|
|
30363
|
-
variableDebtTokenBalance:
|
|
30364
|
-
blockNumber:
|
|
30815
|
+
var MoneyMarketPositionSchema = v7__namespace.object({
|
|
30816
|
+
userAddress: v7__namespace.string(),
|
|
30817
|
+
positions: v7__namespace.array(
|
|
30818
|
+
v7__namespace.object({
|
|
30819
|
+
reserveAddress: v7__namespace.string(),
|
|
30820
|
+
aTokenAddress: v7__namespace.string(),
|
|
30821
|
+
variableDebtTokenAddress: v7__namespace.string(),
|
|
30822
|
+
aTokenBalance: v7__namespace.string(),
|
|
30823
|
+
variableDebtTokenBalance: v7__namespace.string(),
|
|
30824
|
+
blockNumber: v7__namespace.number()
|
|
30365
30825
|
})
|
|
30366
30826
|
)
|
|
30367
30827
|
});
|
|
30368
|
-
var MoneyMarketAssetSchema =
|
|
30369
|
-
reserveAddress:
|
|
30370
|
-
aTokenAddress:
|
|
30371
|
-
totalATokenBalance:
|
|
30372
|
-
variableDebtTokenAddress:
|
|
30373
|
-
totalVariableDebtTokenBalance:
|
|
30374
|
-
liquidityRate:
|
|
30375
|
-
symbol:
|
|
30376
|
-
totalSuppliers:
|
|
30377
|
-
totalBorrowers:
|
|
30378
|
-
variableBorrowRate:
|
|
30379
|
-
stableBorrowRate:
|
|
30380
|
-
liquidityIndex:
|
|
30381
|
-
variableBorrowIndex:
|
|
30382
|
-
blockNumber:
|
|
30828
|
+
var MoneyMarketAssetSchema = v7__namespace.object({
|
|
30829
|
+
reserveAddress: v7__namespace.string(),
|
|
30830
|
+
aTokenAddress: v7__namespace.string(),
|
|
30831
|
+
totalATokenBalance: v7__namespace.string(),
|
|
30832
|
+
variableDebtTokenAddress: v7__namespace.string(),
|
|
30833
|
+
totalVariableDebtTokenBalance: v7__namespace.string(),
|
|
30834
|
+
liquidityRate: v7__namespace.string(),
|
|
30835
|
+
symbol: v7__namespace.string(),
|
|
30836
|
+
totalSuppliers: v7__namespace.number(),
|
|
30837
|
+
totalBorrowers: v7__namespace.number(),
|
|
30838
|
+
variableBorrowRate: v7__namespace.string(),
|
|
30839
|
+
stableBorrowRate: v7__namespace.string(),
|
|
30840
|
+
liquidityIndex: v7__namespace.string(),
|
|
30841
|
+
variableBorrowIndex: v7__namespace.string(),
|
|
30842
|
+
blockNumber: v7__namespace.number()
|
|
30383
30843
|
});
|
|
30384
|
-
var MoneyMarketAssetsSchema =
|
|
30385
|
-
var MoneyMarketAssetBorrowersSchema =
|
|
30386
|
-
borrowers:
|
|
30387
|
-
total:
|
|
30388
|
-
offset:
|
|
30389
|
-
limit:
|
|
30844
|
+
var MoneyMarketAssetsSchema = v7__namespace.array(MoneyMarketAssetSchema);
|
|
30845
|
+
var MoneyMarketAssetBorrowersSchema = v7__namespace.object({
|
|
30846
|
+
borrowers: v7__namespace.array(v7__namespace.string()),
|
|
30847
|
+
total: v7__namespace.number(),
|
|
30848
|
+
offset: v7__namespace.number(),
|
|
30849
|
+
limit: v7__namespace.number()
|
|
30390
30850
|
});
|
|
30391
|
-
var MoneyMarketAssetSuppliersSchema =
|
|
30392
|
-
suppliers:
|
|
30393
|
-
total:
|
|
30394
|
-
offset:
|
|
30395
|
-
limit:
|
|
30851
|
+
var MoneyMarketAssetSuppliersSchema = v7__namespace.object({
|
|
30852
|
+
suppliers: v7__namespace.array(v7__namespace.string()),
|
|
30853
|
+
total: v7__namespace.number(),
|
|
30854
|
+
offset: v7__namespace.number(),
|
|
30855
|
+
limit: v7__namespace.number()
|
|
30396
30856
|
});
|
|
30397
|
-
var MoneyMarketBorrowersSchema =
|
|
30398
|
-
borrowers:
|
|
30399
|
-
total:
|
|
30400
|
-
offset:
|
|
30401
|
-
limit:
|
|
30857
|
+
var MoneyMarketBorrowersSchema = v7__namespace.object({
|
|
30858
|
+
borrowers: v7__namespace.array(v7__namespace.string()),
|
|
30859
|
+
total: v7__namespace.number(),
|
|
30860
|
+
offset: v7__namespace.number(),
|
|
30861
|
+
limit: v7__namespace.number()
|
|
30402
30862
|
});
|
|
30403
|
-
var GetChainsResponseSchema =
|
|
30404
|
-
var TokensByChainMapSchema =
|
|
30405
|
-
(input) => typeof input === "object" && input !== null && Object.values(input).every((tokens) => Array.isArray(tokens) && tokens.every((t) =>
|
|
30863
|
+
var GetChainsResponseSchema = v7__namespace.array(SpokeChainKeySchema);
|
|
30864
|
+
var TokensByChainMapSchema = v7__namespace.custom(
|
|
30865
|
+
(input) => typeof input === "object" && input !== null && Object.values(input).every((tokens) => Array.isArray(tokens) && tokens.every((t) => v7__namespace.is(XTokenSchema, t)))
|
|
30406
30866
|
);
|
|
30407
|
-
var TokensListSchema =
|
|
30408
|
-
var ReserveAssetsSchema =
|
|
30867
|
+
var TokensListSchema = v7__namespace.array(XTokenSchema);
|
|
30868
|
+
var ReserveAssetsSchema = v7__namespace.array(AddressSchema2);
|
|
30409
30869
|
|
|
30410
30870
|
// src/backendApi/BackendApiService.ts
|
|
30411
30871
|
var BackendApiService = class {
|
|
30412
30872
|
// sub-services exposing domain-specific APIs
|
|
30413
30873
|
swaps;
|
|
30414
30874
|
sponsoring;
|
|
30875
|
+
bridge;
|
|
30415
30876
|
// resolved base-API config: the flat fields of the ApiConfig union with any `baseApiConfig` layered on top
|
|
30416
30877
|
config;
|
|
30417
30878
|
headers;
|
|
@@ -30422,6 +30883,7 @@ var BackendApiService = class {
|
|
|
30422
30883
|
this.logger = logger;
|
|
30423
30884
|
this.swaps = new SwapsApiService(resolveSwapsApiConfig(config), this.logger);
|
|
30424
30885
|
this.sponsoring = new SponsoringApiService(resolveSponsoringApiConfig(config), this.logger);
|
|
30886
|
+
this.bridge = new BridgeApiService(resolveBridgeApiConfig(config), this.logger);
|
|
30425
30887
|
}
|
|
30426
30888
|
/**
|
|
30427
30889
|
* Issue a request and validate the JSON body against `schema`, wrapping the result in `Result<T>`.
|
|
@@ -30438,7 +30900,7 @@ var BackendApiService = class {
|
|
|
30438
30900
|
logger: this.logger,
|
|
30439
30901
|
serviceLabel: "BackendApiService"
|
|
30440
30902
|
});
|
|
30441
|
-
const parsed =
|
|
30903
|
+
const parsed = v7__namespace.safeParse(schema, raw);
|
|
30442
30904
|
if (!parsed.success) {
|
|
30443
30905
|
return {
|
|
30444
30906
|
ok: false,
|
|
@@ -30446,7 +30908,7 @@ var BackendApiService = class {
|
|
|
30446
30908
|
api: "backend",
|
|
30447
30909
|
feature: "backend",
|
|
30448
30910
|
endpoint,
|
|
30449
|
-
issues:
|
|
30911
|
+
issues: v7__namespace.flatten(parsed.issues)
|
|
30450
30912
|
})
|
|
30451
30913
|
};
|
|
30452
30914
|
}
|
|
@@ -30781,6 +31243,7 @@ var BackendApiService = class {
|
|
|
30781
31243
|
this.headers[key] = value;
|
|
30782
31244
|
});
|
|
30783
31245
|
this.swaps.setHeaders(headers);
|
|
31246
|
+
this.bridge.setHeaders(headers);
|
|
30784
31247
|
}
|
|
30785
31248
|
/**
|
|
30786
31249
|
* Return the base URL the service is currently pointing at.
|
|
@@ -30831,25 +31294,32 @@ var BridgeService = class {
|
|
|
30831
31294
|
hubProvider;
|
|
30832
31295
|
config;
|
|
30833
31296
|
spoke;
|
|
30834
|
-
|
|
31297
|
+
// backend bridge-API client + opt-in backend submit-tx flag
|
|
31298
|
+
backendApi;
|
|
31299
|
+
useBackendSubmitTx;
|
|
31300
|
+
constructor({ hubProvider, config, spoke, backendApi, useBackendSubmitTx }) {
|
|
30835
31301
|
this.config = config;
|
|
30836
31302
|
this.hubProvider = hubProvider;
|
|
30837
31303
|
this.spoke = spoke;
|
|
31304
|
+
this.backendApi = backendApi;
|
|
31305
|
+
this.useBackendSubmitTx = useBackendSubmitTx ?? false;
|
|
30838
31306
|
}
|
|
30839
31307
|
/**
|
|
30840
31308
|
* Calculates the partner fee deducted from a given bridge input amount.
|
|
30841
31309
|
*
|
|
30842
|
-
* Returns `0n` when no partner fee is configured.
|
|
30843
|
-
*
|
|
31310
|
+
* Returns `0n` when no partner fee is configured. `inputAmount` must be in 18-dp hub/vault
|
|
31311
|
+
* units — the units the hub deducts the fee in (see `buildBridgeData`) — NOT the spoke token's
|
|
31312
|
+
* native base units. This matters for a fixed `PartnerFee.amount`, which is wei-denominated
|
|
31313
|
+
* (18 dp); a percentage fee is unit-agnostic.
|
|
30844
31314
|
*
|
|
30845
|
-
* @param inputAmount - Gross amount being bridged, in vault
|
|
31315
|
+
* @param inputAmount - Gross amount being bridged, in 18-dp hub/vault units.
|
|
30846
31316
|
* @returns Fee amount to be deducted, in the same units as `inputAmount`.
|
|
30847
31317
|
*/
|
|
30848
|
-
getFee(inputAmount) {
|
|
30849
|
-
if (!
|
|
31318
|
+
getFee(inputAmount, partnerFee = this.config.bridgePartnerFee) {
|
|
31319
|
+
if (!partnerFee) {
|
|
30850
31320
|
return 0n;
|
|
30851
31321
|
}
|
|
30852
|
-
return calculateFeeAmount(inputAmount,
|
|
31322
|
+
return calculateFeeAmount(inputAmount, partnerFee);
|
|
30853
31323
|
}
|
|
30854
31324
|
/**
|
|
30855
31325
|
* Checks whether the caller has sufficient token allowance to execute the bridge.
|
|
@@ -31034,42 +31504,21 @@ var BridgeService = class {
|
|
|
31034
31504
|
"bridge",
|
|
31035
31505
|
"bridge",
|
|
31036
31506
|
async () => {
|
|
31037
|
-
const { params
|
|
31507
|
+
const { params } = _params;
|
|
31038
31508
|
const baseCtx = { srcChainKey: params.srcChainKey, dstChainKey: params.dstChainKey };
|
|
31039
31509
|
try {
|
|
31040
|
-
const
|
|
31041
|
-
if (!
|
|
31042
|
-
const
|
|
31043
|
-
|
|
31044
|
-
|
|
31045
|
-
|
|
31046
|
-
|
|
31047
|
-
|
|
31048
|
-
|
|
31049
|
-
|
|
31050
|
-
};
|
|
31510
|
+
const created = await this.createBridgeIntent(_params);
|
|
31511
|
+
if (!created.ok) return { ok: false, error: created.error };
|
|
31512
|
+
const deadline = Date.now() + (_params.timeout ?? DEFAULT_RELAY_TX_TIMEOUT);
|
|
31513
|
+
if (this.useBackendSubmitTx) {
|
|
31514
|
+
const submitted = await this.submitTx(_params, created.value, deadline);
|
|
31515
|
+
if (submitted.ok) return submitted;
|
|
31516
|
+
this.config.logger.warn(
|
|
31517
|
+
"[bridge] backend submit-tx did not complete; falling back to the client-side relay",
|
|
31518
|
+
{ error: submitted.error }
|
|
31519
|
+
);
|
|
31051
31520
|
}
|
|
31052
|
-
|
|
31053
|
-
srcTxHash: txResult.value.tx,
|
|
31054
|
-
data: txResult.value.relayData,
|
|
31055
|
-
chainKey: params.srcChainKey,
|
|
31056
|
-
relayerApiEndpoint: this.config.relay.relayerApiEndpoint,
|
|
31057
|
-
timeout
|
|
31058
|
-
});
|
|
31059
|
-
if (!packetResult.ok)
|
|
31060
|
-
return {
|
|
31061
|
-
ok: false,
|
|
31062
|
-
error: mapRelayFailure(packetResult.error, {
|
|
31063
|
-
feature: "bridge",
|
|
31064
|
-
action: "bridge",
|
|
31065
|
-
srcChainKey: baseCtx.srcChainKey,
|
|
31066
|
-
dstChainKey: baseCtx.dstChainKey
|
|
31067
|
-
})
|
|
31068
|
-
};
|
|
31069
|
-
return {
|
|
31070
|
-
ok: true,
|
|
31071
|
-
value: { srcChainTxHash: txResult.value.tx, dstChainTxHash: packetResult.value.dst_tx_hash }
|
|
31072
|
-
};
|
|
31521
|
+
return this.fallbackBridgeSteps(_params, created.value, deadline);
|
|
31073
31522
|
} catch (error) {
|
|
31074
31523
|
if (isBridgeOrchestrationError(error)) return { ok: false, error };
|
|
31075
31524
|
return {
|
|
@@ -31096,6 +31545,98 @@ var BridgeService = class {
|
|
|
31096
31545
|
}
|
|
31097
31546
|
);
|
|
31098
31547
|
}
|
|
31548
|
+
/**
|
|
31549
|
+
* Client-side bridge completion (the default path): verify the broadcast spoke-deposit tx, then
|
|
31550
|
+
* relay it to the hub and wait for the settlement packet. Extracted verbatim from `bridge()` so the
|
|
31551
|
+
* opt-in backend submit-tx path ({@link submitTx}) can fall back to it on any non-success. Bridge
|
|
31552
|
+
* always relays — there is no hub-source short-circuit.
|
|
31553
|
+
*/
|
|
31554
|
+
async fallbackBridgeSteps(_params, created, deadline) {
|
|
31555
|
+
const { params } = _params;
|
|
31556
|
+
const baseCtx = { srcChainKey: params.srcChainKey, dstChainKey: params.dstChainKey };
|
|
31557
|
+
const verifyTxHashResult = await this.spoke.verifyTxHash({
|
|
31558
|
+
txHash: created.tx,
|
|
31559
|
+
chainKey: params.srcChainKey
|
|
31560
|
+
});
|
|
31561
|
+
if (!verifyTxHashResult.ok) {
|
|
31562
|
+
return { ok: false, error: verifyFailed("bridge", verifyTxHashResult.error, baseCtx) };
|
|
31563
|
+
}
|
|
31564
|
+
const packetResult = await relayTxAndWaitPacket({
|
|
31565
|
+
srcTxHash: created.tx,
|
|
31566
|
+
data: created.relayData,
|
|
31567
|
+
chainKey: params.srcChainKey,
|
|
31568
|
+
relayerApiEndpoint: this.config.relay.relayerApiEndpoint,
|
|
31569
|
+
// Remaining shared budget: ≈ full `timeout` on the flag-off path minus the `verifyTxHash` wait,
|
|
31570
|
+
// or the reserve `submitTx` left on the backend path (`pollBackendSubmitTx` holds back up to a
|
|
31571
|
+
// third, capped at 20s). The floor matters because `relayTxAndWaitPacket` SUBMITS the tx to the
|
|
31572
|
+
// relay before `timeout` bounds anything: a budget exhausted by a slow source-chain confirmation
|
|
31573
|
+
// (Stacks polls for up to its full 120s `maxTimeoutMs`) would otherwise strand an already-landed
|
|
31574
|
+
// deposit unrelayed. Re-relay is idempotent, so always spending the floor is safe.
|
|
31575
|
+
timeout: Math.max(deadline - Date.now(), RELAY_FALLBACK_FLOOR_MS)
|
|
31576
|
+
});
|
|
31577
|
+
if (!packetResult.ok) {
|
|
31578
|
+
return {
|
|
31579
|
+
ok: false,
|
|
31580
|
+
error: mapRelayFailure(packetResult.error, {
|
|
31581
|
+
feature: "bridge",
|
|
31582
|
+
action: "bridge",
|
|
31583
|
+
srcChainKey: baseCtx.srcChainKey,
|
|
31584
|
+
dstChainKey: baseCtx.dstChainKey
|
|
31585
|
+
})
|
|
31586
|
+
};
|
|
31587
|
+
}
|
|
31588
|
+
return {
|
|
31589
|
+
ok: true,
|
|
31590
|
+
value: { srcChainTxHash: created.tx, dstChainTxHash: packetResult.value.dst_tx_hash }
|
|
31591
|
+
};
|
|
31592
|
+
}
|
|
31593
|
+
/**
|
|
31594
|
+
* Backend bridge path (opt-in via `bridgeOptions.useBackendSubmitTx`): hand the broadcast
|
|
31595
|
+
* spoke-deposit tx to the bridge API (`POST /bridge/submit-tx`) with the FULL `relayData`
|
|
31596
|
+
* envelope; the backend relays server-side. Polls `getSubmitTxStatus` until `executed`, then
|
|
31597
|
+
* returns the same {@link TxHashPair} the client-side path returns (`result.dstIntentTxHash` →
|
|
31598
|
+
* destination tx hash; bridge has no solver `intent_hash`).
|
|
31599
|
+
*
|
|
31600
|
+
* Never throws — returns `{ ok: false }` on any non-success (submit `!ok`, terminal `failed` /
|
|
31601
|
+
* abandoned, or poll timeout) so `bridge()` falls back to {@link fallbackBridgeSteps}. Falling back
|
|
31602
|
+
* is safe: re-relaying an already-relayed bridge tx is idempotent — the relay dedups and returns the
|
|
31603
|
+
* existing `executed` packet. Polling stops at `deadline - reserve` so the fallback keeps a
|
|
31604
|
+
* guaranteed slice of the shared `bridge` budget.
|
|
31605
|
+
*/
|
|
31606
|
+
async submitTx(_params, created, deadline) {
|
|
31607
|
+
const { params } = _params;
|
|
31608
|
+
const srcChainKey = params.srcChainKey;
|
|
31609
|
+
const baseCtx = { srcChainKey, dstChainKey: params.dstChainKey };
|
|
31610
|
+
const { tx: spokeTxHash, relayData } = created;
|
|
31611
|
+
const submitTxFailed = (cause) => ({
|
|
31612
|
+
ok: false,
|
|
31613
|
+
error: executionFailed("bridge", cause, { ...baseCtx, action: "bridge" })
|
|
31614
|
+
});
|
|
31615
|
+
try {
|
|
31616
|
+
const submitted = await this.backendApi.bridge.submitTx({
|
|
31617
|
+
txHash: spokeTxHash,
|
|
31618
|
+
srcChainKey,
|
|
31619
|
+
walletAddress: params.srcAddress,
|
|
31620
|
+
// Send the FULL { address, payload } envelope — bridge has no intent.creator for the backend
|
|
31621
|
+
// to rebuild the relay address, so dropping it would break split-tx-chain relay.
|
|
31622
|
+
relayData
|
|
31623
|
+
});
|
|
31624
|
+
if (!submitted.ok) return submitTxFailed(submitted.error);
|
|
31625
|
+
const polled = await pollBackendSubmitTx({
|
|
31626
|
+
deadline,
|
|
31627
|
+
// Bridge terminal success is `executed` (hub-settled) — not the swaps `solved`.
|
|
31628
|
+
terminalStatus: "executed",
|
|
31629
|
+
getStatus: (override) => this.backendApi.bridge.getSubmitTxStatus({ txHash: spokeTxHash, srcChainKey }, override),
|
|
31630
|
+
onExecuted: (result) => result?.dstIntentTxHash ? { srcChainTxHash: spokeTxHash, dstChainTxHash: result.dstIntentTxHash } : void 0,
|
|
31631
|
+
// Bound each status request by the poll cutoff, never above the service default — so a stalled
|
|
31632
|
+
// request can neither eat the fallback's reserve nor consume the window in one attempt.
|
|
31633
|
+
requestTimeoutMs: this.backendApi.bridge.getTimeout()
|
|
31634
|
+
});
|
|
31635
|
+
return polled.ok ? { ok: true, value: polled.value } : submitTxFailed(polled.cause);
|
|
31636
|
+
} catch (error) {
|
|
31637
|
+
return { ok: false, error: unknownFailed("bridge", error, { ...baseCtx, action: "bridge" }) };
|
|
31638
|
+
}
|
|
31639
|
+
}
|
|
31099
31640
|
/**
|
|
31100
31641
|
* Submits the spoke-side deposit transaction that initiates a bridge transfer,
|
|
31101
31642
|
* without waiting for the cross-chain relay to complete.
|
|
@@ -31119,9 +31660,15 @@ var BridgeService = class {
|
|
|
31119
31660
|
* contains the hub wallet address and encoded hub execution payload needed for relay.
|
|
31120
31661
|
*/
|
|
31121
31662
|
async createBridgeIntent(_params) {
|
|
31122
|
-
const { params, skipSimulation } = _params;
|
|
31663
|
+
const { params, skipSimulation, extras } = _params;
|
|
31664
|
+
const partnerFee = extras?.partnerFee ?? this.config.bridgePartnerFee;
|
|
31123
31665
|
const baseCtx = { srcChainKey: params.srcChainKey, dstChainKey: params.dstChainKey };
|
|
31124
31666
|
try {
|
|
31667
|
+
bridgeInvariant(
|
|
31668
|
+
isUndefinedOrValidWalletProviderForChainKey(params.srcChainKey, _params.walletProvider),
|
|
31669
|
+
`Invalid wallet provider for chain key: ${params.srcChainKey}`,
|
|
31670
|
+
baseCtx
|
|
31671
|
+
);
|
|
31125
31672
|
bridgeInvariant(params.amount > 0n, "Amount must be greater than 0", { ...baseCtx, field: "amount" });
|
|
31126
31673
|
const srcToken = this.resolveBridgeEndpointToken(params.srcChainKey, params.srcToken);
|
|
31127
31674
|
const dstToken = this.resolveBridgeEndpointToken(params.dstChainKey, params.dstToken);
|
|
@@ -31133,25 +31680,62 @@ var BridgeService = class {
|
|
|
31133
31680
|
...baseCtx,
|
|
31134
31681
|
field: "dstToken"
|
|
31135
31682
|
});
|
|
31136
|
-
|
|
31137
|
-
|
|
31138
|
-
|
|
31683
|
+
bridgeInvariant(
|
|
31684
|
+
this.config.isValidSpokeChainKey(params.srcChainKey),
|
|
31685
|
+
`Invalid spoke chain (srcChainKey): ${params.srcChainKey}`,
|
|
31686
|
+
{ ...baseCtx, field: "srcChainKey" }
|
|
31687
|
+
);
|
|
31688
|
+
bridgeInvariant(
|
|
31689
|
+
this.config.isValidSpokeChainKey(params.dstChainKey),
|
|
31690
|
+
`Invalid spoke chain (dstChainKey): ${params.dstChainKey}`,
|
|
31691
|
+
{ ...baseCtx, field: "dstChainKey" }
|
|
31692
|
+
);
|
|
31693
|
+
if (isNativeBitcoinTransfer(this.config, params.srcChainKey, srcToken)) {
|
|
31139
31694
|
bridgeInvariant(
|
|
31140
|
-
|
|
31141
|
-
`Invalid
|
|
31142
|
-
{ ...baseCtx, field: "
|
|
31695
|
+
params.amount >= BITCOIN_DUST_SATS,
|
|
31696
|
+
`Invalid amount (${params.amount}): below the Bitcoin dust limit of ${BITCOIN_DUST_SATS} sats`,
|
|
31697
|
+
{ ...baseCtx, field: "amount" }
|
|
31143
31698
|
);
|
|
31144
|
-
|
|
31145
|
-
|
|
31146
|
-
|
|
31699
|
+
}
|
|
31700
|
+
if (isNativeBitcoinTransfer(this.config, params.dstChainKey, dstToken)) {
|
|
31701
|
+
const { delivered } = this.computeBridgeAmounts(params.amount, srcToken, dstToken, partnerFee);
|
|
31702
|
+
bridgeInvariant(
|
|
31703
|
+
delivered >= BITCOIN_DUST_SATS,
|
|
31704
|
+
`Post-fee BTC delivery (${delivered}) is below the Bitcoin dust limit of ${BITCOIN_DUST_SATS} sats`,
|
|
31705
|
+
{ ...baseCtx, field: "amount" }
|
|
31706
|
+
);
|
|
31707
|
+
}
|
|
31708
|
+
if (isStacksChainKeyType(params.srcChainKey) && _params.raw === true) {
|
|
31709
|
+
bridgeInvariant(
|
|
31710
|
+
extras?.srcPublicKey !== void 0,
|
|
31711
|
+
"srcPublicKey is required for Stacks createBridgeIntent (raw) \u2014 the source tx is built unsigned and needs the signer public key",
|
|
31712
|
+
{ ...baseCtx, field: "srcPublicKey" }
|
|
31713
|
+
);
|
|
31714
|
+
}
|
|
31715
|
+
const personalAddress = params.srcAddress;
|
|
31716
|
+
let walletAddress = personalAddress;
|
|
31717
|
+
if (isBitcoinChainKeyType(params.srcChainKey)) {
|
|
31718
|
+
if (_params.raw === false) {
|
|
31719
|
+
bridgeInvariant(
|
|
31720
|
+
isBitcoinWalletProviderType(_params.walletProvider),
|
|
31721
|
+
`Invalid wallet provider for chain key: ${params.srcChainKey}. Expected bitcoin wallet provider.`,
|
|
31722
|
+
{ ...baseCtx, field: "walletProvider" }
|
|
31723
|
+
);
|
|
31724
|
+
if (this.spoke.bitcoin.walletMode === "TRADING") {
|
|
31725
|
+
await this.spoke.bitcoin.radfi.ensureRadfiAccessToken(_params.walletProvider);
|
|
31726
|
+
}
|
|
31147
31727
|
}
|
|
31728
|
+
walletAddress = await this.spoke.bitcoin.getEffectiveWalletAddress(personalAddress);
|
|
31148
31729
|
}
|
|
31149
31730
|
const hubWallet = await this.hubProvider.getUserHubWalletAddress(walletAddress, params.srcChainKey);
|
|
31150
31731
|
const effectiveSkipSimulation = skipSimulation || isBitcoinChainKeyType(params.srcChainKey) && this.spoke.bitcoin.walletMode === "USER";
|
|
31151
|
-
const data = this.buildBridgeData(params, srcToken, dstToken,
|
|
31732
|
+
const data = this.buildBridgeData(params, srcToken, dstToken, partnerFee);
|
|
31152
31733
|
const coreParams = {
|
|
31153
31734
|
srcChainKey: params.srcChainKey,
|
|
31154
31735
|
srcAddress: walletAddress,
|
|
31736
|
+
srcPublicKey: extras?.srcPublicKey,
|
|
31737
|
+
// Bitcoin Bound token; BitcoinSpokeService.deposit falls back to the RadfiProvider instance token when undefined.
|
|
31738
|
+
accessToken: extras?.bound?.accessToken,
|
|
31155
31739
|
to: hubWallet,
|
|
31156
31740
|
token: params.srcToken,
|
|
31157
31741
|
amount: params.amount,
|
|
@@ -31206,6 +31790,26 @@ var BridgeService = class {
|
|
|
31206
31790
|
if (spokeToken) return spokeToken;
|
|
31207
31791
|
return isHubChainKeyType(chainKey) ? this.config.getXTokenFromHubAsset(token) : void 0;
|
|
31208
31792
|
}
|
|
31793
|
+
/**
|
|
31794
|
+
* Post-fee amounts for a bridge, in the units each hub step operates in. Single source for the fee +
|
|
31795
|
+
* vault-decimal pipeline, so {@link buildBridgeData}'s encoded hub calls and the BTC-destination dust
|
|
31796
|
+
* guard in {@link createBridgeIntent} can never disagree about what actually gets delivered.
|
|
31797
|
+
*
|
|
31798
|
+
* A spoke endpoint's amount is translated INTO 18-dp vault units on the way in (skipped when the
|
|
31799
|
+
* endpoint already IS the vault asset), the partner fee is deducted there — so a fixed
|
|
31800
|
+
* `PartnerFee.amount` is wei-denominated, never spoke-denominated — and the remainder is translated
|
|
31801
|
+
* back OUT into the destination endpoint's own units.
|
|
31802
|
+
*
|
|
31803
|
+
* @returns `feeAmount` and `withdrawAmount` in 18-dp vault units (what the hub fee transfer and vault
|
|
31804
|
+
* withdrawal use), and `delivered` in the destination endpoint's units (what the recipient receives).
|
|
31805
|
+
*/
|
|
31806
|
+
computeBridgeAmounts(amount, srcToken, dstToken, partnerFee) {
|
|
31807
|
+
const translatedAmount = this.config.isSodaVaultHubAsset(srcToken.hubAsset) ? amount : EvmVaultTokenService.translateIncomingDecimals(srcToken.decimals, amount);
|
|
31808
|
+
const feeAmount = calculateFeeAmount(translatedAmount, partnerFee);
|
|
31809
|
+
const withdrawAmount = translatedAmount - feeAmount;
|
|
31810
|
+
const delivered = this.config.isSodaVaultHubAsset(dstToken.hubAsset) ? withdrawAmount : EvmVaultTokenService.translateOutgoingDecimals(dstToken.decimals, withdrawAmount);
|
|
31811
|
+
return { feeAmount, withdrawAmount, delivered };
|
|
31812
|
+
}
|
|
31209
31813
|
/**
|
|
31210
31814
|
* Encodes the hub-side execution payload for a bridge operation.
|
|
31211
31815
|
*
|
|
@@ -31229,23 +31833,23 @@ var BridgeService = class {
|
|
|
31229
31833
|
*/
|
|
31230
31834
|
buildBridgeData(params, srcToken, dstToken, partnerFee) {
|
|
31231
31835
|
const calls = [];
|
|
31232
|
-
|
|
31233
|
-
|
|
31836
|
+
const { feeAmount, withdrawAmount, delivered } = this.computeBridgeAmounts(
|
|
31837
|
+
params.amount,
|
|
31838
|
+
srcToken,
|
|
31839
|
+
dstToken,
|
|
31840
|
+
partnerFee
|
|
31841
|
+
);
|
|
31842
|
+
let srcVault = srcToken.hubAsset;
|
|
31234
31843
|
if (!this.config.isSodaVaultHubAsset(srcToken.hubAsset)) {
|
|
31235
31844
|
calls.push(Erc20Service.encodeApprove(srcToken.hubAsset, srcToken.vault, params.amount));
|
|
31236
31845
|
calls.push(EvmVaultTokenService.encodeDeposit(srcToken.vault, srcToken.hubAsset, params.amount));
|
|
31237
|
-
translatedAmount = EvmVaultTokenService.translateIncomingDecimals(srcToken.decimals, params.amount);
|
|
31238
31846
|
srcVault = srcToken.vault;
|
|
31239
31847
|
}
|
|
31240
|
-
const feeAmount = calculateFeeAmount(translatedAmount, partnerFee);
|
|
31241
31848
|
if (partnerFee && feeAmount > 0n) {
|
|
31242
31849
|
calls.push(Erc20Service.encodeTransfer(srcVault, partnerFee.address, feeAmount));
|
|
31243
31850
|
}
|
|
31244
|
-
const withdrawAmount = translatedAmount - feeAmount;
|
|
31245
|
-
let translatedWithdrawAmount = withdrawAmount;
|
|
31246
31851
|
if (!this.config.isSodaVaultHubAsset(dstToken.hubAsset)) {
|
|
31247
31852
|
calls.push(EvmVaultTokenService.encodeWithdraw(dstToken.vault, dstToken.hubAsset, withdrawAmount));
|
|
31248
|
-
translatedWithdrawAmount = EvmVaultTokenService.translateOutgoingDecimals(dstToken.decimals, withdrawAmount);
|
|
31249
31853
|
}
|
|
31250
31854
|
const encodedRecipientAddress = encodeAddress(params.dstChainKey, params.recipient);
|
|
31251
31855
|
if (isHubChainKey(params.dstChainKey)) {
|
|
@@ -31256,11 +31860,11 @@ var BridgeService = class {
|
|
|
31256
31860
|
data: viem.encodeFunctionData({
|
|
31257
31861
|
abi: wrappedSonicAbi,
|
|
31258
31862
|
functionName: "withdrawTo",
|
|
31259
|
-
args: [encodedRecipientAddress,
|
|
31863
|
+
args: [encodedRecipientAddress, delivered]
|
|
31260
31864
|
})
|
|
31261
31865
|
});
|
|
31262
31866
|
} else {
|
|
31263
|
-
calls.push(Erc20Service.encodeTransfer(dstToken.hubAsset, encodedRecipientAddress,
|
|
31867
|
+
calls.push(Erc20Service.encodeTransfer(dstToken.hubAsset, encodedRecipientAddress, delivered));
|
|
31264
31868
|
}
|
|
31265
31869
|
} else {
|
|
31266
31870
|
bridgeInvariant(dstToken, `Unsupported hub chain (${params.dstChainKey}) token: ${params.dstToken}`, {
|
|
@@ -31271,7 +31875,7 @@ var BridgeService = class {
|
|
|
31271
31875
|
EvmAssetManagerService.encodeTransfer(
|
|
31272
31876
|
dstToken.hubAsset,
|
|
31273
31877
|
encodedRecipientAddress,
|
|
31274
|
-
|
|
31878
|
+
delivered,
|
|
31275
31879
|
this.hubProvider.chainConfig.addresses.assetManager
|
|
31276
31880
|
)
|
|
31277
31881
|
);
|
|
@@ -39490,7 +40094,7 @@ var LeverageYieldService = class {
|
|
|
39490
40094
|
}
|
|
39491
40095
|
/** Looks up a vault by its `name` field. Returns `undefined` when not registered. */
|
|
39492
40096
|
getVault(name) {
|
|
39493
|
-
return this.listVaults().find((
|
|
40097
|
+
return this.listVaults().find((v9) => v9.name === name);
|
|
39494
40098
|
}
|
|
39495
40099
|
/**
|
|
39496
40100
|
* Looks up a registered vault by its on-chain proxy address (case-insensitive).
|
|
@@ -39498,7 +40102,7 @@ var LeverageYieldService = class {
|
|
|
39498
40102
|
*/
|
|
39499
40103
|
getVaultByAddress(address) {
|
|
39500
40104
|
const normalized = address.toLowerCase();
|
|
39501
|
-
return this.listVaults().find((
|
|
40105
|
+
return this.listVaults().find((v9) => v9.vault.toLowerCase() === normalized);
|
|
39502
40106
|
}
|
|
39503
40107
|
/**
|
|
39504
40108
|
* Resolves the intent `deadline`: returns the caller-supplied value verbatim, otherwise
|
|
@@ -40305,12 +40909,12 @@ function toDomainCode(value) {
|
|
|
40305
40909
|
}
|
|
40306
40910
|
function readErrorBody(body) {
|
|
40307
40911
|
if (typeof body !== "object" || body === null) return {};
|
|
40308
|
-
const
|
|
40309
|
-
const retryAfterSeconds = typeof
|
|
40310
|
-
const sponsorSequence = typeof
|
|
40912
|
+
const record3 = body;
|
|
40913
|
+
const retryAfterSeconds = typeof record3.retryAfterSeconds === "number" && Number.isFinite(record3.retryAfterSeconds) && record3.retryAfterSeconds > 0 ? record3.retryAfterSeconds : void 0;
|
|
40914
|
+
const sponsorSequence = typeof record3.sponsorSequence === "string" && /^\d+$/.test(record3.sponsorSequence) ? record3.sponsorSequence : void 0;
|
|
40311
40915
|
return {
|
|
40312
|
-
message: typeof
|
|
40313
|
-
code: toDomainCode(
|
|
40916
|
+
message: typeof record3.message === "string" ? record3.message : void 0,
|
|
40917
|
+
code: toDomainCode(record3.error),
|
|
40314
40918
|
retryAfterSeconds,
|
|
40315
40919
|
sponsorSequence
|
|
40316
40920
|
};
|
|
@@ -40876,7 +41480,9 @@ var Sodax = class {
|
|
|
40876
41480
|
const logger = resolveLogger(options?.logger);
|
|
40877
41481
|
const analytics = resolveAnalytics(options?.analytics);
|
|
40878
41482
|
const fee = options?.fee;
|
|
41483
|
+
const radfiSigner = options?.radfi?.signRequest;
|
|
40879
41484
|
const useBackendSubmitTx = options?.swapsOptions?.useBackendSubmitTx ?? false;
|
|
41485
|
+
const bridgeUseBackendSubmitTx = options?.bridgeOptions?.useBackendSubmitTx ?? false;
|
|
40880
41486
|
this.instanceConfig = options ? mergeSodaxConfig(sodaxConfig, options) : sodaxConfig;
|
|
40881
41487
|
this.backendApi = new BackendApiService(this.instanceConfig.api, logger);
|
|
40882
41488
|
this.api = this.backendApi;
|
|
@@ -40886,7 +41492,8 @@ var Sodax = class {
|
|
|
40886
41492
|
userConfig: options,
|
|
40887
41493
|
logger,
|
|
40888
41494
|
analytics,
|
|
40889
|
-
fee
|
|
41495
|
+
fee,
|
|
41496
|
+
radfiSigner
|
|
40890
41497
|
});
|
|
40891
41498
|
this.hubProvider = new EvmHubProvider({ config: this.config });
|
|
40892
41499
|
this.spoke = new SpokeService({ config: this.config, hubProvider: this.hubProvider });
|
|
@@ -40912,7 +41519,13 @@ var Sodax = class {
|
|
|
40912
41519
|
config: this.config,
|
|
40913
41520
|
spoke: this.spoke
|
|
40914
41521
|
});
|
|
40915
|
-
this.bridge = new BridgeService({
|
|
41522
|
+
this.bridge = new BridgeService({
|
|
41523
|
+
hubProvider: this.hubProvider,
|
|
41524
|
+
config: this.config,
|
|
41525
|
+
spoke: this.spoke,
|
|
41526
|
+
backendApi: this.backendApi,
|
|
41527
|
+
useBackendSubmitTx: bridgeUseBackendSubmitTx
|
|
41528
|
+
});
|
|
40916
41529
|
this.staking = new StakingService({ hubProvider: this.hubProvider, config: this.config, spoke: this.spoke });
|
|
40917
41530
|
this.partners = new PartnerService({
|
|
40918
41531
|
hubProvider: this.hubProvider,
|
|
@@ -40984,6 +41597,7 @@ exports.APPROVE_CODES = APPROVE_CODES;
|
|
|
40984
41597
|
exports.AssetService = AssetService;
|
|
40985
41598
|
exports.BITCOIN_CHAIN_KEYS = BITCOIN_CHAIN_KEYS;
|
|
40986
41599
|
exports.BITCOIN_CHAIN_KEYS_SET = BITCOIN_CHAIN_KEYS_SET;
|
|
41600
|
+
exports.BITCOIN_DUST_SATS = BITCOIN_DUST_SATS;
|
|
40987
41601
|
exports.BTC_WALLET_ADDRESS_TYPES = BTC_WALLET_ADDRESS_TYPES;
|
|
40988
41602
|
exports.BackendApiService = BackendApiService;
|
|
40989
41603
|
exports.BackendHttpError = BackendHttpError;
|
|
@@ -40992,6 +41606,7 @@ exports.BigIntToHex = BigIntToHex;
|
|
|
40992
41606
|
exports.BigNumberZeroDecimal = BigNumberZeroDecimal;
|
|
40993
41607
|
exports.BitcoinSpokeService = BitcoinSpokeService;
|
|
40994
41608
|
exports.BnUSDMigrationService = BnUSDMigrationService;
|
|
41609
|
+
exports.BridgeApiService = BridgeApiService;
|
|
40995
41610
|
exports.BridgeService = BridgeService;
|
|
40996
41611
|
exports.CHAIN_KEYS = CHAIN_KEYS;
|
|
40997
41612
|
exports.CHAIN_LOGO_BASE_URL = CHAIN_LOGO_BASE_URL;
|
|
@@ -41075,6 +41690,7 @@ exports.ProtocolIntentsAbi = ProtocolIntentsAbi;
|
|
|
41075
41690
|
exports.RAY = RAY;
|
|
41076
41691
|
exports.RAY_DECIMALS = RAY_DECIMALS;
|
|
41077
41692
|
exports.RELAY_ERROR_CODES = RELAY_ERROR_CODES;
|
|
41693
|
+
exports.RELAY_FALLBACK_FLOOR_MS = RELAY_FALLBACK_FLOOR_MS;
|
|
41078
41694
|
exports.RadfiApiError = RadfiApiError;
|
|
41079
41695
|
exports.RadfiProvider = RadfiProvider;
|
|
41080
41696
|
exports.RecoveryService = RecoveryService;
|
|
@@ -41279,6 +41895,8 @@ exports.isMoneyMarketCreateIntentError = isMoneyMarketCreateIntentError;
|
|
|
41279
41895
|
exports.isMoneyMarketError = isMoneyMarketError;
|
|
41280
41896
|
exports.isMoneyMarketGasEstimationError = isMoneyMarketGasEstimationError;
|
|
41281
41897
|
exports.isMoneyMarketOrchestrationError = isMoneyMarketOrchestrationError;
|
|
41898
|
+
exports.isNativeBitcoinToken = isNativeBitcoinToken;
|
|
41899
|
+
exports.isNativeBitcoinTransfer = isNativeBitcoinTransfer;
|
|
41282
41900
|
exports.isNativeToken = isNativeToken;
|
|
41283
41901
|
exports.isNearChainKey = isNearChainKey;
|
|
41284
41902
|
exports.isNearChainKeyType = isNearChainKeyType;
|
|
@@ -41414,6 +42032,7 @@ exports.swapExactInSingleParamsAbi = swapExactInSingleParamsAbi;
|
|
|
41414
42032
|
exports.swapInvariant = swapInvariant;
|
|
41415
42033
|
exports.swapSupportedTokens = swapSupportedTokens;
|
|
41416
42034
|
exports.swapsConfig = swapsConfig;
|
|
42035
|
+
exports.toCreateBridgeIntentParamsV2 = toCreateBridgeIntentParamsV2;
|
|
41417
42036
|
exports.tokenLogo = tokenLogo;
|
|
41418
42037
|
exports.tokenLogoSlug = tokenLogoSlug;
|
|
41419
42038
|
exports.uiPoolDataAbi = uiPoolDataAbi;
|