@one_deploy/sdk 1.0.3 → 1.0.5

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.
Files changed (53) hide show
  1. package/dist/{engine-CrlhH0nw.d.mts → engine-BeVuHpVx.d.mts} +163 -0
  2. package/dist/{engine-5ndtBaCr.d.ts → engine-DSc1Em4V.d.ts} +163 -0
  3. package/dist/hooks/index.d.mts +132 -3
  4. package/dist/hooks/index.d.ts +132 -3
  5. package/dist/hooks/index.js +351 -0
  6. package/dist/hooks/index.js.map +1 -1
  7. package/dist/hooks/index.mjs +345 -2
  8. package/dist/hooks/index.mjs.map +1 -1
  9. package/dist/index.d.mts +3 -3
  10. package/dist/index.d.ts +3 -3
  11. package/dist/index.js +352 -1
  12. package/dist/index.js.map +1 -1
  13. package/dist/index.mjs +345 -2
  14. package/dist/index.mjs.map +1 -1
  15. package/dist/providers/index.d.mts +1 -1
  16. package/dist/providers/index.d.ts +1 -1
  17. package/dist/providers/index.js +98 -0
  18. package/dist/providers/index.js.map +1 -1
  19. package/dist/providers/index.mjs +98 -0
  20. package/dist/providers/index.mjs.map +1 -1
  21. package/dist/react-native.d.mts +140 -3
  22. package/dist/react-native.d.ts +140 -3
  23. package/dist/react-native.js +642 -0
  24. package/dist/react-native.js.map +1 -1
  25. package/dist/react-native.mjs +636 -1
  26. package/dist/react-native.mjs.map +1 -1
  27. package/dist/services/index.d.mts +99 -79
  28. package/dist/services/index.d.ts +99 -79
  29. package/dist/services/index.js +254 -0
  30. package/dist/services/index.js.map +1 -1
  31. package/dist/services/index.mjs +252 -1
  32. package/dist/services/index.mjs.map +1 -1
  33. package/dist/supabase-BT0c7q9e.d.mts +82 -0
  34. package/dist/supabase-BT0c7q9e.d.ts +82 -0
  35. package/package.json +5 -1
  36. package/src/components/OneSwapWidget.tsx +1 -1
  37. package/src/components/ai/OneChainSelector.tsx +183 -0
  38. package/src/components/ai/OneCycleSelector.tsx +187 -0
  39. package/src/components/ai/OnePairSelector.tsx +181 -0
  40. package/src/components/ai/OneTierSelector.tsx +187 -0
  41. package/src/components/ai/index.ts +17 -0
  42. package/src/components/index.ts +3 -0
  43. package/src/hooks/index.ts +20 -0
  44. package/src/hooks/useAITrading.ts +444 -0
  45. package/src/index.ts +20 -0
  46. package/src/react-native.ts +23 -0
  47. package/src/services/engine.ts +184 -0
  48. package/src/services/index.ts +16 -0
  49. package/src/services/usage.ts +249 -0
  50. package/.turbo/turbo-build.log +0 -0
  51. package/.turbo/turbo-type-check.log +0 -0
  52. package/tsconfig.json +0 -22
  53. package/tsup.config.ts +0 -25
package/dist/index.mjs CHANGED
@@ -1269,6 +1269,43 @@ var OneEngineClient = class {
1269
1269
  async adminClearRateLimits(identifier) {
1270
1270
  return this.request(`/api/v1/admin/rate-limits/${identifier}`, { method: "DELETE" });
1271
1271
  }
1272
+ // ========== AI Agent Configuration ==========
1273
+ /**
1274
+ * Get all AI agent configurations
1275
+ * This returns the full agent setup including tiers, cycles, and trading parameters
1276
+ */
1277
+ async getAgentConfigs(options) {
1278
+ const params = new URLSearchParams();
1279
+ if (options?.includeInactive) params.set("includeInactive", "true");
1280
+ if (options?.agentId) params.set("agentId", options.agentId);
1281
+ const query = params.toString();
1282
+ return this.request(`/api/v1/agents${query ? `?${query}` : ""}`, { method: "GET" });
1283
+ }
1284
+ /**
1285
+ * Calculate subscription parameters for an agent
1286
+ */
1287
+ async calculateAgentParams(params) {
1288
+ return this.request("/api/v1/agents/calculate", {
1289
+ method: "POST",
1290
+ body: JSON.stringify(params)
1291
+ });
1292
+ }
1293
+ /**
1294
+ * Get supported trading pairs from agents
1295
+ */
1296
+ async getTradingPairs() {
1297
+ const result = await this.getAgentConfigs();
1298
+ if (result.success && result.data?.agents) {
1299
+ const allPairs = /* @__PURE__ */ new Set();
1300
+ const byAgent = {};
1301
+ for (const agent of result.data.agents) {
1302
+ byAgent[agent.id] = agent.supported_pairs;
1303
+ agent.supported_pairs.forEach((p) => allPairs.add(p));
1304
+ }
1305
+ return { success: true, data: { pairs: Array.from(allPairs), byAgent } };
1306
+ }
1307
+ return { success: false, error: result.error };
1308
+ }
1272
1309
  // ========== AI Quant Trading ==========
1273
1310
  /**
1274
1311
  * Get all AI trading strategies
@@ -1407,6 +1444,67 @@ var OneEngineClient = class {
1407
1444
  async getCryptoMarketOverview() {
1408
1445
  return this.request("/api/v1/prices?type=overview", { method: "GET" });
1409
1446
  }
1447
+ // ========== Project Management ==========
1448
+ /**
1449
+ * Get user's projects
1450
+ */
1451
+ async getProjects(options) {
1452
+ const params = new URLSearchParams();
1453
+ if (options?.isActive !== void 0) params.set("isActive", String(options.isActive));
1454
+ const query = params.toString();
1455
+ return this.request(`/api/v1/projects${query ? `?${query}` : ""}`, { method: "GET" });
1456
+ }
1457
+ /**
1458
+ * Create a new project for ecosystem partners
1459
+ */
1460
+ async createProject(params) {
1461
+ return this.request("/api/v1/projects", {
1462
+ method: "POST",
1463
+ body: JSON.stringify(params)
1464
+ });
1465
+ }
1466
+ /**
1467
+ * Get project details
1468
+ */
1469
+ async getProject(projectId) {
1470
+ return this.request(`/api/v1/projects/${projectId}`, { method: "GET" });
1471
+ }
1472
+ /**
1473
+ * Update project settings
1474
+ */
1475
+ async updateProject(projectId, updates) {
1476
+ return this.request(`/api/v1/projects/${projectId}`, {
1477
+ method: "PATCH",
1478
+ body: JSON.stringify(updates)
1479
+ });
1480
+ }
1481
+ /**
1482
+ * Get project features status
1483
+ */
1484
+ async getProjectFeatures(projectId) {
1485
+ return this.request(`/api/v1/projects/${projectId}/features`, { method: "GET" });
1486
+ }
1487
+ /**
1488
+ * Enable/disable features for a project
1489
+ */
1490
+ async updateProjectFeatures(projectId, features) {
1491
+ return this.request(`/api/v1/projects/${projectId}/features`, {
1492
+ method: "PATCH",
1493
+ body: JSON.stringify(features)
1494
+ });
1495
+ }
1496
+ /**
1497
+ * Regenerate project API key
1498
+ */
1499
+ async regenerateProjectApiKey(projectId) {
1500
+ return this.request(`/api/v1/projects/${projectId}/api-key`, { method: "POST" });
1501
+ }
1502
+ /**
1503
+ * Delete project
1504
+ */
1505
+ async deleteProject(projectId) {
1506
+ return this.request(`/api/v1/projects/${projectId}`, { method: "DELETE" });
1507
+ }
1410
1508
  };
1411
1509
  function createOneEngineClient(options) {
1412
1510
  return new OneEngineClient(options);
@@ -3459,7 +3557,7 @@ var TOKENS_BY_CHAIN = {
3459
3557
  { address: "0x0000000000000000000000000000000000000000", symbol: "ETH", name: "Ethereum", decimals: 18, chainId: 1 },
3460
3558
  { address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", symbol: "USDC", name: "USD Coin", decimals: 6, chainId: 1 },
3461
3559
  { address: "0xdAC17F958D2ee523a2206206994597C13D831ec7", symbol: "USDT", name: "Tether", decimals: 6, chainId: 1 },
3462
- { address: "0x6B175474E89094C44Da98b954EescdeCB5", symbol: "DAI", name: "Dai", decimals: 18, chainId: 1 },
3560
+ { address: "0x6B175474E89094C44Da98b954EedeAC495271d0F", symbol: "DAI", name: "Dai", decimals: 18, chainId: 1 },
3463
3561
  { address: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", symbol: "WETH", name: "Wrapped Ether", decimals: 18, chainId: 1 }
3464
3562
  ],
3465
3563
  // Base
@@ -4805,6 +4903,251 @@ function useTokenPrices(symbols, options = {}) {
4805
4903
  refetch: fetchPrices
4806
4904
  };
4807
4905
  }
4906
+ var clientInstance = null;
4907
+ function getClient() {
4908
+ if (!clientInstance) {
4909
+ clientInstance = createOneEngineClient();
4910
+ }
4911
+ return clientInstance;
4912
+ }
4913
+ function setAITradingAccessToken(token) {
4914
+ getClient().setAccessToken(token);
4915
+ }
4916
+ function clearAITradingAccessToken() {
4917
+ getClient().clearAccessToken();
4918
+ }
4919
+ function useAIStrategies(options = {}) {
4920
+ const [strategies, setStrategies] = useState([]);
4921
+ const [isLoading, setIsLoading] = useState(true);
4922
+ const [error, setError] = useState(null);
4923
+ const { category, riskLevel, minTvl, isActive, autoRefresh = false, refreshInterval = 6e4 } = options;
4924
+ const fetchStrategies = useCallback(async () => {
4925
+ setIsLoading(true);
4926
+ setError(null);
4927
+ try {
4928
+ const result = await getClient().getAIStrategies({ category, riskLevel, minTvl, isActive });
4929
+ if (result.success && result.data?.strategies) {
4930
+ setStrategies(result.data.strategies);
4931
+ } else {
4932
+ setError(result.error?.message || "Failed to fetch strategies");
4933
+ }
4934
+ } catch (err) {
4935
+ setError(err instanceof Error ? err.message : "Unknown error");
4936
+ } finally {
4937
+ setIsLoading(false);
4938
+ }
4939
+ }, [category, riskLevel, minTvl, isActive]);
4940
+ useEffect(() => {
4941
+ fetchStrategies();
4942
+ }, [fetchStrategies]);
4943
+ useEffect(() => {
4944
+ if (autoRefresh && refreshInterval > 0) {
4945
+ const interval = setInterval(fetchStrategies, refreshInterval);
4946
+ return () => clearInterval(interval);
4947
+ }
4948
+ }, [autoRefresh, refreshInterval, fetchStrategies]);
4949
+ return { strategies, isLoading, error, refresh: fetchStrategies };
4950
+ }
4951
+ function useAIStrategy(strategyId, include = ["performance", "market"]) {
4952
+ const [strategy, setStrategy] = useState(null);
4953
+ const [performance, setPerformance] = useState([]);
4954
+ const [marketData, setMarketData] = useState([]);
4955
+ const [isLoading, setIsLoading] = useState(true);
4956
+ const [error, setError] = useState(null);
4957
+ const fetchStrategy = useCallback(async () => {
4958
+ if (!strategyId) {
4959
+ setIsLoading(false);
4960
+ return;
4961
+ }
4962
+ setIsLoading(true);
4963
+ setError(null);
4964
+ try {
4965
+ const result = await getClient().getAIStrategy(strategyId, include);
4966
+ if (result.success && result.data) {
4967
+ setStrategy(result.data.strategy);
4968
+ setPerformance(result.data.performance || []);
4969
+ setMarketData(result.data.marketData || []);
4970
+ } else {
4971
+ setError(result.error?.message || "Failed to fetch strategy");
4972
+ }
4973
+ } catch (err) {
4974
+ setError(err instanceof Error ? err.message : "Unknown error");
4975
+ } finally {
4976
+ setIsLoading(false);
4977
+ }
4978
+ }, [strategyId, include.join(",")]);
4979
+ useEffect(() => {
4980
+ fetchStrategy();
4981
+ }, [fetchStrategy]);
4982
+ return { strategy, performance, marketData, isLoading, error, refresh: fetchStrategy };
4983
+ }
4984
+ function useAIOrders(options = {}) {
4985
+ const [orders, setOrders] = useState([]);
4986
+ const [isLoading, setIsLoading] = useState(true);
4987
+ const [error, setError] = useState(null);
4988
+ const { strategyId, status, autoRefresh = true, refreshInterval = 3e4 } = options;
4989
+ const fetchOrders = useCallback(async () => {
4990
+ setIsLoading(true);
4991
+ setError(null);
4992
+ try {
4993
+ const result = await getClient().getAIOrders({ strategyId, status });
4994
+ if (result.success && result.data?.orders) {
4995
+ setOrders(result.data.orders);
4996
+ } else {
4997
+ setError(result.error?.message || "Failed to fetch orders");
4998
+ }
4999
+ } catch (err) {
5000
+ setError(err instanceof Error ? err.message : "Unknown error");
5001
+ } finally {
5002
+ setIsLoading(false);
5003
+ }
5004
+ }, [strategyId, status]);
5005
+ useEffect(() => {
5006
+ fetchOrders();
5007
+ }, [fetchOrders]);
5008
+ useEffect(() => {
5009
+ if (autoRefresh && refreshInterval > 0) {
5010
+ const interval = setInterval(fetchOrders, refreshInterval);
5011
+ return () => clearInterval(interval);
5012
+ }
5013
+ }, [autoRefresh, refreshInterval, fetchOrders]);
5014
+ const createOrder = useCallback(async (request) => {
5015
+ const result = await getClient().createAIOrder(request);
5016
+ if (result.success) {
5017
+ await fetchOrders();
5018
+ }
5019
+ return result;
5020
+ }, [fetchOrders]);
5021
+ const pauseOrder = useCallback(async (orderId) => {
5022
+ const result = await getClient().pauseAIOrder(orderId);
5023
+ if (result.success) {
5024
+ await fetchOrders();
5025
+ }
5026
+ return result;
5027
+ }, [fetchOrders]);
5028
+ const resumeOrder = useCallback(async (orderId) => {
5029
+ const result = await getClient().resumeAIOrder(orderId);
5030
+ if (result.success) {
5031
+ await fetchOrders();
5032
+ }
5033
+ return result;
5034
+ }, [fetchOrders]);
5035
+ const redeemOrder = useCallback(async (orderId) => {
5036
+ const result = await getClient().redeemAIOrder(orderId);
5037
+ if (result.success) {
5038
+ await fetchOrders();
5039
+ }
5040
+ return result;
5041
+ }, [fetchOrders]);
5042
+ return {
5043
+ orders,
5044
+ isLoading,
5045
+ error,
5046
+ refresh: fetchOrders,
5047
+ createOrder,
5048
+ pauseOrder,
5049
+ resumeOrder,
5050
+ redeemOrder
5051
+ };
5052
+ }
5053
+ function useAIPortfolio(autoRefresh = true) {
5054
+ const [portfolio, setPortfolio] = useState(null);
5055
+ const [allocations, setAllocations] = useState([]);
5056
+ const [activeOrders, setActiveOrders] = useState([]);
5057
+ const [isLoading, setIsLoading] = useState(true);
5058
+ const [error, setError] = useState(null);
5059
+ const fetchPortfolio = useCallback(async () => {
5060
+ setIsLoading(true);
5061
+ setError(null);
5062
+ try {
5063
+ const result = await getClient().getAIPortfolio(["allocations", "orders"]);
5064
+ if (result.success && result.data) {
5065
+ setPortfolio(result.data.portfolio);
5066
+ setAllocations(result.data.allocations || []);
5067
+ setActiveOrders(result.data.orders || []);
5068
+ } else {
5069
+ setError(result.error?.message || "Failed to fetch portfolio");
5070
+ }
5071
+ } catch (err) {
5072
+ setError(err instanceof Error ? err.message : "Unknown error");
5073
+ } finally {
5074
+ setIsLoading(false);
5075
+ }
5076
+ }, []);
5077
+ useEffect(() => {
5078
+ fetchPortfolio();
5079
+ }, [fetchPortfolio]);
5080
+ useEffect(() => {
5081
+ if (autoRefresh) {
5082
+ const interval = setInterval(fetchPortfolio, 3e4);
5083
+ return () => clearInterval(interval);
5084
+ }
5085
+ }, [autoRefresh, fetchPortfolio]);
5086
+ return { portfolio, allocations, activeOrders, isLoading, error, refresh: fetchPortfolio };
5087
+ }
5088
+ function useAIMarketData(symbols = ["BTC", "ETH", "BNB", "SOL", "XRP", "DOGE", "ADA", "AVAX"], autoRefresh = true) {
5089
+ const [prices, setPrices] = useState({});
5090
+ const [isLoading, setIsLoading] = useState(true);
5091
+ const [error, setError] = useState(null);
5092
+ const fetchPrices = useCallback(async () => {
5093
+ setIsLoading(true);
5094
+ setError(null);
5095
+ try {
5096
+ const result = await getClient().getTokenPrices(symbols);
5097
+ if (result.success && result.data) {
5098
+ setPrices(result.data);
5099
+ } else {
5100
+ setError(result.error?.message || "Failed to fetch prices");
5101
+ }
5102
+ } catch (err) {
5103
+ setError(err instanceof Error ? err.message : "Unknown error");
5104
+ } finally {
5105
+ setIsLoading(false);
5106
+ }
5107
+ }, [symbols.join(",")]);
5108
+ useEffect(() => {
5109
+ fetchPrices();
5110
+ }, [fetchPrices]);
5111
+ useEffect(() => {
5112
+ if (autoRefresh) {
5113
+ const interval = setInterval(fetchPrices, 15e3);
5114
+ return () => clearInterval(interval);
5115
+ }
5116
+ }, [autoRefresh, fetchPrices]);
5117
+ return { prices, isLoading, error, refresh: fetchPrices };
5118
+ }
5119
+ function useAITrading() {
5120
+ const strategiesResult = useAIStrategies({ autoRefresh: true });
5121
+ const ordersResult = useAIOrders({ autoRefresh: true });
5122
+ const portfolioResult = useAIPortfolio(true);
5123
+ const marketResult = useAIMarketData();
5124
+ const refreshAll = useCallback(async () => {
5125
+ await Promise.all([
5126
+ strategiesResult.refresh(),
5127
+ ordersResult.refresh(),
5128
+ portfolioResult.refresh(),
5129
+ marketResult.refresh()
5130
+ ]);
5131
+ }, [strategiesResult.refresh, ordersResult.refresh, portfolioResult.refresh, marketResult.refresh]);
5132
+ const error = useMemo(() => {
5133
+ return strategiesResult.error || ordersResult.error || portfolioResult.error || marketResult.error;
5134
+ }, [strategiesResult.error, ordersResult.error, portfolioResult.error, marketResult.error]);
5135
+ return {
5136
+ strategies: strategiesResult.strategies,
5137
+ strategiesLoading: strategiesResult.isLoading,
5138
+ orders: ordersResult.orders,
5139
+ ordersLoading: ordersResult.isLoading,
5140
+ portfolio: portfolioResult.portfolio,
5141
+ portfolioLoading: portfolioResult.isLoading,
5142
+ prices: marketResult.prices,
5143
+ createOrder: ordersResult.createOrder,
5144
+ pauseOrder: ordersResult.pauseOrder,
5145
+ resumeOrder: ordersResult.resumeOrder,
5146
+ redeemOrder: ordersResult.redeemOrder,
5147
+ refreshAll,
5148
+ error
5149
+ };
5150
+ }
4808
5151
 
4809
5152
  // src/utils/index.ts
4810
5153
  function shortenAddress(address, chars = 4) {
@@ -4945,6 +5288,6 @@ function isOneSDKError(error) {
4945
5288
  return error instanceof OneSDKError;
4946
5289
  }
4947
5290
 
4948
- export { CHAIN_CONFIGS, CHAIN_IDS, COINGECKO_IDS, DEFAULT_CHAIN_ID, OneApproveButton, OneBalanceDisplay, OneBuyBTCWidget, OneBuyETHWidget, OneBuyUSDCWidget, OneBuyUSDTWidget, OneConnectButton, OneConnectButtonFull, OneConnectButtonSimple, OneContext, OneCrossChainSwap, OneCryptoOnlyPayWidget, OneDirectPayWidget, OneEngineClient, OneFiatOnlyPayWidget, OneFundWalletWidget, OneNFTGallery, OneOfframpWidget, OneOnrampWidget, OnePayWidget, OneProvider, OneReceiveWidget, OneSDKError, OneSameChainSwap, OneSellETHWidget, OneSellUSDCWidget, OneSellUSDTWidget, OneSendETHButton, OneSendETHWidget, OneSendUSDCWidget, OneSendWidget, OneSwapWidget, OneThirdwebProvider, OneTransactionButton, OneWalletBalance, PriceService, SUPPORTED_CHAINS, SupabaseService, TOKEN_NAMES, capitalize, checksumAddress, createOneEngineClient, createSupabaseClient, fetchChains, formatDate, formatDateTime, formatNumber, formatPercent, formatRelativeTime, formatTokenAmount, formatUSD2 as formatUSD, getChainById, getChainByName, getChainConfig, getChains, getConfig, getEngineUrl, getRecommendedChains, getSmartWalletChains, initOneSDK, isInitialized, isOneSDKError, isValidAddress, isValidEmail, isValidPhone, omit, pick, priceService, retry, shortenAddress, sleep, slugify, truncate, useOne, useOneAuth, useOneEngine, useOneOnramp, useOneSwap, useOneTrading, useOneWallet, useThirdwebClient, useTokenPrice, useTokenPrices, useWalletBalance2 as useWalletBalance };
5291
+ export { CHAIN_CONFIGS, CHAIN_IDS, COINGECKO_IDS, DEFAULT_CHAIN_ID, OneApproveButton, OneBalanceDisplay, OneBuyBTCWidget, OneBuyETHWidget, OneBuyUSDCWidget, OneBuyUSDTWidget, OneConnectButton, OneConnectButtonFull, OneConnectButtonSimple, OneContext, OneCrossChainSwap, OneCryptoOnlyPayWidget, OneDirectPayWidget, OneEngineClient, OneFiatOnlyPayWidget, OneFundWalletWidget, OneNFTGallery, OneOfframpWidget, OneOnrampWidget, OnePayWidget, OneProvider, OneReceiveWidget, OneSDKError, OneSameChainSwap, OneSellETHWidget, OneSellUSDCWidget, OneSellUSDTWidget, OneSendETHButton, OneSendETHWidget, OneSendUSDCWidget, OneSendWidget, OneSwapWidget, OneThirdwebProvider, OneTransactionButton, OneWalletBalance, PriceService, SUPPORTED_CHAINS, SupabaseService, TOKEN_NAMES, capitalize, checksumAddress, clearAITradingAccessToken, createOneEngineClient, createSupabaseClient, fetchChains, formatDate, formatDateTime, formatNumber, formatPercent, formatRelativeTime, formatTokenAmount, formatUSD2 as formatUSD, getChainById, getChainByName, getChainConfig, getChains, getConfig, getEngineUrl, getRecommendedChains, getSmartWalletChains, initOneSDK, isInitialized, isOneSDKError, isValidAddress, isValidEmail, isValidPhone, omit, pick, priceService, retry, setAITradingAccessToken, shortenAddress, sleep, slugify, truncate, useAIMarketData, useAIOrders, useAIPortfolio, useAIStrategies, useAIStrategy, useAITrading, useOne, useOneAuth, useOneEngine, useOneOnramp, useOneSwap, useOneTrading, useOneWallet, useThirdwebClient, useTokenPrice, useTokenPrices, useWalletBalance2 as useWalletBalance };
4949
5292
  //# sourceMappingURL=index.mjs.map
4950
5293
  //# sourceMappingURL=index.mjs.map