@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.d.mts CHANGED
@@ -1,7 +1,7 @@
1
1
  export { CHAIN_CONFIGS, CHAIN_IDS, COINGECKO_IDS, DEFAULT_CHAIN_ID, OneConfig, SUPPORTED_CHAINS, TOKEN_NAMES, fetchChains, getChainById, getChainByName, getChainConfig, getChains, getConfig, getEngineUrl, getRecommendedChains, getSmartWalletChains, initOneSDK, isInitialized } from './config/index.mjs';
2
2
  export { AIMarketData, AINavSnapshot, AIOrder, AIOrderStatus, AIPortfolioSummary, AIRedemptionResult, AIStrategy, AITradeAllocation, AITradeExecution, AdminListOptions, AdminProject, AdminUser, ApiResponse, AssetAllocation, BillCategory, BillPayment, BillProvider, BridgeQuote, BridgeRoute, BridgeTransaction, Card, CardStatus, CardTier, CardTransaction, ChainConfig, Contract, ContractDeployParams, ContractReadParams, ContractType, ContractWriteParams, CreateAIOrderRequest, CreateWebhookInput, GasEstimate, GasPrice, KycLevel, KycStatus, LimitOrder, MembershipTier, NFT, NFTAttribute, NFTCollection, NFTTransfer, Notification, NotificationSettings, OfframpRequest, OnChainBalance, PaginatedResult, Permission, PermissionScope, PortfolioAnalytics, PortfolioHistory, Position, RateLimitInfo, Referral, ReferralInfo, RiskLevel, SDKEvent, SDKEventType, Session, StakingPool, StakingPosition, StrategyCategory, SystemLog, SystemStats, Token, TokenPrice, TradeAction, TradingCondition, Transaction, TransactionStatus, TransactionType, UpdateWebhookInput, User, UserProfile, UserSettings, WalletBalance, WalletExport, WalletImportRequest, Webhook, WebhookDelivery, WebhookEventType } from './types/index.mjs';
3
- export { E as EngineAuthResponse, b as EngineTransactionRequest, d as EngineTransactionResponse, a as EngineWalletBalance, O as OneEngineClient, g as OnrampQuote, f as OnrampSession, e as OnrampSessionRequest, h as OnrampTransaction, j as SwapExecuteRequest, i as SwapQuote, S as SwapQuoteRequest, k as SwapResult, c as createOneEngineClient } from './engine-CrlhH0nw.mjs';
4
- export { SupabaseService, createSupabaseClient } from './services/index.mjs';
3
+ export { E as EngineAuthResponse, b as EngineTransactionRequest, d as EngineTransactionResponse, a as EngineWalletBalance, O as OneEngineClient, g as OnrampQuote, f as OnrampSession, e as OnrampSessionRequest, h as OnrampTransaction, j as SwapExecuteRequest, i as SwapQuote, S as SwapQuoteRequest, k as SwapResult, c as createOneEngineClient } from './engine-BeVuHpVx.mjs';
4
+ export { S as SupabaseService, c as createSupabaseClient } from './supabase-BT0c7q9e.mjs';
5
5
  export { P as PriceService, p as priceService } from './price-ClbLHHjv.mjs';
6
6
  export { OneContext, OneProvider, OneThirdwebConfig, OneThirdwebProvider, OneThirdwebProviderProps, useOne, useOneAuth, useOneEngine, useOneOnramp, useOneSwap, useOneTrading, useOneWallet, useThirdwebClient } from './providers/index.mjs';
7
7
  import * as react_jsx_runtime from 'react/jsx-runtime';
@@ -11,7 +11,7 @@ export { inAppWallet, smartWallet } from 'thirdweb/wallets';
11
11
  import { PreparedTransaction } from 'thirdweb';
12
12
  import { Chain } from 'thirdweb/chains';
13
13
  export { arbitrum, base, ethereum, optimism, polygon } from 'thirdweb/chains';
14
- export { useTokenPrice, useTokenPrices, useWalletBalance } from './hooks/index.mjs';
14
+ export { UseAIMarketDataResult, UseAIOrdersOptions, UseAIOrdersResult, UseAIPortfolioResult, UseAIStrategiesOptions, UseAIStrategiesResult, UseAIStrategyResult, UseAITradingResult, clearAITradingAccessToken, setAITradingAccessToken, useAIMarketData, useAIOrders, useAIPortfolio, useAIStrategies, useAIStrategy, useAITrading, useTokenPrice, useTokenPrices, useWalletBalance } from './hooks/index.mjs';
15
15
  export { OneSDKError, capitalize, checksumAddress, formatDate, formatDateTime, formatNumber, formatPercent, formatRelativeTime, formatTokenAmount, formatUSD, isOneSDKError, isValidAddress, isValidEmail, isValidPhone, omit, pick, retry, shortenAddress, sleep, slugify, truncate } from './utils/index.mjs';
16
16
  import '@supabase/supabase-js';
17
17
 
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export { CHAIN_CONFIGS, CHAIN_IDS, COINGECKO_IDS, DEFAULT_CHAIN_ID, OneConfig, SUPPORTED_CHAINS, TOKEN_NAMES, fetchChains, getChainById, getChainByName, getChainConfig, getChains, getConfig, getEngineUrl, getRecommendedChains, getSmartWalletChains, initOneSDK, isInitialized } from './config/index.js';
2
2
  export { AIMarketData, AINavSnapshot, AIOrder, AIOrderStatus, AIPortfolioSummary, AIRedemptionResult, AIStrategy, AITradeAllocation, AITradeExecution, AdminListOptions, AdminProject, AdminUser, ApiResponse, AssetAllocation, BillCategory, BillPayment, BillProvider, BridgeQuote, BridgeRoute, BridgeTransaction, Card, CardStatus, CardTier, CardTransaction, ChainConfig, Contract, ContractDeployParams, ContractReadParams, ContractType, ContractWriteParams, CreateAIOrderRequest, CreateWebhookInput, GasEstimate, GasPrice, KycLevel, KycStatus, LimitOrder, MembershipTier, NFT, NFTAttribute, NFTCollection, NFTTransfer, Notification, NotificationSettings, OfframpRequest, OnChainBalance, PaginatedResult, Permission, PermissionScope, PortfolioAnalytics, PortfolioHistory, Position, RateLimitInfo, Referral, ReferralInfo, RiskLevel, SDKEvent, SDKEventType, Session, StakingPool, StakingPosition, StrategyCategory, SystemLog, SystemStats, Token, TokenPrice, TradeAction, TradingCondition, Transaction, TransactionStatus, TransactionType, UpdateWebhookInput, User, UserProfile, UserSettings, WalletBalance, WalletExport, WalletImportRequest, Webhook, WebhookDelivery, WebhookEventType } from './types/index.js';
3
- export { E as EngineAuthResponse, b as EngineTransactionRequest, d as EngineTransactionResponse, a as EngineWalletBalance, O as OneEngineClient, g as OnrampQuote, f as OnrampSession, e as OnrampSessionRequest, h as OnrampTransaction, j as SwapExecuteRequest, i as SwapQuote, S as SwapQuoteRequest, k as SwapResult, c as createOneEngineClient } from './engine-5ndtBaCr.js';
4
- export { SupabaseService, createSupabaseClient } from './services/index.js';
3
+ export { E as EngineAuthResponse, b as EngineTransactionRequest, d as EngineTransactionResponse, a as EngineWalletBalance, O as OneEngineClient, g as OnrampQuote, f as OnrampSession, e as OnrampSessionRequest, h as OnrampTransaction, j as SwapExecuteRequest, i as SwapQuote, S as SwapQuoteRequest, k as SwapResult, c as createOneEngineClient } from './engine-DSc1Em4V.js';
4
+ export { S as SupabaseService, c as createSupabaseClient } from './supabase-BT0c7q9e.js';
5
5
  export { P as PriceService, p as priceService } from './price-CgqXPnT3.js';
6
6
  export { OneContext, OneProvider, OneThirdwebConfig, OneThirdwebProvider, OneThirdwebProviderProps, useOne, useOneAuth, useOneEngine, useOneOnramp, useOneSwap, useOneTrading, useOneWallet, useThirdwebClient } from './providers/index.js';
7
7
  import * as react_jsx_runtime from 'react/jsx-runtime';
@@ -11,7 +11,7 @@ export { inAppWallet, smartWallet } from 'thirdweb/wallets';
11
11
  import { PreparedTransaction } from 'thirdweb';
12
12
  import { Chain } from 'thirdweb/chains';
13
13
  export { arbitrum, base, ethereum, optimism, polygon } from 'thirdweb/chains';
14
- export { useTokenPrice, useTokenPrices, useWalletBalance } from './hooks/index.js';
14
+ export { UseAIMarketDataResult, UseAIOrdersOptions, UseAIOrdersResult, UseAIPortfolioResult, UseAIStrategiesOptions, UseAIStrategiesResult, UseAIStrategyResult, UseAITradingResult, clearAITradingAccessToken, setAITradingAccessToken, useAIMarketData, useAIOrders, useAIPortfolio, useAIStrategies, useAIStrategy, useAITrading, useTokenPrice, useTokenPrices, useWalletBalance } from './hooks/index.js';
15
15
  export { OneSDKError, capitalize, checksumAddress, formatDate, formatDateTime, formatNumber, formatPercent, formatRelativeTime, formatTokenAmount, formatUSD, isOneSDKError, isValidAddress, isValidEmail, isValidPhone, omit, pick, retry, shortenAddress, sleep, slugify, truncate } from './utils/index.js';
16
16
  import '@supabase/supabase-js';
17
17
 
package/dist/index.js CHANGED
@@ -1273,6 +1273,43 @@ var OneEngineClient = class {
1273
1273
  async adminClearRateLimits(identifier) {
1274
1274
  return this.request(`/api/v1/admin/rate-limits/${identifier}`, { method: "DELETE" });
1275
1275
  }
1276
+ // ========== AI Agent Configuration ==========
1277
+ /**
1278
+ * Get all AI agent configurations
1279
+ * This returns the full agent setup including tiers, cycles, and trading parameters
1280
+ */
1281
+ async getAgentConfigs(options) {
1282
+ const params = new URLSearchParams();
1283
+ if (options?.includeInactive) params.set("includeInactive", "true");
1284
+ if (options?.agentId) params.set("agentId", options.agentId);
1285
+ const query = params.toString();
1286
+ return this.request(`/api/v1/agents${query ? `?${query}` : ""}`, { method: "GET" });
1287
+ }
1288
+ /**
1289
+ * Calculate subscription parameters for an agent
1290
+ */
1291
+ async calculateAgentParams(params) {
1292
+ return this.request("/api/v1/agents/calculate", {
1293
+ method: "POST",
1294
+ body: JSON.stringify(params)
1295
+ });
1296
+ }
1297
+ /**
1298
+ * Get supported trading pairs from agents
1299
+ */
1300
+ async getTradingPairs() {
1301
+ const result = await this.getAgentConfigs();
1302
+ if (result.success && result.data?.agents) {
1303
+ const allPairs = /* @__PURE__ */ new Set();
1304
+ const byAgent = {};
1305
+ for (const agent of result.data.agents) {
1306
+ byAgent[agent.id] = agent.supported_pairs;
1307
+ agent.supported_pairs.forEach((p) => allPairs.add(p));
1308
+ }
1309
+ return { success: true, data: { pairs: Array.from(allPairs), byAgent } };
1310
+ }
1311
+ return { success: false, error: result.error };
1312
+ }
1276
1313
  // ========== AI Quant Trading ==========
1277
1314
  /**
1278
1315
  * Get all AI trading strategies
@@ -1411,6 +1448,67 @@ var OneEngineClient = class {
1411
1448
  async getCryptoMarketOverview() {
1412
1449
  return this.request("/api/v1/prices?type=overview", { method: "GET" });
1413
1450
  }
1451
+ // ========== Project Management ==========
1452
+ /**
1453
+ * Get user's projects
1454
+ */
1455
+ async getProjects(options) {
1456
+ const params = new URLSearchParams();
1457
+ if (options?.isActive !== void 0) params.set("isActive", String(options.isActive));
1458
+ const query = params.toString();
1459
+ return this.request(`/api/v1/projects${query ? `?${query}` : ""}`, { method: "GET" });
1460
+ }
1461
+ /**
1462
+ * Create a new project for ecosystem partners
1463
+ */
1464
+ async createProject(params) {
1465
+ return this.request("/api/v1/projects", {
1466
+ method: "POST",
1467
+ body: JSON.stringify(params)
1468
+ });
1469
+ }
1470
+ /**
1471
+ * Get project details
1472
+ */
1473
+ async getProject(projectId) {
1474
+ return this.request(`/api/v1/projects/${projectId}`, { method: "GET" });
1475
+ }
1476
+ /**
1477
+ * Update project settings
1478
+ */
1479
+ async updateProject(projectId, updates) {
1480
+ return this.request(`/api/v1/projects/${projectId}`, {
1481
+ method: "PATCH",
1482
+ body: JSON.stringify(updates)
1483
+ });
1484
+ }
1485
+ /**
1486
+ * Get project features status
1487
+ */
1488
+ async getProjectFeatures(projectId) {
1489
+ return this.request(`/api/v1/projects/${projectId}/features`, { method: "GET" });
1490
+ }
1491
+ /**
1492
+ * Enable/disable features for a project
1493
+ */
1494
+ async updateProjectFeatures(projectId, features) {
1495
+ return this.request(`/api/v1/projects/${projectId}/features`, {
1496
+ method: "PATCH",
1497
+ body: JSON.stringify(features)
1498
+ });
1499
+ }
1500
+ /**
1501
+ * Regenerate project API key
1502
+ */
1503
+ async regenerateProjectApiKey(projectId) {
1504
+ return this.request(`/api/v1/projects/${projectId}/api-key`, { method: "POST" });
1505
+ }
1506
+ /**
1507
+ * Delete project
1508
+ */
1509
+ async deleteProject(projectId) {
1510
+ return this.request(`/api/v1/projects/${projectId}`, { method: "DELETE" });
1511
+ }
1414
1512
  };
1415
1513
  function createOneEngineClient(options) {
1416
1514
  return new OneEngineClient(options);
@@ -3463,7 +3561,7 @@ var TOKENS_BY_CHAIN = {
3463
3561
  { address: "0x0000000000000000000000000000000000000000", symbol: "ETH", name: "Ethereum", decimals: 18, chainId: 1 },
3464
3562
  { address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", symbol: "USDC", name: "USD Coin", decimals: 6, chainId: 1 },
3465
3563
  { address: "0xdAC17F958D2ee523a2206206994597C13D831ec7", symbol: "USDT", name: "Tether", decimals: 6, chainId: 1 },
3466
- { address: "0x6B175474E89094C44Da98b954EescdeCB5", symbol: "DAI", name: "Dai", decimals: 18, chainId: 1 },
3564
+ { address: "0x6B175474E89094C44Da98b954EedeAC495271d0F", symbol: "DAI", name: "Dai", decimals: 18, chainId: 1 },
3467
3565
  { address: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", symbol: "WETH", name: "Wrapped Ether", decimals: 18, chainId: 1 }
3468
3566
  ],
3469
3567
  // Base
@@ -4809,6 +4907,251 @@ function useTokenPrices(symbols, options = {}) {
4809
4907
  refetch: fetchPrices
4810
4908
  };
4811
4909
  }
4910
+ var clientInstance = null;
4911
+ function getClient() {
4912
+ if (!clientInstance) {
4913
+ clientInstance = createOneEngineClient();
4914
+ }
4915
+ return clientInstance;
4916
+ }
4917
+ function setAITradingAccessToken(token) {
4918
+ getClient().setAccessToken(token);
4919
+ }
4920
+ function clearAITradingAccessToken() {
4921
+ getClient().clearAccessToken();
4922
+ }
4923
+ function useAIStrategies(options = {}) {
4924
+ const [strategies, setStrategies] = React2.useState([]);
4925
+ const [isLoading, setIsLoading] = React2.useState(true);
4926
+ const [error, setError] = React2.useState(null);
4927
+ const { category, riskLevel, minTvl, isActive, autoRefresh = false, refreshInterval = 6e4 } = options;
4928
+ const fetchStrategies = React2.useCallback(async () => {
4929
+ setIsLoading(true);
4930
+ setError(null);
4931
+ try {
4932
+ const result = await getClient().getAIStrategies({ category, riskLevel, minTvl, isActive });
4933
+ if (result.success && result.data?.strategies) {
4934
+ setStrategies(result.data.strategies);
4935
+ } else {
4936
+ setError(result.error?.message || "Failed to fetch strategies");
4937
+ }
4938
+ } catch (err) {
4939
+ setError(err instanceof Error ? err.message : "Unknown error");
4940
+ } finally {
4941
+ setIsLoading(false);
4942
+ }
4943
+ }, [category, riskLevel, minTvl, isActive]);
4944
+ React2.useEffect(() => {
4945
+ fetchStrategies();
4946
+ }, [fetchStrategies]);
4947
+ React2.useEffect(() => {
4948
+ if (autoRefresh && refreshInterval > 0) {
4949
+ const interval = setInterval(fetchStrategies, refreshInterval);
4950
+ return () => clearInterval(interval);
4951
+ }
4952
+ }, [autoRefresh, refreshInterval, fetchStrategies]);
4953
+ return { strategies, isLoading, error, refresh: fetchStrategies };
4954
+ }
4955
+ function useAIStrategy(strategyId, include = ["performance", "market"]) {
4956
+ const [strategy, setStrategy] = React2.useState(null);
4957
+ const [performance, setPerformance] = React2.useState([]);
4958
+ const [marketData, setMarketData] = React2.useState([]);
4959
+ const [isLoading, setIsLoading] = React2.useState(true);
4960
+ const [error, setError] = React2.useState(null);
4961
+ const fetchStrategy = React2.useCallback(async () => {
4962
+ if (!strategyId) {
4963
+ setIsLoading(false);
4964
+ return;
4965
+ }
4966
+ setIsLoading(true);
4967
+ setError(null);
4968
+ try {
4969
+ const result = await getClient().getAIStrategy(strategyId, include);
4970
+ if (result.success && result.data) {
4971
+ setStrategy(result.data.strategy);
4972
+ setPerformance(result.data.performance || []);
4973
+ setMarketData(result.data.marketData || []);
4974
+ } else {
4975
+ setError(result.error?.message || "Failed to fetch strategy");
4976
+ }
4977
+ } catch (err) {
4978
+ setError(err instanceof Error ? err.message : "Unknown error");
4979
+ } finally {
4980
+ setIsLoading(false);
4981
+ }
4982
+ }, [strategyId, include.join(",")]);
4983
+ React2.useEffect(() => {
4984
+ fetchStrategy();
4985
+ }, [fetchStrategy]);
4986
+ return { strategy, performance, marketData, isLoading, error, refresh: fetchStrategy };
4987
+ }
4988
+ function useAIOrders(options = {}) {
4989
+ const [orders, setOrders] = React2.useState([]);
4990
+ const [isLoading, setIsLoading] = React2.useState(true);
4991
+ const [error, setError] = React2.useState(null);
4992
+ const { strategyId, status, autoRefresh = true, refreshInterval = 3e4 } = options;
4993
+ const fetchOrders = React2.useCallback(async () => {
4994
+ setIsLoading(true);
4995
+ setError(null);
4996
+ try {
4997
+ const result = await getClient().getAIOrders({ strategyId, status });
4998
+ if (result.success && result.data?.orders) {
4999
+ setOrders(result.data.orders);
5000
+ } else {
5001
+ setError(result.error?.message || "Failed to fetch orders");
5002
+ }
5003
+ } catch (err) {
5004
+ setError(err instanceof Error ? err.message : "Unknown error");
5005
+ } finally {
5006
+ setIsLoading(false);
5007
+ }
5008
+ }, [strategyId, status]);
5009
+ React2.useEffect(() => {
5010
+ fetchOrders();
5011
+ }, [fetchOrders]);
5012
+ React2.useEffect(() => {
5013
+ if (autoRefresh && refreshInterval > 0) {
5014
+ const interval = setInterval(fetchOrders, refreshInterval);
5015
+ return () => clearInterval(interval);
5016
+ }
5017
+ }, [autoRefresh, refreshInterval, fetchOrders]);
5018
+ const createOrder = React2.useCallback(async (request) => {
5019
+ const result = await getClient().createAIOrder(request);
5020
+ if (result.success) {
5021
+ await fetchOrders();
5022
+ }
5023
+ return result;
5024
+ }, [fetchOrders]);
5025
+ const pauseOrder = React2.useCallback(async (orderId) => {
5026
+ const result = await getClient().pauseAIOrder(orderId);
5027
+ if (result.success) {
5028
+ await fetchOrders();
5029
+ }
5030
+ return result;
5031
+ }, [fetchOrders]);
5032
+ const resumeOrder = React2.useCallback(async (orderId) => {
5033
+ const result = await getClient().resumeAIOrder(orderId);
5034
+ if (result.success) {
5035
+ await fetchOrders();
5036
+ }
5037
+ return result;
5038
+ }, [fetchOrders]);
5039
+ const redeemOrder = React2.useCallback(async (orderId) => {
5040
+ const result = await getClient().redeemAIOrder(orderId);
5041
+ if (result.success) {
5042
+ await fetchOrders();
5043
+ }
5044
+ return result;
5045
+ }, [fetchOrders]);
5046
+ return {
5047
+ orders,
5048
+ isLoading,
5049
+ error,
5050
+ refresh: fetchOrders,
5051
+ createOrder,
5052
+ pauseOrder,
5053
+ resumeOrder,
5054
+ redeemOrder
5055
+ };
5056
+ }
5057
+ function useAIPortfolio(autoRefresh = true) {
5058
+ const [portfolio, setPortfolio] = React2.useState(null);
5059
+ const [allocations, setAllocations] = React2.useState([]);
5060
+ const [activeOrders, setActiveOrders] = React2.useState([]);
5061
+ const [isLoading, setIsLoading] = React2.useState(true);
5062
+ const [error, setError] = React2.useState(null);
5063
+ const fetchPortfolio = React2.useCallback(async () => {
5064
+ setIsLoading(true);
5065
+ setError(null);
5066
+ try {
5067
+ const result = await getClient().getAIPortfolio(["allocations", "orders"]);
5068
+ if (result.success && result.data) {
5069
+ setPortfolio(result.data.portfolio);
5070
+ setAllocations(result.data.allocations || []);
5071
+ setActiveOrders(result.data.orders || []);
5072
+ } else {
5073
+ setError(result.error?.message || "Failed to fetch portfolio");
5074
+ }
5075
+ } catch (err) {
5076
+ setError(err instanceof Error ? err.message : "Unknown error");
5077
+ } finally {
5078
+ setIsLoading(false);
5079
+ }
5080
+ }, []);
5081
+ React2.useEffect(() => {
5082
+ fetchPortfolio();
5083
+ }, [fetchPortfolio]);
5084
+ React2.useEffect(() => {
5085
+ if (autoRefresh) {
5086
+ const interval = setInterval(fetchPortfolio, 3e4);
5087
+ return () => clearInterval(interval);
5088
+ }
5089
+ }, [autoRefresh, fetchPortfolio]);
5090
+ return { portfolio, allocations, activeOrders, isLoading, error, refresh: fetchPortfolio };
5091
+ }
5092
+ function useAIMarketData(symbols = ["BTC", "ETH", "BNB", "SOL", "XRP", "DOGE", "ADA", "AVAX"], autoRefresh = true) {
5093
+ const [prices, setPrices] = React2.useState({});
5094
+ const [isLoading, setIsLoading] = React2.useState(true);
5095
+ const [error, setError] = React2.useState(null);
5096
+ const fetchPrices = React2.useCallback(async () => {
5097
+ setIsLoading(true);
5098
+ setError(null);
5099
+ try {
5100
+ const result = await getClient().getTokenPrices(symbols);
5101
+ if (result.success && result.data) {
5102
+ setPrices(result.data);
5103
+ } else {
5104
+ setError(result.error?.message || "Failed to fetch prices");
5105
+ }
5106
+ } catch (err) {
5107
+ setError(err instanceof Error ? err.message : "Unknown error");
5108
+ } finally {
5109
+ setIsLoading(false);
5110
+ }
5111
+ }, [symbols.join(",")]);
5112
+ React2.useEffect(() => {
5113
+ fetchPrices();
5114
+ }, [fetchPrices]);
5115
+ React2.useEffect(() => {
5116
+ if (autoRefresh) {
5117
+ const interval = setInterval(fetchPrices, 15e3);
5118
+ return () => clearInterval(interval);
5119
+ }
5120
+ }, [autoRefresh, fetchPrices]);
5121
+ return { prices, isLoading, error, refresh: fetchPrices };
5122
+ }
5123
+ function useAITrading() {
5124
+ const strategiesResult = useAIStrategies({ autoRefresh: true });
5125
+ const ordersResult = useAIOrders({ autoRefresh: true });
5126
+ const portfolioResult = useAIPortfolio(true);
5127
+ const marketResult = useAIMarketData();
5128
+ const refreshAll = React2.useCallback(async () => {
5129
+ await Promise.all([
5130
+ strategiesResult.refresh(),
5131
+ ordersResult.refresh(),
5132
+ portfolioResult.refresh(),
5133
+ marketResult.refresh()
5134
+ ]);
5135
+ }, [strategiesResult.refresh, ordersResult.refresh, portfolioResult.refresh, marketResult.refresh]);
5136
+ const error = React2.useMemo(() => {
5137
+ return strategiesResult.error || ordersResult.error || portfolioResult.error || marketResult.error;
5138
+ }, [strategiesResult.error, ordersResult.error, portfolioResult.error, marketResult.error]);
5139
+ return {
5140
+ strategies: strategiesResult.strategies,
5141
+ strategiesLoading: strategiesResult.isLoading,
5142
+ orders: ordersResult.orders,
5143
+ ordersLoading: ordersResult.isLoading,
5144
+ portfolio: portfolioResult.portfolio,
5145
+ portfolioLoading: portfolioResult.isLoading,
5146
+ prices: marketResult.prices,
5147
+ createOrder: ordersResult.createOrder,
5148
+ pauseOrder: ordersResult.pauseOrder,
5149
+ resumeOrder: ordersResult.resumeOrder,
5150
+ redeemOrder: ordersResult.redeemOrder,
5151
+ refreshAll,
5152
+ error
5153
+ };
5154
+ }
4812
5155
 
4813
5156
  // src/utils/index.ts
4814
5157
  function shortenAddress(address, chars = 4) {
@@ -5022,6 +5365,7 @@ exports.SupabaseService = SupabaseService;
5022
5365
  exports.TOKEN_NAMES = TOKEN_NAMES;
5023
5366
  exports.capitalize = capitalize;
5024
5367
  exports.checksumAddress = checksumAddress;
5368
+ exports.clearAITradingAccessToken = clearAITradingAccessToken;
5025
5369
  exports.createOneEngineClient = createOneEngineClient;
5026
5370
  exports.createSupabaseClient = createSupabaseClient;
5027
5371
  exports.fetchChains = fetchChains;
@@ -5050,10 +5394,17 @@ exports.omit = omit;
5050
5394
  exports.pick = pick;
5051
5395
  exports.priceService = priceService;
5052
5396
  exports.retry = retry;
5397
+ exports.setAITradingAccessToken = setAITradingAccessToken;
5053
5398
  exports.shortenAddress = shortenAddress;
5054
5399
  exports.sleep = sleep;
5055
5400
  exports.slugify = slugify;
5056
5401
  exports.truncate = truncate;
5402
+ exports.useAIMarketData = useAIMarketData;
5403
+ exports.useAIOrders = useAIOrders;
5404
+ exports.useAIPortfolio = useAIPortfolio;
5405
+ exports.useAIStrategies = useAIStrategies;
5406
+ exports.useAIStrategy = useAIStrategy;
5407
+ exports.useAITrading = useAITrading;
5057
5408
  exports.useOne = useOne;
5058
5409
  exports.useOneAuth = useOneAuth;
5059
5410
  exports.useOneEngine = useOneEngine;