@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
@@ -1,4 +1,4 @@
1
- import { useState, useRef, useCallback, useEffect } from 'react';
1
+ import { useState, useRef, useCallback, useEffect, useMemo } from 'react';
2
2
 
3
3
  function getConfig() {
4
4
  {
@@ -1044,6 +1044,43 @@ var OneEngineClient = class {
1044
1044
  async adminClearRateLimits(identifier) {
1045
1045
  return this.request(`/api/v1/admin/rate-limits/${identifier}`, { method: "DELETE" });
1046
1046
  }
1047
+ // ========== AI Agent Configuration ==========
1048
+ /**
1049
+ * Get all AI agent configurations
1050
+ * This returns the full agent setup including tiers, cycles, and trading parameters
1051
+ */
1052
+ async getAgentConfigs(options) {
1053
+ const params = new URLSearchParams();
1054
+ if (options?.includeInactive) params.set("includeInactive", "true");
1055
+ if (options?.agentId) params.set("agentId", options.agentId);
1056
+ const query = params.toString();
1057
+ return this.request(`/api/v1/agents${query ? `?${query}` : ""}`, { method: "GET" });
1058
+ }
1059
+ /**
1060
+ * Calculate subscription parameters for an agent
1061
+ */
1062
+ async calculateAgentParams(params) {
1063
+ return this.request("/api/v1/agents/calculate", {
1064
+ method: "POST",
1065
+ body: JSON.stringify(params)
1066
+ });
1067
+ }
1068
+ /**
1069
+ * Get supported trading pairs from agents
1070
+ */
1071
+ async getTradingPairs() {
1072
+ const result = await this.getAgentConfigs();
1073
+ if (result.success && result.data?.agents) {
1074
+ const allPairs = /* @__PURE__ */ new Set();
1075
+ const byAgent = {};
1076
+ for (const agent of result.data.agents) {
1077
+ byAgent[agent.id] = agent.supported_pairs;
1078
+ agent.supported_pairs.forEach((p) => allPairs.add(p));
1079
+ }
1080
+ return { success: true, data: { pairs: Array.from(allPairs), byAgent } };
1081
+ }
1082
+ return { success: false, error: result.error };
1083
+ }
1047
1084
  // ========== AI Quant Trading ==========
1048
1085
  /**
1049
1086
  * Get all AI trading strategies
@@ -1182,6 +1219,67 @@ var OneEngineClient = class {
1182
1219
  async getCryptoMarketOverview() {
1183
1220
  return this.request("/api/v1/prices?type=overview", { method: "GET" });
1184
1221
  }
1222
+ // ========== Project Management ==========
1223
+ /**
1224
+ * Get user's projects
1225
+ */
1226
+ async getProjects(options) {
1227
+ const params = new URLSearchParams();
1228
+ if (options?.isActive !== void 0) params.set("isActive", String(options.isActive));
1229
+ const query = params.toString();
1230
+ return this.request(`/api/v1/projects${query ? `?${query}` : ""}`, { method: "GET" });
1231
+ }
1232
+ /**
1233
+ * Create a new project for ecosystem partners
1234
+ */
1235
+ async createProject(params) {
1236
+ return this.request("/api/v1/projects", {
1237
+ method: "POST",
1238
+ body: JSON.stringify(params)
1239
+ });
1240
+ }
1241
+ /**
1242
+ * Get project details
1243
+ */
1244
+ async getProject(projectId) {
1245
+ return this.request(`/api/v1/projects/${projectId}`, { method: "GET" });
1246
+ }
1247
+ /**
1248
+ * Update project settings
1249
+ */
1250
+ async updateProject(projectId, updates) {
1251
+ return this.request(`/api/v1/projects/${projectId}`, {
1252
+ method: "PATCH",
1253
+ body: JSON.stringify(updates)
1254
+ });
1255
+ }
1256
+ /**
1257
+ * Get project features status
1258
+ */
1259
+ async getProjectFeatures(projectId) {
1260
+ return this.request(`/api/v1/projects/${projectId}/features`, { method: "GET" });
1261
+ }
1262
+ /**
1263
+ * Enable/disable features for a project
1264
+ */
1265
+ async updateProjectFeatures(projectId, features) {
1266
+ return this.request(`/api/v1/projects/${projectId}/features`, {
1267
+ method: "PATCH",
1268
+ body: JSON.stringify(features)
1269
+ });
1270
+ }
1271
+ /**
1272
+ * Regenerate project API key
1273
+ */
1274
+ async regenerateProjectApiKey(projectId) {
1275
+ return this.request(`/api/v1/projects/${projectId}/api-key`, { method: "POST" });
1276
+ }
1277
+ /**
1278
+ * Delete project
1279
+ */
1280
+ async deleteProject(projectId) {
1281
+ return this.request(`/api/v1/projects/${projectId}`, { method: "DELETE" });
1282
+ }
1185
1283
  };
1186
1284
  function createOneEngineClient(options) {
1187
1285
  return new OneEngineClient(options);
@@ -1350,7 +1448,252 @@ function useTokenPrices(symbols, options = {}) {
1350
1448
  refetch: fetchPrices
1351
1449
  };
1352
1450
  }
1451
+ var clientInstance = null;
1452
+ function getClient() {
1453
+ if (!clientInstance) {
1454
+ clientInstance = createOneEngineClient();
1455
+ }
1456
+ return clientInstance;
1457
+ }
1458
+ function setAITradingAccessToken(token) {
1459
+ getClient().setAccessToken(token);
1460
+ }
1461
+ function clearAITradingAccessToken() {
1462
+ getClient().clearAccessToken();
1463
+ }
1464
+ function useAIStrategies(options = {}) {
1465
+ const [strategies, setStrategies] = useState([]);
1466
+ const [isLoading, setIsLoading] = useState(true);
1467
+ const [error, setError] = useState(null);
1468
+ const { category, riskLevel, minTvl, isActive, autoRefresh = false, refreshInterval = 6e4 } = options;
1469
+ const fetchStrategies = useCallback(async () => {
1470
+ setIsLoading(true);
1471
+ setError(null);
1472
+ try {
1473
+ const result = await getClient().getAIStrategies({ category, riskLevel, minTvl, isActive });
1474
+ if (result.success && result.data?.strategies) {
1475
+ setStrategies(result.data.strategies);
1476
+ } else {
1477
+ setError(result.error?.message || "Failed to fetch strategies");
1478
+ }
1479
+ } catch (err) {
1480
+ setError(err instanceof Error ? err.message : "Unknown error");
1481
+ } finally {
1482
+ setIsLoading(false);
1483
+ }
1484
+ }, [category, riskLevel, minTvl, isActive]);
1485
+ useEffect(() => {
1486
+ fetchStrategies();
1487
+ }, [fetchStrategies]);
1488
+ useEffect(() => {
1489
+ if (autoRefresh && refreshInterval > 0) {
1490
+ const interval = setInterval(fetchStrategies, refreshInterval);
1491
+ return () => clearInterval(interval);
1492
+ }
1493
+ }, [autoRefresh, refreshInterval, fetchStrategies]);
1494
+ return { strategies, isLoading, error, refresh: fetchStrategies };
1495
+ }
1496
+ function useAIStrategy(strategyId, include = ["performance", "market"]) {
1497
+ const [strategy, setStrategy] = useState(null);
1498
+ const [performance, setPerformance] = useState([]);
1499
+ const [marketData, setMarketData] = useState([]);
1500
+ const [isLoading, setIsLoading] = useState(true);
1501
+ const [error, setError] = useState(null);
1502
+ const fetchStrategy = useCallback(async () => {
1503
+ if (!strategyId) {
1504
+ setIsLoading(false);
1505
+ return;
1506
+ }
1507
+ setIsLoading(true);
1508
+ setError(null);
1509
+ try {
1510
+ const result = await getClient().getAIStrategy(strategyId, include);
1511
+ if (result.success && result.data) {
1512
+ setStrategy(result.data.strategy);
1513
+ setPerformance(result.data.performance || []);
1514
+ setMarketData(result.data.marketData || []);
1515
+ } else {
1516
+ setError(result.error?.message || "Failed to fetch strategy");
1517
+ }
1518
+ } catch (err) {
1519
+ setError(err instanceof Error ? err.message : "Unknown error");
1520
+ } finally {
1521
+ setIsLoading(false);
1522
+ }
1523
+ }, [strategyId, include.join(",")]);
1524
+ useEffect(() => {
1525
+ fetchStrategy();
1526
+ }, [fetchStrategy]);
1527
+ return { strategy, performance, marketData, isLoading, error, refresh: fetchStrategy };
1528
+ }
1529
+ function useAIOrders(options = {}) {
1530
+ const [orders, setOrders] = useState([]);
1531
+ const [isLoading, setIsLoading] = useState(true);
1532
+ const [error, setError] = useState(null);
1533
+ const { strategyId, status, autoRefresh = true, refreshInterval = 3e4 } = options;
1534
+ const fetchOrders = useCallback(async () => {
1535
+ setIsLoading(true);
1536
+ setError(null);
1537
+ try {
1538
+ const result = await getClient().getAIOrders({ strategyId, status });
1539
+ if (result.success && result.data?.orders) {
1540
+ setOrders(result.data.orders);
1541
+ } else {
1542
+ setError(result.error?.message || "Failed to fetch orders");
1543
+ }
1544
+ } catch (err) {
1545
+ setError(err instanceof Error ? err.message : "Unknown error");
1546
+ } finally {
1547
+ setIsLoading(false);
1548
+ }
1549
+ }, [strategyId, status]);
1550
+ useEffect(() => {
1551
+ fetchOrders();
1552
+ }, [fetchOrders]);
1553
+ useEffect(() => {
1554
+ if (autoRefresh && refreshInterval > 0) {
1555
+ const interval = setInterval(fetchOrders, refreshInterval);
1556
+ return () => clearInterval(interval);
1557
+ }
1558
+ }, [autoRefresh, refreshInterval, fetchOrders]);
1559
+ const createOrder = useCallback(async (request) => {
1560
+ const result = await getClient().createAIOrder(request);
1561
+ if (result.success) {
1562
+ await fetchOrders();
1563
+ }
1564
+ return result;
1565
+ }, [fetchOrders]);
1566
+ const pauseOrder = useCallback(async (orderId) => {
1567
+ const result = await getClient().pauseAIOrder(orderId);
1568
+ if (result.success) {
1569
+ await fetchOrders();
1570
+ }
1571
+ return result;
1572
+ }, [fetchOrders]);
1573
+ const resumeOrder = useCallback(async (orderId) => {
1574
+ const result = await getClient().resumeAIOrder(orderId);
1575
+ if (result.success) {
1576
+ await fetchOrders();
1577
+ }
1578
+ return result;
1579
+ }, [fetchOrders]);
1580
+ const redeemOrder = useCallback(async (orderId) => {
1581
+ const result = await getClient().redeemAIOrder(orderId);
1582
+ if (result.success) {
1583
+ await fetchOrders();
1584
+ }
1585
+ return result;
1586
+ }, [fetchOrders]);
1587
+ return {
1588
+ orders,
1589
+ isLoading,
1590
+ error,
1591
+ refresh: fetchOrders,
1592
+ createOrder,
1593
+ pauseOrder,
1594
+ resumeOrder,
1595
+ redeemOrder
1596
+ };
1597
+ }
1598
+ function useAIPortfolio(autoRefresh = true) {
1599
+ const [portfolio, setPortfolio] = useState(null);
1600
+ const [allocations, setAllocations] = useState([]);
1601
+ const [activeOrders, setActiveOrders] = useState([]);
1602
+ const [isLoading, setIsLoading] = useState(true);
1603
+ const [error, setError] = useState(null);
1604
+ const fetchPortfolio = useCallback(async () => {
1605
+ setIsLoading(true);
1606
+ setError(null);
1607
+ try {
1608
+ const result = await getClient().getAIPortfolio(["allocations", "orders"]);
1609
+ if (result.success && result.data) {
1610
+ setPortfolio(result.data.portfolio);
1611
+ setAllocations(result.data.allocations || []);
1612
+ setActiveOrders(result.data.orders || []);
1613
+ } else {
1614
+ setError(result.error?.message || "Failed to fetch portfolio");
1615
+ }
1616
+ } catch (err) {
1617
+ setError(err instanceof Error ? err.message : "Unknown error");
1618
+ } finally {
1619
+ setIsLoading(false);
1620
+ }
1621
+ }, []);
1622
+ useEffect(() => {
1623
+ fetchPortfolio();
1624
+ }, [fetchPortfolio]);
1625
+ useEffect(() => {
1626
+ if (autoRefresh) {
1627
+ const interval = setInterval(fetchPortfolio, 3e4);
1628
+ return () => clearInterval(interval);
1629
+ }
1630
+ }, [autoRefresh, fetchPortfolio]);
1631
+ return { portfolio, allocations, activeOrders, isLoading, error, refresh: fetchPortfolio };
1632
+ }
1633
+ function useAIMarketData(symbols = ["BTC", "ETH", "BNB", "SOL", "XRP", "DOGE", "ADA", "AVAX"], autoRefresh = true) {
1634
+ const [prices, setPrices] = useState({});
1635
+ const [isLoading, setIsLoading] = useState(true);
1636
+ const [error, setError] = useState(null);
1637
+ const fetchPrices = useCallback(async () => {
1638
+ setIsLoading(true);
1639
+ setError(null);
1640
+ try {
1641
+ const result = await getClient().getTokenPrices(symbols);
1642
+ if (result.success && result.data) {
1643
+ setPrices(result.data);
1644
+ } else {
1645
+ setError(result.error?.message || "Failed to fetch prices");
1646
+ }
1647
+ } catch (err) {
1648
+ setError(err instanceof Error ? err.message : "Unknown error");
1649
+ } finally {
1650
+ setIsLoading(false);
1651
+ }
1652
+ }, [symbols.join(",")]);
1653
+ useEffect(() => {
1654
+ fetchPrices();
1655
+ }, [fetchPrices]);
1656
+ useEffect(() => {
1657
+ if (autoRefresh) {
1658
+ const interval = setInterval(fetchPrices, 15e3);
1659
+ return () => clearInterval(interval);
1660
+ }
1661
+ }, [autoRefresh, fetchPrices]);
1662
+ return { prices, isLoading, error, refresh: fetchPrices };
1663
+ }
1664
+ function useAITrading() {
1665
+ const strategiesResult = useAIStrategies({ autoRefresh: true });
1666
+ const ordersResult = useAIOrders({ autoRefresh: true });
1667
+ const portfolioResult = useAIPortfolio(true);
1668
+ const marketResult = useAIMarketData();
1669
+ const refreshAll = useCallback(async () => {
1670
+ await Promise.all([
1671
+ strategiesResult.refresh(),
1672
+ ordersResult.refresh(),
1673
+ portfolioResult.refresh(),
1674
+ marketResult.refresh()
1675
+ ]);
1676
+ }, [strategiesResult.refresh, ordersResult.refresh, portfolioResult.refresh, marketResult.refresh]);
1677
+ const error = useMemo(() => {
1678
+ return strategiesResult.error || ordersResult.error || portfolioResult.error || marketResult.error;
1679
+ }, [strategiesResult.error, ordersResult.error, portfolioResult.error, marketResult.error]);
1680
+ return {
1681
+ strategies: strategiesResult.strategies,
1682
+ strategiesLoading: strategiesResult.isLoading,
1683
+ orders: ordersResult.orders,
1684
+ ordersLoading: ordersResult.isLoading,
1685
+ portfolio: portfolioResult.portfolio,
1686
+ portfolioLoading: portfolioResult.isLoading,
1687
+ prices: marketResult.prices,
1688
+ createOrder: ordersResult.createOrder,
1689
+ pauseOrder: ordersResult.pauseOrder,
1690
+ resumeOrder: ordersResult.resumeOrder,
1691
+ redeemOrder: ordersResult.redeemOrder,
1692
+ refreshAll,
1693
+ error
1694
+ };
1695
+ }
1353
1696
 
1354
- export { useTokenPrice, useTokenPrices, useWalletBalance };
1697
+ export { clearAITradingAccessToken, setAITradingAccessToken, useAIMarketData, useAIOrders, useAIPortfolio, useAIStrategies, useAIStrategy, useAITrading, useTokenPrice, useTokenPrices, useWalletBalance };
1355
1698
  //# sourceMappingURL=index.mjs.map
1356
1699
  //# sourceMappingURL=index.mjs.map