@stableflow/core 3.1.0 → 3.1.1-beta-0b82f1112c-20260722
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -0
- package/dist/index.d.mts +100 -31
- package/dist/index.d.ts +100 -31
- package/dist/index.js +162 -46
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +154 -47
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -25,10 +25,23 @@ For full cross-chain bridge flows (multi-route quote, send, status), use [`@stab
|
|
|
25
25
|
| Models | `QuoteRequest`, `QuoteResponse`, `TokenResponse`, `TokenConfig`, `WalletConfig`, … |
|
|
26
26
|
| Token / chain config | `tokens`, `usdtChains`, `usdcChains`, `frxusdChains`, `usdt0Chains` |
|
|
27
27
|
| RPC | `setRpcUrls`, `getRpcUrls`, `getChainRpcUrl`, `NetworkRpcUrlsMap` |
|
|
28
|
+
| Token prices | `getPrices`, `fetchPrices`, `PriceApiConfig`, `setPriceCacheTtl` |
|
|
29
|
+
| Swap type | `OneClickSwapType` |
|
|
28
30
|
| Utilities | `numberRemoveEndZero`, `getRouteStatus`, `getPrice`, `Csl`, `ExecTime`, … |
|
|
29
31
|
|
|
30
32
|
See `dist/index.d.ts` after running `pnpm build`.
|
|
31
33
|
|
|
34
|
+
## Token prices
|
|
35
|
+
|
|
36
|
+
The SDK fetches trusted token USD prices internally (from
|
|
37
|
+
`https://api.dapdap.net/get-token-price-by-dapdap`) and uses them for fee and
|
|
38
|
+
gas-cost estimation, so integrators do not pass a `prices` map. `getPrices()`
|
|
39
|
+
returns an in-memory cached map (TTL `PriceApiConfig.CACHE_TTL`, default 60s)
|
|
40
|
+
and throws when prices are unavailable, so quotes are never computed with
|
|
41
|
+
missing/untrusted prices. The endpoint is fixed and not user-configurable; use
|
|
42
|
+
`setPriceCacheTtl` to tune the cache TTL, and `fetchPrices()` for an uncached
|
|
43
|
+
network fetch.
|
|
44
|
+
|
|
32
45
|
## Authentication
|
|
33
46
|
|
|
34
47
|
Required for API access:
|
package/dist/index.d.mts
CHANGED
|
@@ -91,7 +91,22 @@ declare enum SendType {
|
|
|
91
91
|
/**
|
|
92
92
|
* @deprecated Please use Service instead
|
|
93
93
|
*/
|
|
94
|
-
type ServiceType = "oneclick" | "usdt0" | "cctp" | "fraxzero" | "fraxzero-oneclick" | "oneclick-fraxzero" | "usdt0-oneclick" | "oneclick-usdt0" | "native";
|
|
94
|
+
type ServiceType = "oneclick" | "usdt0" | "cctp" | "fraxzero" | "fraxzero-oneclick" | "oneclick-fraxzero" | "usdt0-oneclick" | "oneclick-usdt0" | "cctp-oneclick" | "oneclick-cctp" | "native";
|
|
95
|
+
/**
|
|
96
|
+
* OneClick swap type. Controls how `amount` is interpreted for OneClick-based
|
|
97
|
+
* routes and the underlying `/v0/quote` request.
|
|
98
|
+
*
|
|
99
|
+
* - `Input` (`EXACT_INPUT`) - `amount` is the fixed input amount.
|
|
100
|
+
* - `Output` (`EXACT_OUTPUT`) - `amount` is the fixed output amount; required
|
|
101
|
+
* input is computed and any excess is refunded to `refundTo`.
|
|
102
|
+
* - `Flex` (`FLEX_INPUT`) - flexible input allowing partial deposits.
|
|
103
|
+
*/
|
|
104
|
+
declare const OneClickSwapType: {
|
|
105
|
+
readonly Input: "EXACT_INPUT";
|
|
106
|
+
readonly Output: "EXACT_OUTPUT";
|
|
107
|
+
readonly Flex: "FLEX_INPUT";
|
|
108
|
+
};
|
|
109
|
+
type OneClickSwapType = (typeof OneClickSwapType)[keyof typeof OneClickSwapType];
|
|
95
110
|
declare const Service: {
|
|
96
111
|
readonly OneClick: "oneclick";
|
|
97
112
|
readonly Usdt0: "usdt0";
|
|
@@ -101,6 +116,8 @@ declare const Service: {
|
|
|
101
116
|
readonly OneClickFraxZero: "oneclick-fraxzero";
|
|
102
117
|
readonly Usdt0OneClick: "usdt0-oneclick";
|
|
103
118
|
readonly OneClickUsdt0: "oneclick-usdt0";
|
|
119
|
+
readonly CCTPOneClick: "cctp-oneclick";
|
|
120
|
+
readonly OneClickCCTP: "oneclick-cctp";
|
|
104
121
|
readonly Native: "native";
|
|
105
122
|
};
|
|
106
123
|
type Service = (typeof Service)[keyof typeof Service];
|
|
@@ -114,7 +131,9 @@ declare const enum ServiceProject {
|
|
|
114
131
|
OneClickFraxZero = 8,
|
|
115
132
|
Usdt0OneClick = 3,
|
|
116
133
|
OneClickUsdt0 = 4,
|
|
117
|
-
Native = 5
|
|
134
|
+
Native = 5,
|
|
135
|
+
CCTPOneClick = 9,
|
|
136
|
+
OneClickCCTP = 10
|
|
118
137
|
}
|
|
119
138
|
|
|
120
139
|
type AppFee = {
|
|
@@ -614,9 +633,9 @@ type TokenResponse = {
|
|
|
614
633
|
*/
|
|
615
634
|
decimals: number;
|
|
616
635
|
/**
|
|
617
|
-
* Blockchain associated with the token
|
|
636
|
+
* Blockchain associated with the token (API chain key, e.g. eth, arb, tron, pharos)
|
|
618
637
|
*/
|
|
619
|
-
blockchain:
|
|
638
|
+
blockchain: string;
|
|
620
639
|
/**
|
|
621
640
|
* Token symbol (e.g. BTC, ETH)
|
|
622
641
|
*/
|
|
@@ -634,32 +653,6 @@ type TokenResponse = {
|
|
|
634
653
|
*/
|
|
635
654
|
contractAddress?: string;
|
|
636
655
|
};
|
|
637
|
-
declare namespace TokenResponse {
|
|
638
|
-
/**
|
|
639
|
-
* Blockchain associated with the token
|
|
640
|
-
*/
|
|
641
|
-
enum blockchain {
|
|
642
|
-
NEAR = "near",
|
|
643
|
-
ETH = "eth",
|
|
644
|
-
BASE = "base",
|
|
645
|
-
ARB = "arb",
|
|
646
|
-
BTC = "btc",
|
|
647
|
-
SOL = "sol",
|
|
648
|
-
TON = "ton",
|
|
649
|
-
DOGE = "doge",
|
|
650
|
-
XRP = "xrp",
|
|
651
|
-
ZEC = "zec",
|
|
652
|
-
GNOSIS = "gnosis",
|
|
653
|
-
BERA = "bera",
|
|
654
|
-
BSC = "bsc",
|
|
655
|
-
POL = "pol",
|
|
656
|
-
TRON = "tron",
|
|
657
|
-
SUI = "sui",
|
|
658
|
-
OP = "op",
|
|
659
|
-
AVAX = "avax",
|
|
660
|
-
CARDANO = "cardano"
|
|
661
|
-
}
|
|
662
|
-
}
|
|
663
656
|
|
|
664
657
|
interface ChainConfig {
|
|
665
658
|
chainName: string;
|
|
@@ -769,6 +762,8 @@ declare const tokens: TokenConfig[];
|
|
|
769
762
|
declare const usdtTokens: TokenConfig[];
|
|
770
763
|
declare const usdcTokens: TokenConfig[];
|
|
771
764
|
declare const frxusdTokens: TokenConfig[];
|
|
765
|
+
declare const eureTokens: TokenConfig[];
|
|
766
|
+
declare const isStableToken: (token: TokenConfig) => boolean;
|
|
772
767
|
|
|
773
768
|
declare const usdtChains: Record<string, TokenConfig>;
|
|
774
769
|
|
|
@@ -776,6 +771,15 @@ declare const usdcChains: Record<string, TokenConfig>;
|
|
|
776
771
|
|
|
777
772
|
declare const frxusdChains: Record<string, TokenConfig>;
|
|
778
773
|
|
|
774
|
+
declare const eureChains: Record<string, TokenConfig>;
|
|
775
|
+
declare const eureEvm: {
|
|
776
|
+
chains: TokenConfig[];
|
|
777
|
+
symbol: string;
|
|
778
|
+
decimals: number;
|
|
779
|
+
icon: string;
|
|
780
|
+
name: string;
|
|
781
|
+
};
|
|
782
|
+
|
|
779
783
|
declare const usdt0Chains: Record<string, TokenConfig>;
|
|
780
784
|
|
|
781
785
|
declare const NetworkRpcUrlsMap: Record<string, string[]>;
|
|
@@ -811,8 +815,73 @@ declare const _default: {
|
|
|
811
815
|
type: string;
|
|
812
816
|
}[];
|
|
813
817
|
|
|
818
|
+
/**
|
|
819
|
+
* Look up a token's USD price from a trusted price map (case-insensitive).
|
|
820
|
+
*
|
|
821
|
+
* The `prices` map is populated internally by the SDK from the built-in price
|
|
822
|
+
* source (see `getPrices`), so a missing entry means we cannot safely value the
|
|
823
|
+
* token. In that case we throw rather than falling back to a distorted default,
|
|
824
|
+
* to avoid computing fees / on-chain amounts with a wrong price.
|
|
825
|
+
*
|
|
826
|
+
* `USDT0` / `USD₮0` / `USD₮` are normalized to `USDT` since the price feed keys
|
|
827
|
+
* plain `USDT`.
|
|
828
|
+
*
|
|
829
|
+
* @throws when no price is found for the given symbol.
|
|
830
|
+
*/
|
|
814
831
|
declare function getPrice(prices: Record<string, string>, symbol: string): string;
|
|
815
832
|
|
|
833
|
+
/**
|
|
834
|
+
* Override the in-memory price cache TTL (milliseconds).
|
|
835
|
+
*/
|
|
836
|
+
declare function setPriceCacheTtl(ms: number): void;
|
|
837
|
+
/**
|
|
838
|
+
* Fetch token USD prices directly from the configured price endpoint.
|
|
839
|
+
*
|
|
840
|
+
* Always performs a network request (no caching). Throws when the request
|
|
841
|
+
* fails or the response is malformed, so callers never proceed with missing
|
|
842
|
+
* or untrusted prices.
|
|
843
|
+
*
|
|
844
|
+
* @returns Map of token symbol -> USD price (decimal string).
|
|
845
|
+
*/
|
|
846
|
+
declare function fetchPrices(): Promise<Record<string, string>>;
|
|
847
|
+
/**
|
|
848
|
+
* Get token USD prices with a short-lived in-memory cache.
|
|
849
|
+
*
|
|
850
|
+
* The SDK calls this internally when generating quotes. Within the cache TTL
|
|
851
|
+
* (`PriceApiConfig.CACHE_TTL`) the cached map is returned without a network
|
|
852
|
+
* request; otherwise a fresh fetch is performed. Pass `{ force: true }` to
|
|
853
|
+
* bypass the cache.
|
|
854
|
+
*
|
|
855
|
+
* Throws when a fresh fetch is required but fails and no cache is available,
|
|
856
|
+
* ensuring quotes are never computed with stale/missing prices.
|
|
857
|
+
*/
|
|
858
|
+
declare function getPrices(opts?: {
|
|
859
|
+
force?: boolean;
|
|
860
|
+
}): Promise<Record<string, string>>;
|
|
861
|
+
|
|
862
|
+
/**
|
|
863
|
+
* Configuration for the built-in token price source.
|
|
864
|
+
*
|
|
865
|
+
* The SDK fetches trusted USD prices from this endpoint and uses them
|
|
866
|
+
* internally for fee/appFee computation, so integrators do not have to
|
|
867
|
+
* (and can no longer) supply their own `prices` map. This prevents wrong
|
|
868
|
+
* caller-supplied prices from causing on-chain losses.
|
|
869
|
+
*
|
|
870
|
+
* The endpoint mirrors the one used by the StableFlow web interface:
|
|
871
|
+
* `GET https://api.dapdap.net/get-token-price-by-dapdap`
|
|
872
|
+
* Response shape: `{ code: 0, msg: "success", data: Record<string, string> }`
|
|
873
|
+
* where `data` maps token symbol -> USD price (as a decimal string).
|
|
874
|
+
*
|
|
875
|
+
* The endpoint URL is fixed and cannot be changed by integrators; only the
|
|
876
|
+
* cache TTL can be tuned at runtime via `setPriceCacheTtl`.
|
|
877
|
+
*/
|
|
878
|
+
declare const PriceApiConfig: {
|
|
879
|
+
/** Full URL of the price endpoint (no query params, GET). Not user-configurable. */
|
|
880
|
+
URL: string;
|
|
881
|
+
/** In-memory cache TTL in milliseconds. */
|
|
882
|
+
CACHE_TTL: number;
|
|
883
|
+
};
|
|
884
|
+
|
|
816
885
|
declare const numberRemoveEndZero: (value: string) => string;
|
|
817
886
|
|
|
818
887
|
type StyleScale = 50 | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | 950;
|
|
@@ -851,4 +920,4 @@ declare const getRouteStatus: (service: Service, disabledServices?: Service[]) =
|
|
|
851
920
|
disabled: boolean;
|
|
852
921
|
};
|
|
853
922
|
|
|
854
|
-
export { ApiError, type AppFee, type BadRequestResponse, CancelError, CancelablePromise, type ChainType, Csl, DefaultAddresses, ExecTime, type GetExecutionStatusResponse, type GetStatusParams, type GetStatusStableflowResponse, LayerZeroStatus, NetworkRpcUrlsMap, OneClickStatus, OpenAPI, type OpenAPIConfig, type Quote, QuoteRequest, type QuoteResponse, SFA, SendType, Service, ServiceBackend, type ServiceType, StableflowStatus, type SubmitDepositTxRequest, type SubmitDepositTxResponse, type SwapDetails, type TokenConfig, TokenResponse, type TransactionDetails, TransactionStatus, type WalletConfig, _default as erc20Abi, frxusdChains, frxusdTokens, getChainRpcUrl, getPrice, getRequest, getRouteStatus, getRpcUrls, numberRemoveEndZero, postRequest, request, setRpcUrls, tokens, usdcChains, usdcTokens, usdt0Chains, usdtChains, usdtTokens };
|
|
923
|
+
export { ApiError, type AppFee, type BadRequestResponse, CancelError, CancelablePromise, type ChainType, Csl, DefaultAddresses, ExecTime, type GetExecutionStatusResponse, type GetStatusParams, type GetStatusStableflowResponse, LayerZeroStatus, NetworkRpcUrlsMap, OneClickStatus, OneClickSwapType, OpenAPI, type OpenAPIConfig, PriceApiConfig, type Quote, QuoteRequest, type QuoteResponse, SFA, SendType, Service, ServiceBackend, type ServiceType, StableflowStatus, type SubmitDepositTxRequest, type SubmitDepositTxResponse, type SwapDetails, type TokenConfig, type TokenResponse, type TransactionDetails, TransactionStatus, type WalletConfig, _default as erc20Abi, eureChains, eureEvm, eureTokens, fetchPrices, frxusdChains, frxusdTokens, getChainRpcUrl, getPrice, getPrices, getRequest, getRouteStatus, getRpcUrls, isStableToken, numberRemoveEndZero, postRequest, request, setPriceCacheTtl, setRpcUrls, tokens, usdcChains, usdcTokens, usdt0Chains, usdtChains, usdtTokens };
|
package/dist/index.d.ts
CHANGED
|
@@ -91,7 +91,22 @@ declare enum SendType {
|
|
|
91
91
|
/**
|
|
92
92
|
* @deprecated Please use Service instead
|
|
93
93
|
*/
|
|
94
|
-
type ServiceType = "oneclick" | "usdt0" | "cctp" | "fraxzero" | "fraxzero-oneclick" | "oneclick-fraxzero" | "usdt0-oneclick" | "oneclick-usdt0" | "native";
|
|
94
|
+
type ServiceType = "oneclick" | "usdt0" | "cctp" | "fraxzero" | "fraxzero-oneclick" | "oneclick-fraxzero" | "usdt0-oneclick" | "oneclick-usdt0" | "cctp-oneclick" | "oneclick-cctp" | "native";
|
|
95
|
+
/**
|
|
96
|
+
* OneClick swap type. Controls how `amount` is interpreted for OneClick-based
|
|
97
|
+
* routes and the underlying `/v0/quote` request.
|
|
98
|
+
*
|
|
99
|
+
* - `Input` (`EXACT_INPUT`) - `amount` is the fixed input amount.
|
|
100
|
+
* - `Output` (`EXACT_OUTPUT`) - `amount` is the fixed output amount; required
|
|
101
|
+
* input is computed and any excess is refunded to `refundTo`.
|
|
102
|
+
* - `Flex` (`FLEX_INPUT`) - flexible input allowing partial deposits.
|
|
103
|
+
*/
|
|
104
|
+
declare const OneClickSwapType: {
|
|
105
|
+
readonly Input: "EXACT_INPUT";
|
|
106
|
+
readonly Output: "EXACT_OUTPUT";
|
|
107
|
+
readonly Flex: "FLEX_INPUT";
|
|
108
|
+
};
|
|
109
|
+
type OneClickSwapType = (typeof OneClickSwapType)[keyof typeof OneClickSwapType];
|
|
95
110
|
declare const Service: {
|
|
96
111
|
readonly OneClick: "oneclick";
|
|
97
112
|
readonly Usdt0: "usdt0";
|
|
@@ -101,6 +116,8 @@ declare const Service: {
|
|
|
101
116
|
readonly OneClickFraxZero: "oneclick-fraxzero";
|
|
102
117
|
readonly Usdt0OneClick: "usdt0-oneclick";
|
|
103
118
|
readonly OneClickUsdt0: "oneclick-usdt0";
|
|
119
|
+
readonly CCTPOneClick: "cctp-oneclick";
|
|
120
|
+
readonly OneClickCCTP: "oneclick-cctp";
|
|
104
121
|
readonly Native: "native";
|
|
105
122
|
};
|
|
106
123
|
type Service = (typeof Service)[keyof typeof Service];
|
|
@@ -114,7 +131,9 @@ declare const enum ServiceProject {
|
|
|
114
131
|
OneClickFraxZero = 8,
|
|
115
132
|
Usdt0OneClick = 3,
|
|
116
133
|
OneClickUsdt0 = 4,
|
|
117
|
-
Native = 5
|
|
134
|
+
Native = 5,
|
|
135
|
+
CCTPOneClick = 9,
|
|
136
|
+
OneClickCCTP = 10
|
|
118
137
|
}
|
|
119
138
|
|
|
120
139
|
type AppFee = {
|
|
@@ -614,9 +633,9 @@ type TokenResponse = {
|
|
|
614
633
|
*/
|
|
615
634
|
decimals: number;
|
|
616
635
|
/**
|
|
617
|
-
* Blockchain associated with the token
|
|
636
|
+
* Blockchain associated with the token (API chain key, e.g. eth, arb, tron, pharos)
|
|
618
637
|
*/
|
|
619
|
-
blockchain:
|
|
638
|
+
blockchain: string;
|
|
620
639
|
/**
|
|
621
640
|
* Token symbol (e.g. BTC, ETH)
|
|
622
641
|
*/
|
|
@@ -634,32 +653,6 @@ type TokenResponse = {
|
|
|
634
653
|
*/
|
|
635
654
|
contractAddress?: string;
|
|
636
655
|
};
|
|
637
|
-
declare namespace TokenResponse {
|
|
638
|
-
/**
|
|
639
|
-
* Blockchain associated with the token
|
|
640
|
-
*/
|
|
641
|
-
enum blockchain {
|
|
642
|
-
NEAR = "near",
|
|
643
|
-
ETH = "eth",
|
|
644
|
-
BASE = "base",
|
|
645
|
-
ARB = "arb",
|
|
646
|
-
BTC = "btc",
|
|
647
|
-
SOL = "sol",
|
|
648
|
-
TON = "ton",
|
|
649
|
-
DOGE = "doge",
|
|
650
|
-
XRP = "xrp",
|
|
651
|
-
ZEC = "zec",
|
|
652
|
-
GNOSIS = "gnosis",
|
|
653
|
-
BERA = "bera",
|
|
654
|
-
BSC = "bsc",
|
|
655
|
-
POL = "pol",
|
|
656
|
-
TRON = "tron",
|
|
657
|
-
SUI = "sui",
|
|
658
|
-
OP = "op",
|
|
659
|
-
AVAX = "avax",
|
|
660
|
-
CARDANO = "cardano"
|
|
661
|
-
}
|
|
662
|
-
}
|
|
663
656
|
|
|
664
657
|
interface ChainConfig {
|
|
665
658
|
chainName: string;
|
|
@@ -769,6 +762,8 @@ declare const tokens: TokenConfig[];
|
|
|
769
762
|
declare const usdtTokens: TokenConfig[];
|
|
770
763
|
declare const usdcTokens: TokenConfig[];
|
|
771
764
|
declare const frxusdTokens: TokenConfig[];
|
|
765
|
+
declare const eureTokens: TokenConfig[];
|
|
766
|
+
declare const isStableToken: (token: TokenConfig) => boolean;
|
|
772
767
|
|
|
773
768
|
declare const usdtChains: Record<string, TokenConfig>;
|
|
774
769
|
|
|
@@ -776,6 +771,15 @@ declare const usdcChains: Record<string, TokenConfig>;
|
|
|
776
771
|
|
|
777
772
|
declare const frxusdChains: Record<string, TokenConfig>;
|
|
778
773
|
|
|
774
|
+
declare const eureChains: Record<string, TokenConfig>;
|
|
775
|
+
declare const eureEvm: {
|
|
776
|
+
chains: TokenConfig[];
|
|
777
|
+
symbol: string;
|
|
778
|
+
decimals: number;
|
|
779
|
+
icon: string;
|
|
780
|
+
name: string;
|
|
781
|
+
};
|
|
782
|
+
|
|
779
783
|
declare const usdt0Chains: Record<string, TokenConfig>;
|
|
780
784
|
|
|
781
785
|
declare const NetworkRpcUrlsMap: Record<string, string[]>;
|
|
@@ -811,8 +815,73 @@ declare const _default: {
|
|
|
811
815
|
type: string;
|
|
812
816
|
}[];
|
|
813
817
|
|
|
818
|
+
/**
|
|
819
|
+
* Look up a token's USD price from a trusted price map (case-insensitive).
|
|
820
|
+
*
|
|
821
|
+
* The `prices` map is populated internally by the SDK from the built-in price
|
|
822
|
+
* source (see `getPrices`), so a missing entry means we cannot safely value the
|
|
823
|
+
* token. In that case we throw rather than falling back to a distorted default,
|
|
824
|
+
* to avoid computing fees / on-chain amounts with a wrong price.
|
|
825
|
+
*
|
|
826
|
+
* `USDT0` / `USD₮0` / `USD₮` are normalized to `USDT` since the price feed keys
|
|
827
|
+
* plain `USDT`.
|
|
828
|
+
*
|
|
829
|
+
* @throws when no price is found for the given symbol.
|
|
830
|
+
*/
|
|
814
831
|
declare function getPrice(prices: Record<string, string>, symbol: string): string;
|
|
815
832
|
|
|
833
|
+
/**
|
|
834
|
+
* Override the in-memory price cache TTL (milliseconds).
|
|
835
|
+
*/
|
|
836
|
+
declare function setPriceCacheTtl(ms: number): void;
|
|
837
|
+
/**
|
|
838
|
+
* Fetch token USD prices directly from the configured price endpoint.
|
|
839
|
+
*
|
|
840
|
+
* Always performs a network request (no caching). Throws when the request
|
|
841
|
+
* fails or the response is malformed, so callers never proceed with missing
|
|
842
|
+
* or untrusted prices.
|
|
843
|
+
*
|
|
844
|
+
* @returns Map of token symbol -> USD price (decimal string).
|
|
845
|
+
*/
|
|
846
|
+
declare function fetchPrices(): Promise<Record<string, string>>;
|
|
847
|
+
/**
|
|
848
|
+
* Get token USD prices with a short-lived in-memory cache.
|
|
849
|
+
*
|
|
850
|
+
* The SDK calls this internally when generating quotes. Within the cache TTL
|
|
851
|
+
* (`PriceApiConfig.CACHE_TTL`) the cached map is returned without a network
|
|
852
|
+
* request; otherwise a fresh fetch is performed. Pass `{ force: true }` to
|
|
853
|
+
* bypass the cache.
|
|
854
|
+
*
|
|
855
|
+
* Throws when a fresh fetch is required but fails and no cache is available,
|
|
856
|
+
* ensuring quotes are never computed with stale/missing prices.
|
|
857
|
+
*/
|
|
858
|
+
declare function getPrices(opts?: {
|
|
859
|
+
force?: boolean;
|
|
860
|
+
}): Promise<Record<string, string>>;
|
|
861
|
+
|
|
862
|
+
/**
|
|
863
|
+
* Configuration for the built-in token price source.
|
|
864
|
+
*
|
|
865
|
+
* The SDK fetches trusted USD prices from this endpoint and uses them
|
|
866
|
+
* internally for fee/appFee computation, so integrators do not have to
|
|
867
|
+
* (and can no longer) supply their own `prices` map. This prevents wrong
|
|
868
|
+
* caller-supplied prices from causing on-chain losses.
|
|
869
|
+
*
|
|
870
|
+
* The endpoint mirrors the one used by the StableFlow web interface:
|
|
871
|
+
* `GET https://api.dapdap.net/get-token-price-by-dapdap`
|
|
872
|
+
* Response shape: `{ code: 0, msg: "success", data: Record<string, string> }`
|
|
873
|
+
* where `data` maps token symbol -> USD price (as a decimal string).
|
|
874
|
+
*
|
|
875
|
+
* The endpoint URL is fixed and cannot be changed by integrators; only the
|
|
876
|
+
* cache TTL can be tuned at runtime via `setPriceCacheTtl`.
|
|
877
|
+
*/
|
|
878
|
+
declare const PriceApiConfig: {
|
|
879
|
+
/** Full URL of the price endpoint (no query params, GET). Not user-configurable. */
|
|
880
|
+
URL: string;
|
|
881
|
+
/** In-memory cache TTL in milliseconds. */
|
|
882
|
+
CACHE_TTL: number;
|
|
883
|
+
};
|
|
884
|
+
|
|
816
885
|
declare const numberRemoveEndZero: (value: string) => string;
|
|
817
886
|
|
|
818
887
|
type StyleScale = 50 | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | 950;
|
|
@@ -851,4 +920,4 @@ declare const getRouteStatus: (service: Service, disabledServices?: Service[]) =
|
|
|
851
920
|
disabled: boolean;
|
|
852
921
|
};
|
|
853
922
|
|
|
854
|
-
export { ApiError, type AppFee, type BadRequestResponse, CancelError, CancelablePromise, type ChainType, Csl, DefaultAddresses, ExecTime, type GetExecutionStatusResponse, type GetStatusParams, type GetStatusStableflowResponse, LayerZeroStatus, NetworkRpcUrlsMap, OneClickStatus, OpenAPI, type OpenAPIConfig, type Quote, QuoteRequest, type QuoteResponse, SFA, SendType, Service, ServiceBackend, type ServiceType, StableflowStatus, type SubmitDepositTxRequest, type SubmitDepositTxResponse, type SwapDetails, type TokenConfig, TokenResponse, type TransactionDetails, TransactionStatus, type WalletConfig, _default as erc20Abi, frxusdChains, frxusdTokens, getChainRpcUrl, getPrice, getRequest, getRouteStatus, getRpcUrls, numberRemoveEndZero, postRequest, request, setRpcUrls, tokens, usdcChains, usdcTokens, usdt0Chains, usdtChains, usdtTokens };
|
|
923
|
+
export { ApiError, type AppFee, type BadRequestResponse, CancelError, CancelablePromise, type ChainType, Csl, DefaultAddresses, ExecTime, type GetExecutionStatusResponse, type GetStatusParams, type GetStatusStableflowResponse, LayerZeroStatus, NetworkRpcUrlsMap, OneClickStatus, OneClickSwapType, OpenAPI, type OpenAPIConfig, PriceApiConfig, type Quote, QuoteRequest, type QuoteResponse, SFA, SendType, Service, ServiceBackend, type ServiceType, StableflowStatus, type SubmitDepositTxRequest, type SubmitDepositTxResponse, type SwapDetails, type TokenConfig, type TokenResponse, type TransactionDetails, TransactionStatus, type WalletConfig, _default as erc20Abi, eureChains, eureEvm, eureTokens, fetchPrices, frxusdChains, frxusdTokens, getChainRpcUrl, getPrice, getPrices, getRequest, getRouteStatus, getRpcUrls, isStableToken, numberRemoveEndZero, postRequest, request, setPriceCacheTtl, setRpcUrls, tokens, usdcChains, usdcTokens, usdt0Chains, usdtChains, usdtTokens };
|