@one_deploy/sdk 1.0.4 → 1.0.6

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 (57) hide show
  1. package/dist/config/index.d.mts +74 -0
  2. package/dist/config/index.d.ts +74 -0
  3. package/dist/config/index.js +244 -0
  4. package/dist/config/index.js.map +1 -0
  5. package/dist/config/index.mjs +226 -0
  6. package/dist/config/index.mjs.map +1 -0
  7. package/dist/engine-BeVuHpVx.d.mts +1202 -0
  8. package/dist/engine-DSc1Em4V.d.ts +1202 -0
  9. package/dist/hooks/index.d.mts +185 -0
  10. package/dist/hooks/index.d.ts +185 -0
  11. package/dist/hooks/index.js +1711 -0
  12. package/dist/hooks/index.js.map +1 -0
  13. package/dist/hooks/index.mjs +1699 -0
  14. package/dist/hooks/index.mjs.map +1 -0
  15. package/dist/index.d.mts +356 -0
  16. package/dist/index.d.ts +356 -0
  17. package/dist/index.js +5420 -0
  18. package/dist/index.js.map +1 -0
  19. package/dist/index.mjs +5293 -0
  20. package/dist/index.mjs.map +1 -0
  21. package/dist/price-CgqXPnT3.d.ts +13 -0
  22. package/dist/price-ClbLHHjv.d.mts +13 -0
  23. package/dist/providers/index.d.mts +121 -0
  24. package/dist/providers/index.d.ts +121 -0
  25. package/dist/providers/index.js +1741 -0
  26. package/dist/providers/index.js.map +1 -0
  27. package/dist/providers/index.mjs +1699 -0
  28. package/dist/providers/index.mjs.map +1 -0
  29. package/dist/react-native.d.mts +257 -0
  30. package/dist/react-native.d.ts +257 -0
  31. package/dist/react-native.js +2436 -0
  32. package/dist/react-native.js.map +1 -0
  33. package/dist/react-native.mjs +2392 -0
  34. package/dist/react-native.mjs.map +1 -0
  35. package/dist/services/index.d.mts +105 -0
  36. package/dist/services/index.d.ts +105 -0
  37. package/dist/services/index.js +1720 -0
  38. package/dist/services/index.js.map +1 -0
  39. package/dist/services/index.mjs +1709 -0
  40. package/dist/services/index.mjs.map +1 -0
  41. package/dist/supabase-BT0c7q9e.d.mts +82 -0
  42. package/dist/supabase-BT0c7q9e.d.ts +82 -0
  43. package/dist/types/index.d.mts +759 -0
  44. package/dist/types/index.d.ts +759 -0
  45. package/dist/types/index.js +4 -0
  46. package/dist/types/index.js.map +1 -0
  47. package/dist/types/index.mjs +3 -0
  48. package/dist/types/index.mjs.map +1 -0
  49. package/dist/utils/index.d.mts +36 -0
  50. package/dist/utils/index.d.ts +36 -0
  51. package/dist/utils/index.js +164 -0
  52. package/dist/utils/index.js.map +1 -0
  53. package/dist/utils/index.mjs +142 -0
  54. package/dist/utils/index.mjs.map +1 -0
  55. package/package.json +5 -1
  56. package/tsconfig.json +0 -22
  57. package/tsup.config.ts +0 -25
@@ -0,0 +1,2392 @@
1
+ import { StyleSheet, View, Text, TouchableOpacity } from 'react-native';
2
+ import { jsxs, jsx } from 'react/jsx-runtime';
3
+
4
+ // src/config/index.ts
5
+ var DEFAULT_ENGINE_URL = "https://api.one23.io";
6
+ var DEFAULT_CLIENT_ID = "one_pk_e8f647bfa643fdcfaa3a23f760488e49be09f929296eed4a6c399d437d907f60";
7
+ var config = null;
8
+ function initOneSDK(options) {
9
+ const engineUrl = options.oneEngineUrl || DEFAULT_ENGINE_URL;
10
+ const clientId = options.oneClientId || DEFAULT_CLIENT_ID;
11
+ config = {
12
+ ...options,
13
+ oneEngineUrl: engineUrl,
14
+ oneClientId: clientId
15
+ };
16
+ }
17
+ function getConfig() {
18
+ if (!config) {
19
+ throw new Error("ONE SDK not initialized. Call initOneSDK() first.");
20
+ }
21
+ return config;
22
+ }
23
+ var TOKEN_NAMES = {
24
+ ETH: "Ethereum",
25
+ BTC: "Bitcoin",
26
+ BNB: "BNB",
27
+ MATIC: "Polygon",
28
+ POL: "Polygon",
29
+ AVAX: "Avalanche",
30
+ USDT: "Tether",
31
+ USDC: "USD Coin",
32
+ DAI: "Dai",
33
+ WBTC: "Wrapped Bitcoin",
34
+ WETH: "Wrapped Ether",
35
+ ARB: "Arbitrum",
36
+ OP: "Optimism",
37
+ LINK: "Chainlink",
38
+ UNI: "Uniswap",
39
+ AAVE: "Aave",
40
+ CRV: "Curve",
41
+ MKR: "Maker",
42
+ SNX: "Synthetix",
43
+ COMP: "Compound",
44
+ SUSHI: "SushiSwap",
45
+ YFI: "Yearn Finance",
46
+ SOL: "Solana",
47
+ DOT: "Polkadot",
48
+ ATOM: "Cosmos",
49
+ NEAR: "Near Protocol"
50
+ };
51
+ var COINGECKO_IDS = {
52
+ ETH: "ethereum",
53
+ BTC: "bitcoin",
54
+ BNB: "binancecoin",
55
+ MATIC: "matic-network",
56
+ POL: "matic-network",
57
+ AVAX: "avalanche-2",
58
+ USDT: "tether",
59
+ USDC: "usd-coin",
60
+ DAI: "dai",
61
+ WBTC: "wrapped-bitcoin",
62
+ WETH: "weth",
63
+ ARB: "arbitrum",
64
+ OP: "optimism",
65
+ LINK: "chainlink",
66
+ UNI: "uniswap",
67
+ AAVE: "aave",
68
+ SOL: "solana"
69
+ };
70
+ var CHAIN_CONFIGS = {
71
+ ethereum: {
72
+ id: 1,
73
+ name: "Ethereum",
74
+ shortName: "ETH",
75
+ icon: "\u229F",
76
+ nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
77
+ rpcUrls: ["https://ethereum.rpc.thirdweb.com"],
78
+ blockExplorerUrls: ["https://etherscan.io"],
79
+ testnet: false
80
+ },
81
+ polygon: {
82
+ id: 137,
83
+ name: "Polygon",
84
+ shortName: "MATIC",
85
+ icon: "\u{1F7E3}",
86
+ nativeCurrency: { name: "POL", symbol: "POL", decimals: 18 },
87
+ rpcUrls: ["https://polygon.rpc.thirdweb.com"],
88
+ blockExplorerUrls: ["https://polygonscan.com"],
89
+ testnet: false
90
+ },
91
+ base: {
92
+ id: 8453,
93
+ name: "Base",
94
+ shortName: "BASE",
95
+ icon: "\u{1F537}",
96
+ nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
97
+ rpcUrls: ["https://base.rpc.thirdweb.com"],
98
+ blockExplorerUrls: ["https://basescan.org"],
99
+ testnet: false
100
+ },
101
+ arbitrum: {
102
+ id: 42161,
103
+ name: "Arbitrum One",
104
+ shortName: "ARB",
105
+ icon: "\u{1F535}",
106
+ nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
107
+ rpcUrls: ["https://arbitrum.rpc.thirdweb.com"],
108
+ blockExplorerUrls: ["https://arbiscan.io"],
109
+ testnet: false
110
+ },
111
+ optimism: {
112
+ id: 10,
113
+ name: "Optimism",
114
+ shortName: "OP",
115
+ icon: "\u{1F534}",
116
+ nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
117
+ rpcUrls: ["https://optimism.rpc.thirdweb.com"],
118
+ blockExplorerUrls: ["https://optimistic.etherscan.io"],
119
+ testnet: false
120
+ }
121
+ };
122
+
123
+ // src/services/engine.ts
124
+ var OneEngineClient = class {
125
+ constructor(options) {
126
+ const config2 = getConfig();
127
+ this.baseUrl = options?.baseUrl || config2.oneEngineUrl;
128
+ this.clientId = options?.clientId || config2.oneClientId || "";
129
+ this.secretKey = options?.secretKey || config2.oneSecretKey;
130
+ }
131
+ /**
132
+ * Set access token for authenticated requests
133
+ */
134
+ setAccessToken(token) {
135
+ this.accessToken = token;
136
+ }
137
+ /**
138
+ * Clear access token
139
+ */
140
+ clearAccessToken() {
141
+ this.accessToken = void 0;
142
+ }
143
+ getHeaders(includeSecret = false) {
144
+ const headers = {
145
+ "Content-Type": "application/json",
146
+ "x-client-id": this.clientId
147
+ };
148
+ if (this.accessToken) {
149
+ headers["Authorization"] = `Bearer ${this.accessToken}`;
150
+ }
151
+ if (includeSecret && this.secretKey) {
152
+ headers["x-secret-key"] = this.secretKey;
153
+ }
154
+ return headers;
155
+ }
156
+ async request(endpoint, options = {}, includeSecret = false) {
157
+ try {
158
+ const response = await fetch(`${this.baseUrl}${endpoint}`, {
159
+ ...options,
160
+ headers: {
161
+ ...this.getHeaders(includeSecret),
162
+ ...options.headers
163
+ }
164
+ });
165
+ const data = await response.json();
166
+ if (!response.ok) {
167
+ return {
168
+ success: false,
169
+ error: {
170
+ code: data.error?.code || `HTTP_${response.status}`,
171
+ message: data.error?.message || "Request failed"
172
+ }
173
+ };
174
+ }
175
+ return {
176
+ success: true,
177
+ data: data.data || data
178
+ };
179
+ } catch (error) {
180
+ return {
181
+ success: false,
182
+ error: {
183
+ code: "NETWORK_ERROR",
184
+ message: error instanceof Error ? error.message : "Network request failed"
185
+ }
186
+ };
187
+ }
188
+ }
189
+ // ===============================
190
+ // AUTH ENDPOINTS
191
+ // ===============================
192
+ /**
193
+ * Send OTP to email for authentication
194
+ */
195
+ async sendEmailOtp(email) {
196
+ return this.request("/api/v1/auth/otp", {
197
+ method: "POST",
198
+ body: JSON.stringify({ email })
199
+ });
200
+ }
201
+ /**
202
+ * Verify OTP and get access token
203
+ */
204
+ async verifyEmailOtp(email, otp) {
205
+ return this.request("/api/v1/auth/otp/verify", {
206
+ method: "POST",
207
+ body: JSON.stringify({ email, otp })
208
+ });
209
+ }
210
+ /**
211
+ * Authenticate with wallet signature
212
+ */
213
+ async authWithWallet(walletAddress, signature, message) {
214
+ return this.request("/api/v1/auth/wallet", {
215
+ method: "POST",
216
+ body: JSON.stringify({ walletAddress, signature, message })
217
+ });
218
+ }
219
+ /**
220
+ * Refresh access token
221
+ */
222
+ async refreshToken(refreshToken) {
223
+ return this.request("/api/v1/auth/refresh", {
224
+ method: "POST",
225
+ body: JSON.stringify({ refreshToken })
226
+ });
227
+ }
228
+ /**
229
+ * Get current user
230
+ */
231
+ async getCurrentUser() {
232
+ return this.request("/api/v1/auth/me", { method: "GET" });
233
+ }
234
+ /**
235
+ * Sign out
236
+ */
237
+ async signOut() {
238
+ return this.request("/api/v1/auth/logout", { method: "POST" });
239
+ }
240
+ // ===============================
241
+ // WALLET/ASSETS ENDPOINTS
242
+ // ===============================
243
+ /**
244
+ * Get wallet balance across all chains
245
+ */
246
+ async getWalletBalance(walletAddress, chains) {
247
+ const params = new URLSearchParams({ address: walletAddress });
248
+ if (chains?.length && chains.length > 0) {
249
+ params.set("chainId", chains[0].toString());
250
+ }
251
+ return this.request(`/api/v1/assets?${params}`, { method: "GET" });
252
+ }
253
+ /**
254
+ * Get portfolio summary
255
+ */
256
+ async getPortfolioSummary(walletAddress) {
257
+ const params = new URLSearchParams({ address: walletAddress });
258
+ return this.request(`/api/v1/assets/portfolio?${params}`, { method: "GET" });
259
+ }
260
+ /**
261
+ * Get user's wallets
262
+ */
263
+ async getUserWallets(chainId) {
264
+ const params = chainId ? `?chainId=${chainId}` : "";
265
+ return this.request(`/api/v1/wallet${params}`, { method: "GET" });
266
+ }
267
+ /**
268
+ * Create a new wallet
269
+ */
270
+ async createWallet(chainId = 8453, type = "smart") {
271
+ return this.request("/api/v1/wallet", {
272
+ method: "POST",
273
+ body: JSON.stringify({ chainId, type })
274
+ });
275
+ }
276
+ /**
277
+ * Get wallet transactions (placeholder - needs endpoint)
278
+ */
279
+ async getWalletTransactions(walletAddress, options) {
280
+ const params = new URLSearchParams({ address: walletAddress });
281
+ if (options?.limit) params.set("limit", options.limit.toString());
282
+ if (options?.offset) params.set("offset", options.offset.toString());
283
+ if (options?.chainId) params.set("chainId", options.chainId.toString());
284
+ return this.request(`/api/v1/assets/transactions?${params}`, { method: "GET" });
285
+ }
286
+ /**
287
+ * Send native token or ERC20
288
+ */
289
+ async sendTransaction(request) {
290
+ return this.request("/api/v1/wallet/send", {
291
+ method: "POST",
292
+ body: JSON.stringify(request)
293
+ });
294
+ }
295
+ /**
296
+ * Get transaction status
297
+ */
298
+ async getTransactionStatus(txId) {
299
+ return this.request(`/api/v1/wallet/transaction/${txId}`, { method: "GET" });
300
+ }
301
+ // ===============================
302
+ // ONRAMP ENDPOINTS (Fiat-to-Crypto)
303
+ // ===============================
304
+ /**
305
+ * Get onramp quote
306
+ */
307
+ async getOnrampQuote(fiatCurrency, fiatAmount, cryptoCurrency, paymentMethod) {
308
+ const params = new URLSearchParams({
309
+ fiatCurrency,
310
+ fiatAmount: fiatAmount.toString(),
311
+ cryptoCurrency
312
+ });
313
+ if (paymentMethod) params.set("paymentMethod", paymentMethod);
314
+ return this.request(`/api/v1/fiat/onramp/quote?${params}`, { method: "GET" });
315
+ }
316
+ /**
317
+ * Create onramp session (returns widget URL)
318
+ */
319
+ async createOnrampSession(request) {
320
+ return this.request("/api/v1/fiat/onramp", {
321
+ method: "POST",
322
+ body: JSON.stringify({
323
+ fiatCurrency: request.fiatCurrency || "USD",
324
+ fiatAmount: request.fiatAmount || 100,
325
+ cryptoCurrency: request.cryptoCurrency || "ETH",
326
+ walletAddress: request.walletAddress,
327
+ chainId: 8453
328
+ // Default to Base
329
+ })
330
+ });
331
+ }
332
+ /**
333
+ * Get onramp session status
334
+ */
335
+ async getOnrampStatus(sessionId) {
336
+ return this.request(`/api/v1/fiat/onramp/${sessionId}`, { method: "GET" });
337
+ }
338
+ /**
339
+ * Get supported currencies (fiat + crypto)
340
+ */
341
+ async getSupportedCurrencies() {
342
+ return this.request("/api/v1/fiat/onramp", { method: "GET" });
343
+ }
344
+ /**
345
+ * Get supported fiat currencies
346
+ */
347
+ async getSupportedFiatCurrencies() {
348
+ const result = await this.getSupportedCurrencies();
349
+ if (result.success && result.data) {
350
+ return { success: true, data: result.data.fiatCurrencies };
351
+ }
352
+ return { success: false, error: result.error };
353
+ }
354
+ /**
355
+ * Get supported payment methods
356
+ */
357
+ async getSupportedPaymentMethods(country) {
358
+ return { success: true, data: ["card", "bank_transfer", "apple_pay", "google_pay"] };
359
+ }
360
+ // ===============================
361
+ // SWAP ENDPOINTS
362
+ // ===============================
363
+ /**
364
+ * Get swap quote
365
+ */
366
+ async getSwapQuote(request) {
367
+ return this.request("/api/v1/swap/quote", {
368
+ method: "POST",
369
+ body: JSON.stringify(request)
370
+ });
371
+ }
372
+ /**
373
+ * Execute swap
374
+ */
375
+ async executeSwap(request) {
376
+ return this.request("/api/v1/swap/execute", {
377
+ method: "POST",
378
+ body: JSON.stringify(request)
379
+ });
380
+ }
381
+ /**
382
+ * Get swap status
383
+ */
384
+ async getSwapStatus(swapId) {
385
+ return this.request(`/api/v1/swap/${swapId}`, { method: "GET" });
386
+ }
387
+ /**
388
+ * Get supported tokens for swap
389
+ */
390
+ async getSupportedSwapTokens(chainId) {
391
+ const params = chainId ? `?chainId=${chainId}` : "";
392
+ return this.request(`/api/v1/swap/tokens${params}`, { method: "GET" });
393
+ }
394
+ /**
395
+ * Get supported chains for swap
396
+ */
397
+ async getSupportedSwapChains() {
398
+ return this.request("/api/v1/swap/chains", { method: "GET" });
399
+ }
400
+ // ===============================
401
+ // AI TRADING/QUANT ENDPOINTS
402
+ // ===============================
403
+ /**
404
+ * Get available AI trading strategies
405
+ */
406
+ async getStrategies() {
407
+ return this.request("/api/v1/quant/strategies", { method: "GET" });
408
+ }
409
+ /**
410
+ * Get strategy details
411
+ */
412
+ async getStrategy(strategyId) {
413
+ return this.request(`/api/v1/quant/strategies/${strategyId}`, { method: "GET" });
414
+ }
415
+ /**
416
+ * Get user's positions
417
+ */
418
+ async getPositions() {
419
+ return this.request("/api/v1/quant/positions", { method: "GET" });
420
+ }
421
+ /**
422
+ * Create investment order
423
+ */
424
+ async createOrder(strategyId, amount, currency) {
425
+ return this.request("/api/v1/trading/orders", {
426
+ method: "POST",
427
+ body: JSON.stringify({ strategyId, amount, currency })
428
+ });
429
+ }
430
+ /**
431
+ * Get user's orders
432
+ */
433
+ async getUserOrders() {
434
+ return this.request("/api/v1/trading/orders", { method: "GET" });
435
+ }
436
+ /**
437
+ * Get user's portfolio stats from positions
438
+ */
439
+ async getPortfolioStats() {
440
+ const positionsResult = await this.getPositions();
441
+ if (positionsResult.success && positionsResult.data) {
442
+ const positions = positionsResult.data;
443
+ const totalInvested = positions.reduce((sum, p) => sum + (p.investedAmount || 0), 0);
444
+ const totalValue = positions.reduce((sum, p) => sum + (p.currentValue || 0), 0);
445
+ const totalPnl = totalValue - totalInvested;
446
+ const totalPnlPercent = totalInvested > 0 ? totalPnl / totalInvested * 100 : 0;
447
+ return {
448
+ success: true,
449
+ data: {
450
+ totalInvested,
451
+ totalValue,
452
+ totalPnl,
453
+ totalPnlPercent,
454
+ activePositions: positions.filter((p) => p.status === "active").length
455
+ }
456
+ };
457
+ }
458
+ return {
459
+ success: true,
460
+ data: { totalInvested: 0, totalValue: 0, totalPnl: 0, totalPnlPercent: 0, activePositions: 0 }
461
+ };
462
+ }
463
+ // ===============================
464
+ // MARKET/PRICE ENDPOINTS
465
+ // ===============================
466
+ /**
467
+ * Get token prices
468
+ */
469
+ async getTokenPrices(symbols) {
470
+ const bybitSymbols = symbols.map((s) => {
471
+ const upper = s.toUpperCase();
472
+ if (upper.endsWith("USDT")) return upper;
473
+ return `${upper}USDT`;
474
+ });
475
+ const result = await this.request(
476
+ `/api/v1/trading/market?symbols=${bybitSymbols.join(",")}`,
477
+ { method: "GET" }
478
+ );
479
+ if (result.success && result.data?.markets) {
480
+ const prices = {};
481
+ for (const market of result.data.markets) {
482
+ const symbol = market.symbol?.replace("USDT", "") || "";
483
+ prices[symbol] = {
484
+ price: parseFloat(market.lastPrice) || 0,
485
+ change24h: parseFloat(market.price24hPcnt) * 100 || 0,
486
+ marketCap: void 0
487
+ // Bybit doesn't provide this
488
+ };
489
+ }
490
+ return { success: true, data: prices };
491
+ }
492
+ return { success: false, error: result.error };
493
+ }
494
+ /**
495
+ * Get market data overview
496
+ */
497
+ async getMarketData() {
498
+ const result = await this.request("/api/v1/trading/market", { method: "GET" });
499
+ if (result.success && result.data?.markets) {
500
+ return {
501
+ success: true,
502
+ data: {
503
+ totalMarketCap: 0,
504
+ // Would need separate API
505
+ totalVolume24h: result.data.markets.reduce((sum, m) => sum + (parseFloat(m.volume24h) || 0), 0),
506
+ btcDominance: 0,
507
+ // Would need separate API
508
+ markets: result.data.markets
509
+ }
510
+ };
511
+ }
512
+ return { success: false, error: result.error };
513
+ }
514
+ // ===============================
515
+ // NFT ENDPOINTS
516
+ // ===============================
517
+ /**
518
+ * Get user's NFTs
519
+ */
520
+ async getUserNFTs(walletAddress, options) {
521
+ const params = new URLSearchParams({ address: walletAddress });
522
+ if (options?.chainId) params.set("chainId", options.chainId.toString());
523
+ if (options?.limit) params.set("limit", options.limit.toString());
524
+ if (options?.offset) params.set("offset", options.offset.toString());
525
+ return this.request(`/api/v1/assets/nfts?${params}`, { method: "GET" });
526
+ }
527
+ /**
528
+ * Get NFT details
529
+ */
530
+ async getNFTDetails(contractAddress, tokenId, chainId) {
531
+ return this.request(`/api/v1/assets/nfts/${contractAddress}/${tokenId}?chainId=${chainId}`, { method: "GET" });
532
+ }
533
+ /**
534
+ * Get NFT collection
535
+ */
536
+ async getNFTCollection(contractAddress, chainId) {
537
+ return this.request(`/api/v1/assets/nfts/collection/${contractAddress}?chainId=${chainId}`, { method: "GET" });
538
+ }
539
+ /**
540
+ * Transfer NFT
541
+ */
542
+ async transferNFT(params) {
543
+ return this.request("/api/v1/assets/nfts/transfer", {
544
+ method: "POST",
545
+ body: JSON.stringify(params)
546
+ });
547
+ }
548
+ // ===============================
549
+ // CONTRACT ENDPOINTS
550
+ // ===============================
551
+ /**
552
+ * Get user's contracts
553
+ */
554
+ async getUserContracts(options) {
555
+ const params = new URLSearchParams();
556
+ if (options?.chainId) params.set("chainId", options.chainId.toString());
557
+ if (options?.limit) params.set("limit", options.limit.toString());
558
+ if (options?.offset) params.set("offset", options.offset.toString());
559
+ return this.request(`/api/v1/contracts?${params}`, { method: "GET" });
560
+ }
561
+ /**
562
+ * Get contract details
563
+ */
564
+ async getContractDetails(address, chainId) {
565
+ return this.request(`/api/v1/contracts/${address}?chainId=${chainId}`, { method: "GET" });
566
+ }
567
+ /**
568
+ * Read contract (call view function)
569
+ */
570
+ async readContract(params) {
571
+ return this.request("/api/v1/contracts/read", {
572
+ method: "POST",
573
+ body: JSON.stringify(params)
574
+ });
575
+ }
576
+ /**
577
+ * Write to contract (execute transaction)
578
+ */
579
+ async writeContract(params) {
580
+ return this.request("/api/v1/contracts/write", {
581
+ method: "POST",
582
+ body: JSON.stringify(params)
583
+ });
584
+ }
585
+ /**
586
+ * Deploy contract
587
+ */
588
+ async deployContract(params) {
589
+ return this.request("/api/v1/contracts/deploy", {
590
+ method: "POST",
591
+ body: JSON.stringify(params)
592
+ });
593
+ }
594
+ // ===============================
595
+ // OFFRAMP ENDPOINTS (Crypto-to-Fiat)
596
+ // ===============================
597
+ /**
598
+ * Get offramp quote
599
+ */
600
+ async getOfframpQuote(cryptoCurrency, cryptoAmount, fiatCurrency, payoutMethod) {
601
+ const params = new URLSearchParams({
602
+ cryptoCurrency,
603
+ cryptoAmount: cryptoAmount.toString(),
604
+ fiatCurrency
605
+ });
606
+ if (payoutMethod) params.set("payoutMethod", payoutMethod);
607
+ return this.request(`/api/v1/fiat/offramp/quote?${params}`, { method: "GET" });
608
+ }
609
+ /**
610
+ * Create offramp transaction
611
+ */
612
+ async createOfframpTransaction(request) {
613
+ return this.request("/api/v1/fiat/offramp", {
614
+ method: "POST",
615
+ body: JSON.stringify(request)
616
+ });
617
+ }
618
+ /**
619
+ * Get offramp transaction status
620
+ */
621
+ async getOfframpStatus(transactionId) {
622
+ return this.request(`/api/v1/fiat/offramp/${transactionId}`, { method: "GET" });
623
+ }
624
+ /**
625
+ * Get supported payout methods
626
+ */
627
+ async getSupportedPayoutMethods(country) {
628
+ const params = country ? `?country=${country}` : "";
629
+ return this.request(`/api/v1/fiat/offramp/methods${params}`, { method: "GET" });
630
+ }
631
+ // ===============================
632
+ // BILL PAYMENT ENDPOINTS
633
+ // ===============================
634
+ /**
635
+ * Get bill providers
636
+ */
637
+ async getBillProviders(country, category) {
638
+ const params = new URLSearchParams();
639
+ if (country) params.set("country", country);
640
+ if (category) params.set("category", category);
641
+ return this.request(`/api/v1/bills/providers?${params}`, { method: "GET" });
642
+ }
643
+ /**
644
+ * Get bill details/validate account
645
+ */
646
+ async validateBillAccount(providerId, accountNumber) {
647
+ return this.request("/api/v1/bills/validate", {
648
+ method: "POST",
649
+ body: JSON.stringify({ providerId, accountNumber })
650
+ });
651
+ }
652
+ /**
653
+ * Pay bill
654
+ */
655
+ async payBill(params) {
656
+ return this.request("/api/v1/bills/pay", {
657
+ method: "POST",
658
+ body: JSON.stringify(params)
659
+ });
660
+ }
661
+ /**
662
+ * Get bill payment history
663
+ */
664
+ async getBillHistory(options) {
665
+ const params = new URLSearchParams();
666
+ if (options?.limit) params.set("limit", options.limit.toString());
667
+ if (options?.offset) params.set("offset", options.offset.toString());
668
+ return this.request(`/api/v1/bills/history?${params}`, { method: "GET" });
669
+ }
670
+ // ===============================
671
+ // STAKING ENDPOINTS
672
+ // ===============================
673
+ /**
674
+ * Get staking pools
675
+ */
676
+ async getStakingPools(chainId) {
677
+ const params = chainId ? `?chainId=${chainId}` : "";
678
+ return this.request(`/api/v1/staking/pools${params}`, { method: "GET" });
679
+ }
680
+ /**
681
+ * Get user's staking positions
682
+ */
683
+ async getStakingPositions() {
684
+ return this.request("/api/v1/staking/positions", { method: "GET" });
685
+ }
686
+ /**
687
+ * Stake tokens
688
+ */
689
+ async stake(params) {
690
+ return this.request("/api/v1/staking/stake", {
691
+ method: "POST",
692
+ body: JSON.stringify(params)
693
+ });
694
+ }
695
+ /**
696
+ * Unstake tokens
697
+ */
698
+ async unstake(params) {
699
+ return this.request("/api/v1/staking/unstake", {
700
+ method: "POST",
701
+ body: JSON.stringify(params)
702
+ });
703
+ }
704
+ /**
705
+ * Claim staking rewards
706
+ */
707
+ async claimStakingRewards(positionId) {
708
+ return this.request("/api/v1/staking/claim", {
709
+ method: "POST",
710
+ body: JSON.stringify({ positionId })
711
+ });
712
+ }
713
+ // ===============================
714
+ // USER PROFILE ENDPOINTS
715
+ // ===============================
716
+ /**
717
+ * Get user profile
718
+ */
719
+ async getUserProfile() {
720
+ return this.request("/api/v1/user/profile", { method: "GET" });
721
+ }
722
+ /**
723
+ * Update user profile
724
+ */
725
+ async updateUserProfile(updates) {
726
+ return this.request("/api/v1/user/profile", {
727
+ method: "PATCH",
728
+ body: JSON.stringify(updates)
729
+ });
730
+ }
731
+ /**
732
+ * Get user settings
733
+ */
734
+ async getUserSettings() {
735
+ return this.request("/api/v1/user/settings", { method: "GET" });
736
+ }
737
+ /**
738
+ * Update user settings
739
+ */
740
+ async updateUserSettings(updates) {
741
+ return this.request("/api/v1/user/settings", {
742
+ method: "PATCH",
743
+ body: JSON.stringify(updates)
744
+ });
745
+ }
746
+ // ===============================
747
+ // NOTIFICATION ENDPOINTS
748
+ // ===============================
749
+ /**
750
+ * Get notifications
751
+ */
752
+ async getNotifications(options) {
753
+ const params = new URLSearchParams();
754
+ if (options?.unreadOnly) params.set("unreadOnly", "true");
755
+ if (options?.limit) params.set("limit", options.limit.toString());
756
+ if (options?.offset) params.set("offset", options.offset.toString());
757
+ return this.request(`/api/v1/notifications?${params}`, { method: "GET" });
758
+ }
759
+ /**
760
+ * Mark notification as read
761
+ */
762
+ async markNotificationRead(notificationId) {
763
+ return this.request(`/api/v1/notifications/${notificationId}/read`, { method: "POST" });
764
+ }
765
+ /**
766
+ * Mark all notifications as read
767
+ */
768
+ async markAllNotificationsRead() {
769
+ return this.request("/api/v1/notifications/read-all", { method: "POST" });
770
+ }
771
+ // ===============================
772
+ // REFERRAL ENDPOINTS
773
+ // ===============================
774
+ /**
775
+ * Get referral info
776
+ */
777
+ async getReferralInfo() {
778
+ return this.request("/api/v1/referral", { method: "GET" });
779
+ }
780
+ /**
781
+ * Get referred users
782
+ */
783
+ async getReferrals() {
784
+ return this.request("/api/v1/referral/list", { method: "GET" });
785
+ }
786
+ /**
787
+ * Apply referral code
788
+ */
789
+ async applyReferralCode(code) {
790
+ return this.request("/api/v1/referral/apply", {
791
+ method: "POST",
792
+ body: JSON.stringify({ code })
793
+ });
794
+ }
795
+ /**
796
+ * Claim referral rewards
797
+ */
798
+ async claimReferralRewards() {
799
+ return this.request("/api/v1/referral/claim", { method: "POST" });
800
+ }
801
+ // ===============================
802
+ // KYC ENDPOINTS
803
+ // ===============================
804
+ /**
805
+ * Get KYC status
806
+ */
807
+ async getKycStatus() {
808
+ return this.request("/api/v1/kyc/status", { method: "GET" });
809
+ }
810
+ /**
811
+ * Start KYC verification
812
+ */
813
+ async startKycVerification(level) {
814
+ return this.request("/api/v1/kyc/start", {
815
+ method: "POST",
816
+ body: JSON.stringify({ level })
817
+ });
818
+ }
819
+ /**
820
+ * Submit KYC documents
821
+ */
822
+ async submitKycDocuments(params) {
823
+ return this.request("/api/v1/kyc/submit", {
824
+ method: "POST",
825
+ body: JSON.stringify(params)
826
+ });
827
+ }
828
+ // ===============================
829
+ // BRIDGE ENDPOINTS
830
+ // ===============================
831
+ /**
832
+ * Get bridge quote
833
+ */
834
+ async getBridgeQuote(params) {
835
+ return this.request("/api/v1/bridge/quote", {
836
+ method: "POST",
837
+ body: JSON.stringify(params)
838
+ });
839
+ }
840
+ /**
841
+ * Execute bridge transaction
842
+ */
843
+ async executeBridge(params) {
844
+ return this.request("/api/v1/bridge/execute", {
845
+ method: "POST",
846
+ body: JSON.stringify(params)
847
+ });
848
+ }
849
+ /**
850
+ * Get bridge transaction status
851
+ */
852
+ async getBridgeStatus(bridgeId) {
853
+ return this.request(`/api/v1/bridge/${bridgeId}`, { method: "GET" });
854
+ }
855
+ /**
856
+ * Get supported bridge routes
857
+ */
858
+ async getSupportedBridgeRoutes() {
859
+ return this.request("/api/v1/bridge/routes", { method: "GET" });
860
+ }
861
+ // ===============================
862
+ // GAS ENDPOINTS
863
+ // ===============================
864
+ /**
865
+ * Get gas estimate for transaction
866
+ */
867
+ async getGasEstimate(params) {
868
+ return this.request("/api/v1/gas/estimate", {
869
+ method: "POST",
870
+ body: JSON.stringify(params)
871
+ });
872
+ }
873
+ /**
874
+ * Get current gas prices for chain
875
+ */
876
+ async getGasPrice(chainId) {
877
+ return this.request(`/api/v1/gas/price?chainId=${chainId}`, { method: "GET" });
878
+ }
879
+ // ===============================
880
+ // WALLET IMPORT/EXPORT ENDPOINTS
881
+ // ===============================
882
+ /**
883
+ * Import wallet from private key or mnemonic
884
+ */
885
+ async importWallet(request) {
886
+ return this.request("/api/v1/wallet/import", {
887
+ method: "POST",
888
+ body: JSON.stringify(request)
889
+ }, true);
890
+ }
891
+ /**
892
+ * Export wallet (get encrypted private key)
893
+ * Requires additional authentication
894
+ */
895
+ async exportWallet(walletId, pin) {
896
+ return this.request("/api/v1/wallet/export", {
897
+ method: "POST",
898
+ body: JSON.stringify({ walletId, pin })
899
+ }, true);
900
+ }
901
+ /**
902
+ * Generate new mnemonic phrase
903
+ */
904
+ async generateMnemonic() {
905
+ return this.request("/api/v1/wallet/generate-mnemonic", { method: "POST" }, true);
906
+ }
907
+ /**
908
+ * Validate mnemonic phrase
909
+ */
910
+ async validateMnemonic(mnemonic) {
911
+ return this.request("/api/v1/wallet/validate-mnemonic", {
912
+ method: "POST",
913
+ body: JSON.stringify({ mnemonic })
914
+ });
915
+ }
916
+ // ===============================
917
+ // PORTFOLIO ANALYTICS ENDPOINTS
918
+ // ===============================
919
+ /**
920
+ * Get portfolio analytics with historical data
921
+ */
922
+ async getPortfolioAnalytics(walletAddress, period = "30d") {
923
+ const params = new URLSearchParams({ address: walletAddress, period });
924
+ return this.request(`/api/v1/analytics/portfolio?${params}`, { method: "GET" });
925
+ }
926
+ /**
927
+ * Get transaction analytics
928
+ */
929
+ async getTransactionAnalytics(walletAddress, period = "30d") {
930
+ const params = new URLSearchParams({ address: walletAddress, period });
931
+ return this.request(`/api/v1/analytics/transactions?${params}`, { method: "GET" });
932
+ }
933
+ // ===============================
934
+ // ADVANCED TRADING ENDPOINTS
935
+ // ===============================
936
+ /**
937
+ * Create limit order
938
+ */
939
+ async createLimitOrder(params) {
940
+ return this.request("/api/v1/trading/limit-orders", {
941
+ method: "POST",
942
+ body: JSON.stringify(params)
943
+ });
944
+ }
945
+ /**
946
+ * Get user's limit orders
947
+ */
948
+ async getLimitOrders(status) {
949
+ const params = status ? `?status=${status}` : "";
950
+ return this.request(`/api/v1/trading/limit-orders${params}`, { method: "GET" });
951
+ }
952
+ /**
953
+ * Cancel limit order
954
+ */
955
+ async cancelLimitOrder(orderId) {
956
+ return this.request(`/api/v1/trading/limit-orders/${orderId}`, { method: "DELETE" });
957
+ }
958
+ /**
959
+ * Set price alert
960
+ */
961
+ async setPriceAlert(params) {
962
+ return this.request("/api/v1/trading/alerts", {
963
+ method: "POST",
964
+ body: JSON.stringify(params)
965
+ });
966
+ }
967
+ /**
968
+ * Get price alerts
969
+ */
970
+ async getPriceAlerts() {
971
+ return this.request("/api/v1/trading/alerts", { method: "GET" });
972
+ }
973
+ /**
974
+ * Delete price alert
975
+ */
976
+ async deletePriceAlert(alertId) {
977
+ return this.request(`/api/v1/trading/alerts/${alertId}`, { method: "DELETE" });
978
+ }
979
+ // ===============================
980
+ // SESSION MANAGEMENT
981
+ // ===============================
982
+ /**
983
+ * Get active sessions
984
+ */
985
+ async getActiveSessions() {
986
+ return this.request("/api/v1/auth/sessions", { method: "GET" });
987
+ }
988
+ /**
989
+ * Revoke session
990
+ */
991
+ async revokeSession(sessionId) {
992
+ return this.request(`/api/v1/auth/sessions/${sessionId}`, { method: "DELETE" });
993
+ }
994
+ /**
995
+ * Revoke all other sessions
996
+ */
997
+ async revokeAllOtherSessions() {
998
+ return this.request("/api/v1/auth/sessions/revoke-all", { method: "POST" });
999
+ }
1000
+ // ========== Webhooks ==========
1001
+ /**
1002
+ * List webhooks for the project
1003
+ */
1004
+ async listWebhooks(options) {
1005
+ const params = new URLSearchParams();
1006
+ if (options?.isActive !== void 0) params.set("isActive", String(options.isActive));
1007
+ const query = params.toString();
1008
+ return this.request(`/api/v1/webhooks${query ? `?${query}` : ""}`, { method: "GET" });
1009
+ }
1010
+ /**
1011
+ * Get webhook by ID
1012
+ */
1013
+ async getWebhook(webhookId) {
1014
+ return this.request(`/api/v1/webhooks/${webhookId}`, { method: "GET" });
1015
+ }
1016
+ /**
1017
+ * Create a webhook
1018
+ */
1019
+ async createWebhook(input) {
1020
+ return this.request("/api/v1/webhooks", {
1021
+ method: "POST",
1022
+ body: JSON.stringify(input)
1023
+ });
1024
+ }
1025
+ /**
1026
+ * Update a webhook
1027
+ */
1028
+ async updateWebhook(webhookId, input) {
1029
+ return this.request(`/api/v1/webhooks/${webhookId}`, {
1030
+ method: "PATCH",
1031
+ body: JSON.stringify(input)
1032
+ });
1033
+ }
1034
+ /**
1035
+ * Delete a webhook
1036
+ */
1037
+ async deleteWebhook(webhookId) {
1038
+ return this.request(`/api/v1/webhooks/${webhookId}`, { method: "DELETE" });
1039
+ }
1040
+ /**
1041
+ * Get webhook deliveries
1042
+ */
1043
+ async getWebhookDeliveries(webhookId, options) {
1044
+ const params = new URLSearchParams();
1045
+ if (options?.status) params.set("status", options.status);
1046
+ if (options?.limit) params.set("limit", String(options.limit));
1047
+ if (options?.offset) params.set("offset", String(options.offset));
1048
+ const query = params.toString();
1049
+ return this.request(`/api/v1/webhooks/${webhookId}/deliveries${query ? `?${query}` : ""}`, { method: "GET" });
1050
+ }
1051
+ /**
1052
+ * Test a webhook
1053
+ */
1054
+ async testWebhook(webhookId) {
1055
+ return this.request(`/api/v1/webhooks/${webhookId}/test`, { method: "POST" });
1056
+ }
1057
+ // ========== Admin (requires admin role) ==========
1058
+ /**
1059
+ * List all users (admin only)
1060
+ */
1061
+ async adminListUsers(options) {
1062
+ const params = new URLSearchParams();
1063
+ if (options?.page) params.set("page", String(options.page));
1064
+ if (options?.limit) params.set("limit", String(options.limit));
1065
+ if (options?.search) params.set("search", options.search);
1066
+ if (options?.sortBy) params.set("sortBy", options.sortBy);
1067
+ if (options?.sortOrder) params.set("sortOrder", options.sortOrder);
1068
+ if (options?.role) params.set("role", options.role);
1069
+ if (options?.kycStatus) params.set("kycStatus", options.kycStatus);
1070
+ if (options?.isActive !== void 0) params.set("isActive", String(options.isActive));
1071
+ const query = params.toString();
1072
+ return this.request(`/api/v1/admin/users${query ? `?${query}` : ""}`, { method: "GET" });
1073
+ }
1074
+ /**
1075
+ * Get user by ID (admin only)
1076
+ */
1077
+ async adminGetUser(userId) {
1078
+ return this.request(`/api/v1/admin/users/${userId}`, { method: "GET" });
1079
+ }
1080
+ /**
1081
+ * Update user (admin only)
1082
+ */
1083
+ async adminUpdateUser(userId, data) {
1084
+ return this.request(`/api/v1/admin/users/${userId}`, {
1085
+ method: "PATCH",
1086
+ body: JSON.stringify(data)
1087
+ });
1088
+ }
1089
+ /**
1090
+ * List all projects (admin only)
1091
+ */
1092
+ async adminListProjects(options) {
1093
+ const params = new URLSearchParams();
1094
+ if (options?.page) params.set("page", String(options.page));
1095
+ if (options?.limit) params.set("limit", String(options.limit));
1096
+ if (options?.search) params.set("search", options.search);
1097
+ if (options?.sortBy) params.set("sortBy", options.sortBy);
1098
+ if (options?.sortOrder) params.set("sortOrder", options.sortOrder);
1099
+ if (options?.isActive !== void 0) params.set("isActive", String(options.isActive));
1100
+ const query = params.toString();
1101
+ return this.request(`/api/v1/admin/projects${query ? `?${query}` : ""}`, { method: "GET" });
1102
+ }
1103
+ /**
1104
+ * Get project by ID (admin only)
1105
+ */
1106
+ async adminGetProject(projectId) {
1107
+ return this.request(`/api/v1/admin/projects/${projectId}`, { method: "GET" });
1108
+ }
1109
+ /**
1110
+ * Update project (admin only)
1111
+ */
1112
+ async adminUpdateProject(projectId, data) {
1113
+ return this.request(`/api/v1/admin/projects/${projectId}`, {
1114
+ method: "PATCH",
1115
+ body: JSON.stringify(data)
1116
+ });
1117
+ }
1118
+ /**
1119
+ * Regenerate project API key (admin only)
1120
+ */
1121
+ async adminRegenerateApiKey(projectId) {
1122
+ return this.request(`/api/v1/admin/projects/${projectId}/regenerate-key`, { method: "POST" });
1123
+ }
1124
+ /**
1125
+ * Get system statistics (admin only)
1126
+ */
1127
+ async adminGetStats(days) {
1128
+ const query = days ? `?days=${days}` : "";
1129
+ return this.request(`/api/v1/admin/stats${query}`, { method: "GET" });
1130
+ }
1131
+ /**
1132
+ * Get system logs (admin only)
1133
+ */
1134
+ async adminGetLogs(options) {
1135
+ const params = new URLSearchParams();
1136
+ if (options?.level) params.set("level", options.level);
1137
+ if (options?.service) params.set("service", options.service);
1138
+ if (options?.limit) params.set("limit", String(options.limit));
1139
+ if (options?.offset) params.set("offset", String(options.offset));
1140
+ if (options?.startDate) params.set("startDate", options.startDate);
1141
+ if (options?.endDate) params.set("endDate", options.endDate);
1142
+ const query = params.toString();
1143
+ return this.request(`/api/v1/admin/logs${query ? `?${query}` : ""}`, { method: "GET" });
1144
+ }
1145
+ /**
1146
+ * Get rate limit status (admin only)
1147
+ */
1148
+ async adminGetRateLimits(options) {
1149
+ const params = new URLSearchParams();
1150
+ if (options?.identifier) params.set("identifier", options.identifier);
1151
+ if (options?.limit) params.set("limit", String(options.limit));
1152
+ const query = params.toString();
1153
+ return this.request(`/api/v1/admin/rate-limits${query ? `?${query}` : ""}`, { method: "GET" });
1154
+ }
1155
+ /**
1156
+ * Clear rate limits for an identifier (admin only)
1157
+ */
1158
+ async adminClearRateLimits(identifier) {
1159
+ return this.request(`/api/v1/admin/rate-limits/${identifier}`, { method: "DELETE" });
1160
+ }
1161
+ // ========== AI Agent Configuration ==========
1162
+ /**
1163
+ * Get all AI agent configurations
1164
+ * This returns the full agent setup including tiers, cycles, and trading parameters
1165
+ */
1166
+ async getAgentConfigs(options) {
1167
+ const params = new URLSearchParams();
1168
+ if (options?.includeInactive) params.set("includeInactive", "true");
1169
+ if (options?.agentId) params.set("agentId", options.agentId);
1170
+ const query = params.toString();
1171
+ return this.request(`/api/v1/agents${query ? `?${query}` : ""}`, { method: "GET" });
1172
+ }
1173
+ /**
1174
+ * Calculate subscription parameters for an agent
1175
+ */
1176
+ async calculateAgentParams(params) {
1177
+ return this.request("/api/v1/agents/calculate", {
1178
+ method: "POST",
1179
+ body: JSON.stringify(params)
1180
+ });
1181
+ }
1182
+ /**
1183
+ * Get supported trading pairs from agents
1184
+ */
1185
+ async getTradingPairs() {
1186
+ const result = await this.getAgentConfigs();
1187
+ if (result.success && result.data?.agents) {
1188
+ const allPairs = /* @__PURE__ */ new Set();
1189
+ const byAgent = {};
1190
+ for (const agent of result.data.agents) {
1191
+ byAgent[agent.id] = agent.supported_pairs;
1192
+ agent.supported_pairs.forEach((p) => allPairs.add(p));
1193
+ }
1194
+ return { success: true, data: { pairs: Array.from(allPairs), byAgent } };
1195
+ }
1196
+ return { success: false, error: result.error };
1197
+ }
1198
+ // ========== AI Quant Trading ==========
1199
+ /**
1200
+ * Get all AI trading strategies
1201
+ */
1202
+ async getAIStrategies(filters) {
1203
+ const params = new URLSearchParams();
1204
+ if (filters?.category) params.set("category", filters.category);
1205
+ if (filters?.riskLevel) params.set("risk_level", String(filters.riskLevel));
1206
+ if (filters?.minTvl) params.set("min_tvl", String(filters.minTvl));
1207
+ if (filters?.isActive !== void 0) params.set("is_active", String(filters.isActive));
1208
+ const query = params.toString();
1209
+ return this.request(`/api/v1/ai-quant/strategies${query ? `?${query}` : ""}`, { method: "GET" });
1210
+ }
1211
+ /**
1212
+ * Get AI strategy details
1213
+ */
1214
+ async getAIStrategy(strategyId, include) {
1215
+ const params = new URLSearchParams();
1216
+ if (include?.length) params.set("include", include.join(","));
1217
+ const query = params.toString();
1218
+ return this.request(`/api/v1/ai-quant/strategies/${strategyId}${query ? `?${query}` : ""}`, { method: "GET" });
1219
+ }
1220
+ /**
1221
+ * Get strategy performance history
1222
+ */
1223
+ async getAIStrategyPerformance(strategyId, days = 30) {
1224
+ return this.request(`/api/v1/ai-quant/strategies/${strategyId}?include=performance&days=${days}`, { method: "GET" });
1225
+ }
1226
+ /**
1227
+ * Get real-time market data for strategy pairs
1228
+ */
1229
+ async getAIStrategyMarketData(strategyId) {
1230
+ return this.request(`/api/v1/ai-quant/strategies/${strategyId}?include=market`, { method: "GET" });
1231
+ }
1232
+ /**
1233
+ * Create AI trading order
1234
+ */
1235
+ async createAIOrder(request) {
1236
+ return this.request("/api/v1/ai-quant/orders", {
1237
+ method: "POST",
1238
+ body: JSON.stringify(request)
1239
+ });
1240
+ }
1241
+ /**
1242
+ * Get user's AI orders
1243
+ */
1244
+ async getAIOrders(filters) {
1245
+ const params = new URLSearchParams();
1246
+ if (filters?.strategyId) params.set("strategy_id", filters.strategyId);
1247
+ if (filters?.status) params.set("status", filters.status);
1248
+ const query = params.toString();
1249
+ return this.request(`/api/v1/ai-quant/orders${query ? `?${query}` : ""}`, { method: "GET" });
1250
+ }
1251
+ /**
1252
+ * Get AI order details
1253
+ */
1254
+ async getAIOrder(orderId) {
1255
+ return this.request(`/api/v1/ai-quant/orders/${orderId}`, { method: "GET" });
1256
+ }
1257
+ /**
1258
+ * Pause AI order
1259
+ */
1260
+ async pauseAIOrder(orderId) {
1261
+ return this.request(`/api/v1/ai-quant/orders/${orderId}/pause`, { method: "POST" });
1262
+ }
1263
+ /**
1264
+ * Resume AI order
1265
+ */
1266
+ async resumeAIOrder(orderId) {
1267
+ return this.request(`/api/v1/ai-quant/orders/${orderId}/resume`, { method: "POST" });
1268
+ }
1269
+ /**
1270
+ * Request redemption for AI order
1271
+ */
1272
+ async redeemAIOrder(orderId) {
1273
+ return this.request(`/api/v1/ai-quant/orders/${orderId}/redeem`, { method: "POST" });
1274
+ }
1275
+ /**
1276
+ * Get AI portfolio summary
1277
+ */
1278
+ async getAIPortfolio(include) {
1279
+ const params = new URLSearchParams();
1280
+ if (include?.length) params.set("include", include.join(","));
1281
+ const query = params.toString();
1282
+ return this.request(`/api/v1/ai-quant/portfolio${query ? `?${query}` : ""}`, { method: "GET" });
1283
+ }
1284
+ /**
1285
+ * Get user's trade allocations
1286
+ */
1287
+ async getAITradeAllocations(limit = 50) {
1288
+ return this.request(`/api/v1/ai-quant/portfolio?include=allocations&limit=${limit}`, { method: "GET" });
1289
+ }
1290
+ /**
1291
+ * Get trade history for a strategy
1292
+ */
1293
+ async getAITradeHistory(strategyId, limit = 50) {
1294
+ return this.request(`/api/v1/ai-quant/strategies/${strategyId}?include=trades&limit=${limit}`, { method: "GET" });
1295
+ }
1296
+ /**
1297
+ * Execute AI signals for a strategy (admin only)
1298
+ */
1299
+ async executeAISignals(strategyId) {
1300
+ return this.request("/api/v1/ai-quant/execute", {
1301
+ method: "POST",
1302
+ body: JSON.stringify({ strategyId })
1303
+ });
1304
+ }
1305
+ // ========== Free Price APIs (No API Key Required) ==========
1306
+ /**
1307
+ * Get cryptocurrency prices (FREE - uses CoinGecko/Binance/CoinCap)
1308
+ */
1309
+ async getCryptoPrices(symbols) {
1310
+ return this.request(`/api/v1/prices?symbols=${symbols.join(",")}`, { method: "GET" });
1311
+ }
1312
+ /**
1313
+ * Get single cryptocurrency price (FREE)
1314
+ */
1315
+ async getCryptoPrice(symbol) {
1316
+ return this.request(`/api/v1/prices/${symbol}`, { method: "GET" });
1317
+ }
1318
+ /**
1319
+ * Get OHLCV candles for charting (FREE - from Binance)
1320
+ */
1321
+ async getCryptoCandles(symbol, interval = "1h", limit = 100) {
1322
+ return this.request(`/api/v1/prices/${symbol}?candles=true&interval=${interval}&limit=${limit}`, { method: "GET" });
1323
+ }
1324
+ /**
1325
+ * Get top cryptocurrencies by market cap (FREE)
1326
+ */
1327
+ async getTopCryptos(limit = 20) {
1328
+ return this.request(`/api/v1/prices?type=top&limit=${limit}`, { method: "GET" });
1329
+ }
1330
+ /**
1331
+ * Get crypto market overview (FREE)
1332
+ */
1333
+ async getCryptoMarketOverview() {
1334
+ return this.request("/api/v1/prices?type=overview", { method: "GET" });
1335
+ }
1336
+ // ========== Project Management ==========
1337
+ /**
1338
+ * Get user's projects
1339
+ */
1340
+ async getProjects(options) {
1341
+ const params = new URLSearchParams();
1342
+ if (options?.isActive !== void 0) params.set("isActive", String(options.isActive));
1343
+ const query = params.toString();
1344
+ return this.request(`/api/v1/projects${query ? `?${query}` : ""}`, { method: "GET" });
1345
+ }
1346
+ /**
1347
+ * Create a new project for ecosystem partners
1348
+ */
1349
+ async createProject(params) {
1350
+ return this.request("/api/v1/projects", {
1351
+ method: "POST",
1352
+ body: JSON.stringify(params)
1353
+ });
1354
+ }
1355
+ /**
1356
+ * Get project details
1357
+ */
1358
+ async getProject(projectId) {
1359
+ return this.request(`/api/v1/projects/${projectId}`, { method: "GET" });
1360
+ }
1361
+ /**
1362
+ * Update project settings
1363
+ */
1364
+ async updateProject(projectId, updates) {
1365
+ return this.request(`/api/v1/projects/${projectId}`, {
1366
+ method: "PATCH",
1367
+ body: JSON.stringify(updates)
1368
+ });
1369
+ }
1370
+ /**
1371
+ * Get project features status
1372
+ */
1373
+ async getProjectFeatures(projectId) {
1374
+ return this.request(`/api/v1/projects/${projectId}/features`, { method: "GET" });
1375
+ }
1376
+ /**
1377
+ * Enable/disable features for a project
1378
+ */
1379
+ async updateProjectFeatures(projectId, features) {
1380
+ return this.request(`/api/v1/projects/${projectId}/features`, {
1381
+ method: "PATCH",
1382
+ body: JSON.stringify(features)
1383
+ });
1384
+ }
1385
+ /**
1386
+ * Regenerate project API key
1387
+ */
1388
+ async regenerateProjectApiKey(projectId) {
1389
+ return this.request(`/api/v1/projects/${projectId}/api-key`, { method: "POST" });
1390
+ }
1391
+ /**
1392
+ * Delete project
1393
+ */
1394
+ async deleteProject(projectId) {
1395
+ return this.request(`/api/v1/projects/${projectId}`, { method: "DELETE" });
1396
+ }
1397
+ };
1398
+ function createOneEngineClient(options) {
1399
+ return new OneEngineClient(options);
1400
+ }
1401
+
1402
+ // src/services/price.ts
1403
+ var COINGECKO_API = "https://api.coingecko.com/api/v3";
1404
+ var FALLBACK_PRICES = {
1405
+ ETH: 3500,
1406
+ BTC: 95e3,
1407
+ BNB: 700,
1408
+ MATIC: 0.5,
1409
+ AVAX: 40,
1410
+ USDT: 1,
1411
+ USDC: 1,
1412
+ DAI: 1,
1413
+ WBTC: 95e3,
1414
+ WETH: 3500,
1415
+ ARB: 1.2,
1416
+ OP: 2.5,
1417
+ LINK: 20,
1418
+ UNI: 12,
1419
+ AAVE: 250,
1420
+ SOL: 200
1421
+ };
1422
+ var PriceService = class {
1423
+ constructor() {
1424
+ this.cache = /* @__PURE__ */ new Map();
1425
+ this.cacheTTL = 60 * 1e3;
1426
+ }
1427
+ // 1 minute cache
1428
+ async getPrice(symbol) {
1429
+ const upperSymbol = symbol.toUpperCase();
1430
+ const cached = this.cache.get(upperSymbol);
1431
+ if (cached && Date.now() - cached.timestamp < this.cacheTTL) {
1432
+ return cached.price;
1433
+ }
1434
+ const coinId = COINGECKO_IDS[upperSymbol];
1435
+ if (!coinId) {
1436
+ return this.getFallbackPrice(upperSymbol);
1437
+ }
1438
+ try {
1439
+ const response = await fetch(
1440
+ `${COINGECKO_API}/simple/price?ids=${coinId}&vs_currencies=usd&include_24hr_change=true&include_market_cap=true&include_24hr_vol=true`,
1441
+ { headers: { Accept: "application/json" } }
1442
+ );
1443
+ if (!response.ok) {
1444
+ throw new Error(`CoinGecko API error: ${response.status}`);
1445
+ }
1446
+ const data = await response.json();
1447
+ const coinData = data[coinId];
1448
+ if (!coinData) {
1449
+ return this.getFallbackPrice(upperSymbol);
1450
+ }
1451
+ const change24h = coinData.usd_24h_change || 0;
1452
+ const price = {
1453
+ symbol: upperSymbol,
1454
+ price: coinData.usd || 0,
1455
+ change24h,
1456
+ changePercent24h: change24h,
1457
+ priceChange24h: change24h,
1458
+ marketCap: coinData.usd_market_cap,
1459
+ volume24h: coinData.usd_24h_vol
1460
+ };
1461
+ this.cache.set(upperSymbol, { price, timestamp: Date.now() });
1462
+ return price;
1463
+ } catch (error) {
1464
+ console.warn(`Failed to fetch price for ${upperSymbol}:`, error);
1465
+ return this.getFallbackPrice(upperSymbol);
1466
+ }
1467
+ }
1468
+ async getPrices(symbols) {
1469
+ const results = {};
1470
+ const withIds = [];
1471
+ const withoutIds = [];
1472
+ for (const symbol of symbols) {
1473
+ const upper = symbol.toUpperCase();
1474
+ if (COINGECKO_IDS[upper]) {
1475
+ withIds.push(upper);
1476
+ } else {
1477
+ withoutIds.push(upper);
1478
+ }
1479
+ }
1480
+ for (const symbol of withoutIds) {
1481
+ results[symbol] = this.getFallbackPrice(symbol);
1482
+ }
1483
+ if (withIds.length === 0) {
1484
+ return results;
1485
+ }
1486
+ const coinIds = withIds.map((s) => COINGECKO_IDS[s]).join(",");
1487
+ try {
1488
+ const response = await fetch(
1489
+ `${COINGECKO_API}/simple/price?ids=${coinIds}&vs_currencies=usd&include_24hr_change=true`,
1490
+ { headers: { Accept: "application/json" } }
1491
+ );
1492
+ if (!response.ok) {
1493
+ throw new Error(`CoinGecko API error: ${response.status}`);
1494
+ }
1495
+ const data = await response.json();
1496
+ for (const symbol of withIds) {
1497
+ const coinId = COINGECKO_IDS[symbol];
1498
+ const coinData = data[coinId];
1499
+ if (coinData) {
1500
+ const change24h = coinData.usd_24h_change || 0;
1501
+ results[symbol] = {
1502
+ symbol,
1503
+ price: coinData.usd || 0,
1504
+ change24h,
1505
+ changePercent24h: change24h,
1506
+ priceChange24h: change24h
1507
+ };
1508
+ } else {
1509
+ results[symbol] = this.getFallbackPrice(symbol);
1510
+ }
1511
+ }
1512
+ } catch (error) {
1513
+ console.warn("Failed to fetch batch prices:", error);
1514
+ for (const symbol of withIds) {
1515
+ results[symbol] = this.getFallbackPrice(symbol);
1516
+ }
1517
+ }
1518
+ return results;
1519
+ }
1520
+ getFallbackPrice(symbol) {
1521
+ const price = FALLBACK_PRICES[symbol] || 0;
1522
+ return {
1523
+ symbol,
1524
+ price,
1525
+ change24h: 0,
1526
+ changePercent24h: 0,
1527
+ priceChange24h: 0
1528
+ };
1529
+ }
1530
+ clearCache() {
1531
+ this.cache.clear();
1532
+ }
1533
+ };
1534
+ var priceService = new PriceService();
1535
+
1536
+ // src/utils/index.ts
1537
+ function shortenAddress(address, chars = 4) {
1538
+ if (!address) return "";
1539
+ return `${address.slice(0, chars + 2)}...${address.slice(-chars)}`;
1540
+ }
1541
+ function isValidAddress(address) {
1542
+ return /^0x[a-fA-F0-9]{40}$/.test(address);
1543
+ }
1544
+ function checksumAddress(address) {
1545
+ return address.toLowerCase();
1546
+ }
1547
+ function formatNumber(value, options = {}) {
1548
+ const { decimals = 2, compact = false, currency, locale = "en-US" } = options;
1549
+ if (currency) {
1550
+ return new Intl.NumberFormat(locale, {
1551
+ style: "currency",
1552
+ currency,
1553
+ minimumFractionDigits: decimals,
1554
+ maximumFractionDigits: decimals,
1555
+ notation: compact ? "compact" : "standard"
1556
+ }).format(value);
1557
+ }
1558
+ return new Intl.NumberFormat(locale, {
1559
+ minimumFractionDigits: decimals,
1560
+ maximumFractionDigits: decimals,
1561
+ notation: compact ? "compact" : "standard"
1562
+ }).format(value);
1563
+ }
1564
+ function formatUSD(value, compact = false) {
1565
+ return formatNumber(value, { currency: "USD", compact });
1566
+ }
1567
+ function formatPercent(value, decimals = 2) {
1568
+ const sign = value >= 0 ? "+" : "";
1569
+ return `${sign}${value.toFixed(decimals)}%`;
1570
+ }
1571
+ function formatTokenAmount(amount, decimals = 6) {
1572
+ if (amount === 0) return "0";
1573
+ if (amount < 1e-6) return "<0.000001";
1574
+ if (amount < 1) return amount.toFixed(decimals);
1575
+ if (amount < 1e3) return amount.toFixed(4);
1576
+ if (amount < 1e6) return formatNumber(amount, { decimals: 2 });
1577
+ return formatNumber(amount, { decimals: 2, compact: true });
1578
+ }
1579
+ function formatDate(date, options = {
1580
+ year: "numeric",
1581
+ month: "short",
1582
+ day: "numeric"
1583
+ }) {
1584
+ const d = typeof date === "string" ? new Date(date) : date;
1585
+ return d.toLocaleDateString("en-US", options);
1586
+ }
1587
+ function formatDateTime(date) {
1588
+ const d = typeof date === "string" ? new Date(date) : date;
1589
+ return d.toLocaleString("en-US", {
1590
+ year: "numeric",
1591
+ month: "short",
1592
+ day: "numeric",
1593
+ hour: "2-digit",
1594
+ minute: "2-digit"
1595
+ });
1596
+ }
1597
+ function formatRelativeTime(date) {
1598
+ const d = typeof date === "string" ? new Date(date) : date;
1599
+ const now = /* @__PURE__ */ new Date();
1600
+ const diffMs = now.getTime() - d.getTime();
1601
+ const diffSec = Math.floor(diffMs / 1e3);
1602
+ const diffMin = Math.floor(diffSec / 60);
1603
+ const diffHour = Math.floor(diffMin / 60);
1604
+ const diffDay = Math.floor(diffHour / 24);
1605
+ if (diffSec < 60) return "just now";
1606
+ if (diffMin < 60) return `${diffMin}m ago`;
1607
+ if (diffHour < 24) return `${diffHour}h ago`;
1608
+ if (diffDay < 7) return `${diffDay}d ago`;
1609
+ return formatDate(d);
1610
+ }
1611
+ function isValidEmail(email) {
1612
+ const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
1613
+ return emailRegex.test(email);
1614
+ }
1615
+ function isValidPhone(phone) {
1616
+ const phoneRegex = /^\+?[1-9]\d{1,14}$/;
1617
+ return phoneRegex.test(phone.replace(/[\s-()]/g, ""));
1618
+ }
1619
+ function capitalize(str) {
1620
+ return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();
1621
+ }
1622
+ function truncate(str, length) {
1623
+ if (str.length <= length) return str;
1624
+ return `${str.slice(0, length)}...`;
1625
+ }
1626
+ function slugify(str) {
1627
+ return str.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/(^-|-$)/g, "");
1628
+ }
1629
+ function sleep(ms) {
1630
+ return new Promise((resolve) => setTimeout(resolve, ms));
1631
+ }
1632
+ async function retry(fn, options = {}) {
1633
+ const { maxAttempts = 3, delay = 1e3, backoff = 2 } = options;
1634
+ let lastError;
1635
+ for (let attempt = 1; attempt <= maxAttempts; attempt++) {
1636
+ try {
1637
+ return await fn();
1638
+ } catch (error) {
1639
+ lastError = error instanceof Error ? error : new Error(String(error));
1640
+ if (attempt < maxAttempts) {
1641
+ await sleep(delay * Math.pow(backoff, attempt - 1));
1642
+ }
1643
+ }
1644
+ }
1645
+ throw lastError;
1646
+ }
1647
+ function omit(obj, keys) {
1648
+ const result = { ...obj };
1649
+ for (const key of keys) {
1650
+ delete result[key];
1651
+ }
1652
+ return result;
1653
+ }
1654
+ function pick(obj, keys) {
1655
+ const result = {};
1656
+ for (const key of keys) {
1657
+ if (key in obj) {
1658
+ result[key] = obj[key];
1659
+ }
1660
+ }
1661
+ return result;
1662
+ }
1663
+ var OneSDKError = class extends Error {
1664
+ constructor(message, code, details) {
1665
+ super(message);
1666
+ this.name = "OneSDKError";
1667
+ this.code = code;
1668
+ this.details = details;
1669
+ }
1670
+ };
1671
+ function isOneSDKError(error) {
1672
+ return error instanceof OneSDKError;
1673
+ }
1674
+ var CHAIN_CONFIG = {
1675
+ ethereum: { name: "Ethereum", icon: "\u039E", color: "#627EEA" },
1676
+ arbitrum: { name: "Arbitrum", icon: "\u25C6", color: "#28A0F0" },
1677
+ bsc: { name: "BSC", icon: "\u25C6", color: "#F3BA2F" },
1678
+ base: { name: "Base", icon: "\u25CF", color: "#0052FF" },
1679
+ polygon: { name: "Polygon", icon: "\u2B21", color: "#8247E5" },
1680
+ optimism: { name: "Optimism", icon: "\u25C9", color: "#FF0420" },
1681
+ avalanche: { name: "Avalanche", icon: "\u25B2", color: "#E84142" },
1682
+ linea: { name: "Linea", icon: "\u2550", color: "#121212" },
1683
+ zksync: { name: "zkSync", icon: "\u2B22", color: "#8C8DFC" },
1684
+ scroll: { name: "Scroll", icon: "\u25CE", color: "#FFEEDA" }
1685
+ };
1686
+ var OneChainSelector = ({
1687
+ supportedChains,
1688
+ selectedChains,
1689
+ onSelectChain,
1690
+ multiSelect = true,
1691
+ accentColor = "#188775",
1692
+ title,
1693
+ subtitle,
1694
+ minSelections = 1,
1695
+ style,
1696
+ titleStyle
1697
+ }) => {
1698
+ const handleSelect = (chain) => {
1699
+ if (multiSelect) {
1700
+ if (selectedChains.includes(chain) && selectedChains.length <= minSelections) {
1701
+ return;
1702
+ }
1703
+ onSelectChain(chain);
1704
+ } else {
1705
+ if (!selectedChains.includes(chain)) {
1706
+ onSelectChain(chain);
1707
+ }
1708
+ }
1709
+ };
1710
+ return /* @__PURE__ */ jsxs(View, { style: [styles.container, style], children: [
1711
+ title && /* @__PURE__ */ jsx(Text, { style: [styles.title, titleStyle], children: title }),
1712
+ subtitle && /* @__PURE__ */ jsx(Text, { style: styles.subtitle, children: subtitle }),
1713
+ /* @__PURE__ */ jsx(View, { style: styles.chainsContainer, children: supportedChains.map((chain) => {
1714
+ const chainInfo = CHAIN_CONFIG[chain] || { name: chain, icon: "\u25CF", color: "#888" };
1715
+ const isSelected = selectedChains.includes(chain);
1716
+ return /* @__PURE__ */ jsxs(
1717
+ TouchableOpacity,
1718
+ {
1719
+ style: [
1720
+ styles.chainChip,
1721
+ isSelected && styles.chainChipSelected,
1722
+ isSelected && { borderColor: accentColor, backgroundColor: accentColor + "15" }
1723
+ ],
1724
+ onPress: () => handleSelect(chain),
1725
+ activeOpacity: 0.7,
1726
+ children: [
1727
+ /* @__PURE__ */ jsx(View, { style: [styles.chainIconBg, { backgroundColor: chainInfo.color + "20" }], children: /* @__PURE__ */ jsx(Text, { style: [styles.chainIcon, { color: chainInfo.color }], children: chainInfo.icon }) }),
1728
+ /* @__PURE__ */ jsx(Text, { style: [
1729
+ styles.chainText,
1730
+ isSelected && { color: accentColor, fontWeight: "600" }
1731
+ ], children: chainInfo.name }),
1732
+ isSelected && /* @__PURE__ */ jsx(Text, { style: [styles.checkmark, { color: accentColor }], children: "\u2713" })
1733
+ ]
1734
+ },
1735
+ chain
1736
+ );
1737
+ }) }),
1738
+ multiSelect && selectedChains.length > 0 && /* @__PURE__ */ jsx(View, { style: styles.selectedInfo, children: /* @__PURE__ */ jsxs(Text, { style: styles.selectedText, children: [
1739
+ selectedChains.length,
1740
+ " chain",
1741
+ selectedChains.length > 1 ? "s" : "",
1742
+ " selected"
1743
+ ] }) })
1744
+ ] });
1745
+ };
1746
+ var styles = StyleSheet.create({
1747
+ container: {
1748
+ marginBottom: 16
1749
+ },
1750
+ title: {
1751
+ fontSize: 16,
1752
+ fontWeight: "600",
1753
+ color: "#1a1a1a",
1754
+ marginBottom: 4
1755
+ },
1756
+ subtitle: {
1757
+ fontSize: 12,
1758
+ color: "#666",
1759
+ marginBottom: 12
1760
+ },
1761
+ chainsContainer: {
1762
+ flexDirection: "row",
1763
+ flexWrap: "wrap",
1764
+ gap: 8
1765
+ },
1766
+ chainChip: {
1767
+ flexDirection: "row",
1768
+ alignItems: "center",
1769
+ paddingHorizontal: 12,
1770
+ paddingVertical: 8,
1771
+ backgroundColor: "#fff",
1772
+ borderRadius: 12,
1773
+ borderWidth: 2,
1774
+ borderColor: "#e5e5e5",
1775
+ gap: 8
1776
+ },
1777
+ chainChipSelected: {
1778
+ borderWidth: 2
1779
+ },
1780
+ chainIconBg: {
1781
+ width: 28,
1782
+ height: 28,
1783
+ borderRadius: 14,
1784
+ alignItems: "center",
1785
+ justifyContent: "center"
1786
+ },
1787
+ chainIcon: {
1788
+ fontSize: 14,
1789
+ fontWeight: "700"
1790
+ },
1791
+ chainText: {
1792
+ fontSize: 14,
1793
+ color: "#666"
1794
+ },
1795
+ checkmark: {
1796
+ fontSize: 16,
1797
+ fontWeight: "700"
1798
+ },
1799
+ selectedInfo: {
1800
+ marginTop: 8,
1801
+ paddingVertical: 4
1802
+ },
1803
+ selectedText: {
1804
+ fontSize: 12,
1805
+ color: "#888"
1806
+ }
1807
+ });
1808
+ var OneTierSelector = ({
1809
+ tiers,
1810
+ selectedTier,
1811
+ onSelectTier,
1812
+ accentColor = "#188775",
1813
+ title,
1814
+ subtitle,
1815
+ showRecommended = true,
1816
+ recommendedLabel = "Recommended",
1817
+ useZhLabels = false,
1818
+ style,
1819
+ titleStyle
1820
+ }) => {
1821
+ const recommendedTierIndex = Math.floor(tiers.length / 2);
1822
+ return /* @__PURE__ */ jsxs(View, { style: [styles2.container, style], children: [
1823
+ title && /* @__PURE__ */ jsx(Text, { style: [styles2.title, titleStyle], children: title }),
1824
+ subtitle && /* @__PURE__ */ jsx(Text, { style: styles2.subtitle, children: subtitle }),
1825
+ /* @__PURE__ */ jsx(View, { style: styles2.tiersContainer, children: tiers.map((tier, index) => {
1826
+ const isSelected = selectedTier?.tier === tier.tier;
1827
+ const isRecommended = showRecommended && index === recommendedTierIndex;
1828
+ return /* @__PURE__ */ jsxs(
1829
+ TouchableOpacity,
1830
+ {
1831
+ style: [
1832
+ styles2.tierCard,
1833
+ isSelected && styles2.tierCardSelected,
1834
+ isSelected && { borderColor: accentColor }
1835
+ ],
1836
+ onPress: () => onSelectTier(tier),
1837
+ activeOpacity: 0.7,
1838
+ children: [
1839
+ isRecommended && /* @__PURE__ */ jsx(View, { style: [styles2.recommendedBadge, { backgroundColor: accentColor }], children: /* @__PURE__ */ jsx(Text, { style: styles2.recommendedText, children: recommendedLabel }) }),
1840
+ /* @__PURE__ */ jsx(Text, { style: [
1841
+ styles2.tierLabel,
1842
+ isSelected && { color: accentColor },
1843
+ isRecommended && styles2.tierLabelWithBadge
1844
+ ], children: useZhLabels && tier.label_zh ? tier.label_zh : tier.label }),
1845
+ /* @__PURE__ */ jsxs(Text, { style: [
1846
+ styles2.tierAmount,
1847
+ isSelected && { color: accentColor }
1848
+ ], children: [
1849
+ "$",
1850
+ tier.amount.toLocaleString()
1851
+ ] }),
1852
+ isSelected && /* @__PURE__ */ jsx(View, { style: [styles2.checkCircle, { backgroundColor: accentColor }], children: /* @__PURE__ */ jsx(Text, { style: styles2.checkmark, children: "\u2713" }) })
1853
+ ]
1854
+ },
1855
+ tier.tier
1856
+ );
1857
+ }) })
1858
+ ] });
1859
+ };
1860
+ var styles2 = StyleSheet.create({
1861
+ container: {
1862
+ marginBottom: 16
1863
+ },
1864
+ title: {
1865
+ fontSize: 16,
1866
+ fontWeight: "600",
1867
+ color: "#1a1a1a",
1868
+ marginBottom: 4
1869
+ },
1870
+ subtitle: {
1871
+ fontSize: 12,
1872
+ color: "#666",
1873
+ marginBottom: 12
1874
+ },
1875
+ tiersContainer: {
1876
+ flexDirection: "row",
1877
+ gap: 8
1878
+ },
1879
+ tierCard: {
1880
+ flex: 1,
1881
+ padding: 16,
1882
+ backgroundColor: "#fff",
1883
+ borderRadius: 12,
1884
+ borderWidth: 2,
1885
+ borderColor: "#e5e5e5",
1886
+ alignItems: "center",
1887
+ position: "relative",
1888
+ overflow: "hidden"
1889
+ },
1890
+ tierCardSelected: {
1891
+ backgroundColor: "#fff"
1892
+ },
1893
+ tierLabel: {
1894
+ fontSize: 12,
1895
+ color: "#666",
1896
+ marginBottom: 4
1897
+ },
1898
+ tierLabelWithBadge: {
1899
+ marginTop: 16
1900
+ },
1901
+ tierAmount: {
1902
+ fontSize: 20,
1903
+ fontWeight: "700",
1904
+ color: "#1a1a1a"
1905
+ },
1906
+ checkCircle: {
1907
+ position: "absolute",
1908
+ top: -8,
1909
+ right: -8,
1910
+ width: 28,
1911
+ height: 28,
1912
+ borderRadius: 14,
1913
+ alignItems: "center",
1914
+ justifyContent: "center"
1915
+ },
1916
+ checkmark: {
1917
+ fontSize: 14,
1918
+ fontWeight: "700",
1919
+ color: "#fff"
1920
+ },
1921
+ recommendedBadge: {
1922
+ position: "absolute",
1923
+ top: 0,
1924
+ left: 0,
1925
+ right: 0,
1926
+ paddingVertical: 4,
1927
+ alignItems: "center"
1928
+ },
1929
+ recommendedText: {
1930
+ fontSize: 10,
1931
+ fontWeight: "700",
1932
+ color: "#fff",
1933
+ textTransform: "uppercase"
1934
+ }
1935
+ });
1936
+ var DEFAULT_SHARE_RATES = {
1937
+ 7: 25,
1938
+ 14: 22,
1939
+ 30: 18,
1940
+ 60: 15,
1941
+ 90: 12
1942
+ };
1943
+ var OneCycleSelector = ({
1944
+ supportedCycles,
1945
+ selectedCycle,
1946
+ onSelectCycle,
1947
+ accentColor = "#188775",
1948
+ title,
1949
+ subtitle,
1950
+ shareRates = DEFAULT_SHARE_RATES,
1951
+ daysLabel = "days",
1952
+ yourShareLabel = "Your share",
1953
+ platformFeeLabel = "Platform fee",
1954
+ style,
1955
+ titleStyle
1956
+ }) => {
1957
+ return /* @__PURE__ */ jsxs(View, { style: [styles3.container, style], children: [
1958
+ title && /* @__PURE__ */ jsx(Text, { style: [styles3.title, titleStyle], children: title }),
1959
+ subtitle && /* @__PURE__ */ jsx(Text, { style: styles3.subtitle, children: subtitle }),
1960
+ /* @__PURE__ */ jsx(View, { style: styles3.cyclesContainer, children: supportedCycles.map((cycle) => {
1961
+ const isSelected = selectedCycle === cycle;
1962
+ const shareRate = shareRates[cycle] || 20;
1963
+ const userRate = 100 - shareRate;
1964
+ return /* @__PURE__ */ jsxs(
1965
+ TouchableOpacity,
1966
+ {
1967
+ style: [
1968
+ styles3.cycleOption,
1969
+ isSelected && styles3.cycleOptionSelected,
1970
+ isSelected && { borderColor: accentColor, backgroundColor: accentColor + "10" }
1971
+ ],
1972
+ onPress: () => onSelectCycle(cycle),
1973
+ activeOpacity: 0.7,
1974
+ children: [
1975
+ /* @__PURE__ */ jsx(Text, { style: [
1976
+ styles3.cycleDays,
1977
+ isSelected && { color: accentColor }
1978
+ ], children: cycle }),
1979
+ /* @__PURE__ */ jsx(Text, { style: styles3.cycleDaysLabel, children: daysLabel }),
1980
+ /* @__PURE__ */ jsxs(View, { style: styles3.cycleEarnings, children: [
1981
+ /* @__PURE__ */ jsxs(Text, { style: [
1982
+ styles3.cycleEarningsValue,
1983
+ isSelected && { color: accentColor }
1984
+ ], children: [
1985
+ userRate,
1986
+ "%"
1987
+ ] }),
1988
+ /* @__PURE__ */ jsx(Text, { style: styles3.cycleEarningsLabel, children: yourShareLabel })
1989
+ ] }),
1990
+ /* @__PURE__ */ jsxs(Text, { style: styles3.cycleFee, children: [
1991
+ shareRate,
1992
+ "% ",
1993
+ platformFeeLabel
1994
+ ] })
1995
+ ]
1996
+ },
1997
+ cycle
1998
+ );
1999
+ }) }),
2000
+ /* @__PURE__ */ jsx(View, { style: styles3.infoBox, children: /* @__PURE__ */ jsx(Text, { style: styles3.infoText, children: "Longer cycles = higher user share" }) })
2001
+ ] });
2002
+ };
2003
+ var styles3 = StyleSheet.create({
2004
+ container: {
2005
+ marginBottom: 16
2006
+ },
2007
+ title: {
2008
+ fontSize: 16,
2009
+ fontWeight: "600",
2010
+ color: "#1a1a1a",
2011
+ marginBottom: 4
2012
+ },
2013
+ subtitle: {
2014
+ fontSize: 12,
2015
+ color: "#666",
2016
+ marginBottom: 12
2017
+ },
2018
+ cyclesContainer: {
2019
+ flexDirection: "row",
2020
+ flexWrap: "wrap",
2021
+ gap: 8
2022
+ },
2023
+ cycleOption: {
2024
+ flex: 1,
2025
+ minWidth: "45%",
2026
+ padding: 16,
2027
+ borderRadius: 12,
2028
+ borderWidth: 2,
2029
+ borderColor: "#e5e5e5",
2030
+ backgroundColor: "#fff",
2031
+ alignItems: "center"
2032
+ },
2033
+ cycleOptionSelected: {
2034
+ borderWidth: 2
2035
+ },
2036
+ cycleDays: {
2037
+ fontSize: 28,
2038
+ fontWeight: "700",
2039
+ color: "#1a1a1a"
2040
+ },
2041
+ cycleDaysLabel: {
2042
+ fontSize: 12,
2043
+ color: "#666",
2044
+ marginBottom: 8
2045
+ },
2046
+ cycleEarnings: {
2047
+ alignItems: "center"
2048
+ },
2049
+ cycleEarningsValue: {
2050
+ fontSize: 18,
2051
+ fontWeight: "700",
2052
+ color: "#10B981"
2053
+ },
2054
+ cycleEarningsLabel: {
2055
+ fontSize: 11,
2056
+ color: "#666"
2057
+ },
2058
+ cycleFee: {
2059
+ fontSize: 11,
2060
+ color: "#888",
2061
+ marginTop: 4
2062
+ },
2063
+ infoBox: {
2064
+ marginTop: 12,
2065
+ padding: 8,
2066
+ backgroundColor: "#f5f5f5",
2067
+ borderRadius: 8
2068
+ },
2069
+ infoText: {
2070
+ fontSize: 12,
2071
+ color: "#666",
2072
+ textAlign: "center"
2073
+ }
2074
+ });
2075
+ var PAIR_ICONS = {
2076
+ "BTC/USDT": "\u20BF",
2077
+ "ETH/USDT": "\u039E",
2078
+ "SOL/USDT": "\u25CE",
2079
+ "BNB/USDT": "\u25C6",
2080
+ "XRP/USDT": "\u2715",
2081
+ "DOGE/USDT": "\xD0",
2082
+ "ADA/USDT": "\u25C8",
2083
+ "AVAX/USDT": "\u25B2",
2084
+ "DOT/USDT": "\u25CF",
2085
+ "MATIC/USDT": "\u2B21",
2086
+ "LINK/USDT": "\u25C7",
2087
+ "UNI/USDT": "\u{1F984}",
2088
+ "ATOM/USDT": "\u269B",
2089
+ "LTC/USDT": "\u0141",
2090
+ "ARB/USDT": "\u25C6",
2091
+ "OP/USDT": "\u25C9"
2092
+ };
2093
+ var OnePairSelector = ({
2094
+ supportedPairs,
2095
+ selectedPairs,
2096
+ onTogglePair,
2097
+ accentColor = "#188775",
2098
+ title,
2099
+ subtitle,
2100
+ minSelections = 1,
2101
+ maxSelections = 0,
2102
+ style,
2103
+ titleStyle
2104
+ }) => {
2105
+ const handleToggle = (pair) => {
2106
+ const isSelected = selectedPairs.includes(pair);
2107
+ if (isSelected && selectedPairs.length <= minSelections) {
2108
+ return;
2109
+ }
2110
+ if (!isSelected && maxSelections > 0 && selectedPairs.length >= maxSelections) {
2111
+ return;
2112
+ }
2113
+ onTogglePair(pair);
2114
+ };
2115
+ return /* @__PURE__ */ jsxs(View, { style: [styles4.container, style], children: [
2116
+ title && /* @__PURE__ */ jsx(Text, { style: [styles4.title, titleStyle], children: title }),
2117
+ subtitle && /* @__PURE__ */ jsx(Text, { style: styles4.subtitle, children: subtitle }),
2118
+ /* @__PURE__ */ jsx(View, { style: styles4.pairsContainer, children: supportedPairs.map((pair) => {
2119
+ const isSelected = selectedPairs.includes(pair);
2120
+ const icon = PAIR_ICONS[pair] || "\u25CF";
2121
+ const baseSymbol = pair.split("/")[0];
2122
+ return /* @__PURE__ */ jsxs(
2123
+ TouchableOpacity,
2124
+ {
2125
+ style: [
2126
+ styles4.pairChip,
2127
+ isSelected && styles4.pairChipSelected,
2128
+ isSelected && { backgroundColor: accentColor + "15", borderColor: accentColor }
2129
+ ],
2130
+ onPress: () => handleToggle(pair),
2131
+ activeOpacity: 0.7,
2132
+ children: [
2133
+ /* @__PURE__ */ jsx(Text, { style: styles4.pairIcon, children: icon }),
2134
+ /* @__PURE__ */ jsx(Text, { style: [
2135
+ styles4.pairText,
2136
+ isSelected && { color: accentColor, fontWeight: "600" }
2137
+ ], children: baseSymbol }),
2138
+ isSelected && /* @__PURE__ */ jsx(Text, { style: [styles4.checkmark, { color: accentColor }], children: "\u2713" })
2139
+ ]
2140
+ },
2141
+ pair
2142
+ );
2143
+ }) }),
2144
+ /* @__PURE__ */ jsx(View, { style: styles4.selectedInfo, children: /* @__PURE__ */ jsxs(Text, { style: styles4.selectedText, children: [
2145
+ selectedPairs.length,
2146
+ " pair",
2147
+ selectedPairs.length !== 1 ? "s" : "",
2148
+ " selected",
2149
+ minSelections > 0 && ` (min: ${minSelections})`,
2150
+ maxSelections > 0 && ` (max: ${maxSelections})`
2151
+ ] }) })
2152
+ ] });
2153
+ };
2154
+ var styles4 = StyleSheet.create({
2155
+ container: {
2156
+ marginBottom: 16
2157
+ },
2158
+ title: {
2159
+ fontSize: 16,
2160
+ fontWeight: "600",
2161
+ color: "#1a1a1a",
2162
+ marginBottom: 4
2163
+ },
2164
+ subtitle: {
2165
+ fontSize: 12,
2166
+ color: "#666",
2167
+ marginBottom: 12
2168
+ },
2169
+ pairsContainer: {
2170
+ flexDirection: "row",
2171
+ flexWrap: "wrap",
2172
+ gap: 8
2173
+ },
2174
+ pairChip: {
2175
+ flexDirection: "row",
2176
+ alignItems: "center",
2177
+ paddingHorizontal: 12,
2178
+ paddingVertical: 8,
2179
+ backgroundColor: "#fff",
2180
+ borderRadius: 8,
2181
+ borderWidth: 1,
2182
+ borderColor: "#e5e5e5",
2183
+ gap: 6
2184
+ },
2185
+ pairChipSelected: {
2186
+ borderWidth: 2
2187
+ },
2188
+ pairIcon: {
2189
+ fontSize: 14
2190
+ },
2191
+ pairText: {
2192
+ fontSize: 14,
2193
+ color: "#666"
2194
+ },
2195
+ checkmark: {
2196
+ fontSize: 14,
2197
+ fontWeight: "700"
2198
+ },
2199
+ selectedInfo: {
2200
+ marginTop: 8,
2201
+ paddingVertical: 4
2202
+ },
2203
+ selectedText: {
2204
+ fontSize: 12,
2205
+ color: "#888"
2206
+ }
2207
+ });
2208
+
2209
+ // src/react-native.ts
2210
+ function createCachedEngineClient(storage, options) {
2211
+ const client = createOneEngineClient(options);
2212
+ return {
2213
+ ...client,
2214
+ /**
2215
+ * Initialize with stored token
2216
+ */
2217
+ async initialize() {
2218
+ const token = await storage.getItem("one_access_token");
2219
+ if (token) {
2220
+ client.setAccessToken(token);
2221
+ return true;
2222
+ }
2223
+ return false;
2224
+ },
2225
+ /**
2226
+ * Login and persist token
2227
+ */
2228
+ async login(email, otp) {
2229
+ const result = await client.verifyEmailOtp(email, otp);
2230
+ if (result.success && result.data?.accessToken) {
2231
+ await storage.setItem("one_access_token", result.data.accessToken);
2232
+ if (result.data.refreshToken) {
2233
+ await storage.setItem("one_refresh_token", result.data.refreshToken);
2234
+ }
2235
+ }
2236
+ return result;
2237
+ },
2238
+ /**
2239
+ * Logout and clear stored tokens
2240
+ */
2241
+ async logout() {
2242
+ await client.signOut();
2243
+ await storage.removeItem("one_access_token");
2244
+ await storage.removeItem("one_refresh_token");
2245
+ client.clearAccessToken();
2246
+ },
2247
+ /**
2248
+ * Refresh token from storage
2249
+ */
2250
+ async refreshFromStorage() {
2251
+ const refreshToken = await storage.getItem("one_refresh_token");
2252
+ if (refreshToken) {
2253
+ const result = await client.refreshToken(refreshToken);
2254
+ if (result.success && result.data?.accessToken) {
2255
+ await storage.setItem("one_access_token", result.data.accessToken);
2256
+ if (result.data.refreshToken) {
2257
+ await storage.setItem("one_refresh_token", result.data.refreshToken);
2258
+ }
2259
+ return true;
2260
+ }
2261
+ }
2262
+ return false;
2263
+ },
2264
+ // Expose underlying client
2265
+ getClient: () => client
2266
+ };
2267
+ }
2268
+ function createDeepLinkHandler(scheme = "onewallet") {
2269
+ return {
2270
+ parse(url) {
2271
+ try {
2272
+ const urlObj = new URL(url);
2273
+ const path = urlObj.pathname.replace(/^\//, "");
2274
+ const params = {};
2275
+ urlObj.searchParams.forEach((value, key) => {
2276
+ params[key] = value;
2277
+ });
2278
+ let type = "unknown";
2279
+ if (path.includes("onramp") || path.includes("callback")) {
2280
+ type = "onramp_callback";
2281
+ } else if (path.includes("wc") || path.includes("walletconnect")) {
2282
+ type = "wallet_connect";
2283
+ } else if (path.includes("pay") || path.includes("payment")) {
2284
+ type = "payment";
2285
+ }
2286
+ return { type, params };
2287
+ } catch {
2288
+ return { type: "unknown", params: {} };
2289
+ }
2290
+ },
2291
+ generate(type, params) {
2292
+ const searchParams = new URLSearchParams(params);
2293
+ return `${scheme}://${type}?${searchParams.toString()}`;
2294
+ }
2295
+ };
2296
+ }
2297
+ function parseQRCode(data) {
2298
+ if (/^0x[a-fA-F0-9]{40}$/.test(data)) {
2299
+ return {
2300
+ type: "address",
2301
+ data,
2302
+ parsed: { address: data }
2303
+ };
2304
+ }
2305
+ if (data.startsWith("ethereum:")) {
2306
+ const match = data.match(/^ethereum:(0x[a-fA-F0-9]{40})(?:@(\d+))?(?:\?(.*))?$/);
2307
+ if (match) {
2308
+ const [, address, chainId, queryString] = match;
2309
+ const params = new URLSearchParams(queryString || "");
2310
+ return {
2311
+ type: "payment_request",
2312
+ data,
2313
+ parsed: {
2314
+ address,
2315
+ chainId: chainId ? parseInt(chainId) : void 0,
2316
+ amount: params.get("value") || void 0,
2317
+ token: params.get("token") || void 0,
2318
+ message: params.get("message") || void 0
2319
+ }
2320
+ };
2321
+ }
2322
+ }
2323
+ if (data.startsWith("wc:")) {
2324
+ return {
2325
+ type: "wallet_connect",
2326
+ data
2327
+ };
2328
+ }
2329
+ return { type: "unknown", data };
2330
+ }
2331
+ function formatCryptoAmount(amount, symbol, options = {}) {
2332
+ const { maxDecimals = 6, showSymbol = true, compact = false } = options;
2333
+ const num = typeof amount === "string" ? parseFloat(amount) : amount;
2334
+ if (isNaN(num)) return showSymbol ? `0 ${symbol}` : "0";
2335
+ let formatted;
2336
+ if (compact && num >= 1e6) {
2337
+ formatted = (num / 1e6).toFixed(2) + "M";
2338
+ } else if (compact && num >= 1e3) {
2339
+ formatted = (num / 1e3).toFixed(2) + "K";
2340
+ } else if (num < 1e-6 && num > 0) {
2341
+ formatted = "<0.000001";
2342
+ } else {
2343
+ const decimals = num < 1 ? maxDecimals : Math.min(maxDecimals, 4);
2344
+ formatted = num.toFixed(decimals).replace(/\.?0+$/, "");
2345
+ }
2346
+ return showSymbol ? `${formatted} ${symbol}` : formatted;
2347
+ }
2348
+ function generateShareContent(params) {
2349
+ const { type, address, amount, token, txHash, chainId } = params;
2350
+ switch (type) {
2351
+ case "receive":
2352
+ return {
2353
+ title: "My Wallet Address",
2354
+ message: `Send ${token || "crypto"} to my wallet:
2355
+ ${address}`,
2356
+ url: address ? `ethereum:${address}${chainId ? `@${chainId}` : ""}` : void 0
2357
+ };
2358
+ case "payment_request":
2359
+ return {
2360
+ title: "Payment Request",
2361
+ message: `Please send ${amount} ${token} to:
2362
+ ${address}`,
2363
+ url: `ethereum:${address}${chainId ? `@${chainId}` : ""}?value=${amount}${token ? `&token=${token}` : ""}`
2364
+ };
2365
+ case "transaction":
2366
+ return {
2367
+ title: "Transaction Sent",
2368
+ message: `Transaction confirmed!
2369
+ Hash: ${txHash}`,
2370
+ url: txHash ? getExplorerUrl(chainId || 1, txHash, "tx") : void 0
2371
+ };
2372
+ default:
2373
+ return { title: "", message: "" };
2374
+ }
2375
+ }
2376
+ function getExplorerUrl(chainId, hash, type = "tx") {
2377
+ const explorers = {
2378
+ 1: "https://etherscan.io",
2379
+ 137: "https://polygonscan.com",
2380
+ 42161: "https://arbiscan.io",
2381
+ 10: "https://optimistic.etherscan.io",
2382
+ 8453: "https://basescan.org",
2383
+ 56: "https://bscscan.com",
2384
+ 43114: "https://snowtrace.io"
2385
+ };
2386
+ const baseUrl = explorers[chainId] || explorers[1];
2387
+ return `${baseUrl}/${type}/${hash}`;
2388
+ }
2389
+
2390
+ export { CHAIN_CONFIG, CHAIN_CONFIGS, COINGECKO_IDS, DEFAULT_SHARE_RATES, OneChainSelector, OneCycleSelector, OneEngineClient, OnePairSelector, OneSDKError, OneTierSelector, PAIR_ICONS, PriceService, TOKEN_NAMES, capitalize, checksumAddress, createCachedEngineClient, createDeepLinkHandler, createOneEngineClient, formatCryptoAmount, formatDate, formatDateTime, formatNumber, formatPercent, formatRelativeTime, formatTokenAmount, formatUSD, generateShareContent, getConfig, getExplorerUrl, initOneSDK, isOneSDKError, isValidAddress, isValidEmail, isValidPhone, omit, parseQRCode, pick, priceService, retry, shortenAddress, sleep, slugify, truncate };
2391
+ //# sourceMappingURL=react-native.mjs.map
2392
+ //# sourceMappingURL=react-native.mjs.map