@sodax/sdk 2.0.0-rc.19 → 2.0.0-rc.20
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/README.md +4 -4
- package/dist/index.cjs +544 -762
- package/dist/index.d.cts +124 -175
- package/dist/index.d.ts +124 -175
- package/dist/index.mjs +540 -764
- package/package.json +4 -3
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { getAbiItem, parseAbi, isAddress, toHex, hexToBytes, encodeAbiParameters, parseAbiParameters, defineChain, encodeFunctionData, erc20Abi as erc20Abi$1, createPublicClient, http, bytesToHex, keccak256, stringToBytes, fromHex, encodePacked, decodeAbiParameters, parseEventLogs, maxUint160, maxUint48 } from 'viem';
|
|
1
|
+
import { getAbiItem, parseAbi, isAddress, toHex, hexToBytes, encodeAbiParameters, parseAbiParameters, defineChain, encodeFunctionData, erc20Abi as erc20Abi$1, createPublicClient, http, bytesToHex, keccak256, stringToBytes, fromHex, encodePacked, decodeAbiParameters, parseEventLogs, maxUint160, maxUint48, fallback } from 'viem';
|
|
2
2
|
import { bcs } from '@mysten/sui/bcs';
|
|
3
3
|
import { PublicKey, Connection, VersionedTransaction, SystemProgram, ComputeBudgetProgram, TransactionMessage, TransactionInstruction } from '@solana/web3.js';
|
|
4
4
|
import { rpc, Address, xdr, Account, Horizon, Contract, TransactionBuilder, nativeToScVal, TimeoutInfinite, scValToBigInt, Operation, Asset, FeeBumpTransaction } from '@stellar/stellar-sdk';
|
|
5
5
|
import { serializeCV, Cl, deserializeCV, cvToString, createNetwork, fetchFeeEstimateTransaction, fetchCallReadOnlyFunction, parseContractId, PostConditionMode, noneCV, someCV, uintCV, getAddressFromPublicKey, makeUnsignedContractCall, serializePayloadBytes } from '@sodax/libs/stacks/core';
|
|
6
|
-
import { kaia, redbellyMainnet, mainnet, lightlinkPhoenix, polygon, bsc, optimism, base, arbitrum, avalanche, sonic } from 'viem/chains';
|
|
6
|
+
import { hedera, kaia, redbellyMainnet, mainnet, lightlinkPhoenix, polygon, bsc, optimism, base, arbitrum, avalanche, sonic } from 'viem/chains';
|
|
7
7
|
import * as rlp from 'rlp';
|
|
8
8
|
import { initEccLib, networks, Transaction, Psbt, payments, opcodes, script } from 'bitcoinjs-lib';
|
|
9
9
|
import * as ecc from '@bitcoinerlab/secp256k1';
|
|
@@ -17,7 +17,9 @@ import * as IconSdkRaw from 'icon-sdk-js';
|
|
|
17
17
|
import { ChainGrpcWasmApi, TxGrpcApi, toBase64, fromBase64, MsgExecuteContract, ChainRestAuthApi, BaseAccount, createTransaction } from '@injectivelabs/sdk-ts';
|
|
18
18
|
import { TxRaw } from 'cosmjs-types/cosmos/tx/v1beta1/tx.js';
|
|
19
19
|
import { getNetworkEndpoints, Network } from '@injectivelabs/networks';
|
|
20
|
-
import * as
|
|
20
|
+
import * as v2 from 'valibot';
|
|
21
|
+
import { SwapsApi, SwapsApiError } from '@sodax/swaps-api';
|
|
22
|
+
export { SwapsApiError } from '@sodax/swaps-api';
|
|
21
23
|
import BigNumber5, { BigNumber } from 'bignumber.js';
|
|
22
24
|
import { Token, Price } from '@pancakeswap/swap-sdk-core';
|
|
23
25
|
import { sqrtRatioX96ToPrice, PositionMath, tickToPrice, TickMath, maxLiquidityForAmount0Precise, maxLiquidityForAmount1, maxLiquidityForAmounts } from '@pancakeswap/v3-sdk';
|
|
@@ -92,8 +94,8 @@ function serializeCause(cause, depth) {
|
|
|
92
94
|
}
|
|
93
95
|
function sanitizeContext(value, depth) {
|
|
94
96
|
const out = {};
|
|
95
|
-
for (const [key,
|
|
96
|
-
out[key] = sanitizeValue(
|
|
97
|
+
for (const [key, v4] of Object.entries(value)) {
|
|
98
|
+
out[key] = sanitizeValue(v4, depth + 1);
|
|
97
99
|
}
|
|
98
100
|
return out;
|
|
99
101
|
}
|
|
@@ -104,13 +106,13 @@ function sanitizeValue(value, depth) {
|
|
|
104
106
|
if (t === "bigint") return value.toString();
|
|
105
107
|
if (t === "string" || t === "number" || t === "boolean") return value;
|
|
106
108
|
if (t === "function" || t === "symbol") return safeString(value);
|
|
107
|
-
if (Array.isArray(value)) return value.map((
|
|
109
|
+
if (Array.isArray(value)) return value.map((v4) => sanitizeValue(v4, depth + 1));
|
|
108
110
|
if (value instanceof Date) return value.toISOString();
|
|
109
111
|
if (value instanceof Map) {
|
|
110
|
-
return Array.from(value.entries()).map(([k,
|
|
112
|
+
return Array.from(value.entries()).map(([k, v4]) => [sanitizeValue(k, depth + 1), sanitizeValue(v4, depth + 1)]);
|
|
111
113
|
}
|
|
112
114
|
if (value instanceof Set) {
|
|
113
|
-
return Array.from(value.values()).map((
|
|
115
|
+
return Array.from(value.values()).map((v4) => sanitizeValue(v4, depth + 1));
|
|
114
116
|
}
|
|
115
117
|
if (value instanceof Error) return { name: value.name, message: value.message };
|
|
116
118
|
if (t === "object") {
|
|
@@ -122,9 +124,9 @@ function sanitizeValue(value, depth) {
|
|
|
122
124
|
}
|
|
123
125
|
return safeString(value);
|
|
124
126
|
}
|
|
125
|
-
function safeString(
|
|
127
|
+
function safeString(v4) {
|
|
126
128
|
try {
|
|
127
|
-
return String(
|
|
129
|
+
return String(v4);
|
|
128
130
|
} catch {
|
|
129
131
|
return "[unserializable]";
|
|
130
132
|
}
|
|
@@ -132,11 +134,17 @@ function safeString(v6) {
|
|
|
132
134
|
|
|
133
135
|
// src/errors/codes.ts
|
|
134
136
|
var CREATE_INTENT_CODES = /* @__PURE__ */ new Set([
|
|
137
|
+
"USER_REJECTED",
|
|
135
138
|
"VALIDATION_FAILED",
|
|
136
139
|
"INTENT_CREATION_FAILED",
|
|
137
140
|
"UNKNOWN"
|
|
138
141
|
]);
|
|
139
|
-
var APPROVE_CODES = /* @__PURE__ */ new Set([
|
|
142
|
+
var APPROVE_CODES = /* @__PURE__ */ new Set([
|
|
143
|
+
"USER_REJECTED",
|
|
144
|
+
"VALIDATION_FAILED",
|
|
145
|
+
"APPROVE_FAILED",
|
|
146
|
+
"UNKNOWN"
|
|
147
|
+
]);
|
|
140
148
|
var ALLOWANCE_CHECK_CODES = /* @__PURE__ */ new Set([
|
|
141
149
|
"VALIDATION_FAILED",
|
|
142
150
|
"ALLOWANCE_CHECK_FAILED",
|
|
@@ -149,6 +157,7 @@ var GAS_ESTIMATION_CODES = /* @__PURE__ */ new Set([
|
|
|
149
157
|
]);
|
|
150
158
|
var LOOKUP_CODES = /* @__PURE__ */ new Set(["VALIDATION_FAILED", "LOOKUP_FAILED", "UNKNOWN"]);
|
|
151
159
|
var SODAX_ERROR_CODES = [
|
|
160
|
+
"USER_REJECTED",
|
|
152
161
|
"VALIDATION_FAILED",
|
|
153
162
|
"INTENT_CREATION_FAILED",
|
|
154
163
|
"EXECUTION_FAILED",
|
|
@@ -270,7 +279,8 @@ var ChainKeys = {
|
|
|
270
279
|
BITCOIN_MAINNET: "bitcoin",
|
|
271
280
|
REDBELLY_MAINNET: "redbelly",
|
|
272
281
|
KAIA_MAINNET: "0x2019.kaia",
|
|
273
|
-
STACKS_MAINNET: "stacks"
|
|
282
|
+
STACKS_MAINNET: "stacks",
|
|
283
|
+
HEDERA_MAINNET: "hedera"
|
|
274
284
|
};
|
|
275
285
|
var CHAIN_KEYS = Object.values(ChainKeys);
|
|
276
286
|
var spokeChainKeysSet = new Set(CHAIN_KEYS);
|
|
@@ -307,6 +317,7 @@ var HubVaultSymbols = [
|
|
|
307
317
|
"sodaKAIA",
|
|
308
318
|
"sodaSTX",
|
|
309
319
|
"sodaUSDS",
|
|
320
|
+
"sodaHBAR",
|
|
310
321
|
"sodaJITOSOL"
|
|
311
322
|
];
|
|
312
323
|
var SodaTokens = {
|
|
@@ -535,6 +546,15 @@ var SodaTokens = {
|
|
|
535
546
|
hubAsset: "0x243b0c26c8b38793908d7C64e8510f21B19B4613",
|
|
536
547
|
vault: "0x243b0c26c8b38793908d7C64e8510f21B19B4613"
|
|
537
548
|
},
|
|
549
|
+
sodaHBAR: {
|
|
550
|
+
symbol: "sodaHBAR",
|
|
551
|
+
name: "Soda HBAR",
|
|
552
|
+
decimals: 18,
|
|
553
|
+
address: "0x3BB956cc8922E1Ba4148dc10eD1b4Fa19aa599c4",
|
|
554
|
+
chainKey: ChainKeys.SONIC_MAINNET,
|
|
555
|
+
hubAsset: "0x3BB956cc8922E1Ba4148dc10eD1b4Fa19aa599c4",
|
|
556
|
+
vault: "0x3BB956cc8922E1Ba4148dc10eD1b4Fa19aa599c4"
|
|
557
|
+
},
|
|
538
558
|
sodaJITOSOL: {
|
|
539
559
|
symbol: "sodaJITOSOL",
|
|
540
560
|
name: "Soda JITOSOL",
|
|
@@ -2520,6 +2540,44 @@ var kaiaSupportedTokens = {
|
|
|
2520
2540
|
vault: SodaTokens.sodaSODA.address
|
|
2521
2541
|
}
|
|
2522
2542
|
};
|
|
2543
|
+
var hederaSupportedTokens = {
|
|
2544
|
+
HBAR: {
|
|
2545
|
+
symbol: "HBAR",
|
|
2546
|
+
name: "HBAR",
|
|
2547
|
+
decimals: 8,
|
|
2548
|
+
address: "0x0000000000000000000000000000000000000000",
|
|
2549
|
+
chainKey: ChainKeys.HEDERA_MAINNET,
|
|
2550
|
+
hubAsset: "0x5c18c543b6B6EA97dE739F48C49CfC291B3AD465",
|
|
2551
|
+
vault: SodaTokens.sodaHBAR.address
|
|
2552
|
+
},
|
|
2553
|
+
bnUSD: {
|
|
2554
|
+
symbol: "bnUSD",
|
|
2555
|
+
name: "bnUSD",
|
|
2556
|
+
decimals: 8,
|
|
2557
|
+
address: "0x0000000000000000000000000000000000a0286a",
|
|
2558
|
+
chainKey: ChainKeys.HEDERA_MAINNET,
|
|
2559
|
+
hubAsset: "0x44be1984cd279334a630469fa357305c7dba2837",
|
|
2560
|
+
vault: SodaTokens.bnUSD.address
|
|
2561
|
+
},
|
|
2562
|
+
SODA: {
|
|
2563
|
+
symbol: "SODA",
|
|
2564
|
+
name: "SODAX",
|
|
2565
|
+
decimals: 8,
|
|
2566
|
+
address: "0x0000000000000000000000000000000000a02869",
|
|
2567
|
+
chainKey: ChainKeys.HEDERA_MAINNET,
|
|
2568
|
+
hubAsset: "0x1217721376839dbffe78093ddd5d8e50d0239b3f",
|
|
2569
|
+
vault: SodaTokens.sodaSODA.address
|
|
2570
|
+
},
|
|
2571
|
+
USDC: {
|
|
2572
|
+
symbol: "USDC",
|
|
2573
|
+
name: "USD Coin",
|
|
2574
|
+
decimals: 6,
|
|
2575
|
+
address: "0x000000000000000000000000000000000006f89a",
|
|
2576
|
+
chainKey: ChainKeys.HEDERA_MAINNET,
|
|
2577
|
+
hubAsset: "0xafafae0c1476424c4b81f09095bd7dcb858047c8",
|
|
2578
|
+
vault: SodaTokens.sodaUSDC.address
|
|
2579
|
+
}
|
|
2580
|
+
};
|
|
2523
2581
|
var stacksSupportedTokens = {
|
|
2524
2582
|
STX: {
|
|
2525
2583
|
symbol: "STX",
|
|
@@ -2587,7 +2645,8 @@ var supportedTokensByChain = {
|
|
|
2587
2645
|
[ChainKeys.NEAR_MAINNET]: nearSupportedTokens,
|
|
2588
2646
|
[ChainKeys.ETHEREUM_MAINNET]: ethereumSupportedTokens,
|
|
2589
2647
|
[ChainKeys.KAIA_MAINNET]: kaiaSupportedTokens,
|
|
2590
|
-
[ChainKeys.STACKS_MAINNET]: stacksSupportedTokens
|
|
2648
|
+
[ChainKeys.STACKS_MAINNET]: stacksSupportedTokens,
|
|
2649
|
+
[ChainKeys.HEDERA_MAINNET]: hederaSupportedTokens
|
|
2591
2650
|
};
|
|
2592
2651
|
|
|
2593
2652
|
// ../types/dist/chains/chains.js
|
|
@@ -2611,7 +2670,8 @@ var RelayChainIdMap = {
|
|
|
2611
2670
|
[ChainKeys.BITCOIN_MAINNET]: 627463n,
|
|
2612
2671
|
[ChainKeys.REDBELLY_MAINNET]: 726564n,
|
|
2613
2672
|
[ChainKeys.KAIA_MAINNET]: 27489n,
|
|
2614
|
-
[ChainKeys.STACKS_MAINNET]: 60n
|
|
2673
|
+
[ChainKeys.STACKS_MAINNET]: 60n,
|
|
2674
|
+
[ChainKeys.HEDERA_MAINNET]: 18501n
|
|
2615
2675
|
};
|
|
2616
2676
|
var INTENT_CHAIN_IDS = Object.values(RelayChainIdMap);
|
|
2617
2677
|
var IntentRelayChainIdToChainKey = new Map(Object.entries(RelayChainIdMap).map(([chainKey, chainId]) => [chainId, chainKey]));
|
|
@@ -2897,6 +2957,20 @@ var baseChainInfo = {
|
|
|
2897
2957
|
addressUrl: "https://explorer.hiro.so/address/",
|
|
2898
2958
|
contractUrl: "https://explorer.hiro.so/txid/"
|
|
2899
2959
|
}
|
|
2960
|
+
},
|
|
2961
|
+
[ChainKeys.HEDERA_MAINNET]: {
|
|
2962
|
+
name: "Hedera",
|
|
2963
|
+
key: ChainKeys.HEDERA_MAINNET,
|
|
2964
|
+
type: "EVM",
|
|
2965
|
+
chainId: 295,
|
|
2966
|
+
mainnet: true,
|
|
2967
|
+
logo: chainLogo(ChainKeys.HEDERA_MAINNET),
|
|
2968
|
+
explorer: {
|
|
2969
|
+
baseUrl: "https://hashscan.io/mainnet/",
|
|
2970
|
+
txUrl: "https://hashscan.io/mainnet/transaction/",
|
|
2971
|
+
addressUrl: "https://hashscan.io/mainnet/account/",
|
|
2972
|
+
contractUrl: "https://hashscan.io/mainnet/contract/"
|
|
2973
|
+
}
|
|
2900
2974
|
}
|
|
2901
2975
|
};
|
|
2902
2976
|
var filterChainKeysByType = (type) => CHAIN_KEYS.filter((key) => baseChainInfo[key].type === type);
|
|
@@ -3292,6 +3366,21 @@ var spokeChainConfig = {
|
|
|
3292
3366
|
pollingIntervalMs: 1e4,
|
|
3293
3367
|
maxTimeoutMs: 12e4
|
|
3294
3368
|
}
|
|
3369
|
+
},
|
|
3370
|
+
[ChainKeys.HEDERA_MAINNET]: {
|
|
3371
|
+
chain: baseChainInfo[ChainKeys.HEDERA_MAINNET],
|
|
3372
|
+
rpcUrl: "https://mainnet.hashio.io/api",
|
|
3373
|
+
addresses: {
|
|
3374
|
+
assetManager: "0x0df73542cC68bDC01b361d231c60F726B0e0bC05",
|
|
3375
|
+
connection: "0x4555aC13D7338D9E671584C1D118c06B2a3C88eD"
|
|
3376
|
+
},
|
|
3377
|
+
nativeToken: "0x0000000000000000000000000000000000000000",
|
|
3378
|
+
bnUSD: "0x0000000000000000000000000000000000a0286a",
|
|
3379
|
+
supportedTokens: hederaSupportedTokens,
|
|
3380
|
+
pollingConfig: {
|
|
3381
|
+
pollingIntervalMs: 2e3,
|
|
3382
|
+
maxTimeoutMs: 6e4
|
|
3383
|
+
}
|
|
3295
3384
|
}
|
|
3296
3385
|
};
|
|
3297
3386
|
var supportedSpokeChains = Object.keys(spokeChainConfig);
|
|
@@ -3542,6 +3631,11 @@ var moneyMarketSupportedTokens = {
|
|
|
3542
3631
|
],
|
|
3543
3632
|
[ChainKeys.BITCOIN_MAINNET]: [
|
|
3544
3633
|
spokeChainConfig[ChainKeys.BITCOIN_MAINNET].supportedTokens.BTC
|
|
3634
|
+
],
|
|
3635
|
+
[ChainKeys.HEDERA_MAINNET]: [
|
|
3636
|
+
spokeChainConfig[ChainKeys.HEDERA_MAINNET].supportedTokens.bnUSD,
|
|
3637
|
+
spokeChainConfig[ChainKeys.HEDERA_MAINNET].supportedTokens.SODA,
|
|
3638
|
+
spokeChainConfig[ChainKeys.HEDERA_MAINNET].supportedTokens.USDC
|
|
3545
3639
|
]
|
|
3546
3640
|
};
|
|
3547
3641
|
var moneyMarketReserveAssets = [
|
|
@@ -3951,7 +4045,9 @@ var swapSupportedTokens = {
|
|
|
3951
4045
|
spokeChainConfig[ChainKeys.STACKS_MAINNET].supportedTokens.SODA,
|
|
3952
4046
|
spokeChainConfig[ChainKeys.STACKS_MAINNET].supportedTokens.sBTC,
|
|
3953
4047
|
spokeChainConfig[ChainKeys.STACKS_MAINNET].supportedTokens.USDC
|
|
3954
|
-
]
|
|
4048
|
+
],
|
|
4049
|
+
// Hedera is currently staging-only — see stagingSwapSupportedTokens
|
|
4050
|
+
[ChainKeys.HEDERA_MAINNET]: []
|
|
3955
4051
|
};
|
|
3956
4052
|
var stagingSwapSupportedTokens = {
|
|
3957
4053
|
[ChainKeys.SONIC_MAINNET]: [SodaTokens.sodaUSDS],
|
|
@@ -3984,7 +4080,13 @@ var stagingSwapSupportedTokens = {
|
|
|
3984
4080
|
],
|
|
3985
4081
|
[ChainKeys.REDBELLY_MAINNET]: [],
|
|
3986
4082
|
[ChainKeys.KAIA_MAINNET]: [],
|
|
3987
|
-
[ChainKeys.STACKS_MAINNET]: []
|
|
4083
|
+
[ChainKeys.STACKS_MAINNET]: [],
|
|
4084
|
+
[ChainKeys.HEDERA_MAINNET]: [
|
|
4085
|
+
spokeChainConfig[ChainKeys.HEDERA_MAINNET].supportedTokens.HBAR,
|
|
4086
|
+
spokeChainConfig[ChainKeys.HEDERA_MAINNET].supportedTokens.bnUSD,
|
|
4087
|
+
spokeChainConfig[ChainKeys.HEDERA_MAINNET].supportedTokens.USDC,
|
|
4088
|
+
spokeChainConfig[ChainKeys.HEDERA_MAINNET].supportedTokens.SODA
|
|
4089
|
+
]
|
|
3988
4090
|
};
|
|
3989
4091
|
var swapsConfig = {
|
|
3990
4092
|
supportedTokens: swapSupportedTokens
|
|
@@ -4220,7 +4322,7 @@ function isValidWalletProviderForChainKey(chainKey, walletProvider) {
|
|
|
4220
4322
|
}
|
|
4221
4323
|
|
|
4222
4324
|
// ../types/dist/index.js
|
|
4223
|
-
var CONFIG_VERSION =
|
|
4325
|
+
var CONFIG_VERSION = 218;
|
|
4224
4326
|
function isEvmSpokeChainConfig(value) {
|
|
4225
4327
|
return typeof value === "object" && value !== null && value.chain.type === "EVM" && value.chain.key !== HUB_CHAIN_KEY;
|
|
4226
4328
|
}
|
|
@@ -4347,11 +4449,11 @@ async function retry(action, retryCount = DEFAULT_MAX_RETRY, delayMs = DEFAULT_R
|
|
|
4347
4449
|
throw new Error(`Retry exceeded MAX_RETRY_DEFAULT=${DEFAULT_MAX_RETRY}`);
|
|
4348
4450
|
}
|
|
4349
4451
|
function getRandomBytes(length) {
|
|
4350
|
-
const
|
|
4452
|
+
const array2 = new Uint8Array(length);
|
|
4351
4453
|
for (let i = 0; i < length; i++) {
|
|
4352
|
-
|
|
4454
|
+
array2[i] = Math.floor(Math.random() * 256);
|
|
4353
4455
|
}
|
|
4354
|
-
return
|
|
4456
|
+
return array2;
|
|
4355
4457
|
}
|
|
4356
4458
|
function randomUint256() {
|
|
4357
4459
|
const bytes = getRandomBytes(32);
|
|
@@ -4710,8 +4812,61 @@ function isCodeMember(codes) {
|
|
|
4710
4812
|
}
|
|
4711
4813
|
|
|
4712
4814
|
// src/errors/wrappers.ts
|
|
4713
|
-
function messageOf(error,
|
|
4714
|
-
return error instanceof Error ? error.message :
|
|
4815
|
+
function messageOf(error, fallback2) {
|
|
4816
|
+
return error instanceof Error ? error.message : fallback2;
|
|
4817
|
+
}
|
|
4818
|
+
var REJECTION_TEXT_PATTERNS = [
|
|
4819
|
+
/user rejected/i,
|
|
4820
|
+
/user denied/i,
|
|
4821
|
+
/user declined/i,
|
|
4822
|
+
/user cancel(?:l)?ed/i,
|
|
4823
|
+
/user abort(?:ed)?/i,
|
|
4824
|
+
/user closed/i,
|
|
4825
|
+
/rejected by user/i,
|
|
4826
|
+
/cancelled by user/i,
|
|
4827
|
+
/canceled by user/i,
|
|
4828
|
+
// `was` is mandatory: matches Phantom / Brave's "Transaction was rejected" (user cancellation)
|
|
4829
|
+
// but NOT bare "Transaction rejected by node / by validator" (network or chain-level reject).
|
|
4830
|
+
/transaction was rejected/i,
|
|
4831
|
+
/signature rejected/i,
|
|
4832
|
+
/request rejected/i,
|
|
4833
|
+
/cancel_signing/i,
|
|
4834
|
+
/cancel_json-rpc/i,
|
|
4835
|
+
/popup ?closed/i
|
|
4836
|
+
];
|
|
4837
|
+
function matchRejectionText(text) {
|
|
4838
|
+
if (typeof text !== "string" || text.length === 0) return false;
|
|
4839
|
+
for (const pattern of REJECTION_TEXT_PATTERNS) {
|
|
4840
|
+
if (pattern.test(text)) return true;
|
|
4841
|
+
}
|
|
4842
|
+
return false;
|
|
4843
|
+
}
|
|
4844
|
+
function isWalletRejection(error) {
|
|
4845
|
+
if (error == null) return false;
|
|
4846
|
+
if (isSodaxError(error)) return error.code === "USER_REJECTED";
|
|
4847
|
+
if (typeof error === "string") return matchRejectionText(error);
|
|
4848
|
+
if (typeof error !== "object") return false;
|
|
4849
|
+
const o = error;
|
|
4850
|
+
if (o.name === "UserRejectedRequestError") return true;
|
|
4851
|
+
if (o.name === "WalletSignTransactionError" && matchRejectionText(o.message)) return true;
|
|
4852
|
+
if (o.name === "WalletConnectionError" && matchRejectionText(o.message)) return true;
|
|
4853
|
+
if (o.code === 4001) return true;
|
|
4854
|
+
if (o.code === "ACTION_REJECTED") return true;
|
|
4855
|
+
if (o.code === "CANCEL_SIGNING") return true;
|
|
4856
|
+
if (o.code === "CANCEL_JSON-RPC") return true;
|
|
4857
|
+
if (o.code === -31002) return true;
|
|
4858
|
+
if (matchRejectionText(o.shortMessage)) return true;
|
|
4859
|
+
if (matchRejectionText(o.details)) return true;
|
|
4860
|
+
if (matchRejectionText(o.message)) return true;
|
|
4861
|
+
if (matchRejectionText(o.reason)) return true;
|
|
4862
|
+
return false;
|
|
4863
|
+
}
|
|
4864
|
+
function userRejected(feature, cause, context) {
|
|
4865
|
+
return new SodaxError("USER_REJECTED", "User rejected the request", {
|
|
4866
|
+
feature,
|
|
4867
|
+
cause,
|
|
4868
|
+
context
|
|
4869
|
+
});
|
|
4715
4870
|
}
|
|
4716
4871
|
function lookupFailed(feature, method, cause, context) {
|
|
4717
4872
|
return new SodaxError("LOOKUP_FAILED", messageOf(cause, `${method} failed`), {
|
|
@@ -4728,6 +4883,7 @@ function verifyFailed(feature, cause, context) {
|
|
|
4728
4883
|
});
|
|
4729
4884
|
}
|
|
4730
4885
|
function intentCreationFailed(feature, cause, context) {
|
|
4886
|
+
if (isWalletRejection(cause)) return userRejected(feature, cause, { phase: "intentCreation", ...context });
|
|
4731
4887
|
return new SodaxError("INTENT_CREATION_FAILED", messageOf(cause, "Intent creation failed"), {
|
|
4732
4888
|
feature,
|
|
4733
4889
|
cause,
|
|
@@ -4742,6 +4898,7 @@ function executionFailed(feature, cause, context) {
|
|
|
4742
4898
|
});
|
|
4743
4899
|
}
|
|
4744
4900
|
function approveFailed(feature, cause, context) {
|
|
4901
|
+
if (isWalletRejection(cause)) return userRejected(feature, cause, { phase: "approve", ...context });
|
|
4745
4902
|
return new SodaxError("APPROVE_FAILED", messageOf(cause, "Approve failed"), {
|
|
4746
4903
|
feature,
|
|
4747
4904
|
cause,
|
|
@@ -14026,7 +14183,7 @@ function mergeSodaxConfig(base2, override) {
|
|
|
14026
14183
|
}
|
|
14027
14184
|
function encodeContractCalls(calls) {
|
|
14028
14185
|
return encodeAbiParameters(parseAbiParameters("(address,uint256,bytes)[]"), [
|
|
14029
|
-
calls.map((
|
|
14186
|
+
calls.map((v4) => [v4.address, v4.value, v4.data])
|
|
14030
14187
|
]);
|
|
14031
14188
|
}
|
|
14032
14189
|
async function waitForTransactionReceipt(hash, provider) {
|
|
@@ -14110,6 +14267,8 @@ function getEvmViemChain(key) {
|
|
|
14110
14267
|
return redbellyMainnet;
|
|
14111
14268
|
case ChainKeys.KAIA_MAINNET:
|
|
14112
14269
|
return kaia;
|
|
14270
|
+
case ChainKeys.HEDERA_MAINNET:
|
|
14271
|
+
return hedera;
|
|
14113
14272
|
default: {
|
|
14114
14273
|
const exhaustiveCheck = key;
|
|
14115
14274
|
console.log(exhaustiveCheck);
|
|
@@ -14124,7 +14283,7 @@ var EvmVaultTokenService = class {
|
|
|
14124
14283
|
* Fetches token information for a specific token in the vault.
|
|
14125
14284
|
* @param vault - The address of the vault.
|
|
14126
14285
|
* @param token - The address of the token.
|
|
14127
|
-
* @param publicClient - PublicClient
|
|
14286
|
+
* @param publicClient - PublicClient
|
|
14128
14287
|
* @returns Token information as a TokenInfo object.
|
|
14129
14288
|
*/
|
|
14130
14289
|
static async getTokenInfo(vault, token, publicClient) {
|
|
@@ -14163,7 +14322,7 @@ var EvmVaultTokenService = class {
|
|
|
14163
14322
|
/**
|
|
14164
14323
|
* Retrieves the reserves of the vault.
|
|
14165
14324
|
* @param vault - The address of the vault.
|
|
14166
|
-
* @param publicClient - PublicClient
|
|
14325
|
+
* @param publicClient - PublicClient
|
|
14167
14326
|
* @returns An object containing tokens and their balances.
|
|
14168
14327
|
*/
|
|
14169
14328
|
static async getVaultReserves(vault, publicClient) {
|
|
@@ -14181,7 +14340,7 @@ var EvmVaultTokenService = class {
|
|
|
14181
14340
|
/**
|
|
14182
14341
|
* Retrieves all token information for the vault.
|
|
14183
14342
|
* @param vault - The address of the vault.
|
|
14184
|
-
* @param publicClient - PublicClient
|
|
14343
|
+
* @param publicClient - PublicClient
|
|
14185
14344
|
* @returns A promise that resolves to an object containing tokens, their infos, and reserves.
|
|
14186
14345
|
*/
|
|
14187
14346
|
static async getAllTokenInfo(vault, publicClient) {
|
|
@@ -14541,6 +14700,10 @@ var EvmAssetManagerService = class _EvmAssetManagerService {
|
|
|
14541
14700
|
});
|
|
14542
14701
|
}
|
|
14543
14702
|
};
|
|
14703
|
+
var HEDERA_NATIVE_VALUE_SCALE = 10n ** 10n;
|
|
14704
|
+
function scaleNativeMsgValue(chainKey, amount) {
|
|
14705
|
+
return chainKey === ChainKeys.HEDERA_MAINNET ? amount * HEDERA_NATIVE_VALUE_SCALE : amount;
|
|
14706
|
+
}
|
|
14544
14707
|
var EvmSpokeService = class {
|
|
14545
14708
|
config;
|
|
14546
14709
|
// map containing the public clients for each evm spoke chain, lazy loaded on demand
|
|
@@ -14628,10 +14791,11 @@ var EvmSpokeService = class {
|
|
|
14628
14791
|
async deposit(params) {
|
|
14629
14792
|
const { srcChainKey, srcAddress: from, token, to, amount, data = "0x" } = params;
|
|
14630
14793
|
const chainConfig = this.config.getChainConfig(srcChainKey);
|
|
14794
|
+
const isNative = token.toLowerCase() === chainConfig.nativeToken.toLowerCase();
|
|
14631
14795
|
const rawTx = {
|
|
14632
14796
|
from,
|
|
14633
14797
|
to: chainConfig.addresses.assetManager,
|
|
14634
|
-
value:
|
|
14798
|
+
value: isNative ? scaleNativeMsgValue(srcChainKey, amount) : 0n,
|
|
14635
14799
|
data: encodeFunctionData({
|
|
14636
14800
|
abi: spokeAssetManagerAbi,
|
|
14637
14801
|
functionName: "transfer",
|
|
@@ -14920,8 +15084,8 @@ var RadfiApiError = class extends Error {
|
|
|
14920
15084
|
code;
|
|
14921
15085
|
details;
|
|
14922
15086
|
cause;
|
|
14923
|
-
constructor(status, body,
|
|
14924
|
-
super(body?.message ||
|
|
15087
|
+
constructor(status, body, fallback2) {
|
|
15088
|
+
super(body?.message || fallback2);
|
|
14925
15089
|
this.name = "RadfiApiError";
|
|
14926
15090
|
this.status = status;
|
|
14927
15091
|
this.code = body?.code;
|
|
@@ -15289,7 +15453,7 @@ var RadfiProvider = class {
|
|
|
15289
15453
|
* body as text first and parsing it ourselves lets us raise a `RadfiApiError` carrying the
|
|
15290
15454
|
* actual status code and a body snippet instead.
|
|
15291
15455
|
*/
|
|
15292
|
-
async parseJsonBody(res,
|
|
15456
|
+
async parseJsonBody(res, fallback2) {
|
|
15293
15457
|
const text = await res.text();
|
|
15294
15458
|
try {
|
|
15295
15459
|
return text.length ? JSON.parse(text) : {};
|
|
@@ -15298,7 +15462,7 @@ var RadfiProvider = class {
|
|
|
15298
15462
|
throw new RadfiApiError(
|
|
15299
15463
|
res.status,
|
|
15300
15464
|
{ message: `Bound Exchange returned a non-JSON response (HTTP ${res.status})${snippet ? `: ${snippet}` : ""}` },
|
|
15301
|
-
|
|
15465
|
+
fallback2
|
|
15302
15466
|
);
|
|
15303
15467
|
}
|
|
15304
15468
|
}
|
|
@@ -16002,7 +16166,7 @@ function hexToBytes2(hex) {
|
|
|
16002
16166
|
const al = hl / 2;
|
|
16003
16167
|
if (hl % 2)
|
|
16004
16168
|
throw new Error("hex string expected, got unpadded hex of length " + hl);
|
|
16005
|
-
const
|
|
16169
|
+
const array2 = new Uint8Array(al);
|
|
16006
16170
|
for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) {
|
|
16007
16171
|
const n1 = asciiToBase16(hex.charCodeAt(hi));
|
|
16008
16172
|
const n2 = asciiToBase16(hex.charCodeAt(hi + 1));
|
|
@@ -16010,9 +16174,9 @@ function hexToBytes2(hex) {
|
|
|
16010
16174
|
const char = hex[hi] + hex[hi + 1];
|
|
16011
16175
|
throw new Error('hex string expected, got non-hex character "' + char + '" at index ' + hi);
|
|
16012
16176
|
}
|
|
16013
|
-
|
|
16177
|
+
array2[ai] = n1 * 16 + n2;
|
|
16014
16178
|
}
|
|
16015
|
-
return
|
|
16179
|
+
return array2;
|
|
16016
16180
|
}
|
|
16017
16181
|
function concatBytes(...arrays) {
|
|
16018
16182
|
let sum = 0;
|
|
@@ -16642,22 +16806,22 @@ function createHmacDrbg(hashLen, qByteLen, hmacFn) {
|
|
|
16642
16806
|
const byte0 = Uint8Array.of(0);
|
|
16643
16807
|
const byte1 = Uint8Array.of(1);
|
|
16644
16808
|
const _maxDrbgIters = 1e3;
|
|
16645
|
-
let
|
|
16809
|
+
let v4 = u8n(hashLen);
|
|
16646
16810
|
let k = u8n(hashLen);
|
|
16647
16811
|
let i = 0;
|
|
16648
16812
|
const reset = () => {
|
|
16649
|
-
|
|
16813
|
+
v4.fill(1);
|
|
16650
16814
|
k.fill(0);
|
|
16651
16815
|
i = 0;
|
|
16652
16816
|
};
|
|
16653
|
-
const h = (...msgs) => hmacFn(k, concatBytes(
|
|
16817
|
+
const h = (...msgs) => hmacFn(k, concatBytes(v4, ...msgs));
|
|
16654
16818
|
const reseed = (seed = NULL) => {
|
|
16655
16819
|
k = h(byte0, seed);
|
|
16656
|
-
|
|
16820
|
+
v4 = h();
|
|
16657
16821
|
if (seed.length === 0)
|
|
16658
16822
|
return;
|
|
16659
16823
|
k = h(byte1, seed);
|
|
16660
|
-
|
|
16824
|
+
v4 = h();
|
|
16661
16825
|
};
|
|
16662
16826
|
const gen = () => {
|
|
16663
16827
|
if (i++ >= _maxDrbgIters)
|
|
@@ -16665,10 +16829,10 @@ function createHmacDrbg(hashLen, qByteLen, hmacFn) {
|
|
|
16665
16829
|
let len = 0;
|
|
16666
16830
|
const out = [];
|
|
16667
16831
|
while (len < qByteLen) {
|
|
16668
|
-
|
|
16669
|
-
const sl =
|
|
16832
|
+
v4 = h();
|
|
16833
|
+
const sl = v4.slice();
|
|
16670
16834
|
out.push(sl);
|
|
16671
|
-
len +=
|
|
16835
|
+
len += v4.length;
|
|
16672
16836
|
}
|
|
16673
16837
|
return concatBytes(...out);
|
|
16674
16838
|
};
|
|
@@ -16683,18 +16847,18 @@ function createHmacDrbg(hashLen, qByteLen, hmacFn) {
|
|
|
16683
16847
|
};
|
|
16684
16848
|
return genUntil;
|
|
16685
16849
|
}
|
|
16686
|
-
function validateObject(
|
|
16687
|
-
if (!
|
|
16850
|
+
function validateObject(object2, fields = {}, optFields = {}) {
|
|
16851
|
+
if (!object2 || typeof object2 !== "object")
|
|
16688
16852
|
throw new Error("expected valid options object");
|
|
16689
16853
|
function checkField(fieldName, expectedType, isOpt) {
|
|
16690
|
-
const val =
|
|
16854
|
+
const val = object2[fieldName];
|
|
16691
16855
|
if (isOpt && val === void 0)
|
|
16692
16856
|
return;
|
|
16693
16857
|
const current = typeof val;
|
|
16694
16858
|
if (current !== expectedType || val === null)
|
|
16695
16859
|
throw new Error(`param "${fieldName}" is invalid: expected ${expectedType}, got ${current}`);
|
|
16696
16860
|
}
|
|
16697
|
-
const iter = (f, isOpt) => Object.entries(f).forEach(([k,
|
|
16861
|
+
const iter = (f, isOpt) => Object.entries(f).forEach(([k, v4]) => checkField(k, v4, isOpt));
|
|
16698
16862
|
iter(fields, false);
|
|
16699
16863
|
iter(optFields, true);
|
|
16700
16864
|
}
|
|
@@ -16733,12 +16897,12 @@ function pow2(x, power, modulo) {
|
|
|
16733
16897
|
}
|
|
16734
16898
|
return res;
|
|
16735
16899
|
}
|
|
16736
|
-
function invert(
|
|
16737
|
-
if (
|
|
16900
|
+
function invert(number2, modulo) {
|
|
16901
|
+
if (number2 === _0n2)
|
|
16738
16902
|
throw new Error("invert: expected non-zero number");
|
|
16739
16903
|
if (modulo <= _0n2)
|
|
16740
16904
|
throw new Error("invert: expected positive modulus, got " + modulo);
|
|
16741
|
-
let a = mod(
|
|
16905
|
+
let a = mod(number2, modulo);
|
|
16742
16906
|
let b = modulo;
|
|
16743
16907
|
let x = _0n2, u = _1n2;
|
|
16744
16908
|
while (a !== _0n2) {
|
|
@@ -16765,9 +16929,9 @@ function sqrt3mod4(Fp, n) {
|
|
|
16765
16929
|
function sqrt5mod8(Fp, n) {
|
|
16766
16930
|
const p5div8 = (Fp.ORDER - _5n) / _8n;
|
|
16767
16931
|
const n2 = Fp.mul(n, _2n);
|
|
16768
|
-
const
|
|
16769
|
-
const nv = Fp.mul(n,
|
|
16770
|
-
const i = Fp.mul(Fp.mul(nv, _2n),
|
|
16932
|
+
const v4 = Fp.pow(n2, p5div8);
|
|
16933
|
+
const nv = Fp.mul(n, v4);
|
|
16934
|
+
const i = Fp.mul(Fp.mul(nv, _2n), v4);
|
|
16771
16935
|
const root = Fp.mul(nv, Fp.sub(i, Fp.ONE));
|
|
16772
16936
|
assertIsSquare(Fp, root, n);
|
|
16773
16937
|
return root;
|
|
@@ -17242,27 +17406,27 @@ var wNAF = class {
|
|
|
17242
17406
|
assert0(n);
|
|
17243
17407
|
return acc;
|
|
17244
17408
|
}
|
|
17245
|
-
getPrecomputes(W, point,
|
|
17409
|
+
getPrecomputes(W, point, transform) {
|
|
17246
17410
|
let comp = pointPrecomputes.get(point);
|
|
17247
17411
|
if (!comp) {
|
|
17248
17412
|
comp = this.precomputeWindow(point, W);
|
|
17249
17413
|
if (W !== 1) {
|
|
17250
|
-
if (typeof
|
|
17251
|
-
comp =
|
|
17414
|
+
if (typeof transform === "function")
|
|
17415
|
+
comp = transform(comp);
|
|
17252
17416
|
pointPrecomputes.set(point, comp);
|
|
17253
17417
|
}
|
|
17254
17418
|
}
|
|
17255
17419
|
return comp;
|
|
17256
17420
|
}
|
|
17257
|
-
cached(point, scalar,
|
|
17421
|
+
cached(point, scalar, transform) {
|
|
17258
17422
|
const W = getW(point);
|
|
17259
|
-
return this.wNAF(W, this.getPrecomputes(W, point,
|
|
17423
|
+
return this.wNAF(W, this.getPrecomputes(W, point, transform), scalar);
|
|
17260
17424
|
}
|
|
17261
|
-
unsafe(point, scalar,
|
|
17425
|
+
unsafe(point, scalar, transform, prev) {
|
|
17262
17426
|
const W = getW(point);
|
|
17263
17427
|
if (W === 1)
|
|
17264
17428
|
return this._unsafeLadder(point, scalar, prev);
|
|
17265
|
-
return this.wNAFUnsafe(W, this.getPrecomputes(W, point,
|
|
17429
|
+
return this.wNAFUnsafe(W, this.getPrecomputes(W, point, transform), scalar, prev);
|
|
17266
17430
|
}
|
|
17267
17431
|
// We calculate precomputes for elliptic curve point multiplication
|
|
17268
17432
|
// using windowed method. This specifies window size and
|
|
@@ -17349,9 +17513,9 @@ function edwards(params, extraOpts = {}) {
|
|
|
17349
17513
|
validateObject(extraOpts, {}, { uvRatio: "function" });
|
|
17350
17514
|
const MASK = _2n2 << BigInt(Fn.BYTES * 8) - _1n4;
|
|
17351
17515
|
const modP = (n) => Fp.create(n);
|
|
17352
|
-
const uvRatio2 = extraOpts.uvRatio || ((u,
|
|
17516
|
+
const uvRatio2 = extraOpts.uvRatio || ((u, v4) => {
|
|
17353
17517
|
try {
|
|
17354
|
-
return { isValid: true, value: Fp.sqrt(Fp.div(u,
|
|
17518
|
+
return { isValid: true, value: Fp.sqrt(Fp.div(u, v4)) };
|
|
17355
17519
|
} catch (e) {
|
|
17356
17520
|
return { isValid: false, value: _0n4 };
|
|
17357
17521
|
}
|
|
@@ -17447,8 +17611,8 @@ function edwards(params, extraOpts = {}) {
|
|
|
17447
17611
|
aInRange("point.y", y, _0n4, max);
|
|
17448
17612
|
const y2 = modP(y * y);
|
|
17449
17613
|
const u = modP(y2 - _1n4);
|
|
17450
|
-
const
|
|
17451
|
-
let { isValid, value: x } = uvRatio2(u,
|
|
17614
|
+
const v4 = modP(d * y2 - a);
|
|
17615
|
+
let { isValid, value: x } = uvRatio2(u, v4);
|
|
17452
17616
|
if (!isValid)
|
|
17453
17617
|
throw new Error("bad point: invalid y coordinate");
|
|
17454
17618
|
const isXOdd = (x & _1n4) === _1n4;
|
|
@@ -17788,13 +17952,13 @@ function adjustScalarBytes(bytes) {
|
|
|
17788
17952
|
return bytes;
|
|
17789
17953
|
}
|
|
17790
17954
|
var ED25519_SQRT_M1 = /* @__PURE__ */ BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");
|
|
17791
|
-
function uvRatio(u,
|
|
17955
|
+
function uvRatio(u, v4) {
|
|
17792
17956
|
const P = ed25519_CURVE_p;
|
|
17793
|
-
const v32 = mod(
|
|
17794
|
-
const v7 = mod(v32 * v32 *
|
|
17957
|
+
const v32 = mod(v4 * v4 * v4, P);
|
|
17958
|
+
const v7 = mod(v32 * v32 * v4, P);
|
|
17795
17959
|
const pow = ed25519_pow_2_252_3(u * v7).pow_p_5_8;
|
|
17796
17960
|
let x = mod(u * v32 * pow, P);
|
|
17797
|
-
const vx2 = mod(
|
|
17961
|
+
const vx2 = mod(v4 * x * x, P);
|
|
17798
17962
|
const root1 = x;
|
|
17799
17963
|
const root2 = mod(x * ED25519_SQRT_M1, P);
|
|
17800
17964
|
const useRoot1 = vx2 === u;
|
|
@@ -18125,7 +18289,7 @@ function findSeatPrice(validators, maxNumberOfSeats, minimumStakeRatio, protocol
|
|
|
18125
18289
|
return findSeatPriceForProtocolAfter49(validators, maxNumberOfSeats, minimumStakeRatio);
|
|
18126
18290
|
}
|
|
18127
18291
|
function findSeatPriceForProtocolBefore49(validators, numSeats) {
|
|
18128
|
-
const stakes = validators.map((
|
|
18292
|
+
const stakes = validators.map((v4) => BigInt(v4.stake)).sort(sortBigIntAsc);
|
|
18129
18293
|
const num = BigInt(numSeats);
|
|
18130
18294
|
const stakesSum = stakes.reduce((a, b) => a + b);
|
|
18131
18295
|
if (stakesSum < num) {
|
|
@@ -18154,7 +18318,7 @@ function findSeatPriceForProtocolAfter49(validators, maxNumberOfSeats, minimumSt
|
|
|
18154
18318
|
if (minimumStakeRatio.length != 2) {
|
|
18155
18319
|
throw Error("minimumStakeRatio should have 2 elements");
|
|
18156
18320
|
}
|
|
18157
|
-
const stakes = validators.map((
|
|
18321
|
+
const stakes = validators.map((v4) => BigInt(v4.stake)).sort(sortBigIntAsc);
|
|
18158
18322
|
const stakesSum = stakes.reduce((a, b) => a + b);
|
|
18159
18323
|
if (validators.length < maxNumberOfSeats) {
|
|
18160
18324
|
return stakesSum * BigInt(minimumStakeRatio[0]) / BigInt(minimumStakeRatio[1]);
|
|
@@ -18326,10 +18490,10 @@ var DER = {
|
|
|
18326
18490
|
if (length < 128)
|
|
18327
18491
|
throw new E("tlv.decode(long): not minimal encoding");
|
|
18328
18492
|
}
|
|
18329
|
-
const
|
|
18330
|
-
if (
|
|
18493
|
+
const v4 = data.subarray(pos, pos + length);
|
|
18494
|
+
if (v4.length !== length)
|
|
18331
18495
|
throw new E("tlv.decode: wrong value length");
|
|
18332
|
-
return { v:
|
|
18496
|
+
return { v: v4, l: data.subarray(pos + length) };
|
|
18333
18497
|
}
|
|
18334
18498
|
},
|
|
18335
18499
|
// https://crypto.stackexchange.com/a/57734 Leftmost bit of first byte is 'negative' flag,
|
|
@@ -18897,9 +19061,9 @@ function ecdsa(Point, hash, ecdsaOpts = {}) {
|
|
|
18897
19061
|
extraEntropy: false
|
|
18898
19062
|
};
|
|
18899
19063
|
const hasLargeCofactor = CURVE_ORDER * _2n4 < Fp.ORDER;
|
|
18900
|
-
function isBiggerThanHalfOrder(
|
|
19064
|
+
function isBiggerThanHalfOrder(number2) {
|
|
18901
19065
|
const HALF = CURVE_ORDER >> _1n6;
|
|
18902
|
-
return
|
|
19066
|
+
return number2 > HALF;
|
|
18903
19067
|
}
|
|
18904
19068
|
function validateRS(title, num) {
|
|
18905
19069
|
if (!Fn.isValidNot0(num))
|
|
@@ -19082,8 +19246,8 @@ function ecdsa(Point, hash, ecdsaOpts = {}) {
|
|
|
19082
19246
|
const R = Point.BASE.multiplyUnsafe(u1).add(P.multiplyUnsafe(u2));
|
|
19083
19247
|
if (R.is0())
|
|
19084
19248
|
return false;
|
|
19085
|
-
const
|
|
19086
|
-
return
|
|
19249
|
+
const v4 = Fn.create(R.x);
|
|
19250
|
+
return v4 === r;
|
|
19087
19251
|
} catch (e) {
|
|
19088
19252
|
return false;
|
|
19089
19253
|
}
|
|
@@ -22079,6 +22243,15 @@ var NearSpokeService = class {
|
|
|
22079
22243
|
};
|
|
22080
22244
|
}
|
|
22081
22245
|
};
|
|
22246
|
+
function buildEvmRpcTransport(cfg) {
|
|
22247
|
+
const configured = (cfg.rpcUrls ?? []).map((url) => url.trim()).filter((url) => url.length > 0);
|
|
22248
|
+
const urls = [...new Set(configured.length > 0 ? configured : [cfg.rpcUrl])];
|
|
22249
|
+
const rpcOptions = cfg.rpcOptions?.rank && urls.length < 2 ? { ...cfg.rpcOptions, rank: false } : cfg.rpcOptions;
|
|
22250
|
+
return fallback(
|
|
22251
|
+
urls.map((url) => http(url)),
|
|
22252
|
+
rpcOptions
|
|
22253
|
+
);
|
|
22254
|
+
}
|
|
22082
22255
|
|
|
22083
22256
|
// src/shared/types/intent-types.ts
|
|
22084
22257
|
var IntentDataType = /* @__PURE__ */ ((IntentDataType2) => {
|
|
@@ -22541,7 +22714,7 @@ var SonicSpokeService = class {
|
|
|
22541
22714
|
this.config = config;
|
|
22542
22715
|
const chainConfig = config.getChainConfig(ChainKeys.SONIC_MAINNET);
|
|
22543
22716
|
this.publicClient = createPublicClient({
|
|
22544
|
-
transport:
|
|
22717
|
+
transport: buildEvmRpcTransport(chainConfig),
|
|
22545
22718
|
chain: getEvmViemChain(ChainKeys.SONIC_MAINNET)
|
|
22546
22719
|
});
|
|
22547
22720
|
this.pollingIntervalMs = chainConfig.pollingConfig.pollingIntervalMs;
|
|
@@ -26140,7 +26313,7 @@ var EvmHubProvider = class {
|
|
|
26140
26313
|
hubAddressMap = /* @__PURE__ */ new Map();
|
|
26141
26314
|
constructor({ config }) {
|
|
26142
26315
|
this.publicClient = createPublicClient({
|
|
26143
|
-
transport:
|
|
26316
|
+
transport: buildEvmRpcTransport(config.sodaxConfig.hub),
|
|
26144
26317
|
chain: getEvmViemChain(config.sodaxConfig.hub.chain.key)
|
|
26145
26318
|
});
|
|
26146
26319
|
this.chainConfig = config.sodaxConfig.hub;
|
|
@@ -26405,6 +26578,7 @@ var POST_EXECUTION_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
|
26405
26578
|
"UNKNOWN"
|
|
26406
26579
|
]);
|
|
26407
26580
|
var SWAP_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
26581
|
+
"USER_REJECTED",
|
|
26408
26582
|
"VALIDATION_FAILED",
|
|
26409
26583
|
"INTENT_CREATION_FAILED",
|
|
26410
26584
|
"TX_VERIFICATION_FAILED",
|
|
@@ -26731,7 +26905,7 @@ var SwapService = class {
|
|
|
26731
26905
|
/**
|
|
26732
26906
|
* Backend 2-step swap path (opt-in via `swapsOptions.useBackendSubmitTx`): hand the broadcast
|
|
26733
26907
|
* intent tx to the swaps API (`POST /swaps/submit-tx`); the backend relays + post-executes
|
|
26734
|
-
* server-side. Polls `getSubmitTxStatus` until `
|
|
26908
|
+
* server-side. Polls `getSubmitTxStatus` until `solved`, then reconstructs the same
|
|
26735
26909
|
* {@link SwapResponse} the client-side path returns (`result.dstIntentTxHash` → delivery info,
|
|
26736
26910
|
* `result.intent_hash` → solver response).
|
|
26737
26911
|
*
|
|
@@ -26768,7 +26942,7 @@ var SwapService = class {
|
|
|
26768
26942
|
const statusResult = await this.backendApi.swaps.getSubmitTxStatus({ txHash: spokeTxHash, srcChainKey });
|
|
26769
26943
|
if (statusResult.ok) {
|
|
26770
26944
|
const { status, result, failureReason, abandonedAt } = statusResult.value.data;
|
|
26771
|
-
if (status === "
|
|
26945
|
+
if (status === "solved" && result?.dstIntentTxHash && result.intent_hash) {
|
|
26772
26946
|
return {
|
|
26773
26947
|
ok: true,
|
|
26774
26948
|
value: {
|
|
@@ -26793,7 +26967,7 @@ var SwapService = class {
|
|
|
26793
26967
|
}
|
|
26794
26968
|
await new Promise((resolve) => setTimeout(resolve, pollIntervalMs));
|
|
26795
26969
|
}
|
|
26796
|
-
return submitTxFailed(new Error("backend submit-tx polling timed out before reaching
|
|
26970
|
+
return submitTxFailed(new Error("backend submit-tx polling timed out before reaching solved"));
|
|
26797
26971
|
} catch (error) {
|
|
26798
26972
|
return { ok: false, error: unknownFailed("swap", error, { ...baseCtx, action: "swap" }) };
|
|
26799
26973
|
}
|
|
@@ -26864,6 +27038,7 @@ var SwapService = class {
|
|
|
26864
27038
|
*/
|
|
26865
27039
|
async approve(_params) {
|
|
26866
27040
|
const { params } = _params;
|
|
27041
|
+
const wrapApproveFailure = (cause) => approveFailed("swap", cause);
|
|
26867
27042
|
try {
|
|
26868
27043
|
if (isHubChainKeyType(params.srcChainKey) || isEvmSpokeOnlyChainKeyType(params.srcChainKey)) {
|
|
26869
27044
|
invariant(
|
|
@@ -26884,7 +27059,7 @@ var SwapService = class {
|
|
|
26884
27059
|
walletProvider: _params.walletProvider
|
|
26885
27060
|
});
|
|
26886
27061
|
if (!result.ok) {
|
|
26887
|
-
return result;
|
|
27062
|
+
return { ok: false, error: wrapApproveFailure(result.error) };
|
|
26888
27063
|
}
|
|
26889
27064
|
return {
|
|
26890
27065
|
ok: true,
|
|
@@ -26912,7 +27087,7 @@ var SwapService = class {
|
|
|
26912
27087
|
walletProvider: _params.walletProvider
|
|
26913
27088
|
}
|
|
26914
27089
|
);
|
|
26915
|
-
if (!result.ok) return result;
|
|
27090
|
+
if (!result.ok) return { ok: false, error: wrapApproveFailure(result.error) };
|
|
26916
27091
|
return {
|
|
26917
27092
|
ok: true,
|
|
26918
27093
|
value: result.value
|
|
@@ -27205,13 +27380,14 @@ var SwapService = class {
|
|
|
27205
27380
|
walletProvider: _params.walletProvider
|
|
27206
27381
|
};
|
|
27207
27382
|
const txResult = await this.spoke.sendMessage(sendMessageParams);
|
|
27208
|
-
if (!txResult.ok) return txResult;
|
|
27383
|
+
if (!txResult.ok) return { ok: false, error: intentCreationFailed("swap", txResult.error) };
|
|
27209
27384
|
return {
|
|
27210
27385
|
ok: true,
|
|
27211
27386
|
value: txResult.value
|
|
27212
27387
|
};
|
|
27213
27388
|
} catch (error) {
|
|
27214
|
-
return { ok: false, error };
|
|
27389
|
+
if (isSwapCreateIntentError(error)) return { ok: false, error };
|
|
27390
|
+
return { ok: false, error: intentCreationFailed("swap", error) };
|
|
27215
27391
|
}
|
|
27216
27392
|
}
|
|
27217
27393
|
/**
|
|
@@ -27265,7 +27441,8 @@ var SwapService = class {
|
|
|
27265
27441
|
}
|
|
27266
27442
|
return { ok: true, value: { srcChainTxHash: cancelTxHash, dstChainTxHash: dstIntentTxHash } };
|
|
27267
27443
|
} catch (error) {
|
|
27268
|
-
return { ok: false, error };
|
|
27444
|
+
if (isSwapError(error)) return { ok: false, error };
|
|
27445
|
+
return { ok: false, error: executionFailed("swap", error, { action: "cancelIntent" }) };
|
|
27269
27446
|
}
|
|
27270
27447
|
}
|
|
27271
27448
|
/**
|
|
@@ -27450,6 +27627,7 @@ var SwapService = class {
|
|
|
27450
27627
|
// src/migration/errors.ts
|
|
27451
27628
|
var migrationInvariant = createInvariant("migration");
|
|
27452
27629
|
var MIGRATE_ORCH_CODES = /* @__PURE__ */ new Set([
|
|
27630
|
+
"USER_REJECTED",
|
|
27453
27631
|
"VALIDATION_FAILED",
|
|
27454
27632
|
"INTENT_CREATION_FAILED",
|
|
27455
27633
|
"TX_VERIFICATION_FAILED",
|
|
@@ -27460,6 +27638,7 @@ var MIGRATE_ORCH_CODES = /* @__PURE__ */ new Set([
|
|
|
27460
27638
|
"UNKNOWN"
|
|
27461
27639
|
]);
|
|
27462
27640
|
var REVERT_ORCH_CODES = /* @__PURE__ */ new Set([
|
|
27641
|
+
"USER_REJECTED",
|
|
27463
27642
|
"VALIDATION_FAILED",
|
|
27464
27643
|
"INTENT_CREATION_FAILED",
|
|
27465
27644
|
"TX_SUBMIT_FAILED",
|
|
@@ -27469,6 +27648,7 @@ var REVERT_ORCH_CODES = /* @__PURE__ */ new Set([
|
|
|
27469
27648
|
"UNKNOWN"
|
|
27470
27649
|
]);
|
|
27471
27650
|
var MIGRATION_CODES = /* @__PURE__ */ new Set([
|
|
27651
|
+
"USER_REJECTED",
|
|
27472
27652
|
"VALIDATION_FAILED",
|
|
27473
27653
|
"INTENT_CREATION_FAILED",
|
|
27474
27654
|
"TX_VERIFICATION_FAILED",
|
|
@@ -29521,7 +29701,6 @@ var MigrationService = class {
|
|
|
29521
29701
|
};
|
|
29522
29702
|
|
|
29523
29703
|
// src/backendApi/api-utils.ts
|
|
29524
|
-
var toJsonBody = (value) => JSON.stringify(value, (_key, val) => typeof val === "bigint" ? val.toString() : val);
|
|
29525
29704
|
async function makeRequest(params) {
|
|
29526
29705
|
const { endpoint, config, overrideConfig = {}, logger, serviceLabel } = params;
|
|
29527
29706
|
const baseURL = overrideConfig.baseURL || config.baseURL || "";
|
|
@@ -29557,227 +29736,7 @@ async function makeRequest(params) {
|
|
|
29557
29736
|
throw new Error("UNKNOWN_REQUEST_ERROR", { cause: error });
|
|
29558
29737
|
}
|
|
29559
29738
|
}
|
|
29560
|
-
var
|
|
29561
|
-
symbol: v4.string(),
|
|
29562
|
-
name: v4.string(),
|
|
29563
|
-
decimals: v4.number(),
|
|
29564
|
-
address: v4.string(),
|
|
29565
|
-
chainKey: v4.string(),
|
|
29566
|
-
hubAsset: v4.string(),
|
|
29567
|
-
vault: v4.string()
|
|
29568
|
-
});
|
|
29569
|
-
var IntentResponseSchema = v4.object({
|
|
29570
|
-
intentId: v4.string(),
|
|
29571
|
-
creator: v4.string(),
|
|
29572
|
-
inputToken: v4.string(),
|
|
29573
|
-
outputToken: v4.string(),
|
|
29574
|
-
inputAmount: v4.string(),
|
|
29575
|
-
minOutputAmount: v4.string(),
|
|
29576
|
-
deadline: v4.string(),
|
|
29577
|
-
allowPartialFill: v4.boolean(),
|
|
29578
|
-
srcChain: v4.string(),
|
|
29579
|
-
dstChain: v4.string(),
|
|
29580
|
-
srcAddress: v4.string(),
|
|
29581
|
-
dstAddress: v4.string(),
|
|
29582
|
-
solver: v4.string(),
|
|
29583
|
-
data: v4.string()
|
|
29584
|
-
});
|
|
29585
|
-
var RelayExtraDataResponseSchema = v4.object({
|
|
29586
|
-
address: v4.string(),
|
|
29587
|
-
payload: v4.string()
|
|
29588
|
-
});
|
|
29589
|
-
var makeCreateIntentResponseSchema = (txSchema) => v4.object({
|
|
29590
|
-
tx: txSchema,
|
|
29591
|
-
intent: IntentResponseSchema,
|
|
29592
|
-
relayData: RelayExtraDataResponseSchema
|
|
29593
|
-
});
|
|
29594
|
-
var GetSwapTokensResponseSchema = v4.record(v4.string(), v4.array(SwapTokenSchema));
|
|
29595
|
-
var GetSwapTokensByChainResponseSchema = v4.array(SwapTokenSchema);
|
|
29596
|
-
var makeQuoteResponseSchema = (txSchema) => v4.object({
|
|
29597
|
-
quotedAmount: v4.string(),
|
|
29598
|
-
txData: v4.optional(makeCreateIntentResponseSchema(txSchema))
|
|
29599
|
-
});
|
|
29600
|
-
var DeadlineResponseSchema = v4.object({
|
|
29601
|
-
deadline: v4.string()
|
|
29602
|
-
});
|
|
29603
|
-
var AllowanceCheckResponseSchema = v4.object({
|
|
29604
|
-
valid: v4.boolean()
|
|
29605
|
-
});
|
|
29606
|
-
var makeApproveResponseSchema = (txSchema) => v4.object({ tx: txSchema });
|
|
29607
|
-
var SubmitIntentResponseSchema = v4.object({
|
|
29608
|
-
result: v4.unknown()
|
|
29609
|
-
});
|
|
29610
|
-
var StatusResponseSchema = v4.object({
|
|
29611
|
-
status: v4.picklist([-1, 1, 2, 3, 4]),
|
|
29612
|
-
fillTxHash: v4.optional(v4.string())
|
|
29613
|
-
});
|
|
29614
|
-
var makeCancelIntentResponseSchema = (txSchema) => v4.object({ tx: txSchema });
|
|
29615
|
-
var IntentHashResponseSchema = v4.object({
|
|
29616
|
-
hash: v4.string()
|
|
29617
|
-
});
|
|
29618
|
-
var IntentPacketResponseSchema = v4.object({
|
|
29619
|
-
srcChainId: v4.number(),
|
|
29620
|
-
srcTxHash: v4.string(),
|
|
29621
|
-
srcAddress: v4.string(),
|
|
29622
|
-
status: v4.string(),
|
|
29623
|
-
dstChainId: v4.number(),
|
|
29624
|
-
connSn: v4.number(),
|
|
29625
|
-
dstAddress: v4.string(),
|
|
29626
|
-
dstTxHash: v4.string(),
|
|
29627
|
-
signatures: v4.array(v4.string()),
|
|
29628
|
-
payload: v4.string()
|
|
29629
|
-
});
|
|
29630
|
-
var IntentStateResponseSchema = v4.object({
|
|
29631
|
-
exists: v4.boolean(),
|
|
29632
|
-
remainingInput: v4.string(),
|
|
29633
|
-
receivedOutput: v4.string(),
|
|
29634
|
-
pendingPayment: v4.boolean()
|
|
29635
|
-
});
|
|
29636
|
-
var GasEstimateResponseSchema = v4.object({
|
|
29637
|
-
gas: v4.unknown()
|
|
29638
|
-
});
|
|
29639
|
-
var FeeResponseSchema = v4.object({
|
|
29640
|
-
fee: v4.string()
|
|
29641
|
-
});
|
|
29642
|
-
var SubmitTxResponseSchema = v4.object({
|
|
29643
|
-
success: v4.boolean(),
|
|
29644
|
-
data: v4.object({
|
|
29645
|
-
status: v4.picklist(["inserted", "duplicate"]),
|
|
29646
|
-
message: v4.string()
|
|
29647
|
-
})
|
|
29648
|
-
});
|
|
29649
|
-
var SubmitSwapTxStatusSchema = v4.picklist([
|
|
29650
|
-
"pending",
|
|
29651
|
-
"relaying",
|
|
29652
|
-
"relayed",
|
|
29653
|
-
"posting_execution",
|
|
29654
|
-
"executed",
|
|
29655
|
-
"failed"
|
|
29656
|
-
]);
|
|
29657
|
-
var PacketDataSchema = v4.object({
|
|
29658
|
-
src_chain_id: v4.number(),
|
|
29659
|
-
src_tx_hash: v4.string(),
|
|
29660
|
-
src_address: v4.string(),
|
|
29661
|
-
status: v4.picklist(["pending", "validating", "executing", "executed"]),
|
|
29662
|
-
dst_chain_id: v4.number(),
|
|
29663
|
-
conn_sn: v4.number(),
|
|
29664
|
-
dst_address: v4.string(),
|
|
29665
|
-
dst_tx_hash: v4.string(),
|
|
29666
|
-
signatures: v4.array(v4.string()),
|
|
29667
|
-
payload: v4.string()
|
|
29668
|
-
});
|
|
29669
|
-
var SubmitTxStatusResultSchema = v4.object({
|
|
29670
|
-
dstIntentTxHash: v4.string(),
|
|
29671
|
-
packetData: v4.optional(PacketDataSchema),
|
|
29672
|
-
intent_hash: v4.optional(v4.string())
|
|
29673
|
-
});
|
|
29674
|
-
var SubmitTxStatusDataSchema = v4.object({
|
|
29675
|
-
txHash: v4.string(),
|
|
29676
|
-
srcChainKey: v4.string(),
|
|
29677
|
-
status: SubmitSwapTxStatusSchema,
|
|
29678
|
-
failedAtStep: v4.optional(SubmitSwapTxStatusSchema),
|
|
29679
|
-
failureReason: v4.optional(v4.string()),
|
|
29680
|
-
processingAttempts: v4.number(),
|
|
29681
|
-
abandonedAt: v4.optional(v4.string()),
|
|
29682
|
-
result: v4.optional(SubmitTxStatusResultSchema),
|
|
29683
|
-
userMessage: v4.optional(v4.string()),
|
|
29684
|
-
intentCancelled: v4.optional(v4.boolean())
|
|
29685
|
-
});
|
|
29686
|
-
var SubmitTxStatusResponseSchema = v4.object({
|
|
29687
|
-
success: v4.boolean(),
|
|
29688
|
-
data: SubmitTxStatusDataSchema
|
|
29689
|
-
});
|
|
29690
|
-
var AddressSchema = v4.custom((input) => typeof input === "string");
|
|
29691
|
-
var HexSchema = v4.custom((input) => typeof input === "string");
|
|
29692
|
-
var BigintFromString = v4.pipe(v4.string(), v4.toBigint());
|
|
29693
|
-
var BytesFromIndexRecord = v4.pipe(
|
|
29694
|
-
v4.record(v4.string(), v4.number()),
|
|
29695
|
-
v4.transform((indexed) => Uint8Array.from(Object.values(indexed)))
|
|
29696
|
-
);
|
|
29697
|
-
var EvmRawTxSchema = v4.object({
|
|
29698
|
-
from: AddressSchema,
|
|
29699
|
-
to: AddressSchema,
|
|
29700
|
-
value: BigintFromString,
|
|
29701
|
-
data: HexSchema
|
|
29702
|
-
});
|
|
29703
|
-
var SolanaRawTxSchema = v4.object({
|
|
29704
|
-
from: v4.string(),
|
|
29705
|
-
to: v4.string(),
|
|
29706
|
-
value: BigintFromString,
|
|
29707
|
-
data: v4.string()
|
|
29708
|
-
});
|
|
29709
|
-
var SuiRawTxSchema = v4.object({
|
|
29710
|
-
from: HexSchema,
|
|
29711
|
-
to: v4.string(),
|
|
29712
|
-
value: BigintFromString,
|
|
29713
|
-
data: v4.string()
|
|
29714
|
-
});
|
|
29715
|
-
var StellarRawTxSchema = v4.object({
|
|
29716
|
-
from: v4.string(),
|
|
29717
|
-
to: v4.string(),
|
|
29718
|
-
value: BigintFromString,
|
|
29719
|
-
data: v4.string()
|
|
29720
|
-
});
|
|
29721
|
-
var InjectiveRawTxSchema = v4.object({
|
|
29722
|
-
from: HexSchema,
|
|
29723
|
-
to: HexSchema,
|
|
29724
|
-
signedDoc: v4.object({
|
|
29725
|
-
bodyBytes: BytesFromIndexRecord,
|
|
29726
|
-
authInfoBytes: BytesFromIndexRecord,
|
|
29727
|
-
chainId: v4.string(),
|
|
29728
|
-
accountNumber: BigintFromString
|
|
29729
|
-
})
|
|
29730
|
-
});
|
|
29731
|
-
var NearRawTxSchema = v4.object({
|
|
29732
|
-
signerId: v4.string(),
|
|
29733
|
-
params: v4.object({
|
|
29734
|
-
contractId: v4.string(),
|
|
29735
|
-
method: v4.string(),
|
|
29736
|
-
args: v4.custom((input) => typeof input === "object" && input !== null),
|
|
29737
|
-
gas: v4.optional(BigintFromString),
|
|
29738
|
-
deposit: v4.optional(BigintFromString)
|
|
29739
|
-
})
|
|
29740
|
-
});
|
|
29741
|
-
var IconRawTxSchema = v4.record(
|
|
29742
|
-
v4.string(),
|
|
29743
|
-
v4.union([v4.string(), v4.custom((input) => typeof input === "object" && input !== null)])
|
|
29744
|
-
);
|
|
29745
|
-
var StacksRawTxSchema = v4.object({
|
|
29746
|
-
payload: v4.string(),
|
|
29747
|
-
estimatedLength: v4.optional(v4.number())
|
|
29748
|
-
});
|
|
29749
|
-
var AnyRawTxSchema = v4.custom((input) => typeof input === "object" && input !== null);
|
|
29750
|
-
function rawTxSchemaForChainKey(chainKey) {
|
|
29751
|
-
let chainType;
|
|
29752
|
-
try {
|
|
29753
|
-
chainType = getChainType(chainKey);
|
|
29754
|
-
} catch {
|
|
29755
|
-
chainType = void 0;
|
|
29756
|
-
}
|
|
29757
|
-
switch (chainType) {
|
|
29758
|
-
case "EVM":
|
|
29759
|
-
return EvmRawTxSchema;
|
|
29760
|
-
case "SOLANA":
|
|
29761
|
-
return SolanaRawTxSchema;
|
|
29762
|
-
case "SUI":
|
|
29763
|
-
return SuiRawTxSchema;
|
|
29764
|
-
case "STELLAR":
|
|
29765
|
-
return StellarRawTxSchema;
|
|
29766
|
-
case "INJECTIVE":
|
|
29767
|
-
return InjectiveRawTxSchema;
|
|
29768
|
-
case "ICON":
|
|
29769
|
-
return IconRawTxSchema;
|
|
29770
|
-
case "STACKS":
|
|
29771
|
-
return StacksRawTxSchema;
|
|
29772
|
-
case "NEAR":
|
|
29773
|
-
return NearRawTxSchema;
|
|
29774
|
-
default:
|
|
29775
|
-
return AnyRawTxSchema;
|
|
29776
|
-
}
|
|
29777
|
-
}
|
|
29778
|
-
|
|
29779
|
-
// src/backendApi/SwapsApiService.ts
|
|
29780
|
-
var SwapsApiService = class {
|
|
29739
|
+
var SwapsApiService = class _SwapsApiService {
|
|
29781
29740
|
// Fully-resolved swaps-API config supplied by the caller (BackendApiService resolves the
|
|
29782
29741
|
// `ApiConfig` union via `resolveSwapsApiConfig`); this service does not resolve the union.
|
|
29783
29742
|
config;
|
|
@@ -29789,347 +29748,189 @@ var SwapsApiService = class {
|
|
|
29789
29748
|
this.logger = logger;
|
|
29790
29749
|
}
|
|
29791
29750
|
/**
|
|
29792
|
-
*
|
|
29793
|
-
*
|
|
29794
|
-
*
|
|
29795
|
-
*
|
|
29751
|
+
* Build a `@sodax/swaps-api` client for a single call. Maps the SDK's `SwapsApiConfig`
|
|
29752
|
+
* (`baseURL`/`timeout`/`headers`) to the package's config (`baseUrl`/`timeout`/`headers`), layering
|
|
29753
|
+
* the optional per-call `RequestOverrideConfig` on top (override wins per field; headers merge).
|
|
29754
|
+
* `timeout` falls back to the backend-API default so a config that omits it still gets a ceiling
|
|
29755
|
+
* rather than an unbounded request. Constructed per call so `setHeaders` mutations and per-call
|
|
29756
|
+
* overrides both take effect without caching stale state.
|
|
29796
29757
|
*/
|
|
29797
|
-
|
|
29758
|
+
buildClient(overrideConfig) {
|
|
29759
|
+
const baseUrl = overrideConfig?.baseURL || this.config.baseURL;
|
|
29760
|
+
const timeout = overrideConfig?.timeout ?? this.config.timeout ?? DEFAULT_BACKEND_API_TIMEOUT;
|
|
29761
|
+
const headers = { ...this.headers, ...overrideConfig?.headers };
|
|
29762
|
+
return new SwapsApi({ baseUrl, headers, timeout });
|
|
29763
|
+
}
|
|
29764
|
+
/**
|
|
29765
|
+
* Run one delegated `SwapsApi` call and wrap it in `Result<T>`. A thrown `SwapsApiError`
|
|
29766
|
+
* (network/timeout/HTTP/parse/validation) becomes `{ ok: false }` with a canonical
|
|
29767
|
+
* `SodaxError<'EXTERNAL_API_ERROR'>`; the original error is kept as `cause`, and its
|
|
29768
|
+
* `code`/`status`/`issues` are projected into `context` so consumers can discriminate failure
|
|
29769
|
+
* kinds without unwrapping `cause`. Only a RESPONSE-shape validation failure is tagged
|
|
29770
|
+
* `reason: 'invalid_response_shape'` — a request-side validation error is a caller bug, not a
|
|
29771
|
+
* backend fault.
|
|
29772
|
+
*/
|
|
29773
|
+
async toResult(endpoint, call, overrideConfig) {
|
|
29798
29774
|
try {
|
|
29799
|
-
const
|
|
29800
|
-
|
|
29801
|
-
config: { baseURL: this.config.baseURL, timeout: this.config.timeout, headers: this.headers, ...config },
|
|
29802
|
-
overrideConfig,
|
|
29803
|
-
logger: this.logger,
|
|
29804
|
-
serviceLabel: "SwapsApiService"
|
|
29805
|
-
});
|
|
29806
|
-
const parsed = v4.safeParse(schema, raw);
|
|
29807
|
-
if (!parsed.success) {
|
|
29808
|
-
return {
|
|
29809
|
-
ok: false,
|
|
29810
|
-
error: new SodaxError("EXTERNAL_API_ERROR", `Invalid response shape from swaps API for ${endpoint}`, {
|
|
29811
|
-
feature: "backend",
|
|
29812
|
-
context: { api: "swaps", endpoint, reason: "invalid_response_shape", issues: v4.flatten(parsed.issues) }
|
|
29813
|
-
})
|
|
29814
|
-
};
|
|
29815
|
-
}
|
|
29816
|
-
return { ok: true, value: parsed.output };
|
|
29775
|
+
const value = await call(this.buildClient(overrideConfig));
|
|
29776
|
+
return { ok: true, value };
|
|
29817
29777
|
} catch (error) {
|
|
29778
|
+
const context = { api: "swaps", endpoint };
|
|
29779
|
+
if (error instanceof SwapsApiError) {
|
|
29780
|
+
context.code = error.code;
|
|
29781
|
+
if (error.code === "VALIDATION_ERROR" && error.context.issues !== void 0) {
|
|
29782
|
+
context.reason = "invalid_response_shape";
|
|
29783
|
+
const issues = error.context.issues;
|
|
29784
|
+
context.issues = issues instanceof v2.ValiError ? v2.flatten(issues.issues) : issues;
|
|
29785
|
+
}
|
|
29786
|
+
if (error.context.status !== void 0) context.status = error.context.status;
|
|
29787
|
+
}
|
|
29788
|
+
this.logger.error(`[SwapsApiService] Request to ${endpoint} failed`, error);
|
|
29818
29789
|
return {
|
|
29819
29790
|
ok: false,
|
|
29820
29791
|
error: new SodaxError(
|
|
29821
29792
|
"EXTERNAL_API_ERROR",
|
|
29822
29793
|
error instanceof Error ? error.message : `Request to ${endpoint} failed`,
|
|
29823
|
-
{
|
|
29824
|
-
feature: "backend",
|
|
29825
|
-
cause: error,
|
|
29826
|
-
context: { api: "swaps", endpoint }
|
|
29827
|
-
}
|
|
29794
|
+
{ feature: "backend", cause: error, context }
|
|
29828
29795
|
)
|
|
29829
29796
|
};
|
|
29830
29797
|
}
|
|
29831
29798
|
}
|
|
29799
|
+
/**
|
|
29800
|
+
* Drop the SDK-only display field `feeAmount` before an intent reaches the strict wire serializer.
|
|
29801
|
+
* `sodax.swaps.createIntent` returns `Intent & FeeAmount`, which is structurally assignable to the
|
|
29802
|
+
* wire `IntentRequestV2` and so gets passed straight into the intent-carrying endpoints; the extra
|
|
29803
|
+
* bigint would trip `serializeIntentRequest`. This is a no-op for an already-clean `IntentRequestV2`.
|
|
29804
|
+
*/
|
|
29805
|
+
static toWireIntent(intent) {
|
|
29806
|
+
const { feeAmount: _feeAmount, ...rest } = intent;
|
|
29807
|
+
return rest;
|
|
29808
|
+
}
|
|
29832
29809
|
// ──────────────────────────────────────────────────────────────────────
|
|
29833
29810
|
// Tokens
|
|
29834
29811
|
// ──────────────────────────────────────────────────────────────────────
|
|
29835
|
-
/**
|
|
29836
|
-
* Fetch all supported swap tokens grouped by SpokeChainKey.
|
|
29837
|
-
*
|
|
29838
|
-
* @returns `Result<GetSwapTokensResponseV2>` — map of chain key → token list.
|
|
29839
|
-
*/
|
|
29812
|
+
/** Fetch all supported swap tokens grouped by SpokeChainKey. */
|
|
29840
29813
|
async getTokens(config) {
|
|
29841
|
-
return this.
|
|
29814
|
+
return this.toResult("/swaps/tokens", (c) => c.getTokens(), config);
|
|
29842
29815
|
}
|
|
29843
|
-
/**
|
|
29844
|
-
* Fetch supported swap tokens for a single SpokeChainKey.
|
|
29845
|
-
*
|
|
29846
|
-
* @param chainKey - SODAX SpokeChainKey (e.g. `0xa4b1.arbitrum`, `solana`).
|
|
29847
|
-
* @returns `Result<GetSwapTokensByChainResponseV2>` — token list for the chain.
|
|
29848
|
-
*/
|
|
29816
|
+
/** Fetch supported swap tokens for a single SpokeChainKey. */
|
|
29849
29817
|
async getTokensByChain(chainKey, config) {
|
|
29850
|
-
return this.
|
|
29851
|
-
`/swaps/tokens/${chainKey}`,
|
|
29852
|
-
{ method: "GET" },
|
|
29853
|
-
GetSwapTokensByChainResponseSchema,
|
|
29854
|
-
config
|
|
29855
|
-
);
|
|
29818
|
+
return this.toResult(`/swaps/tokens/${chainKey}`, (c) => c.getTokensByChain(chainKey), config);
|
|
29856
29819
|
}
|
|
29857
29820
|
// ──────────────────────────────────────────────────────────────────────
|
|
29858
29821
|
// Quote · deadline
|
|
29859
29822
|
// ──────────────────────────────────────────────────────────────────────
|
|
29860
29823
|
/**
|
|
29861
|
-
* Get a solver quote for a cross-chain swap.
|
|
29862
|
-
*
|
|
29863
|
-
* Pass `query.includeTxData = true` to also build an unsigned create-intent
|
|
29864
|
-
* transaction (`txData`) using the quoted amount as `minOutputAmount`; in that
|
|
29865
|
-
* case `srcAddress`/`dstAddress` are required in the body.
|
|
29866
|
-
*
|
|
29867
|
-
* @returns `Result<QuoteResponseV2>` — `quotedAmount` (decimal string) and optional `txData`.
|
|
29824
|
+
* Get a solver quote for a cross-chain swap. Pass `query.includeTxData = true` to also build an
|
|
29825
|
+
* unsigned create-intent transaction (`txData`); in that case `srcAddress`/`dstAddress` are required.
|
|
29868
29826
|
*/
|
|
29869
29827
|
async getQuote(body, query, config) {
|
|
29870
|
-
|
|
29871
|
-
const txSchema = rawTxSchemaForChainKey(body.tokenSrcChainKey);
|
|
29872
|
-
return this.request(
|
|
29873
|
-
endpoint,
|
|
29874
|
-
{ method: "POST", body: toJsonBody(body) },
|
|
29875
|
-
makeQuoteResponseSchema(txSchema),
|
|
29876
|
-
config
|
|
29877
|
-
);
|
|
29828
|
+
return this.toResult("/swaps/quote", (c) => c.getQuote(body, query), config);
|
|
29878
29829
|
}
|
|
29879
|
-
/**
|
|
29880
|
-
* Compute a swap deadline (hub timestamp + `offsetSeconds`, default 300s).
|
|
29881
|
-
*
|
|
29882
|
-
* @returns `Result<DeadlineResponseV2>` — unix-seconds deadline (decimal string).
|
|
29883
|
-
*/
|
|
29830
|
+
/** Compute a swap deadline (hub timestamp + `offsetSeconds`, default 300s). */
|
|
29884
29831
|
async getDeadline(query, config) {
|
|
29885
|
-
|
|
29886
|
-
if (query?.offsetSeconds !== void 0) queryParams.append("offsetSeconds", String(query.offsetSeconds));
|
|
29887
|
-
const queryString = queryParams.toString();
|
|
29888
|
-
const endpoint = queryString.length > 0 ? `/swaps/deadline?${queryString}` : "/swaps/deadline";
|
|
29889
|
-
return this.request(endpoint, { method: "GET" }, DeadlineResponseSchema, config);
|
|
29832
|
+
return this.toResult("/swaps/deadline", (c) => c.getDeadline(query), config);
|
|
29890
29833
|
}
|
|
29891
29834
|
// ──────────────────────────────────────────────────────────────────────
|
|
29892
29835
|
// Allowance · approve · create intent
|
|
29893
29836
|
// ──────────────────────────────────────────────────────────────────────
|
|
29894
|
-
/**
|
|
29895
|
-
* Check whether the source token allowance is already sufficient for the intent.
|
|
29896
|
-
*
|
|
29897
|
-
* @returns `Result<AllowanceCheckResponseV2>` — `{ valid }`.
|
|
29898
|
-
*/
|
|
29837
|
+
/** Check whether the source token allowance is already sufficient for the intent. */
|
|
29899
29838
|
async checkAllowance(body, config) {
|
|
29900
|
-
return this.
|
|
29901
|
-
"/swaps/allowance/check",
|
|
29902
|
-
{ method: "POST", body: toJsonBody(body) },
|
|
29903
|
-
AllowanceCheckResponseSchema,
|
|
29904
|
-
config
|
|
29905
|
-
);
|
|
29839
|
+
return this.toResult("/swaps/allowance/check", (c) => c.checkAllowance(body), config);
|
|
29906
29840
|
}
|
|
29907
|
-
/**
|
|
29908
|
-
* Build an unsigned token-approval transaction for the source token.
|
|
29909
|
-
*
|
|
29910
|
-
* @returns `Result<ApproveResponseV2>` — `{ tx }` (chain-specific unsigned tx).
|
|
29911
|
-
*/
|
|
29841
|
+
/** Build an unsigned token-approval transaction for the source token. */
|
|
29912
29842
|
async approve(body, config) {
|
|
29913
|
-
|
|
29914
|
-
return this.request(
|
|
29915
|
-
"/swaps/approve",
|
|
29916
|
-
{ method: "POST", body: toJsonBody(body) },
|
|
29917
|
-
makeApproveResponseSchema(txSchema),
|
|
29918
|
-
config
|
|
29919
|
-
);
|
|
29843
|
+
return this.toResult("/swaps/approve", (c) => c.approve(body), config);
|
|
29920
29844
|
}
|
|
29921
|
-
/**
|
|
29922
|
-
* Build an unsigned create-intent transaction.
|
|
29923
|
-
*
|
|
29924
|
-
* @returns `Result<CreateIntentResponseV2>` — `{ tx, intent, relayData }`.
|
|
29925
|
-
*/
|
|
29845
|
+
/** Build an unsigned create-intent transaction. */
|
|
29926
29846
|
async createIntent(body, config) {
|
|
29927
|
-
|
|
29928
|
-
return this.request(
|
|
29929
|
-
"/swaps/intents",
|
|
29930
|
-
{ method: "POST", body: toJsonBody(body) },
|
|
29931
|
-
makeCreateIntentResponseSchema(txSchema),
|
|
29932
|
-
config
|
|
29933
|
-
);
|
|
29847
|
+
return this.toResult("/swaps/intents", (c) => c.createIntent(body), config);
|
|
29934
29848
|
}
|
|
29935
29849
|
// ──────────────────────────────────────────────────────────────────────
|
|
29936
29850
|
// Intent lifecycle: submit · status · cancel · hash · packet · extra-data
|
|
29937
29851
|
// ──────────────────────────────────────────────────────────────────────
|
|
29938
|
-
/**
|
|
29939
|
-
* Submit the broadcast intent tx to the relay.
|
|
29940
|
-
*
|
|
29941
|
-
* @returns `Result<SubmitIntentResponseV2>` — `{ result }` (opaque relay response).
|
|
29942
|
-
*/
|
|
29852
|
+
/** Submit the broadcast intent tx to the relay. */
|
|
29943
29853
|
async submitIntent(body, config) {
|
|
29944
|
-
return this.
|
|
29945
|
-
"/swaps/intents/submit",
|
|
29946
|
-
{ method: "POST", body: toJsonBody(body) },
|
|
29947
|
-
SubmitIntentResponseSchema,
|
|
29948
|
-
config
|
|
29949
|
-
);
|
|
29854
|
+
return this.toResult("/swaps/intents/submit", (c) => c.submitIntent(body), config);
|
|
29950
29855
|
}
|
|
29951
|
-
/**
|
|
29952
|
-
* Poll the solver for intent execution status.
|
|
29953
|
-
*
|
|
29954
|
-
* @returns `Result<StatusResponseV2>` — `{ status, fillTxHash? }` (`fillTxHash` set when `status === 3`).
|
|
29955
|
-
*/
|
|
29856
|
+
/** Poll the solver for intent execution status. */
|
|
29956
29857
|
async getStatus(body, config) {
|
|
29957
|
-
return this.
|
|
29958
|
-
"/swaps/intents/status",
|
|
29959
|
-
{ method: "POST", body: toJsonBody(body) },
|
|
29960
|
-
StatusResponseSchema,
|
|
29961
|
-
config
|
|
29962
|
-
);
|
|
29858
|
+
return this.toResult("/swaps/intents/status", (c) => c.getStatus(body), config);
|
|
29963
29859
|
}
|
|
29964
|
-
/**
|
|
29965
|
-
* Build an unsigned cancel-intent transaction. The `intent` field carries
|
|
29966
|
-
* `bigint` numerics — {@link toJsonBody} serializes them to decimal strings.
|
|
29967
|
-
*
|
|
29968
|
-
* @returns `Result<CancelIntentResponseV2>` — `{ tx }`.
|
|
29969
|
-
*/
|
|
29860
|
+
/** Build an unsigned cancel-intent transaction (the `intent` bigint numerics serialize to strings). */
|
|
29970
29861
|
async cancelIntent(body, config) {
|
|
29971
|
-
|
|
29972
|
-
return this.request(
|
|
29862
|
+
return this.toResult(
|
|
29973
29863
|
"/swaps/intents/cancel",
|
|
29974
|
-
{
|
|
29975
|
-
makeCancelIntentResponseSchema(txSchema),
|
|
29864
|
+
(c) => c.cancelIntent({ ...body, intent: _SwapsApiService.toWireIntent(body.intent) }),
|
|
29976
29865
|
config
|
|
29977
29866
|
);
|
|
29978
29867
|
}
|
|
29979
|
-
/**
|
|
29980
|
-
* Compute the keccak256 hash of an Intent struct. The `intent` field carries
|
|
29981
|
-
* `bigint` numerics — {@link toJsonBody} serializes them to decimal strings.
|
|
29982
|
-
*
|
|
29983
|
-
* @returns `Result<IntentHashResponseV2>` — `{ hash }`.
|
|
29984
|
-
*/
|
|
29868
|
+
/** Compute the keccak256 hash of an Intent struct (bigint numerics serialize to strings). */
|
|
29985
29869
|
async getIntentHash(body, config) {
|
|
29986
|
-
return this.
|
|
29870
|
+
return this.toResult(
|
|
29987
29871
|
"/swaps/intents/hash",
|
|
29988
|
-
{
|
|
29989
|
-
IntentHashResponseSchema,
|
|
29872
|
+
(c) => c.getIntentHash({ ...body, intent: _SwapsApiService.toWireIntent(body.intent) }),
|
|
29990
29873
|
config
|
|
29991
29874
|
);
|
|
29992
29875
|
}
|
|
29993
|
-
/**
|
|
29994
|
-
* Long-poll the relayer until the fill packet lands on the destination chain.
|
|
29995
|
-
*
|
|
29996
|
-
* @returns `Result<IntentPacketResponseV2>` — delivered packet data.
|
|
29997
|
-
*/
|
|
29876
|
+
/** Long-poll the relayer until the fill packet lands on the destination chain. */
|
|
29998
29877
|
async getSolvedIntentPacket(body, config) {
|
|
29999
|
-
return this.
|
|
30000
|
-
"/swaps/intents/packet",
|
|
30001
|
-
{ method: "POST", body: toJsonBody(body) },
|
|
30002
|
-
IntentPacketResponseSchema,
|
|
30003
|
-
config
|
|
30004
|
-
);
|
|
29878
|
+
return this.toResult("/swaps/intents/packet", (c) => c.getSolvedIntentPacket(body), config);
|
|
30005
29879
|
}
|
|
30006
|
-
/**
|
|
30007
|
-
* Recover the relay extra data needed by `/swaps/intents/submit`. Provide
|
|
30008
|
-
* EITHER `txHash` OR `intent` (whose `bigint` numerics {@link toJsonBody} serializes).
|
|
30009
|
-
*
|
|
30010
|
-
* @returns `Result<IntentExtraDataResponseV2>` — `{ address, payload }`.
|
|
30011
|
-
*/
|
|
29880
|
+
/** Recover the relay extra data needed by `/swaps/intents/submit` (provide EITHER `txHash` OR `intent`). */
|
|
30012
29881
|
async getIntentSubmitTxExtraData(body, config) {
|
|
30013
|
-
|
|
30014
|
-
|
|
30015
|
-
{ method: "POST", body: toJsonBody(body) },
|
|
30016
|
-
RelayExtraDataResponseSchema,
|
|
30017
|
-
config
|
|
30018
|
-
);
|
|
29882
|
+
const normalized = body.intent ? { ...body, intent: _SwapsApiService.toWireIntent(body.intent) } : body;
|
|
29883
|
+
return this.toResult("/swaps/intents/extra-data", (c) => c.getIntentSubmitTxExtraData(normalized), config);
|
|
30019
29884
|
}
|
|
30020
|
-
/**
|
|
30021
|
-
* Get the on-chain fill state for an intent by its hub-chain tx hash.
|
|
30022
|
-
*
|
|
30023
|
-
* @returns `Result<IntentStateV2>` — `{ exists, remainingInput, receivedOutput, pendingPayment }`.
|
|
30024
|
-
*/
|
|
29885
|
+
/** Get the on-chain fill state for an intent by its hub-chain tx hash. */
|
|
30025
29886
|
async getFilledIntent(txHash, config) {
|
|
30026
|
-
return this.
|
|
29887
|
+
return this.toResult(`/swaps/intents/${txHash}/fill`, (c) => c.getFilledIntent(txHash), config);
|
|
30027
29888
|
}
|
|
30028
|
-
/**
|
|
30029
|
-
* Look up an Intent struct by its hub-chain creation tx hash.
|
|
30030
|
-
*
|
|
30031
|
-
* @returns `Result<GetIntentResponseV2>` — the decoded intent (bigint fields as decimal strings).
|
|
30032
|
-
*/
|
|
29889
|
+
/** Look up an Intent struct by its hub-chain creation tx hash. */
|
|
30033
29890
|
async getIntent(txHash, config) {
|
|
30034
|
-
return this.
|
|
29891
|
+
return this.toResult(`/swaps/intents/${txHash}`, (c) => c.getIntent(txHash), config);
|
|
30035
29892
|
}
|
|
30036
29893
|
// ──────────────────────────────────────────────────────────────────────
|
|
30037
29894
|
// Limit orders · gas · fees
|
|
30038
29895
|
// ──────────────────────────────────────────────────────────────────────
|
|
30039
|
-
/**
|
|
30040
|
-
* Build an unsigned create-limit-order-intent transaction (same as create-intent
|
|
30041
|
-
* but `deadline` is optional).
|
|
30042
|
-
*
|
|
30043
|
-
* @returns `Result<CreateLimitOrderResponseV2>` — `{ tx, intent, relayData }`.
|
|
30044
|
-
*/
|
|
29896
|
+
/** Build an unsigned create-limit-order-intent transaction (create-intent with optional `deadline`). */
|
|
30045
29897
|
async createLimitOrderIntent(body, config) {
|
|
30046
|
-
|
|
30047
|
-
return this.request(
|
|
30048
|
-
"/swaps/limit-orders",
|
|
30049
|
-
{ method: "POST", body: toJsonBody(body) },
|
|
30050
|
-
makeCreateIntentResponseSchema(txSchema),
|
|
30051
|
-
config
|
|
30052
|
-
);
|
|
29898
|
+
return this.toResult("/swaps/limit-orders", (c) => c.createLimitOrderIntent(body), config);
|
|
30053
29899
|
}
|
|
30054
|
-
/**
|
|
30055
|
-
* Estimate gas for a raw transaction on a spoke chain.
|
|
30056
|
-
*
|
|
30057
|
-
* @returns `Result<GasEstimateResponseV2>` — `{ gas }` (chain-specific shape).
|
|
30058
|
-
*/
|
|
29900
|
+
/** Estimate gas for a raw transaction on a spoke chain (bigint `tx` numerics serialize to strings). */
|
|
30059
29901
|
async estimateGas(body, config) {
|
|
30060
|
-
return this.
|
|
30061
|
-
"/swaps/gas/estimate",
|
|
30062
|
-
{ method: "POST", body: toJsonBody(body) },
|
|
30063
|
-
GasEstimateResponseSchema,
|
|
30064
|
-
config
|
|
30065
|
-
);
|
|
29902
|
+
return this.toResult("/swaps/gas/estimate", (c) => c.estimateGas(body), config);
|
|
30066
29903
|
}
|
|
30067
|
-
/**
|
|
30068
|
-
* Compute the partner fee for a given input amount.
|
|
30069
|
-
*
|
|
30070
|
-
* @returns `Result<FeeResponseV2>` — `{ fee }` (decimal string).
|
|
30071
|
-
*/
|
|
29904
|
+
/** Compute the partner fee for a given input amount. */
|
|
30072
29905
|
async getPartnerFee(query, config) {
|
|
30073
|
-
|
|
30074
|
-
return this.request(
|
|
30075
|
-
`/swaps/fees/partner?${queryParams.toString()}`,
|
|
30076
|
-
{ method: "GET" },
|
|
30077
|
-
FeeResponseSchema,
|
|
30078
|
-
config
|
|
30079
|
-
);
|
|
29906
|
+
return this.toResult("/swaps/fees/partner", (c) => c.getPartnerFee(query), config);
|
|
30080
29907
|
}
|
|
30081
|
-
/**
|
|
30082
|
-
* Compute the protocol (solver) fee for a given input amount.
|
|
30083
|
-
*
|
|
30084
|
-
* @returns `Result<FeeResponseV2>` — `{ fee }` (decimal string).
|
|
30085
|
-
*/
|
|
29908
|
+
/** Compute the protocol (solver) fee for a given input amount. */
|
|
30086
29909
|
async getSolverFee(query, config) {
|
|
30087
|
-
|
|
30088
|
-
return this.request(
|
|
30089
|
-
`/swaps/fees/solver?${queryParams.toString()}`,
|
|
30090
|
-
{ method: "GET" },
|
|
30091
|
-
FeeResponseSchema,
|
|
30092
|
-
config
|
|
30093
|
-
);
|
|
29910
|
+
return this.toResult("/swaps/fees/solver", (c) => c.getSolverFee(query), config);
|
|
30094
29911
|
}
|
|
30095
29912
|
// ──────────────────────────────────────────────────────────────────────
|
|
30096
29913
|
// Submit-tx state machine
|
|
30097
29914
|
// ──────────────────────────────────────────────────────────────────────
|
|
30098
|
-
/**
|
|
30099
|
-
* Submit a swap transaction to be processed (relay, post-execution, etc.). The
|
|
30100
|
-
* `intent` field carries `bigint` numerics — {@link toJsonBody} serializes them.
|
|
30101
|
-
* Idempotent on `(txHash, srcChainKey)`.
|
|
30102
|
-
*
|
|
30103
|
-
* @returns `Result<SubmitTxResponseV2>` — `{ success, data: { status, message } }`.
|
|
30104
|
-
*/
|
|
29915
|
+
/** Submit a swap transaction to be processed (relay, post-execution, etc.). Idempotent on `(txHash, srcChainKey)`. */
|
|
30105
29916
|
async submitTx(body, config) {
|
|
30106
|
-
return this.
|
|
29917
|
+
return this.toResult(
|
|
30107
29918
|
"/swaps/submit-tx",
|
|
30108
|
-
{
|
|
30109
|
-
SubmitTxResponseSchema,
|
|
29919
|
+
(c) => c.submitTx({ ...body, intent: _SwapsApiService.toWireIntent(body.intent) }),
|
|
30110
29920
|
config
|
|
30111
29921
|
);
|
|
30112
29922
|
}
|
|
30113
|
-
/**
|
|
30114
|
-
* Get the processing status of a submitted swap transaction by `(txHash, srcChainKey)`.
|
|
30115
|
-
*
|
|
30116
|
-
* @returns `Result<SubmitTxStatusResponseV2>` — `{ success, data }` (processing state).
|
|
30117
|
-
*/
|
|
29923
|
+
/** Get the processing status of a submitted swap transaction by `(txHash, srcChainKey)`. */
|
|
30118
29924
|
async getSubmitTxStatus(query, config) {
|
|
30119
|
-
|
|
30120
|
-
return this.request(
|
|
30121
|
-
`/swaps/submit-tx/status?${queryParams.toString()}`,
|
|
30122
|
-
{ method: "GET" },
|
|
30123
|
-
SubmitTxStatusResponseSchema,
|
|
30124
|
-
config
|
|
30125
|
-
);
|
|
29925
|
+
return this.toResult("/swaps/submit-tx/status", (c) => c.getSubmitTxStatus(query), config);
|
|
30126
29926
|
}
|
|
30127
29927
|
// ──────────────────────────────────────────────────────────────────────
|
|
30128
29928
|
// Utilities (parity with BackendApiService)
|
|
30129
29929
|
// ──────────────────────────────────────────────────────────────────────
|
|
30130
29930
|
/**
|
|
30131
29931
|
* Merge additional headers into the service's default header set. Existing
|
|
30132
|
-
* keys are overwritten; keys absent from `headers` are preserved.
|
|
29932
|
+
* keys are overwritten; keys absent from `headers` are preserved. Applied to
|
|
29933
|
+
* every subsequent call (the delegated client is rebuilt per call).
|
|
30133
29934
|
*/
|
|
30134
29935
|
setHeaders(headers) {
|
|
30135
29936
|
Object.entries(headers).forEach(([key, value]) => {
|
|
@@ -30172,137 +29973,137 @@ function resolveSwapsApiConfig(config) {
|
|
|
30172
29973
|
}
|
|
30173
29974
|
return layerConfigs(config);
|
|
30174
29975
|
}
|
|
30175
|
-
var ChainKeySchema =
|
|
30176
|
-
var SpokeChainKeySchema =
|
|
30177
|
-
var
|
|
30178
|
-
var XTokenSchema =
|
|
30179
|
-
symbol:
|
|
30180
|
-
name:
|
|
30181
|
-
decimals:
|
|
30182
|
-
address:
|
|
29976
|
+
var ChainKeySchema = v2.custom((input) => typeof input === "string");
|
|
29977
|
+
var SpokeChainKeySchema = v2.custom((input) => typeof input === "string");
|
|
29978
|
+
var AddressSchema = v2.custom((input) => typeof input === "string");
|
|
29979
|
+
var XTokenSchema = v2.object({
|
|
29980
|
+
symbol: v2.string(),
|
|
29981
|
+
name: v2.string(),
|
|
29982
|
+
decimals: v2.number(),
|
|
29983
|
+
address: v2.string(),
|
|
30183
29984
|
chainKey: ChainKeySchema,
|
|
30184
|
-
hubAsset:
|
|
30185
|
-
vault:
|
|
30186
|
-
access:
|
|
29985
|
+
hubAsset: AddressSchema,
|
|
29986
|
+
vault: AddressSchema,
|
|
29987
|
+
access: v2.optional(v2.picklist(["withdrawOnly", "depositOnly"]))
|
|
30187
29988
|
});
|
|
30188
|
-
var IntentStructSchema =
|
|
30189
|
-
intentId:
|
|
30190
|
-
creator:
|
|
30191
|
-
inputToken:
|
|
30192
|
-
outputToken:
|
|
30193
|
-
inputAmount:
|
|
30194
|
-
minOutputAmount:
|
|
30195
|
-
deadline:
|
|
30196
|
-
allowPartialFill:
|
|
30197
|
-
srcChain:
|
|
30198
|
-
dstChain:
|
|
30199
|
-
srcAddress:
|
|
30200
|
-
dstAddress:
|
|
30201
|
-
solver:
|
|
30202
|
-
data:
|
|
29989
|
+
var IntentStructSchema = v2.object({
|
|
29990
|
+
intentId: v2.string(),
|
|
29991
|
+
creator: v2.string(),
|
|
29992
|
+
inputToken: v2.string(),
|
|
29993
|
+
outputToken: v2.string(),
|
|
29994
|
+
inputAmount: v2.string(),
|
|
29995
|
+
minOutputAmount: v2.string(),
|
|
29996
|
+
deadline: v2.string(),
|
|
29997
|
+
allowPartialFill: v2.boolean(),
|
|
29998
|
+
srcChain: v2.number(),
|
|
29999
|
+
dstChain: v2.number(),
|
|
30000
|
+
srcAddress: v2.string(),
|
|
30001
|
+
dstAddress: v2.string(),
|
|
30002
|
+
solver: v2.string(),
|
|
30003
|
+
data: v2.string()
|
|
30203
30004
|
});
|
|
30204
|
-
var
|
|
30205
|
-
intentHash:
|
|
30206
|
-
txHash:
|
|
30207
|
-
logIndex:
|
|
30208
|
-
chainId:
|
|
30209
|
-
blockNumber:
|
|
30210
|
-
open:
|
|
30005
|
+
var IntentResponseSchema = v2.object({
|
|
30006
|
+
intentHash: v2.string(),
|
|
30007
|
+
txHash: v2.string(),
|
|
30008
|
+
logIndex: v2.number(),
|
|
30009
|
+
chainId: v2.number(),
|
|
30010
|
+
blockNumber: v2.number(),
|
|
30011
|
+
open: v2.boolean(),
|
|
30211
30012
|
intent: IntentStructSchema,
|
|
30212
|
-
events:
|
|
30013
|
+
events: v2.array(v2.unknown())
|
|
30213
30014
|
});
|
|
30214
|
-
var UserIntentsResponseSchema =
|
|
30215
|
-
total:
|
|
30216
|
-
offset:
|
|
30217
|
-
limit:
|
|
30218
|
-
items:
|
|
30015
|
+
var UserIntentsResponseSchema = v2.object({
|
|
30016
|
+
total: v2.number(),
|
|
30017
|
+
offset: v2.number(),
|
|
30018
|
+
limit: v2.number(),
|
|
30019
|
+
items: v2.array(IntentResponseSchema)
|
|
30219
30020
|
});
|
|
30220
|
-
var OrderbookResponseSchema =
|
|
30221
|
-
total:
|
|
30222
|
-
data:
|
|
30223
|
-
|
|
30224
|
-
intentState:
|
|
30225
|
-
exists:
|
|
30226
|
-
remainingInput:
|
|
30227
|
-
receivedOutput:
|
|
30228
|
-
pendingPayment:
|
|
30021
|
+
var OrderbookResponseSchema = v2.object({
|
|
30022
|
+
total: v2.number(),
|
|
30023
|
+
data: v2.array(
|
|
30024
|
+
v2.object({
|
|
30025
|
+
intentState: v2.object({
|
|
30026
|
+
exists: v2.boolean(),
|
|
30027
|
+
remainingInput: v2.string(),
|
|
30028
|
+
receivedOutput: v2.string(),
|
|
30029
|
+
pendingPayment: v2.boolean()
|
|
30229
30030
|
}),
|
|
30230
|
-
intentData:
|
|
30231
|
-
intentId:
|
|
30232
|
-
creator:
|
|
30233
|
-
inputToken:
|
|
30234
|
-
outputToken:
|
|
30235
|
-
inputAmount:
|
|
30236
|
-
minOutputAmount:
|
|
30237
|
-
deadline:
|
|
30238
|
-
allowPartialFill:
|
|
30239
|
-
srcChain:
|
|
30240
|
-
dstChain:
|
|
30241
|
-
srcAddress:
|
|
30242
|
-
dstAddress:
|
|
30243
|
-
solver:
|
|
30244
|
-
data:
|
|
30245
|
-
intentHash:
|
|
30246
|
-
txHash:
|
|
30247
|
-
blockNumber:
|
|
30031
|
+
intentData: v2.object({
|
|
30032
|
+
intentId: v2.string(),
|
|
30033
|
+
creator: v2.string(),
|
|
30034
|
+
inputToken: v2.string(),
|
|
30035
|
+
outputToken: v2.string(),
|
|
30036
|
+
inputAmount: v2.string(),
|
|
30037
|
+
minOutputAmount: v2.string(),
|
|
30038
|
+
deadline: v2.string(),
|
|
30039
|
+
allowPartialFill: v2.boolean(),
|
|
30040
|
+
srcChain: v2.number(),
|
|
30041
|
+
dstChain: v2.number(),
|
|
30042
|
+
srcAddress: v2.string(),
|
|
30043
|
+
dstAddress: v2.string(),
|
|
30044
|
+
solver: v2.string(),
|
|
30045
|
+
data: v2.string(),
|
|
30046
|
+
intentHash: v2.string(),
|
|
30047
|
+
txHash: v2.string(),
|
|
30048
|
+
blockNumber: v2.number()
|
|
30248
30049
|
})
|
|
30249
30050
|
})
|
|
30250
30051
|
)
|
|
30251
30052
|
});
|
|
30252
|
-
var MoneyMarketPositionSchema =
|
|
30253
|
-
userAddress:
|
|
30254
|
-
positions:
|
|
30255
|
-
|
|
30256
|
-
reserveAddress:
|
|
30257
|
-
aTokenAddress:
|
|
30258
|
-
variableDebtTokenAddress:
|
|
30259
|
-
aTokenBalance:
|
|
30260
|
-
variableDebtTokenBalance:
|
|
30261
|
-
blockNumber:
|
|
30053
|
+
var MoneyMarketPositionSchema = v2.object({
|
|
30054
|
+
userAddress: v2.string(),
|
|
30055
|
+
positions: v2.array(
|
|
30056
|
+
v2.object({
|
|
30057
|
+
reserveAddress: v2.string(),
|
|
30058
|
+
aTokenAddress: v2.string(),
|
|
30059
|
+
variableDebtTokenAddress: v2.string(),
|
|
30060
|
+
aTokenBalance: v2.string(),
|
|
30061
|
+
variableDebtTokenBalance: v2.string(),
|
|
30062
|
+
blockNumber: v2.number()
|
|
30262
30063
|
})
|
|
30263
30064
|
)
|
|
30264
30065
|
});
|
|
30265
|
-
var MoneyMarketAssetSchema =
|
|
30266
|
-
reserveAddress:
|
|
30267
|
-
aTokenAddress:
|
|
30268
|
-
totalATokenBalance:
|
|
30269
|
-
variableDebtTokenAddress:
|
|
30270
|
-
totalVariableDebtTokenBalance:
|
|
30271
|
-
liquidityRate:
|
|
30272
|
-
symbol:
|
|
30273
|
-
totalSuppliers:
|
|
30274
|
-
totalBorrowers:
|
|
30275
|
-
variableBorrowRate:
|
|
30276
|
-
stableBorrowRate:
|
|
30277
|
-
liquidityIndex:
|
|
30278
|
-
variableBorrowIndex:
|
|
30279
|
-
blockNumber:
|
|
30066
|
+
var MoneyMarketAssetSchema = v2.object({
|
|
30067
|
+
reserveAddress: v2.string(),
|
|
30068
|
+
aTokenAddress: v2.string(),
|
|
30069
|
+
totalATokenBalance: v2.string(),
|
|
30070
|
+
variableDebtTokenAddress: v2.string(),
|
|
30071
|
+
totalVariableDebtTokenBalance: v2.string(),
|
|
30072
|
+
liquidityRate: v2.string(),
|
|
30073
|
+
symbol: v2.string(),
|
|
30074
|
+
totalSuppliers: v2.number(),
|
|
30075
|
+
totalBorrowers: v2.number(),
|
|
30076
|
+
variableBorrowRate: v2.string(),
|
|
30077
|
+
stableBorrowRate: v2.string(),
|
|
30078
|
+
liquidityIndex: v2.string(),
|
|
30079
|
+
variableBorrowIndex: v2.string(),
|
|
30080
|
+
blockNumber: v2.number()
|
|
30280
30081
|
});
|
|
30281
|
-
var MoneyMarketAssetsSchema =
|
|
30282
|
-
var MoneyMarketAssetBorrowersSchema =
|
|
30283
|
-
borrowers:
|
|
30284
|
-
total:
|
|
30285
|
-
offset:
|
|
30286
|
-
limit:
|
|
30082
|
+
var MoneyMarketAssetsSchema = v2.array(MoneyMarketAssetSchema);
|
|
30083
|
+
var MoneyMarketAssetBorrowersSchema = v2.object({
|
|
30084
|
+
borrowers: v2.array(v2.string()),
|
|
30085
|
+
total: v2.number(),
|
|
30086
|
+
offset: v2.number(),
|
|
30087
|
+
limit: v2.number()
|
|
30287
30088
|
});
|
|
30288
|
-
var MoneyMarketAssetSuppliersSchema =
|
|
30289
|
-
suppliers:
|
|
30290
|
-
total:
|
|
30291
|
-
offset:
|
|
30292
|
-
limit:
|
|
30089
|
+
var MoneyMarketAssetSuppliersSchema = v2.object({
|
|
30090
|
+
suppliers: v2.array(v2.string()),
|
|
30091
|
+
total: v2.number(),
|
|
30092
|
+
offset: v2.number(),
|
|
30093
|
+
limit: v2.number()
|
|
30293
30094
|
});
|
|
30294
|
-
var MoneyMarketBorrowersSchema =
|
|
30295
|
-
borrowers:
|
|
30296
|
-
total:
|
|
30297
|
-
offset:
|
|
30298
|
-
limit:
|
|
30095
|
+
var MoneyMarketBorrowersSchema = v2.object({
|
|
30096
|
+
borrowers: v2.array(v2.string()),
|
|
30097
|
+
total: v2.number(),
|
|
30098
|
+
offset: v2.number(),
|
|
30099
|
+
limit: v2.number()
|
|
30299
30100
|
});
|
|
30300
|
-
var GetChainsResponseSchema =
|
|
30301
|
-
var TokensByChainMapSchema =
|
|
30302
|
-
(input) => typeof input === "object" && input !== null && Object.values(input).every((tokens) => Array.isArray(tokens) && tokens.every((t) =>
|
|
30101
|
+
var GetChainsResponseSchema = v2.array(SpokeChainKeySchema);
|
|
30102
|
+
var TokensByChainMapSchema = v2.custom(
|
|
30103
|
+
(input) => typeof input === "object" && input !== null && Object.values(input).every((tokens) => Array.isArray(tokens) && tokens.every((t) => v2.is(XTokenSchema, t)))
|
|
30303
30104
|
);
|
|
30304
|
-
var TokensListSchema =
|
|
30305
|
-
var ReserveAssetsSchema =
|
|
30105
|
+
var TokensListSchema = v2.array(XTokenSchema);
|
|
30106
|
+
var ReserveAssetsSchema = v2.array(AddressSchema);
|
|
30306
30107
|
|
|
30307
30108
|
// src/backendApi/BackendApiService.ts
|
|
30308
30109
|
var BackendApiService = class {
|
|
@@ -30364,13 +30165,13 @@ var BackendApiService = class {
|
|
|
30364
30165
|
logger: this.logger,
|
|
30365
30166
|
serviceLabel: "BackendApiService"
|
|
30366
30167
|
});
|
|
30367
|
-
const parsed =
|
|
30168
|
+
const parsed = v2.safeParse(schema, raw);
|
|
30368
30169
|
if (!parsed.success) {
|
|
30369
30170
|
return {
|
|
30370
30171
|
ok: false,
|
|
30371
30172
|
error: new SodaxError("EXTERNAL_API_ERROR", `Invalid response shape from backend API for ${endpoint}`, {
|
|
30372
30173
|
feature: "backend",
|
|
30373
|
-
context: { api: "backend", endpoint, reason: "invalid_response_shape", issues:
|
|
30174
|
+
context: { api: "backend", endpoint, reason: "invalid_response_shape", issues: v2.flatten(parsed.issues) }
|
|
30374
30175
|
})
|
|
30375
30176
|
};
|
|
30376
30177
|
}
|
|
@@ -30411,7 +30212,7 @@ var BackendApiService = class {
|
|
|
30411
30212
|
* open/closed state, token amounts, and any fill events.
|
|
30412
30213
|
*/
|
|
30413
30214
|
async getIntentByTxHash(txHash, config) {
|
|
30414
|
-
return this.request(`/intent/tx/${txHash}`, { ...config, method: "GET" },
|
|
30215
|
+
return this.request(`/intent/tx/${txHash}`, { ...config, method: "GET" }, IntentResponseSchema);
|
|
30415
30216
|
}
|
|
30416
30217
|
/**
|
|
30417
30218
|
* Fetch a swap intent by its canonical intent hash.
|
|
@@ -30420,7 +30221,7 @@ var BackendApiService = class {
|
|
|
30420
30221
|
* @returns `Result<IntentResponse>` — on success, the full intent details.
|
|
30421
30222
|
*/
|
|
30422
30223
|
async getIntentByHash(intentHash, config) {
|
|
30423
|
-
return this.request(`/intent/${intentHash}`, { ...config, method: "GET" },
|
|
30224
|
+
return this.request(`/intent/${intentHash}`, { ...config, method: "GET" }, IntentResponseSchema);
|
|
30424
30225
|
}
|
|
30425
30226
|
// Solver endpoints
|
|
30426
30227
|
/**
|
|
@@ -30720,6 +30521,7 @@ var BackendApiService = class {
|
|
|
30720
30521
|
// src/bridge/errors.ts
|
|
30721
30522
|
var bridgeInvariant = createInvariant("bridge");
|
|
30722
30523
|
var ORCHESTRATION_CODES = /* @__PURE__ */ new Set([
|
|
30524
|
+
"USER_REJECTED",
|
|
30723
30525
|
"VALIDATION_FAILED",
|
|
30724
30526
|
"INTENT_CREATION_FAILED",
|
|
30725
30527
|
"TX_VERIFICATION_FAILED",
|
|
@@ -30730,6 +30532,7 @@ var ORCHESTRATION_CODES = /* @__PURE__ */ new Set([
|
|
|
30730
30532
|
"UNKNOWN"
|
|
30731
30533
|
]);
|
|
30732
30534
|
var BRIDGE_CODES = /* @__PURE__ */ new Set([
|
|
30535
|
+
"USER_REJECTED",
|
|
30733
30536
|
"VALIDATION_FAILED",
|
|
30734
30537
|
"INTENT_CREATION_FAILED",
|
|
30735
30538
|
"TX_VERIFICATION_FAILED",
|
|
@@ -31806,6 +31609,7 @@ var StakingLogic = class _StakingLogic {
|
|
|
31806
31609
|
// src/staking/errors.ts
|
|
31807
31610
|
var stakingInvariant = createInvariant("staking");
|
|
31808
31611
|
var STAKE_ORCHESTRATION_CODES = /* @__PURE__ */ new Set([
|
|
31612
|
+
"USER_REJECTED",
|
|
31809
31613
|
"VALIDATION_FAILED",
|
|
31810
31614
|
"INTENT_CREATION_FAILED",
|
|
31811
31615
|
"TX_VERIFICATION_FAILED",
|
|
@@ -31816,6 +31620,7 @@ var STAKE_ORCHESTRATION_CODES = /* @__PURE__ */ new Set([
|
|
|
31816
31620
|
"UNKNOWN"
|
|
31817
31621
|
]);
|
|
31818
31622
|
var STAKING_ORCHESTRATION_CODES = /* @__PURE__ */ new Set([
|
|
31623
|
+
"USER_REJECTED",
|
|
31819
31624
|
"VALIDATION_FAILED",
|
|
31820
31625
|
"INTENT_CREATION_FAILED",
|
|
31821
31626
|
"TX_SUBMIT_FAILED",
|
|
@@ -31825,6 +31630,7 @@ var STAKING_ORCHESTRATION_CODES = /* @__PURE__ */ new Set([
|
|
|
31825
31630
|
"UNKNOWN"
|
|
31826
31631
|
]);
|
|
31827
31632
|
var STAKING_CODES = /* @__PURE__ */ new Set([
|
|
31633
|
+
"USER_REJECTED",
|
|
31828
31634
|
"VALIDATION_FAILED",
|
|
31829
31635
|
"INTENT_CREATION_FAILED",
|
|
31830
31636
|
"TX_VERIFICATION_FAILED",
|
|
@@ -33128,6 +32934,14 @@ var StakingService = class {
|
|
|
33128
32934
|
});
|
|
33129
32935
|
}
|
|
33130
32936
|
};
|
|
32937
|
+
|
|
32938
|
+
// src/dex/errors.ts
|
|
32939
|
+
var dexInvariant = createInvariant("dex");
|
|
32940
|
+
var isDexError = isCodeMember(LOOKUP_CODES);
|
|
32941
|
+
var isDexCreateIntentError = isCodeMember(CREATE_INTENT_CODES);
|
|
32942
|
+
var isDexApproveError = isCodeMember(APPROVE_CODES);
|
|
32943
|
+
|
|
32944
|
+
// src/dex/AssetService.ts
|
|
33131
32945
|
var AssetService = class {
|
|
33132
32946
|
relayerApiEndpoint;
|
|
33133
32947
|
hubProvider;
|
|
@@ -33233,7 +33047,7 @@ var AssetService = class {
|
|
|
33233
33047
|
walletProvider: _params.walletProvider
|
|
33234
33048
|
}
|
|
33235
33049
|
);
|
|
33236
|
-
if (!result.ok) return result;
|
|
33050
|
+
if (!result.ok) return { ok: false, error: approveFailed("dex", result.error) };
|
|
33237
33051
|
return {
|
|
33238
33052
|
ok: true,
|
|
33239
33053
|
value: result.value
|
|
@@ -33258,23 +33072,16 @@ var AssetService = class {
|
|
|
33258
33072
|
raw: _params.raw,
|
|
33259
33073
|
walletProvider: _params.walletProvider
|
|
33260
33074
|
});
|
|
33261
|
-
if (!result.ok) {
|
|
33262
|
-
return result;
|
|
33263
|
-
}
|
|
33075
|
+
if (!result.ok) return { ok: false, error: approveFailed("dex", result.error) };
|
|
33264
33076
|
return {
|
|
33265
33077
|
ok: true,
|
|
33266
33078
|
value: result.value
|
|
33267
33079
|
};
|
|
33268
33080
|
}
|
|
33269
|
-
|
|
33270
|
-
ok: false,
|
|
33271
|
-
error: new Error("Approve only supported for EVM/Stellar spoke chains")
|
|
33272
|
-
};
|
|
33081
|
+
dexInvariant(false, "Approve only supported for EVM/Stellar spoke chains");
|
|
33273
33082
|
} catch (error) {
|
|
33274
|
-
return {
|
|
33275
|
-
|
|
33276
|
-
error
|
|
33277
|
-
};
|
|
33083
|
+
if (isDexApproveError(error)) return { ok: false, error };
|
|
33084
|
+
return { ok: false, error: approveFailed("dex", error) };
|
|
33278
33085
|
}
|
|
33279
33086
|
}
|
|
33280
33087
|
/**
|
|
@@ -33332,12 +33139,7 @@ var AssetService = class {
|
|
|
33332
33139
|
walletProvider: _params.walletProvider
|
|
33333
33140
|
}
|
|
33334
33141
|
);
|
|
33335
|
-
if (!txResult.ok) {
|
|
33336
|
-
return {
|
|
33337
|
-
ok: false,
|
|
33338
|
-
error: txResult.error
|
|
33339
|
-
};
|
|
33340
|
-
}
|
|
33142
|
+
if (!txResult.ok) return { ok: false, error: intentCreationFailed("dex", txResult.error) };
|
|
33341
33143
|
return {
|
|
33342
33144
|
ok: true,
|
|
33343
33145
|
value: {
|
|
@@ -33346,10 +33148,8 @@ var AssetService = class {
|
|
|
33346
33148
|
}
|
|
33347
33149
|
};
|
|
33348
33150
|
} catch (error) {
|
|
33349
|
-
return {
|
|
33350
|
-
|
|
33351
|
-
error
|
|
33352
|
-
};
|
|
33151
|
+
if (isDexCreateIntentError(error)) return { ok: false, error };
|
|
33152
|
+
return { ok: false, error: intentCreationFailed("dex", error) };
|
|
33353
33153
|
}
|
|
33354
33154
|
}
|
|
33355
33155
|
/**
|
|
@@ -33407,12 +33207,7 @@ var AssetService = class {
|
|
|
33407
33207
|
walletProvider: _params.walletProvider
|
|
33408
33208
|
};
|
|
33409
33209
|
const txResult = await this.spoke.sendMessage(sendMessageParams);
|
|
33410
|
-
if (!txResult.ok) {
|
|
33411
|
-
return {
|
|
33412
|
-
ok: false,
|
|
33413
|
-
error: txResult.error
|
|
33414
|
-
};
|
|
33415
|
-
}
|
|
33210
|
+
if (!txResult.ok) return { ok: false, error: intentCreationFailed("dex", txResult.error) };
|
|
33416
33211
|
return {
|
|
33417
33212
|
ok: true,
|
|
33418
33213
|
value: {
|
|
@@ -33421,10 +33216,8 @@ var AssetService = class {
|
|
|
33421
33216
|
}
|
|
33422
33217
|
};
|
|
33423
33218
|
} catch (error) {
|
|
33424
|
-
return {
|
|
33425
|
-
|
|
33426
|
-
error
|
|
33427
|
-
};
|
|
33219
|
+
if (isDexCreateIntentError(error)) return { ok: false, error };
|
|
33220
|
+
return { ok: false, error: intentCreationFailed("dex", error) };
|
|
33428
33221
|
}
|
|
33429
33222
|
}
|
|
33430
33223
|
/**
|
|
@@ -33486,7 +33279,8 @@ var AssetService = class {
|
|
|
33486
33279
|
}
|
|
33487
33280
|
return { ok: true, value: { srcChainTxHash: txResult.value.tx, dstChainTxHash: hubTxHash } };
|
|
33488
33281
|
} catch (error) {
|
|
33489
|
-
return { ok: false, error };
|
|
33282
|
+
if (isDexCreateIntentError(error)) return { ok: false, error };
|
|
33283
|
+
return { ok: false, error: intentCreationFailed("dex", error) };
|
|
33490
33284
|
}
|
|
33491
33285
|
}
|
|
33492
33286
|
/**
|
|
@@ -33522,7 +33316,8 @@ var AssetService = class {
|
|
|
33522
33316
|
}
|
|
33523
33317
|
return { ok: true, value: { srcChainTxHash: txResult.value.tx, dstChainTxHash: hubTxHash } };
|
|
33524
33318
|
} catch (error) {
|
|
33525
|
-
return { ok: false, error };
|
|
33319
|
+
if (isDexCreateIntentError(error)) return { ok: false, error };
|
|
33320
|
+
return { ok: false, error: intentCreationFailed("dex", error) };
|
|
33526
33321
|
}
|
|
33527
33322
|
}
|
|
33528
33323
|
/**
|
|
@@ -33654,10 +33449,10 @@ var AssetService = class {
|
|
|
33654
33449
|
async getWrappedAmount(dexToken, assetAmount) {
|
|
33655
33450
|
try {
|
|
33656
33451
|
const shares = await Erc4626Service.convertToShares(dexToken, assetAmount, this.hubProvider.publicClient);
|
|
33657
|
-
if (!shares.ok) return shares;
|
|
33452
|
+
if (!shares.ok) return { ok: false, error: lookupFailed("dex", "getWrappedAmount", shares.error) };
|
|
33658
33453
|
return { ok: true, value: shares.value };
|
|
33659
33454
|
} catch (error) {
|
|
33660
|
-
return { ok: false, error };
|
|
33455
|
+
return { ok: false, error: lookupFailed("dex", "getWrappedAmount", error) };
|
|
33661
33456
|
}
|
|
33662
33457
|
}
|
|
33663
33458
|
/**
|
|
@@ -33673,10 +33468,10 @@ var AssetService = class {
|
|
|
33673
33468
|
async getUnwrappedAmount(dexToken, shareAmount) {
|
|
33674
33469
|
try {
|
|
33675
33470
|
const assetAmount = await Erc4626Service.convertToAssets(dexToken, shareAmount, this.hubProvider.publicClient);
|
|
33676
|
-
if (!assetAmount.ok) return assetAmount;
|
|
33471
|
+
if (!assetAmount.ok) return { ok: false, error: lookupFailed("dex", "getUnwrappedAmount", assetAmount.error) };
|
|
33677
33472
|
return { ok: true, value: assetAmount.value };
|
|
33678
33473
|
} catch (error) {
|
|
33679
|
-
return { ok: false, error };
|
|
33474
|
+
return { ok: false, error: lookupFailed("dex", "getUnwrappedAmount", error) };
|
|
33680
33475
|
}
|
|
33681
33476
|
}
|
|
33682
33477
|
/**
|
|
@@ -33702,14 +33497,10 @@ var AssetService = class {
|
|
|
33702
33497
|
});
|
|
33703
33498
|
return { ok: true, value };
|
|
33704
33499
|
} catch (error) {
|
|
33705
|
-
return { ok: false, error };
|
|
33500
|
+
return { ok: false, error: lookupFailed("dex", "getDeposit", error) };
|
|
33706
33501
|
}
|
|
33707
33502
|
}
|
|
33708
33503
|
};
|
|
33709
|
-
|
|
33710
|
-
// src/dex/errors.ts
|
|
33711
|
-
var dexInvariant = createInvariant("dex");
|
|
33712
|
-
var isDexError = isCodeMember(LOOKUP_CODES);
|
|
33713
33504
|
var ClService = class _ClService {
|
|
33714
33505
|
relayerApiEndpoint;
|
|
33715
33506
|
hubProvider;
|
|
@@ -33824,7 +33615,7 @@ var ClService = class _ClService {
|
|
|
33824
33615
|
this.config.logger.error("executeSupplyLiquidity error", txResult.error);
|
|
33825
33616
|
return {
|
|
33826
33617
|
ok: false,
|
|
33827
|
-
error: txResult.error
|
|
33618
|
+
error: intentCreationFailed("dex", txResult.error)
|
|
33828
33619
|
};
|
|
33829
33620
|
}
|
|
33830
33621
|
return {
|
|
@@ -33836,10 +33627,8 @@ var ClService = class _ClService {
|
|
|
33836
33627
|
};
|
|
33837
33628
|
} catch (error) {
|
|
33838
33629
|
this.config.logger.error("executeSupplyLiquidity error", error);
|
|
33839
|
-
return {
|
|
33840
|
-
|
|
33841
|
-
error
|
|
33842
|
-
};
|
|
33630
|
+
if (isDexCreateIntentError(error)) return { ok: false, error };
|
|
33631
|
+
return { ok: false, error: intentCreationFailed("dex", error) };
|
|
33843
33632
|
}
|
|
33844
33633
|
}
|
|
33845
33634
|
/**
|
|
@@ -33951,7 +33740,7 @@ var ClService = class _ClService {
|
|
|
33951
33740
|
if (!txResult.ok) {
|
|
33952
33741
|
return {
|
|
33953
33742
|
ok: false,
|
|
33954
|
-
error: txResult.error
|
|
33743
|
+
error: intentCreationFailed("dex", txResult.error)
|
|
33955
33744
|
};
|
|
33956
33745
|
}
|
|
33957
33746
|
return {
|
|
@@ -33962,10 +33751,8 @@ var ClService = class _ClService {
|
|
|
33962
33751
|
}
|
|
33963
33752
|
};
|
|
33964
33753
|
} catch (error) {
|
|
33965
|
-
return {
|
|
33966
|
-
|
|
33967
|
-
error
|
|
33968
|
-
};
|
|
33754
|
+
if (isDexCreateIntentError(error)) return { ok: false, error };
|
|
33755
|
+
return { ok: false, error: intentCreationFailed("dex", error) };
|
|
33969
33756
|
}
|
|
33970
33757
|
}
|
|
33971
33758
|
/**
|
|
@@ -34024,7 +33811,7 @@ var ClService = class _ClService {
|
|
|
34024
33811
|
if (!txResult.ok) {
|
|
34025
33812
|
return {
|
|
34026
33813
|
ok: false,
|
|
34027
|
-
error: txResult.error
|
|
33814
|
+
error: intentCreationFailed("dex", txResult.error)
|
|
34028
33815
|
};
|
|
34029
33816
|
}
|
|
34030
33817
|
return {
|
|
@@ -34035,10 +33822,8 @@ var ClService = class _ClService {
|
|
|
34035
33822
|
}
|
|
34036
33823
|
};
|
|
34037
33824
|
} catch (error) {
|
|
34038
|
-
return {
|
|
34039
|
-
|
|
34040
|
-
error
|
|
34041
|
-
};
|
|
33825
|
+
if (isDexCreateIntentError(error)) return { ok: false, error };
|
|
33826
|
+
return { ok: false, error: intentCreationFailed("dex", error) };
|
|
34042
33827
|
}
|
|
34043
33828
|
}
|
|
34044
33829
|
/**
|
|
@@ -34113,10 +33898,8 @@ var ClService = class _ClService {
|
|
|
34113
33898
|
return { ok: true, value: { srcChainTxHash: txResult.value.tx, dstChainTxHash: hubTxHash } };
|
|
34114
33899
|
} catch (error) {
|
|
34115
33900
|
this.config.logger.error("supplyLiquidity error", error);
|
|
34116
|
-
return {
|
|
34117
|
-
|
|
34118
|
-
error
|
|
34119
|
-
};
|
|
33901
|
+
if (isDexCreateIntentError(error)) return { ok: false, error };
|
|
33902
|
+
return { ok: false, error: intentCreationFailed("dex", error) };
|
|
34120
33903
|
}
|
|
34121
33904
|
},
|
|
34122
33905
|
{
|
|
@@ -34176,10 +33959,8 @@ var ClService = class _ClService {
|
|
|
34176
33959
|
}
|
|
34177
33960
|
return { ok: true, value: { srcChainTxHash: txResult.value.tx, dstChainTxHash: hubTxHash } };
|
|
34178
33961
|
} catch (error) {
|
|
34179
|
-
return {
|
|
34180
|
-
|
|
34181
|
-
error
|
|
34182
|
-
};
|
|
33962
|
+
if (isDexCreateIntentError(error)) return { ok: false, error };
|
|
33963
|
+
return { ok: false, error: intentCreationFailed("dex", error) };
|
|
34183
33964
|
}
|
|
34184
33965
|
},
|
|
34185
33966
|
{
|
|
@@ -34240,10 +34021,8 @@ var ClService = class _ClService {
|
|
|
34240
34021
|
}
|
|
34241
34022
|
return { ok: true, value: { srcChainTxHash: txResult.value.tx, dstChainTxHash: hubTxHash } };
|
|
34242
34023
|
} catch (error) {
|
|
34243
|
-
return {
|
|
34244
|
-
|
|
34245
|
-
error
|
|
34246
|
-
};
|
|
34024
|
+
if (isDexCreateIntentError(error)) return { ok: false, error };
|
|
34025
|
+
return { ok: false, error: intentCreationFailed("dex", error) };
|
|
34247
34026
|
}
|
|
34248
34027
|
},
|
|
34249
34028
|
{
|
|
@@ -34382,7 +34161,7 @@ var ClService = class _ClService {
|
|
|
34382
34161
|
this.config.logger.error("executeClaimRewards error", txResult.error);
|
|
34383
34162
|
return {
|
|
34384
34163
|
ok: false,
|
|
34385
|
-
error: txResult.error
|
|
34164
|
+
error: intentCreationFailed("dex", txResult.error)
|
|
34386
34165
|
};
|
|
34387
34166
|
}
|
|
34388
34167
|
return {
|
|
@@ -34394,10 +34173,8 @@ var ClService = class _ClService {
|
|
|
34394
34173
|
};
|
|
34395
34174
|
} catch (error) {
|
|
34396
34175
|
this.config.logger.error("executeClaimRewards error", error);
|
|
34397
|
-
return {
|
|
34398
|
-
|
|
34399
|
-
error
|
|
34400
|
-
};
|
|
34176
|
+
if (isDexCreateIntentError(error)) return { ok: false, error };
|
|
34177
|
+
return { ok: false, error: intentCreationFailed("dex", error) };
|
|
34401
34178
|
}
|
|
34402
34179
|
}
|
|
34403
34180
|
/**
|
|
@@ -34440,10 +34217,8 @@ var ClService = class _ClService {
|
|
|
34440
34217
|
return { ok: true, value: { srcChainTxHash: txResult.value.tx, dstChainTxHash: hubTxHash } };
|
|
34441
34218
|
} catch (error) {
|
|
34442
34219
|
this.config.logger.error("claimRewards error", error);
|
|
34443
|
-
return {
|
|
34444
|
-
|
|
34445
|
-
error
|
|
34446
|
-
};
|
|
34220
|
+
if (isDexCreateIntentError(error)) return { ok: false, error };
|
|
34221
|
+
return { ok: false, error: intentCreationFailed("dex", error) };
|
|
34447
34222
|
}
|
|
34448
34223
|
},
|
|
34449
34224
|
{
|
|
@@ -35044,6 +34819,7 @@ var DexService = class {
|
|
|
35044
34819
|
// src/moneyMarket/errors.ts
|
|
35045
34820
|
var mmInvariant = createInvariant("moneyMarket");
|
|
35046
34821
|
var ORCHESTRATION_CODES2 = /* @__PURE__ */ new Set([
|
|
34822
|
+
"USER_REJECTED",
|
|
35047
34823
|
"VALIDATION_FAILED",
|
|
35048
34824
|
"INTENT_CREATION_FAILED",
|
|
35049
34825
|
"TX_VERIFICATION_FAILED",
|
|
@@ -35054,6 +34830,7 @@ var ORCHESTRATION_CODES2 = /* @__PURE__ */ new Set([
|
|
|
35054
34830
|
"UNKNOWN"
|
|
35055
34831
|
]);
|
|
35056
34832
|
var MONEY_MARKET_CODES = /* @__PURE__ */ new Set([
|
|
34833
|
+
"USER_REJECTED",
|
|
35057
34834
|
"VALIDATION_FAILED",
|
|
35058
34835
|
"INTENT_CREATION_FAILED",
|
|
35059
34836
|
"TX_VERIFICATION_FAILED",
|
|
@@ -38810,11 +38587,7 @@ var PartnerFeeClaimService = class {
|
|
|
38810
38587
|
} catch (error) {
|
|
38811
38588
|
return {
|
|
38812
38589
|
ok: false,
|
|
38813
|
-
error:
|
|
38814
|
-
feature: "partner",
|
|
38815
|
-
cause: error,
|
|
38816
|
-
context: { phase: "approve" }
|
|
38817
|
-
})
|
|
38590
|
+
error: approveFailed("partner", error)
|
|
38818
38591
|
};
|
|
38819
38592
|
}
|
|
38820
38593
|
}
|
|
@@ -39330,6 +39103,7 @@ var RecoveryService = class {
|
|
|
39330
39103
|
// src/leverageYield/errors.ts
|
|
39331
39104
|
var leverageYieldInvariant = createInvariant("leverageYield");
|
|
39332
39105
|
var LEVERAGE_YIELD_CODES = /* @__PURE__ */ new Set([
|
|
39106
|
+
"USER_REJECTED",
|
|
39333
39107
|
"VALIDATION_FAILED",
|
|
39334
39108
|
"INTENT_CREATION_FAILED",
|
|
39335
39109
|
"APPROVE_FAILED",
|
|
@@ -39349,6 +39123,7 @@ var LEVERAGE_YIELD_POST_EXECUTION_CODES = /* @__PURE__ */ new Set([
|
|
|
39349
39123
|
"UNKNOWN"
|
|
39350
39124
|
]);
|
|
39351
39125
|
var LEVERAGE_YIELD_SWAP_CODES = /* @__PURE__ */ new Set([
|
|
39126
|
+
"USER_REJECTED",
|
|
39352
39127
|
"VALIDATION_FAILED",
|
|
39353
39128
|
"INTENT_CREATION_FAILED",
|
|
39354
39129
|
"TX_VERIFICATION_FAILED",
|
|
@@ -39425,7 +39200,7 @@ var LeverageYieldService = class {
|
|
|
39425
39200
|
}
|
|
39426
39201
|
/** Looks up a vault by its `name` field. Returns `undefined` when not registered. */
|
|
39427
39202
|
getVault(name) {
|
|
39428
|
-
return this.listVaults().find((
|
|
39203
|
+
return this.listVaults().find((v4) => v4.name === name);
|
|
39429
39204
|
}
|
|
39430
39205
|
/**
|
|
39431
39206
|
* Looks up a registered vault by its on-chain proxy address (case-insensitive).
|
|
@@ -39433,7 +39208,7 @@ var LeverageYieldService = class {
|
|
|
39433
39208
|
*/
|
|
39434
39209
|
getVaultByAddress(address) {
|
|
39435
39210
|
const normalized = address.toLowerCase();
|
|
39436
|
-
return this.listVaults().find((
|
|
39211
|
+
return this.listVaults().find((v4) => v4.vault.toLowerCase() === normalized);
|
|
39437
39212
|
}
|
|
39438
39213
|
/**
|
|
39439
39214
|
* Resolves the intent `deadline`: returns the caller-supplied value verbatim, otherwise
|
|
@@ -40318,6 +40093,7 @@ var Sodax = class {
|
|
|
40318
40093
|
// src/partner/errors.ts
|
|
40319
40094
|
var partnerInvariant = createInvariant("partner");
|
|
40320
40095
|
var PARTNER_CODES = /* @__PURE__ */ new Set([
|
|
40096
|
+
"USER_REJECTED",
|
|
40321
40097
|
"VALIDATION_FAILED",
|
|
40322
40098
|
"LOOKUP_FAILED",
|
|
40323
40099
|
"APPROVE_FAILED",
|
|
@@ -40343,4 +40119,4 @@ var isPartnerError = isCodeMember(PARTNER_CODES);
|
|
|
40343
40119
|
(*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
40344
40120
|
*/
|
|
40345
40121
|
|
|
40346
|
-
export { ALLOWANCE_CHECK_CODES, APPROVE_CODES, AssetService, BITCOIN_CHAIN_KEYS, BITCOIN_CHAIN_KEYS_SET, BTC_WALLET_ADDRESS_TYPES, BackendApiService, BalnSwapService, BigIntToHex, BigNumberZeroDecimal, BitcoinSpokeService, BnUSDMigrationService, BridgeService, CHAIN_KEYS, CHAIN_LOGO_BASE_URL, CONFIG_VERSION, CREATE_INTENT_CODES, ChainKeys, ChainTypeArr, ClService, ConfigService, CustomSorobanServer, CustomStellarAccount, DEFAULT_BACKEND_API_ENDPOINT, DEFAULT_BACKEND_API_HEADERS, DEFAULT_BACKEND_API_TIMEOUT, DEFAULT_DEADLINE_OFFSET, DEFAULT_MAX_RETRY, DEFAULT_RELAYER_API_ENDPOINT, DEFAULT_RELAY_TX_TIMEOUT, DEFAULT_RETRY_DELAY_MS, DexService, EVM_CHAIN_ID_TO_KEY, EVM_CHAIN_KEYS, EVM_CHAIN_KEYS_SET, EVM_SPOKE_ONLY_CHAIN_KEYS, EVM_SPOKE_ONLY_CHAIN_KEYS_SET, Erc20Service, Erc4626Service, EvmAssetManagerService, EvmHubProvider, EvmSolverService, EvmSpokeService, EvmVaultTokenService, FEE_PERCENTAGE_SCALE, GAS_ESTIMATION_CODES, HALF_RAY, HALF_WAD, HUB_CHAIN_KEY, HookKind, HookService, HttpRelayError, HubVaultSymbols, ICON_CHAIN_KEYS, ICON_CHAIN_KEYS_SET, ICON_TX_RESULT_WAIT_MAX_RETRY, INJECTIVE_CHAIN_KEYS, INJECTIVE_CHAIN_KEYS_SET, INTENT_CHAIN_IDS, IconSpokeService, IcxMigrationService, Injective20Token, InjectiveSpokeService, IntentCreatedEventAbi, IntentDataService, IntentDataType, IntentFilledEventAbi, IntentRelayChainIdToChainKey, IntentsAbi, LOOKUP_CODES, LTV_PRECISION, LendingPoolService, LeverageYieldService, LockupMultiplier, LockupPeriod, LsodaSymbols, LsodaTokens, MAX_UINT256, MigrationService, MintPositionEventAbi, MoneyMarketDataService, MoneyMarketService, NEAR_CHAIN_KEYS, NEAR_CHAIN_KEYS_SET, NEAR_DEFAULT_GAS, NEAR_STORAGE_DEPOSIT, NearSpokeService, PartnerFeeClaimService, PartnerService, Permit2Service, ProtocolIntentsAbi, RAY, RAY_DECIMALS, RELAY_ERROR_CODES, RadfiApiError, RadfiProvider, RecoveryService, RelayChainIdMap, SECONDS_PER_YEAR, SODAX_ERROR_CODES, SODAX_FEATURES, SOLANA_CHAIN_KEYS, SOLANA_CHAIN_KEYS_SET, SONIC_CHAIN_KEYS, SONIC_CHAIN_KEYS_SET, STACKS_CHAIN_KEYS, STACKS_CHAIN_KEYS_SET, STELLAR_CHAIN_KEYS, STELLAR_CHAIN_KEYS_SET, SUI_CHAIN_KEYS, SUI_CHAIN_KEYS_SET, SodaTokens, Sodax, SodaxError, SolanaSpokeService, SolverApiService, SolverIntentErrorCode, SolverIntentStatusCode, SonicSpokeService, SpokeService, StacksSpokeService, StakingLogic, StakingService, StatATokenAddresses, StellarSpokeService, SuiSpokeService, SupportedMigrationTokens, SwapService, SwapsApiService, USD_DECIMALS, UiPoolDataProviderService, VAULT_TOKEN_DECIMALS, WAD, WAD_RAY_RATIO, WEI_DECIMALS, adjustAmountByFee, allowanceCheckFailed, apiConfig, approveFailed, arbitrumSupportedTokens, assetManagerAbi, avalancheSupportedTokens, balnSwapAbi, baseChainInfo, baseSupportedTokens, binomialApproximatedRayPow, bitcoinSupportedTokens, bnUSDLegacySpokeChainIds, bnUSDLegacyTokens, bridgeConfig, bridgeInvariant, bscSupportedTokens, calcOpReturnOutputVbytes, calculateAllReserveIncentives, calculateAllUserIncentives, calculateAvailableBorrowsMarketReferenceCurrency, calculateCompoundedInterest, calculateCompoundedRate, calculateFeeAmount, calculateHealthFactorFromBalances, calculateHealthFactorFromBalancesBigUnits, calculateLinearInterest, calculatePercentageFeeAmount, clPoolAbi, clPoolManagerAbi, clPositionManagerAbi, clQuoterAbi, clRouterAbi, clTickLensAbi, concentratedLiquidityConfig, connectionAbi, consoleLogger, convertTransactionInstructionToRaw, createInvariant, deepMerge, defaultHookAbi, detectBitcoinAddressType, dexConfig, dexInvariant, dexPools, encodeAddress, encodeBtcPayloadToBytes, encodeContractCalls, erc20Abi, erc4626Abi, estimateBitcoinTxSize, ethereumSupportedTokens, executionFailed, formatBasisPoints, formatEModeCategory, formatEModes, formatPercentage, formatReserve, formatReserveUSD, formatReserves, formatReservesAndIncentives, formatUserSummary, formatUserSummaryAndIncentives, gasEstimationFailed, getAllLegacybnUSDTokens, getAndFormatReserveEModes, getAssetManagerIdl, getAssetManagerProgram, getChainKeyFromRelayChainId, getChainType, getCompoundedBalance, getConcentratedLiquidityConfig, getConnectionIdl, getConnectionProgram, getEvmChainKeyByChainId, getEvmViemChain, getIconAddressBytes, getIntentRelayChainId, getLinearBalance, getMarketReferenceCurrencyAndUsdBalance, getPacket, getProvider, getRandomBytes, getReserveNormalizedIncome, getReservesEModes, getSolanaAddressBytes, getSolverConfig, getSpokeHook, getSpokeHooks, getStagingSolverTokens, getSupportedSolverTokens, getTransactionPackets, getbnUSDToken, hexToBigInt, hexToSolanaAddress, hubConfig, hyper, hyperevmSupportedTokens, iconSupportedTokens, injectiveSupportedTokens, intentCreationFailed, isBalnMigrateParams, isBitcoinChainKey, isBitcoinChainKeyType, isBitcoinWalletProviderType, isBridgeAllowanceCheckError, isBridgeApproveError, isBridgeCreateIntentError, isBridgeError, isBridgeLookupError, isBridgeOrchestrationError, isCodeMember, isDexError, isEvmChainKey, isEvmChainKeyType, isEvmSpokeChainConfig, isEvmSpokeOnlyChainKey, isEvmSpokeOnlyChainKeyType, isEvmWalletProviderType, isFeatureError, isHookSupportedToken, isHubChainKey, isHubChainKeyType, isIconAddress, isIconChainKey, isIconChainKeyType, isIcxCreateRevertMigrationParams, isIcxMigrateParams, isInjectiveChainKey, isInjectiveChainKeyType, isJsonRpcPayloadResponse, isLegacybnUSDChainId, isLegacybnUSDToken, isLeverageYieldAllowanceCheckError, isLeverageYieldApproveError, isLeverageYieldCreateIntentError, isLeverageYieldError, isLeverageYieldLookupError, isLeverageYieldPostExecutionError, isLeverageYieldSwapError, isMigrateOrchestrationError, isMigrationAllowanceCheckError, isMigrationApproveError, isMigrationCreateIntentError, isMigrationError, isMigrationLookupError, isMoneyMarketAllowanceCheckError, isMoneyMarketApproveError, isMoneyMarketCreateIntentError, isMoneyMarketError, isMoneyMarketGasEstimationError, isMoneyMarketOrchestrationError, isNativeToken, isNearChainKey, isNearChainKeyType, isNewbnUSDChainId, isNewbnUSDToken, isOptionalBitcoinWalletProviderType, isOptionalEvmWalletProviderType, isOptionalStellarWalletProviderType, isPartnerError, isPartnerFeeAmount, isPartnerFeePercentage, isPostExecutionError, isRawDestinationParams, isRecoveryError, isResponseAddressType, isResponseSigningType, isRevertMigrationOrchestrationError, isSodaxError, isSolanaChainKey, isSolanaChainKeyType, isSolanaNativeToken, isSonicChainKey, isSonicChainKeyType, isSpokeApproveParamsEvmSpoke, isSpokeApproveParamsHub, isSpokeApproveParamsStellar, isSpokeChainKey, isSpokeIsAllowanceValidParamsEvmSpoke, isSpokeIsAllowanceValidParamsHub, isSpokeIsAllowanceValidParamsStellar, isStacksChainKey, isStacksChainKeyType, isStakeOrchestrationError, isStakingAllowanceCheckError, isStakingApproveError, isStakingCreateIntentError, isStakingError, isStakingInfoFetchError, isStakingOrchestrationError, isStellarChainKey, isStellarChainKeyType, isStellarWalletProviderType, isSuiChainKey, isSuiChainKeyType, isSupportedBitcoinAddressType, isSwapCreateIntentError, isSwapError, isSwapSupportedToken, isUndefinedOrValidWalletProviderForChainKey, isUnifiedBnUSDMigrateParams, isValidWalletProviderForChainKey, kaiaSupportedTokens, leverageYieldConfig, leverageYieldInvariant, leverageYieldVaults, lightlinkSupportedTokens, lookupFailed, mapRelayFailure, mergeSodaxConfig, messageOf, migrationInvariant, mintPositionParamsAbi, mmInvariant, modifyLiquidityParamsAbi, moneyMarketConfig, moneyMarketReserveAssets, moneyMarketSupportedTokens, nativeToUSD, nearSupportedTokens, newbnUSDSpokeChainIds, noopAnalytics, normalize, normalizeBN, normalizePsbtToBase64, normalizeSignatureToBase64, normalizedToUsd, optimismSupportedTokens, pancakeSwapInfinityDefaultHookAbi, pancakeSwapInfinityPoolManagerAbi, pancakeSwapInfinityPositionManagerAbi, parseToStroops, parseTokenArrayFromJson, partnerInvariant, permit2Abi, polygonSupportedTokens, poolAbi, poolKeyAbi, randomUint256, rayDiv, rayMul, rayPow, rayToWad, recoveryInvariant, redbellySupportedTokens, relayConfig, relayTxAndWaitPacket, requestAddress, requestJsonRpc, requestSigning, resolveAnalytics, resolveLogger, retry, reverseEncodeAddress, serializeAddressData, silentLogger, sleep, sodaxConfig, sodaxInvariant, solanaSupportedTokens, solverConfig, sonicSupportedTokens, sonicWalletFactoryAbi, spokeAssetManagerAbi, spokeChainConfig, spokeChainKeysSet, spokeHooks, stacksSupportedTokens, stagingSwapSupportedTokens, stakedSodaAbi, stakingInvariant, stakingRouterAbi, stataTokenFactoryAbi, stellarSupportedTokens, submitTransaction, suiSupportedTokens, supportedSpokeChains, supportedTokensByChain, swapExactInSingleParamsAbi, swapInvariant, swapSupportedTokens, swapsConfig, uiPoolDataAbi, universalRouterAbi, unknownFailed, usesBip322MessageSigning, valueToBigNumber, valueToZDBigNumber, variableDebtTokenAbi, vaultTokenAbi, verifyFailed, wadToRay, waitForStacksTransaction, waitForTransactionReceipt, waitUntilIntentExecuted, walletFactoryAbi, wrappedSonicAbi };
|
|
40122
|
+
export { ALLOWANCE_CHECK_CODES, APPROVE_CODES, AssetService, BITCOIN_CHAIN_KEYS, BITCOIN_CHAIN_KEYS_SET, BTC_WALLET_ADDRESS_TYPES, BackendApiService, BalnSwapService, BigIntToHex, BigNumberZeroDecimal, BitcoinSpokeService, BnUSDMigrationService, BridgeService, CHAIN_KEYS, CHAIN_LOGO_BASE_URL, CONFIG_VERSION, CREATE_INTENT_CODES, ChainKeys, ChainTypeArr, ClService, ConfigService, CustomSorobanServer, CustomStellarAccount, DEFAULT_BACKEND_API_ENDPOINT, DEFAULT_BACKEND_API_HEADERS, DEFAULT_BACKEND_API_TIMEOUT, DEFAULT_DEADLINE_OFFSET, DEFAULT_MAX_RETRY, DEFAULT_RELAYER_API_ENDPOINT, DEFAULT_RELAY_TX_TIMEOUT, DEFAULT_RETRY_DELAY_MS, DexService, EVM_CHAIN_ID_TO_KEY, EVM_CHAIN_KEYS, EVM_CHAIN_KEYS_SET, EVM_SPOKE_ONLY_CHAIN_KEYS, EVM_SPOKE_ONLY_CHAIN_KEYS_SET, Erc20Service, Erc4626Service, EvmAssetManagerService, EvmHubProvider, EvmSolverService, EvmSpokeService, EvmVaultTokenService, FEE_PERCENTAGE_SCALE, GAS_ESTIMATION_CODES, HALF_RAY, HALF_WAD, HUB_CHAIN_KEY, HookKind, HookService, HttpRelayError, HubVaultSymbols, ICON_CHAIN_KEYS, ICON_CHAIN_KEYS_SET, ICON_TX_RESULT_WAIT_MAX_RETRY, INJECTIVE_CHAIN_KEYS, INJECTIVE_CHAIN_KEYS_SET, INTENT_CHAIN_IDS, IconSpokeService, IcxMigrationService, Injective20Token, InjectiveSpokeService, IntentCreatedEventAbi, IntentDataService, IntentDataType, IntentFilledEventAbi, IntentRelayChainIdToChainKey, IntentsAbi, LOOKUP_CODES, LTV_PRECISION, LendingPoolService, LeverageYieldService, LockupMultiplier, LockupPeriod, LsodaSymbols, LsodaTokens, MAX_UINT256, MigrationService, MintPositionEventAbi, MoneyMarketDataService, MoneyMarketService, NEAR_CHAIN_KEYS, NEAR_CHAIN_KEYS_SET, NEAR_DEFAULT_GAS, NEAR_STORAGE_DEPOSIT, NearSpokeService, PartnerFeeClaimService, PartnerService, Permit2Service, ProtocolIntentsAbi, RAY, RAY_DECIMALS, RELAY_ERROR_CODES, RadfiApiError, RadfiProvider, RecoveryService, RelayChainIdMap, SECONDS_PER_YEAR, SODAX_ERROR_CODES, SODAX_FEATURES, SOLANA_CHAIN_KEYS, SOLANA_CHAIN_KEYS_SET, SONIC_CHAIN_KEYS, SONIC_CHAIN_KEYS_SET, STACKS_CHAIN_KEYS, STACKS_CHAIN_KEYS_SET, STELLAR_CHAIN_KEYS, STELLAR_CHAIN_KEYS_SET, SUI_CHAIN_KEYS, SUI_CHAIN_KEYS_SET, SodaTokens, Sodax, SodaxError, SolanaSpokeService, SolverApiService, SolverIntentErrorCode, SolverIntentStatusCode, SonicSpokeService, SpokeService, StacksSpokeService, StakingLogic, StakingService, StatATokenAddresses, StellarSpokeService, SuiSpokeService, SupportedMigrationTokens, SwapService, SwapsApiService, USD_DECIMALS, UiPoolDataProviderService, VAULT_TOKEN_DECIMALS, WAD, WAD_RAY_RATIO, WEI_DECIMALS, adjustAmountByFee, allowanceCheckFailed, apiConfig, approveFailed, arbitrumSupportedTokens, assetManagerAbi, avalancheSupportedTokens, balnSwapAbi, baseChainInfo, baseSupportedTokens, binomialApproximatedRayPow, bitcoinSupportedTokens, bnUSDLegacySpokeChainIds, bnUSDLegacyTokens, bridgeConfig, bridgeInvariant, bscSupportedTokens, calcOpReturnOutputVbytes, calculateAllReserveIncentives, calculateAllUserIncentives, calculateAvailableBorrowsMarketReferenceCurrency, calculateCompoundedInterest, calculateCompoundedRate, calculateFeeAmount, calculateHealthFactorFromBalances, calculateHealthFactorFromBalancesBigUnits, calculateLinearInterest, calculatePercentageFeeAmount, clPoolAbi, clPoolManagerAbi, clPositionManagerAbi, clQuoterAbi, clRouterAbi, clTickLensAbi, concentratedLiquidityConfig, connectionAbi, consoleLogger, convertTransactionInstructionToRaw, createInvariant, deepMerge, defaultHookAbi, detectBitcoinAddressType, dexConfig, dexInvariant, dexPools, encodeAddress, encodeBtcPayloadToBytes, encodeContractCalls, erc20Abi, erc4626Abi, estimateBitcoinTxSize, ethereumSupportedTokens, executionFailed, formatBasisPoints, formatEModeCategory, formatEModes, formatPercentage, formatReserve, formatReserveUSD, formatReserves, formatReservesAndIncentives, formatUserSummary, formatUserSummaryAndIncentives, gasEstimationFailed, getAllLegacybnUSDTokens, getAndFormatReserveEModes, getAssetManagerIdl, getAssetManagerProgram, getChainKeyFromRelayChainId, getChainType, getCompoundedBalance, getConcentratedLiquidityConfig, getConnectionIdl, getConnectionProgram, getEvmChainKeyByChainId, getEvmViemChain, getIconAddressBytes, getIntentRelayChainId, getLinearBalance, getMarketReferenceCurrencyAndUsdBalance, getPacket, getProvider, getRandomBytes, getReserveNormalizedIncome, getReservesEModes, getSolanaAddressBytes, getSolverConfig, getSpokeHook, getSpokeHooks, getStagingSolverTokens, getSupportedSolverTokens, getTransactionPackets, getbnUSDToken, hederaSupportedTokens, hexToBigInt, hexToSolanaAddress, hubConfig, hyper, hyperevmSupportedTokens, iconSupportedTokens, injectiveSupportedTokens, intentCreationFailed, isBalnMigrateParams, isBitcoinChainKey, isBitcoinChainKeyType, isBitcoinWalletProviderType, isBridgeAllowanceCheckError, isBridgeApproveError, isBridgeCreateIntentError, isBridgeError, isBridgeLookupError, isBridgeOrchestrationError, isCodeMember, isDexApproveError, isDexCreateIntentError, isDexError, isEvmChainKey, isEvmChainKeyType, isEvmSpokeChainConfig, isEvmSpokeOnlyChainKey, isEvmSpokeOnlyChainKeyType, isEvmWalletProviderType, isFeatureError, isHookSupportedToken, isHubChainKey, isHubChainKeyType, isIconAddress, isIconChainKey, isIconChainKeyType, isIcxCreateRevertMigrationParams, isIcxMigrateParams, isInjectiveChainKey, isInjectiveChainKeyType, isJsonRpcPayloadResponse, isLegacybnUSDChainId, isLegacybnUSDToken, isLeverageYieldAllowanceCheckError, isLeverageYieldApproveError, isLeverageYieldCreateIntentError, isLeverageYieldError, isLeverageYieldLookupError, isLeverageYieldPostExecutionError, isLeverageYieldSwapError, isMigrateOrchestrationError, isMigrationAllowanceCheckError, isMigrationApproveError, isMigrationCreateIntentError, isMigrationError, isMigrationLookupError, isMoneyMarketAllowanceCheckError, isMoneyMarketApproveError, isMoneyMarketCreateIntentError, isMoneyMarketError, isMoneyMarketGasEstimationError, isMoneyMarketOrchestrationError, isNativeToken, isNearChainKey, isNearChainKeyType, isNewbnUSDChainId, isNewbnUSDToken, isOptionalBitcoinWalletProviderType, isOptionalEvmWalletProviderType, isOptionalStellarWalletProviderType, isPartnerError, isPartnerFeeAmount, isPartnerFeePercentage, isPostExecutionError, isRawDestinationParams, isRecoveryError, isResponseAddressType, isResponseSigningType, isRevertMigrationOrchestrationError, isSodaxError, isSolanaChainKey, isSolanaChainKeyType, isSolanaNativeToken, isSonicChainKey, isSonicChainKeyType, isSpokeApproveParamsEvmSpoke, isSpokeApproveParamsHub, isSpokeApproveParamsStellar, isSpokeChainKey, isSpokeIsAllowanceValidParamsEvmSpoke, isSpokeIsAllowanceValidParamsHub, isSpokeIsAllowanceValidParamsStellar, isStacksChainKey, isStacksChainKeyType, isStakeOrchestrationError, isStakingAllowanceCheckError, isStakingApproveError, isStakingCreateIntentError, isStakingError, isStakingInfoFetchError, isStakingOrchestrationError, isStellarChainKey, isStellarChainKeyType, isStellarWalletProviderType, isSuiChainKey, isSuiChainKeyType, isSupportedBitcoinAddressType, isSwapCreateIntentError, isSwapError, isSwapSupportedToken, isUndefinedOrValidWalletProviderForChainKey, isUnifiedBnUSDMigrateParams, isValidWalletProviderForChainKey, kaiaSupportedTokens, leverageYieldConfig, leverageYieldInvariant, leverageYieldVaults, lightlinkSupportedTokens, lookupFailed, mapRelayFailure, mergeSodaxConfig, messageOf, migrationInvariant, mintPositionParamsAbi, mmInvariant, modifyLiquidityParamsAbi, moneyMarketConfig, moneyMarketReserveAssets, moneyMarketSupportedTokens, nativeToUSD, nearSupportedTokens, newbnUSDSpokeChainIds, noopAnalytics, normalize, normalizeBN, normalizePsbtToBase64, normalizeSignatureToBase64, normalizedToUsd, optimismSupportedTokens, pancakeSwapInfinityDefaultHookAbi, pancakeSwapInfinityPoolManagerAbi, pancakeSwapInfinityPositionManagerAbi, parseToStroops, parseTokenArrayFromJson, partnerInvariant, permit2Abi, polygonSupportedTokens, poolAbi, poolKeyAbi, randomUint256, rayDiv, rayMul, rayPow, rayToWad, recoveryInvariant, redbellySupportedTokens, relayConfig, relayTxAndWaitPacket, requestAddress, requestJsonRpc, requestSigning, resolveAnalytics, resolveLogger, retry, reverseEncodeAddress, serializeAddressData, silentLogger, sleep, sodaxConfig, sodaxInvariant, solanaSupportedTokens, solverConfig, sonicSupportedTokens, sonicWalletFactoryAbi, spokeAssetManagerAbi, spokeChainConfig, spokeChainKeysSet, spokeHooks, stacksSupportedTokens, stagingSwapSupportedTokens, stakedSodaAbi, stakingInvariant, stakingRouterAbi, stataTokenFactoryAbi, stellarSupportedTokens, submitTransaction, suiSupportedTokens, supportedSpokeChains, supportedTokensByChain, swapExactInSingleParamsAbi, swapInvariant, swapSupportedTokens, swapsConfig, uiPoolDataAbi, universalRouterAbi, unknownFailed, usesBip322MessageSigning, valueToBigNumber, valueToZDBigNumber, variableDebtTokenAbi, vaultTokenAbi, verifyFailed, wadToRay, waitForStacksTransaction, waitForTransactionReceipt, waitUntilIntentExecuted, walletFactoryAbi, wrappedSonicAbi };
|