@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/dist/index.js
CHANGED
|
@@ -623,6 +623,11 @@ var SendType = /* @__PURE__ */ ((SendType2) => {
|
|
|
623
623
|
})(SendType || {});
|
|
624
624
|
|
|
625
625
|
// src/core/Service.ts
|
|
626
|
+
var OneClickSwapType = {
|
|
627
|
+
Input: "EXACT_INPUT",
|
|
628
|
+
Output: "EXACT_OUTPUT",
|
|
629
|
+
Flex: "FLEX_INPUT"
|
|
630
|
+
};
|
|
626
631
|
var Service = {
|
|
627
632
|
OneClick: "oneclick",
|
|
628
633
|
Usdt0: "usdt0",
|
|
@@ -632,6 +637,8 @@ var Service = {
|
|
|
632
637
|
OneClickFraxZero: "oneclick-fraxzero",
|
|
633
638
|
Usdt0OneClick: "usdt0-oneclick",
|
|
634
639
|
OneClickUsdt0: "oneclick-usdt0",
|
|
640
|
+
CCTPOneClick: "cctp-oneclick",
|
|
641
|
+
OneClickCCTP: "oneclick-cctp",
|
|
635
642
|
Native: "native"
|
|
636
643
|
};
|
|
637
644
|
var ServiceBackend = {
|
|
@@ -643,6 +650,8 @@ var ServiceBackend = {
|
|
|
643
650
|
[Service.OneClickFraxZero]: "intentfraxzero",
|
|
644
651
|
[Service.Usdt0OneClick]: "zerointent",
|
|
645
652
|
[Service.OneClickUsdt0]: "intentzero",
|
|
653
|
+
[Service.CCTPOneClick]: "cctpintent",
|
|
654
|
+
[Service.OneClickCCTP]: "intentcctp",
|
|
646
655
|
[Service.Native]: "native"
|
|
647
656
|
};
|
|
648
657
|
({
|
|
@@ -654,7 +663,9 @@ var ServiceBackend = {
|
|
|
654
663
|
[8 /* OneClickFraxZero */]: { service: Service.OneClickFraxZero },
|
|
655
664
|
[3 /* Usdt0OneClick */]: { service: Service.Usdt0OneClick },
|
|
656
665
|
[4 /* OneClickUsdt0 */]: { service: Service.OneClickUsdt0 },
|
|
657
|
-
[5 /* Native */]: { service: Service.Native }
|
|
666
|
+
[5 /* Native */]: { service: Service.Native },
|
|
667
|
+
[9 /* CCTPOneClick */]: { service: Service.CCTPOneClick },
|
|
668
|
+
[10 /* OneClickCCTP */]: { service: Service.OneClickCCTP }
|
|
658
669
|
});
|
|
659
670
|
|
|
660
671
|
// src/models/ServiceStatus.ts
|
|
@@ -717,32 +728,6 @@ exports.QuoteRequest = void 0;
|
|
|
717
728
|
})(QuoteRequest2.recipientType || (QuoteRequest2.recipientType = {}));
|
|
718
729
|
})(exports.QuoteRequest || (exports.QuoteRequest = {}));
|
|
719
730
|
|
|
720
|
-
// src/models/TokenResponse.ts
|
|
721
|
-
exports.TokenResponse = void 0;
|
|
722
|
-
((TokenResponse2) => {
|
|
723
|
-
((blockchain2) => {
|
|
724
|
-
blockchain2["NEAR"] = "near";
|
|
725
|
-
blockchain2["ETH"] = "eth";
|
|
726
|
-
blockchain2["BASE"] = "base";
|
|
727
|
-
blockchain2["ARB"] = "arb";
|
|
728
|
-
blockchain2["BTC"] = "btc";
|
|
729
|
-
blockchain2["SOL"] = "sol";
|
|
730
|
-
blockchain2["TON"] = "ton";
|
|
731
|
-
blockchain2["DOGE"] = "doge";
|
|
732
|
-
blockchain2["XRP"] = "xrp";
|
|
733
|
-
blockchain2["ZEC"] = "zec";
|
|
734
|
-
blockchain2["GNOSIS"] = "gnosis";
|
|
735
|
-
blockchain2["BERA"] = "bera";
|
|
736
|
-
blockchain2["BSC"] = "bsc";
|
|
737
|
-
blockchain2["POL"] = "pol";
|
|
738
|
-
blockchain2["TRON"] = "tron";
|
|
739
|
-
blockchain2["SUI"] = "sui";
|
|
740
|
-
blockchain2["OP"] = "op";
|
|
741
|
-
blockchain2["AVAX"] = "avax";
|
|
742
|
-
blockchain2["CARDANO"] = "cardano";
|
|
743
|
-
})(TokenResponse2.blockchain || (TokenResponse2.blockchain = {}));
|
|
744
|
-
})(exports.TokenResponse || (exports.TokenResponse = {}));
|
|
745
|
-
|
|
746
731
|
// src/models/Status.ts
|
|
747
732
|
var TransactionStatus = /* @__PURE__ */ ((TransactionStatus2) => {
|
|
748
733
|
TransactionStatus2["Pending"] = "pending";
|
|
@@ -817,7 +802,8 @@ var NetworkRpcUrlsMap = {
|
|
|
817
802
|
"frax": ["https://rpc.frax.com"],
|
|
818
803
|
"ton": ["https://toncenter.com/api/v2/jsonRPC"],
|
|
819
804
|
"sui": ["https://fullnode.mainnet.sui.io:443"],
|
|
820
|
-
"katana": ["https://rpc.katana.network", "https://katana.drpc.org"]
|
|
805
|
+
"katana": ["https://rpc.katana.network", "https://katana.drpc.org"],
|
|
806
|
+
"pharos": ["https://rpc.pharos.xyz"]
|
|
821
807
|
};
|
|
822
808
|
var getRpcUrls = (blockchain) => {
|
|
823
809
|
return NetworkRpcUrlsMap[blockchain] || [];
|
|
@@ -991,6 +977,19 @@ var chains = {
|
|
|
991
977
|
...getChainRpcUrl("pol")
|
|
992
978
|
},
|
|
993
979
|
gnosis: {
|
|
980
|
+
chainName: "Gnosis",
|
|
981
|
+
blockchain: "gnosis",
|
|
982
|
+
chainIcon: getStableflowChainLogo("Gnosis"),
|
|
983
|
+
chainIconGray: getStableflowChainLogo("Gnosis-gray"),
|
|
984
|
+
chainType: chainTypes.evm.value,
|
|
985
|
+
chainId: 100,
|
|
986
|
+
blockExplorerUrl: "https://gnosisscan.io/tx",
|
|
987
|
+
blockExplorerUrls: ["https://gnosisscan.io"],
|
|
988
|
+
primaryColor: "#285230",
|
|
989
|
+
nativeToken: {
|
|
990
|
+
symbol: "XDAI",
|
|
991
|
+
decimals: 18
|
|
992
|
+
},
|
|
994
993
|
...getChainRpcUrl("gnosis")
|
|
995
994
|
},
|
|
996
995
|
op: {
|
|
@@ -1260,6 +1259,22 @@ var chains = {
|
|
|
1260
1259
|
decimals: 18
|
|
1261
1260
|
},
|
|
1262
1261
|
...getChainRpcUrl("katana")
|
|
1262
|
+
},
|
|
1263
|
+
pharos: {
|
|
1264
|
+
chainName: "Pharos",
|
|
1265
|
+
blockchain: "pharos",
|
|
1266
|
+
chainIcon: getStableflowChainLogo("Pharos"),
|
|
1267
|
+
chainIconGray: getStableflowChainLogo("Pharos-gray"),
|
|
1268
|
+
chainType: chainTypes.evm.value,
|
|
1269
|
+
chainId: 1672,
|
|
1270
|
+
blockExplorerUrl: "https://www.pharosscan.xyz/tx",
|
|
1271
|
+
blockExplorerUrls: ["https://www.pharosscan.xyz"],
|
|
1272
|
+
primaryColor: "#0066FF",
|
|
1273
|
+
nativeToken: {
|
|
1274
|
+
symbol: "PROS",
|
|
1275
|
+
decimals: 18
|
|
1276
|
+
},
|
|
1277
|
+
...getChainRpcUrl("pharos")
|
|
1263
1278
|
}
|
|
1264
1279
|
};
|
|
1265
1280
|
var chains_default = chains;
|
|
@@ -1582,6 +1597,13 @@ var usdcChains = {
|
|
|
1582
1597
|
contractAddress: "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC",
|
|
1583
1598
|
...chains_default.sui,
|
|
1584
1599
|
services: [Service.OneClick]
|
|
1600
|
+
},
|
|
1601
|
+
pharos: {
|
|
1602
|
+
...usdc,
|
|
1603
|
+
assetId: "",
|
|
1604
|
+
contractAddress: "0xC879C018dB60520F4355C26eD1a6D572cdAC1815",
|
|
1605
|
+
...chains_default.pharos,
|
|
1606
|
+
services: [Service.CCTP]
|
|
1585
1607
|
}
|
|
1586
1608
|
};
|
|
1587
1609
|
({
|
|
@@ -1706,16 +1728,42 @@ var frxusdChains = {
|
|
|
1706
1728
|
chains: Object.values(frxusdChains).filter((chain) => chain.chainType === "evm")
|
|
1707
1729
|
});
|
|
1708
1730
|
|
|
1731
|
+
// src/wallets/config/eure.ts
|
|
1732
|
+
var eure = {
|
|
1733
|
+
symbol: "EURe",
|
|
1734
|
+
decimals: 18,
|
|
1735
|
+
icon: "/eure.png",
|
|
1736
|
+
name: "Monerium EURe"
|
|
1737
|
+
};
|
|
1738
|
+
var eureChains = {
|
|
1739
|
+
gnosis: {
|
|
1740
|
+
...eure,
|
|
1741
|
+
assetId: "nep141:gnosis-0x420ca0f9b9b604ce0fd9c18ef134c705e5fa3430.omft.near",
|
|
1742
|
+
contractAddress: "0x420ca0f9b9b604ce0fd9c18ef134c705e5fa3430",
|
|
1743
|
+
...chains_default.gnosis,
|
|
1744
|
+
services: [Service.OneClick]
|
|
1745
|
+
}
|
|
1746
|
+
};
|
|
1747
|
+
var eureEvm = {
|
|
1748
|
+
...eure,
|
|
1749
|
+
chains: Object.values(eureChains).filter((chain) => chain.chainType === "evm")
|
|
1750
|
+
};
|
|
1751
|
+
|
|
1709
1752
|
// src/wallets/config/tokens.ts
|
|
1710
1753
|
var tokens = [
|
|
1711
1754
|
...Object.values(usdtChains),
|
|
1712
1755
|
...Object.values(usdcChains),
|
|
1713
1756
|
...Object.values(usdt0Chains),
|
|
1714
|
-
...Object.values(frxusdChains)
|
|
1757
|
+
...Object.values(frxusdChains),
|
|
1758
|
+
...Object.values(eureChains)
|
|
1715
1759
|
];
|
|
1716
1760
|
var usdtTokens = [...Object.values(usdtChains), ...Object.values(usdt0Chains)];
|
|
1717
1761
|
var usdcTokens = Object.values(usdcChains);
|
|
1718
1762
|
var frxusdTokens = Object.values(frxusdChains);
|
|
1763
|
+
var eureTokens = Object.values(eureChains);
|
|
1764
|
+
var isStableToken = (token) => {
|
|
1765
|
+
return !["EURe"].includes(token.symbol);
|
|
1766
|
+
};
|
|
1719
1767
|
|
|
1720
1768
|
// src/wallets/config/addresses.ts
|
|
1721
1769
|
var DefaultAddresses = {
|
|
@@ -1807,26 +1855,65 @@ var erc20_default = [
|
|
|
1807
1855
|
|
|
1808
1856
|
// src/utils/price.ts
|
|
1809
1857
|
function getPrice(prices, symbol) {
|
|
1810
|
-
let
|
|
1811
|
-
if (
|
|
1812
|
-
|
|
1813
|
-
if (price !== "0") {
|
|
1814
|
-
return price;
|
|
1815
|
-
}
|
|
1858
|
+
let _symbol = symbol;
|
|
1859
|
+
if (symbol === "USDT0" || symbol === "USD\u20AE0" || symbol === "USD\u20AE") {
|
|
1860
|
+
_symbol = "USDT";
|
|
1816
1861
|
}
|
|
1817
|
-
if (prices[
|
|
1818
|
-
|
|
1819
|
-
if (price !== "0") {
|
|
1820
|
-
return price;
|
|
1821
|
-
}
|
|
1862
|
+
if (prices?.[_symbol] && prices[_symbol] !== "0") {
|
|
1863
|
+
return prices[_symbol];
|
|
1822
1864
|
}
|
|
1823
|
-
if (prices[
|
|
1824
|
-
|
|
1825
|
-
if (price !== "0") {
|
|
1826
|
-
return price;
|
|
1827
|
-
}
|
|
1865
|
+
if (prices?.[_symbol.toLowerCase()] && prices[_symbol.toLowerCase()] !== "0") {
|
|
1866
|
+
return prices[_symbol.toLowerCase()];
|
|
1828
1867
|
}
|
|
1829
|
-
|
|
1868
|
+
if (prices?.[_symbol.toUpperCase()] && prices[_symbol.toUpperCase()] !== "0") {
|
|
1869
|
+
return prices[_symbol.toUpperCase()];
|
|
1870
|
+
}
|
|
1871
|
+
throw new Error(`Missing price for token: ${symbol}`);
|
|
1872
|
+
}
|
|
1873
|
+
|
|
1874
|
+
// src/config/price-api.ts
|
|
1875
|
+
var PriceApiConfig = {
|
|
1876
|
+
/** Full URL of the price endpoint (no query params, GET). Not user-configurable. */
|
|
1877
|
+
URL: "https://api.dapdap.net/get-token-price-by-dapdap",
|
|
1878
|
+
/** In-memory cache TTL in milliseconds. */
|
|
1879
|
+
CACHE_TTL: 6e4
|
|
1880
|
+
};
|
|
1881
|
+
|
|
1882
|
+
// src/services/PriceService.ts
|
|
1883
|
+
var priceCache = null;
|
|
1884
|
+
var priceCacheAt = 0;
|
|
1885
|
+
var inflight = null;
|
|
1886
|
+
function setPriceCacheTtl(ms) {
|
|
1887
|
+
PriceApiConfig.CACHE_TTL = ms;
|
|
1888
|
+
}
|
|
1889
|
+
async function fetchPrices() {
|
|
1890
|
+
let res;
|
|
1891
|
+
try {
|
|
1892
|
+
res = await axios__default.default.get(PriceApiConfig.URL, { timeout: 3e4 });
|
|
1893
|
+
} catch (error) {
|
|
1894
|
+
throw new Error(`Failed to fetch token prices: ${error?.message || error}`);
|
|
1895
|
+
}
|
|
1896
|
+
if (res.status !== 200 || res.data?.code !== 0 || !res.data?.data) {
|
|
1897
|
+
throw new Error(`Failed to fetch token prices: unexpected response (code=${res.data?.code})`);
|
|
1898
|
+
}
|
|
1899
|
+
return res.data.data;
|
|
1900
|
+
}
|
|
1901
|
+
async function getPrices(opts) {
|
|
1902
|
+
const now = Date.now();
|
|
1903
|
+
const isFresh = priceCache && now - priceCacheAt < PriceApiConfig.CACHE_TTL;
|
|
1904
|
+
if (!opts?.force && isFresh) {
|
|
1905
|
+
return priceCache;
|
|
1906
|
+
}
|
|
1907
|
+
if (!inflight) {
|
|
1908
|
+
inflight = fetchPrices().then((prices) => {
|
|
1909
|
+
priceCache = prices;
|
|
1910
|
+
priceCacheAt = Date.now();
|
|
1911
|
+
return prices;
|
|
1912
|
+
}).finally(() => {
|
|
1913
|
+
inflight = null;
|
|
1914
|
+
});
|
|
1915
|
+
}
|
|
1916
|
+
return inflight;
|
|
1830
1917
|
}
|
|
1831
1918
|
|
|
1832
1919
|
// src/utils/number.ts
|
|
@@ -1885,6 +1972,8 @@ var getRouteStatus = (service, disabledServices) => {
|
|
|
1885
1972
|
const IS_PAUSE_ONECLICK_USDT0 = disabledServices.includes(Service.OneClickUsdt0);
|
|
1886
1973
|
const IS_PAUSE_FRAXZERO_ONECLICK = disabledServices.includes(Service.FraxZeroOneClick);
|
|
1887
1974
|
const IS_PAUSE_ONECLICK_FRAXZERO = disabledServices.includes(Service.OneClickFraxZero);
|
|
1975
|
+
const IS_PAUSE_CCTP_ONECLICK = disabledServices.includes(Service.CCTPOneClick);
|
|
1976
|
+
const IS_PAUSE_ONECLICK_CCTP = disabledServices.includes(Service.OneClickCCTP);
|
|
1888
1977
|
const IS_PAUSE_ALL = IS_PAUSE_ONECLICK && IS_PAUSE_USDT0 && IS_PAUSE_CCTP && IS_PAUSE_FRAXZERO && IS_PAUSE_NATIVE;
|
|
1889
1978
|
if (IS_PAUSE_ALL) {
|
|
1890
1979
|
result.disabled = true;
|
|
@@ -1896,6 +1985,12 @@ var getRouteStatus = (service, disabledServices) => {
|
|
|
1896
1985
|
return result;
|
|
1897
1986
|
}
|
|
1898
1987
|
}
|
|
1988
|
+
if ([Service.CCTPOneClick, Service.OneClickCCTP].includes(service)) {
|
|
1989
|
+
if (IS_PAUSE_ONECLICK || IS_PAUSE_CCTP) {
|
|
1990
|
+
result.disabled = true;
|
|
1991
|
+
return result;
|
|
1992
|
+
}
|
|
1993
|
+
}
|
|
1899
1994
|
if (service === Service.FraxZero) {
|
|
1900
1995
|
if (IS_PAUSE_FRAXZERO) {
|
|
1901
1996
|
result.disabled = true;
|
|
@@ -1956,6 +2051,18 @@ var getRouteStatus = (service, disabledServices) => {
|
|
|
1956
2051
|
return result;
|
|
1957
2052
|
}
|
|
1958
2053
|
}
|
|
2054
|
+
if (service === Service.CCTPOneClick) {
|
|
2055
|
+
if (IS_PAUSE_CCTP_ONECLICK) {
|
|
2056
|
+
result.disabled = true;
|
|
2057
|
+
return result;
|
|
2058
|
+
}
|
|
2059
|
+
}
|
|
2060
|
+
if (service === Service.OneClickCCTP) {
|
|
2061
|
+
if (IS_PAUSE_ONECLICK_CCTP) {
|
|
2062
|
+
result.disabled = true;
|
|
2063
|
+
return result;
|
|
2064
|
+
}
|
|
2065
|
+
}
|
|
1959
2066
|
return result;
|
|
1960
2067
|
};
|
|
1961
2068
|
|
|
@@ -1968,7 +2075,9 @@ exports.ExecTime = ExecTime;
|
|
|
1968
2075
|
exports.LayerZeroStatus = LayerZeroStatus;
|
|
1969
2076
|
exports.NetworkRpcUrlsMap = NetworkRpcUrlsMap;
|
|
1970
2077
|
exports.OneClickStatus = OneClickStatus;
|
|
2078
|
+
exports.OneClickSwapType = OneClickSwapType;
|
|
1971
2079
|
exports.OpenAPI = OpenAPI;
|
|
2080
|
+
exports.PriceApiConfig = PriceApiConfig;
|
|
1972
2081
|
exports.SFA = SFA;
|
|
1973
2082
|
exports.SendType = SendType;
|
|
1974
2083
|
exports.Service = Service;
|
|
@@ -1976,16 +2085,23 @@ exports.ServiceBackend = ServiceBackend;
|
|
|
1976
2085
|
exports.StableflowStatus = StableflowStatus;
|
|
1977
2086
|
exports.TransactionStatus = TransactionStatus;
|
|
1978
2087
|
exports.erc20Abi = erc20_default;
|
|
2088
|
+
exports.eureChains = eureChains;
|
|
2089
|
+
exports.eureEvm = eureEvm;
|
|
2090
|
+
exports.eureTokens = eureTokens;
|
|
2091
|
+
exports.fetchPrices = fetchPrices;
|
|
1979
2092
|
exports.frxusdChains = frxusdChains;
|
|
1980
2093
|
exports.frxusdTokens = frxusdTokens;
|
|
1981
2094
|
exports.getChainRpcUrl = getChainRpcUrl;
|
|
1982
2095
|
exports.getPrice = getPrice;
|
|
2096
|
+
exports.getPrices = getPrices;
|
|
1983
2097
|
exports.getRequest = getRequest;
|
|
1984
2098
|
exports.getRouteStatus = getRouteStatus;
|
|
1985
2099
|
exports.getRpcUrls = getRpcUrls;
|
|
2100
|
+
exports.isStableToken = isStableToken;
|
|
1986
2101
|
exports.numberRemoveEndZero = numberRemoveEndZero;
|
|
1987
2102
|
exports.postRequest = postRequest;
|
|
1988
2103
|
exports.request = request;
|
|
2104
|
+
exports.setPriceCacheTtl = setPriceCacheTtl;
|
|
1989
2105
|
exports.setRpcUrls = setRpcUrls;
|
|
1990
2106
|
exports.tokens = tokens;
|
|
1991
2107
|
exports.usdcChains = usdcChains;
|