@sodax/sdk 2.2.0-rc.2 → 2.2.0-rc.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1085 -219
- package/dist/index.d.cts +374 -7
- package/dist/index.d.ts +374 -7
- package/dist/index.mjs +1083 -223
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var viem = require('viem');
|
|
4
|
+
var bitcoinjsLib = require('bitcoinjs-lib');
|
|
4
5
|
var bcs = require('@mysten/sui/bcs');
|
|
5
6
|
var web3_js = require('@solana/web3.js');
|
|
6
7
|
var stellarSdk = require('@stellar/stellar-sdk');
|
|
7
8
|
var core = require('@sodax/libs/stacks/core');
|
|
8
9
|
var chains = require('viem/chains');
|
|
9
10
|
var rlp = require('rlp');
|
|
10
|
-
var bitcoinjsLib = require('bitcoinjs-lib');
|
|
11
11
|
var ecc = require('@bitcoinerlab/secp256k1');
|
|
12
12
|
var infinitySdk = require('@pancakeswap/infinity-sdk');
|
|
13
13
|
var transactions = require('@mysten/sui/transactions');
|
|
@@ -122,8 +122,8 @@ function serializeCause(cause, depth) {
|
|
|
122
122
|
}
|
|
123
123
|
function sanitizeContext(value, depth) {
|
|
124
124
|
const out = {};
|
|
125
|
-
for (const [key,
|
|
126
|
-
out[key] = sanitizeValue(
|
|
125
|
+
for (const [key, v12] of Object.entries(value)) {
|
|
126
|
+
out[key] = sanitizeValue(v12, depth + 1);
|
|
127
127
|
}
|
|
128
128
|
return out;
|
|
129
129
|
}
|
|
@@ -134,13 +134,13 @@ function sanitizeValue(value, depth) {
|
|
|
134
134
|
if (t === "bigint") return value.toString();
|
|
135
135
|
if (t === "string" || t === "number" || t === "boolean") return value;
|
|
136
136
|
if (t === "function" || t === "symbol") return safeString(value);
|
|
137
|
-
if (Array.isArray(value)) return value.map((
|
|
137
|
+
if (Array.isArray(value)) return value.map((v12) => sanitizeValue(v12, depth + 1));
|
|
138
138
|
if (value instanceof Date) return value.toISOString();
|
|
139
139
|
if (value instanceof Map) {
|
|
140
|
-
return Array.from(value.entries()).map(([k,
|
|
140
|
+
return Array.from(value.entries()).map(([k, v12]) => [sanitizeValue(k, depth + 1), sanitizeValue(v12, depth + 1)]);
|
|
141
141
|
}
|
|
142
142
|
if (value instanceof Set) {
|
|
143
|
-
return Array.from(value.values()).map((
|
|
143
|
+
return Array.from(value.values()).map((v12) => sanitizeValue(v12, depth + 1));
|
|
144
144
|
}
|
|
145
145
|
if (value instanceof Error) return { name: value.name, message: value.message };
|
|
146
146
|
if (t === "object") {
|
|
@@ -152,9 +152,9 @@ function sanitizeValue(value, depth) {
|
|
|
152
152
|
}
|
|
153
153
|
return safeString(value);
|
|
154
154
|
}
|
|
155
|
-
function safeString(
|
|
155
|
+
function safeString(v12) {
|
|
156
156
|
try {
|
|
157
|
-
return String(
|
|
157
|
+
return String(v12);
|
|
158
158
|
} catch {
|
|
159
159
|
return "[unserializable]";
|
|
160
160
|
}
|
|
@@ -4892,7 +4892,7 @@ function isValidWalletProviderForChainKey(chainKey, walletProvider) {
|
|
|
4892
4892
|
}
|
|
4893
4893
|
|
|
4894
4894
|
// ../types/dist/index.js
|
|
4895
|
-
var CONFIG_VERSION =
|
|
4895
|
+
var CONFIG_VERSION = 233;
|
|
4896
4896
|
|
|
4897
4897
|
// src/shared/utils/resolveTimeoutMs.ts
|
|
4898
4898
|
function resolveTimeoutMs(timeout, fallbackMs) {
|
|
@@ -4905,6 +4905,33 @@ function isEvmSpokeChainConfig(value) {
|
|
|
4905
4905
|
function isIconAddress(value) {
|
|
4906
4906
|
return typeof value === "string" && /^hx[a-f0-9]{40}$|^cx[a-f0-9]{40}$/.test(value);
|
|
4907
4907
|
}
|
|
4908
|
+
var NEAR_ACCOUNT_ID_REGEX = /^(([a-z\d]+[-_])*[a-z\d]+\.)*([a-z\d]+[-_])*[a-z\d]+$/;
|
|
4909
|
+
function isValidNearAccountId(accountId) {
|
|
4910
|
+
return accountId.length >= 2 && accountId.length <= 64 && NEAR_ACCOUNT_ID_REGEX.test(accountId);
|
|
4911
|
+
}
|
|
4912
|
+
var INJECTIVE_ADDRESS_REGEX = /^inj1(?:[02-9ac-hj-np-z]{38}|[02-9ac-hj-np-z]{58})$/;
|
|
4913
|
+
var BECH32_CHARSET = "qpzry9x8gf2tvdw0s3jn54khce6mua7l";
|
|
4914
|
+
var BECH32_GENERATOR = [996825010, 642813549, 513874426, 1027748829, 705979059];
|
|
4915
|
+
function bech32ChecksumVerifies(hrp, dataChars) {
|
|
4916
|
+
const values = [
|
|
4917
|
+
...[...hrp].map((c) => c.charCodeAt(0) >>> 5),
|
|
4918
|
+
0,
|
|
4919
|
+
...[...hrp].map((c) => c.charCodeAt(0) & 31),
|
|
4920
|
+
...[...dataChars].map((c) => BECH32_CHARSET.indexOf(c))
|
|
4921
|
+
];
|
|
4922
|
+
let chk = 1;
|
|
4923
|
+
for (const value of values) {
|
|
4924
|
+
const top = chk >>> 25;
|
|
4925
|
+
chk = (chk & 33554431) << 5 ^ value;
|
|
4926
|
+
for (let i = 0; i < 5; i++) {
|
|
4927
|
+
if (top >>> i & 1) chk ^= BECH32_GENERATOR[i];
|
|
4928
|
+
}
|
|
4929
|
+
}
|
|
4930
|
+
return chk === 1;
|
|
4931
|
+
}
|
|
4932
|
+
function isValidInjectiveAddress(address) {
|
|
4933
|
+
return INJECTIVE_ADDRESS_REGEX.test(address) && bech32ChecksumVerifies("inj", address.slice(4));
|
|
4934
|
+
}
|
|
4908
4935
|
function isResponseAddressType(value) {
|
|
4909
4936
|
return typeof value === "object" && value !== null && "type" in value && "payload" in value && value.type === "RESPONSE_ADDRESS" && isIconAddress(value.payload);
|
|
4910
4937
|
}
|
|
@@ -5012,6 +5039,81 @@ function isUndefinedOrValidWalletProviderForChainKey(chainKey, walletProvider) {
|
|
|
5012
5039
|
function isOptionalBitcoinWalletProviderType(walletProvider) {
|
|
5013
5040
|
return walletProvider === void 0 || isBitcoinWalletProviderType(walletProvider);
|
|
5014
5041
|
}
|
|
5042
|
+
var BITCOIN_FEE_SAFETY_VBYTES = 20;
|
|
5043
|
+
function calcOpReturnOutputVbytes(payloadByteLength) {
|
|
5044
|
+
let scriptSize;
|
|
5045
|
+
if (payloadByteLength <= 75) {
|
|
5046
|
+
scriptSize = 3 + payloadByteLength;
|
|
5047
|
+
} else if (payloadByteLength <= 255) {
|
|
5048
|
+
scriptSize = 4 + payloadByteLength;
|
|
5049
|
+
} else {
|
|
5050
|
+
scriptSize = 5 + payloadByteLength;
|
|
5051
|
+
}
|
|
5052
|
+
const scriptLenVarint = scriptSize <= 252 ? 1 : 3;
|
|
5053
|
+
return 8 + scriptLenVarint + scriptSize;
|
|
5054
|
+
}
|
|
5055
|
+
function estimateBitcoinTxSize(inputCount, outputCount, addressType, opReturnOutputVbytes = 44) {
|
|
5056
|
+
let inputWeight;
|
|
5057
|
+
switch (addressType) {
|
|
5058
|
+
case "P2PKH":
|
|
5059
|
+
inputWeight = 148;
|
|
5060
|
+
break;
|
|
5061
|
+
case "P2SH":
|
|
5062
|
+
inputWeight = 91;
|
|
5063
|
+
break;
|
|
5064
|
+
case "P2TR":
|
|
5065
|
+
inputWeight = 58;
|
|
5066
|
+
break;
|
|
5067
|
+
default:
|
|
5068
|
+
inputWeight = 68;
|
|
5069
|
+
break;
|
|
5070
|
+
}
|
|
5071
|
+
return Math.ceil(
|
|
5072
|
+
10.5 + opReturnOutputVbytes + BITCOIN_FEE_SAFETY_VBYTES + inputCount * inputWeight + outputCount * 31
|
|
5073
|
+
);
|
|
5074
|
+
}
|
|
5075
|
+
function encodeBtcPayloadToBytes(payload) {
|
|
5076
|
+
const isBase58Check = payload.address_type === "P2PKH" || payload.address_type === "P2SH";
|
|
5077
|
+
return JSON.stringify({
|
|
5078
|
+
src_address: isBase58Check ? payload.src_address : payload.src_address.toLowerCase(),
|
|
5079
|
+
data: payload.data.toLowerCase(),
|
|
5080
|
+
src_chain_id: payload.src_chain_id,
|
|
5081
|
+
dst_chain_id: payload.dst_chain_id,
|
|
5082
|
+
wallet_used: payload.wallet_used,
|
|
5083
|
+
timestamp: payload.timestamp,
|
|
5084
|
+
address_type: payload.address_type
|
|
5085
|
+
});
|
|
5086
|
+
}
|
|
5087
|
+
function isValidBitcoinAddress(address) {
|
|
5088
|
+
try {
|
|
5089
|
+
const { prefix: prefix2, version, data } = bitcoinjsLib.address.fromBech32(address);
|
|
5090
|
+
if (prefix2 !== "bc" && prefix2 !== "tb") return false;
|
|
5091
|
+
return version === 0 && (data.length === 20 || data.length === 32) || version === 1 && data.length === 32;
|
|
5092
|
+
} catch {
|
|
5093
|
+
}
|
|
5094
|
+
try {
|
|
5095
|
+
const { version } = bitcoinjsLib.address.fromBase58Check(address);
|
|
5096
|
+
return version === 0 || version === 5 || version === 111 || version === 196;
|
|
5097
|
+
} catch {
|
|
5098
|
+
return false;
|
|
5099
|
+
}
|
|
5100
|
+
}
|
|
5101
|
+
function canonicalizeBitcoinAddress(address) {
|
|
5102
|
+
try {
|
|
5103
|
+
bitcoinjsLib.address.fromBech32(address);
|
|
5104
|
+
return address.toLowerCase();
|
|
5105
|
+
} catch {
|
|
5106
|
+
return address;
|
|
5107
|
+
}
|
|
5108
|
+
}
|
|
5109
|
+
function normalizePsbtToBase64(signedPsbt) {
|
|
5110
|
+
const isHex2 = /^[0-9a-fA-F]+$/.test(signedPsbt);
|
|
5111
|
+
return isHex2 ? Buffer.from(signedPsbt, "hex").toString("base64") : signedPsbt;
|
|
5112
|
+
}
|
|
5113
|
+
function normalizeSignatureToBase64(signature) {
|
|
5114
|
+
const isHex2 = /^[0-9a-fA-F]+$/.test(signature);
|
|
5115
|
+
return isHex2 ? Buffer.from(signature, "hex").toString("base64") : signature;
|
|
5116
|
+
}
|
|
5015
5117
|
function isNativeBitcoinTransfer(config, chainKey, token) {
|
|
5016
5118
|
return isBitcoinChainKeyType(chainKey) && !!token && isNativeBitcoinToken(config.getChainConfig(chainKey), token.address);
|
|
5017
5119
|
}
|
|
@@ -5031,11 +5133,10 @@ async function retry(action, retryCount = DEFAULT_MAX_RETRY, delayMs = DEFAULT_R
|
|
|
5031
5133
|
throw new Error(`Retry exceeded MAX_RETRY_DEFAULT=${DEFAULT_MAX_RETRY}`);
|
|
5032
5134
|
}
|
|
5033
5135
|
function getRandomBytes(length) {
|
|
5034
|
-
|
|
5035
|
-
|
|
5036
|
-
array3[i] = Math.floor(Math.random() * 256);
|
|
5136
|
+
if (!globalThis.crypto?.getRandomValues) {
|
|
5137
|
+
throw new Error("Web Crypto (crypto.getRandomValues) is unavailable in this runtime");
|
|
5037
5138
|
}
|
|
5038
|
-
return
|
|
5139
|
+
return globalThis.crypto.getRandomValues(new Uint8Array(length));
|
|
5039
5140
|
}
|
|
5040
5141
|
function randomUint256() {
|
|
5041
5142
|
const bytes = getRandomBytes(32);
|
|
@@ -5084,6 +5185,7 @@ function encodeAddress(spokeChainId, address) {
|
|
|
5084
5185
|
const chainType = getChainType(spokeChainId);
|
|
5085
5186
|
switch (chainType) {
|
|
5086
5187
|
case "EVM":
|
|
5188
|
+
invariant(viem.isAddress(address), `Invalid EVM address: ${address}`);
|
|
5087
5189
|
return address;
|
|
5088
5190
|
case "ICON": {
|
|
5089
5191
|
invariant(isIconAddress(address), `Invalid ICON address: ${address}`);
|
|
@@ -5099,8 +5201,13 @@ function encodeAddress(spokeChainId, address) {
|
|
|
5099
5201
|
case "STACKS":
|
|
5100
5202
|
return `0x${core.serializeCV(core.Cl.principal(address))}`;
|
|
5101
5203
|
case "BITCOIN":
|
|
5204
|
+
invariant(isValidBitcoinAddress(address), `Invalid Bitcoin address: ${address}`);
|
|
5205
|
+
return viem.toHex(Buffer.from(canonicalizeBitcoinAddress(address), "utf-8"));
|
|
5102
5206
|
case "NEAR":
|
|
5207
|
+
invariant(isValidNearAccountId(address), `Invalid NEAR account id: ${address}`);
|
|
5208
|
+
return viem.toHex(Buffer.from(address, "utf-8"));
|
|
5103
5209
|
case "INJECTIVE":
|
|
5210
|
+
invariant(isValidInjectiveAddress(address), `Invalid Injective address: ${address}`);
|
|
5104
5211
|
return viem.toHex(Buffer.from(address, "utf-8"));
|
|
5105
5212
|
default: {
|
|
5106
5213
|
const exhaustiveCheck = chainType;
|
|
@@ -5108,6 +5215,16 @@ function encodeAddress(spokeChainId, address) {
|
|
|
5108
5215
|
}
|
|
5109
5216
|
}
|
|
5110
5217
|
}
|
|
5218
|
+
function encodeTokenIdentifier(spokeChainId, token) {
|
|
5219
|
+
switch (getChainType(spokeChainId)) {
|
|
5220
|
+
case "BITCOIN":
|
|
5221
|
+
case "NEAR":
|
|
5222
|
+
case "INJECTIVE":
|
|
5223
|
+
return viem.toHex(Buffer.from(token, "utf-8"));
|
|
5224
|
+
default:
|
|
5225
|
+
return encodeAddress(spokeChainId, token);
|
|
5226
|
+
}
|
|
5227
|
+
}
|
|
5111
5228
|
function reverseEncodeAddress(spokeChainId, encoded) {
|
|
5112
5229
|
const chainType = getChainType(spokeChainId);
|
|
5113
5230
|
switch (chainType) {
|
|
@@ -14807,6 +14924,11 @@ var ConfigService = class {
|
|
|
14807
14924
|
get bridgeUseBackendSubmitTx() {
|
|
14808
14925
|
return this.bridge.useBackendSubmitTx ?? this.sodax.bridgeOptions?.useBackendSubmitTx ?? true;
|
|
14809
14926
|
}
|
|
14927
|
+
// Opt-in (default OFF), unlike the swaps/bridge toggles above: the leverage-yield submit-tx
|
|
14928
|
+
// backend path is newer, so an omitted flag keeps the proven client-side relay.
|
|
14929
|
+
get leverageYieldUseBackendSubmitTx() {
|
|
14930
|
+
return this.leverageYield.useBackendSubmitTx ?? false;
|
|
14931
|
+
}
|
|
14810
14932
|
get dex() {
|
|
14811
14933
|
return this.sodax.dex;
|
|
14812
14934
|
}
|
|
@@ -14858,7 +14980,7 @@ function mergeSodaxConfig(base2, override) {
|
|
|
14858
14980
|
}
|
|
14859
14981
|
function encodeContractCalls(calls) {
|
|
14860
14982
|
return viem.encodeAbiParameters(viem.parseAbiParameters("(address,uint256,bytes)[]"), [
|
|
14861
|
-
calls.map((
|
|
14983
|
+
calls.map((v12) => [v12.address, v12.value, v12.data])
|
|
14862
14984
|
]);
|
|
14863
14985
|
}
|
|
14864
14986
|
async function waitForTransactionReceipt(hash, provider) {
|
|
@@ -15061,16 +15183,20 @@ var EvmVaultTokenService = class {
|
|
|
15061
15183
|
*/
|
|
15062
15184
|
static async deposit(vault, token, amount, walletProvider) {
|
|
15063
15185
|
const from = await walletProvider.getWalletAddress();
|
|
15064
|
-
return walletProvider.sendTransaction(
|
|
15065
|
-
|
|
15066
|
-
|
|
15067
|
-
|
|
15068
|
-
|
|
15069
|
-
|
|
15070
|
-
|
|
15071
|
-
|
|
15072
|
-
|
|
15073
|
-
|
|
15186
|
+
return walletProvider.sendTransaction(
|
|
15187
|
+
{
|
|
15188
|
+
from,
|
|
15189
|
+
to: vault,
|
|
15190
|
+
value: 0n,
|
|
15191
|
+
data: viem.encodeFunctionData({
|
|
15192
|
+
abi: vaultTokenAbi,
|
|
15193
|
+
functionName: "deposit",
|
|
15194
|
+
args: [token, amount]
|
|
15195
|
+
})
|
|
15196
|
+
},
|
|
15197
|
+
// Vaults live on the hub; refuse to broadcast from a wallet on another EVM network.
|
|
15198
|
+
{ expectedChainId: getEvmViemChain(ChainKeys.SONIC_MAINNET).id }
|
|
15199
|
+
);
|
|
15074
15200
|
}
|
|
15075
15201
|
/**
|
|
15076
15202
|
* Withdraws a specified amount of a token from the vault.
|
|
@@ -15082,16 +15208,19 @@ var EvmVaultTokenService = class {
|
|
|
15082
15208
|
*/
|
|
15083
15209
|
static async withdraw(vault, token, amount, provider) {
|
|
15084
15210
|
const from = await provider.getWalletAddress();
|
|
15085
|
-
return provider.sendTransaction(
|
|
15086
|
-
|
|
15087
|
-
|
|
15088
|
-
|
|
15089
|
-
|
|
15090
|
-
|
|
15091
|
-
|
|
15092
|
-
|
|
15093
|
-
|
|
15094
|
-
|
|
15211
|
+
return provider.sendTransaction(
|
|
15212
|
+
{
|
|
15213
|
+
from,
|
|
15214
|
+
to: vault,
|
|
15215
|
+
value: 0n,
|
|
15216
|
+
data: viem.encodeFunctionData({
|
|
15217
|
+
abi: vaultTokenAbi,
|
|
15218
|
+
functionName: "withdraw",
|
|
15219
|
+
args: [token, amount]
|
|
15220
|
+
})
|
|
15221
|
+
},
|
|
15222
|
+
{ expectedChainId: getEvmViemChain(ChainKeys.SONIC_MAINNET).id }
|
|
15223
|
+
);
|
|
15095
15224
|
}
|
|
15096
15225
|
/**
|
|
15097
15226
|
* Encodes the deposit transaction data for the vault.
|
|
@@ -15292,7 +15421,9 @@ var Erc20Service = class _Erc20Service {
|
|
|
15292
15421
|
if (params.raw) {
|
|
15293
15422
|
return rawTx;
|
|
15294
15423
|
}
|
|
15295
|
-
return await params.walletProvider.sendTransaction(rawTx
|
|
15424
|
+
return await params.walletProvider.sendTransaction(rawTx, {
|
|
15425
|
+
expectedChainId: params.expectedChainId
|
|
15426
|
+
});
|
|
15296
15427
|
}
|
|
15297
15428
|
/**
|
|
15298
15429
|
* Encodes a transfer transaction for a token.
|
|
@@ -15605,7 +15736,9 @@ var EvmSpokeService = class {
|
|
|
15605
15736
|
if (params.raw === true) {
|
|
15606
15737
|
return rawTx;
|
|
15607
15738
|
}
|
|
15608
|
-
return params.walletProvider.sendTransaction(rawTx
|
|
15739
|
+
return params.walletProvider.sendTransaction(rawTx, {
|
|
15740
|
+
expectedChainId: getEvmViemChain(srcChainKey).id
|
|
15741
|
+
});
|
|
15609
15742
|
}
|
|
15610
15743
|
/**
|
|
15611
15744
|
* Get the balance of the token deposited in the spoke chain asset manager.
|
|
@@ -15718,7 +15851,9 @@ var EvmSpokeService = class {
|
|
|
15718
15851
|
if (params.raw) {
|
|
15719
15852
|
return rawTx;
|
|
15720
15853
|
}
|
|
15721
|
-
return params.walletProvider.sendTransaction(rawTx
|
|
15854
|
+
return params.walletProvider.sendTransaction(rawTx, {
|
|
15855
|
+
expectedChainId: getEvmViemChain(srcChainKey).id
|
|
15856
|
+
});
|
|
15722
15857
|
}
|
|
15723
15858
|
async waitForTransactionReceipt(params) {
|
|
15724
15859
|
try {
|
|
@@ -15810,6 +15945,24 @@ var StacksSpokeService = class {
|
|
|
15810
15945
|
});
|
|
15811
15946
|
return result.value.value;
|
|
15812
15947
|
}
|
|
15948
|
+
ftAssetNames = /* @__PURE__ */ new Map();
|
|
15949
|
+
/** Post-conditions need the on-chain `define-fungible-token` names; SIP-10 exposes no read for them. */
|
|
15950
|
+
async getFtAssetNames(tokenContractId) {
|
|
15951
|
+
const cached = this.ftAssetNames.get(tokenContractId);
|
|
15952
|
+
if (cached) return cached;
|
|
15953
|
+
const [address, name] = core.parseContractId(tokenContractId);
|
|
15954
|
+
const response = await fetch(`${this.network.client.baseUrl}/v2/contracts/interface/${address}/${name}`);
|
|
15955
|
+
if (!response.ok) {
|
|
15956
|
+
throw new Error(`Failed to fetch the contract interface for ${tokenContractId}: ${response.statusText}`);
|
|
15957
|
+
}
|
|
15958
|
+
const abi = await response.json();
|
|
15959
|
+
const assetNames = (abi.fungible_tokens ?? []).map((token) => token.name);
|
|
15960
|
+
if (assetNames.length === 0) {
|
|
15961
|
+
throw new Error(`${tokenContractId} defines no fungible token \u2014 not a SIP-10 contract`);
|
|
15962
|
+
}
|
|
15963
|
+
this.ftAssetNames.set(tokenContractId, assetNames);
|
|
15964
|
+
return assetNames;
|
|
15965
|
+
}
|
|
15813
15966
|
async getImplContractAddress(stateContract) {
|
|
15814
15967
|
const [contractAddress, contractName] = core.parseContractId(stateContract);
|
|
15815
15968
|
const txParams = {
|
|
@@ -15832,18 +15985,18 @@ var StacksSpokeService = class {
|
|
|
15832
15985
|
const assetManagerImpl = await this.getImplContractAddress(chainConfig.addresses.assetManager);
|
|
15833
15986
|
const [implAddress, implName] = core.parseContractId(assetManagerImpl);
|
|
15834
15987
|
const [connectionAddress, connectionName] = core.parseContractId(chainConfig.addresses.connection);
|
|
15988
|
+
const isNative = isNativeToken(params.srcChainKey, params.token);
|
|
15835
15989
|
const reqData = {
|
|
15836
15990
|
contractAddress: implAddress,
|
|
15837
15991
|
contractName: implName,
|
|
15838
15992
|
functionName: "transfer",
|
|
15839
15993
|
functionArgs: [
|
|
15840
|
-
|
|
15994
|
+
isNative ? core.noneCV() : core.someCV(core.Cl.principal(params.token)),
|
|
15841
15995
|
core.Cl.bufferFromHex(params.to),
|
|
15842
15996
|
core.uintCV(params.amount),
|
|
15843
15997
|
core.Cl.bufferFromHex(params.data),
|
|
15844
15998
|
core.Cl.contractPrincipal(connectionAddress, connectionName)
|
|
15845
|
-
]
|
|
15846
|
-
postConditionMode: core.PostConditionMode.Allow
|
|
15999
|
+
]
|
|
15847
16000
|
};
|
|
15848
16001
|
if (params.raw === true) {
|
|
15849
16002
|
if (!params.srcPublicKey) {
|
|
@@ -15872,9 +16025,25 @@ var StacksSpokeService = class {
|
|
|
15872
16025
|
payload: viem.bytesToHex(core.serializePayloadBytes(tx.payload))
|
|
15873
16026
|
};
|
|
15874
16027
|
}
|
|
15875
|
-
const txId = await params.walletProvider.sendTransaction(
|
|
16028
|
+
const txId = await params.walletProvider.sendTransaction({
|
|
16029
|
+
...reqData,
|
|
16030
|
+
postConditionMode: core.PostConditionMode.Deny,
|
|
16031
|
+
postConditions: await this.depositPostConditions(params.srcAddress, params.token, params.amount, isNative)
|
|
16032
|
+
});
|
|
15876
16033
|
return txId;
|
|
15877
16034
|
}
|
|
16035
|
+
/**
|
|
16036
|
+
* Caps for a Deny-mode deposit: asset-manager-state.deposit moves exactly `amount` from the
|
|
16037
|
+
* caller, so cap the sender at `amount` — one cap per FT the token contract defines (sBTC has
|
|
16038
|
+
* two; the unmoved ones pass at 0 trivially), or uSTX for native.
|
|
16039
|
+
*/
|
|
16040
|
+
async depositPostConditions(srcAddress, token, amount, isNative) {
|
|
16041
|
+
if (isNative) return [core.Pc.principal(srcAddress).willSendLte(amount).ustx()];
|
|
16042
|
+
const assetNames = await this.getFtAssetNames(token);
|
|
16043
|
+
return assetNames.map(
|
|
16044
|
+
(assetName) => core.Pc.principal(srcAddress).willSendLte(amount).ft(token, assetName)
|
|
16045
|
+
);
|
|
16046
|
+
}
|
|
15878
16047
|
/**
|
|
15879
16048
|
* Get the balance of the token deposited in the spoke chain asset manager.
|
|
15880
16049
|
* @param {GetDepositParams<StacksChainKey>} params - The parameters for the deposit, including the user's address, token address, and chain id.
|
|
@@ -15924,8 +16093,7 @@ var StacksSpokeService = class {
|
|
|
15924
16093
|
contractAddress: connectionAddress,
|
|
15925
16094
|
contractName: connectionName,
|
|
15926
16095
|
functionName: "send-message",
|
|
15927
|
-
functionArgs: [core.uintCV(dstRelayChainId), core.Cl.bufferFromHex(params.dstAddress), core.Cl.bufferFromHex(params.payload)]
|
|
15928
|
-
postConditionMode: core.PostConditionMode.Allow
|
|
16096
|
+
functionArgs: [core.uintCV(dstRelayChainId), core.Cl.bufferFromHex(params.dstAddress), core.Cl.bufferFromHex(params.payload)]
|
|
15929
16097
|
};
|
|
15930
16098
|
if (params.raw === true) {
|
|
15931
16099
|
const tx = await core.makeUnsignedContractCall({
|
|
@@ -15940,7 +16108,12 @@ var StacksSpokeService = class {
|
|
|
15940
16108
|
payload: viem.bytesToHex(core.serializePayloadBytes(tx.payload))
|
|
15941
16109
|
};
|
|
15942
16110
|
}
|
|
15943
|
-
const txId = await params.walletProvider.sendTransaction(
|
|
16111
|
+
const txId = await params.walletProvider.sendTransaction({
|
|
16112
|
+
...reqData,
|
|
16113
|
+
// send-message moves no assets — deny with no conditions aborts if it ever tries.
|
|
16114
|
+
postConditionMode: core.PostConditionMode.Deny,
|
|
16115
|
+
postConditions: []
|
|
16116
|
+
});
|
|
15944
16117
|
return txId;
|
|
15945
16118
|
}
|
|
15946
16119
|
async waitForTransactionReceipt(params) {
|
|
@@ -16387,60 +16560,6 @@ var RadfiProvider = class {
|
|
|
16387
16560
|
}
|
|
16388
16561
|
};
|
|
16389
16562
|
|
|
16390
|
-
// src/shared/entities/btc/btc-utils.ts
|
|
16391
|
-
var BITCOIN_FEE_SAFETY_VBYTES = 20;
|
|
16392
|
-
function calcOpReturnOutputVbytes(payloadByteLength) {
|
|
16393
|
-
let scriptSize;
|
|
16394
|
-
if (payloadByteLength <= 75) {
|
|
16395
|
-
scriptSize = 3 + payloadByteLength;
|
|
16396
|
-
} else if (payloadByteLength <= 255) {
|
|
16397
|
-
scriptSize = 4 + payloadByteLength;
|
|
16398
|
-
} else {
|
|
16399
|
-
scriptSize = 5 + payloadByteLength;
|
|
16400
|
-
}
|
|
16401
|
-
const scriptLenVarint = scriptSize <= 252 ? 1 : 3;
|
|
16402
|
-
return 8 + scriptLenVarint + scriptSize;
|
|
16403
|
-
}
|
|
16404
|
-
function estimateBitcoinTxSize(inputCount, outputCount, addressType, opReturnOutputVbytes = 44) {
|
|
16405
|
-
let inputWeight;
|
|
16406
|
-
switch (addressType) {
|
|
16407
|
-
case "P2PKH":
|
|
16408
|
-
inputWeight = 148;
|
|
16409
|
-
break;
|
|
16410
|
-
case "P2SH":
|
|
16411
|
-
inputWeight = 91;
|
|
16412
|
-
break;
|
|
16413
|
-
case "P2TR":
|
|
16414
|
-
inputWeight = 58;
|
|
16415
|
-
break;
|
|
16416
|
-
default:
|
|
16417
|
-
inputWeight = 68;
|
|
16418
|
-
break;
|
|
16419
|
-
}
|
|
16420
|
-
return Math.ceil(
|
|
16421
|
-
10.5 + opReturnOutputVbytes + BITCOIN_FEE_SAFETY_VBYTES + inputCount * inputWeight + outputCount * 31
|
|
16422
|
-
);
|
|
16423
|
-
}
|
|
16424
|
-
function encodeBtcPayloadToBytes(payload) {
|
|
16425
|
-
return JSON.stringify({
|
|
16426
|
-
src_address: payload.src_address.toLowerCase(),
|
|
16427
|
-
data: payload.data.toLowerCase(),
|
|
16428
|
-
src_chain_id: payload.src_chain_id,
|
|
16429
|
-
dst_chain_id: payload.dst_chain_id,
|
|
16430
|
-
wallet_used: payload.wallet_used,
|
|
16431
|
-
timestamp: payload.timestamp,
|
|
16432
|
-
address_type: payload.address_type
|
|
16433
|
-
});
|
|
16434
|
-
}
|
|
16435
|
-
function normalizePsbtToBase64(signedPsbt) {
|
|
16436
|
-
const isHex2 = /^[0-9a-fA-F]+$/.test(signedPsbt);
|
|
16437
|
-
return isHex2 ? Buffer.from(signedPsbt, "hex").toString("base64") : signedPsbt;
|
|
16438
|
-
}
|
|
16439
|
-
function normalizeSignatureToBase64(signature) {
|
|
16440
|
-
const isHex2 = /^[0-9a-fA-F]+$/.test(signature);
|
|
16441
|
-
return isHex2 ? Buffer.from(signature, "hex").toString("base64") : signature;
|
|
16442
|
-
}
|
|
16443
|
-
|
|
16444
16563
|
// src/shared/services/spoke/BitcoinSpokeService.ts
|
|
16445
16564
|
bitcoinjsLib.initEccLib(ecc__namespace);
|
|
16446
16565
|
var BITCOIN_DEFAULT_FEE_RATE = 3;
|
|
@@ -17098,7 +17217,7 @@ function hexToBytes2(hex) {
|
|
|
17098
17217
|
const al = hl / 2;
|
|
17099
17218
|
if (hl % 2)
|
|
17100
17219
|
throw new Error("hex string expected, got unpadded hex of length " + hl);
|
|
17101
|
-
const
|
|
17220
|
+
const array4 = new Uint8Array(al);
|
|
17102
17221
|
for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) {
|
|
17103
17222
|
const n1 = asciiToBase16(hex.charCodeAt(hi));
|
|
17104
17223
|
const n2 = asciiToBase16(hex.charCodeAt(hi + 1));
|
|
@@ -17106,9 +17225,9 @@ function hexToBytes2(hex) {
|
|
|
17106
17225
|
const char = hex[hi] + hex[hi + 1];
|
|
17107
17226
|
throw new Error('hex string expected, got non-hex character "' + char + '" at index ' + hi);
|
|
17108
17227
|
}
|
|
17109
|
-
|
|
17228
|
+
array4[ai] = n1 * 16 + n2;
|
|
17110
17229
|
}
|
|
17111
|
-
return
|
|
17230
|
+
return array4;
|
|
17112
17231
|
}
|
|
17113
17232
|
function concatBytes(...arrays) {
|
|
17114
17233
|
let sum = 0;
|
|
@@ -17738,22 +17857,22 @@ function createHmacDrbg(hashLen, qByteLen, hmacFn) {
|
|
|
17738
17857
|
const byte0 = Uint8Array.of(0);
|
|
17739
17858
|
const byte1 = Uint8Array.of(1);
|
|
17740
17859
|
const _maxDrbgIters = 1e3;
|
|
17741
|
-
let
|
|
17860
|
+
let v12 = u8n(hashLen);
|
|
17742
17861
|
let k = u8n(hashLen);
|
|
17743
17862
|
let i = 0;
|
|
17744
17863
|
const reset = () => {
|
|
17745
|
-
|
|
17864
|
+
v12.fill(1);
|
|
17746
17865
|
k.fill(0);
|
|
17747
17866
|
i = 0;
|
|
17748
17867
|
};
|
|
17749
|
-
const h = (...msgs) => hmacFn(k, concatBytes(
|
|
17868
|
+
const h = (...msgs) => hmacFn(k, concatBytes(v12, ...msgs));
|
|
17750
17869
|
const reseed = (seed = NULL) => {
|
|
17751
17870
|
k = h(byte0, seed);
|
|
17752
|
-
|
|
17871
|
+
v12 = h();
|
|
17753
17872
|
if (seed.length === 0)
|
|
17754
17873
|
return;
|
|
17755
17874
|
k = h(byte1, seed);
|
|
17756
|
-
|
|
17875
|
+
v12 = h();
|
|
17757
17876
|
};
|
|
17758
17877
|
const gen = () => {
|
|
17759
17878
|
if (i++ >= _maxDrbgIters)
|
|
@@ -17761,10 +17880,10 @@ function createHmacDrbg(hashLen, qByteLen, hmacFn) {
|
|
|
17761
17880
|
let len = 0;
|
|
17762
17881
|
const out = [];
|
|
17763
17882
|
while (len < qByteLen) {
|
|
17764
|
-
|
|
17765
|
-
const sl =
|
|
17883
|
+
v12 = h();
|
|
17884
|
+
const sl = v12.slice();
|
|
17766
17885
|
out.push(sl);
|
|
17767
|
-
len +=
|
|
17886
|
+
len += v12.length;
|
|
17768
17887
|
}
|
|
17769
17888
|
return concatBytes(...out);
|
|
17770
17889
|
};
|
|
@@ -17779,18 +17898,18 @@ function createHmacDrbg(hashLen, qByteLen, hmacFn) {
|
|
|
17779
17898
|
};
|
|
17780
17899
|
return genUntil;
|
|
17781
17900
|
}
|
|
17782
|
-
function validateObject(
|
|
17783
|
-
if (!
|
|
17901
|
+
function validateObject(object6, fields = {}, optFields = {}) {
|
|
17902
|
+
if (!object6 || typeof object6 !== "object")
|
|
17784
17903
|
throw new Error("expected valid options object");
|
|
17785
17904
|
function checkField(fieldName, expectedType, isOpt) {
|
|
17786
|
-
const val =
|
|
17905
|
+
const val = object6[fieldName];
|
|
17787
17906
|
if (isOpt && val === void 0)
|
|
17788
17907
|
return;
|
|
17789
17908
|
const current = typeof val;
|
|
17790
17909
|
if (current !== expectedType || val === null)
|
|
17791
17910
|
throw new Error(`param "${fieldName}" is invalid: expected ${expectedType}, got ${current}`);
|
|
17792
17911
|
}
|
|
17793
|
-
const iter = (f, isOpt) => Object.entries(f).forEach(([k,
|
|
17912
|
+
const iter = (f, isOpt) => Object.entries(f).forEach(([k, v12]) => checkField(k, v12, isOpt));
|
|
17794
17913
|
iter(fields, false);
|
|
17795
17914
|
iter(optFields, true);
|
|
17796
17915
|
}
|
|
@@ -17829,12 +17948,12 @@ function pow2(x, power, modulo) {
|
|
|
17829
17948
|
}
|
|
17830
17949
|
return res;
|
|
17831
17950
|
}
|
|
17832
|
-
function invert(
|
|
17833
|
-
if (
|
|
17951
|
+
function invert(number6, modulo) {
|
|
17952
|
+
if (number6 === _0n2)
|
|
17834
17953
|
throw new Error("invert: expected non-zero number");
|
|
17835
17954
|
if (modulo <= _0n2)
|
|
17836
17955
|
throw new Error("invert: expected positive modulus, got " + modulo);
|
|
17837
|
-
let a = mod(
|
|
17956
|
+
let a = mod(number6, modulo);
|
|
17838
17957
|
let b = modulo;
|
|
17839
17958
|
let x = _0n2, u = _1n2;
|
|
17840
17959
|
while (a !== _0n2) {
|
|
@@ -17861,9 +17980,9 @@ function sqrt3mod4(Fp, n) {
|
|
|
17861
17980
|
function sqrt5mod8(Fp, n) {
|
|
17862
17981
|
const p5div8 = (Fp.ORDER - _5n) / _8n;
|
|
17863
17982
|
const n2 = Fp.mul(n, _2n);
|
|
17864
|
-
const
|
|
17865
|
-
const nv = Fp.mul(n,
|
|
17866
|
-
const i = Fp.mul(Fp.mul(nv, _2n),
|
|
17983
|
+
const v12 = Fp.pow(n2, p5div8);
|
|
17984
|
+
const nv = Fp.mul(n, v12);
|
|
17985
|
+
const i = Fp.mul(Fp.mul(nv, _2n), v12);
|
|
17867
17986
|
const root = Fp.mul(nv, Fp.sub(i, Fp.ONE));
|
|
17868
17987
|
assertIsSquare(Fp, root, n);
|
|
17869
17988
|
return root;
|
|
@@ -18445,9 +18564,9 @@ function edwards(params, extraOpts = {}) {
|
|
|
18445
18564
|
validateObject(extraOpts, {}, { uvRatio: "function" });
|
|
18446
18565
|
const MASK = _2n2 << BigInt(Fn.BYTES * 8) - _1n4;
|
|
18447
18566
|
const modP = (n) => Fp.create(n);
|
|
18448
|
-
const uvRatio2 = extraOpts.uvRatio || ((u,
|
|
18567
|
+
const uvRatio2 = extraOpts.uvRatio || ((u, v12) => {
|
|
18449
18568
|
try {
|
|
18450
|
-
return { isValid: true, value: Fp.sqrt(Fp.div(u,
|
|
18569
|
+
return { isValid: true, value: Fp.sqrt(Fp.div(u, v12)) };
|
|
18451
18570
|
} catch (e) {
|
|
18452
18571
|
return { isValid: false, value: _0n4 };
|
|
18453
18572
|
}
|
|
@@ -18543,8 +18662,8 @@ function edwards(params, extraOpts = {}) {
|
|
|
18543
18662
|
aInRange("point.y", y, _0n4, max);
|
|
18544
18663
|
const y2 = modP(y * y);
|
|
18545
18664
|
const u = modP(y2 - _1n4);
|
|
18546
|
-
const
|
|
18547
|
-
let { isValid, value: x } = uvRatio2(u,
|
|
18665
|
+
const v12 = modP(d * y2 - a);
|
|
18666
|
+
let { isValid, value: x } = uvRatio2(u, v12);
|
|
18548
18667
|
if (!isValid)
|
|
18549
18668
|
throw new Error("bad point: invalid y coordinate");
|
|
18550
18669
|
const isXOdd = (x & _1n4) === _1n4;
|
|
@@ -18884,13 +19003,13 @@ function adjustScalarBytes(bytes) {
|
|
|
18884
19003
|
return bytes;
|
|
18885
19004
|
}
|
|
18886
19005
|
var ED25519_SQRT_M1 = /* @__PURE__ */ BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");
|
|
18887
|
-
function uvRatio(u,
|
|
19006
|
+
function uvRatio(u, v12) {
|
|
18888
19007
|
const P = ed25519_CURVE_p;
|
|
18889
|
-
const v32 = mod(
|
|
18890
|
-
const v72 = mod(v32 * v32 *
|
|
19008
|
+
const v32 = mod(v12 * v12 * v12, P);
|
|
19009
|
+
const v72 = mod(v32 * v32 * v12, P);
|
|
18891
19010
|
const pow = ed25519_pow_2_252_3(u * v72).pow_p_5_8;
|
|
18892
19011
|
let x = mod(u * v32 * pow, P);
|
|
18893
|
-
const vx2 = mod(
|
|
19012
|
+
const vx2 = mod(v12 * x * x, P);
|
|
18894
19013
|
const root1 = x;
|
|
18895
19014
|
const root2 = mod(x * ED25519_SQRT_M1, P);
|
|
18896
19015
|
const useRoot1 = vx2 === u;
|
|
@@ -19221,7 +19340,7 @@ function findSeatPrice(validators, maxNumberOfSeats, minimumStakeRatio, protocol
|
|
|
19221
19340
|
return findSeatPriceForProtocolAfter49(validators, maxNumberOfSeats, minimumStakeRatio);
|
|
19222
19341
|
}
|
|
19223
19342
|
function findSeatPriceForProtocolBefore49(validators, numSeats) {
|
|
19224
|
-
const stakes = validators.map((
|
|
19343
|
+
const stakes = validators.map((v12) => BigInt(v12.stake)).sort(sortBigIntAsc);
|
|
19225
19344
|
const num = BigInt(numSeats);
|
|
19226
19345
|
const stakesSum = stakes.reduce((a, b) => a + b);
|
|
19227
19346
|
if (stakesSum < num) {
|
|
@@ -19250,7 +19369,7 @@ function findSeatPriceForProtocolAfter49(validators, maxNumberOfSeats, minimumSt
|
|
|
19250
19369
|
if (minimumStakeRatio.length != 2) {
|
|
19251
19370
|
throw Error("minimumStakeRatio should have 2 elements");
|
|
19252
19371
|
}
|
|
19253
|
-
const stakes = validators.map((
|
|
19372
|
+
const stakes = validators.map((v12) => BigInt(v12.stake)).sort(sortBigIntAsc);
|
|
19254
19373
|
const stakesSum = stakes.reduce((a, b) => a + b);
|
|
19255
19374
|
if (validators.length < maxNumberOfSeats) {
|
|
19256
19375
|
return stakesSum * BigInt(minimumStakeRatio[0]) / BigInt(minimumStakeRatio[1]);
|
|
@@ -19422,10 +19541,10 @@ var DER = {
|
|
|
19422
19541
|
if (length < 128)
|
|
19423
19542
|
throw new E("tlv.decode(long): not minimal encoding");
|
|
19424
19543
|
}
|
|
19425
|
-
const
|
|
19426
|
-
if (
|
|
19544
|
+
const v12 = data.subarray(pos, pos + length);
|
|
19545
|
+
if (v12.length !== length)
|
|
19427
19546
|
throw new E("tlv.decode: wrong value length");
|
|
19428
|
-
return { v:
|
|
19547
|
+
return { v: v12, l: data.subarray(pos + length) };
|
|
19429
19548
|
}
|
|
19430
19549
|
},
|
|
19431
19550
|
// https://crypto.stackexchange.com/a/57734 Leftmost bit of first byte is 'negative' flag,
|
|
@@ -19993,9 +20112,9 @@ function ecdsa(Point, hash, ecdsaOpts = {}) {
|
|
|
19993
20112
|
extraEntropy: false
|
|
19994
20113
|
};
|
|
19995
20114
|
const hasLargeCofactor = CURVE_ORDER * _2n4 < Fp.ORDER;
|
|
19996
|
-
function isBiggerThanHalfOrder(
|
|
20115
|
+
function isBiggerThanHalfOrder(number6) {
|
|
19997
20116
|
const HALF = CURVE_ORDER >> _1n6;
|
|
19998
|
-
return
|
|
20117
|
+
return number6 > HALF;
|
|
19999
20118
|
}
|
|
20000
20119
|
function validateRS(title, num) {
|
|
20001
20120
|
if (!Fn.isValidNot0(num))
|
|
@@ -20178,8 +20297,8 @@ function ecdsa(Point, hash, ecdsaOpts = {}) {
|
|
|
20178
20297
|
const R = Point.BASE.multiplyUnsafe(u1).add(P.multiplyUnsafe(u2));
|
|
20179
20298
|
if (R.is0())
|
|
20180
20299
|
return false;
|
|
20181
|
-
const
|
|
20182
|
-
return
|
|
20300
|
+
const v12 = Fn.create(R.x);
|
|
20301
|
+
return v12 === r;
|
|
20183
20302
|
} catch (e) {
|
|
20184
20303
|
return false;
|
|
20185
20304
|
}
|
|
@@ -23867,7 +23986,9 @@ var SonicSpokeService = class {
|
|
|
23867
23986
|
if (params.raw === true) {
|
|
23868
23987
|
return rawTx;
|
|
23869
23988
|
}
|
|
23870
|
-
return params.walletProvider.sendTransaction(rawTx
|
|
23989
|
+
return params.walletProvider.sendTransaction(rawTx, {
|
|
23990
|
+
expectedChainId: getEvmViemChain(ChainKeys.SONIC_MAINNET).id
|
|
23991
|
+
});
|
|
23871
23992
|
}
|
|
23872
23993
|
static async createSwapIntent(params) {
|
|
23873
23994
|
const { createIntentParams, creatorHubWalletAddress, solverConfig: solverConfig2, fee, hubProvider } = params;
|
|
@@ -23917,7 +24038,9 @@ var SonicSpokeService = class {
|
|
|
23917
24038
|
return [rawTx, intent, feeAmount, txData.data];
|
|
23918
24039
|
}
|
|
23919
24040
|
return [
|
|
23920
|
-
await params.walletProvider.sendTransaction(rawTx
|
|
24041
|
+
await params.walletProvider.sendTransaction(rawTx, {
|
|
24042
|
+
expectedChainId: getEvmViemChain(ChainKeys.SONIC_MAINNET).id
|
|
24043
|
+
}),
|
|
23921
24044
|
intent,
|
|
23922
24045
|
feeAmount,
|
|
23923
24046
|
txData.data
|
|
@@ -24048,7 +24171,9 @@ var SonicSpokeService = class {
|
|
|
24048
24171
|
if (params.raw === true) {
|
|
24049
24172
|
return rawTx;
|
|
24050
24173
|
}
|
|
24051
|
-
return params.walletProvider.sendTransaction(rawTx
|
|
24174
|
+
return params.walletProvider.sendTransaction(rawTx, {
|
|
24175
|
+
expectedChainId: getEvmViemChain(ChainKeys.SONIC_MAINNET).id
|
|
24176
|
+
});
|
|
24052
24177
|
}
|
|
24053
24178
|
};
|
|
24054
24179
|
async function toMystenTransaction(txn) {
|
|
@@ -24133,16 +24258,16 @@ var SuiGrpcTransport = class {
|
|
|
24133
24258
|
return effects.gasUsed;
|
|
24134
24259
|
}
|
|
24135
24260
|
async fetchLatestPackageId(objectId) {
|
|
24136
|
-
let
|
|
24261
|
+
let object6;
|
|
24137
24262
|
try {
|
|
24138
|
-
({ object:
|
|
24263
|
+
({ object: object6 } = await this.client.core.getObject({ objectId, include: { json: true } }));
|
|
24139
24264
|
} catch (error) {
|
|
24140
24265
|
throw new Error("Failed to fetch asset manager id", { cause: error });
|
|
24141
24266
|
}
|
|
24142
|
-
if (!
|
|
24267
|
+
if (!object6) {
|
|
24143
24268
|
throw new Error("Asset manager id not found (no data)");
|
|
24144
24269
|
}
|
|
24145
|
-
const fields =
|
|
24270
|
+
const fields = object6.json;
|
|
24146
24271
|
if (!fields) {
|
|
24147
24272
|
throw new Error("Asset manager id not found (not a move object)");
|
|
24148
24273
|
}
|
|
@@ -26199,7 +26324,9 @@ var SpokeService = class _SpokeService {
|
|
|
26199
26324
|
from: params.owner,
|
|
26200
26325
|
spender: params.spender,
|
|
26201
26326
|
raw: false,
|
|
26202
|
-
walletProvider
|
|
26327
|
+
walletProvider,
|
|
26328
|
+
// Covers the reset leg too — an approval must not broadcast on the wrong EVM network.
|
|
26329
|
+
expectedChainId: getEvmViemChain(params.srcChainKey).id
|
|
26203
26330
|
});
|
|
26204
26331
|
if (plan.resetAmount !== void 0) {
|
|
26205
26332
|
const resetHash = await sendApprove(plan.resetAmount);
|
|
@@ -26406,7 +26533,8 @@ var SpokeService = class _SpokeService {
|
|
|
26406
26533
|
return this.sui.encodeSimulationParams(token, assetManager);
|
|
26407
26534
|
default:
|
|
26408
26535
|
return {
|
|
26409
|
-
|
|
26536
|
+
// Token identifiers on BITCOIN/NEAR/INJECTIVE are not addresses — recipient validation stays on the address leg only.
|
|
26537
|
+
encodedToken: encodeTokenIdentifier(srcChainKey, token),
|
|
26410
26538
|
encodedSrcAddress: encodeAddress(srcChainKey, assetManager)
|
|
26411
26539
|
};
|
|
26412
26540
|
}
|
|
@@ -27033,6 +27161,7 @@ var SpokeService = class _SpokeService {
|
|
|
27033
27161
|
}
|
|
27034
27162
|
}
|
|
27035
27163
|
};
|
|
27164
|
+
var HUB_CHAIN_ID = getEvmViemChain(ChainKeys.SONIC_MAINNET).id;
|
|
27036
27165
|
var Erc4626Service = class {
|
|
27037
27166
|
constructor() {
|
|
27038
27167
|
}
|
|
@@ -27211,7 +27340,7 @@ var Erc4626Service = class {
|
|
|
27211
27340
|
if (raw) {
|
|
27212
27341
|
return rawTx;
|
|
27213
27342
|
}
|
|
27214
|
-
return walletProvider.sendTransaction(rawTx);
|
|
27343
|
+
return walletProvider.sendTransaction(rawTx, { expectedChainId: HUB_CHAIN_ID });
|
|
27215
27344
|
}
|
|
27216
27345
|
/**
|
|
27217
27346
|
* Get the maximum amount of shares that can be minted
|
|
@@ -27288,7 +27417,7 @@ var Erc4626Service = class {
|
|
|
27288
27417
|
if (raw) {
|
|
27289
27418
|
return rawTx;
|
|
27290
27419
|
}
|
|
27291
|
-
return walletProvider.sendTransaction(rawTx);
|
|
27420
|
+
return walletProvider.sendTransaction(rawTx, { expectedChainId: HUB_CHAIN_ID });
|
|
27292
27421
|
}
|
|
27293
27422
|
/**
|
|
27294
27423
|
* Get the maximum amount of assets that can be withdrawn
|
|
@@ -27366,7 +27495,7 @@ var Erc4626Service = class {
|
|
|
27366
27495
|
if (raw) {
|
|
27367
27496
|
return rawTx;
|
|
27368
27497
|
}
|
|
27369
|
-
return walletProvider.sendTransaction(rawTx);
|
|
27498
|
+
return walletProvider.sendTransaction(rawTx, { expectedChainId: HUB_CHAIN_ID });
|
|
27370
27499
|
}
|
|
27371
27500
|
/**
|
|
27372
27501
|
* Get the maximum amount of shares that can be redeemed
|
|
@@ -27444,7 +27573,7 @@ var Erc4626Service = class {
|
|
|
27444
27573
|
if (raw) {
|
|
27445
27574
|
return rawTx;
|
|
27446
27575
|
}
|
|
27447
|
-
return walletProvider.sendTransaction(rawTx);
|
|
27576
|
+
return walletProvider.sendTransaction(rawTx, { expectedChainId: HUB_CHAIN_ID });
|
|
27448
27577
|
}
|
|
27449
27578
|
/**
|
|
27450
27579
|
* Encodes a deposit transaction for a vault.
|
|
@@ -27521,6 +27650,7 @@ var Erc4626Service = class {
|
|
|
27521
27650
|
};
|
|
27522
27651
|
}
|
|
27523
27652
|
};
|
|
27653
|
+
var HUB_CHAIN_ID2 = getEvmViemChain(ChainKeys.SONIC_MAINNET).id;
|
|
27524
27654
|
var Permit2Service = class _Permit2Service {
|
|
27525
27655
|
constructor() {
|
|
27526
27656
|
}
|
|
@@ -27609,7 +27739,7 @@ var Permit2Service = class _Permit2Service {
|
|
|
27609
27739
|
if (raw) {
|
|
27610
27740
|
return rawTx;
|
|
27611
27741
|
}
|
|
27612
|
-
return walletProvider.sendTransaction(rawTx);
|
|
27742
|
+
return walletProvider.sendTransaction(rawTx, { expectedChainId: HUB_CHAIN_ID2 });
|
|
27613
27743
|
}
|
|
27614
27744
|
/**
|
|
27615
27745
|
* Execute a permit for a single token
|
|
@@ -27634,7 +27764,7 @@ var Permit2Service = class _Permit2Service {
|
|
|
27634
27764
|
if (raw) {
|
|
27635
27765
|
return rawTx;
|
|
27636
27766
|
}
|
|
27637
|
-
return walletProvider.sendTransaction(rawTx);
|
|
27767
|
+
return walletProvider.sendTransaction(rawTx, { expectedChainId: HUB_CHAIN_ID2 });
|
|
27638
27768
|
}
|
|
27639
27769
|
/**
|
|
27640
27770
|
* Execute a permit for multiple tokens
|
|
@@ -27659,7 +27789,7 @@ var Permit2Service = class _Permit2Service {
|
|
|
27659
27789
|
if (raw) {
|
|
27660
27790
|
return rawTx;
|
|
27661
27791
|
}
|
|
27662
|
-
return walletProvider.sendTransaction(rawTx);
|
|
27792
|
+
return walletProvider.sendTransaction(rawTx, { expectedChainId: HUB_CHAIN_ID2 });
|
|
27663
27793
|
}
|
|
27664
27794
|
/**
|
|
27665
27795
|
* Transfer tokens from one address to another using Permit2
|
|
@@ -27685,7 +27815,7 @@ var Permit2Service = class _Permit2Service {
|
|
|
27685
27815
|
if (raw) {
|
|
27686
27816
|
return rawTx;
|
|
27687
27817
|
}
|
|
27688
|
-
return walletProvider.sendTransaction(rawTx);
|
|
27818
|
+
return walletProvider.sendTransaction(rawTx, { expectedChainId: HUB_CHAIN_ID2 });
|
|
27689
27819
|
}
|
|
27690
27820
|
/**
|
|
27691
27821
|
* Transfer multiple tokens in a batch using Permit2
|
|
@@ -27708,7 +27838,7 @@ var Permit2Service = class _Permit2Service {
|
|
|
27708
27838
|
if (raw) {
|
|
27709
27839
|
return rawTx;
|
|
27710
27840
|
}
|
|
27711
|
-
return walletProvider.sendTransaction(rawTx);
|
|
27841
|
+
return walletProvider.sendTransaction(rawTx, { expectedChainId: HUB_CHAIN_ID2 });
|
|
27712
27842
|
}
|
|
27713
27843
|
/**
|
|
27714
27844
|
* Lockdown approvals to prevent malicious usage
|
|
@@ -27731,7 +27861,7 @@ var Permit2Service = class _Permit2Service {
|
|
|
27731
27861
|
if (raw) {
|
|
27732
27862
|
return rawTx;
|
|
27733
27863
|
}
|
|
27734
|
-
return walletProvider.sendTransaction(rawTx);
|
|
27864
|
+
return walletProvider.sendTransaction(rawTx, { expectedChainId: HUB_CHAIN_ID2 });
|
|
27735
27865
|
}
|
|
27736
27866
|
/**
|
|
27737
27867
|
* Invalidate nonces to prevent replay attacks
|
|
@@ -27756,7 +27886,7 @@ var Permit2Service = class _Permit2Service {
|
|
|
27756
27886
|
if (raw) {
|
|
27757
27887
|
return rawTx;
|
|
27758
27888
|
}
|
|
27759
|
-
return walletProvider.sendTransaction(rawTx);
|
|
27889
|
+
return walletProvider.sendTransaction(rawTx, { expectedChainId: HUB_CHAIN_ID2 });
|
|
27760
27890
|
}
|
|
27761
27891
|
/**
|
|
27762
27892
|
* Encodes an approve transaction for Permit2.
|
|
@@ -31014,7 +31144,9 @@ var BalnSwapService = class {
|
|
|
31014
31144
|
if (walletProviderSlot.raw) {
|
|
31015
31145
|
return tx;
|
|
31016
31146
|
}
|
|
31017
|
-
return walletProviderSlot.walletProvider.sendTransaction(tx
|
|
31147
|
+
return walletProviderSlot.walletProvider.sendTransaction(tx, {
|
|
31148
|
+
expectedChainId: getEvmViemChain(ChainKeys.SONIC_MAINNET).id
|
|
31149
|
+
});
|
|
31018
31150
|
}
|
|
31019
31151
|
};
|
|
31020
31152
|
|
|
@@ -32153,6 +32285,9 @@ function resolveSponsoringApiConfig(layers) {
|
|
|
32153
32285
|
function resolveBridgeApiConfig(layers) {
|
|
32154
32286
|
return resolveSharedApiConfig(layers);
|
|
32155
32287
|
}
|
|
32288
|
+
function resolveLeverageYieldApiConfig(layers) {
|
|
32289
|
+
return resolveSharedApiConfig(layers);
|
|
32290
|
+
}
|
|
32156
32291
|
var SwapsApiService = class _SwapsApiService {
|
|
32157
32292
|
// Fully-resolved swaps-API config supplied by the caller (BackendApiService resolves the
|
|
32158
32293
|
// `ApiConfig` union via `resolveSwapsApiConfig`); this service does not resolve the union.
|
|
@@ -32878,6 +33013,623 @@ var BridgeApiService = class {
|
|
|
32878
33013
|
return this.config.timeout;
|
|
32879
33014
|
}
|
|
32880
33015
|
};
|
|
33016
|
+
var LsdSourceSchema = v__namespace.object({
|
|
33017
|
+
poolId: v__namespace.string(),
|
|
33018
|
+
fallbackAprPct: v__namespace.number(),
|
|
33019
|
+
label: v__namespace.string()
|
|
33020
|
+
});
|
|
33021
|
+
var LeverageVaultSchema = v__namespace.object({
|
|
33022
|
+
name: v__namespace.string(),
|
|
33023
|
+
vault: v__namespace.string(),
|
|
33024
|
+
asset: v__namespace.string(),
|
|
33025
|
+
borrowToken: v__namespace.string(),
|
|
33026
|
+
lsdSource: v__namespace.optional(LsdSourceSchema)
|
|
33027
|
+
});
|
|
33028
|
+
var GetLeverageVaultsResponseSchema = v__namespace.array(LeverageVaultSchema);
|
|
33029
|
+
var GetLeverageVaultResponseSchema = LeverageVaultSchema;
|
|
33030
|
+
var VaultAssetResponseSchema = v__namespace.object({
|
|
33031
|
+
asset: v__namespace.string()
|
|
33032
|
+
});
|
|
33033
|
+
var LeverageYieldPositionSchema = v__namespace.object({
|
|
33034
|
+
collateral: v__namespace.string(),
|
|
33035
|
+
debt: v__namespace.string(),
|
|
33036
|
+
ltv: v__namespace.string(),
|
|
33037
|
+
healthFactor: v__namespace.string(),
|
|
33038
|
+
idleAsset: v__namespace.string()
|
|
33039
|
+
});
|
|
33040
|
+
var LeverageYieldAprSchema = v__namespace.object({
|
|
33041
|
+
supplyAprRay: v__namespace.string(),
|
|
33042
|
+
borrowAprRay: v__namespace.string(),
|
|
33043
|
+
targetLtvBps: v__namespace.string(),
|
|
33044
|
+
leverageMultiplierWad: v__namespace.string(),
|
|
33045
|
+
netAprRay: v__namespace.string()
|
|
33046
|
+
});
|
|
33047
|
+
var LeverageYieldLsdAprSchema = v__namespace.object({
|
|
33048
|
+
aprRay: v__namespace.string(),
|
|
33049
|
+
label: v__namespace.string(),
|
|
33050
|
+
stale: v__namespace.boolean()
|
|
33051
|
+
});
|
|
33052
|
+
var LeverageYieldEffectiveAprSchema = v__namespace.object({
|
|
33053
|
+
supplyAprRay: v__namespace.string(),
|
|
33054
|
+
borrowAprRay: v__namespace.string(),
|
|
33055
|
+
targetLtvBps: v__namespace.string(),
|
|
33056
|
+
leverageMultiplierWad: v__namespace.string(),
|
|
33057
|
+
netAprRay: v__namespace.string(),
|
|
33058
|
+
lsdApr: LeverageYieldLsdAprSchema,
|
|
33059
|
+
effectiveSupplyAprRay: v__namespace.string(),
|
|
33060
|
+
effectiveNetAprRay: v__namespace.string()
|
|
33061
|
+
});
|
|
33062
|
+
var VaultTotalAssetsResponseSchema = v__namespace.object({
|
|
33063
|
+
totalAssets: v__namespace.string()
|
|
33064
|
+
});
|
|
33065
|
+
var PreviewDepositResponseSchema = v__namespace.object({
|
|
33066
|
+
shares: v__namespace.string()
|
|
33067
|
+
});
|
|
33068
|
+
var PreviewWithdrawResponseSchema = v__namespace.object({
|
|
33069
|
+
shares: v__namespace.string()
|
|
33070
|
+
});
|
|
33071
|
+
var PreviewRedeemResponseSchema = v__namespace.object({
|
|
33072
|
+
assets: v__namespace.string()
|
|
33073
|
+
});
|
|
33074
|
+
var ShareBalanceResponseSchema = v__namespace.object({
|
|
33075
|
+
balance: v__namespace.string()
|
|
33076
|
+
});
|
|
33077
|
+
var MaxWithdrawResponseSchema = v__namespace.object({
|
|
33078
|
+
maxWithdraw: v__namespace.string()
|
|
33079
|
+
});
|
|
33080
|
+
|
|
33081
|
+
// src/backendApi/LeverageYieldApiService.ts
|
|
33082
|
+
var LeverageYieldApiService = class _LeverageYieldApiService {
|
|
33083
|
+
// Fully-resolved API config supplied by the caller (BackendApiService resolves the ApiConfig
|
|
33084
|
+
// union via `resolveBaseApiConfig`); leverage-yield endpoints are sub-paths under the base URL.
|
|
33085
|
+
config;
|
|
33086
|
+
headers;
|
|
33087
|
+
logger;
|
|
33088
|
+
/** See {@link LeverageYieldApiServiceOptions.trimLegacyOverrides}. */
|
|
33089
|
+
trimsLegacyOverrides;
|
|
33090
|
+
constructor(config, logger = consoleLogger, options = {}) {
|
|
33091
|
+
this.config = config;
|
|
33092
|
+
this.headers = { ...config.headers };
|
|
33093
|
+
this.logger = logger;
|
|
33094
|
+
this.trimsLegacyOverrides = options.trimLegacyOverrides ?? true;
|
|
33095
|
+
}
|
|
33096
|
+
/**
|
|
33097
|
+
* Issues a single HTTP request, validates the JSON body against `schema`, and wraps the
|
|
33098
|
+
* result in `Result<T>`. Mirrors `SwapsApiService.request`; every public method delegates here.
|
|
33099
|
+
*/
|
|
33100
|
+
async request(endpoint, config, schema, overrideConfig) {
|
|
33101
|
+
try {
|
|
33102
|
+
const raw = await makeRequest({
|
|
33103
|
+
endpoint,
|
|
33104
|
+
config: { baseURL: this.config.baseURL, timeout: this.config.timeout, headers: this.headers, ...config },
|
|
33105
|
+
// Normalized like a configured base URL: the override is the gateway root, so a legacy
|
|
33106
|
+
// `/be`-suffixed value must not nest `/leverage-yield/*` under the data API's mount — unless the
|
|
33107
|
+
// config opted out of the legacy trim, in which case the per-call value is left as given.
|
|
33108
|
+
overrideConfig: this.trimsLegacyOverrides ? normalizeOverrideBaseURL(overrideConfig) : overrideConfig,
|
|
33109
|
+
logger: this.logger,
|
|
33110
|
+
serviceLabel: "LeverageYieldApiService"
|
|
33111
|
+
});
|
|
33112
|
+
const parsed = v__namespace.safeParse(schema, raw);
|
|
33113
|
+
if (!parsed.success) {
|
|
33114
|
+
return {
|
|
33115
|
+
ok: false,
|
|
33116
|
+
error: toInvalidResponseShapeError({
|
|
33117
|
+
api: "leverageYield",
|
|
33118
|
+
feature: "backend",
|
|
33119
|
+
endpoint,
|
|
33120
|
+
issues: v__namespace.flatten(parsed.issues)
|
|
33121
|
+
})
|
|
33122
|
+
};
|
|
33123
|
+
}
|
|
33124
|
+
return { ok: true, value: parsed.output };
|
|
33125
|
+
} catch (error) {
|
|
33126
|
+
return { ok: false, error: toExternalApiError({ api: "leverageYield", feature: "backend", endpoint, error }) };
|
|
33127
|
+
}
|
|
33128
|
+
}
|
|
33129
|
+
/**
|
|
33130
|
+
* Drop the SDK-only display field `feeAmount` before an intent reaches the strict wire serializer.
|
|
33131
|
+
* `sodax.leverageYield.createVaultIntent` returns `Intent & FeeAmount`, which is structurally
|
|
33132
|
+
* assignable to the wire `IntentRequestV2` and so gets passed straight into the intent-carrying
|
|
33133
|
+
* endpoints; the lenient JSON serializer would send the extra bigint wholesale. Mirrors
|
|
33134
|
+
* `SwapsApiService.toWireIntent`; a no-op for an already-clean `IntentRequestV2`.
|
|
33135
|
+
*/
|
|
33136
|
+
static toWireIntent(intent) {
|
|
33137
|
+
const { feeAmount: _feeAmount, ...rest } = intent;
|
|
33138
|
+
return rest;
|
|
33139
|
+
}
|
|
33140
|
+
/** Append `params` to `base` as a query string, returning `base` unchanged when `params` is empty. */
|
|
33141
|
+
withQuery(base2, params) {
|
|
33142
|
+
const queryString = new URLSearchParams(params).toString();
|
|
33143
|
+
return queryString.length > 0 ? `${base2}?${queryString}` : base2;
|
|
33144
|
+
}
|
|
33145
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
33146
|
+
// Vault registry
|
|
33147
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
33148
|
+
/**
|
|
33149
|
+
* Fetch the registry of deployed leverage-yield vaults.
|
|
33150
|
+
*
|
|
33151
|
+
* @returns `Result<GetLeverageVaultsResponseV2>` — array of vault descriptors.
|
|
33152
|
+
*/
|
|
33153
|
+
async getVaults(config) {
|
|
33154
|
+
return this.request("/leverage-yield/vaults", { method: "GET" }, GetLeverageVaultsResponseSchema, config);
|
|
33155
|
+
}
|
|
33156
|
+
/**
|
|
33157
|
+
* Fetch a single vault descriptor by its lsoda* share-token name (e.g. `lsodaWEETH`).
|
|
33158
|
+
*
|
|
33159
|
+
* @returns `Result<GetLeverageVaultResponseV2>` — the vault descriptor.
|
|
33160
|
+
*/
|
|
33161
|
+
async getVault(name, config) {
|
|
33162
|
+
return this.request(
|
|
33163
|
+
`/leverage-yield/vaults/${name}`,
|
|
33164
|
+
{ method: "GET" },
|
|
33165
|
+
GetLeverageVaultResponseSchema,
|
|
33166
|
+
config
|
|
33167
|
+
);
|
|
33168
|
+
}
|
|
33169
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
33170
|
+
// Vault reads
|
|
33171
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
33172
|
+
/**
|
|
33173
|
+
* Get the vault's underlying hub asset (Sodax vault-token wrapper).
|
|
33174
|
+
*
|
|
33175
|
+
* @returns `Result<VaultAssetResponseV2>` — `{ asset }`.
|
|
33176
|
+
*/
|
|
33177
|
+
async getAsset(query, config) {
|
|
33178
|
+
return this.request(
|
|
33179
|
+
this.withQuery("/leverage-yield/asset", { vault: query.vault }),
|
|
33180
|
+
{ method: "GET" },
|
|
33181
|
+
VaultAssetResponseSchema,
|
|
33182
|
+
config
|
|
33183
|
+
);
|
|
33184
|
+
}
|
|
33185
|
+
/**
|
|
33186
|
+
* Get a leveraged-position snapshot for the vault.
|
|
33187
|
+
*
|
|
33188
|
+
* @returns `Result<LeverageYieldPositionV2>` — `{ collateral, debt, ltv, healthFactor, idleAsset }` (decimal strings).
|
|
33189
|
+
*/
|
|
33190
|
+
async getPosition(query, config) {
|
|
33191
|
+
return this.request(
|
|
33192
|
+
this.withQuery("/leverage-yield/position", { vault: query.vault }),
|
|
33193
|
+
{ method: "GET" },
|
|
33194
|
+
LeverageYieldPositionSchema,
|
|
33195
|
+
config
|
|
33196
|
+
);
|
|
33197
|
+
}
|
|
33198
|
+
/**
|
|
33199
|
+
* Get the AAVE-only steady-state APR for the vault (goes negative when the LSD yield is the alpha).
|
|
33200
|
+
*
|
|
33201
|
+
* @returns `Result<LeverageYieldAprV2>` — RAY-denominated rates as decimal strings.
|
|
33202
|
+
*/
|
|
33203
|
+
async getApr(query, config) {
|
|
33204
|
+
return this.request(
|
|
33205
|
+
this.withQuery("/leverage-yield/apr", { vault: query.vault }),
|
|
33206
|
+
{ method: "GET" },
|
|
33207
|
+
LeverageYieldAprSchema,
|
|
33208
|
+
config
|
|
33209
|
+
);
|
|
33210
|
+
}
|
|
33211
|
+
/**
|
|
33212
|
+
* Get the honest combined AAVE + LSD effective APR for the vault.
|
|
33213
|
+
*
|
|
33214
|
+
* @returns `Result<LeverageYieldEffectiveAprV2>` — includes `effectiveNetAprRay` (the headline number).
|
|
33215
|
+
*/
|
|
33216
|
+
async getEffectiveApr(query, config) {
|
|
33217
|
+
return this.request(
|
|
33218
|
+
this.withQuery("/leverage-yield/apr/effective", { vault: query.vault }),
|
|
33219
|
+
{ method: "GET" },
|
|
33220
|
+
LeverageYieldEffectiveAprSchema,
|
|
33221
|
+
config
|
|
33222
|
+
);
|
|
33223
|
+
}
|
|
33224
|
+
/**
|
|
33225
|
+
* Get the off-chain LSD staking-APR snapshot for the vault's underlying asset.
|
|
33226
|
+
*
|
|
33227
|
+
* @returns `Result<LeverageYieldLsdAprV2>` — `{ aprRay, label, stale }`.
|
|
33228
|
+
*/
|
|
33229
|
+
async getLsdApr(query, config) {
|
|
33230
|
+
return this.request(
|
|
33231
|
+
this.withQuery("/leverage-yield/apr/lsd", { vault: query.vault }),
|
|
33232
|
+
{ method: "GET" },
|
|
33233
|
+
LeverageYieldLsdAprSchema,
|
|
33234
|
+
config
|
|
33235
|
+
);
|
|
33236
|
+
}
|
|
33237
|
+
/**
|
|
33238
|
+
* Get the total assets managed by the vault.
|
|
33239
|
+
*
|
|
33240
|
+
* @returns `Result<VaultTotalAssetsResponseV2>` — `{ totalAssets }` (decimal string).
|
|
33241
|
+
*/
|
|
33242
|
+
async getTotalAssets(query, config) {
|
|
33243
|
+
return this.request(
|
|
33244
|
+
this.withQuery("/leverage-yield/total-assets", { vault: query.vault }),
|
|
33245
|
+
{ method: "GET" },
|
|
33246
|
+
VaultTotalAssetsResponseSchema,
|
|
33247
|
+
config
|
|
33248
|
+
);
|
|
33249
|
+
}
|
|
33250
|
+
/**
|
|
33251
|
+
* Preview the shares minted for depositing `assets` into the vault (ERC-4626 `previewDeposit`).
|
|
33252
|
+
*
|
|
33253
|
+
* @returns `Result<PreviewDepositResponseV2>` — `{ shares }` (decimal string).
|
|
33254
|
+
*/
|
|
33255
|
+
async previewDeposit(query, config) {
|
|
33256
|
+
return this.request(
|
|
33257
|
+
this.withQuery("/leverage-yield/preview/deposit", { vault: query.vault, assets: query.assets }),
|
|
33258
|
+
{ method: "GET" },
|
|
33259
|
+
PreviewDepositResponseSchema,
|
|
33260
|
+
config
|
|
33261
|
+
);
|
|
33262
|
+
}
|
|
33263
|
+
/**
|
|
33264
|
+
* Preview the shares burned to withdraw `assets` from the vault (ERC-4626 `previewWithdraw`).
|
|
33265
|
+
*
|
|
33266
|
+
* @returns `Result<PreviewWithdrawResponseV2>` — `{ shares }` (decimal string).
|
|
33267
|
+
*/
|
|
33268
|
+
async previewWithdraw(query, config) {
|
|
33269
|
+
return this.request(
|
|
33270
|
+
this.withQuery("/leverage-yield/preview/withdraw", { vault: query.vault, assets: query.assets }),
|
|
33271
|
+
{ method: "GET" },
|
|
33272
|
+
PreviewWithdrawResponseSchema,
|
|
33273
|
+
config
|
|
33274
|
+
);
|
|
33275
|
+
}
|
|
33276
|
+
/**
|
|
33277
|
+
* Preview the assets returned for redeeming `shares` from the vault (ERC-4626 `previewRedeem`).
|
|
33278
|
+
*
|
|
33279
|
+
* @returns `Result<PreviewRedeemResponseV2>` — `{ assets }` (decimal string).
|
|
33280
|
+
*/
|
|
33281
|
+
async previewRedeem(query, config) {
|
|
33282
|
+
return this.request(
|
|
33283
|
+
this.withQuery("/leverage-yield/preview/redeem", { vault: query.vault, shares: query.shares }),
|
|
33284
|
+
{ method: "GET" },
|
|
33285
|
+
PreviewRedeemResponseSchema,
|
|
33286
|
+
config
|
|
33287
|
+
);
|
|
33288
|
+
}
|
|
33289
|
+
/**
|
|
33290
|
+
* Get an owner's vault share (lsoda*) balance.
|
|
33291
|
+
*
|
|
33292
|
+
* @returns `Result<ShareBalanceResponseV2>` — `{ balance }` (decimal string).
|
|
33293
|
+
*/
|
|
33294
|
+
async getShareBalance(query, config) {
|
|
33295
|
+
return this.request(
|
|
33296
|
+
this.withQuery("/leverage-yield/share-balance", { vault: query.vault, owner: query.owner }),
|
|
33297
|
+
{ method: "GET" },
|
|
33298
|
+
ShareBalanceResponseSchema,
|
|
33299
|
+
config
|
|
33300
|
+
);
|
|
33301
|
+
}
|
|
33302
|
+
/**
|
|
33303
|
+
* Get an owner's RAW ERC-4626 `maxWithdraw` — NOT dust-trimmed, unlike the SDK-local
|
|
33304
|
+
* `sodax.leverageYield.getMaxWithdrawForUser`. Apply a margin before using it as a withdraw amount.
|
|
33305
|
+
*
|
|
33306
|
+
* @returns `Result<MaxWithdrawResponseV2>` — `{ maxWithdraw }` (decimal string).
|
|
33307
|
+
*/
|
|
33308
|
+
async getMaxWithdraw(query, config) {
|
|
33309
|
+
return this.request(
|
|
33310
|
+
this.withQuery("/leverage-yield/max-withdraw", { vault: query.vault, owner: query.owner }),
|
|
33311
|
+
{ method: "GET" },
|
|
33312
|
+
MaxWithdrawResponseSchema,
|
|
33313
|
+
config
|
|
33314
|
+
);
|
|
33315
|
+
}
|
|
33316
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
33317
|
+
// Quote · deadline
|
|
33318
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
33319
|
+
/**
|
|
33320
|
+
* Quote a swap-style deposit: any solver-supported `tokenSrc` → the vault's lsoda* shares.
|
|
33321
|
+
* Pass `query.includeTxData = true` to also build the unsigned create-intent tx (`srcAddress`
|
|
33322
|
+
* required in the body then).
|
|
33323
|
+
*
|
|
33324
|
+
* @returns `Result<QuoteResponseV2>` — `quotedAmount` (shares) and optional `txData`.
|
|
33325
|
+
*/
|
|
33326
|
+
async getDepositQuote(body, query, config) {
|
|
33327
|
+
const endpoint = query?.includeTxData ? "/leverage-yield/quote/deposit?includeTxData=true" : "/leverage-yield/quote/deposit";
|
|
33328
|
+
const txSchema = swapsApi.rawTxSchemaForChainKey(body.tokenSrcChainKey);
|
|
33329
|
+
return this.request(
|
|
33330
|
+
endpoint,
|
|
33331
|
+
{ method: "POST", body: toJsonBody(body) },
|
|
33332
|
+
swapsApi.makeQuoteResponseSchema(txSchema),
|
|
33333
|
+
config
|
|
33334
|
+
);
|
|
33335
|
+
}
|
|
33336
|
+
/**
|
|
33337
|
+
* Quote a swap-style withdraw: the vault's lsoda* shares → any solver-supported `tokenDst`.
|
|
33338
|
+
* Pass `query.includeTxData = true` to also build the unsigned tx (signed on `srcChainKey`;
|
|
33339
|
+
* `srcAddress`/`dstAddress` required in the body then).
|
|
33340
|
+
*
|
|
33341
|
+
* @returns `Result<QuoteResponseV2>` — `quotedAmount` (output token) and optional `txData`.
|
|
33342
|
+
*/
|
|
33343
|
+
async getWithdrawQuote(body, query, config) {
|
|
33344
|
+
const endpoint = query?.includeTxData ? "/leverage-yield/quote/withdraw?includeTxData=true" : "/leverage-yield/quote/withdraw";
|
|
33345
|
+
const txSchema = swapsApi.rawTxSchemaForChainKey(body.srcChainKey);
|
|
33346
|
+
return this.request(
|
|
33347
|
+
endpoint,
|
|
33348
|
+
{ method: "POST", body: toJsonBody(body) },
|
|
33349
|
+
swapsApi.makeQuoteResponseSchema(txSchema),
|
|
33350
|
+
config
|
|
33351
|
+
);
|
|
33352
|
+
}
|
|
33353
|
+
/**
|
|
33354
|
+
* Compute a deposit/withdraw deadline (hub timestamp + `offsetSeconds`, default 300s).
|
|
33355
|
+
*
|
|
33356
|
+
* @returns `Result<DeadlineResponseV2>` — unix-seconds deadline (decimal string).
|
|
33357
|
+
*/
|
|
33358
|
+
async getDeadline(query, config) {
|
|
33359
|
+
const params = {};
|
|
33360
|
+
if (query?.offsetSeconds !== void 0) params.offsetSeconds = String(query.offsetSeconds);
|
|
33361
|
+
return this.request(
|
|
33362
|
+
this.withQuery("/leverage-yield/deadline", params),
|
|
33363
|
+
{ method: "GET" },
|
|
33364
|
+
swapsApi.DeadlineResponseSchema,
|
|
33365
|
+
config
|
|
33366
|
+
);
|
|
33367
|
+
}
|
|
33368
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
33369
|
+
// Deposit allowance · approve · create intent (deposit / withdraw)
|
|
33370
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
33371
|
+
/**
|
|
33372
|
+
* Check whether the deposit input-token allowance is already sufficient for the intent.
|
|
33373
|
+
* (Withdraw needs no spoke allowance — it spends lsoda* from the hub wallet.)
|
|
33374
|
+
*
|
|
33375
|
+
* @returns `Result<AllowanceCheckResponseV2>` — `{ valid }`.
|
|
33376
|
+
*/
|
|
33377
|
+
async checkAllowance(body, config) {
|
|
33378
|
+
return this.request(
|
|
33379
|
+
"/leverage-yield/allowance/check",
|
|
33380
|
+
{ method: "POST", body: toJsonBody(body) },
|
|
33381
|
+
swapsApi.AllowanceCheckResponseSchema,
|
|
33382
|
+
config
|
|
33383
|
+
);
|
|
33384
|
+
}
|
|
33385
|
+
/**
|
|
33386
|
+
* Build an unsigned token-approval transaction for the deposit input token.
|
|
33387
|
+
*
|
|
33388
|
+
* @returns `Result<ApproveResponseV2>` — `{ tx }` (chain-specific unsigned tx).
|
|
33389
|
+
*/
|
|
33390
|
+
async approve(body, config) {
|
|
33391
|
+
const txSchema = swapsApi.rawTxSchemaForChainKey(body.srcChainKey);
|
|
33392
|
+
return this.request(
|
|
33393
|
+
"/leverage-yield/approve",
|
|
33394
|
+
{ method: "POST", body: toJsonBody(body) },
|
|
33395
|
+
swapsApi.makeApproveResponseSchema(txSchema),
|
|
33396
|
+
config
|
|
33397
|
+
);
|
|
33398
|
+
}
|
|
33399
|
+
/**
|
|
33400
|
+
* Build an unsigned deposit create-intent transaction (any token → lsoda* shares).
|
|
33401
|
+
*
|
|
33402
|
+
* @returns `Result<CreateIntentResponseV2>` — `{ tx, intent, relayData }`.
|
|
33403
|
+
*/
|
|
33404
|
+
async createDepositIntent(body, config) {
|
|
33405
|
+
const txSchema = swapsApi.rawTxSchemaForChainKey(body.srcChainKey);
|
|
33406
|
+
return this.request(
|
|
33407
|
+
"/leverage-yield/intents/deposit",
|
|
33408
|
+
{ method: "POST", body: toJsonBody(body) },
|
|
33409
|
+
swapsApi.makeCreateIntentResponseSchema(txSchema),
|
|
33410
|
+
config
|
|
33411
|
+
);
|
|
33412
|
+
}
|
|
33413
|
+
/**
|
|
33414
|
+
* Build an unsigned withdraw create-intent transaction (lsoda* shares → any token). The backend
|
|
33415
|
+
* sets `hubWalletSwap` internally so the swap spends the lsoda* held in the user's hub wallet.
|
|
33416
|
+
*
|
|
33417
|
+
* @returns `Result<CreateIntentResponseV2>` — `{ tx, intent, relayData }`.
|
|
33418
|
+
*/
|
|
33419
|
+
async createWithdrawIntent(body, config) {
|
|
33420
|
+
const txSchema = swapsApi.rawTxSchemaForChainKey(body.srcChainKey);
|
|
33421
|
+
return this.request(
|
|
33422
|
+
"/leverage-yield/intents/withdraw",
|
|
33423
|
+
{ method: "POST", body: toJsonBody(body) },
|
|
33424
|
+
swapsApi.makeCreateIntentResponseSchema(txSchema),
|
|
33425
|
+
config
|
|
33426
|
+
);
|
|
33427
|
+
}
|
|
33428
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
33429
|
+
// Intent lifecycle: submit · status · cancel · hash · packet · extra-data
|
|
33430
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
33431
|
+
/**
|
|
33432
|
+
* Submit the broadcast intent tx to the relay.
|
|
33433
|
+
*
|
|
33434
|
+
* @returns `Result<SubmitIntentResponseV2>` — `{ result }` (opaque relay response).
|
|
33435
|
+
*/
|
|
33436
|
+
async submitIntent(body, config) {
|
|
33437
|
+
return this.request(
|
|
33438
|
+
"/leverage-yield/intents/submit",
|
|
33439
|
+
{ method: "POST", body: toJsonBody(body) },
|
|
33440
|
+
swapsApi.SubmitIntentResponseSchema,
|
|
33441
|
+
config
|
|
33442
|
+
);
|
|
33443
|
+
}
|
|
33444
|
+
/**
|
|
33445
|
+
* Poll the solver for intent execution status.
|
|
33446
|
+
*
|
|
33447
|
+
* @returns `Result<StatusResponseV2>` — `{ status, fillTxHash? }`.
|
|
33448
|
+
*/
|
|
33449
|
+
async getStatus(body, config) {
|
|
33450
|
+
return this.request(
|
|
33451
|
+
"/leverage-yield/intents/status",
|
|
33452
|
+
{ method: "POST", body: toJsonBody(body) },
|
|
33453
|
+
swapsApi.StatusResponseSchema,
|
|
33454
|
+
config
|
|
33455
|
+
);
|
|
33456
|
+
}
|
|
33457
|
+
/**
|
|
33458
|
+
* Build an unsigned cancel-intent transaction. The `intent` field carries `bigint` numerics —
|
|
33459
|
+
* {@link toJsonBody} serializes them to decimal strings.
|
|
33460
|
+
*
|
|
33461
|
+
* @returns `Result<CancelIntentResponseV2>` — `{ tx }`.
|
|
33462
|
+
*/
|
|
33463
|
+
async cancelIntent(body, config) {
|
|
33464
|
+
const txSchema = swapsApi.rawTxSchemaForChainKey(body.srcChainKey);
|
|
33465
|
+
return this.request(
|
|
33466
|
+
"/leverage-yield/intents/cancel",
|
|
33467
|
+
{ method: "POST", body: toJsonBody({ ...body, intent: _LeverageYieldApiService.toWireIntent(body.intent) }) },
|
|
33468
|
+
swapsApi.makeCancelIntentResponseSchema(txSchema),
|
|
33469
|
+
config
|
|
33470
|
+
);
|
|
33471
|
+
}
|
|
33472
|
+
/**
|
|
33473
|
+
* Compute the keccak256 hash of an Intent struct. The `intent` field carries `bigint` numerics.
|
|
33474
|
+
*
|
|
33475
|
+
* @returns `Result<IntentHashResponseV2>` — `{ hash }`.
|
|
33476
|
+
*/
|
|
33477
|
+
async getIntentHash(body, config) {
|
|
33478
|
+
return this.request(
|
|
33479
|
+
"/leverage-yield/intents/hash",
|
|
33480
|
+
{ method: "POST", body: toJsonBody({ ...body, intent: _LeverageYieldApiService.toWireIntent(body.intent) }) },
|
|
33481
|
+
swapsApi.IntentHashResponseSchema,
|
|
33482
|
+
config
|
|
33483
|
+
);
|
|
33484
|
+
}
|
|
33485
|
+
/**
|
|
33486
|
+
* Long-poll the relayer until the fill packet lands on the destination chain.
|
|
33487
|
+
*
|
|
33488
|
+
* @returns `Result<IntentPacketResponseV2>` — delivered packet data.
|
|
33489
|
+
*/
|
|
33490
|
+
async getSolvedIntentPacket(body, config) {
|
|
33491
|
+
return this.request(
|
|
33492
|
+
"/leverage-yield/intents/packet",
|
|
33493
|
+
{ method: "POST", body: toJsonBody(body) },
|
|
33494
|
+
swapsApi.IntentPacketResponseSchema,
|
|
33495
|
+
config
|
|
33496
|
+
);
|
|
33497
|
+
}
|
|
33498
|
+
/**
|
|
33499
|
+
* Recover the relay extra data needed by `/leverage-yield/intents/submit`. Provide EITHER
|
|
33500
|
+
* `txHash` OR `intent` (whose `bigint` numerics {@link toJsonBody} serializes).
|
|
33501
|
+
*
|
|
33502
|
+
* @returns `Result<IntentExtraDataResponseV2>` — `{ address, payload }`.
|
|
33503
|
+
*/
|
|
33504
|
+
async getIntentSubmitTxExtraData(body, config) {
|
|
33505
|
+
const normalized = body.intent ? { ...body, intent: _LeverageYieldApiService.toWireIntent(body.intent) } : body;
|
|
33506
|
+
return this.request(
|
|
33507
|
+
"/leverage-yield/intents/extra-data",
|
|
33508
|
+
{ method: "POST", body: toJsonBody(normalized) },
|
|
33509
|
+
swapsApi.RelayExtraDataResponseSchema,
|
|
33510
|
+
config
|
|
33511
|
+
);
|
|
33512
|
+
}
|
|
33513
|
+
/**
|
|
33514
|
+
* Get the on-chain fill state for an intent by its hub-chain tx hash.
|
|
33515
|
+
*
|
|
33516
|
+
* @returns `Result<IntentStateV2>` — `{ exists, remainingInput, receivedOutput, pendingPayment }`.
|
|
33517
|
+
*/
|
|
33518
|
+
async getFilledIntent(txHash, config) {
|
|
33519
|
+
return this.request(
|
|
33520
|
+
`/leverage-yield/intents/${txHash}/fill`,
|
|
33521
|
+
{ method: "GET" },
|
|
33522
|
+
swapsApi.IntentStateSchema,
|
|
33523
|
+
config
|
|
33524
|
+
);
|
|
33525
|
+
}
|
|
33526
|
+
/**
|
|
33527
|
+
* Look up an Intent struct by its hub-chain creation tx hash.
|
|
33528
|
+
*
|
|
33529
|
+
* @returns `Result<GetIntentResponseV2>` — the decoded intent (bigint fields as decimal strings).
|
|
33530
|
+
*/
|
|
33531
|
+
async getIntent(txHash, config) {
|
|
33532
|
+
return this.request(`/leverage-yield/intents/${txHash}`, { method: "GET" }, swapsApi.IntentResponseSchema, config);
|
|
33533
|
+
}
|
|
33534
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
33535
|
+
// Gas · fees
|
|
33536
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
33537
|
+
/**
|
|
33538
|
+
* Estimate gas for a raw transaction on a spoke chain.
|
|
33539
|
+
*
|
|
33540
|
+
* @returns `Result<GasEstimateResponseV2>` — `{ gas }` (chain-specific shape).
|
|
33541
|
+
*/
|
|
33542
|
+
async estimateGas(body, config) {
|
|
33543
|
+
return this.request(
|
|
33544
|
+
"/leverage-yield/gas/estimate",
|
|
33545
|
+
{ method: "POST", body: toJsonBody(body) },
|
|
33546
|
+
swapsApi.GasEstimateResponseSchema,
|
|
33547
|
+
config
|
|
33548
|
+
);
|
|
33549
|
+
}
|
|
33550
|
+
/**
|
|
33551
|
+
* Compute the partner fee for a given input amount.
|
|
33552
|
+
*
|
|
33553
|
+
* @returns `Result<FeeResponseV2>` — `{ fee }` (decimal string).
|
|
33554
|
+
*/
|
|
33555
|
+
async getPartnerFee(query, config) {
|
|
33556
|
+
return this.request(
|
|
33557
|
+
this.withQuery("/leverage-yield/fees/partner", { amount: query.amount }),
|
|
33558
|
+
{ method: "GET" },
|
|
33559
|
+
swapsApi.FeeResponseSchema,
|
|
33560
|
+
config
|
|
33561
|
+
);
|
|
33562
|
+
}
|
|
33563
|
+
/**
|
|
33564
|
+
* Compute the protocol (solver) fee for a given input amount.
|
|
33565
|
+
*
|
|
33566
|
+
* @returns `Result<FeeResponseV2>` — `{ fee }` (decimal string).
|
|
33567
|
+
*/
|
|
33568
|
+
async getSolverFee(query, config) {
|
|
33569
|
+
return this.request(
|
|
33570
|
+
this.withQuery("/leverage-yield/fees/solver", { amount: query.amount }),
|
|
33571
|
+
{ method: "GET" },
|
|
33572
|
+
swapsApi.FeeResponseSchema,
|
|
33573
|
+
config
|
|
33574
|
+
);
|
|
33575
|
+
}
|
|
33576
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
33577
|
+
// Submit-tx state machine
|
|
33578
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
33579
|
+
/**
|
|
33580
|
+
* Submit a vault-swap transaction to be processed (relay, post-execution, etc.). The `intent`
|
|
33581
|
+
* field carries `bigint` numerics — {@link toJsonBody} serializes them. Idempotent on
|
|
33582
|
+
* `(txHash, srcChainKey)`.
|
|
33583
|
+
*
|
|
33584
|
+
* @returns `Result<SubmitTxResponseV2>` — `{ success, data: { status, message } }`.
|
|
33585
|
+
*/
|
|
33586
|
+
async submitTx(body, config) {
|
|
33587
|
+
return this.request(
|
|
33588
|
+
"/leverage-yield/submit-tx",
|
|
33589
|
+
{ method: "POST", body: toJsonBody({ ...body, intent: _LeverageYieldApiService.toWireIntent(body.intent) }) },
|
|
33590
|
+
swapsApi.SubmitTxResponseSchema,
|
|
33591
|
+
config
|
|
33592
|
+
);
|
|
33593
|
+
}
|
|
33594
|
+
/**
|
|
33595
|
+
* Get the processing status of a submitted vault-swap transaction by `(txHash, srcChainKey)`.
|
|
33596
|
+
*
|
|
33597
|
+
* @returns `Result<SubmitTxStatusResponseV2>` — `{ success, data }` (processing state).
|
|
33598
|
+
*/
|
|
33599
|
+
async getSubmitTxStatus(query, config) {
|
|
33600
|
+
return this.request(
|
|
33601
|
+
this.withQuery("/leverage-yield/submit-tx/status", { txHash: query.txHash, srcChainKey: query.srcChainKey }),
|
|
33602
|
+
{ method: "GET" },
|
|
33603
|
+
swapsApi.SubmitTxStatusResponseSchema,
|
|
33604
|
+
config
|
|
33605
|
+
);
|
|
33606
|
+
}
|
|
33607
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
33608
|
+
// Utilities (parity with SwapsApiService)
|
|
33609
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
33610
|
+
/**
|
|
33611
|
+
* Merge additional headers into the service's default header set. Existing keys are
|
|
33612
|
+
* overwritten; keys absent from `headers` are preserved.
|
|
33613
|
+
*/
|
|
33614
|
+
setHeaders(headers) {
|
|
33615
|
+
assignHeaders(this.headers, headers);
|
|
33616
|
+
}
|
|
33617
|
+
/** Return the base URL the service is currently pointing at. */
|
|
33618
|
+
getBaseURL() {
|
|
33619
|
+
return this.config.baseURL;
|
|
33620
|
+
}
|
|
33621
|
+
/**
|
|
33622
|
+
* Return the effective per-request timeout (ms).
|
|
33623
|
+
*
|
|
33624
|
+
* Callers bounding a request tighter than this need it as the CEILING, because a
|
|
33625
|
+
* `RequestOverrideConfig.timeout` REPLACES the service value rather than lowering it: an override
|
|
33626
|
+
* derived from a caller budget alone would raise the bound whenever that budget is the larger of the
|
|
33627
|
+
* two. `SubmitTxAttempt.requestTimeout` clamps against both (`min(budget left in the attempt, this)`).
|
|
33628
|
+
*/
|
|
33629
|
+
getTimeout() {
|
|
33630
|
+
return this.config.timeout;
|
|
33631
|
+
}
|
|
33632
|
+
};
|
|
32881
33633
|
|
|
32882
33634
|
// src/backendApi/BackendApiService.ts
|
|
32883
33635
|
var BackendApiService = class {
|
|
@@ -32885,6 +33637,7 @@ var BackendApiService = class {
|
|
|
32885
33637
|
swaps;
|
|
32886
33638
|
sponsoring;
|
|
32887
33639
|
bridge;
|
|
33640
|
+
leverageYield;
|
|
32888
33641
|
// resolved base-API config: the flat fields of the ApiConfig union with any `baseApiConfig` layered on
|
|
32889
33642
|
// top. `baseURL` is the gateway root; `basePath` is this service's own mount below it.
|
|
32890
33643
|
config;
|
|
@@ -32913,6 +33666,7 @@ var BackendApiService = class {
|
|
|
32913
33666
|
const swapsConfig2 = resolveSwapsApiConfig(config);
|
|
32914
33667
|
const sponsoringConfig = resolveSponsoringApiConfig(config);
|
|
32915
33668
|
const bridgeConfig2 = resolveBridgeApiConfig(config);
|
|
33669
|
+
const leverageYieldConfig2 = resolveLeverageYieldApiConfig(config);
|
|
32916
33670
|
const shortRoots = [
|
|
32917
33671
|
["backendApi", this.config.baseURL],
|
|
32918
33672
|
["api.swaps", swapsConfig2.baseURL],
|
|
@@ -32937,6 +33691,11 @@ var BackendApiService = class {
|
|
|
32937
33691
|
inheritedApiKeyBaseURLs: [DEFAULT_SPONSORING_API_ENDPOINT, this.config.baseURL]
|
|
32938
33692
|
});
|
|
32939
33693
|
this.bridge = new BridgeApiService(withApiKey(bridgeConfig2, options.apiKey), this.logger, overrideOptions);
|
|
33694
|
+
this.leverageYield = new LeverageYieldApiService(
|
|
33695
|
+
withApiKey(leverageYieldConfig2, options.apiKey),
|
|
33696
|
+
this.logger,
|
|
33697
|
+
overrideOptions
|
|
33698
|
+
);
|
|
32940
33699
|
}
|
|
32941
33700
|
/**
|
|
32942
33701
|
* Issue the HTTP call for a route.
|
|
@@ -33340,15 +34099,17 @@ var BackendApiService = class {
|
|
|
33340
34099
|
* without constructing a new service instance. Existing header keys are
|
|
33341
34100
|
* overwritten; keys absent from `headers` are preserved.
|
|
33342
34101
|
*
|
|
33343
|
-
* Headers also reach `swaps` and `
|
|
33344
|
-
* base-API credentials must not be forwarded to whatever origin it points at. Note
|
|
33345
|
-
* retargeted to another origin via `swapsApiConfig`, in which case a header set
|
|
34102
|
+
* Headers also reach `swaps`, `bridge` and `leverageYield`, but never `sponsoring`: it is configured
|
|
34103
|
+
* independently, so base-API credentials must not be forwarded to whatever origin it points at. Note
|
|
34104
|
+
* `swaps` can also be retargeted to another origin via `swapsApiConfig`, in which case a header set
|
|
34105
|
+
* here follows it.
|
|
33346
34106
|
*
|
|
33347
34107
|
* @param headers - Key-value pairs to add or overwrite in the default headers.
|
|
33348
34108
|
*/
|
|
33349
34109
|
setHeaders(headers) {
|
|
33350
34110
|
assignHeaders(this.headers, headers);
|
|
33351
34111
|
this.swaps.setHeaders(headers);
|
|
34112
|
+
this.leverageYield.setHeaders(headers);
|
|
33352
34113
|
this.bridge.setHeaders(headers);
|
|
33353
34114
|
}
|
|
33354
34115
|
/**
|
|
@@ -36290,7 +37051,7 @@ var AssetService = class {
|
|
|
36290
37051
|
ok: true,
|
|
36291
37052
|
value: {
|
|
36292
37053
|
tx: txResult.value,
|
|
36293
|
-
relayData: { address:
|
|
37054
|
+
relayData: { address: fromHubWallet, payload: data }
|
|
36294
37055
|
}
|
|
36295
37056
|
};
|
|
36296
37057
|
} catch (error) {
|
|
@@ -41574,7 +42335,9 @@ var PartnerFeeClaimService = class {
|
|
|
41574
42335
|
isEvmWalletProviderType(walletProvider),
|
|
41575
42336
|
"PartnerFeeClaimService only supports Evm (sonic) wallet provider"
|
|
41576
42337
|
);
|
|
41577
|
-
const txHash = await walletProvider.sendTransaction(rawTx
|
|
42338
|
+
const txHash = await walletProvider.sendTransaction(rawTx, {
|
|
42339
|
+
expectedChainId: getEvmViemChain(ChainKeys.SONIC_MAINNET).id
|
|
42340
|
+
});
|
|
41578
42341
|
return {
|
|
41579
42342
|
ok: true,
|
|
41580
42343
|
value: txHash
|
|
@@ -41769,7 +42532,9 @@ var PartnerFeeClaimService = class {
|
|
|
41769
42532
|
value: rawTx
|
|
41770
42533
|
};
|
|
41771
42534
|
}
|
|
41772
|
-
const txHash = await _params.walletProvider.sendTransaction(rawTx
|
|
42535
|
+
const txHash = await _params.walletProvider.sendTransaction(rawTx, {
|
|
42536
|
+
expectedChainId: getEvmViemChain(ChainKeys.SONIC_MAINNET).id
|
|
42537
|
+
});
|
|
41773
42538
|
return {
|
|
41774
42539
|
ok: true,
|
|
41775
42540
|
value: txHash
|
|
@@ -41916,7 +42681,9 @@ var PartnerFeeClaimService = class {
|
|
|
41916
42681
|
value: rawTx
|
|
41917
42682
|
};
|
|
41918
42683
|
}
|
|
41919
|
-
const txHash = await _params.walletProvider.sendTransaction(rawTx
|
|
42684
|
+
const txHash = await _params.walletProvider.sendTransaction(rawTx, {
|
|
42685
|
+
expectedChainId: getEvmViemChain(ChainKeys.SONIC_MAINNET).id
|
|
42686
|
+
});
|
|
41920
42687
|
return {
|
|
41921
42688
|
ok: true,
|
|
41922
42689
|
value: txHash
|
|
@@ -42293,10 +43060,20 @@ var LeverageYieldService = class {
|
|
|
42293
43060
|
hubProvider;
|
|
42294
43061
|
config;
|
|
42295
43062
|
spoke;
|
|
42296
|
-
|
|
43063
|
+
backendApi;
|
|
43064
|
+
/**
|
|
43065
|
+
* Effective backend submit-tx flow (`leverageYield.useBackendSubmitTx`, default off). Read live off
|
|
43066
|
+
* `ConfigService`, like `config.leverageYieldPartnerFee`, so the config object and the behavior can
|
|
43067
|
+
* never disagree.
|
|
43068
|
+
*/
|
|
43069
|
+
get useBackendSubmitTx() {
|
|
43070
|
+
return this.config.leverageYieldUseBackendSubmitTx;
|
|
43071
|
+
}
|
|
43072
|
+
constructor({ hubProvider, config, spoke, backendApi }) {
|
|
42297
43073
|
this.hubProvider = hubProvider;
|
|
42298
43074
|
this.config = config;
|
|
42299
43075
|
this.spoke = spoke;
|
|
43076
|
+
this.backendApi = backendApi;
|
|
42300
43077
|
}
|
|
42301
43078
|
// ─── Registry ──────────────────────────────────────────────────────────
|
|
42302
43079
|
/** Returns the static registry of known leverage-yield vaults. */
|
|
@@ -42305,7 +43082,7 @@ var LeverageYieldService = class {
|
|
|
42305
43082
|
}
|
|
42306
43083
|
/** Looks up a vault by its `name` field. Returns `undefined` when not registered. */
|
|
42307
43084
|
getVault(name) {
|
|
42308
|
-
return this.listVaults().find((
|
|
43085
|
+
return this.listVaults().find((v12) => v12.name === name);
|
|
42309
43086
|
}
|
|
42310
43087
|
/**
|
|
42311
43088
|
* Looks up a registered vault by its on-chain proxy address (case-insensitive).
|
|
@@ -42313,7 +43090,7 @@ var LeverageYieldService = class {
|
|
|
42313
43090
|
*/
|
|
42314
43091
|
getVaultByAddress(address) {
|
|
42315
43092
|
const normalized = address.toLowerCase();
|
|
42316
|
-
return this.listVaults().find((
|
|
43093
|
+
return this.listVaults().find((v12) => v12.vault.toLowerCase() === normalized);
|
|
42317
43094
|
}
|
|
42318
43095
|
/**
|
|
42319
43096
|
* Resolves the intent `deadline`: returns the caller-supplied value verbatim, otherwise
|
|
@@ -42736,62 +43513,21 @@ var LeverageYieldService = class {
|
|
|
42736
43513
|
"vaultSwap",
|
|
42737
43514
|
async () => {
|
|
42738
43515
|
try {
|
|
42739
|
-
const timeout = _params.timeout;
|
|
42740
43516
|
const createIntentResult = await this.createVaultIntent(_params);
|
|
42741
43517
|
if (!createIntentResult.ok) {
|
|
42742
43518
|
return { ok: false, error: createIntentResult.error };
|
|
42743
43519
|
}
|
|
42744
|
-
const
|
|
42745
|
-
const
|
|
42746
|
-
|
|
42747
|
-
|
|
42748
|
-
|
|
42749
|
-
|
|
42750
|
-
|
|
42751
|
-
|
|
42752
|
-
|
|
42753
|
-
};
|
|
42754
|
-
}
|
|
42755
|
-
let dstIntentTxHash;
|
|
42756
|
-
if (isHubChainKeyType(srcChainKey)) {
|
|
42757
|
-
dstIntentTxHash = spokeTxHash;
|
|
42758
|
-
} else {
|
|
42759
|
-
const packet = await relayTxAndWaitPacket({
|
|
42760
|
-
srcTxHash: spokeTxHash,
|
|
42761
|
-
data: relayData,
|
|
42762
|
-
chainKey: srcChainKey,
|
|
42763
|
-
relayerApiEndpoint: this.config.relay.relayerApiEndpoint,
|
|
42764
|
-
timeout
|
|
42765
|
-
});
|
|
42766
|
-
if (!packet.ok) {
|
|
42767
|
-
return {
|
|
42768
|
-
ok: false,
|
|
42769
|
-
error: mapRelayFailure(packet.error, { feature: "leverageYield", ...baseCtx })
|
|
42770
|
-
};
|
|
42771
|
-
}
|
|
42772
|
-
dstIntentTxHash = packet.value.dst_tx_hash;
|
|
42773
|
-
}
|
|
42774
|
-
const postExecResult = await this.notifySolver({
|
|
42775
|
-
intent_tx_hash: dstIntentTxHash
|
|
42776
|
-
});
|
|
42777
|
-
if (!postExecResult.ok) {
|
|
42778
|
-
return { ok: false, error: postExecResult.error };
|
|
43520
|
+
const created = createIntentResult.value;
|
|
43521
|
+
const timeoutMs = resolveTimeoutMs(_params.timeout, DEFAULT_RELAY_TX_TIMEOUT);
|
|
43522
|
+
if (this.useBackendSubmitTx) {
|
|
43523
|
+
const submitted = await this.submitTx(_params, created, createSubmitTxAttempt(timeoutMs));
|
|
43524
|
+
if (submitted.ok) return submitted;
|
|
43525
|
+
this.config.logger.warn(
|
|
43526
|
+
"[leverageYield] backend submit-tx did not complete; falling back to the client-side relay",
|
|
43527
|
+
{ error: submitted.error }
|
|
43528
|
+
);
|
|
42779
43529
|
}
|
|
42780
|
-
return
|
|
42781
|
-
ok: true,
|
|
42782
|
-
value: {
|
|
42783
|
-
solverExecutionResponse: postExecResult.value,
|
|
42784
|
-
intent,
|
|
42785
|
-
intentDeliveryInfo: {
|
|
42786
|
-
srcChainKey,
|
|
42787
|
-
srcTxHash: spokeTxHash,
|
|
42788
|
-
srcAddress: params.srcAddress,
|
|
42789
|
-
dstChainKey: params.dstChainKey,
|
|
42790
|
-
dstTxHash: dstIntentTxHash,
|
|
42791
|
-
dstAddress: params.dstAddress
|
|
42792
|
-
}
|
|
42793
|
-
}
|
|
42794
|
-
};
|
|
43530
|
+
return this.fallbackVaultSwapSteps(_params, created, timeoutMs);
|
|
42795
43531
|
} catch (error) {
|
|
42796
43532
|
if (isLeverageYieldSwapError(error)) return { ok: false, error };
|
|
42797
43533
|
return {
|
|
@@ -42819,6 +43555,129 @@ var LeverageYieldService = class {
|
|
|
42819
43555
|
}
|
|
42820
43556
|
);
|
|
42821
43557
|
}
|
|
43558
|
+
/**
|
|
43559
|
+
* Client-side vault-swap completion (the default path): verify the broadcast intent tx landed,
|
|
43560
|
+
* relay it to the hub (Sonic) — or use it directly when the source IS the hub — then notify the
|
|
43561
|
+
* solver via {@link LeverageYieldService.notifySolver} and build the {@link VaultSwapResponse}.
|
|
43562
|
+
* Extracted from `vaultSwap()` so the opt-in backend 2-step path ({@link LeverageYieldService.submitTx})
|
|
43563
|
+
* can fall back to it on any non-success. Leverage-yield copy of `SwapService.fallbackSwapSteps`.
|
|
43564
|
+
*/
|
|
43565
|
+
async fallbackVaultSwapSteps(_params, created, timeoutMs) {
|
|
43566
|
+
const { params } = _params;
|
|
43567
|
+
const srcChainKey = params.srcChainKey;
|
|
43568
|
+
const baseCtx = { srcChainKey, dstChainKey: params.dstChainKey, action: "vaultSwap" };
|
|
43569
|
+
const { tx: spokeTxHash, intent, relayData } = created;
|
|
43570
|
+
const verifyTxHashResult = await this.spoke.verifyTxHash({
|
|
43571
|
+
txHash: spokeTxHash,
|
|
43572
|
+
chainKey: srcChainKey
|
|
43573
|
+
});
|
|
43574
|
+
if (!verifyTxHashResult.ok) {
|
|
43575
|
+
return { ok: false, error: verifyFailed("leverageYield", verifyTxHashResult.error, baseCtx) };
|
|
43576
|
+
}
|
|
43577
|
+
let dstIntentTxHash;
|
|
43578
|
+
if (isHubChainKeyType(srcChainKey)) {
|
|
43579
|
+
dstIntentTxHash = spokeTxHash;
|
|
43580
|
+
} else {
|
|
43581
|
+
const packet = await relayTxAndWaitPacket({
|
|
43582
|
+
srcTxHash: spokeTxHash,
|
|
43583
|
+
data: relayData,
|
|
43584
|
+
chainKey: srcChainKey,
|
|
43585
|
+
relayerApiEndpoint: this.config.relay.relayerApiEndpoint,
|
|
43586
|
+
// The caller's full `timeout`, starting HERE — whether this runs as the only path or as the
|
|
43587
|
+
// backend's fallback, so a stalled backend attempt cannot shorten the relay wait. The floor
|
|
43588
|
+
// covers a sub-floor caller `timeout`: `relayTxAndWaitPacket` SUBMITS before `timeout` bounds
|
|
43589
|
+
// anything, so a zero budget would strand an already-landed tx unrelayed.
|
|
43590
|
+
timeout: Math.max(timeoutMs, RELAY_FALLBACK_FLOOR_MS)
|
|
43591
|
+
});
|
|
43592
|
+
if (!packet.ok) {
|
|
43593
|
+
return { ok: false, error: mapRelayFailure(packet.error, { feature: "leverageYield", ...baseCtx }) };
|
|
43594
|
+
}
|
|
43595
|
+
dstIntentTxHash = packet.value.dst_tx_hash;
|
|
43596
|
+
}
|
|
43597
|
+
const postExecResult = await this.notifySolver({
|
|
43598
|
+
intent_tx_hash: dstIntentTxHash
|
|
43599
|
+
});
|
|
43600
|
+
if (!postExecResult.ok) {
|
|
43601
|
+
return { ok: false, error: postExecResult.error };
|
|
43602
|
+
}
|
|
43603
|
+
return {
|
|
43604
|
+
ok: true,
|
|
43605
|
+
value: {
|
|
43606
|
+
solverExecutionResponse: postExecResult.value,
|
|
43607
|
+
intent,
|
|
43608
|
+
intentDeliveryInfo: {
|
|
43609
|
+
srcChainKey,
|
|
43610
|
+
srcTxHash: spokeTxHash,
|
|
43611
|
+
srcAddress: params.srcAddress,
|
|
43612
|
+
dstChainKey: params.dstChainKey,
|
|
43613
|
+
dstTxHash: dstIntentTxHash,
|
|
43614
|
+
dstAddress: params.dstAddress
|
|
43615
|
+
}
|
|
43616
|
+
}
|
|
43617
|
+
};
|
|
43618
|
+
}
|
|
43619
|
+
/**
|
|
43620
|
+
* Backend 2-step vault-swap path (opt-in via `leverageYield.useBackendSubmitTx`): hand the
|
|
43621
|
+
* broadcast intent tx to the leverage-yield API (`POST /leverage-yield/submit-tx`); the backend
|
|
43622
|
+
* relays + post-executes server-side. Polls `getSubmitTxStatus` until `solved`, then reconstructs
|
|
43623
|
+
* the same {@link VaultSwapResponse} the client-side path returns.
|
|
43624
|
+
*
|
|
43625
|
+
* Never throws — returns `{ ok: false }` on any non-success (submit `!ok`, a 200 the backend did not
|
|
43626
|
+
* accept, terminal `failed` / abandoned, or poll timeout) so `vaultSwap()` falls back to
|
|
43627
|
+
* {@link LeverageYieldService.fallbackVaultSwapSteps}. Falling back is safe: re-relaying / re-posting
|
|
43628
|
+
* an already-processed vault swap is idempotent (the relay dedups the `executed` packet and the solver
|
|
43629
|
+
* re-affirms the intent — no double-fill), and load-bearing rather than belt-and-braces: the backend
|
|
43630
|
+
* keeps processing after this attempt gives up, so the fallback's relay can race the backend's own.
|
|
43631
|
+
*
|
|
43632
|
+
* The attempt itself — POST, budget clamps, status poll — is {@link runBackendSubmitTx}, shared with
|
|
43633
|
+
* swaps and bridge. What is leverage-yield-specific and lives here: the request body (including the
|
|
43634
|
+
* `operation` discriminator), the `solved` terminal status, the mapping to a
|
|
43635
|
+
* {@link VaultSwapResponse}, and the leverage-yield error taxonomy.
|
|
43636
|
+
*
|
|
43637
|
+
* `attempt` bounds this attempt alone — the POST and every status request draw on it, and the
|
|
43638
|
+
* client-side fallback holds a separate fresh `timeout`.
|
|
43639
|
+
*/
|
|
43640
|
+
async submitTx(_params, created, attempt) {
|
|
43641
|
+
const { params } = _params;
|
|
43642
|
+
const srcChainKey = params.srcChainKey;
|
|
43643
|
+
const baseCtx = { srcChainKey, dstChainKey: params.dstChainKey, action: "vaultSwap" };
|
|
43644
|
+
const { tx: spokeTxHash, intent, relayData } = created;
|
|
43645
|
+
try {
|
|
43646
|
+
const outcome = await runBackendSubmitTx({
|
|
43647
|
+
attempt,
|
|
43648
|
+
api: this.backendApi.leverageYield,
|
|
43649
|
+
body: {
|
|
43650
|
+
txHash: spokeTxHash,
|
|
43651
|
+
srcChainKey,
|
|
43652
|
+
walletAddress: params.srcAddress,
|
|
43653
|
+
intent,
|
|
43654
|
+
relayData: relayData.payload,
|
|
43655
|
+
// `withdraw` sets `hubWalletSwap: true` (spends the hub-wallet lsoda*); a plain deposit doesn't.
|
|
43656
|
+
operation: _params.hubWalletSwap ? "withdraw" : "deposit"
|
|
43657
|
+
},
|
|
43658
|
+
statusQuery: { txHash: spokeTxHash, srcChainKey },
|
|
43659
|
+
// A vault deposit/withdraw IS a solver swap, so terminal success is `solved` — not bridge's
|
|
43660
|
+
// `executed`.
|
|
43661
|
+
terminalStatus: "solved",
|
|
43662
|
+
onExecuted: (result) => result?.dstIntentTxHash && result.intent_hash ? {
|
|
43663
|
+
// Backend serializes the hex intent_hash as a plain string; brand it at the boundary.
|
|
43664
|
+
solverExecutionResponse: { answer: "OK", intent_hash: result.intent_hash },
|
|
43665
|
+
intent,
|
|
43666
|
+
intentDeliveryInfo: {
|
|
43667
|
+
srcChainKey,
|
|
43668
|
+
srcTxHash: spokeTxHash,
|
|
43669
|
+
srcAddress: params.srcAddress,
|
|
43670
|
+
dstChainKey: params.dstChainKey,
|
|
43671
|
+
dstTxHash: result.dstIntentTxHash,
|
|
43672
|
+
dstAddress: params.dstAddress
|
|
43673
|
+
}
|
|
43674
|
+
} : void 0
|
|
43675
|
+
});
|
|
43676
|
+
return outcome.ok ? { ok: true, value: outcome.value } : { ok: false, error: executionFailed("leverageYield", outcome.cause, baseCtx) };
|
|
43677
|
+
} catch (error) {
|
|
43678
|
+
return { ok: false, error: unknownFailed("leverageYield", error, baseCtx) };
|
|
43679
|
+
}
|
|
43680
|
+
}
|
|
42822
43681
|
/**
|
|
42823
43682
|
* Notifies the solver that the vault intent landed on the hub, triggering it to fill.
|
|
42824
43683
|
* Leverage-yield copy of the swap domain's `postExecution` — emits only
|
|
@@ -43830,7 +44689,8 @@ var Sodax = class {
|
|
|
43830
44689
|
this.leverageYield = new LeverageYieldService({
|
|
43831
44690
|
hubProvider: this.hubProvider,
|
|
43832
44691
|
config: this.config,
|
|
43833
|
-
spoke: this.spoke
|
|
44692
|
+
spoke: this.spoke,
|
|
44693
|
+
backendApi: this.backendApi
|
|
43834
44694
|
});
|
|
43835
44695
|
this.sponsoring = new SponsoringService({
|
|
43836
44696
|
config: this.config,
|
|
@@ -43961,6 +44821,7 @@ exports.IntentsAbi = IntentsAbi;
|
|
|
43961
44821
|
exports.LOOKUP_CODES = LOOKUP_CODES;
|
|
43962
44822
|
exports.LTV_PRECISION = LTV_PRECISION;
|
|
43963
44823
|
exports.LendingPoolService = LendingPoolService;
|
|
44824
|
+
exports.LeverageYieldApiService = LeverageYieldApiService;
|
|
43964
44825
|
exports.LeverageYieldService = LeverageYieldService;
|
|
43965
44826
|
exports.LockupMultiplier = LockupMultiplier;
|
|
43966
44827
|
exports.LockupPeriod = LockupPeriod;
|
|
@@ -44064,6 +44925,7 @@ exports.calculateHealthFactorFromBalances = calculateHealthFactorFromBalances;
|
|
|
44064
44925
|
exports.calculateHealthFactorFromBalancesBigUnits = calculateHealthFactorFromBalancesBigUnits;
|
|
44065
44926
|
exports.calculateLinearInterest = calculateLinearInterest;
|
|
44066
44927
|
exports.calculatePercentageFeeAmount = calculatePercentageFeeAmount;
|
|
44928
|
+
exports.canonicalizeBitcoinAddress = canonicalizeBitcoinAddress;
|
|
44067
44929
|
exports.clPoolAbi = clPoolAbi;
|
|
44068
44930
|
exports.clPoolManagerAbi = clPoolManagerAbi;
|
|
44069
44931
|
exports.clPositionManagerAbi = clPositionManagerAbi;
|
|
@@ -44086,6 +44948,7 @@ exports.dexPools = dexPools;
|
|
|
44086
44948
|
exports.encodeAddress = encodeAddress;
|
|
44087
44949
|
exports.encodeBtcPayloadToBytes = encodeBtcPayloadToBytes;
|
|
44088
44950
|
exports.encodeContractCalls = encodeContractCalls;
|
|
44951
|
+
exports.encodeTokenIdentifier = encodeTokenIdentifier;
|
|
44089
44952
|
exports.erc20Abi = erc20Abi;
|
|
44090
44953
|
exports.erc4626Abi = erc4626Abi;
|
|
44091
44954
|
exports.estimateBitcoinTxSize = estimateBitcoinTxSize;
|
|
@@ -44255,6 +45118,9 @@ exports.isSwapError = isSwapError;
|
|
|
44255
45118
|
exports.isSwapSupportedToken = isSwapSupportedToken;
|
|
44256
45119
|
exports.isUndefinedOrValidWalletProviderForChainKey = isUndefinedOrValidWalletProviderForChainKey;
|
|
44257
45120
|
exports.isUnifiedBnUSDMigrateParams = isUnifiedBnUSDMigrateParams;
|
|
45121
|
+
exports.isValidBitcoinAddress = isValidBitcoinAddress;
|
|
45122
|
+
exports.isValidInjectiveAddress = isValidInjectiveAddress;
|
|
45123
|
+
exports.isValidNearAccountId = isValidNearAccountId;
|
|
44258
45124
|
exports.isValidWalletProviderForChainKey = isValidWalletProviderForChainKey;
|
|
44259
45125
|
exports.kaiaSupportedTokens = kaiaSupportedTokens;
|
|
44260
45126
|
exports.leverageYieldConfig = leverageYieldConfig;
|