@sodax/sdk 2.0.0-rc.14 → 2.0.0-rc.16
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 +130 -72
- package/dist/index.d.cts +45 -6
- package/dist/index.d.ts +45 -6
- package/dist/index.mjs +130 -72
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -4201,7 +4201,7 @@ function isValidWalletProviderForChainKey(chainKey, walletProvider) {
|
|
|
4201
4201
|
}
|
|
4202
4202
|
|
|
4203
4203
|
// ../types/dist/index.js
|
|
4204
|
-
var CONFIG_VERSION =
|
|
4204
|
+
var CONFIG_VERSION = 214;
|
|
4205
4205
|
function isEvmSpokeChainConfig(value) {
|
|
4206
4206
|
return typeof value === "object" && value !== null && value.chain.type === "EVM" && value.chain.key !== HUB_CHAIN_KEY;
|
|
4207
4207
|
}
|
|
@@ -14731,6 +14731,8 @@ var RadfiProvider = class {
|
|
|
14731
14731
|
refreshToken = "";
|
|
14732
14732
|
constructor(config) {
|
|
14733
14733
|
this.config = config;
|
|
14734
|
+
this.accessToken = config.accessToken ?? "";
|
|
14735
|
+
this.refreshToken = config.refreshToken ?? "";
|
|
14734
14736
|
if (config.apiUrl.endsWith("/")) {
|
|
14735
14737
|
this.config.apiUrl = config.apiUrl.slice(0, -1);
|
|
14736
14738
|
}
|
|
@@ -14771,13 +14773,11 @@ var RadfiProvider = class {
|
|
|
14771
14773
|
try {
|
|
14772
14774
|
const { accessToken, refreshToken } = await this.refreshAccessToken(this.refreshToken);
|
|
14773
14775
|
this.setRadfiAccessToken(accessToken, refreshToken);
|
|
14774
|
-
console.log("[ensureRadfiAccessToken] token refreshed successfully");
|
|
14775
14776
|
return;
|
|
14776
14777
|
} catch (error) {
|
|
14777
14778
|
console.warn("[ensureRadfiAccessToken] refresh failed, falling back to full re-auth", error);
|
|
14778
14779
|
}
|
|
14779
14780
|
}
|
|
14780
|
-
console.log("[ensureRadfiAccessToken] performing full re-authentication (BIP322 sign)");
|
|
14781
14781
|
this.accessToken = "";
|
|
14782
14782
|
this.refreshToken = "";
|
|
14783
14783
|
await this.authenticateWithWallet(walletProvider);
|
|
@@ -14793,55 +14793,53 @@ var RadfiProvider = class {
|
|
|
14793
14793
|
method: "POST",
|
|
14794
14794
|
body: JSON.stringify(params)
|
|
14795
14795
|
});
|
|
14796
|
+
const body = await this.parseJsonBody(res, "Bound Exchange authentication failed");
|
|
14796
14797
|
if (!res.ok) {
|
|
14797
|
-
|
|
14798
|
-
throw new RadfiApiError(res.status, err, "Bound Exchange authentication failed");
|
|
14798
|
+
throw new RadfiApiError(res.status, body, "Bound Exchange authentication failed");
|
|
14799
14799
|
}
|
|
14800
|
-
return
|
|
14801
|
-
accessToken:
|
|
14802
|
-
refreshToken:
|
|
14803
|
-
tradingAddress:
|
|
14804
|
-
}
|
|
14800
|
+
return {
|
|
14801
|
+
accessToken: body.data?.accessToken ?? "",
|
|
14802
|
+
refreshToken: body.data?.refreshToken ?? "",
|
|
14803
|
+
tradingAddress: body.data?.tradingAddress ?? body.data?.wallet?.tradingAddress ?? ""
|
|
14804
|
+
};
|
|
14805
14805
|
}
|
|
14806
14806
|
async refreshAccessToken(refreshToken) {
|
|
14807
14807
|
const res = await this.request("/auth/refresh-token", {
|
|
14808
14808
|
method: "POST",
|
|
14809
14809
|
body: JSON.stringify({ refreshToken })
|
|
14810
14810
|
});
|
|
14811
|
+
const body = await this.parseJsonBody(res, "Token refresh failed");
|
|
14811
14812
|
if (!res.ok) {
|
|
14812
|
-
|
|
14813
|
-
throw new RadfiApiError(res.status, err, "Token refresh failed");
|
|
14813
|
+
throw new RadfiApiError(res.status, body, "Token refresh failed");
|
|
14814
14814
|
}
|
|
14815
|
-
return
|
|
14816
|
-
accessToken:
|
|
14817
|
-
refreshToken:
|
|
14818
|
-
}
|
|
14815
|
+
return {
|
|
14816
|
+
accessToken: body.data?.accessToken ?? "",
|
|
14817
|
+
refreshToken: body.data?.refreshToken ?? refreshToken
|
|
14818
|
+
};
|
|
14819
14819
|
}
|
|
14820
14820
|
async createTradingWallet(params, accessToken) {
|
|
14821
14821
|
const res = await this.request("/wallets", {
|
|
14822
14822
|
method: "POST",
|
|
14823
14823
|
headers: {
|
|
14824
|
-
Authorization: `Bearer ${
|
|
14824
|
+
Authorization: `Bearer ${this.resolveAuth(accessToken)}`
|
|
14825
14825
|
},
|
|
14826
14826
|
body: JSON.stringify(params)
|
|
14827
14827
|
});
|
|
14828
|
-
|
|
14829
|
-
|
|
14830
|
-
throw new RadfiApiError(res.status,
|
|
14828
|
+
const body = await this.parseJsonBody(res, "Failed to create trading wallet");
|
|
14829
|
+
if (!res.ok || !body.data) {
|
|
14830
|
+
throw new RadfiApiError(res.status, body, "Failed to create trading wallet");
|
|
14831
14831
|
}
|
|
14832
|
-
return
|
|
14832
|
+
return body.data;
|
|
14833
14833
|
}
|
|
14834
|
-
async getTradingWallet(userAddress
|
|
14834
|
+
async getTradingWallet(userAddress) {
|
|
14835
14835
|
const res = await this.request(`/wallets/details/${userAddress}`, {
|
|
14836
|
-
method: "GET"
|
|
14837
|
-
headers: accessToken ? { Authorization: `Bearer ${accessToken}` } : {}
|
|
14836
|
+
method: "GET"
|
|
14838
14837
|
});
|
|
14839
|
-
|
|
14840
|
-
|
|
14838
|
+
const body = await this.parseJsonBody(res, "Trading wallet not found");
|
|
14839
|
+
if (!res.ok || !body.data) {
|
|
14840
|
+
throw new RadfiApiError(res.status, body, "Trading wallet not found");
|
|
14841
14841
|
}
|
|
14842
|
-
|
|
14843
|
-
if (!data) throw new Error("Trading wallet not found");
|
|
14844
|
-
return data;
|
|
14842
|
+
return body.data;
|
|
14845
14843
|
}
|
|
14846
14844
|
async getBalance(address) {
|
|
14847
14845
|
if (!this.config.umsUrl) {
|
|
@@ -14855,12 +14853,12 @@ var RadfiProvider = class {
|
|
|
14855
14853
|
if (!res.ok) {
|
|
14856
14854
|
throw new Error("Failed to fetch wallet balance");
|
|
14857
14855
|
}
|
|
14858
|
-
const { data } = await
|
|
14856
|
+
const { data } = await this.parseJsonBody(res, "Failed to fetch wallet balance");
|
|
14859
14857
|
return {
|
|
14860
|
-
btcSatoshi: BigInt(data
|
|
14861
|
-
pendingSatoshi: BigInt(data
|
|
14862
|
-
externalPendingSatoshi: BigInt(data
|
|
14863
|
-
totalUtxos: Number(data
|
|
14858
|
+
btcSatoshi: BigInt(data?.btcSatoshi ?? "0"),
|
|
14859
|
+
pendingSatoshi: BigInt(data?.pendingSatoshi ?? "0"),
|
|
14860
|
+
externalPendingSatoshi: BigInt(data?.externalPendingSatoshi ?? "0"),
|
|
14861
|
+
totalUtxos: Number(data?.totalUtxos ?? 0)
|
|
14864
14862
|
};
|
|
14865
14863
|
}
|
|
14866
14864
|
async checkIfTradingWalletExists(userAddress) {
|
|
@@ -14876,7 +14874,7 @@ var RadfiProvider = class {
|
|
|
14876
14874
|
const res = await this.request("/sodax/transaction", {
|
|
14877
14875
|
method: "POST",
|
|
14878
14876
|
headers: {
|
|
14879
|
-
Authorization: `Bearer ${
|
|
14877
|
+
Authorization: `Bearer ${this.resolveAuth(accessToken)}`
|
|
14880
14878
|
},
|
|
14881
14879
|
body: JSON.stringify({
|
|
14882
14880
|
type: "sodax-withdraw",
|
|
@@ -14887,8 +14885,8 @@ var RadfiProvider = class {
|
|
|
14887
14885
|
}
|
|
14888
14886
|
})
|
|
14889
14887
|
});
|
|
14890
|
-
const body = await
|
|
14891
|
-
if (!res.ok || !body
|
|
14888
|
+
const body = await this.parseJsonBody(res, "Bound Exchange transaction request failed");
|
|
14889
|
+
if (!res.ok || !body.data) {
|
|
14892
14890
|
throw new RadfiApiError(res.status, body, "Bound Exchange transaction request failed");
|
|
14893
14891
|
}
|
|
14894
14892
|
return body.data;
|
|
@@ -14905,18 +14903,18 @@ var RadfiProvider = class {
|
|
|
14905
14903
|
const res = await this.request("/sodax/transaction/sign", {
|
|
14906
14904
|
method: "POST",
|
|
14907
14905
|
headers: {
|
|
14908
|
-
Authorization: `Bearer ${
|
|
14906
|
+
Authorization: `Bearer ${this.resolveAuth(accessToken)}`
|
|
14909
14907
|
},
|
|
14910
14908
|
body: JSON.stringify({
|
|
14911
14909
|
type: "sodax-withdraw",
|
|
14912
14910
|
params
|
|
14913
14911
|
})
|
|
14914
14912
|
});
|
|
14915
|
-
|
|
14916
|
-
|
|
14917
|
-
throw new RadfiApiError(res.status,
|
|
14913
|
+
const body = await this.parseJsonBody(res, "Bound Exchange signature request failed");
|
|
14914
|
+
if (!res.ok || !body.data?.txId) {
|
|
14915
|
+
throw new RadfiApiError(res.status, body, "Bound Exchange signature request failed");
|
|
14918
14916
|
}
|
|
14919
|
-
return
|
|
14917
|
+
return body.data.txId;
|
|
14920
14918
|
}
|
|
14921
14919
|
/**
|
|
14922
14920
|
* Fetch expired (or near-expiry) UTXOs for a trading wallet address from UMS API.
|
|
@@ -14935,7 +14933,8 @@ var RadfiProvider = class {
|
|
|
14935
14933
|
if (!res.ok) {
|
|
14936
14934
|
throw new Error("Failed to fetch expired UTXOs");
|
|
14937
14935
|
}
|
|
14938
|
-
|
|
14936
|
+
const body = await this.parseJsonBody(res, "Failed to fetch expired UTXOs");
|
|
14937
|
+
return { code: body.code ?? "", message: body.message ?? "", data: body.data ?? [] };
|
|
14939
14938
|
}
|
|
14940
14939
|
/**
|
|
14941
14940
|
* Build a renew-utxo transaction via the Bound Exchange API.
|
|
@@ -14955,11 +14954,11 @@ var RadfiProvider = class {
|
|
|
14955
14954
|
}
|
|
14956
14955
|
})
|
|
14957
14956
|
});
|
|
14958
|
-
|
|
14959
|
-
|
|
14960
|
-
throw new RadfiApiError(res.status,
|
|
14957
|
+
const body = await this.parseJsonBody(res, "Failed to build renew-utxo transaction");
|
|
14958
|
+
if (!res.ok || !body.data) {
|
|
14959
|
+
throw new RadfiApiError(res.status, body, "Failed to build renew-utxo transaction");
|
|
14961
14960
|
}
|
|
14962
|
-
return
|
|
14961
|
+
return body.data;
|
|
14963
14962
|
}
|
|
14964
14963
|
/**
|
|
14965
14964
|
* Sign and broadcast a renew-utxo transaction via the Bound Exchange API.
|
|
@@ -14976,11 +14975,14 @@ var RadfiProvider = class {
|
|
|
14976
14975
|
params
|
|
14977
14976
|
})
|
|
14978
14977
|
});
|
|
14979
|
-
|
|
14980
|
-
|
|
14981
|
-
|
|
14978
|
+
const body = await this.parseJsonBody(
|
|
14979
|
+
res,
|
|
14980
|
+
"Failed to sign and broadcast renew-utxo transaction"
|
|
14981
|
+
);
|
|
14982
|
+
if (!res.ok || !body.data?.txId) {
|
|
14983
|
+
throw new RadfiApiError(res.status, body, "Failed to sign and broadcast renew-utxo transaction");
|
|
14982
14984
|
}
|
|
14983
|
-
return
|
|
14985
|
+
return body.data.txId;
|
|
14984
14986
|
}
|
|
14985
14987
|
/**
|
|
14986
14988
|
* Withdraw BTC from trading wallet to user's personal wallet.
|
|
@@ -14997,11 +14999,11 @@ var RadfiProvider = class {
|
|
|
14997
14999
|
params
|
|
14998
15000
|
})
|
|
14999
15001
|
});
|
|
15000
|
-
|
|
15001
|
-
|
|
15002
|
-
throw new RadfiApiError(res.status,
|
|
15002
|
+
const body = await this.parseJsonBody(res, "Failed to build withdraw transaction");
|
|
15003
|
+
if (!res.ok || !body.data) {
|
|
15004
|
+
throw new RadfiApiError(res.status, body, "Failed to build withdraw transaction");
|
|
15003
15005
|
}
|
|
15004
|
-
return
|
|
15006
|
+
return body.data;
|
|
15005
15007
|
}
|
|
15006
15008
|
/**
|
|
15007
15009
|
* Sign and broadcast a withdraw transaction via Bound Exchange.
|
|
@@ -15017,14 +15019,19 @@ var RadfiProvider = class {
|
|
|
15017
15019
|
params
|
|
15018
15020
|
})
|
|
15019
15021
|
});
|
|
15022
|
+
const body = await this.parseJsonBody(
|
|
15023
|
+
res,
|
|
15024
|
+
"Failed to sign and broadcast withdraw transaction"
|
|
15025
|
+
);
|
|
15020
15026
|
if (!res.ok) {
|
|
15021
|
-
|
|
15022
|
-
throw new RadfiApiError(res.status, err, "Failed to sign and broadcast withdraw transaction");
|
|
15027
|
+
throw new RadfiApiError(res.status, body, "Failed to sign and broadcast withdraw transaction");
|
|
15023
15028
|
}
|
|
15024
|
-
|
|
15025
|
-
|
|
15026
|
-
|
|
15027
|
-
|
|
15029
|
+
const raw = body.data?.txId;
|
|
15030
|
+
const txId = typeof raw === "object" ? raw?.data : raw;
|
|
15031
|
+
if (!txId) {
|
|
15032
|
+
throw new RadfiApiError(res.status, body, "Failed to sign and broadcast withdraw transaction");
|
|
15033
|
+
}
|
|
15034
|
+
return txId;
|
|
15028
15035
|
}
|
|
15029
15036
|
/**
|
|
15030
15037
|
* Get max spendable amount for a withdraw transaction (amount after fee).
|
|
@@ -15040,11 +15047,56 @@ var RadfiProvider = class {
|
|
|
15040
15047
|
params
|
|
15041
15048
|
})
|
|
15042
15049
|
});
|
|
15043
|
-
|
|
15044
|
-
|
|
15045
|
-
throw new RadfiApiError(res.status,
|
|
15050
|
+
const body = await this.parseJsonBody(res, "Failed to get max withdrawable amount");
|
|
15051
|
+
if (!res.ok || !body.data) {
|
|
15052
|
+
throw new RadfiApiError(res.status, body, "Failed to get max withdrawable amount");
|
|
15053
|
+
}
|
|
15054
|
+
return body.data;
|
|
15055
|
+
}
|
|
15056
|
+
/**
|
|
15057
|
+
* Resolve the bearer credential for an authenticated Bound Exchange call, failing fast when none
|
|
15058
|
+
* is available. A server-side raw-build caller that never ran the interactive sign-in would
|
|
15059
|
+
* otherwise send `Authorization: Bearer ` (empty) and get an opaque 403 from Bound's gateway;
|
|
15060
|
+
* throwing here turns that into an actionable client-side error naming the fix. We deliberately do
|
|
15061
|
+
* NOT validate the token's contents (expiry / scope / signature) — only Bound can, and an invalid
|
|
15062
|
+
* token still surfaces as a legible 401/403 via `parseJsonBody`.
|
|
15063
|
+
*/
|
|
15064
|
+
resolveAuth(accessToken) {
|
|
15065
|
+
const auth = accessToken || this.config.apiKey;
|
|
15066
|
+
if (!auth) {
|
|
15067
|
+
throw new RadfiApiError(
|
|
15068
|
+
401,
|
|
15069
|
+
{
|
|
15070
|
+
message: "Bound Exchange access token (or apiKey) is required but none was set. Inject one via sodax.spoke.bitcoin.radfi.setRadfiAccessToken(token) or new Sodax({ ... }) with radfi.accessToken."
|
|
15071
|
+
},
|
|
15072
|
+
"Missing Bound Exchange credentials"
|
|
15073
|
+
);
|
|
15074
|
+
}
|
|
15075
|
+
return auth;
|
|
15076
|
+
}
|
|
15077
|
+
/**
|
|
15078
|
+
* Parse a Bound Exchange response body as JSON defensively.
|
|
15079
|
+
*
|
|
15080
|
+
* Bound (or an upstream gateway / WAF / CDN) can answer a request with an HTML error page
|
|
15081
|
+
* instead of JSON — e.g. an unauthenticated call, a blocked origin, a 404, or a 5xx. Calling
|
|
15082
|
+
* `res.json()` on that throws a cryptic `SyntaxError: Unexpected token '<'` that masks the real
|
|
15083
|
+
* HTTP status and bubbles up as an opaque failure (it surfaced as a `createIntent` /
|
|
15084
|
+
* `INTENT_CREATION_FAILED` "is not valid JSON" error on the Bitcoin raw-tx path). Reading the
|
|
15085
|
+
* body as text first and parsing it ourselves lets us raise a `RadfiApiError` carrying the
|
|
15086
|
+
* actual status code and a body snippet instead.
|
|
15087
|
+
*/
|
|
15088
|
+
async parseJsonBody(res, fallback) {
|
|
15089
|
+
const text = await res.text();
|
|
15090
|
+
try {
|
|
15091
|
+
return text.length ? JSON.parse(text) : {};
|
|
15092
|
+
} catch {
|
|
15093
|
+
const snippet = text.replace(/\s+/g, " ").trim().slice(0, 200);
|
|
15094
|
+
throw new RadfiApiError(
|
|
15095
|
+
res.status,
|
|
15096
|
+
{ message: `Bound Exchange returned a non-JSON response (HTTP ${res.status})${snippet ? `: ${snippet}` : ""}` },
|
|
15097
|
+
fallback
|
|
15098
|
+
);
|
|
15046
15099
|
}
|
|
15047
|
-
return res.json().then((r) => r.data);
|
|
15048
15100
|
}
|
|
15049
15101
|
async request(endpoint, options) {
|
|
15050
15102
|
return fetch(`${this.config.apiUrl}${endpoint}`, {
|
|
@@ -26451,14 +26503,18 @@ var SwapService = class {
|
|
|
26451
26503
|
}
|
|
26452
26504
|
const personalAddress = params.srcAddress;
|
|
26453
26505
|
let walletAddress = personalAddress;
|
|
26454
|
-
if (isBitcoinChainKeyType(params.srcChainKey)
|
|
26455
|
-
|
|
26456
|
-
|
|
26457
|
-
|
|
26458
|
-
|
|
26459
|
-
|
|
26506
|
+
if (isBitcoinChainKeyType(params.srcChainKey)) {
|
|
26507
|
+
if (_params.raw === false) {
|
|
26508
|
+
swapInvariant(
|
|
26509
|
+
isBitcoinWalletProviderType(_params.walletProvider),
|
|
26510
|
+
`Invalid wallet provider for chain key: ${params.srcChainKey}`,
|
|
26511
|
+
baseCtx
|
|
26512
|
+
);
|
|
26513
|
+
if (this.spoke.bitcoin.walletMode === "TRADING") {
|
|
26514
|
+
await this.spoke.bitcoin.radfi.ensureRadfiAccessToken(_params.walletProvider);
|
|
26515
|
+
}
|
|
26516
|
+
}
|
|
26460
26517
|
walletAddress = await this.spoke.bitcoin.getEffectiveWalletAddress(personalAddress);
|
|
26461
|
-
await this.spoke.bitcoin.radfi.ensureRadfiAccessToken(_params.walletProvider);
|
|
26462
26518
|
}
|
|
26463
26519
|
const creatorHubWalletAddress = await this.hubProvider.getUserHubWalletAddress(walletAddress, params.srcChainKey);
|
|
26464
26520
|
if (isHubChainKeyType(params.srcChainKey) && isSonicChainKeyType(params.srcChainKey)) {
|
|
@@ -26498,6 +26554,8 @@ var SwapService = class {
|
|
|
26498
26554
|
srcChainKey: params.srcChainKey,
|
|
26499
26555
|
srcAddress: walletAddress,
|
|
26500
26556
|
srcPublicKey: extras?.srcPublicKey,
|
|
26557
|
+
// Bitcoin Bound token; BitcoinSpokeService.deposit falls back to the RadfiProvider instance token when undefined.
|
|
26558
|
+
accessToken: extras?.bound?.accessToken,
|
|
26501
26559
|
to: creatorHubWalletAddress,
|
|
26502
26560
|
token: params.inputToken,
|
|
26503
26561
|
amount: params.inputAmount,
|
package/dist/index.d.cts
CHANGED
|
@@ -8116,6 +8116,7 @@ type OptionalSkipSimulation$1 = {
|
|
|
8116
8116
|
type DepositParams<C extends SpokeChainKey, Raw extends boolean = boolean> = {
|
|
8117
8117
|
srcAddress: GetAddressType<C>;
|
|
8118
8118
|
srcPublicKey?: string;
|
|
8119
|
+
accessToken?: string;
|
|
8119
8120
|
srcChainKey: C;
|
|
8120
8121
|
to: HubAddress;
|
|
8121
8122
|
token: GetTokenAddressType<C>;
|
|
@@ -8255,6 +8256,16 @@ type SrcPublicKeySlot<K extends SpokeChainKey> = GetChainType<K> extends 'STACKS
|
|
|
8255
8256
|
} : {
|
|
8256
8257
|
srcPublicKey?: never;
|
|
8257
8258
|
};
|
|
8259
|
+
/** Bound Exchange (Radfi) inputs for raw Bitcoin TRADING-mode swap intents. */
|
|
8260
|
+
type BitcoinBoundExtras = {
|
|
8261
|
+
/** Bound token, for raw Bitcoin TRADING callers; falls back to the RadfiProvider instance token when omitted. */
|
|
8262
|
+
accessToken?: string;
|
|
8263
|
+
};
|
|
8264
|
+
type BitcoinBoundSlot<K extends SpokeChainKey> = GetChainType<K> extends 'BITCOIN' ? {
|
|
8265
|
+
bound?: BitcoinBoundExtras;
|
|
8266
|
+
} : {
|
|
8267
|
+
bound?: never;
|
|
8268
|
+
};
|
|
8258
8269
|
/**
|
|
8259
8270
|
* Per-action extras for swap intent creation, supplied via the `extras` slot of the swap
|
|
8260
8271
|
* action params.
|
|
@@ -8262,7 +8273,7 @@ type SrcPublicKeySlot<K extends SpokeChainKey> = GetChainType<K> extends 'STACKS
|
|
|
8262
8273
|
type SwapExtras<K extends SpokeChainKey = SpokeChainKey> = {
|
|
8263
8274
|
/** Overrides the configured swap partner fee for this action; falls back to config when omitted. */
|
|
8264
8275
|
partnerFee?: PartnerFee;
|
|
8265
|
-
} & SrcPublicKeySlot<K>;
|
|
8276
|
+
} & SrcPublicKeySlot<K> & BitcoinBoundSlot<K>;
|
|
8266
8277
|
type Intent = {
|
|
8267
8278
|
intentId: bigint;
|
|
8268
8279
|
creator: Address;
|
|
@@ -8782,6 +8793,15 @@ type RadfiErrorBody = {
|
|
|
8782
8793
|
message?: string;
|
|
8783
8794
|
};
|
|
8784
8795
|
};
|
|
8796
|
+
/**
|
|
8797
|
+
* Shape of a parsed Bound Exchange JSON response: the {@link RadfiErrorBody} envelope fields plus an
|
|
8798
|
+
* optional, per-call typed `data` payload. Modeled as a superset of `RadfiErrorBody` so a parsed body
|
|
8799
|
+
* can be handed straight to {@link RadfiApiError} on the error path. `data` is optional because Bound
|
|
8800
|
+
* can answer 2xx with a logical-error envelope (no `data`); callers guard before dereferencing it.
|
|
8801
|
+
*/
|
|
8802
|
+
type RadfiResponseEnvelope<T = unknown> = RadfiErrorBody & {
|
|
8803
|
+
data?: T;
|
|
8804
|
+
};
|
|
8785
8805
|
/**
|
|
8786
8806
|
* Structured error from a Bound Exchange HTTP request. Exposes `status` (HTTP), `code`
|
|
8787
8807
|
* (Bound Exchange-specific identifier), and `details` (human-readable) so callers can
|
|
@@ -8890,7 +8910,7 @@ declare class RadfiProvider {
|
|
|
8890
8910
|
walletAddress: string;
|
|
8891
8911
|
publicKey: string;
|
|
8892
8912
|
}, accessToken: string): Promise<RadfiTradingWallet>;
|
|
8893
|
-
getTradingWallet(userAddress: string
|
|
8913
|
+
getTradingWallet(userAddress: string): Promise<RadfiTradingWallet>;
|
|
8894
8914
|
getBalance(address: string): Promise<RadfiWalletBalance>;
|
|
8895
8915
|
checkIfTradingWalletExists(userAddress: string): Promise<boolean>;
|
|
8896
8916
|
createWithdrawTransaction(params: {
|
|
@@ -8962,6 +8982,27 @@ declare class RadfiProvider {
|
|
|
8962
8982
|
tokenId: string;
|
|
8963
8983
|
withdrawTo: string;
|
|
8964
8984
|
}, accessToken: string): Promise<RadfiMaxSpentResponse>;
|
|
8985
|
+
/**
|
|
8986
|
+
* Resolve the bearer credential for an authenticated Bound Exchange call, failing fast when none
|
|
8987
|
+
* is available. A server-side raw-build caller that never ran the interactive sign-in would
|
|
8988
|
+
* otherwise send `Authorization: Bearer ` (empty) and get an opaque 403 from Bound's gateway;
|
|
8989
|
+
* throwing here turns that into an actionable client-side error naming the fix. We deliberately do
|
|
8990
|
+
* NOT validate the token's contents (expiry / scope / signature) — only Bound can, and an invalid
|
|
8991
|
+
* token still surfaces as a legible 401/403 via `parseJsonBody`.
|
|
8992
|
+
*/
|
|
8993
|
+
private resolveAuth;
|
|
8994
|
+
/**
|
|
8995
|
+
* Parse a Bound Exchange response body as JSON defensively.
|
|
8996
|
+
*
|
|
8997
|
+
* Bound (or an upstream gateway / WAF / CDN) can answer a request with an HTML error page
|
|
8998
|
+
* instead of JSON — e.g. an unauthenticated call, a blocked origin, a 404, or a 5xx. Calling
|
|
8999
|
+
* `res.json()` on that throws a cryptic `SyntaxError: Unexpected token '<'` that masks the real
|
|
9000
|
+
* HTTP status and bubbles up as an opaque failure (it surfaced as a `createIntent` /
|
|
9001
|
+
* `INTENT_CREATION_FAILED` "is not valid JSON" error on the Bitcoin raw-tx path). Reading the
|
|
9002
|
+
* body as text first and parsing it ourselves lets us raise a `RadfiApiError` carrying the
|
|
9003
|
+
* actual status code and a body snippet instead.
|
|
9004
|
+
*/
|
|
9005
|
+
private parseJsonBody;
|
|
8965
9006
|
private request;
|
|
8966
9007
|
}
|
|
8967
9008
|
|
|
@@ -9117,9 +9158,7 @@ declare class BitcoinSpokeService {
|
|
|
9117
9158
|
/**
|
|
9118
9159
|
* Deposit operation - transfer BTC to the asset manager
|
|
9119
9160
|
*/
|
|
9120
|
-
deposit<Raw extends boolean = false>(params: DepositParams<BitcoinChainKey, Raw>
|
|
9121
|
-
accessToken?: string;
|
|
9122
|
-
}): Promise<TxReturnType<BitcoinChainKey, Raw>>;
|
|
9161
|
+
deposit<Raw extends boolean = false>(params: DepositParams<BitcoinChainKey, Raw>): Promise<TxReturnType<BitcoinChainKey, Raw>>;
|
|
9123
9162
|
/**
|
|
9124
9163
|
* Build deposit PSBT with embedded cross-chain data
|
|
9125
9164
|
*/
|
|
@@ -17114,4 +17153,4 @@ type DexErrorCode = LookupErrorCode;
|
|
|
17114
17153
|
type DexError = SodaxError<DexErrorCode>;
|
|
17115
17154
|
declare const isDexError: (e: unknown) => e is SodaxError<LookupErrorCode>;
|
|
17116
17155
|
|
|
17117
|
-
export { ALLOWANCE_CHECK_CODES, APPROVE_CODES, type AggregatedReserveData, type AllowanceCheckErrorCode, type AllowanceInfo, type AllowanceResponse, type AllowanceTransferDetails, type ApiResponse, type ApproveErrorCode, type ApyRange, type AssetDepositAction, type AssetEntry, AssetService, type AssetServiceConstructorParams, type AssetWithdrawAction, type AutoSwapPreferences, BackendApiService, type BalnLockParams, type BalnMigrateAction, type BalnMigrateParams, type BalnSwapAbi, BalnSwapService, type BalnSwapServiceConstructorParams, type BaseCurrencyInfo, BigIntToHex, type BigNumberValue, BigNumberZeroDecimal, BitcoinSpokeService, type BitcoinTransactionResult, type BitcoinUTXO, BnUSDMigrationService, type BnUSDMigrationServiceConstructorParams, type BnUSDRevertMigrationParams, type BorrowInfo, type BridgeAction, type BridgeAllowanceCheckError, type BridgeAllowanceCheckErrorCode, type BridgeApproveError, type BridgeApproveErrorCode, type BridgeCreateIntentError, type BridgeCreateIntentErrorCode, type BridgeError, type BridgeErrorCode, type BridgeLookupError, type BridgeLookupErrorCode, type BridgeOrchestrationError, type BridgeOrchestrationErrorCode, type BridgeParams, BridgeService, type BridgeServiceConstructorParams, type BtcPayload, CREATE_INTENT_CODES, type CalculateAllReserveIncentivesRequest, type CalculateAllUserIncentivesRequest, type CalculateCompoundedRateRequest, type CallResponse, type CancelIntentActionParams, type CancelIntentParams, type CancelUnstakeAction, type CancelUnstakeParams, type ClClaimRewardsParams, type ClDecreaseLiquidityParams, type ClGetPoolDataParams, type ClIncreaseLiquidityParams, type ClLiquidityClaimRewardsAction, type ClLiquidityDecreaseLiquidityAction, type ClLiquidityIncreaseLiquidityAction, type ClLiquidityWithdrawAction, type ClMintPositionEventLog, type ClPositionInfo, ClService, type ClServiceConstructorParams, type ClSupplyAction, type ClSupplyParams, type ClWithdrawParams, type ClaimAction, type ClaimParams, type CombinedReserveData, type ComputedUserReserve, type ConcentratedLiquidityParams, type ConcentratedLiquidityTokenInfo, ConfigService, type ConfigServiceConstructorParams, type ConnMsg, type CreateAssetDepositParams, type CreateAssetWithdrawParams, type CreateBridgeIntentParams, type CreateIntentErrorCode, type CreateIntentParams, type CreateIntentResult, type CreateLimitOrderParams, type CreateSonicSwapIntentParams, type CreateVaultIntentResult, type CreateViemPublicClientParams, CustomSorobanServer, CustomStellarAccount, type DepositParams, type DepositSimulationParams, type DestinationParamsType, type DetailedLock, type DexError, type DexErrorCode, DexService, type DexServiceConstructorParams, type EModeCategory, type EModeCategoryHumanized, type EModeData, type EModeDataString, type EmodeDataHumanized, type EnrichedToken, type Erc20ApproveParams, type Erc20IsAllowanceParams, Erc20Service, type Erc20Token, Erc4626Service, type EstimateGasParams, EvmAssetManagerService, type EvmDepositToDataParams, EvmHubProvider, type EvmHubProviderConstructorParams, EvmSolverService, EvmSpokeService, EvmVaultTokenService, type EvmWithdrawAssetDataParams, type ExecuteMsg, type FeatureInvariant, type FeeData, type FeeTokenApproveAction, type FeeTokenApproveParams, type FetchHubAssetBalancesParams, type FormatReserveRequest, type FormatReserveResponse, type FormatReserveUSDRequest, type FormatReserveUSDResponse, type FormatReservesAndIncentivesUSDRequest, type FormatReservesUSDRequest, type FormatUserSummaryAndIncentivesRequest, type FormatUserSummaryAndIncentivesResponse, type FormatUserSummaryRequest, type FormatUserSummaryResponse, type FormattedReserveEMode, GAS_ESTIMATION_CODES, type GasEstimationErrorCode, type GetDepositParams, type GetIntentSubmitTxExtraDataParams, type GetPacketParams, type GetPacketResponse, type GetQuoteParams, type GetRelayRequestParamType, type GetRelayResponse, type GetSpokeServiceType, type GetTransactionPacketsParams, type GetTransactionPacketsResponse, type GetTxReceiptType, type GetUserRouterParams, HALF_RAY, HALF_WAD, type HanaWalletRequestEvent, type HanaWalletResponseEvent, HttpRelayError, type HubAssetBalance, type HubProvider, type IconJsonRpcVersion, IconSpokeService, type IcxCreateRevertMigrationParams, type IcxMigrateAction, type IcxMigrateParams, IcxMigrationService, type IcxMigrationServiceConstructorParams, type IcxRevertMigrationAction, type IcxRevertMigrationParams, type IncentiveDataHumanized, type InjTokenInfo, Injective20Token, type InjectiveBalance, InjectiveSpokeService, type InstantUnstakeAction, type InstantUnstakeParams, type InstantiateMsg, type Intent, type IntentAutoSwapResult, IntentCreatedEventAbi, type IntentCreatedEventLog, type IntentData, IntentDataType, type IntentDeliveryInfo, IntentFilledEventAbi, type IntentFilledEventLog, type IntentRelayRequest, type IntentRelayRequestParams, type IntentResponse, type IntentState, type IntentTxResult, IntentsAbi, type JsonRpcPayloadResponse, LOOKUP_CODES, LTV_PRECISION, LendingPoolService, type LendingPoolServiceConstructorParams, type LeverageYieldAction, type LeverageYieldAllowanceCheckError, type LeverageYieldAllowanceCheckErrorCode, type LeverageYieldAllowanceParams, type LeverageYieldApproveError, type LeverageYieldApproveErrorCode, type LeverageYieldApproveParams, type LeverageYieldApr, type LeverageYieldCreateIntentError, type LeverageYieldCreateIntentErrorCode, type LeverageYieldEffectiveApr, type LeverageYieldError, type LeverageYieldErrorCode, type LeverageYieldLookupError, type LeverageYieldLookupErrorCode, type LeverageYieldLsdApr, type LeverageYieldPosition, type LeverageYieldPostExecutionError, type LeverageYieldPostExecutionErrorCode, LeverageYieldService, type LeverageYieldServiceConstructorParams, type LeverageYieldSwapDepositParams, type LeverageYieldSwapError, type LeverageYieldSwapErrorCode, type LeverageYieldSwapPayload, type LeverageYieldSwapWithdrawParams, type LimitOrderActionParams, LockupMultiplier, LockupPeriod, type LookupErrorCode, type MapRelayFailureCtx, type MigrateOrchestrationError, type MigrateOrchestrationErrorCode, type MigrationAction, type MigrationAllowanceCheckError, type MigrationAllowanceCheckErrorCode, type MigrationApproveError, type MigrationApproveErrorCode, type MigrationCreateIntentError, type MigrationCreateIntentErrorCode, type MigrationDirection, type MigrationError, type MigrationErrorCode, type MigrationLookupError, type MigrationLookupErrorCode, type MigrationOp, type MigrationParams, type MigrationRevertParams, MigrationService, type MigrationServiceConstructorParams, type MigrationTokens, MintPositionEventAbi, type MintPositionEventLog, type MoneyMarketAction, type MoneyMarketAllowanceCheckError, type MoneyMarketAllowanceCheckErrorCode, type MoneyMarketAllowanceParams, type MoneyMarketApproveActionParams, type MoneyMarketApproveError, type MoneyMarketApproveErrorCode, type MoneyMarketAsset, type MoneyMarketAssetBorrowers, type MoneyMarketAssetSuppliers, type MoneyMarketBorrowActionParams, type MoneyMarketBorrowParams, type MoneyMarketBorrowers, type MoneyMarketCreateIntentError, type MoneyMarketCreateIntentErrorCode, MoneyMarketDataService, type MoneyMarketDataServiceConstructorParams, type MoneyMarketEncodeBorrowParams, type MoneyMarketEncodeRepayParams, type MoneyMarketEncodeRepayWithATokensParams, type MoneyMarketEncodeSupplyParams, type MoneyMarketEncodeWithdrawParams, type MoneyMarketError, type MoneyMarketErrorCode, type MoneyMarketGasEstimationError, type MoneyMarketGasEstimationErrorCode, type MoneyMarketOrchestrationError, type MoneyMarketOrchestrationErrorCode, type MoneyMarketParams, type MoneyMarketPosition, type MoneyMarketRepayActionParams, type MoneyMarketRepayParams, MoneyMarketService, type MoneyMarketServiceConstructorParams, type MoneyMarketSupplyActionParams, type MoneyMarketSupplyParams, type MoneyMarketWithdrawActionParams, type MoneyMarketWithdrawParams, NEAR_DEFAULT_GAS, NEAR_STORAGE_DEPOSIT, NearSpokeService, type OnDemandBtcPayload, type OnDemandRelayData, type OptionalRaw, type OptionalSkipSimulation, type OptionalTimeout, type OrderbookResponse, type PacketData, type PartnerAction, type PartnerError, type PartnerErrorCode, type PartnerFeeClaimAssetBalance, PartnerFeeClaimService, type PartnerFeeClaimServiceConstructorParams, type PartnerFeeClaimSwapAction, type PartnerFeeClaimSwapParams, PartnerService, type PartnerServiceConfig, type PartnerServiceConstructorParams, Permit2Service, type PermitBatch, type PermitDetails, type PermitSingle, type PoolBaseCurrencyHumanized, type PoolData, type PoolRewardConfig, type PoolSpokeAssets, type PostExecutionError, type PostExecutionErrorCode, ProtocolIntentsAbi, type QueryMsg, type QueryResponse, RAY, RAY_DECIMALS, RELAY_ERROR_CODES, RadfiApiError, type RadfiAuthResult, type RadfiBuildTxResponse, type RadfiErrorBody, type RadfiMaxSpentResponse, RadfiProvider, type RadfiTradingWallet, type RadfiUtxo, type RadfiUtxoListResponse, type RadfiWalletBalance, type RateLimitConfig, type RawDestinationParams, type RecoveryAction, type RecoveryError, type RecoveryErrorCode, RecoveryService, type RecoveryServiceConstructorParams, type RelayAction, type RelayAndWaitParams, type RelayCode, type RelayErrorCode, type RelayExtraData, type RelayRequestDetail, type RelayRequestSigning, type RelayTxStatus, type RelayWrappedErrorCode, type RequestConfig, type RequestOverrideConfig, type RequestTrustlineParams, type ReserveCalculationData, type ReserveData, type ReserveDataHumanized, type ReserveDataLegacy, type ReserveDataWithPrice, type ReserveEMode, type ReserveIncentiveDict, type ReservesDataHumanized, type ReservesIncentiveDataHumanized, type ResponseAddressType, type ResponseSigningType, type RevertMigrationOrchestrationError, type RevertMigrationOrchestrationErrorCode, type RewardInfoHumanized, SECONDS_PER_YEAR, SODAX_ERROR_CODES, SODAX_FEATURES, type SendMessageParams, type SetSwapPreferenceAction, type SetSwapPreferenceParams, Sodax, SodaxError, type SodaxErrorCode, type SodaxErrorContext, type SodaxErrorJSON, type SodaxFeature, type SodaxPhase, SolanaSpokeService, SolverApiService, SonicSpokeService, type SpokeApproveParams, type SpokeApproveParamsEvmSpoke, type SpokeApproveParamsHub, type SpokeApproveParamsStellar, type SpokeIsAllowanceValidParams, type SpokeIsAllowanceValidParamsEvmSpoke, type SpokeIsAllowanceValidParamsHub, type SpokeIsAllowanceValidParamsOther, type SpokeIsAllowanceValidParamsStellar, SpokeService, type SpokeServiceConstructorParams, type SpokeServiceType, StacksSpokeService, type StakeAction, type StakeOrchestrationError, type StakeOrchestrationErrorCode, type StakeParams, type StakingActionType, type StakingActionUnion, type StakingAllowanceCheckError, type StakingAllowanceCheckErrorCode, type StakingApproveError, type StakingApproveErrorCode, type StakingConfig, type StakingCreateIntentError, type StakingCreateIntentErrorCode, type StakingError, type StakingErrorCode, type StakingInfo, type StakingInfoFetchError, type StakingInfoFetchErrorCode, StakingLogic, type StakingOrchestrationError, type StakingOrchestrationErrorCode, type StakingParamsUnion, StakingService, type StakingServiceConstructorParams, type State, StellarSpokeService, type SubmitTxParams, type SubmitTxResponse, SuiSpokeService, SupportedMigrationTokens, type SwapAction, type SwapActionParams, type SwapCreateIntentError, type SwapCreateIntentErrorCode, type SwapError, type SwapErrorCode, type SwapExtras, type SwapResponse, SwapService, type SwapServiceConstructorParams, type TokenSpenderPair, type TokenWithConversion, type TxHashPair, type TxStatus, USD_DECIMALS, type UiPoolDataProviderInterface, UiPoolDataProviderService, type UiPoolDataProviderServiceConstructorParams, type UnifiedBnUSDMigrateAction, type UnifiedBnUSDMigrateParams, type UnstakeAction, type UnstakeParams, type UnstakeRequest, type UnstakeRequestWithPenalty, type UnstakingInfo, type UserIncentiveData, type UserIncentiveDataHumanized, type UserIncentiveDict, type UserIntentsResponse, type UserReserveCalculationData, type UserReserveData, type UserReserveDataHumanized, type UserReserveDataString, type UserReservesIncentivesDataHumanized, type UserRewardInfoHumanized, type VaultSwapActionParams, type VaultSwapResponse, type VerifySimulationParams, type VerifyTxHashParams, WAD, WAD_RAY_RATIO, WEI_DECIMALS, type WaitForTxReceiptParams, type WaitForTxReceiptReturnType, type WaitUntilIntentExecutedPayload, type WalletMode, type WalletSimulationParams, type WithdrawHubAssetAction, type WithdrawHubAssetParams, type WithdrawInfo, adjustAmountByFee, allowanceCheckFailed, approveFailed, assetManagerAbi, balnSwapAbi, binomialApproximatedRayPow, bridgeInvariant, calcOpReturnOutputVbytes, calculateAllReserveIncentives, calculateAllUserIncentives, calculateAvailableBorrowsMarketReferenceCurrency, calculateCompoundedInterest, calculateCompoundedRate, calculateFeeAmount, calculateHealthFactorFromBalances, calculateHealthFactorFromBalancesBigUnits, calculateLinearInterest, calculatePercentageFeeAmount, clPoolAbi, clPoolManagerAbi, clPositionManagerAbi, clQuoterAbi, clRouterAbi, clTickLensAbi, connectionAbi, consoleLogger, convertTransactionInstructionToRaw, createInvariant, deepMerge, defaultHookAbi, dexInvariant, encodeAddress, encodeBtcPayloadToBytes, encodeContractCalls, erc20Abi, erc4626Abi, estimateBitcoinTxSize, executionFailed, formatBasisPoints, formatEModeCategory, formatEModes, formatPercentage, formatReserve, formatReserveUSD, formatReserves, formatReservesAndIncentives, formatUserSummary, formatUserSummaryAndIncentives, gasEstimationFailed, getAndFormatReserveEModes, getAssetManagerIdl, getAssetManagerProgram, getCompoundedBalance, getConnectionIdl, getConnectionProgram, getEvmViemChain, getIconAddressBytes, getLinearBalance, getMarketReferenceCurrencyAndUsdBalance, getPacket, getProvider, getRandomBytes, getReserveNormalizedIncome, getReservesEModes, getSolanaAddressBytes, getTransactionPackets, hexToBigInt, hexToSolanaAddress, hyper, intentCreationFailed, isBalnMigrateParams, isBitcoinChainKeyType, isBitcoinWalletProviderType, isBridgeAllowanceCheckError, isBridgeApproveError, isBridgeCreateIntentError, isBridgeError, isBridgeLookupError, isBridgeOrchestrationError, isCodeMember, isDexError, isEvmChainKeyType, isEvmSpokeChainConfig, isEvmSpokeOnlyChainKeyType, isEvmWalletProviderType, isFeatureError, isHubChainKeyType, isIconAddress, isIconChainKeyType, isIcxCreateRevertMigrationParams, isIcxMigrateParams, isInjectiveChainKeyType, isJsonRpcPayloadResponse, isLeverageYieldAllowanceCheckError, isLeverageYieldApproveError, isLeverageYieldCreateIntentError, isLeverageYieldError, isLeverageYieldLookupError, isLeverageYieldPostExecutionError, isLeverageYieldSwapError, isMigrateOrchestrationError, isMigrationAllowanceCheckError, isMigrationApproveError, isMigrationCreateIntentError, isMigrationError, isMigrationLookupError, isMoneyMarketAllowanceCheckError, isMoneyMarketApproveError, isMoneyMarketCreateIntentError, isMoneyMarketError, isMoneyMarketGasEstimationError, isMoneyMarketOrchestrationError, isNearChainKeyType, isOptionalBitcoinWalletProviderType, isOptionalEvmWalletProviderType, isOptionalStellarWalletProviderType, isPartnerError, isPartnerFeeAmount, isPartnerFeePercentage, isPostExecutionError, isRawDestinationParams, isRecoveryError, isResponseAddressType, isResponseSigningType, isRevertMigrationOrchestrationError, isSodaxError, isSolanaChainKeyType, isSolanaNativeToken, isSonicChainKeyType, isSpokeApproveParamsEvmSpoke, isSpokeApproveParamsHub, isSpokeApproveParamsStellar, isSpokeIsAllowanceValidParamsEvmSpoke, isSpokeIsAllowanceValidParamsHub, isSpokeIsAllowanceValidParamsStellar, isStacksChainKeyType, isStakeOrchestrationError, isStakingAllowanceCheckError, isStakingApproveError, isStakingCreateIntentError, isStakingError, isStakingInfoFetchError, isStakingOrchestrationError, isStellarChainKeyType, isStellarWalletProviderType, isSubmitSwapTxResponse, isSubmitSwapTxStatusResponse, isSuiChainKeyType, isSwapCreateIntentError, isSwapError, isUndefinedOrValidWalletProviderForChainKey, isUnifiedBnUSDMigrateParams, leverageYieldInvariant, lookupFailed, mapRelayFailure, mergeSodaxConfig, messageOf, migrationInvariant, mintPositionParamsAbi, mmInvariant, modifyLiquidityParamsAbi, nativeToUSD, normalize, normalizeBN, normalizePsbtToBase64, normalizeSignatureToBase64, normalizedToUsd, pancakeSwapInfinityDefaultHookAbi, pancakeSwapInfinityPoolManagerAbi, pancakeSwapInfinityPositionManagerAbi, parseToStroops, parseTokenArrayFromJson, partnerInvariant, permit2Abi, poolAbi, poolKeyAbi, randomUint256, rayDiv, rayMul, rayPow, rayToWad, recoveryInvariant, relayTxAndWaitPacket, requestAddress, requestJsonRpc, requestSigning, resolveLogger, retry, reverseEncodeAddress, serializeAddressData, silentLogger, sleep, sodaxInvariant, sonicWalletFactoryAbi, spokeAssetManagerAbi, stakedSodaAbi, stakingInvariant, stakingRouterAbi, stataTokenFactoryAbi, submitTransaction, swapExactInSingleParamsAbi, swapInvariant, uiPoolDataAbi, universalRouterAbi, unknownFailed, valueToBigNumber, valueToZDBigNumber, variableDebtTokenAbi, vaultTokenAbi, verifyFailed, wadToRay, waitForStacksTransaction, waitForTransactionReceipt, waitUntilIntentExecuted, walletFactoryAbi, wrappedSonicAbi };
|
|
17156
|
+
export { ALLOWANCE_CHECK_CODES, APPROVE_CODES, type AggregatedReserveData, type AllowanceCheckErrorCode, type AllowanceInfo, type AllowanceResponse, type AllowanceTransferDetails, type ApiResponse, type ApproveErrorCode, type ApyRange, type AssetDepositAction, type AssetEntry, AssetService, type AssetServiceConstructorParams, type AssetWithdrawAction, type AutoSwapPreferences, BackendApiService, type BalnLockParams, type BalnMigrateAction, type BalnMigrateParams, type BalnSwapAbi, BalnSwapService, type BalnSwapServiceConstructorParams, type BaseCurrencyInfo, BigIntToHex, type BigNumberValue, BigNumberZeroDecimal, type BitcoinBoundExtras, BitcoinSpokeService, type BitcoinTransactionResult, type BitcoinUTXO, BnUSDMigrationService, type BnUSDMigrationServiceConstructorParams, type BnUSDRevertMigrationParams, type BorrowInfo, type BridgeAction, type BridgeAllowanceCheckError, type BridgeAllowanceCheckErrorCode, type BridgeApproveError, type BridgeApproveErrorCode, type BridgeCreateIntentError, type BridgeCreateIntentErrorCode, type BridgeError, type BridgeErrorCode, type BridgeLookupError, type BridgeLookupErrorCode, type BridgeOrchestrationError, type BridgeOrchestrationErrorCode, type BridgeParams, BridgeService, type BridgeServiceConstructorParams, type BtcPayload, CREATE_INTENT_CODES, type CalculateAllReserveIncentivesRequest, type CalculateAllUserIncentivesRequest, type CalculateCompoundedRateRequest, type CallResponse, type CancelIntentActionParams, type CancelIntentParams, type CancelUnstakeAction, type CancelUnstakeParams, type ClClaimRewardsParams, type ClDecreaseLiquidityParams, type ClGetPoolDataParams, type ClIncreaseLiquidityParams, type ClLiquidityClaimRewardsAction, type ClLiquidityDecreaseLiquidityAction, type ClLiquidityIncreaseLiquidityAction, type ClLiquidityWithdrawAction, type ClMintPositionEventLog, type ClPositionInfo, ClService, type ClServiceConstructorParams, type ClSupplyAction, type ClSupplyParams, type ClWithdrawParams, type ClaimAction, type ClaimParams, type CombinedReserveData, type ComputedUserReserve, type ConcentratedLiquidityParams, type ConcentratedLiquidityTokenInfo, ConfigService, type ConfigServiceConstructorParams, type ConnMsg, type CreateAssetDepositParams, type CreateAssetWithdrawParams, type CreateBridgeIntentParams, type CreateIntentErrorCode, type CreateIntentParams, type CreateIntentResult, type CreateLimitOrderParams, type CreateSonicSwapIntentParams, type CreateVaultIntentResult, type CreateViemPublicClientParams, CustomSorobanServer, CustomStellarAccount, type DepositParams, type DepositSimulationParams, type DestinationParamsType, type DetailedLock, type DexError, type DexErrorCode, DexService, type DexServiceConstructorParams, type EModeCategory, type EModeCategoryHumanized, type EModeData, type EModeDataString, type EmodeDataHumanized, type EnrichedToken, type Erc20ApproveParams, type Erc20IsAllowanceParams, Erc20Service, type Erc20Token, Erc4626Service, type EstimateGasParams, EvmAssetManagerService, type EvmDepositToDataParams, EvmHubProvider, type EvmHubProviderConstructorParams, EvmSolverService, EvmSpokeService, EvmVaultTokenService, type EvmWithdrawAssetDataParams, type ExecuteMsg, type FeatureInvariant, type FeeData, type FeeTokenApproveAction, type FeeTokenApproveParams, type FetchHubAssetBalancesParams, type FormatReserveRequest, type FormatReserveResponse, type FormatReserveUSDRequest, type FormatReserveUSDResponse, type FormatReservesAndIncentivesUSDRequest, type FormatReservesUSDRequest, type FormatUserSummaryAndIncentivesRequest, type FormatUserSummaryAndIncentivesResponse, type FormatUserSummaryRequest, type FormatUserSummaryResponse, type FormattedReserveEMode, GAS_ESTIMATION_CODES, type GasEstimationErrorCode, type GetDepositParams, type GetIntentSubmitTxExtraDataParams, type GetPacketParams, type GetPacketResponse, type GetQuoteParams, type GetRelayRequestParamType, type GetRelayResponse, type GetSpokeServiceType, type GetTransactionPacketsParams, type GetTransactionPacketsResponse, type GetTxReceiptType, type GetUserRouterParams, HALF_RAY, HALF_WAD, type HanaWalletRequestEvent, type HanaWalletResponseEvent, HttpRelayError, type HubAssetBalance, type HubProvider, type IconJsonRpcVersion, IconSpokeService, type IcxCreateRevertMigrationParams, type IcxMigrateAction, type IcxMigrateParams, IcxMigrationService, type IcxMigrationServiceConstructorParams, type IcxRevertMigrationAction, type IcxRevertMigrationParams, type IncentiveDataHumanized, type InjTokenInfo, Injective20Token, type InjectiveBalance, InjectiveSpokeService, type InstantUnstakeAction, type InstantUnstakeParams, type InstantiateMsg, type Intent, type IntentAutoSwapResult, IntentCreatedEventAbi, type IntentCreatedEventLog, type IntentData, IntentDataType, type IntentDeliveryInfo, IntentFilledEventAbi, type IntentFilledEventLog, type IntentRelayRequest, type IntentRelayRequestParams, type IntentResponse, type IntentState, type IntentTxResult, IntentsAbi, type JsonRpcPayloadResponse, LOOKUP_CODES, LTV_PRECISION, LendingPoolService, type LendingPoolServiceConstructorParams, type LeverageYieldAction, type LeverageYieldAllowanceCheckError, type LeverageYieldAllowanceCheckErrorCode, type LeverageYieldAllowanceParams, type LeverageYieldApproveError, type LeverageYieldApproveErrorCode, type LeverageYieldApproveParams, type LeverageYieldApr, type LeverageYieldCreateIntentError, type LeverageYieldCreateIntentErrorCode, type LeverageYieldEffectiveApr, type LeverageYieldError, type LeverageYieldErrorCode, type LeverageYieldLookupError, type LeverageYieldLookupErrorCode, type LeverageYieldLsdApr, type LeverageYieldPosition, type LeverageYieldPostExecutionError, type LeverageYieldPostExecutionErrorCode, LeverageYieldService, type LeverageYieldServiceConstructorParams, type LeverageYieldSwapDepositParams, type LeverageYieldSwapError, type LeverageYieldSwapErrorCode, type LeverageYieldSwapPayload, type LeverageYieldSwapWithdrawParams, type LimitOrderActionParams, LockupMultiplier, LockupPeriod, type LookupErrorCode, type MapRelayFailureCtx, type MigrateOrchestrationError, type MigrateOrchestrationErrorCode, type MigrationAction, type MigrationAllowanceCheckError, type MigrationAllowanceCheckErrorCode, type MigrationApproveError, type MigrationApproveErrorCode, type MigrationCreateIntentError, type MigrationCreateIntentErrorCode, type MigrationDirection, type MigrationError, type MigrationErrorCode, type MigrationLookupError, type MigrationLookupErrorCode, type MigrationOp, type MigrationParams, type MigrationRevertParams, MigrationService, type MigrationServiceConstructorParams, type MigrationTokens, MintPositionEventAbi, type MintPositionEventLog, type MoneyMarketAction, type MoneyMarketAllowanceCheckError, type MoneyMarketAllowanceCheckErrorCode, type MoneyMarketAllowanceParams, type MoneyMarketApproveActionParams, type MoneyMarketApproveError, type MoneyMarketApproveErrorCode, type MoneyMarketAsset, type MoneyMarketAssetBorrowers, type MoneyMarketAssetSuppliers, type MoneyMarketBorrowActionParams, type MoneyMarketBorrowParams, type MoneyMarketBorrowers, type MoneyMarketCreateIntentError, type MoneyMarketCreateIntentErrorCode, MoneyMarketDataService, type MoneyMarketDataServiceConstructorParams, type MoneyMarketEncodeBorrowParams, type MoneyMarketEncodeRepayParams, type MoneyMarketEncodeRepayWithATokensParams, type MoneyMarketEncodeSupplyParams, type MoneyMarketEncodeWithdrawParams, type MoneyMarketError, type MoneyMarketErrorCode, type MoneyMarketGasEstimationError, type MoneyMarketGasEstimationErrorCode, type MoneyMarketOrchestrationError, type MoneyMarketOrchestrationErrorCode, type MoneyMarketParams, type MoneyMarketPosition, type MoneyMarketRepayActionParams, type MoneyMarketRepayParams, MoneyMarketService, type MoneyMarketServiceConstructorParams, type MoneyMarketSupplyActionParams, type MoneyMarketSupplyParams, type MoneyMarketWithdrawActionParams, type MoneyMarketWithdrawParams, NEAR_DEFAULT_GAS, NEAR_STORAGE_DEPOSIT, NearSpokeService, type OnDemandBtcPayload, type OnDemandRelayData, type OptionalRaw, type OptionalSkipSimulation, type OptionalTimeout, type OrderbookResponse, type PacketData, type PartnerAction, type PartnerError, type PartnerErrorCode, type PartnerFeeClaimAssetBalance, PartnerFeeClaimService, type PartnerFeeClaimServiceConstructorParams, type PartnerFeeClaimSwapAction, type PartnerFeeClaimSwapParams, PartnerService, type PartnerServiceConfig, type PartnerServiceConstructorParams, Permit2Service, type PermitBatch, type PermitDetails, type PermitSingle, type PoolBaseCurrencyHumanized, type PoolData, type PoolRewardConfig, type PoolSpokeAssets, type PostExecutionError, type PostExecutionErrorCode, ProtocolIntentsAbi, type QueryMsg, type QueryResponse, RAY, RAY_DECIMALS, RELAY_ERROR_CODES, RadfiApiError, type RadfiAuthResult, type RadfiBuildTxResponse, type RadfiErrorBody, type RadfiMaxSpentResponse, RadfiProvider, type RadfiResponseEnvelope, type RadfiTradingWallet, type RadfiUtxo, type RadfiUtxoListResponse, type RadfiWalletBalance, type RateLimitConfig, type RawDestinationParams, type RecoveryAction, type RecoveryError, type RecoveryErrorCode, RecoveryService, type RecoveryServiceConstructorParams, type RelayAction, type RelayAndWaitParams, type RelayCode, type RelayErrorCode, type RelayExtraData, type RelayRequestDetail, type RelayRequestSigning, type RelayTxStatus, type RelayWrappedErrorCode, type RequestConfig, type RequestOverrideConfig, type RequestTrustlineParams, type ReserveCalculationData, type ReserveData, type ReserveDataHumanized, type ReserveDataLegacy, type ReserveDataWithPrice, type ReserveEMode, type ReserveIncentiveDict, type ReservesDataHumanized, type ReservesIncentiveDataHumanized, type ResponseAddressType, type ResponseSigningType, type RevertMigrationOrchestrationError, type RevertMigrationOrchestrationErrorCode, type RewardInfoHumanized, SECONDS_PER_YEAR, SODAX_ERROR_CODES, SODAX_FEATURES, type SendMessageParams, type SetSwapPreferenceAction, type SetSwapPreferenceParams, Sodax, SodaxError, type SodaxErrorCode, type SodaxErrorContext, type SodaxErrorJSON, type SodaxFeature, type SodaxPhase, SolanaSpokeService, SolverApiService, SonicSpokeService, type SpokeApproveParams, type SpokeApproveParamsEvmSpoke, type SpokeApproveParamsHub, type SpokeApproveParamsStellar, type SpokeIsAllowanceValidParams, type SpokeIsAllowanceValidParamsEvmSpoke, type SpokeIsAllowanceValidParamsHub, type SpokeIsAllowanceValidParamsOther, type SpokeIsAllowanceValidParamsStellar, SpokeService, type SpokeServiceConstructorParams, type SpokeServiceType, StacksSpokeService, type StakeAction, type StakeOrchestrationError, type StakeOrchestrationErrorCode, type StakeParams, type StakingActionType, type StakingActionUnion, type StakingAllowanceCheckError, type StakingAllowanceCheckErrorCode, type StakingApproveError, type StakingApproveErrorCode, type StakingConfig, type StakingCreateIntentError, type StakingCreateIntentErrorCode, type StakingError, type StakingErrorCode, type StakingInfo, type StakingInfoFetchError, type StakingInfoFetchErrorCode, StakingLogic, type StakingOrchestrationError, type StakingOrchestrationErrorCode, type StakingParamsUnion, StakingService, type StakingServiceConstructorParams, type State, StellarSpokeService, type SubmitTxParams, type SubmitTxResponse, SuiSpokeService, SupportedMigrationTokens, type SwapAction, type SwapActionParams, type SwapCreateIntentError, type SwapCreateIntentErrorCode, type SwapError, type SwapErrorCode, type SwapExtras, type SwapResponse, SwapService, type SwapServiceConstructorParams, type TokenSpenderPair, type TokenWithConversion, type TxHashPair, type TxStatus, USD_DECIMALS, type UiPoolDataProviderInterface, UiPoolDataProviderService, type UiPoolDataProviderServiceConstructorParams, type UnifiedBnUSDMigrateAction, type UnifiedBnUSDMigrateParams, type UnstakeAction, type UnstakeParams, type UnstakeRequest, type UnstakeRequestWithPenalty, type UnstakingInfo, type UserIncentiveData, type UserIncentiveDataHumanized, type UserIncentiveDict, type UserIntentsResponse, type UserReserveCalculationData, type UserReserveData, type UserReserveDataHumanized, type UserReserveDataString, type UserReservesIncentivesDataHumanized, type UserRewardInfoHumanized, type VaultSwapActionParams, type VaultSwapResponse, type VerifySimulationParams, type VerifyTxHashParams, WAD, WAD_RAY_RATIO, WEI_DECIMALS, type WaitForTxReceiptParams, type WaitForTxReceiptReturnType, type WaitUntilIntentExecutedPayload, type WalletMode, type WalletSimulationParams, type WithdrawHubAssetAction, type WithdrawHubAssetParams, type WithdrawInfo, adjustAmountByFee, allowanceCheckFailed, approveFailed, assetManagerAbi, balnSwapAbi, binomialApproximatedRayPow, bridgeInvariant, calcOpReturnOutputVbytes, calculateAllReserveIncentives, calculateAllUserIncentives, calculateAvailableBorrowsMarketReferenceCurrency, calculateCompoundedInterest, calculateCompoundedRate, calculateFeeAmount, calculateHealthFactorFromBalances, calculateHealthFactorFromBalancesBigUnits, calculateLinearInterest, calculatePercentageFeeAmount, clPoolAbi, clPoolManagerAbi, clPositionManagerAbi, clQuoterAbi, clRouterAbi, clTickLensAbi, connectionAbi, consoleLogger, convertTransactionInstructionToRaw, createInvariant, deepMerge, defaultHookAbi, dexInvariant, encodeAddress, encodeBtcPayloadToBytes, encodeContractCalls, erc20Abi, erc4626Abi, estimateBitcoinTxSize, executionFailed, formatBasisPoints, formatEModeCategory, formatEModes, formatPercentage, formatReserve, formatReserveUSD, formatReserves, formatReservesAndIncentives, formatUserSummary, formatUserSummaryAndIncentives, gasEstimationFailed, getAndFormatReserveEModes, getAssetManagerIdl, getAssetManagerProgram, getCompoundedBalance, getConnectionIdl, getConnectionProgram, getEvmViemChain, getIconAddressBytes, getLinearBalance, getMarketReferenceCurrencyAndUsdBalance, getPacket, getProvider, getRandomBytes, getReserveNormalizedIncome, getReservesEModes, getSolanaAddressBytes, getTransactionPackets, hexToBigInt, hexToSolanaAddress, hyper, intentCreationFailed, isBalnMigrateParams, isBitcoinChainKeyType, isBitcoinWalletProviderType, isBridgeAllowanceCheckError, isBridgeApproveError, isBridgeCreateIntentError, isBridgeError, isBridgeLookupError, isBridgeOrchestrationError, isCodeMember, isDexError, isEvmChainKeyType, isEvmSpokeChainConfig, isEvmSpokeOnlyChainKeyType, isEvmWalletProviderType, isFeatureError, isHubChainKeyType, isIconAddress, isIconChainKeyType, isIcxCreateRevertMigrationParams, isIcxMigrateParams, isInjectiveChainKeyType, isJsonRpcPayloadResponse, isLeverageYieldAllowanceCheckError, isLeverageYieldApproveError, isLeverageYieldCreateIntentError, isLeverageYieldError, isLeverageYieldLookupError, isLeverageYieldPostExecutionError, isLeverageYieldSwapError, isMigrateOrchestrationError, isMigrationAllowanceCheckError, isMigrationApproveError, isMigrationCreateIntentError, isMigrationError, isMigrationLookupError, isMoneyMarketAllowanceCheckError, isMoneyMarketApproveError, isMoneyMarketCreateIntentError, isMoneyMarketError, isMoneyMarketGasEstimationError, isMoneyMarketOrchestrationError, isNearChainKeyType, isOptionalBitcoinWalletProviderType, isOptionalEvmWalletProviderType, isOptionalStellarWalletProviderType, isPartnerError, isPartnerFeeAmount, isPartnerFeePercentage, isPostExecutionError, isRawDestinationParams, isRecoveryError, isResponseAddressType, isResponseSigningType, isRevertMigrationOrchestrationError, isSodaxError, isSolanaChainKeyType, isSolanaNativeToken, isSonicChainKeyType, isSpokeApproveParamsEvmSpoke, isSpokeApproveParamsHub, isSpokeApproveParamsStellar, isSpokeIsAllowanceValidParamsEvmSpoke, isSpokeIsAllowanceValidParamsHub, isSpokeIsAllowanceValidParamsStellar, isStacksChainKeyType, isStakeOrchestrationError, isStakingAllowanceCheckError, isStakingApproveError, isStakingCreateIntentError, isStakingError, isStakingInfoFetchError, isStakingOrchestrationError, isStellarChainKeyType, isStellarWalletProviderType, isSubmitSwapTxResponse, isSubmitSwapTxStatusResponse, isSuiChainKeyType, isSwapCreateIntentError, isSwapError, isUndefinedOrValidWalletProviderForChainKey, isUnifiedBnUSDMigrateParams, leverageYieldInvariant, lookupFailed, mapRelayFailure, mergeSodaxConfig, messageOf, migrationInvariant, mintPositionParamsAbi, mmInvariant, modifyLiquidityParamsAbi, nativeToUSD, normalize, normalizeBN, normalizePsbtToBase64, normalizeSignatureToBase64, normalizedToUsd, pancakeSwapInfinityDefaultHookAbi, pancakeSwapInfinityPoolManagerAbi, pancakeSwapInfinityPositionManagerAbi, parseToStroops, parseTokenArrayFromJson, partnerInvariant, permit2Abi, poolAbi, poolKeyAbi, randomUint256, rayDiv, rayMul, rayPow, rayToWad, recoveryInvariant, relayTxAndWaitPacket, requestAddress, requestJsonRpc, requestSigning, resolveLogger, retry, reverseEncodeAddress, serializeAddressData, silentLogger, sleep, sodaxInvariant, sonicWalletFactoryAbi, spokeAssetManagerAbi, stakedSodaAbi, stakingInvariant, stakingRouterAbi, stataTokenFactoryAbi, submitTransaction, swapExactInSingleParamsAbi, swapInvariant, uiPoolDataAbi, universalRouterAbi, unknownFailed, valueToBigNumber, valueToZDBigNumber, variableDebtTokenAbi, vaultTokenAbi, verifyFailed, wadToRay, waitForStacksTransaction, waitForTransactionReceipt, waitUntilIntentExecuted, walletFactoryAbi, wrappedSonicAbi };
|
package/dist/index.d.ts
CHANGED
|
@@ -8116,6 +8116,7 @@ type OptionalSkipSimulation$1 = {
|
|
|
8116
8116
|
type DepositParams<C extends SpokeChainKey, Raw extends boolean = boolean> = {
|
|
8117
8117
|
srcAddress: GetAddressType<C>;
|
|
8118
8118
|
srcPublicKey?: string;
|
|
8119
|
+
accessToken?: string;
|
|
8119
8120
|
srcChainKey: C;
|
|
8120
8121
|
to: HubAddress;
|
|
8121
8122
|
token: GetTokenAddressType<C>;
|
|
@@ -8255,6 +8256,16 @@ type SrcPublicKeySlot<K extends SpokeChainKey> = GetChainType<K> extends 'STACKS
|
|
|
8255
8256
|
} : {
|
|
8256
8257
|
srcPublicKey?: never;
|
|
8257
8258
|
};
|
|
8259
|
+
/** Bound Exchange (Radfi) inputs for raw Bitcoin TRADING-mode swap intents. */
|
|
8260
|
+
type BitcoinBoundExtras = {
|
|
8261
|
+
/** Bound token, for raw Bitcoin TRADING callers; falls back to the RadfiProvider instance token when omitted. */
|
|
8262
|
+
accessToken?: string;
|
|
8263
|
+
};
|
|
8264
|
+
type BitcoinBoundSlot<K extends SpokeChainKey> = GetChainType<K> extends 'BITCOIN' ? {
|
|
8265
|
+
bound?: BitcoinBoundExtras;
|
|
8266
|
+
} : {
|
|
8267
|
+
bound?: never;
|
|
8268
|
+
};
|
|
8258
8269
|
/**
|
|
8259
8270
|
* Per-action extras for swap intent creation, supplied via the `extras` slot of the swap
|
|
8260
8271
|
* action params.
|
|
@@ -8262,7 +8273,7 @@ type SrcPublicKeySlot<K extends SpokeChainKey> = GetChainType<K> extends 'STACKS
|
|
|
8262
8273
|
type SwapExtras<K extends SpokeChainKey = SpokeChainKey> = {
|
|
8263
8274
|
/** Overrides the configured swap partner fee for this action; falls back to config when omitted. */
|
|
8264
8275
|
partnerFee?: PartnerFee;
|
|
8265
|
-
} & SrcPublicKeySlot<K>;
|
|
8276
|
+
} & SrcPublicKeySlot<K> & BitcoinBoundSlot<K>;
|
|
8266
8277
|
type Intent = {
|
|
8267
8278
|
intentId: bigint;
|
|
8268
8279
|
creator: Address;
|
|
@@ -8782,6 +8793,15 @@ type RadfiErrorBody = {
|
|
|
8782
8793
|
message?: string;
|
|
8783
8794
|
};
|
|
8784
8795
|
};
|
|
8796
|
+
/**
|
|
8797
|
+
* Shape of a parsed Bound Exchange JSON response: the {@link RadfiErrorBody} envelope fields plus an
|
|
8798
|
+
* optional, per-call typed `data` payload. Modeled as a superset of `RadfiErrorBody` so a parsed body
|
|
8799
|
+
* can be handed straight to {@link RadfiApiError} on the error path. `data` is optional because Bound
|
|
8800
|
+
* can answer 2xx with a logical-error envelope (no `data`); callers guard before dereferencing it.
|
|
8801
|
+
*/
|
|
8802
|
+
type RadfiResponseEnvelope<T = unknown> = RadfiErrorBody & {
|
|
8803
|
+
data?: T;
|
|
8804
|
+
};
|
|
8785
8805
|
/**
|
|
8786
8806
|
* Structured error from a Bound Exchange HTTP request. Exposes `status` (HTTP), `code`
|
|
8787
8807
|
* (Bound Exchange-specific identifier), and `details` (human-readable) so callers can
|
|
@@ -8890,7 +8910,7 @@ declare class RadfiProvider {
|
|
|
8890
8910
|
walletAddress: string;
|
|
8891
8911
|
publicKey: string;
|
|
8892
8912
|
}, accessToken: string): Promise<RadfiTradingWallet>;
|
|
8893
|
-
getTradingWallet(userAddress: string
|
|
8913
|
+
getTradingWallet(userAddress: string): Promise<RadfiTradingWallet>;
|
|
8894
8914
|
getBalance(address: string): Promise<RadfiWalletBalance>;
|
|
8895
8915
|
checkIfTradingWalletExists(userAddress: string): Promise<boolean>;
|
|
8896
8916
|
createWithdrawTransaction(params: {
|
|
@@ -8962,6 +8982,27 @@ declare class RadfiProvider {
|
|
|
8962
8982
|
tokenId: string;
|
|
8963
8983
|
withdrawTo: string;
|
|
8964
8984
|
}, accessToken: string): Promise<RadfiMaxSpentResponse>;
|
|
8985
|
+
/**
|
|
8986
|
+
* Resolve the bearer credential for an authenticated Bound Exchange call, failing fast when none
|
|
8987
|
+
* is available. A server-side raw-build caller that never ran the interactive sign-in would
|
|
8988
|
+
* otherwise send `Authorization: Bearer ` (empty) and get an opaque 403 from Bound's gateway;
|
|
8989
|
+
* throwing here turns that into an actionable client-side error naming the fix. We deliberately do
|
|
8990
|
+
* NOT validate the token's contents (expiry / scope / signature) — only Bound can, and an invalid
|
|
8991
|
+
* token still surfaces as a legible 401/403 via `parseJsonBody`.
|
|
8992
|
+
*/
|
|
8993
|
+
private resolveAuth;
|
|
8994
|
+
/**
|
|
8995
|
+
* Parse a Bound Exchange response body as JSON defensively.
|
|
8996
|
+
*
|
|
8997
|
+
* Bound (or an upstream gateway / WAF / CDN) can answer a request with an HTML error page
|
|
8998
|
+
* instead of JSON — e.g. an unauthenticated call, a blocked origin, a 404, or a 5xx. Calling
|
|
8999
|
+
* `res.json()` on that throws a cryptic `SyntaxError: Unexpected token '<'` that masks the real
|
|
9000
|
+
* HTTP status and bubbles up as an opaque failure (it surfaced as a `createIntent` /
|
|
9001
|
+
* `INTENT_CREATION_FAILED` "is not valid JSON" error on the Bitcoin raw-tx path). Reading the
|
|
9002
|
+
* body as text first and parsing it ourselves lets us raise a `RadfiApiError` carrying the
|
|
9003
|
+
* actual status code and a body snippet instead.
|
|
9004
|
+
*/
|
|
9005
|
+
private parseJsonBody;
|
|
8965
9006
|
private request;
|
|
8966
9007
|
}
|
|
8967
9008
|
|
|
@@ -9117,9 +9158,7 @@ declare class BitcoinSpokeService {
|
|
|
9117
9158
|
/**
|
|
9118
9159
|
* Deposit operation - transfer BTC to the asset manager
|
|
9119
9160
|
*/
|
|
9120
|
-
deposit<Raw extends boolean = false>(params: DepositParams<BitcoinChainKey, Raw>
|
|
9121
|
-
accessToken?: string;
|
|
9122
|
-
}): Promise<TxReturnType<BitcoinChainKey, Raw>>;
|
|
9161
|
+
deposit<Raw extends boolean = false>(params: DepositParams<BitcoinChainKey, Raw>): Promise<TxReturnType<BitcoinChainKey, Raw>>;
|
|
9123
9162
|
/**
|
|
9124
9163
|
* Build deposit PSBT with embedded cross-chain data
|
|
9125
9164
|
*/
|
|
@@ -17114,4 +17153,4 @@ type DexErrorCode = LookupErrorCode;
|
|
|
17114
17153
|
type DexError = SodaxError<DexErrorCode>;
|
|
17115
17154
|
declare const isDexError: (e: unknown) => e is SodaxError<LookupErrorCode>;
|
|
17116
17155
|
|
|
17117
|
-
export { ALLOWANCE_CHECK_CODES, APPROVE_CODES, type AggregatedReserveData, type AllowanceCheckErrorCode, type AllowanceInfo, type AllowanceResponse, type AllowanceTransferDetails, type ApiResponse, type ApproveErrorCode, type ApyRange, type AssetDepositAction, type AssetEntry, AssetService, type AssetServiceConstructorParams, type AssetWithdrawAction, type AutoSwapPreferences, BackendApiService, type BalnLockParams, type BalnMigrateAction, type BalnMigrateParams, type BalnSwapAbi, BalnSwapService, type BalnSwapServiceConstructorParams, type BaseCurrencyInfo, BigIntToHex, type BigNumberValue, BigNumberZeroDecimal, BitcoinSpokeService, type BitcoinTransactionResult, type BitcoinUTXO, BnUSDMigrationService, type BnUSDMigrationServiceConstructorParams, type BnUSDRevertMigrationParams, type BorrowInfo, type BridgeAction, type BridgeAllowanceCheckError, type BridgeAllowanceCheckErrorCode, type BridgeApproveError, type BridgeApproveErrorCode, type BridgeCreateIntentError, type BridgeCreateIntentErrorCode, type BridgeError, type BridgeErrorCode, type BridgeLookupError, type BridgeLookupErrorCode, type BridgeOrchestrationError, type BridgeOrchestrationErrorCode, type BridgeParams, BridgeService, type BridgeServiceConstructorParams, type BtcPayload, CREATE_INTENT_CODES, type CalculateAllReserveIncentivesRequest, type CalculateAllUserIncentivesRequest, type CalculateCompoundedRateRequest, type CallResponse, type CancelIntentActionParams, type CancelIntentParams, type CancelUnstakeAction, type CancelUnstakeParams, type ClClaimRewardsParams, type ClDecreaseLiquidityParams, type ClGetPoolDataParams, type ClIncreaseLiquidityParams, type ClLiquidityClaimRewardsAction, type ClLiquidityDecreaseLiquidityAction, type ClLiquidityIncreaseLiquidityAction, type ClLiquidityWithdrawAction, type ClMintPositionEventLog, type ClPositionInfo, ClService, type ClServiceConstructorParams, type ClSupplyAction, type ClSupplyParams, type ClWithdrawParams, type ClaimAction, type ClaimParams, type CombinedReserveData, type ComputedUserReserve, type ConcentratedLiquidityParams, type ConcentratedLiquidityTokenInfo, ConfigService, type ConfigServiceConstructorParams, type ConnMsg, type CreateAssetDepositParams, type CreateAssetWithdrawParams, type CreateBridgeIntentParams, type CreateIntentErrorCode, type CreateIntentParams, type CreateIntentResult, type CreateLimitOrderParams, type CreateSonicSwapIntentParams, type CreateVaultIntentResult, type CreateViemPublicClientParams, CustomSorobanServer, CustomStellarAccount, type DepositParams, type DepositSimulationParams, type DestinationParamsType, type DetailedLock, type DexError, type DexErrorCode, DexService, type DexServiceConstructorParams, type EModeCategory, type EModeCategoryHumanized, type EModeData, type EModeDataString, type EmodeDataHumanized, type EnrichedToken, type Erc20ApproveParams, type Erc20IsAllowanceParams, Erc20Service, type Erc20Token, Erc4626Service, type EstimateGasParams, EvmAssetManagerService, type EvmDepositToDataParams, EvmHubProvider, type EvmHubProviderConstructorParams, EvmSolverService, EvmSpokeService, EvmVaultTokenService, type EvmWithdrawAssetDataParams, type ExecuteMsg, type FeatureInvariant, type FeeData, type FeeTokenApproveAction, type FeeTokenApproveParams, type FetchHubAssetBalancesParams, type FormatReserveRequest, type FormatReserveResponse, type FormatReserveUSDRequest, type FormatReserveUSDResponse, type FormatReservesAndIncentivesUSDRequest, type FormatReservesUSDRequest, type FormatUserSummaryAndIncentivesRequest, type FormatUserSummaryAndIncentivesResponse, type FormatUserSummaryRequest, type FormatUserSummaryResponse, type FormattedReserveEMode, GAS_ESTIMATION_CODES, type GasEstimationErrorCode, type GetDepositParams, type GetIntentSubmitTxExtraDataParams, type GetPacketParams, type GetPacketResponse, type GetQuoteParams, type GetRelayRequestParamType, type GetRelayResponse, type GetSpokeServiceType, type GetTransactionPacketsParams, type GetTransactionPacketsResponse, type GetTxReceiptType, type GetUserRouterParams, HALF_RAY, HALF_WAD, type HanaWalletRequestEvent, type HanaWalletResponseEvent, HttpRelayError, type HubAssetBalance, type HubProvider, type IconJsonRpcVersion, IconSpokeService, type IcxCreateRevertMigrationParams, type IcxMigrateAction, type IcxMigrateParams, IcxMigrationService, type IcxMigrationServiceConstructorParams, type IcxRevertMigrationAction, type IcxRevertMigrationParams, type IncentiveDataHumanized, type InjTokenInfo, Injective20Token, type InjectiveBalance, InjectiveSpokeService, type InstantUnstakeAction, type InstantUnstakeParams, type InstantiateMsg, type Intent, type IntentAutoSwapResult, IntentCreatedEventAbi, type IntentCreatedEventLog, type IntentData, IntentDataType, type IntentDeliveryInfo, IntentFilledEventAbi, type IntentFilledEventLog, type IntentRelayRequest, type IntentRelayRequestParams, type IntentResponse, type IntentState, type IntentTxResult, IntentsAbi, type JsonRpcPayloadResponse, LOOKUP_CODES, LTV_PRECISION, LendingPoolService, type LendingPoolServiceConstructorParams, type LeverageYieldAction, type LeverageYieldAllowanceCheckError, type LeverageYieldAllowanceCheckErrorCode, type LeverageYieldAllowanceParams, type LeverageYieldApproveError, type LeverageYieldApproveErrorCode, type LeverageYieldApproveParams, type LeverageYieldApr, type LeverageYieldCreateIntentError, type LeverageYieldCreateIntentErrorCode, type LeverageYieldEffectiveApr, type LeverageYieldError, type LeverageYieldErrorCode, type LeverageYieldLookupError, type LeverageYieldLookupErrorCode, type LeverageYieldLsdApr, type LeverageYieldPosition, type LeverageYieldPostExecutionError, type LeverageYieldPostExecutionErrorCode, LeverageYieldService, type LeverageYieldServiceConstructorParams, type LeverageYieldSwapDepositParams, type LeverageYieldSwapError, type LeverageYieldSwapErrorCode, type LeverageYieldSwapPayload, type LeverageYieldSwapWithdrawParams, type LimitOrderActionParams, LockupMultiplier, LockupPeriod, type LookupErrorCode, type MapRelayFailureCtx, type MigrateOrchestrationError, type MigrateOrchestrationErrorCode, type MigrationAction, type MigrationAllowanceCheckError, type MigrationAllowanceCheckErrorCode, type MigrationApproveError, type MigrationApproveErrorCode, type MigrationCreateIntentError, type MigrationCreateIntentErrorCode, type MigrationDirection, type MigrationError, type MigrationErrorCode, type MigrationLookupError, type MigrationLookupErrorCode, type MigrationOp, type MigrationParams, type MigrationRevertParams, MigrationService, type MigrationServiceConstructorParams, type MigrationTokens, MintPositionEventAbi, type MintPositionEventLog, type MoneyMarketAction, type MoneyMarketAllowanceCheckError, type MoneyMarketAllowanceCheckErrorCode, type MoneyMarketAllowanceParams, type MoneyMarketApproveActionParams, type MoneyMarketApproveError, type MoneyMarketApproveErrorCode, type MoneyMarketAsset, type MoneyMarketAssetBorrowers, type MoneyMarketAssetSuppliers, type MoneyMarketBorrowActionParams, type MoneyMarketBorrowParams, type MoneyMarketBorrowers, type MoneyMarketCreateIntentError, type MoneyMarketCreateIntentErrorCode, MoneyMarketDataService, type MoneyMarketDataServiceConstructorParams, type MoneyMarketEncodeBorrowParams, type MoneyMarketEncodeRepayParams, type MoneyMarketEncodeRepayWithATokensParams, type MoneyMarketEncodeSupplyParams, type MoneyMarketEncodeWithdrawParams, type MoneyMarketError, type MoneyMarketErrorCode, type MoneyMarketGasEstimationError, type MoneyMarketGasEstimationErrorCode, type MoneyMarketOrchestrationError, type MoneyMarketOrchestrationErrorCode, type MoneyMarketParams, type MoneyMarketPosition, type MoneyMarketRepayActionParams, type MoneyMarketRepayParams, MoneyMarketService, type MoneyMarketServiceConstructorParams, type MoneyMarketSupplyActionParams, type MoneyMarketSupplyParams, type MoneyMarketWithdrawActionParams, type MoneyMarketWithdrawParams, NEAR_DEFAULT_GAS, NEAR_STORAGE_DEPOSIT, NearSpokeService, type OnDemandBtcPayload, type OnDemandRelayData, type OptionalRaw, type OptionalSkipSimulation, type OptionalTimeout, type OrderbookResponse, type PacketData, type PartnerAction, type PartnerError, type PartnerErrorCode, type PartnerFeeClaimAssetBalance, PartnerFeeClaimService, type PartnerFeeClaimServiceConstructorParams, type PartnerFeeClaimSwapAction, type PartnerFeeClaimSwapParams, PartnerService, type PartnerServiceConfig, type PartnerServiceConstructorParams, Permit2Service, type PermitBatch, type PermitDetails, type PermitSingle, type PoolBaseCurrencyHumanized, type PoolData, type PoolRewardConfig, type PoolSpokeAssets, type PostExecutionError, type PostExecutionErrorCode, ProtocolIntentsAbi, type QueryMsg, type QueryResponse, RAY, RAY_DECIMALS, RELAY_ERROR_CODES, RadfiApiError, type RadfiAuthResult, type RadfiBuildTxResponse, type RadfiErrorBody, type RadfiMaxSpentResponse, RadfiProvider, type RadfiTradingWallet, type RadfiUtxo, type RadfiUtxoListResponse, type RadfiWalletBalance, type RateLimitConfig, type RawDestinationParams, type RecoveryAction, type RecoveryError, type RecoveryErrorCode, RecoveryService, type RecoveryServiceConstructorParams, type RelayAction, type RelayAndWaitParams, type RelayCode, type RelayErrorCode, type RelayExtraData, type RelayRequestDetail, type RelayRequestSigning, type RelayTxStatus, type RelayWrappedErrorCode, type RequestConfig, type RequestOverrideConfig, type RequestTrustlineParams, type ReserveCalculationData, type ReserveData, type ReserveDataHumanized, type ReserveDataLegacy, type ReserveDataWithPrice, type ReserveEMode, type ReserveIncentiveDict, type ReservesDataHumanized, type ReservesIncentiveDataHumanized, type ResponseAddressType, type ResponseSigningType, type RevertMigrationOrchestrationError, type RevertMigrationOrchestrationErrorCode, type RewardInfoHumanized, SECONDS_PER_YEAR, SODAX_ERROR_CODES, SODAX_FEATURES, type SendMessageParams, type SetSwapPreferenceAction, type SetSwapPreferenceParams, Sodax, SodaxError, type SodaxErrorCode, type SodaxErrorContext, type SodaxErrorJSON, type SodaxFeature, type SodaxPhase, SolanaSpokeService, SolverApiService, SonicSpokeService, type SpokeApproveParams, type SpokeApproveParamsEvmSpoke, type SpokeApproveParamsHub, type SpokeApproveParamsStellar, type SpokeIsAllowanceValidParams, type SpokeIsAllowanceValidParamsEvmSpoke, type SpokeIsAllowanceValidParamsHub, type SpokeIsAllowanceValidParamsOther, type SpokeIsAllowanceValidParamsStellar, SpokeService, type SpokeServiceConstructorParams, type SpokeServiceType, StacksSpokeService, type StakeAction, type StakeOrchestrationError, type StakeOrchestrationErrorCode, type StakeParams, type StakingActionType, type StakingActionUnion, type StakingAllowanceCheckError, type StakingAllowanceCheckErrorCode, type StakingApproveError, type StakingApproveErrorCode, type StakingConfig, type StakingCreateIntentError, type StakingCreateIntentErrorCode, type StakingError, type StakingErrorCode, type StakingInfo, type StakingInfoFetchError, type StakingInfoFetchErrorCode, StakingLogic, type StakingOrchestrationError, type StakingOrchestrationErrorCode, type StakingParamsUnion, StakingService, type StakingServiceConstructorParams, type State, StellarSpokeService, type SubmitTxParams, type SubmitTxResponse, SuiSpokeService, SupportedMigrationTokens, type SwapAction, type SwapActionParams, type SwapCreateIntentError, type SwapCreateIntentErrorCode, type SwapError, type SwapErrorCode, type SwapExtras, type SwapResponse, SwapService, type SwapServiceConstructorParams, type TokenSpenderPair, type TokenWithConversion, type TxHashPair, type TxStatus, USD_DECIMALS, type UiPoolDataProviderInterface, UiPoolDataProviderService, type UiPoolDataProviderServiceConstructorParams, type UnifiedBnUSDMigrateAction, type UnifiedBnUSDMigrateParams, type UnstakeAction, type UnstakeParams, type UnstakeRequest, type UnstakeRequestWithPenalty, type UnstakingInfo, type UserIncentiveData, type UserIncentiveDataHumanized, type UserIncentiveDict, type UserIntentsResponse, type UserReserveCalculationData, type UserReserveData, type UserReserveDataHumanized, type UserReserveDataString, type UserReservesIncentivesDataHumanized, type UserRewardInfoHumanized, type VaultSwapActionParams, type VaultSwapResponse, type VerifySimulationParams, type VerifyTxHashParams, WAD, WAD_RAY_RATIO, WEI_DECIMALS, type WaitForTxReceiptParams, type WaitForTxReceiptReturnType, type WaitUntilIntentExecutedPayload, type WalletMode, type WalletSimulationParams, type WithdrawHubAssetAction, type WithdrawHubAssetParams, type WithdrawInfo, adjustAmountByFee, allowanceCheckFailed, approveFailed, assetManagerAbi, balnSwapAbi, binomialApproximatedRayPow, bridgeInvariant, calcOpReturnOutputVbytes, calculateAllReserveIncentives, calculateAllUserIncentives, calculateAvailableBorrowsMarketReferenceCurrency, calculateCompoundedInterest, calculateCompoundedRate, calculateFeeAmount, calculateHealthFactorFromBalances, calculateHealthFactorFromBalancesBigUnits, calculateLinearInterest, calculatePercentageFeeAmount, clPoolAbi, clPoolManagerAbi, clPositionManagerAbi, clQuoterAbi, clRouterAbi, clTickLensAbi, connectionAbi, consoleLogger, convertTransactionInstructionToRaw, createInvariant, deepMerge, defaultHookAbi, dexInvariant, encodeAddress, encodeBtcPayloadToBytes, encodeContractCalls, erc20Abi, erc4626Abi, estimateBitcoinTxSize, executionFailed, formatBasisPoints, formatEModeCategory, formatEModes, formatPercentage, formatReserve, formatReserveUSD, formatReserves, formatReservesAndIncentives, formatUserSummary, formatUserSummaryAndIncentives, gasEstimationFailed, getAndFormatReserveEModes, getAssetManagerIdl, getAssetManagerProgram, getCompoundedBalance, getConnectionIdl, getConnectionProgram, getEvmViemChain, getIconAddressBytes, getLinearBalance, getMarketReferenceCurrencyAndUsdBalance, getPacket, getProvider, getRandomBytes, getReserveNormalizedIncome, getReservesEModes, getSolanaAddressBytes, getTransactionPackets, hexToBigInt, hexToSolanaAddress, hyper, intentCreationFailed, isBalnMigrateParams, isBitcoinChainKeyType, isBitcoinWalletProviderType, isBridgeAllowanceCheckError, isBridgeApproveError, isBridgeCreateIntentError, isBridgeError, isBridgeLookupError, isBridgeOrchestrationError, isCodeMember, isDexError, isEvmChainKeyType, isEvmSpokeChainConfig, isEvmSpokeOnlyChainKeyType, isEvmWalletProviderType, isFeatureError, isHubChainKeyType, isIconAddress, isIconChainKeyType, isIcxCreateRevertMigrationParams, isIcxMigrateParams, isInjectiveChainKeyType, isJsonRpcPayloadResponse, isLeverageYieldAllowanceCheckError, isLeverageYieldApproveError, isLeverageYieldCreateIntentError, isLeverageYieldError, isLeverageYieldLookupError, isLeverageYieldPostExecutionError, isLeverageYieldSwapError, isMigrateOrchestrationError, isMigrationAllowanceCheckError, isMigrationApproveError, isMigrationCreateIntentError, isMigrationError, isMigrationLookupError, isMoneyMarketAllowanceCheckError, isMoneyMarketApproveError, isMoneyMarketCreateIntentError, isMoneyMarketError, isMoneyMarketGasEstimationError, isMoneyMarketOrchestrationError, isNearChainKeyType, isOptionalBitcoinWalletProviderType, isOptionalEvmWalletProviderType, isOptionalStellarWalletProviderType, isPartnerError, isPartnerFeeAmount, isPartnerFeePercentage, isPostExecutionError, isRawDestinationParams, isRecoveryError, isResponseAddressType, isResponseSigningType, isRevertMigrationOrchestrationError, isSodaxError, isSolanaChainKeyType, isSolanaNativeToken, isSonicChainKeyType, isSpokeApproveParamsEvmSpoke, isSpokeApproveParamsHub, isSpokeApproveParamsStellar, isSpokeIsAllowanceValidParamsEvmSpoke, isSpokeIsAllowanceValidParamsHub, isSpokeIsAllowanceValidParamsStellar, isStacksChainKeyType, isStakeOrchestrationError, isStakingAllowanceCheckError, isStakingApproveError, isStakingCreateIntentError, isStakingError, isStakingInfoFetchError, isStakingOrchestrationError, isStellarChainKeyType, isStellarWalletProviderType, isSubmitSwapTxResponse, isSubmitSwapTxStatusResponse, isSuiChainKeyType, isSwapCreateIntentError, isSwapError, isUndefinedOrValidWalletProviderForChainKey, isUnifiedBnUSDMigrateParams, leverageYieldInvariant, lookupFailed, mapRelayFailure, mergeSodaxConfig, messageOf, migrationInvariant, mintPositionParamsAbi, mmInvariant, modifyLiquidityParamsAbi, nativeToUSD, normalize, normalizeBN, normalizePsbtToBase64, normalizeSignatureToBase64, normalizedToUsd, pancakeSwapInfinityDefaultHookAbi, pancakeSwapInfinityPoolManagerAbi, pancakeSwapInfinityPositionManagerAbi, parseToStroops, parseTokenArrayFromJson, partnerInvariant, permit2Abi, poolAbi, poolKeyAbi, randomUint256, rayDiv, rayMul, rayPow, rayToWad, recoveryInvariant, relayTxAndWaitPacket, requestAddress, requestJsonRpc, requestSigning, resolveLogger, retry, reverseEncodeAddress, serializeAddressData, silentLogger, sleep, sodaxInvariant, sonicWalletFactoryAbi, spokeAssetManagerAbi, stakedSodaAbi, stakingInvariant, stakingRouterAbi, stataTokenFactoryAbi, submitTransaction, swapExactInSingleParamsAbi, swapInvariant, uiPoolDataAbi, universalRouterAbi, unknownFailed, valueToBigNumber, valueToZDBigNumber, variableDebtTokenAbi, vaultTokenAbi, verifyFailed, wadToRay, waitForStacksTransaction, waitForTransactionReceipt, waitUntilIntentExecuted, walletFactoryAbi, wrappedSonicAbi };
|
|
17156
|
+
export { ALLOWANCE_CHECK_CODES, APPROVE_CODES, type AggregatedReserveData, type AllowanceCheckErrorCode, type AllowanceInfo, type AllowanceResponse, type AllowanceTransferDetails, type ApiResponse, type ApproveErrorCode, type ApyRange, type AssetDepositAction, type AssetEntry, AssetService, type AssetServiceConstructorParams, type AssetWithdrawAction, type AutoSwapPreferences, BackendApiService, type BalnLockParams, type BalnMigrateAction, type BalnMigrateParams, type BalnSwapAbi, BalnSwapService, type BalnSwapServiceConstructorParams, type BaseCurrencyInfo, BigIntToHex, type BigNumberValue, BigNumberZeroDecimal, type BitcoinBoundExtras, BitcoinSpokeService, type BitcoinTransactionResult, type BitcoinUTXO, BnUSDMigrationService, type BnUSDMigrationServiceConstructorParams, type BnUSDRevertMigrationParams, type BorrowInfo, type BridgeAction, type BridgeAllowanceCheckError, type BridgeAllowanceCheckErrorCode, type BridgeApproveError, type BridgeApproveErrorCode, type BridgeCreateIntentError, type BridgeCreateIntentErrorCode, type BridgeError, type BridgeErrorCode, type BridgeLookupError, type BridgeLookupErrorCode, type BridgeOrchestrationError, type BridgeOrchestrationErrorCode, type BridgeParams, BridgeService, type BridgeServiceConstructorParams, type BtcPayload, CREATE_INTENT_CODES, type CalculateAllReserveIncentivesRequest, type CalculateAllUserIncentivesRequest, type CalculateCompoundedRateRequest, type CallResponse, type CancelIntentActionParams, type CancelIntentParams, type CancelUnstakeAction, type CancelUnstakeParams, type ClClaimRewardsParams, type ClDecreaseLiquidityParams, type ClGetPoolDataParams, type ClIncreaseLiquidityParams, type ClLiquidityClaimRewardsAction, type ClLiquidityDecreaseLiquidityAction, type ClLiquidityIncreaseLiquidityAction, type ClLiquidityWithdrawAction, type ClMintPositionEventLog, type ClPositionInfo, ClService, type ClServiceConstructorParams, type ClSupplyAction, type ClSupplyParams, type ClWithdrawParams, type ClaimAction, type ClaimParams, type CombinedReserveData, type ComputedUserReserve, type ConcentratedLiquidityParams, type ConcentratedLiquidityTokenInfo, ConfigService, type ConfigServiceConstructorParams, type ConnMsg, type CreateAssetDepositParams, type CreateAssetWithdrawParams, type CreateBridgeIntentParams, type CreateIntentErrorCode, type CreateIntentParams, type CreateIntentResult, type CreateLimitOrderParams, type CreateSonicSwapIntentParams, type CreateVaultIntentResult, type CreateViemPublicClientParams, CustomSorobanServer, CustomStellarAccount, type DepositParams, type DepositSimulationParams, type DestinationParamsType, type DetailedLock, type DexError, type DexErrorCode, DexService, type DexServiceConstructorParams, type EModeCategory, type EModeCategoryHumanized, type EModeData, type EModeDataString, type EmodeDataHumanized, type EnrichedToken, type Erc20ApproveParams, type Erc20IsAllowanceParams, Erc20Service, type Erc20Token, Erc4626Service, type EstimateGasParams, EvmAssetManagerService, type EvmDepositToDataParams, EvmHubProvider, type EvmHubProviderConstructorParams, EvmSolverService, EvmSpokeService, EvmVaultTokenService, type EvmWithdrawAssetDataParams, type ExecuteMsg, type FeatureInvariant, type FeeData, type FeeTokenApproveAction, type FeeTokenApproveParams, type FetchHubAssetBalancesParams, type FormatReserveRequest, type FormatReserveResponse, type FormatReserveUSDRequest, type FormatReserveUSDResponse, type FormatReservesAndIncentivesUSDRequest, type FormatReservesUSDRequest, type FormatUserSummaryAndIncentivesRequest, type FormatUserSummaryAndIncentivesResponse, type FormatUserSummaryRequest, type FormatUserSummaryResponse, type FormattedReserveEMode, GAS_ESTIMATION_CODES, type GasEstimationErrorCode, type GetDepositParams, type GetIntentSubmitTxExtraDataParams, type GetPacketParams, type GetPacketResponse, type GetQuoteParams, type GetRelayRequestParamType, type GetRelayResponse, type GetSpokeServiceType, type GetTransactionPacketsParams, type GetTransactionPacketsResponse, type GetTxReceiptType, type GetUserRouterParams, HALF_RAY, HALF_WAD, type HanaWalletRequestEvent, type HanaWalletResponseEvent, HttpRelayError, type HubAssetBalance, type HubProvider, type IconJsonRpcVersion, IconSpokeService, type IcxCreateRevertMigrationParams, type IcxMigrateAction, type IcxMigrateParams, IcxMigrationService, type IcxMigrationServiceConstructorParams, type IcxRevertMigrationAction, type IcxRevertMigrationParams, type IncentiveDataHumanized, type InjTokenInfo, Injective20Token, type InjectiveBalance, InjectiveSpokeService, type InstantUnstakeAction, type InstantUnstakeParams, type InstantiateMsg, type Intent, type IntentAutoSwapResult, IntentCreatedEventAbi, type IntentCreatedEventLog, type IntentData, IntentDataType, type IntentDeliveryInfo, IntentFilledEventAbi, type IntentFilledEventLog, type IntentRelayRequest, type IntentRelayRequestParams, type IntentResponse, type IntentState, type IntentTxResult, IntentsAbi, type JsonRpcPayloadResponse, LOOKUP_CODES, LTV_PRECISION, LendingPoolService, type LendingPoolServiceConstructorParams, type LeverageYieldAction, type LeverageYieldAllowanceCheckError, type LeverageYieldAllowanceCheckErrorCode, type LeverageYieldAllowanceParams, type LeverageYieldApproveError, type LeverageYieldApproveErrorCode, type LeverageYieldApproveParams, type LeverageYieldApr, type LeverageYieldCreateIntentError, type LeverageYieldCreateIntentErrorCode, type LeverageYieldEffectiveApr, type LeverageYieldError, type LeverageYieldErrorCode, type LeverageYieldLookupError, type LeverageYieldLookupErrorCode, type LeverageYieldLsdApr, type LeverageYieldPosition, type LeverageYieldPostExecutionError, type LeverageYieldPostExecutionErrorCode, LeverageYieldService, type LeverageYieldServiceConstructorParams, type LeverageYieldSwapDepositParams, type LeverageYieldSwapError, type LeverageYieldSwapErrorCode, type LeverageYieldSwapPayload, type LeverageYieldSwapWithdrawParams, type LimitOrderActionParams, LockupMultiplier, LockupPeriod, type LookupErrorCode, type MapRelayFailureCtx, type MigrateOrchestrationError, type MigrateOrchestrationErrorCode, type MigrationAction, type MigrationAllowanceCheckError, type MigrationAllowanceCheckErrorCode, type MigrationApproveError, type MigrationApproveErrorCode, type MigrationCreateIntentError, type MigrationCreateIntentErrorCode, type MigrationDirection, type MigrationError, type MigrationErrorCode, type MigrationLookupError, type MigrationLookupErrorCode, type MigrationOp, type MigrationParams, type MigrationRevertParams, MigrationService, type MigrationServiceConstructorParams, type MigrationTokens, MintPositionEventAbi, type MintPositionEventLog, type MoneyMarketAction, type MoneyMarketAllowanceCheckError, type MoneyMarketAllowanceCheckErrorCode, type MoneyMarketAllowanceParams, type MoneyMarketApproveActionParams, type MoneyMarketApproveError, type MoneyMarketApproveErrorCode, type MoneyMarketAsset, type MoneyMarketAssetBorrowers, type MoneyMarketAssetSuppliers, type MoneyMarketBorrowActionParams, type MoneyMarketBorrowParams, type MoneyMarketBorrowers, type MoneyMarketCreateIntentError, type MoneyMarketCreateIntentErrorCode, MoneyMarketDataService, type MoneyMarketDataServiceConstructorParams, type MoneyMarketEncodeBorrowParams, type MoneyMarketEncodeRepayParams, type MoneyMarketEncodeRepayWithATokensParams, type MoneyMarketEncodeSupplyParams, type MoneyMarketEncodeWithdrawParams, type MoneyMarketError, type MoneyMarketErrorCode, type MoneyMarketGasEstimationError, type MoneyMarketGasEstimationErrorCode, type MoneyMarketOrchestrationError, type MoneyMarketOrchestrationErrorCode, type MoneyMarketParams, type MoneyMarketPosition, type MoneyMarketRepayActionParams, type MoneyMarketRepayParams, MoneyMarketService, type MoneyMarketServiceConstructorParams, type MoneyMarketSupplyActionParams, type MoneyMarketSupplyParams, type MoneyMarketWithdrawActionParams, type MoneyMarketWithdrawParams, NEAR_DEFAULT_GAS, NEAR_STORAGE_DEPOSIT, NearSpokeService, type OnDemandBtcPayload, type OnDemandRelayData, type OptionalRaw, type OptionalSkipSimulation, type OptionalTimeout, type OrderbookResponse, type PacketData, type PartnerAction, type PartnerError, type PartnerErrorCode, type PartnerFeeClaimAssetBalance, PartnerFeeClaimService, type PartnerFeeClaimServiceConstructorParams, type PartnerFeeClaimSwapAction, type PartnerFeeClaimSwapParams, PartnerService, type PartnerServiceConfig, type PartnerServiceConstructorParams, Permit2Service, type PermitBatch, type PermitDetails, type PermitSingle, type PoolBaseCurrencyHumanized, type PoolData, type PoolRewardConfig, type PoolSpokeAssets, type PostExecutionError, type PostExecutionErrorCode, ProtocolIntentsAbi, type QueryMsg, type QueryResponse, RAY, RAY_DECIMALS, RELAY_ERROR_CODES, RadfiApiError, type RadfiAuthResult, type RadfiBuildTxResponse, type RadfiErrorBody, type RadfiMaxSpentResponse, RadfiProvider, type RadfiResponseEnvelope, type RadfiTradingWallet, type RadfiUtxo, type RadfiUtxoListResponse, type RadfiWalletBalance, type RateLimitConfig, type RawDestinationParams, type RecoveryAction, type RecoveryError, type RecoveryErrorCode, RecoveryService, type RecoveryServiceConstructorParams, type RelayAction, type RelayAndWaitParams, type RelayCode, type RelayErrorCode, type RelayExtraData, type RelayRequestDetail, type RelayRequestSigning, type RelayTxStatus, type RelayWrappedErrorCode, type RequestConfig, type RequestOverrideConfig, type RequestTrustlineParams, type ReserveCalculationData, type ReserveData, type ReserveDataHumanized, type ReserveDataLegacy, type ReserveDataWithPrice, type ReserveEMode, type ReserveIncentiveDict, type ReservesDataHumanized, type ReservesIncentiveDataHumanized, type ResponseAddressType, type ResponseSigningType, type RevertMigrationOrchestrationError, type RevertMigrationOrchestrationErrorCode, type RewardInfoHumanized, SECONDS_PER_YEAR, SODAX_ERROR_CODES, SODAX_FEATURES, type SendMessageParams, type SetSwapPreferenceAction, type SetSwapPreferenceParams, Sodax, SodaxError, type SodaxErrorCode, type SodaxErrorContext, type SodaxErrorJSON, type SodaxFeature, type SodaxPhase, SolanaSpokeService, SolverApiService, SonicSpokeService, type SpokeApproveParams, type SpokeApproveParamsEvmSpoke, type SpokeApproveParamsHub, type SpokeApproveParamsStellar, type SpokeIsAllowanceValidParams, type SpokeIsAllowanceValidParamsEvmSpoke, type SpokeIsAllowanceValidParamsHub, type SpokeIsAllowanceValidParamsOther, type SpokeIsAllowanceValidParamsStellar, SpokeService, type SpokeServiceConstructorParams, type SpokeServiceType, StacksSpokeService, type StakeAction, type StakeOrchestrationError, type StakeOrchestrationErrorCode, type StakeParams, type StakingActionType, type StakingActionUnion, type StakingAllowanceCheckError, type StakingAllowanceCheckErrorCode, type StakingApproveError, type StakingApproveErrorCode, type StakingConfig, type StakingCreateIntentError, type StakingCreateIntentErrorCode, type StakingError, type StakingErrorCode, type StakingInfo, type StakingInfoFetchError, type StakingInfoFetchErrorCode, StakingLogic, type StakingOrchestrationError, type StakingOrchestrationErrorCode, type StakingParamsUnion, StakingService, type StakingServiceConstructorParams, type State, StellarSpokeService, type SubmitTxParams, type SubmitTxResponse, SuiSpokeService, SupportedMigrationTokens, type SwapAction, type SwapActionParams, type SwapCreateIntentError, type SwapCreateIntentErrorCode, type SwapError, type SwapErrorCode, type SwapExtras, type SwapResponse, SwapService, type SwapServiceConstructorParams, type TokenSpenderPair, type TokenWithConversion, type TxHashPair, type TxStatus, USD_DECIMALS, type UiPoolDataProviderInterface, UiPoolDataProviderService, type UiPoolDataProviderServiceConstructorParams, type UnifiedBnUSDMigrateAction, type UnifiedBnUSDMigrateParams, type UnstakeAction, type UnstakeParams, type UnstakeRequest, type UnstakeRequestWithPenalty, type UnstakingInfo, type UserIncentiveData, type UserIncentiveDataHumanized, type UserIncentiveDict, type UserIntentsResponse, type UserReserveCalculationData, type UserReserveData, type UserReserveDataHumanized, type UserReserveDataString, type UserReservesIncentivesDataHumanized, type UserRewardInfoHumanized, type VaultSwapActionParams, type VaultSwapResponse, type VerifySimulationParams, type VerifyTxHashParams, WAD, WAD_RAY_RATIO, WEI_DECIMALS, type WaitForTxReceiptParams, type WaitForTxReceiptReturnType, type WaitUntilIntentExecutedPayload, type WalletMode, type WalletSimulationParams, type WithdrawHubAssetAction, type WithdrawHubAssetParams, type WithdrawInfo, adjustAmountByFee, allowanceCheckFailed, approveFailed, assetManagerAbi, balnSwapAbi, binomialApproximatedRayPow, bridgeInvariant, calcOpReturnOutputVbytes, calculateAllReserveIncentives, calculateAllUserIncentives, calculateAvailableBorrowsMarketReferenceCurrency, calculateCompoundedInterest, calculateCompoundedRate, calculateFeeAmount, calculateHealthFactorFromBalances, calculateHealthFactorFromBalancesBigUnits, calculateLinearInterest, calculatePercentageFeeAmount, clPoolAbi, clPoolManagerAbi, clPositionManagerAbi, clQuoterAbi, clRouterAbi, clTickLensAbi, connectionAbi, consoleLogger, convertTransactionInstructionToRaw, createInvariant, deepMerge, defaultHookAbi, dexInvariant, encodeAddress, encodeBtcPayloadToBytes, encodeContractCalls, erc20Abi, erc4626Abi, estimateBitcoinTxSize, executionFailed, formatBasisPoints, formatEModeCategory, formatEModes, formatPercentage, formatReserve, formatReserveUSD, formatReserves, formatReservesAndIncentives, formatUserSummary, formatUserSummaryAndIncentives, gasEstimationFailed, getAndFormatReserveEModes, getAssetManagerIdl, getAssetManagerProgram, getCompoundedBalance, getConnectionIdl, getConnectionProgram, getEvmViemChain, getIconAddressBytes, getLinearBalance, getMarketReferenceCurrencyAndUsdBalance, getPacket, getProvider, getRandomBytes, getReserveNormalizedIncome, getReservesEModes, getSolanaAddressBytes, getTransactionPackets, hexToBigInt, hexToSolanaAddress, hyper, intentCreationFailed, isBalnMigrateParams, isBitcoinChainKeyType, isBitcoinWalletProviderType, isBridgeAllowanceCheckError, isBridgeApproveError, isBridgeCreateIntentError, isBridgeError, isBridgeLookupError, isBridgeOrchestrationError, isCodeMember, isDexError, isEvmChainKeyType, isEvmSpokeChainConfig, isEvmSpokeOnlyChainKeyType, isEvmWalletProviderType, isFeatureError, isHubChainKeyType, isIconAddress, isIconChainKeyType, isIcxCreateRevertMigrationParams, isIcxMigrateParams, isInjectiveChainKeyType, isJsonRpcPayloadResponse, isLeverageYieldAllowanceCheckError, isLeverageYieldApproveError, isLeverageYieldCreateIntentError, isLeverageYieldError, isLeverageYieldLookupError, isLeverageYieldPostExecutionError, isLeverageYieldSwapError, isMigrateOrchestrationError, isMigrationAllowanceCheckError, isMigrationApproveError, isMigrationCreateIntentError, isMigrationError, isMigrationLookupError, isMoneyMarketAllowanceCheckError, isMoneyMarketApproveError, isMoneyMarketCreateIntentError, isMoneyMarketError, isMoneyMarketGasEstimationError, isMoneyMarketOrchestrationError, isNearChainKeyType, isOptionalBitcoinWalletProviderType, isOptionalEvmWalletProviderType, isOptionalStellarWalletProviderType, isPartnerError, isPartnerFeeAmount, isPartnerFeePercentage, isPostExecutionError, isRawDestinationParams, isRecoveryError, isResponseAddressType, isResponseSigningType, isRevertMigrationOrchestrationError, isSodaxError, isSolanaChainKeyType, isSolanaNativeToken, isSonicChainKeyType, isSpokeApproveParamsEvmSpoke, isSpokeApproveParamsHub, isSpokeApproveParamsStellar, isSpokeIsAllowanceValidParamsEvmSpoke, isSpokeIsAllowanceValidParamsHub, isSpokeIsAllowanceValidParamsStellar, isStacksChainKeyType, isStakeOrchestrationError, isStakingAllowanceCheckError, isStakingApproveError, isStakingCreateIntentError, isStakingError, isStakingInfoFetchError, isStakingOrchestrationError, isStellarChainKeyType, isStellarWalletProviderType, isSubmitSwapTxResponse, isSubmitSwapTxStatusResponse, isSuiChainKeyType, isSwapCreateIntentError, isSwapError, isUndefinedOrValidWalletProviderForChainKey, isUnifiedBnUSDMigrateParams, leverageYieldInvariant, lookupFailed, mapRelayFailure, mergeSodaxConfig, messageOf, migrationInvariant, mintPositionParamsAbi, mmInvariant, modifyLiquidityParamsAbi, nativeToUSD, normalize, normalizeBN, normalizePsbtToBase64, normalizeSignatureToBase64, normalizedToUsd, pancakeSwapInfinityDefaultHookAbi, pancakeSwapInfinityPoolManagerAbi, pancakeSwapInfinityPositionManagerAbi, parseToStroops, parseTokenArrayFromJson, partnerInvariant, permit2Abi, poolAbi, poolKeyAbi, randomUint256, rayDiv, rayMul, rayPow, rayToWad, recoveryInvariant, relayTxAndWaitPacket, requestAddress, requestJsonRpc, requestSigning, resolveLogger, retry, reverseEncodeAddress, serializeAddressData, silentLogger, sleep, sodaxInvariant, sonicWalletFactoryAbi, spokeAssetManagerAbi, stakedSodaAbi, stakingInvariant, stakingRouterAbi, stataTokenFactoryAbi, submitTransaction, swapExactInSingleParamsAbi, swapInvariant, uiPoolDataAbi, universalRouterAbi, unknownFailed, valueToBigNumber, valueToZDBigNumber, variableDebtTokenAbi, vaultTokenAbi, verifyFailed, wadToRay, waitForStacksTransaction, waitForTransactionReceipt, waitUntilIntentExecuted, walletFactoryAbi, wrappedSonicAbi };
|
package/dist/index.mjs
CHANGED
|
@@ -4173,7 +4173,7 @@ function isValidWalletProviderForChainKey(chainKey, walletProvider) {
|
|
|
4173
4173
|
}
|
|
4174
4174
|
|
|
4175
4175
|
// ../types/dist/index.js
|
|
4176
|
-
var CONFIG_VERSION =
|
|
4176
|
+
var CONFIG_VERSION = 214;
|
|
4177
4177
|
function isEvmSpokeChainConfig(value) {
|
|
4178
4178
|
return typeof value === "object" && value !== null && value.chain.type === "EVM" && value.chain.key !== HUB_CHAIN_KEY;
|
|
4179
4179
|
}
|
|
@@ -14703,6 +14703,8 @@ var RadfiProvider = class {
|
|
|
14703
14703
|
refreshToken = "";
|
|
14704
14704
|
constructor(config) {
|
|
14705
14705
|
this.config = config;
|
|
14706
|
+
this.accessToken = config.accessToken ?? "";
|
|
14707
|
+
this.refreshToken = config.refreshToken ?? "";
|
|
14706
14708
|
if (config.apiUrl.endsWith("/")) {
|
|
14707
14709
|
this.config.apiUrl = config.apiUrl.slice(0, -1);
|
|
14708
14710
|
}
|
|
@@ -14743,13 +14745,11 @@ var RadfiProvider = class {
|
|
|
14743
14745
|
try {
|
|
14744
14746
|
const { accessToken, refreshToken } = await this.refreshAccessToken(this.refreshToken);
|
|
14745
14747
|
this.setRadfiAccessToken(accessToken, refreshToken);
|
|
14746
|
-
console.log("[ensureRadfiAccessToken] token refreshed successfully");
|
|
14747
14748
|
return;
|
|
14748
14749
|
} catch (error) {
|
|
14749
14750
|
console.warn("[ensureRadfiAccessToken] refresh failed, falling back to full re-auth", error);
|
|
14750
14751
|
}
|
|
14751
14752
|
}
|
|
14752
|
-
console.log("[ensureRadfiAccessToken] performing full re-authentication (BIP322 sign)");
|
|
14753
14753
|
this.accessToken = "";
|
|
14754
14754
|
this.refreshToken = "";
|
|
14755
14755
|
await this.authenticateWithWallet(walletProvider);
|
|
@@ -14765,55 +14765,53 @@ var RadfiProvider = class {
|
|
|
14765
14765
|
method: "POST",
|
|
14766
14766
|
body: JSON.stringify(params)
|
|
14767
14767
|
});
|
|
14768
|
+
const body = await this.parseJsonBody(res, "Bound Exchange authentication failed");
|
|
14768
14769
|
if (!res.ok) {
|
|
14769
|
-
|
|
14770
|
-
throw new RadfiApiError(res.status, err, "Bound Exchange authentication failed");
|
|
14770
|
+
throw new RadfiApiError(res.status, body, "Bound Exchange authentication failed");
|
|
14771
14771
|
}
|
|
14772
|
-
return
|
|
14773
|
-
accessToken:
|
|
14774
|
-
refreshToken:
|
|
14775
|
-
tradingAddress:
|
|
14776
|
-
}
|
|
14772
|
+
return {
|
|
14773
|
+
accessToken: body.data?.accessToken ?? "",
|
|
14774
|
+
refreshToken: body.data?.refreshToken ?? "",
|
|
14775
|
+
tradingAddress: body.data?.tradingAddress ?? body.data?.wallet?.tradingAddress ?? ""
|
|
14776
|
+
};
|
|
14777
14777
|
}
|
|
14778
14778
|
async refreshAccessToken(refreshToken) {
|
|
14779
14779
|
const res = await this.request("/auth/refresh-token", {
|
|
14780
14780
|
method: "POST",
|
|
14781
14781
|
body: JSON.stringify({ refreshToken })
|
|
14782
14782
|
});
|
|
14783
|
+
const body = await this.parseJsonBody(res, "Token refresh failed");
|
|
14783
14784
|
if (!res.ok) {
|
|
14784
|
-
|
|
14785
|
-
throw new RadfiApiError(res.status, err, "Token refresh failed");
|
|
14785
|
+
throw new RadfiApiError(res.status, body, "Token refresh failed");
|
|
14786
14786
|
}
|
|
14787
|
-
return
|
|
14788
|
-
accessToken:
|
|
14789
|
-
refreshToken:
|
|
14790
|
-
}
|
|
14787
|
+
return {
|
|
14788
|
+
accessToken: body.data?.accessToken ?? "",
|
|
14789
|
+
refreshToken: body.data?.refreshToken ?? refreshToken
|
|
14790
|
+
};
|
|
14791
14791
|
}
|
|
14792
14792
|
async createTradingWallet(params, accessToken) {
|
|
14793
14793
|
const res = await this.request("/wallets", {
|
|
14794
14794
|
method: "POST",
|
|
14795
14795
|
headers: {
|
|
14796
|
-
Authorization: `Bearer ${
|
|
14796
|
+
Authorization: `Bearer ${this.resolveAuth(accessToken)}`
|
|
14797
14797
|
},
|
|
14798
14798
|
body: JSON.stringify(params)
|
|
14799
14799
|
});
|
|
14800
|
-
|
|
14801
|
-
|
|
14802
|
-
throw new RadfiApiError(res.status,
|
|
14800
|
+
const body = await this.parseJsonBody(res, "Failed to create trading wallet");
|
|
14801
|
+
if (!res.ok || !body.data) {
|
|
14802
|
+
throw new RadfiApiError(res.status, body, "Failed to create trading wallet");
|
|
14803
14803
|
}
|
|
14804
|
-
return
|
|
14804
|
+
return body.data;
|
|
14805
14805
|
}
|
|
14806
|
-
async getTradingWallet(userAddress
|
|
14806
|
+
async getTradingWallet(userAddress) {
|
|
14807
14807
|
const res = await this.request(`/wallets/details/${userAddress}`, {
|
|
14808
|
-
method: "GET"
|
|
14809
|
-
headers: accessToken ? { Authorization: `Bearer ${accessToken}` } : {}
|
|
14808
|
+
method: "GET"
|
|
14810
14809
|
});
|
|
14811
|
-
|
|
14812
|
-
|
|
14810
|
+
const body = await this.parseJsonBody(res, "Trading wallet not found");
|
|
14811
|
+
if (!res.ok || !body.data) {
|
|
14812
|
+
throw new RadfiApiError(res.status, body, "Trading wallet not found");
|
|
14813
14813
|
}
|
|
14814
|
-
|
|
14815
|
-
if (!data) throw new Error("Trading wallet not found");
|
|
14816
|
-
return data;
|
|
14814
|
+
return body.data;
|
|
14817
14815
|
}
|
|
14818
14816
|
async getBalance(address) {
|
|
14819
14817
|
if (!this.config.umsUrl) {
|
|
@@ -14827,12 +14825,12 @@ var RadfiProvider = class {
|
|
|
14827
14825
|
if (!res.ok) {
|
|
14828
14826
|
throw new Error("Failed to fetch wallet balance");
|
|
14829
14827
|
}
|
|
14830
|
-
const { data } = await
|
|
14828
|
+
const { data } = await this.parseJsonBody(res, "Failed to fetch wallet balance");
|
|
14831
14829
|
return {
|
|
14832
|
-
btcSatoshi: BigInt(data
|
|
14833
|
-
pendingSatoshi: BigInt(data
|
|
14834
|
-
externalPendingSatoshi: BigInt(data
|
|
14835
|
-
totalUtxos: Number(data
|
|
14830
|
+
btcSatoshi: BigInt(data?.btcSatoshi ?? "0"),
|
|
14831
|
+
pendingSatoshi: BigInt(data?.pendingSatoshi ?? "0"),
|
|
14832
|
+
externalPendingSatoshi: BigInt(data?.externalPendingSatoshi ?? "0"),
|
|
14833
|
+
totalUtxos: Number(data?.totalUtxos ?? 0)
|
|
14836
14834
|
};
|
|
14837
14835
|
}
|
|
14838
14836
|
async checkIfTradingWalletExists(userAddress) {
|
|
@@ -14848,7 +14846,7 @@ var RadfiProvider = class {
|
|
|
14848
14846
|
const res = await this.request("/sodax/transaction", {
|
|
14849
14847
|
method: "POST",
|
|
14850
14848
|
headers: {
|
|
14851
|
-
Authorization: `Bearer ${
|
|
14849
|
+
Authorization: `Bearer ${this.resolveAuth(accessToken)}`
|
|
14852
14850
|
},
|
|
14853
14851
|
body: JSON.stringify({
|
|
14854
14852
|
type: "sodax-withdraw",
|
|
@@ -14859,8 +14857,8 @@ var RadfiProvider = class {
|
|
|
14859
14857
|
}
|
|
14860
14858
|
})
|
|
14861
14859
|
});
|
|
14862
|
-
const body = await
|
|
14863
|
-
if (!res.ok || !body
|
|
14860
|
+
const body = await this.parseJsonBody(res, "Bound Exchange transaction request failed");
|
|
14861
|
+
if (!res.ok || !body.data) {
|
|
14864
14862
|
throw new RadfiApiError(res.status, body, "Bound Exchange transaction request failed");
|
|
14865
14863
|
}
|
|
14866
14864
|
return body.data;
|
|
@@ -14877,18 +14875,18 @@ var RadfiProvider = class {
|
|
|
14877
14875
|
const res = await this.request("/sodax/transaction/sign", {
|
|
14878
14876
|
method: "POST",
|
|
14879
14877
|
headers: {
|
|
14880
|
-
Authorization: `Bearer ${
|
|
14878
|
+
Authorization: `Bearer ${this.resolveAuth(accessToken)}`
|
|
14881
14879
|
},
|
|
14882
14880
|
body: JSON.stringify({
|
|
14883
14881
|
type: "sodax-withdraw",
|
|
14884
14882
|
params
|
|
14885
14883
|
})
|
|
14886
14884
|
});
|
|
14887
|
-
|
|
14888
|
-
|
|
14889
|
-
throw new RadfiApiError(res.status,
|
|
14885
|
+
const body = await this.parseJsonBody(res, "Bound Exchange signature request failed");
|
|
14886
|
+
if (!res.ok || !body.data?.txId) {
|
|
14887
|
+
throw new RadfiApiError(res.status, body, "Bound Exchange signature request failed");
|
|
14890
14888
|
}
|
|
14891
|
-
return
|
|
14889
|
+
return body.data.txId;
|
|
14892
14890
|
}
|
|
14893
14891
|
/**
|
|
14894
14892
|
* Fetch expired (or near-expiry) UTXOs for a trading wallet address from UMS API.
|
|
@@ -14907,7 +14905,8 @@ var RadfiProvider = class {
|
|
|
14907
14905
|
if (!res.ok) {
|
|
14908
14906
|
throw new Error("Failed to fetch expired UTXOs");
|
|
14909
14907
|
}
|
|
14910
|
-
|
|
14908
|
+
const body = await this.parseJsonBody(res, "Failed to fetch expired UTXOs");
|
|
14909
|
+
return { code: body.code ?? "", message: body.message ?? "", data: body.data ?? [] };
|
|
14911
14910
|
}
|
|
14912
14911
|
/**
|
|
14913
14912
|
* Build a renew-utxo transaction via the Bound Exchange API.
|
|
@@ -14927,11 +14926,11 @@ var RadfiProvider = class {
|
|
|
14927
14926
|
}
|
|
14928
14927
|
})
|
|
14929
14928
|
});
|
|
14930
|
-
|
|
14931
|
-
|
|
14932
|
-
throw new RadfiApiError(res.status,
|
|
14929
|
+
const body = await this.parseJsonBody(res, "Failed to build renew-utxo transaction");
|
|
14930
|
+
if (!res.ok || !body.data) {
|
|
14931
|
+
throw new RadfiApiError(res.status, body, "Failed to build renew-utxo transaction");
|
|
14933
14932
|
}
|
|
14934
|
-
return
|
|
14933
|
+
return body.data;
|
|
14935
14934
|
}
|
|
14936
14935
|
/**
|
|
14937
14936
|
* Sign and broadcast a renew-utxo transaction via the Bound Exchange API.
|
|
@@ -14948,11 +14947,14 @@ var RadfiProvider = class {
|
|
|
14948
14947
|
params
|
|
14949
14948
|
})
|
|
14950
14949
|
});
|
|
14951
|
-
|
|
14952
|
-
|
|
14953
|
-
|
|
14950
|
+
const body = await this.parseJsonBody(
|
|
14951
|
+
res,
|
|
14952
|
+
"Failed to sign and broadcast renew-utxo transaction"
|
|
14953
|
+
);
|
|
14954
|
+
if (!res.ok || !body.data?.txId) {
|
|
14955
|
+
throw new RadfiApiError(res.status, body, "Failed to sign and broadcast renew-utxo transaction");
|
|
14954
14956
|
}
|
|
14955
|
-
return
|
|
14957
|
+
return body.data.txId;
|
|
14956
14958
|
}
|
|
14957
14959
|
/**
|
|
14958
14960
|
* Withdraw BTC from trading wallet to user's personal wallet.
|
|
@@ -14969,11 +14971,11 @@ var RadfiProvider = class {
|
|
|
14969
14971
|
params
|
|
14970
14972
|
})
|
|
14971
14973
|
});
|
|
14972
|
-
|
|
14973
|
-
|
|
14974
|
-
throw new RadfiApiError(res.status,
|
|
14974
|
+
const body = await this.parseJsonBody(res, "Failed to build withdraw transaction");
|
|
14975
|
+
if (!res.ok || !body.data) {
|
|
14976
|
+
throw new RadfiApiError(res.status, body, "Failed to build withdraw transaction");
|
|
14975
14977
|
}
|
|
14976
|
-
return
|
|
14978
|
+
return body.data;
|
|
14977
14979
|
}
|
|
14978
14980
|
/**
|
|
14979
14981
|
* Sign and broadcast a withdraw transaction via Bound Exchange.
|
|
@@ -14989,14 +14991,19 @@ var RadfiProvider = class {
|
|
|
14989
14991
|
params
|
|
14990
14992
|
})
|
|
14991
14993
|
});
|
|
14994
|
+
const body = await this.parseJsonBody(
|
|
14995
|
+
res,
|
|
14996
|
+
"Failed to sign and broadcast withdraw transaction"
|
|
14997
|
+
);
|
|
14992
14998
|
if (!res.ok) {
|
|
14993
|
-
|
|
14994
|
-
throw new RadfiApiError(res.status, err, "Failed to sign and broadcast withdraw transaction");
|
|
14999
|
+
throw new RadfiApiError(res.status, body, "Failed to sign and broadcast withdraw transaction");
|
|
14995
15000
|
}
|
|
14996
|
-
|
|
14997
|
-
|
|
14998
|
-
|
|
14999
|
-
|
|
15001
|
+
const raw = body.data?.txId;
|
|
15002
|
+
const txId = typeof raw === "object" ? raw?.data : raw;
|
|
15003
|
+
if (!txId) {
|
|
15004
|
+
throw new RadfiApiError(res.status, body, "Failed to sign and broadcast withdraw transaction");
|
|
15005
|
+
}
|
|
15006
|
+
return txId;
|
|
15000
15007
|
}
|
|
15001
15008
|
/**
|
|
15002
15009
|
* Get max spendable amount for a withdraw transaction (amount after fee).
|
|
@@ -15012,11 +15019,56 @@ var RadfiProvider = class {
|
|
|
15012
15019
|
params
|
|
15013
15020
|
})
|
|
15014
15021
|
});
|
|
15015
|
-
|
|
15016
|
-
|
|
15017
|
-
throw new RadfiApiError(res.status,
|
|
15022
|
+
const body = await this.parseJsonBody(res, "Failed to get max withdrawable amount");
|
|
15023
|
+
if (!res.ok || !body.data) {
|
|
15024
|
+
throw new RadfiApiError(res.status, body, "Failed to get max withdrawable amount");
|
|
15025
|
+
}
|
|
15026
|
+
return body.data;
|
|
15027
|
+
}
|
|
15028
|
+
/**
|
|
15029
|
+
* Resolve the bearer credential for an authenticated Bound Exchange call, failing fast when none
|
|
15030
|
+
* is available. A server-side raw-build caller that never ran the interactive sign-in would
|
|
15031
|
+
* otherwise send `Authorization: Bearer ` (empty) and get an opaque 403 from Bound's gateway;
|
|
15032
|
+
* throwing here turns that into an actionable client-side error naming the fix. We deliberately do
|
|
15033
|
+
* NOT validate the token's contents (expiry / scope / signature) — only Bound can, and an invalid
|
|
15034
|
+
* token still surfaces as a legible 401/403 via `parseJsonBody`.
|
|
15035
|
+
*/
|
|
15036
|
+
resolveAuth(accessToken) {
|
|
15037
|
+
const auth = accessToken || this.config.apiKey;
|
|
15038
|
+
if (!auth) {
|
|
15039
|
+
throw new RadfiApiError(
|
|
15040
|
+
401,
|
|
15041
|
+
{
|
|
15042
|
+
message: "Bound Exchange access token (or apiKey) is required but none was set. Inject one via sodax.spoke.bitcoin.radfi.setRadfiAccessToken(token) or new Sodax({ ... }) with radfi.accessToken."
|
|
15043
|
+
},
|
|
15044
|
+
"Missing Bound Exchange credentials"
|
|
15045
|
+
);
|
|
15046
|
+
}
|
|
15047
|
+
return auth;
|
|
15048
|
+
}
|
|
15049
|
+
/**
|
|
15050
|
+
* Parse a Bound Exchange response body as JSON defensively.
|
|
15051
|
+
*
|
|
15052
|
+
* Bound (or an upstream gateway / WAF / CDN) can answer a request with an HTML error page
|
|
15053
|
+
* instead of JSON — e.g. an unauthenticated call, a blocked origin, a 404, or a 5xx. Calling
|
|
15054
|
+
* `res.json()` on that throws a cryptic `SyntaxError: Unexpected token '<'` that masks the real
|
|
15055
|
+
* HTTP status and bubbles up as an opaque failure (it surfaced as a `createIntent` /
|
|
15056
|
+
* `INTENT_CREATION_FAILED` "is not valid JSON" error on the Bitcoin raw-tx path). Reading the
|
|
15057
|
+
* body as text first and parsing it ourselves lets us raise a `RadfiApiError` carrying the
|
|
15058
|
+
* actual status code and a body snippet instead.
|
|
15059
|
+
*/
|
|
15060
|
+
async parseJsonBody(res, fallback) {
|
|
15061
|
+
const text = await res.text();
|
|
15062
|
+
try {
|
|
15063
|
+
return text.length ? JSON.parse(text) : {};
|
|
15064
|
+
} catch {
|
|
15065
|
+
const snippet = text.replace(/\s+/g, " ").trim().slice(0, 200);
|
|
15066
|
+
throw new RadfiApiError(
|
|
15067
|
+
res.status,
|
|
15068
|
+
{ message: `Bound Exchange returned a non-JSON response (HTTP ${res.status})${snippet ? `: ${snippet}` : ""}` },
|
|
15069
|
+
fallback
|
|
15070
|
+
);
|
|
15018
15071
|
}
|
|
15019
|
-
return res.json().then((r) => r.data);
|
|
15020
15072
|
}
|
|
15021
15073
|
async request(endpoint, options) {
|
|
15022
15074
|
return fetch(`${this.config.apiUrl}${endpoint}`, {
|
|
@@ -26423,14 +26475,18 @@ var SwapService = class {
|
|
|
26423
26475
|
}
|
|
26424
26476
|
const personalAddress = params.srcAddress;
|
|
26425
26477
|
let walletAddress = personalAddress;
|
|
26426
|
-
if (isBitcoinChainKeyType(params.srcChainKey)
|
|
26427
|
-
|
|
26428
|
-
|
|
26429
|
-
|
|
26430
|
-
|
|
26431
|
-
|
|
26478
|
+
if (isBitcoinChainKeyType(params.srcChainKey)) {
|
|
26479
|
+
if (_params.raw === false) {
|
|
26480
|
+
swapInvariant(
|
|
26481
|
+
isBitcoinWalletProviderType(_params.walletProvider),
|
|
26482
|
+
`Invalid wallet provider for chain key: ${params.srcChainKey}`,
|
|
26483
|
+
baseCtx
|
|
26484
|
+
);
|
|
26485
|
+
if (this.spoke.bitcoin.walletMode === "TRADING") {
|
|
26486
|
+
await this.spoke.bitcoin.radfi.ensureRadfiAccessToken(_params.walletProvider);
|
|
26487
|
+
}
|
|
26488
|
+
}
|
|
26432
26489
|
walletAddress = await this.spoke.bitcoin.getEffectiveWalletAddress(personalAddress);
|
|
26433
|
-
await this.spoke.bitcoin.radfi.ensureRadfiAccessToken(_params.walletProvider);
|
|
26434
26490
|
}
|
|
26435
26491
|
const creatorHubWalletAddress = await this.hubProvider.getUserHubWalletAddress(walletAddress, params.srcChainKey);
|
|
26436
26492
|
if (isHubChainKeyType(params.srcChainKey) && isSonicChainKeyType(params.srcChainKey)) {
|
|
@@ -26470,6 +26526,8 @@ var SwapService = class {
|
|
|
26470
26526
|
srcChainKey: params.srcChainKey,
|
|
26471
26527
|
srcAddress: walletAddress,
|
|
26472
26528
|
srcPublicKey: extras?.srcPublicKey,
|
|
26529
|
+
// Bitcoin Bound token; BitcoinSpokeService.deposit falls back to the RadfiProvider instance token when undefined.
|
|
26530
|
+
accessToken: extras?.bound?.accessToken,
|
|
26473
26531
|
to: creatorHubWalletAddress,
|
|
26474
26532
|
token: params.inputToken,
|
|
26475
26533
|
amount: params.inputAmount,
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "2.0.0-rc.
|
|
7
|
+
"version": "2.0.0-rc.16",
|
|
8
8
|
"license": "MIT",
|
|
9
9
|
"description": "Sodax SDK",
|
|
10
10
|
"keywords": [
|
|
@@ -66,8 +66,8 @@
|
|
|
66
66
|
"near-api-js": "7.2.0",
|
|
67
67
|
"rlp": "3.0.0",
|
|
68
68
|
"viem": "2.29.2",
|
|
69
|
-
"@sodax/libs": "2.0.0-rc.
|
|
70
|
-
"@sodax/types": "2.0.0-rc.
|
|
69
|
+
"@sodax/libs": "2.0.0-rc.16",
|
|
70
|
+
"@sodax/types": "2.0.0-rc.16"
|
|
71
71
|
},
|
|
72
72
|
"devDependencies": {
|
|
73
73
|
"@arethetypeswrong/cli": "0.17.4",
|