@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/dist/index.mjs CHANGED
@@ -616,6 +616,11 @@ var SendType = /* @__PURE__ */ ((SendType2) => {
616
616
  })(SendType || {});
617
617
 
618
618
  // src/core/Service.ts
619
+ var OneClickSwapType = {
620
+ Input: "EXACT_INPUT",
621
+ Output: "EXACT_OUTPUT",
622
+ Flex: "FLEX_INPUT"
623
+ };
619
624
  var Service = {
620
625
  OneClick: "oneclick",
621
626
  Usdt0: "usdt0",
@@ -625,6 +630,8 @@ var Service = {
625
630
  OneClickFraxZero: "oneclick-fraxzero",
626
631
  Usdt0OneClick: "usdt0-oneclick",
627
632
  OneClickUsdt0: "oneclick-usdt0",
633
+ CCTPOneClick: "cctp-oneclick",
634
+ OneClickCCTP: "oneclick-cctp",
628
635
  Native: "native"
629
636
  };
630
637
  var ServiceBackend = {
@@ -636,6 +643,8 @@ var ServiceBackend = {
636
643
  [Service.OneClickFraxZero]: "intentfraxzero",
637
644
  [Service.Usdt0OneClick]: "zerointent",
638
645
  [Service.OneClickUsdt0]: "intentzero",
646
+ [Service.CCTPOneClick]: "cctpintent",
647
+ [Service.OneClickCCTP]: "intentcctp",
639
648
  [Service.Native]: "native"
640
649
  };
641
650
  ({
@@ -647,7 +656,9 @@ var ServiceBackend = {
647
656
  [8 /* OneClickFraxZero */]: { service: Service.OneClickFraxZero },
648
657
  [3 /* Usdt0OneClick */]: { service: Service.Usdt0OneClick },
649
658
  [4 /* OneClickUsdt0 */]: { service: Service.OneClickUsdt0 },
650
- [5 /* Native */]: { service: Service.Native }
659
+ [5 /* Native */]: { service: Service.Native },
660
+ [9 /* CCTPOneClick */]: { service: Service.CCTPOneClick },
661
+ [10 /* OneClickCCTP */]: { service: Service.OneClickCCTP }
651
662
  });
652
663
 
653
664
  // src/models/ServiceStatus.ts
@@ -710,32 +721,6 @@ var QuoteRequest;
710
721
  })(QuoteRequest2.recipientType || (QuoteRequest2.recipientType = {}));
711
722
  })(QuoteRequest || (QuoteRequest = {}));
712
723
 
713
- // src/models/TokenResponse.ts
714
- var TokenResponse;
715
- ((TokenResponse2) => {
716
- ((blockchain2) => {
717
- blockchain2["NEAR"] = "near";
718
- blockchain2["ETH"] = "eth";
719
- blockchain2["BASE"] = "base";
720
- blockchain2["ARB"] = "arb";
721
- blockchain2["BTC"] = "btc";
722
- blockchain2["SOL"] = "sol";
723
- blockchain2["TON"] = "ton";
724
- blockchain2["DOGE"] = "doge";
725
- blockchain2["XRP"] = "xrp";
726
- blockchain2["ZEC"] = "zec";
727
- blockchain2["GNOSIS"] = "gnosis";
728
- blockchain2["BERA"] = "bera";
729
- blockchain2["BSC"] = "bsc";
730
- blockchain2["POL"] = "pol";
731
- blockchain2["TRON"] = "tron";
732
- blockchain2["SUI"] = "sui";
733
- blockchain2["OP"] = "op";
734
- blockchain2["AVAX"] = "avax";
735
- blockchain2["CARDANO"] = "cardano";
736
- })(TokenResponse2.blockchain || (TokenResponse2.blockchain = {}));
737
- })(TokenResponse || (TokenResponse = {}));
738
-
739
724
  // src/models/Status.ts
740
725
  var TransactionStatus = /* @__PURE__ */ ((TransactionStatus2) => {
741
726
  TransactionStatus2["Pending"] = "pending";
@@ -810,7 +795,8 @@ var NetworkRpcUrlsMap = {
810
795
  "frax": ["https://rpc.frax.com"],
811
796
  "ton": ["https://toncenter.com/api/v2/jsonRPC"],
812
797
  "sui": ["https://fullnode.mainnet.sui.io:443"],
813
- "katana": ["https://rpc.katana.network", "https://katana.drpc.org"]
798
+ "katana": ["https://rpc.katana.network", "https://katana.drpc.org"],
799
+ "pharos": ["https://rpc.pharos.xyz"]
814
800
  };
815
801
  var getRpcUrls = (blockchain) => {
816
802
  return NetworkRpcUrlsMap[blockchain] || [];
@@ -984,6 +970,19 @@ var chains = {
984
970
  ...getChainRpcUrl("pol")
985
971
  },
986
972
  gnosis: {
973
+ chainName: "Gnosis",
974
+ blockchain: "gnosis",
975
+ chainIcon: getStableflowChainLogo("Gnosis"),
976
+ chainIconGray: getStableflowChainLogo("Gnosis-gray"),
977
+ chainType: chainTypes.evm.value,
978
+ chainId: 100,
979
+ blockExplorerUrl: "https://gnosisscan.io/tx",
980
+ blockExplorerUrls: ["https://gnosisscan.io"],
981
+ primaryColor: "#285230",
982
+ nativeToken: {
983
+ symbol: "XDAI",
984
+ decimals: 18
985
+ },
987
986
  ...getChainRpcUrl("gnosis")
988
987
  },
989
988
  op: {
@@ -1253,6 +1252,22 @@ var chains = {
1253
1252
  decimals: 18
1254
1253
  },
1255
1254
  ...getChainRpcUrl("katana")
1255
+ },
1256
+ pharos: {
1257
+ chainName: "Pharos",
1258
+ blockchain: "pharos",
1259
+ chainIcon: getStableflowChainLogo("Pharos"),
1260
+ chainIconGray: getStableflowChainLogo("Pharos-gray"),
1261
+ chainType: chainTypes.evm.value,
1262
+ chainId: 1672,
1263
+ blockExplorerUrl: "https://www.pharosscan.xyz/tx",
1264
+ blockExplorerUrls: ["https://www.pharosscan.xyz"],
1265
+ primaryColor: "#0066FF",
1266
+ nativeToken: {
1267
+ symbol: "PROS",
1268
+ decimals: 18
1269
+ },
1270
+ ...getChainRpcUrl("pharos")
1256
1271
  }
1257
1272
  };
1258
1273
  var chains_default = chains;
@@ -1575,6 +1590,13 @@ var usdcChains = {
1575
1590
  contractAddress: "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC",
1576
1591
  ...chains_default.sui,
1577
1592
  services: [Service.OneClick]
1593
+ },
1594
+ pharos: {
1595
+ ...usdc,
1596
+ assetId: "",
1597
+ contractAddress: "0xC879C018dB60520F4355C26eD1a6D572cdAC1815",
1598
+ ...chains_default.pharos,
1599
+ services: [Service.CCTP]
1578
1600
  }
1579
1601
  };
1580
1602
  ({
@@ -1699,16 +1721,42 @@ var frxusdChains = {
1699
1721
  chains: Object.values(frxusdChains).filter((chain) => chain.chainType === "evm")
1700
1722
  });
1701
1723
 
1724
+ // src/wallets/config/eure.ts
1725
+ var eure = {
1726
+ symbol: "EURe",
1727
+ decimals: 18,
1728
+ icon: "/eure.png",
1729
+ name: "Monerium EURe"
1730
+ };
1731
+ var eureChains = {
1732
+ gnosis: {
1733
+ ...eure,
1734
+ assetId: "nep141:gnosis-0x420ca0f9b9b604ce0fd9c18ef134c705e5fa3430.omft.near",
1735
+ contractAddress: "0x420ca0f9b9b604ce0fd9c18ef134c705e5fa3430",
1736
+ ...chains_default.gnosis,
1737
+ services: [Service.OneClick]
1738
+ }
1739
+ };
1740
+ var eureEvm = {
1741
+ ...eure,
1742
+ chains: Object.values(eureChains).filter((chain) => chain.chainType === "evm")
1743
+ };
1744
+
1702
1745
  // src/wallets/config/tokens.ts
1703
1746
  var tokens = [
1704
1747
  ...Object.values(usdtChains),
1705
1748
  ...Object.values(usdcChains),
1706
1749
  ...Object.values(usdt0Chains),
1707
- ...Object.values(frxusdChains)
1750
+ ...Object.values(frxusdChains),
1751
+ ...Object.values(eureChains)
1708
1752
  ];
1709
1753
  var usdtTokens = [...Object.values(usdtChains), ...Object.values(usdt0Chains)];
1710
1754
  var usdcTokens = Object.values(usdcChains);
1711
1755
  var frxusdTokens = Object.values(frxusdChains);
1756
+ var eureTokens = Object.values(eureChains);
1757
+ var isStableToken = (token) => {
1758
+ return !["EURe"].includes(token.symbol);
1759
+ };
1712
1760
 
1713
1761
  // src/wallets/config/addresses.ts
1714
1762
  var DefaultAddresses = {
@@ -1800,26 +1848,65 @@ var erc20_default = [
1800
1848
 
1801
1849
  // src/utils/price.ts
1802
1850
  function getPrice(prices, symbol) {
1803
- let price = "1";
1804
- if (prices[symbol]) {
1805
- price = prices[symbol];
1806
- if (price !== "0") {
1807
- return price;
1808
- }
1851
+ let _symbol = symbol;
1852
+ if (symbol === "USDT0" || symbol === "USD\u20AE0" || symbol === "USD\u20AE") {
1853
+ _symbol = "USDT";
1809
1854
  }
1810
- if (prices[symbol.toLowerCase()]) {
1811
- price = prices[symbol.toLowerCase()];
1812
- if (price !== "0") {
1813
- return price;
1814
- }
1855
+ if (prices?.[_symbol] && prices[_symbol] !== "0") {
1856
+ return prices[_symbol];
1815
1857
  }
1816
- if (prices[symbol.toUpperCase()]) {
1817
- price = prices[symbol.toUpperCase()];
1818
- if (price !== "0") {
1819
- return price;
1820
- }
1858
+ if (prices?.[_symbol.toLowerCase()] && prices[_symbol.toLowerCase()] !== "0") {
1859
+ return prices[_symbol.toLowerCase()];
1821
1860
  }
1822
- return "1";
1861
+ if (prices?.[_symbol.toUpperCase()] && prices[_symbol.toUpperCase()] !== "0") {
1862
+ return prices[_symbol.toUpperCase()];
1863
+ }
1864
+ throw new Error(`Missing price for token: ${symbol}`);
1865
+ }
1866
+
1867
+ // src/config/price-api.ts
1868
+ var PriceApiConfig = {
1869
+ /** Full URL of the price endpoint (no query params, GET). Not user-configurable. */
1870
+ URL: "https://api.dapdap.net/get-token-price-by-dapdap",
1871
+ /** In-memory cache TTL in milliseconds. */
1872
+ CACHE_TTL: 6e4
1873
+ };
1874
+
1875
+ // src/services/PriceService.ts
1876
+ var priceCache = null;
1877
+ var priceCacheAt = 0;
1878
+ var inflight = null;
1879
+ function setPriceCacheTtl(ms) {
1880
+ PriceApiConfig.CACHE_TTL = ms;
1881
+ }
1882
+ async function fetchPrices() {
1883
+ let res;
1884
+ try {
1885
+ res = await axios.get(PriceApiConfig.URL, { timeout: 3e4 });
1886
+ } catch (error) {
1887
+ throw new Error(`Failed to fetch token prices: ${error?.message || error}`);
1888
+ }
1889
+ if (res.status !== 200 || res.data?.code !== 0 || !res.data?.data) {
1890
+ throw new Error(`Failed to fetch token prices: unexpected response (code=${res.data?.code})`);
1891
+ }
1892
+ return res.data.data;
1893
+ }
1894
+ async function getPrices(opts) {
1895
+ const now = Date.now();
1896
+ const isFresh = priceCache && now - priceCacheAt < PriceApiConfig.CACHE_TTL;
1897
+ if (!opts?.force && isFresh) {
1898
+ return priceCache;
1899
+ }
1900
+ if (!inflight) {
1901
+ inflight = fetchPrices().then((prices) => {
1902
+ priceCache = prices;
1903
+ priceCacheAt = Date.now();
1904
+ return prices;
1905
+ }).finally(() => {
1906
+ inflight = null;
1907
+ });
1908
+ }
1909
+ return inflight;
1823
1910
  }
1824
1911
 
1825
1912
  // src/utils/number.ts
@@ -1878,6 +1965,8 @@ var getRouteStatus = (service, disabledServices) => {
1878
1965
  const IS_PAUSE_ONECLICK_USDT0 = disabledServices.includes(Service.OneClickUsdt0);
1879
1966
  const IS_PAUSE_FRAXZERO_ONECLICK = disabledServices.includes(Service.FraxZeroOneClick);
1880
1967
  const IS_PAUSE_ONECLICK_FRAXZERO = disabledServices.includes(Service.OneClickFraxZero);
1968
+ const IS_PAUSE_CCTP_ONECLICK = disabledServices.includes(Service.CCTPOneClick);
1969
+ const IS_PAUSE_ONECLICK_CCTP = disabledServices.includes(Service.OneClickCCTP);
1881
1970
  const IS_PAUSE_ALL = IS_PAUSE_ONECLICK && IS_PAUSE_USDT0 && IS_PAUSE_CCTP && IS_PAUSE_FRAXZERO && IS_PAUSE_NATIVE;
1882
1971
  if (IS_PAUSE_ALL) {
1883
1972
  result.disabled = true;
@@ -1889,6 +1978,12 @@ var getRouteStatus = (service, disabledServices) => {
1889
1978
  return result;
1890
1979
  }
1891
1980
  }
1981
+ if ([Service.CCTPOneClick, Service.OneClickCCTP].includes(service)) {
1982
+ if (IS_PAUSE_ONECLICK || IS_PAUSE_CCTP) {
1983
+ result.disabled = true;
1984
+ return result;
1985
+ }
1986
+ }
1892
1987
  if (service === Service.FraxZero) {
1893
1988
  if (IS_PAUSE_FRAXZERO) {
1894
1989
  result.disabled = true;
@@ -1949,9 +2044,21 @@ var getRouteStatus = (service, disabledServices) => {
1949
2044
  return result;
1950
2045
  }
1951
2046
  }
2047
+ if (service === Service.CCTPOneClick) {
2048
+ if (IS_PAUSE_CCTP_ONECLICK) {
2049
+ result.disabled = true;
2050
+ return result;
2051
+ }
2052
+ }
2053
+ if (service === Service.OneClickCCTP) {
2054
+ if (IS_PAUSE_ONECLICK_CCTP) {
2055
+ result.disabled = true;
2056
+ return result;
2057
+ }
2058
+ }
1952
2059
  return result;
1953
2060
  };
1954
2061
 
1955
- export { ApiError, CancelError, CancelablePromise, Csl, DefaultAddresses, ExecTime, LayerZeroStatus, NetworkRpcUrlsMap, OneClickStatus, OpenAPI, QuoteRequest, SFA, SendType, Service, ServiceBackend, StableflowStatus, TokenResponse, TransactionStatus, erc20_default as erc20Abi, frxusdChains, frxusdTokens, getChainRpcUrl, getPrice, getRequest, getRouteStatus, getRpcUrls, numberRemoveEndZero, postRequest, request, setRpcUrls, tokens, usdcChains, usdcTokens, usdt0Chains, usdtChains, usdtTokens };
2062
+ export { ApiError, CancelError, CancelablePromise, Csl, DefaultAddresses, ExecTime, LayerZeroStatus, NetworkRpcUrlsMap, OneClickStatus, OneClickSwapType, OpenAPI, PriceApiConfig, QuoteRequest, SFA, SendType, Service, ServiceBackend, StableflowStatus, TransactionStatus, erc20_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 };
1956
2063
  //# sourceMappingURL=index.mjs.map
1957
2064
  //# sourceMappingURL=index.mjs.map