@silentswap/sdk 0.1.64 → 0.1.66
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/assets.d.ts +1 -1
- package/dist/assets.js +20 -5
- package/dist/bridge.js +67 -33
- package/dist/chains.d.ts +20 -16
- package/dist/index.d.ts +29 -20
- package/dist/index.js +29 -23
- package/package.json +4 -3
package/dist/assets.d.ts
CHANGED
|
@@ -27,7 +27,7 @@ export interface AssetsData {
|
|
|
27
27
|
chains: Record<Caip2, ChainInfo>;
|
|
28
28
|
assets: Record<Caip19, AssetInfo>;
|
|
29
29
|
}
|
|
30
|
-
export declare function loadAssetsData(): AssetsData
|
|
30
|
+
export declare function loadAssetsData(): Promise<AssetsData>;
|
|
31
31
|
export declare function getAllAssets(): Record<Caip19, AssetInfo>;
|
|
32
32
|
export declare function getAllChains(): Record<Caip2, ChainInfo>;
|
|
33
33
|
export declare function getAllAssetsArray(): AssetInfo[];
|
package/dist/assets.js
CHANGED
|
@@ -1,10 +1,25 @@
|
|
|
1
|
-
|
|
1
|
+
// Lazy-loaded assets data — avoids loading the 96KB JSON at module import time.
|
|
2
|
+
// Dynamic import works with Vite/webpack code-splitting; bundlers treat .json imports as modules.
|
|
3
|
+
let _filteredDataPromise = null;
|
|
4
|
+
async function getFilteredDataAsync() {
|
|
5
|
+
if (!_filteredDataPromise) {
|
|
6
|
+
_filteredDataPromise = import('./data/filtered.json').then((module) => (module.default ?? module));
|
|
7
|
+
}
|
|
8
|
+
return _filteredDataPromise;
|
|
9
|
+
}
|
|
10
|
+
// Synchronous accessor — returns cached data after loadAssetsData() resolves.
|
|
11
|
+
// Throws if data hasn't been loaded yet; callers should await loadAssetsData() first.
|
|
12
|
+
let _filteredData = null;
|
|
2
13
|
function getFilteredData() {
|
|
3
|
-
|
|
14
|
+
if (!_filteredData) {
|
|
15
|
+
throw new Error('Assets data not loaded. Call loadAssetsData() first.');
|
|
16
|
+
}
|
|
17
|
+
return _filteredData;
|
|
4
18
|
}
|
|
5
|
-
// Load assets data from filtered.json
|
|
6
|
-
export function loadAssetsData() {
|
|
7
|
-
|
|
19
|
+
// Load assets data from filtered.json (async — call once at app startup)
|
|
20
|
+
export async function loadAssetsData() {
|
|
21
|
+
_filteredData = await getFilteredDataAsync();
|
|
22
|
+
return _filteredData;
|
|
8
23
|
}
|
|
9
24
|
// Get all assets from the filtered data
|
|
10
25
|
export function getAllAssets() {
|
package/dist/bridge.js
CHANGED
|
@@ -2,6 +2,12 @@ import { encodeFunctionData, erc20Abi } from 'viem';
|
|
|
2
2
|
import BigNumber from 'bignumber.js';
|
|
3
3
|
import { NI_CHAIN_ID_AVALANCHE, S0X_ADDR_USDC_AVALANCHE, S0X_ADDR_EVM_ZERO, UINT256_MAX, N_DEBRIDGE_CHAIN_ID_SOLANA, N_DEBRIDGE_CHAIN_ID_TRON, N_RELAY_CHAIN_ID_SOLANA, N_RELAY_CHAIN_ID_BITCOIN, N_RELAY_CHAIN_ID_SUI, N_RELAY_CHAIN_ID_TRON, S0X_ADDR_TRON_NATIVE, SB58_ADDR_SOL_PROGRAM_SYSTEM, } from './constants.js';
|
|
4
4
|
import { createPhonyDepositCalldata } from './wallet.js';
|
|
5
|
+
// TTL cache for solveOptimalUsdcAmount — avoids re-fetching identical quotes
|
|
6
|
+
const QUOTE_CACHE_TTL = 30_000; // 30 seconds
|
|
7
|
+
const quoteCache = new Map();
|
|
8
|
+
function getQuoteCacheKey(srcChainId, srcToken, srcAmount, forceProvider) {
|
|
9
|
+
return `${srcChainId}:${srcToken}:${srcAmount}:${forceProvider ?? 'any'}`;
|
|
10
|
+
}
|
|
5
11
|
/**
|
|
6
12
|
* Map relay.link chain IDs to deBridge chain IDs
|
|
7
13
|
* Different bridge providers use different chain ID schemes
|
|
@@ -794,6 +800,12 @@ async function solveDebridgeSingleChainUsdcAmount(chainId, srcToken, srcAmount,
|
|
|
794
800
|
*/
|
|
795
801
|
export async function solveOptimalUsdcAmount(srcChainId, srcToken, srcAmount, userAddress, depositCalldata, maxImpactPercent, depositorAddress, evmSignerAddress, // Optional EVM address for deposit calldata (required for non-EVM swaps: Solana, Bitcoin)
|
|
796
802
|
forceProvider) {
|
|
803
|
+
// Check cache first
|
|
804
|
+
const cacheKey = getQuoteCacheKey(srcChainId, srcToken, srcAmount, forceProvider);
|
|
805
|
+
const cached = quoteCache.get(cacheKey);
|
|
806
|
+
if (cached && Date.now() - cached.timestamp < QUOTE_CACHE_TTL) {
|
|
807
|
+
return cached.result;
|
|
808
|
+
}
|
|
797
809
|
// Check if this is a non-EVM chain (Solana, Bitcoin, etc.)
|
|
798
810
|
const isNonEvmChain = isNonEvmRelayChainId(srcChainId);
|
|
799
811
|
// For non-EVM chains (Solana, Bitcoin), we need an EVM address for deposit calldata
|
|
@@ -811,21 +823,38 @@ forceProvider) {
|
|
|
811
823
|
const recipientAddress = isNonEvmChain && evmSignerAddress ? evmSignerAddress : userAddress;
|
|
812
824
|
const useRelay = forceProvider !== 'debridge';
|
|
813
825
|
const useDebridge = forceProvider !== 'relay';
|
|
814
|
-
//
|
|
815
|
-
const
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
:
|
|
822
|
-
|
|
826
|
+
// Build promise array only for enabled providers to avoid creating unnecessary promises
|
|
827
|
+
const promises = [];
|
|
828
|
+
if (useRelay) {
|
|
829
|
+
promises.push(solveRelayUsdcAmount(srcChainId, srcToken, srcAmount, userAddress, calldata, maxImpactPercent, depositorAddress, recipientAddress)
|
|
830
|
+
.then(([usdcAmountOut, actualAmountIn, allowanceTarget]) => ({
|
|
831
|
+
usdcAmountOut,
|
|
832
|
+
actualAmountIn,
|
|
833
|
+
provider: 'relay',
|
|
834
|
+
allowanceTarget,
|
|
835
|
+
})));
|
|
836
|
+
}
|
|
837
|
+
else {
|
|
838
|
+
promises.push(Promise.resolve(null));
|
|
839
|
+
}
|
|
840
|
+
if (useDebridge) {
|
|
841
|
+
promises.push(solveDebridgeUsdcAmount(srcChainId, srcToken, srcAmount, userAddress, calldata, maxImpactPercent, depositorAddress)
|
|
842
|
+
.then(([usdcAmountOut, actualAmountIn, allowanceTarget]) => ({
|
|
843
|
+
usdcAmountOut,
|
|
844
|
+
actualAmountIn,
|
|
845
|
+
provider: 'debridge',
|
|
846
|
+
allowanceTarget,
|
|
847
|
+
})));
|
|
848
|
+
}
|
|
849
|
+
else {
|
|
850
|
+
promises.push(Promise.resolve(null));
|
|
851
|
+
}
|
|
852
|
+
const [relayResult, debridgeResult] = await Promise.allSettled(promises);
|
|
823
853
|
// Extract results
|
|
824
854
|
const relayData = relayResult.status === 'fulfilled' ? relayResult.value : null;
|
|
825
855
|
const debridgeData = debridgeResult.status === 'fulfilled' ? debridgeResult.value : null;
|
|
826
856
|
// Both failed — surface the most relevant inner error message
|
|
827
857
|
if (!relayData && !debridgeData) {
|
|
828
|
-
debugger;
|
|
829
858
|
const errors = [
|
|
830
859
|
relayResult.status === 'rejected' ? relayResult.reason : null,
|
|
831
860
|
debridgeResult.status === 'rejected' ? debridgeResult.reason : null,
|
|
@@ -844,48 +873,53 @@ forceProvider) {
|
|
|
844
873
|
}
|
|
845
874
|
throw new AggregateError(errors, 'All bridge providers failed');
|
|
846
875
|
}
|
|
876
|
+
// Helper to cache and return result
|
|
877
|
+
const cacheAndReturn = (result) => {
|
|
878
|
+
quoteCache.set(cacheKey, { result, timestamp: Date.now() });
|
|
879
|
+
return result;
|
|
880
|
+
};
|
|
847
881
|
// Only one succeeded
|
|
848
882
|
if (!relayData) {
|
|
849
883
|
console.info('Using deBridge (relay failed)');
|
|
850
|
-
return {
|
|
851
|
-
usdcAmountOut: debridgeData
|
|
852
|
-
actualAmountIn: debridgeData
|
|
884
|
+
return cacheAndReturn({
|
|
885
|
+
usdcAmountOut: debridgeData.usdcAmountOut,
|
|
886
|
+
actualAmountIn: debridgeData.actualAmountIn,
|
|
853
887
|
provider: 'debridge',
|
|
854
|
-
allowanceTarget: debridgeData
|
|
855
|
-
};
|
|
888
|
+
allowanceTarget: debridgeData.allowanceTarget,
|
|
889
|
+
});
|
|
856
890
|
}
|
|
857
891
|
if (!debridgeData) {
|
|
858
892
|
console.info('Using relay.link (deBridge failed)');
|
|
859
|
-
return {
|
|
860
|
-
usdcAmountOut: relayData
|
|
861
|
-
actualAmountIn: relayData
|
|
893
|
+
return cacheAndReturn({
|
|
894
|
+
usdcAmountOut: relayData.usdcAmountOut,
|
|
895
|
+
actualAmountIn: relayData.actualAmountIn,
|
|
862
896
|
provider: 'relay',
|
|
863
|
-
allowanceTarget: relayData
|
|
864
|
-
};
|
|
897
|
+
allowanceTarget: relayData.allowanceTarget,
|
|
898
|
+
});
|
|
865
899
|
}
|
|
866
900
|
// Compare rates (USDC out / amount in)
|
|
867
901
|
// Use BigNumber for precision (matching Svelte implementation)
|
|
868
902
|
// Svelte: yx_rate_relay = BigNumber(xg_uusdc_out_relay).div(xg_amount_in_relay)
|
|
869
|
-
const relayRate = BigNumber(relayData
|
|
870
|
-
const debridgeRate = BigNumber(debridgeData
|
|
903
|
+
const relayRate = BigNumber(relayData.usdcAmountOut.toString()).div(relayData.actualAmountIn.toString());
|
|
904
|
+
const debridgeRate = BigNumber(debridgeData.usdcAmountOut.toString()).div(debridgeData.actualAmountIn.toString());
|
|
871
905
|
// Relay performs better (matches Svelte: yx_rate_relay.gte(yx_rate_debridge))
|
|
872
906
|
if (relayRate.gte(debridgeRate)) {
|
|
873
|
-
console.info(`Using relay.link: ${relayRate.toString()} >= ${debridgeRate.toString()}`, [relayData
|
|
874
|
-
return {
|
|
875
|
-
usdcAmountOut: relayData
|
|
876
|
-
actualAmountIn: relayData
|
|
907
|
+
console.info(`Using relay.link: ${relayRate.toString()} >= ${debridgeRate.toString()}`, [relayData.usdcAmountOut, relayData.actualAmountIn], [debridgeData.usdcAmountOut, debridgeData.actualAmountIn]);
|
|
908
|
+
return cacheAndReturn({
|
|
909
|
+
usdcAmountOut: relayData.usdcAmountOut,
|
|
910
|
+
actualAmountIn: relayData.actualAmountIn,
|
|
877
911
|
provider: 'relay',
|
|
878
912
|
allowanceTarget: '',
|
|
879
|
-
};
|
|
913
|
+
});
|
|
880
914
|
}
|
|
881
915
|
else {
|
|
882
916
|
// DeBridge performs better
|
|
883
|
-
console.info(`Using deBridge: ${debridgeRate.toString()} >= ${relayRate.toString()}`, [debridgeData
|
|
884
|
-
return {
|
|
885
|
-
usdcAmountOut: debridgeData
|
|
886
|
-
actualAmountIn: debridgeData
|
|
917
|
+
console.info(`Using deBridge: ${debridgeRate.toString()} >= ${relayRate.toString()}`, [debridgeData.usdcAmountOut, debridgeData.actualAmountIn], [relayData.usdcAmountOut, relayData.actualAmountIn]);
|
|
918
|
+
return cacheAndReturn({
|
|
919
|
+
usdcAmountOut: debridgeData.usdcAmountOut,
|
|
920
|
+
actualAmountIn: debridgeData.actualAmountIn,
|
|
887
921
|
provider: 'debridge',
|
|
888
|
-
allowanceTarget: debridgeData
|
|
889
|
-
};
|
|
922
|
+
allowanceTarget: debridgeData.allowanceTarget,
|
|
923
|
+
});
|
|
890
924
|
}
|
|
891
925
|
}
|
package/dist/chains.d.ts
CHANGED
|
@@ -238,16 +238,16 @@ export declare const A_VIEM_CHAINS: readonly [{
|
|
|
238
238
|
r: import("viem").Hex;
|
|
239
239
|
s: import("viem").Hex;
|
|
240
240
|
v: bigint;
|
|
241
|
-
value: bigint;
|
|
242
|
-
gas: bigint;
|
|
243
241
|
to: import("viem").Address | null;
|
|
244
242
|
from: import("viem").Address;
|
|
243
|
+
gas: bigint;
|
|
245
244
|
nonce: number;
|
|
245
|
+
value: bigint;
|
|
246
246
|
blockHash: `0x${string}` | null;
|
|
247
247
|
blockNumber: bigint | null;
|
|
248
|
-
transactionIndex: number | null;
|
|
249
248
|
hash: import("viem").Hash;
|
|
250
249
|
input: import("viem").Hex;
|
|
250
|
+
transactionIndex: number | null;
|
|
251
251
|
typeHex: import("viem").Hex | null;
|
|
252
252
|
accessList?: undefined | undefined;
|
|
253
253
|
authorizationList?: undefined | undefined;
|
|
@@ -384,6 +384,7 @@ export declare const A_VIEM_CHAINS: readonly [{
|
|
|
384
384
|
blobGasUsed?: bigint | undefined;
|
|
385
385
|
blockHash: import("viem").Hash;
|
|
386
386
|
blockNumber: bigint;
|
|
387
|
+
blockTimestamp?: bigint | undefined;
|
|
387
388
|
contractAddress: import("viem").Address | null | undefined;
|
|
388
389
|
cumulativeGasUsed: bigint;
|
|
389
390
|
effectiveGasPrice: bigint;
|
|
@@ -442,7 +443,7 @@ export declare const A_VIEM_CHAINS: readonly [{
|
|
|
442
443
|
experimental_preconfirmationTime?: number | undefined | undefined;
|
|
443
444
|
rpcUrls: {
|
|
444
445
|
readonly default: {
|
|
445
|
-
readonly http: readonly ["https://polygon
|
|
446
|
+
readonly http: readonly ["https://polygon.drpc.org"];
|
|
446
447
|
};
|
|
447
448
|
};
|
|
448
449
|
sourceId?: number | undefined | undefined;
|
|
@@ -684,16 +685,16 @@ export declare const A_VIEM_CHAINS: readonly [{
|
|
|
684
685
|
r: import("viem").Hex;
|
|
685
686
|
s: import("viem").Hex;
|
|
686
687
|
v: bigint;
|
|
687
|
-
value: bigint;
|
|
688
|
-
gas: bigint;
|
|
689
688
|
to: import("viem").Address | null;
|
|
690
689
|
from: import("viem").Address;
|
|
690
|
+
gas: bigint;
|
|
691
691
|
nonce: number;
|
|
692
|
+
value: bigint;
|
|
692
693
|
blockHash: `0x${string}` | null;
|
|
693
694
|
blockNumber: bigint | null;
|
|
694
|
-
transactionIndex: number | null;
|
|
695
695
|
hash: import("viem").Hash;
|
|
696
696
|
input: import("viem").Hex;
|
|
697
|
+
transactionIndex: number | null;
|
|
697
698
|
typeHex: import("viem").Hex | null;
|
|
698
699
|
accessList?: undefined | undefined;
|
|
699
700
|
authorizationList?: undefined | undefined;
|
|
@@ -830,6 +831,7 @@ export declare const A_VIEM_CHAINS: readonly [{
|
|
|
830
831
|
blobGasUsed?: bigint | undefined;
|
|
831
832
|
blockHash: import("viem").Hash;
|
|
832
833
|
blockNumber: bigint;
|
|
834
|
+
blockTimestamp?: bigint | undefined;
|
|
833
835
|
contractAddress: import("viem").Address | null | undefined;
|
|
834
836
|
cumulativeGasUsed: bigint;
|
|
835
837
|
effectiveGasPrice: bigint;
|
|
@@ -1271,16 +1273,16 @@ export declare const A_VIEM_CHAINS: readonly [{
|
|
|
1271
1273
|
r: import("viem").Hex;
|
|
1272
1274
|
s: import("viem").Hex;
|
|
1273
1275
|
v: bigint;
|
|
1274
|
-
value: bigint;
|
|
1275
|
-
gas: bigint;
|
|
1276
1276
|
to: import("viem").Address | null;
|
|
1277
1277
|
from: import("viem").Address;
|
|
1278
|
+
gas: bigint;
|
|
1278
1279
|
nonce: number;
|
|
1280
|
+
value: bigint;
|
|
1279
1281
|
blockHash: `0x${string}` | null;
|
|
1280
1282
|
blockNumber: bigint | null;
|
|
1281
|
-
transactionIndex: number | null;
|
|
1282
1283
|
hash: import("viem").Hash;
|
|
1283
1284
|
input: import("viem").Hex;
|
|
1285
|
+
transactionIndex: number | null;
|
|
1284
1286
|
typeHex: import("viem").Hex | null;
|
|
1285
1287
|
accessList?: undefined | undefined;
|
|
1286
1288
|
authorizationList?: undefined | undefined;
|
|
@@ -1417,6 +1419,7 @@ export declare const A_VIEM_CHAINS: readonly [{
|
|
|
1417
1419
|
blobGasUsed?: bigint | undefined;
|
|
1418
1420
|
blockHash: import("viem").Hash;
|
|
1419
1421
|
blockNumber: bigint;
|
|
1422
|
+
blockTimestamp?: bigint | undefined;
|
|
1420
1423
|
contractAddress: import("viem").Address | null | undefined;
|
|
1421
1424
|
cumulativeGasUsed: bigint;
|
|
1422
1425
|
effectiveGasPrice: bigint;
|
|
@@ -1718,16 +1721,16 @@ export declare const A_VIEM_CHAINS: readonly [{
|
|
|
1718
1721
|
r: import("viem").Hex;
|
|
1719
1722
|
s: import("viem").Hex;
|
|
1720
1723
|
v: bigint;
|
|
1721
|
-
value: bigint;
|
|
1722
|
-
gas: bigint;
|
|
1723
1724
|
to: import("viem").Address | null;
|
|
1724
1725
|
from: import("viem").Address;
|
|
1726
|
+
gas: bigint;
|
|
1725
1727
|
nonce: number;
|
|
1728
|
+
value: bigint;
|
|
1726
1729
|
blockHash: `0x${string}` | null;
|
|
1727
1730
|
blockNumber: bigint | null;
|
|
1728
|
-
transactionIndex: number | null;
|
|
1729
1731
|
hash: import("viem").Hash;
|
|
1730
1732
|
input: import("viem").Hex;
|
|
1733
|
+
transactionIndex: number | null;
|
|
1731
1734
|
typeHex: import("viem").Hex | null;
|
|
1732
1735
|
accessList?: undefined | undefined;
|
|
1733
1736
|
authorizationList?: undefined | undefined;
|
|
@@ -1864,6 +1867,7 @@ export declare const A_VIEM_CHAINS: readonly [{
|
|
|
1864
1867
|
blobGasUsed?: bigint | undefined;
|
|
1865
1868
|
blockHash: import("viem").Hash;
|
|
1866
1869
|
blockNumber: bigint;
|
|
1870
|
+
blockTimestamp?: bigint | undefined;
|
|
1867
1871
|
contractAddress: import("viem").Address | null | undefined;
|
|
1868
1872
|
cumulativeGasUsed: bigint;
|
|
1869
1873
|
effectiveGasPrice: bigint;
|
|
@@ -1987,9 +1991,9 @@ export declare const A_VIEM_CHAINS: readonly [{
|
|
|
1987
1991
|
}, {
|
|
1988
1992
|
blockExplorers: {
|
|
1989
1993
|
readonly default: {
|
|
1990
|
-
readonly name: "
|
|
1991
|
-
readonly url: "https://
|
|
1992
|
-
readonly apiUrl: "https://
|
|
1994
|
+
readonly name: "Seiscan";
|
|
1995
|
+
readonly url: "https://seiscan.io";
|
|
1996
|
+
readonly apiUrl: "https://api.etherscan.io/v2/api";
|
|
1993
1997
|
};
|
|
1994
1998
|
};
|
|
1995
1999
|
blockTime?: number | undefined | undefined;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,31 +1,40 @@
|
|
|
1
1
|
export type { SilentSwapClientConfig, SilentSwapClient, } from './client.js';
|
|
2
|
-
export type
|
|
2
|
+
export type { NonceResponse, AuthRequest, AuthResponse, QuoteRequest, QuoteResponse, OrderRequest, DepositParams, OrderResponse, } from './types/api.js';
|
|
3
3
|
export type { Caip19, SignInMessage } from './types/core.js';
|
|
4
4
|
export type { EvmSigner } from './types/sdk.js';
|
|
5
|
-
export
|
|
6
|
-
export
|
|
5
|
+
export type { FacilitatorPublicKey, Eip712Document, Eip3009TypedData, AuthorizationInstruction, AuthorizationReply, FacilitatorInstruction, FacilitatorReply, OrderOutputArg, OrderMetadata, Quote, Order, } from './order.js';
|
|
6
|
+
export { DeliveryMethod, PrivacySetting, FacilitatorKeyType, PublicKeyArgGroups, EIP712_TYPES_ORDER, EIP712_TYPES_WALLET_GENERATION, EIP712_DOMAIN_ORDER_DEFAULT, EIP712_DOMAIN_WALLET_GENERATION, quoteResponseToEip712Document, } from './order.js';
|
|
7
|
+
export type { Caip19Parts, ParsedCaip19, ParsedEvmCaip19, ParsedSolanaCaip19, ParsedTronCaip19, } from './caip19.js';
|
|
8
|
+
export { CAIP19_REGEX, EVM_CAIP19_REGEX, SOLANA_CAIP19_REGEX, TRON_CAIP19_NATIVE_REGEX, TRON_CAIP19_TOKEN_REGEX, Caip19Namespace, parseCaip19, parseEvmCaip19, parseSolanaCaip19, parseTronCaip19, getChainNamespace, getChainId, getEvmChainId, getAssetNamespace, getAssetReference, getEvmTokenAddress, getCaip2FromCaip19, isNativeToken, isEvmAsset, isSolanaAsset, isTronAsset, BIP122_BITCOIN_MAINNET_CHAIN_ID, isBitcoinAsset, isBitcoinMainnetAsset, isEvmNativeToken, isErc20Token, isSolanaNativeToken, isSplToken, caip19FromParts, caip19FungibleEvmToken, caip19NativeEvmToken, caip19SplToken, caip19NativeSolanaToken, } from './caip19.js';
|
|
7
9
|
export { createSilentSwapClient, } from './client.js';
|
|
8
|
-
export
|
|
9
|
-
export
|
|
10
|
+
export type { CalculationDirection, } from './constants.js';
|
|
11
|
+
export { EVM_PHONY_ADDRESS, EVM_NATIVE_ADDRESS, DEAD_ADDRESS, S0X_ADDR_EVM_ZERO, UINT256_MAX, MAINNET_GATEWAY_ADDRESS, MAINNET_GATEWAY_PUBLIC_KEY, ENVIRONMENT, ENVIRONMENT_CONFIGS, S0X_ADDR_USDC_AVALANCHE, S_CAIP19_USDC_AVALANCHE, NI_CHAIN_ID_AVALANCHE, XT_TTL_SESSION_CACHE, X_MINIMUM_INPUT_USD, X_MAX_IMPACT_PERCENT, COIN_TYPES, SB58_CHAIN_ID_SOLANA_MAINNET, SB58_ADDR_SOL_PROGRAM_SYSTEM, SB58_ADDR_SOL_RELAY_LINK_RECIPIENT, SB58_ADDR_SOL_DEAD, SBTC_ADDR_BITCOIN_NATIVE, SBTC_ADDR_BTC_RELAY_LINK_RECIPIENT, S0X_ADDR_TRON_NATIVE, SB58_ADDR_TRON_DEAD, N_RELAY_CHAIN_ID_SOLANA, N_RELAY_CHAIN_ID_BITCOIN, N_RELAY_CHAIN_ID_TRON, N_RELAY_CHAIN_ID_SUI, N_DEBRIDGE_CHAIN_ID_SOLANA, N_DEBRIDGE_CHAIN_ID_TRON, S0X_ADDR_EVM_RELAY_LINK_DEAD, P_URL_API_RPC_SOLANA, CALCULATION_DIRECTION_INPUT_TO_OUTPUT, CALCULATION_DIRECTION_OUTPUT_TO_INPUT, } from './constants.js';
|
|
12
|
+
export { GATEWAY_ABI, } from './gateway-abi.js';
|
|
10
13
|
export { createHdFacilitatorGroupFromEntropy, exportSecretMnemonicFromEntropy, type HdFacilitatorGroup, } from './hd-facilitator-group.js';
|
|
11
14
|
export { createSignInMessage, createEip712DocForOrder, createEip712DocForWalletGeneration, } from './sdk.js';
|
|
12
15
|
export { createViemSigner, parseTransactionRequestForViem, } from './signer-adapters/viem.js';
|
|
13
|
-
export
|
|
14
|
-
export
|
|
15
|
-
export
|
|
16
|
-
export
|
|
17
|
-
export
|
|
18
|
-
export
|
|
19
|
-
export
|
|
20
|
-
export
|
|
21
|
-
export
|
|
22
|
-
export
|
|
23
|
-
export
|
|
16
|
+
export type { BridgeProvider, BridgeQuote, SolanaInstruction, BridgeTransaction, BridgeStatus, BridgeQuoteParams, RelayQuoteParams, RelayQuoteResponse, DeBridgeOrderParams, DeBridgeOrderResponse, SolveUsdcResult, } from './bridge.js';
|
|
17
|
+
export { getRelayOriginAsset, executeRelayBridge, executeDebridgeBridge, getRelayStatus, getDebridgeStatus, fetchRelayQuote, fetchDebridgeOrder, solveOptimalUsdcAmount, } from './bridge.js';
|
|
18
|
+
export type { EstimateSample, Estimate, QuoteMetrics, BridgeQuoteResult, ForceBridgeProvider, } from './quote-utils.js';
|
|
19
|
+
export { calculateRelayMetrics, calculateDebridgeMetrics, selectBestQuote, interpolateSamples, getBridgeQuote, convertQuoteResultToQuote, } from './quote-utils.js';
|
|
20
|
+
export type { SolanaTransactionExecutor, BitcoinTransactionExecutor, TronTransactionExecutor, UniversalTransactionExecutor, } from './transaction-utils.js';
|
|
21
|
+
export { createTransactionExecutor, createChainSwitcher, executeBridgeTransaction, getBridgeStatus, } from './transaction-utils.js';
|
|
22
|
+
export { queryDepositCount, createPhonyDepositCalldata, } from './wallet.js';
|
|
23
|
+
export { STORAGE_KEY_AUTH_PREFIX, STORAGE_KEY_WALLET_PREFIX, getAuthStorageKey, getWalletStorageKey, loadCachedAuth, saveAuth, clearAuth, saveWalletData, loadWalletData, clearWalletData, } from './storage.js';
|
|
24
|
+
export { ensureChain, pingWalletConnectSession, clearStaleWalletConnectSessions, createPublicClientWithRpc, waitForTransactionConfirmation, executeTransaction, } from './chain.js';
|
|
25
|
+
export { SOLANA_CHAIN_ID, BITCOIN_CHAIN_ID, TRON_CHAIN_ID, A_VIEM_CHAINS, getChainById, } from './chains.js';
|
|
26
|
+
export { H_RPCS, } from './rpc.js';
|
|
27
|
+
export type { AssetInfo, ChainInfo, AssetsData, } from './assets.js';
|
|
28
|
+
export { loadAssetsData, getAllAssets, getAllChains, getAllAssetsArray, getCommonAssets, COMMON_ASSETS, CHAIN_NAMES, getAssetByCaip19, getChainByCaip2, getAssetsByChain, getChainName, searchAssets, } from './assets.js';
|
|
29
|
+
export { hexToBytes, bytesToBase58, hexToBase58, base93ToBytes, bytesToBase93, } from './encoding.js';
|
|
30
|
+
export type { GatewayOrderStatus, RefundEligibility, } from './refund.js';
|
|
31
|
+
export { DepositStatus, orderIdToBytes32, queryOrderStatus, checkRefundEligibility, executeRefund, checkRecoveryEligibility, } from './refund.js';
|
|
24
32
|
export { trackOrderViaWebSocket, getOrderTrackingWebSocketUrl, type TrackOrderOptions, type OrderStatusUpdate, } from './order-tracking.js';
|
|
25
33
|
export type { NaiveBase58, NaiveBase93, NaiveHexLower, NaiveHexUpper } from './belt-utils.js';
|
|
26
34
|
export { bytes_to_base58, base58_to_bytes, bytes_to_base93, base93_to_bytes, bytes_to_hex, hex_to_bytes } from './belt-utils.js';
|
|
27
|
-
export
|
|
28
|
-
export
|
|
29
|
-
export
|
|
30
|
-
export
|
|
35
|
+
export type { ContactSource, Contact, Caip10, } from './address.js';
|
|
36
|
+
export { isValidEvmAddress, isValidSolanaAddress, isValidBitcoinAddress, isValidTronAddress, validateAddress, normalizeAddress, isValidEnsName, formatAddress, formatAddressByType, getAvatarColor, getAvatarInitials, createCaip10, parseCaip10, getAddressFromCaip10, evmAddressToCaip10, solanaAddressToCaip10, bitcoinAddressToCaip10, addressToCaip10, isContactCompatibleWithAsset, filterContacts, } from './address.js';
|
|
37
|
+
export { parseCaip19Legacy, getChainNamespaceFromAsset, getChainIdFromAsset, getAssetNamespaceFromAsset, getAssetId, getCaip2, getTokenAddress, isBitcoin, isEvm, isSolana, isCosmos, isSui, isTron, isNativeTokenFromAsset, isEvmNative, isEvmErc20, isSolanaNative, isSolanaToken, isCosmosNative, isCosmosIbc, getTokenChainId, getTokenChainIdString, extractChainIdsFromAssets, extractChainIdFromAsset, getTokenChainInfo, getTokenChainName, switchChainNamespace, } from './asset-utils.js';
|
|
38
|
+
export { getSolanaRpcUrl, } from './solana-utils.js';
|
|
39
|
+
export { SilentSwapError, ApiError, NetworkError, AuthenticationError, QuoteError, OrderError, ValidationError, ConfigurationError, WalletError, TransactionError, createErrorFromResponse, } from './errors.js';
|
|
31
40
|
export { executeSolanaSwap, type SwapEnvironment, type OutputStage, type OrderStatus, type SwapStatusUpdate, type SwapResult, type EvmAccount, type SolanaAccount, type SwapAccounts, type SolanaSwapConfig, } from './swap-executor.js';
|
package/dist/index.js
CHANGED
|
@@ -1,31 +1,37 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
1
|
+
export { DeliveryMethod, PrivacySetting, FacilitatorKeyType, PublicKeyArgGroups, EIP712_TYPES_ORDER, EIP712_TYPES_WALLET_GENERATION, EIP712_DOMAIN_ORDER_DEFAULT, EIP712_DOMAIN_WALLET_GENERATION, quoteResponseToEip712Document, } from './order.js';
|
|
2
|
+
export { CAIP19_REGEX, EVM_CAIP19_REGEX, SOLANA_CAIP19_REGEX, TRON_CAIP19_NATIVE_REGEX, TRON_CAIP19_TOKEN_REGEX, Caip19Namespace, parseCaip19, parseEvmCaip19, parseSolanaCaip19, parseTronCaip19, getChainNamespace, getChainId, getEvmChainId, getAssetNamespace, getAssetReference, getEvmTokenAddress, getCaip2FromCaip19, isNativeToken, isEvmAsset, isSolanaAsset, isTronAsset, BIP122_BITCOIN_MAINNET_CHAIN_ID, isBitcoinAsset, isBitcoinMainnetAsset, isEvmNativeToken, isErc20Token, isSolanaNativeToken, isSplToken, caip19FromParts, caip19FungibleEvmToken, caip19NativeEvmToken, caip19SplToken, caip19NativeSolanaToken, } from './caip19.js';
|
|
3
3
|
export { createSilentSwapClient, } from './client.js';
|
|
4
|
-
export
|
|
5
|
-
|
|
4
|
+
export { EVM_PHONY_ADDRESS, EVM_NATIVE_ADDRESS, DEAD_ADDRESS, S0X_ADDR_EVM_ZERO, UINT256_MAX, MAINNET_GATEWAY_ADDRESS, MAINNET_GATEWAY_PUBLIC_KEY, ENVIRONMENT, ENVIRONMENT_CONFIGS, S0X_ADDR_USDC_AVALANCHE, S_CAIP19_USDC_AVALANCHE, NI_CHAIN_ID_AVALANCHE, XT_TTL_SESSION_CACHE, X_MINIMUM_INPUT_USD, X_MAX_IMPACT_PERCENT, COIN_TYPES, SB58_CHAIN_ID_SOLANA_MAINNET, SB58_ADDR_SOL_PROGRAM_SYSTEM, SB58_ADDR_SOL_RELAY_LINK_RECIPIENT, SB58_ADDR_SOL_DEAD, SBTC_ADDR_BITCOIN_NATIVE, SBTC_ADDR_BTC_RELAY_LINK_RECIPIENT, S0X_ADDR_TRON_NATIVE, SB58_ADDR_TRON_DEAD, N_RELAY_CHAIN_ID_SOLANA, N_RELAY_CHAIN_ID_BITCOIN, N_RELAY_CHAIN_ID_TRON, N_RELAY_CHAIN_ID_SUI, N_DEBRIDGE_CHAIN_ID_SOLANA, N_DEBRIDGE_CHAIN_ID_TRON, S0X_ADDR_EVM_RELAY_LINK_DEAD, P_URL_API_RPC_SOLANA, CALCULATION_DIRECTION_INPUT_TO_OUTPUT, CALCULATION_DIRECTION_OUTPUT_TO_INPUT, } from './constants.js';
|
|
5
|
+
// gateway-abi
|
|
6
|
+
export { GATEWAY_ABI, } from './gateway-abi.js';
|
|
6
7
|
export { createHdFacilitatorGroupFromEntropy, exportSecretMnemonicFromEntropy, } from './hd-facilitator-group.js';
|
|
7
8
|
export { createSignInMessage, createEip712DocForOrder, createEip712DocForWalletGeneration, } from './sdk.js';
|
|
8
9
|
export { createViemSigner, parseTransactionRequestForViem, } from './signer-adapters/viem.js';
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
export
|
|
12
|
-
|
|
13
|
-
export
|
|
14
|
-
|
|
15
|
-
export
|
|
16
|
-
|
|
17
|
-
export
|
|
18
|
-
|
|
19
|
-
export
|
|
10
|
+
export { getRelayOriginAsset, executeRelayBridge, executeDebridgeBridge, getRelayStatus, getDebridgeStatus, fetchRelayQuote, fetchDebridgeOrder, solveOptimalUsdcAmount, } from './bridge.js';
|
|
11
|
+
export { calculateRelayMetrics, calculateDebridgeMetrics, selectBestQuote, interpolateSamples, getBridgeQuote, convertQuoteResultToQuote, } from './quote-utils.js';
|
|
12
|
+
export { createTransactionExecutor, createChainSwitcher, executeBridgeTransaction, getBridgeStatus, } from './transaction-utils.js';
|
|
13
|
+
// wallet
|
|
14
|
+
export { queryDepositCount, createPhonyDepositCalldata, } from './wallet.js';
|
|
15
|
+
// storage
|
|
16
|
+
export { STORAGE_KEY_AUTH_PREFIX, STORAGE_KEY_WALLET_PREFIX, getAuthStorageKey, getWalletStorageKey, loadCachedAuth, saveAuth, clearAuth, saveWalletData, loadWalletData, clearWalletData, } from './storage.js';
|
|
17
|
+
// chain
|
|
18
|
+
export { ensureChain, pingWalletConnectSession, clearStaleWalletConnectSessions, createPublicClientWithRpc, waitForTransactionConfirmation, executeTransaction, } from './chain.js';
|
|
19
|
+
// chains
|
|
20
|
+
export { SOLANA_CHAIN_ID, BITCOIN_CHAIN_ID, TRON_CHAIN_ID, A_VIEM_CHAINS, getChainById, } from './chains.js';
|
|
21
|
+
// rpc
|
|
22
|
+
export { H_RPCS, } from './rpc.js';
|
|
23
|
+
export { loadAssetsData, getAllAssets, getAllChains, getAllAssetsArray, getCommonAssets, COMMON_ASSETS, CHAIN_NAMES, getAssetByCaip19, getChainByCaip2, getAssetsByChain, getChainName, searchAssets, } from './assets.js';
|
|
24
|
+
// encoding
|
|
25
|
+
export { hexToBytes, bytesToBase58, hexToBase58, base93ToBytes, bytesToBase93, } from './encoding.js';
|
|
26
|
+
export { DepositStatus, orderIdToBytes32, queryOrderStatus, checkRefundEligibility, executeRefund, checkRecoveryEligibility, } from './refund.js';
|
|
20
27
|
export { trackOrderViaWebSocket, getOrderTrackingWebSocketUrl, } from './order-tracking.js';
|
|
21
28
|
export { bytes_to_base58, base58_to_bytes, bytes_to_base93, base93_to_bytes, bytes_to_hex, hex_to_bytes } from './belt-utils.js';
|
|
22
|
-
export
|
|
23
|
-
//
|
|
24
|
-
|
|
25
|
-
//
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
export
|
|
29
|
-
export * from './errors.js';
|
|
29
|
+
export { isValidEvmAddress, isValidSolanaAddress, isValidBitcoinAddress, isValidTronAddress, validateAddress, normalizeAddress, isValidEnsName, formatAddress, formatAddressByType, getAvatarColor, getAvatarInitials, createCaip10, parseCaip10, getAddressFromCaip10, evmAddressToCaip10, solanaAddressToCaip10, bitcoinAddressToCaip10, addressToCaip10, isContactCompatibleWithAsset, filterContacts, } from './address.js';
|
|
30
|
+
// asset-utils
|
|
31
|
+
export { parseCaip19Legacy, getChainNamespaceFromAsset, getChainIdFromAsset, getAssetNamespaceFromAsset, getAssetId, getCaip2, getTokenAddress, isBitcoin, isEvm, isSolana, isCosmos, isSui, isTron, isNativeTokenFromAsset, isEvmNative, isEvmErc20, isSolanaNative, isSolanaToken, isCosmosNative, isCosmosIbc, getTokenChainId, getTokenChainIdString, extractChainIdsFromAssets, extractChainIdFromAsset, getTokenChainInfo, getTokenChainName, switchChainNamespace, } from './asset-utils.js';
|
|
32
|
+
// solana-utils
|
|
33
|
+
export { getSolanaRpcUrl, } from './solana-utils.js';
|
|
34
|
+
// errors
|
|
35
|
+
export { SilentSwapError, ApiError, NetworkError, AuthenticationError, QuoteError, OrderError, ValidationError, ConfigurationError, WalletError, TransactionError, createErrorFromResponse, } from './errors.js';
|
|
30
36
|
// Swap executor for Node.js integrators
|
|
31
37
|
export { executeSolanaSwap, } from './swap-executor.js';
|
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@silentswap/sdk",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.66",
|
|
5
5
|
"license": "MIT",
|
|
6
|
+
"sideEffects": false,
|
|
6
7
|
"main": "dist/index.js",
|
|
7
8
|
"files": [
|
|
8
9
|
"dist",
|
|
@@ -27,8 +28,8 @@
|
|
|
27
28
|
"@solar-republic/wasm-secp256k1": "0.6.3",
|
|
28
29
|
"bignumber.js": "9.3.1",
|
|
29
30
|
"siwe": "3.0.0",
|
|
30
|
-
"viem": "2.
|
|
31
|
-
"wagmi": "3.
|
|
31
|
+
"viem": "2.48.4",
|
|
32
|
+
"wagmi": "3.6.8"
|
|
32
33
|
},
|
|
33
34
|
"devDependencies": {
|
|
34
35
|
"@eslint/js": "9.38.0",
|