@one_deploy/sdk 1.0.0

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 (83) hide show
  1. package/.turbo/turbo-build.log +0 -0
  2. package/.turbo/turbo-type-check.log +0 -0
  3. package/dist/config/index.d.mts +74 -0
  4. package/dist/config/index.d.ts +74 -0
  5. package/dist/config/index.js +242 -0
  6. package/dist/config/index.js.map +1 -0
  7. package/dist/config/index.mjs +224 -0
  8. package/dist/config/index.mjs.map +1 -0
  9. package/dist/engine-5ndtBaCr.d.ts +1039 -0
  10. package/dist/engine-CrlhH0nw.d.mts +1039 -0
  11. package/dist/hooks/index.d.mts +56 -0
  12. package/dist/hooks/index.d.ts +56 -0
  13. package/dist/hooks/index.js +1360 -0
  14. package/dist/hooks/index.js.map +1 -0
  15. package/dist/hooks/index.mjs +1356 -0
  16. package/dist/hooks/index.mjs.map +1 -0
  17. package/dist/index.d.mts +356 -0
  18. package/dist/index.d.ts +356 -0
  19. package/dist/index.js +5068 -0
  20. package/dist/index.js.map +1 -0
  21. package/dist/index.mjs +4949 -0
  22. package/dist/index.mjs.map +1 -0
  23. package/dist/price-CgqXPnT3.d.ts +13 -0
  24. package/dist/price-ClbLHHjv.d.mts +13 -0
  25. package/dist/providers/index.d.mts +121 -0
  26. package/dist/providers/index.d.ts +121 -0
  27. package/dist/providers/index.js +1642 -0
  28. package/dist/providers/index.js.map +1 -0
  29. package/dist/providers/index.mjs +1600 -0
  30. package/dist/providers/index.mjs.map +1 -0
  31. package/dist/react-native.d.mts +120 -0
  32. package/dist/react-native.d.ts +120 -0
  33. package/dist/react-native.js +1792 -0
  34. package/dist/react-native.js.map +1 -0
  35. package/dist/react-native.mjs +1755 -0
  36. package/dist/react-native.mjs.map +1 -0
  37. package/dist/services/index.d.mts +85 -0
  38. package/dist/services/index.d.ts +85 -0
  39. package/dist/services/index.js +1466 -0
  40. package/dist/services/index.js.map +1 -0
  41. package/dist/services/index.mjs +1458 -0
  42. package/dist/services/index.mjs.map +1 -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 +101 -0
  56. package/src/components/OneConnectButton.tsx +143 -0
  57. package/src/components/OneNFTGallery.tsx +324 -0
  58. package/src/components/OneOfframpWidget.tsx +660 -0
  59. package/src/components/OneOnrampWidget.tsx +596 -0
  60. package/src/components/OnePayWidget.tsx +160 -0
  61. package/src/components/OneReceiveWidget.tsx +272 -0
  62. package/src/components/OneSendWidget.tsx +248 -0
  63. package/src/components/OneSwapWidget.tsx +715 -0
  64. package/src/components/OneTransactionButton.tsx +150 -0
  65. package/src/components/OneWalletBalance.tsx +354 -0
  66. package/src/components/index.ts +24 -0
  67. package/src/config/index.ts +299 -0
  68. package/src/hooks/index.ts +2 -0
  69. package/src/hooks/useTokenPrice.ts +162 -0
  70. package/src/hooks/useWalletBalance.ts +98 -0
  71. package/src/index.ts +193 -0
  72. package/src/providers/OneProvider.tsx +452 -0
  73. package/src/providers/ThirdwebProvider.tsx +203 -0
  74. package/src/providers/index.ts +26 -0
  75. package/src/react-native.ts +378 -0
  76. package/src/services/engine.ts +1854 -0
  77. package/src/services/index.ts +30 -0
  78. package/src/services/price.ts +164 -0
  79. package/src/services/supabase.ts +180 -0
  80. package/src/types/index.ts +887 -0
  81. package/src/utils/index.ts +200 -0
  82. package/tsconfig.json +22 -0
  83. package/tsup.config.ts +25 -0
@@ -0,0 +1,1792 @@
1
+ 'use strict';
2
+
3
+ // src/config/index.ts
4
+ var config = null;
5
+ function initOneSDK(options) {
6
+ if (!options.oneEngineUrl) {
7
+ throw new Error("oneEngineUrl is required");
8
+ }
9
+ if (!options.oneClientId) {
10
+ throw new Error("oneClientId is required");
11
+ }
12
+ config = options;
13
+ }
14
+ function getConfig() {
15
+ if (!config) {
16
+ throw new Error("ONE SDK not initialized. Call initOneSDK() first.");
17
+ }
18
+ return config;
19
+ }
20
+ var TOKEN_NAMES = {
21
+ ETH: "Ethereum",
22
+ BTC: "Bitcoin",
23
+ BNB: "BNB",
24
+ MATIC: "Polygon",
25
+ POL: "Polygon",
26
+ AVAX: "Avalanche",
27
+ USDT: "Tether",
28
+ USDC: "USD Coin",
29
+ DAI: "Dai",
30
+ WBTC: "Wrapped Bitcoin",
31
+ WETH: "Wrapped Ether",
32
+ ARB: "Arbitrum",
33
+ OP: "Optimism",
34
+ LINK: "Chainlink",
35
+ UNI: "Uniswap",
36
+ AAVE: "Aave",
37
+ CRV: "Curve",
38
+ MKR: "Maker",
39
+ SNX: "Synthetix",
40
+ COMP: "Compound",
41
+ SUSHI: "SushiSwap",
42
+ YFI: "Yearn Finance",
43
+ SOL: "Solana",
44
+ DOT: "Polkadot",
45
+ ATOM: "Cosmos",
46
+ NEAR: "Near Protocol"
47
+ };
48
+ var COINGECKO_IDS = {
49
+ ETH: "ethereum",
50
+ BTC: "bitcoin",
51
+ BNB: "binancecoin",
52
+ MATIC: "matic-network",
53
+ POL: "matic-network",
54
+ AVAX: "avalanche-2",
55
+ USDT: "tether",
56
+ USDC: "usd-coin",
57
+ DAI: "dai",
58
+ WBTC: "wrapped-bitcoin",
59
+ WETH: "weth",
60
+ ARB: "arbitrum",
61
+ OP: "optimism",
62
+ LINK: "chainlink",
63
+ UNI: "uniswap",
64
+ AAVE: "aave",
65
+ SOL: "solana"
66
+ };
67
+ var CHAIN_CONFIGS = {
68
+ ethereum: {
69
+ id: 1,
70
+ name: "Ethereum",
71
+ shortName: "ETH",
72
+ icon: "\u229F",
73
+ nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
74
+ rpcUrls: ["https://ethereum.rpc.thirdweb.com"],
75
+ blockExplorerUrls: ["https://etherscan.io"],
76
+ testnet: false
77
+ },
78
+ polygon: {
79
+ id: 137,
80
+ name: "Polygon",
81
+ shortName: "MATIC",
82
+ icon: "\u{1F7E3}",
83
+ nativeCurrency: { name: "POL", symbol: "POL", decimals: 18 },
84
+ rpcUrls: ["https://polygon.rpc.thirdweb.com"],
85
+ blockExplorerUrls: ["https://polygonscan.com"],
86
+ testnet: false
87
+ },
88
+ base: {
89
+ id: 8453,
90
+ name: "Base",
91
+ shortName: "BASE",
92
+ icon: "\u{1F537}",
93
+ nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
94
+ rpcUrls: ["https://base.rpc.thirdweb.com"],
95
+ blockExplorerUrls: ["https://basescan.org"],
96
+ testnet: false
97
+ },
98
+ arbitrum: {
99
+ id: 42161,
100
+ name: "Arbitrum One",
101
+ shortName: "ARB",
102
+ icon: "\u{1F535}",
103
+ nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
104
+ rpcUrls: ["https://arbitrum.rpc.thirdweb.com"],
105
+ blockExplorerUrls: ["https://arbiscan.io"],
106
+ testnet: false
107
+ },
108
+ optimism: {
109
+ id: 10,
110
+ name: "Optimism",
111
+ shortName: "OP",
112
+ icon: "\u{1F534}",
113
+ nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
114
+ rpcUrls: ["https://optimism.rpc.thirdweb.com"],
115
+ blockExplorerUrls: ["https://optimistic.etherscan.io"],
116
+ testnet: false
117
+ }
118
+ };
119
+
120
+ // src/services/engine.ts
121
+ var OneEngineClient = class {
122
+ constructor(options) {
123
+ const config2 = getConfig();
124
+ this.baseUrl = options?.baseUrl || config2.oneEngineUrl;
125
+ this.clientId = options?.clientId || config2.oneClientId || "";
126
+ this.secretKey = options?.secretKey || config2.oneSecretKey;
127
+ }
128
+ /**
129
+ * Set access token for authenticated requests
130
+ */
131
+ setAccessToken(token) {
132
+ this.accessToken = token;
133
+ }
134
+ /**
135
+ * Clear access token
136
+ */
137
+ clearAccessToken() {
138
+ this.accessToken = void 0;
139
+ }
140
+ getHeaders(includeSecret = false) {
141
+ const headers = {
142
+ "Content-Type": "application/json",
143
+ "x-client-id": this.clientId
144
+ };
145
+ if (this.accessToken) {
146
+ headers["Authorization"] = `Bearer ${this.accessToken}`;
147
+ }
148
+ if (includeSecret && this.secretKey) {
149
+ headers["x-secret-key"] = this.secretKey;
150
+ }
151
+ return headers;
152
+ }
153
+ async request(endpoint, options = {}, includeSecret = false) {
154
+ try {
155
+ const response = await fetch(`${this.baseUrl}${endpoint}`, {
156
+ ...options,
157
+ headers: {
158
+ ...this.getHeaders(includeSecret),
159
+ ...options.headers
160
+ }
161
+ });
162
+ const data = await response.json();
163
+ if (!response.ok) {
164
+ return {
165
+ success: false,
166
+ error: {
167
+ code: data.error?.code || `HTTP_${response.status}`,
168
+ message: data.error?.message || "Request failed"
169
+ }
170
+ };
171
+ }
172
+ return {
173
+ success: true,
174
+ data: data.data || data
175
+ };
176
+ } catch (error) {
177
+ return {
178
+ success: false,
179
+ error: {
180
+ code: "NETWORK_ERROR",
181
+ message: error instanceof Error ? error.message : "Network request failed"
182
+ }
183
+ };
184
+ }
185
+ }
186
+ // ===============================
187
+ // AUTH ENDPOINTS
188
+ // ===============================
189
+ /**
190
+ * Send OTP to email for authentication
191
+ */
192
+ async sendEmailOtp(email) {
193
+ return this.request("/api/v1/auth/otp", {
194
+ method: "POST",
195
+ body: JSON.stringify({ email })
196
+ });
197
+ }
198
+ /**
199
+ * Verify OTP and get access token
200
+ */
201
+ async verifyEmailOtp(email, otp) {
202
+ return this.request("/api/v1/auth/otp/verify", {
203
+ method: "POST",
204
+ body: JSON.stringify({ email, otp })
205
+ });
206
+ }
207
+ /**
208
+ * Authenticate with wallet signature
209
+ */
210
+ async authWithWallet(walletAddress, signature, message) {
211
+ return this.request("/api/v1/auth/wallet", {
212
+ method: "POST",
213
+ body: JSON.stringify({ walletAddress, signature, message })
214
+ });
215
+ }
216
+ /**
217
+ * Refresh access token
218
+ */
219
+ async refreshToken(refreshToken) {
220
+ return this.request("/api/v1/auth/refresh", {
221
+ method: "POST",
222
+ body: JSON.stringify({ refreshToken })
223
+ });
224
+ }
225
+ /**
226
+ * Get current user
227
+ */
228
+ async getCurrentUser() {
229
+ return this.request("/api/v1/auth/me", { method: "GET" });
230
+ }
231
+ /**
232
+ * Sign out
233
+ */
234
+ async signOut() {
235
+ return this.request("/api/v1/auth/logout", { method: "POST" });
236
+ }
237
+ // ===============================
238
+ // WALLET/ASSETS ENDPOINTS
239
+ // ===============================
240
+ /**
241
+ * Get wallet balance across all chains
242
+ */
243
+ async getWalletBalance(walletAddress, chains) {
244
+ const params = new URLSearchParams({ address: walletAddress });
245
+ if (chains?.length && chains.length > 0) {
246
+ params.set("chainId", chains[0].toString());
247
+ }
248
+ return this.request(`/api/v1/assets?${params}`, { method: "GET" });
249
+ }
250
+ /**
251
+ * Get portfolio summary
252
+ */
253
+ async getPortfolioSummary(walletAddress) {
254
+ const params = new URLSearchParams({ address: walletAddress });
255
+ return this.request(`/api/v1/assets/portfolio?${params}`, { method: "GET" });
256
+ }
257
+ /**
258
+ * Get user's wallets
259
+ */
260
+ async getUserWallets(chainId) {
261
+ const params = chainId ? `?chainId=${chainId}` : "";
262
+ return this.request(`/api/v1/wallet${params}`, { method: "GET" });
263
+ }
264
+ /**
265
+ * Create a new wallet
266
+ */
267
+ async createWallet(chainId = 8453, type = "smart") {
268
+ return this.request("/api/v1/wallet", {
269
+ method: "POST",
270
+ body: JSON.stringify({ chainId, type })
271
+ });
272
+ }
273
+ /**
274
+ * Get wallet transactions (placeholder - needs endpoint)
275
+ */
276
+ async getWalletTransactions(walletAddress, options) {
277
+ const params = new URLSearchParams({ address: walletAddress });
278
+ if (options?.limit) params.set("limit", options.limit.toString());
279
+ if (options?.offset) params.set("offset", options.offset.toString());
280
+ if (options?.chainId) params.set("chainId", options.chainId.toString());
281
+ return this.request(`/api/v1/assets/transactions?${params}`, { method: "GET" });
282
+ }
283
+ /**
284
+ * Send native token or ERC20
285
+ */
286
+ async sendTransaction(request) {
287
+ return this.request("/api/v1/wallet/send", {
288
+ method: "POST",
289
+ body: JSON.stringify(request)
290
+ });
291
+ }
292
+ /**
293
+ * Get transaction status
294
+ */
295
+ async getTransactionStatus(txId) {
296
+ return this.request(`/api/v1/wallet/transaction/${txId}`, { method: "GET" });
297
+ }
298
+ // ===============================
299
+ // ONRAMP ENDPOINTS (Fiat-to-Crypto)
300
+ // ===============================
301
+ /**
302
+ * Get onramp quote
303
+ */
304
+ async getOnrampQuote(fiatCurrency, fiatAmount, cryptoCurrency, paymentMethod) {
305
+ const params = new URLSearchParams({
306
+ fiatCurrency,
307
+ fiatAmount: fiatAmount.toString(),
308
+ cryptoCurrency
309
+ });
310
+ if (paymentMethod) params.set("paymentMethod", paymentMethod);
311
+ return this.request(`/api/v1/fiat/onramp/quote?${params}`, { method: "GET" });
312
+ }
313
+ /**
314
+ * Create onramp session (returns widget URL)
315
+ */
316
+ async createOnrampSession(request) {
317
+ return this.request("/api/v1/fiat/onramp", {
318
+ method: "POST",
319
+ body: JSON.stringify({
320
+ fiatCurrency: request.fiatCurrency || "USD",
321
+ fiatAmount: request.fiatAmount || 100,
322
+ cryptoCurrency: request.cryptoCurrency || "ETH",
323
+ walletAddress: request.walletAddress,
324
+ chainId: 8453
325
+ // Default to Base
326
+ })
327
+ });
328
+ }
329
+ /**
330
+ * Get onramp session status
331
+ */
332
+ async getOnrampStatus(sessionId) {
333
+ return this.request(`/api/v1/fiat/onramp/${sessionId}`, { method: "GET" });
334
+ }
335
+ /**
336
+ * Get supported currencies (fiat + crypto)
337
+ */
338
+ async getSupportedCurrencies() {
339
+ return this.request("/api/v1/fiat/onramp", { method: "GET" });
340
+ }
341
+ /**
342
+ * Get supported fiat currencies
343
+ */
344
+ async getSupportedFiatCurrencies() {
345
+ const result = await this.getSupportedCurrencies();
346
+ if (result.success && result.data) {
347
+ return { success: true, data: result.data.fiatCurrencies };
348
+ }
349
+ return { success: false, error: result.error };
350
+ }
351
+ /**
352
+ * Get supported payment methods
353
+ */
354
+ async getSupportedPaymentMethods(country) {
355
+ return { success: true, data: ["card", "bank_transfer", "apple_pay", "google_pay"] };
356
+ }
357
+ // ===============================
358
+ // SWAP ENDPOINTS
359
+ // ===============================
360
+ /**
361
+ * Get swap quote
362
+ */
363
+ async getSwapQuote(request) {
364
+ return this.request("/api/v1/swap/quote", {
365
+ method: "POST",
366
+ body: JSON.stringify(request)
367
+ });
368
+ }
369
+ /**
370
+ * Execute swap
371
+ */
372
+ async executeSwap(request) {
373
+ return this.request("/api/v1/swap/execute", {
374
+ method: "POST",
375
+ body: JSON.stringify(request)
376
+ });
377
+ }
378
+ /**
379
+ * Get swap status
380
+ */
381
+ async getSwapStatus(swapId) {
382
+ return this.request(`/api/v1/swap/${swapId}`, { method: "GET" });
383
+ }
384
+ /**
385
+ * Get supported tokens for swap
386
+ */
387
+ async getSupportedSwapTokens(chainId) {
388
+ const params = chainId ? `?chainId=${chainId}` : "";
389
+ return this.request(`/api/v1/swap/tokens${params}`, { method: "GET" });
390
+ }
391
+ /**
392
+ * Get supported chains for swap
393
+ */
394
+ async getSupportedSwapChains() {
395
+ return this.request("/api/v1/swap/chains", { method: "GET" });
396
+ }
397
+ // ===============================
398
+ // AI TRADING/QUANT ENDPOINTS
399
+ // ===============================
400
+ /**
401
+ * Get available AI trading strategies
402
+ */
403
+ async getStrategies() {
404
+ return this.request("/api/v1/quant/strategies", { method: "GET" });
405
+ }
406
+ /**
407
+ * Get strategy details
408
+ */
409
+ async getStrategy(strategyId) {
410
+ return this.request(`/api/v1/quant/strategies/${strategyId}`, { method: "GET" });
411
+ }
412
+ /**
413
+ * Get user's positions
414
+ */
415
+ async getPositions() {
416
+ return this.request("/api/v1/quant/positions", { method: "GET" });
417
+ }
418
+ /**
419
+ * Create investment order
420
+ */
421
+ async createOrder(strategyId, amount, currency) {
422
+ return this.request("/api/v1/trading/orders", {
423
+ method: "POST",
424
+ body: JSON.stringify({ strategyId, amount, currency })
425
+ });
426
+ }
427
+ /**
428
+ * Get user's orders
429
+ */
430
+ async getUserOrders() {
431
+ return this.request("/api/v1/trading/orders", { method: "GET" });
432
+ }
433
+ /**
434
+ * Get user's portfolio stats from positions
435
+ */
436
+ async getPortfolioStats() {
437
+ const positionsResult = await this.getPositions();
438
+ if (positionsResult.success && positionsResult.data) {
439
+ const positions = positionsResult.data;
440
+ const totalInvested = positions.reduce((sum, p) => sum + (p.investedAmount || 0), 0);
441
+ const totalValue = positions.reduce((sum, p) => sum + (p.currentValue || 0), 0);
442
+ const totalPnl = totalValue - totalInvested;
443
+ const totalPnlPercent = totalInvested > 0 ? totalPnl / totalInvested * 100 : 0;
444
+ return {
445
+ success: true,
446
+ data: {
447
+ totalInvested,
448
+ totalValue,
449
+ totalPnl,
450
+ totalPnlPercent,
451
+ activePositions: positions.filter((p) => p.status === "active").length
452
+ }
453
+ };
454
+ }
455
+ return {
456
+ success: true,
457
+ data: { totalInvested: 0, totalValue: 0, totalPnl: 0, totalPnlPercent: 0, activePositions: 0 }
458
+ };
459
+ }
460
+ // ===============================
461
+ // MARKET/PRICE ENDPOINTS
462
+ // ===============================
463
+ /**
464
+ * Get token prices
465
+ */
466
+ async getTokenPrices(symbols) {
467
+ const bybitSymbols = symbols.map((s) => {
468
+ const upper = s.toUpperCase();
469
+ if (upper.endsWith("USDT")) return upper;
470
+ return `${upper}USDT`;
471
+ });
472
+ const result = await this.request(
473
+ `/api/v1/trading/market?symbols=${bybitSymbols.join(",")}`,
474
+ { method: "GET" }
475
+ );
476
+ if (result.success && result.data?.markets) {
477
+ const prices = {};
478
+ for (const market of result.data.markets) {
479
+ const symbol = market.symbol?.replace("USDT", "") || "";
480
+ prices[symbol] = {
481
+ price: parseFloat(market.lastPrice) || 0,
482
+ change24h: parseFloat(market.price24hPcnt) * 100 || 0,
483
+ marketCap: void 0
484
+ // Bybit doesn't provide this
485
+ };
486
+ }
487
+ return { success: true, data: prices };
488
+ }
489
+ return { success: false, error: result.error };
490
+ }
491
+ /**
492
+ * Get market data overview
493
+ */
494
+ async getMarketData() {
495
+ const result = await this.request("/api/v1/trading/market", { method: "GET" });
496
+ if (result.success && result.data?.markets) {
497
+ return {
498
+ success: true,
499
+ data: {
500
+ totalMarketCap: 0,
501
+ // Would need separate API
502
+ totalVolume24h: result.data.markets.reduce((sum, m) => sum + (parseFloat(m.volume24h) || 0), 0),
503
+ btcDominance: 0,
504
+ // Would need separate API
505
+ markets: result.data.markets
506
+ }
507
+ };
508
+ }
509
+ return { success: false, error: result.error };
510
+ }
511
+ // ===============================
512
+ // NFT ENDPOINTS
513
+ // ===============================
514
+ /**
515
+ * Get user's NFTs
516
+ */
517
+ async getUserNFTs(walletAddress, options) {
518
+ const params = new URLSearchParams({ address: walletAddress });
519
+ if (options?.chainId) params.set("chainId", options.chainId.toString());
520
+ if (options?.limit) params.set("limit", options.limit.toString());
521
+ if (options?.offset) params.set("offset", options.offset.toString());
522
+ return this.request(`/api/v1/assets/nfts?${params}`, { method: "GET" });
523
+ }
524
+ /**
525
+ * Get NFT details
526
+ */
527
+ async getNFTDetails(contractAddress, tokenId, chainId) {
528
+ return this.request(`/api/v1/assets/nfts/${contractAddress}/${tokenId}?chainId=${chainId}`, { method: "GET" });
529
+ }
530
+ /**
531
+ * Get NFT collection
532
+ */
533
+ async getNFTCollection(contractAddress, chainId) {
534
+ return this.request(`/api/v1/assets/nfts/collection/${contractAddress}?chainId=${chainId}`, { method: "GET" });
535
+ }
536
+ /**
537
+ * Transfer NFT
538
+ */
539
+ async transferNFT(params) {
540
+ return this.request("/api/v1/assets/nfts/transfer", {
541
+ method: "POST",
542
+ body: JSON.stringify(params)
543
+ });
544
+ }
545
+ // ===============================
546
+ // CONTRACT ENDPOINTS
547
+ // ===============================
548
+ /**
549
+ * Get user's contracts
550
+ */
551
+ async getUserContracts(options) {
552
+ const params = new URLSearchParams();
553
+ if (options?.chainId) params.set("chainId", options.chainId.toString());
554
+ if (options?.limit) params.set("limit", options.limit.toString());
555
+ if (options?.offset) params.set("offset", options.offset.toString());
556
+ return this.request(`/api/v1/contracts?${params}`, { method: "GET" });
557
+ }
558
+ /**
559
+ * Get contract details
560
+ */
561
+ async getContractDetails(address, chainId) {
562
+ return this.request(`/api/v1/contracts/${address}?chainId=${chainId}`, { method: "GET" });
563
+ }
564
+ /**
565
+ * Read contract (call view function)
566
+ */
567
+ async readContract(params) {
568
+ return this.request("/api/v1/contracts/read", {
569
+ method: "POST",
570
+ body: JSON.stringify(params)
571
+ });
572
+ }
573
+ /**
574
+ * Write to contract (execute transaction)
575
+ */
576
+ async writeContract(params) {
577
+ return this.request("/api/v1/contracts/write", {
578
+ method: "POST",
579
+ body: JSON.stringify(params)
580
+ });
581
+ }
582
+ /**
583
+ * Deploy contract
584
+ */
585
+ async deployContract(params) {
586
+ return this.request("/api/v1/contracts/deploy", {
587
+ method: "POST",
588
+ body: JSON.stringify(params)
589
+ });
590
+ }
591
+ // ===============================
592
+ // OFFRAMP ENDPOINTS (Crypto-to-Fiat)
593
+ // ===============================
594
+ /**
595
+ * Get offramp quote
596
+ */
597
+ async getOfframpQuote(cryptoCurrency, cryptoAmount, fiatCurrency, payoutMethod) {
598
+ const params = new URLSearchParams({
599
+ cryptoCurrency,
600
+ cryptoAmount: cryptoAmount.toString(),
601
+ fiatCurrency
602
+ });
603
+ if (payoutMethod) params.set("payoutMethod", payoutMethod);
604
+ return this.request(`/api/v1/fiat/offramp/quote?${params}`, { method: "GET" });
605
+ }
606
+ /**
607
+ * Create offramp transaction
608
+ */
609
+ async createOfframpTransaction(request) {
610
+ return this.request("/api/v1/fiat/offramp", {
611
+ method: "POST",
612
+ body: JSON.stringify(request)
613
+ });
614
+ }
615
+ /**
616
+ * Get offramp transaction status
617
+ */
618
+ async getOfframpStatus(transactionId) {
619
+ return this.request(`/api/v1/fiat/offramp/${transactionId}`, { method: "GET" });
620
+ }
621
+ /**
622
+ * Get supported payout methods
623
+ */
624
+ async getSupportedPayoutMethods(country) {
625
+ const params = country ? `?country=${country}` : "";
626
+ return this.request(`/api/v1/fiat/offramp/methods${params}`, { method: "GET" });
627
+ }
628
+ // ===============================
629
+ // BILL PAYMENT ENDPOINTS
630
+ // ===============================
631
+ /**
632
+ * Get bill providers
633
+ */
634
+ async getBillProviders(country, category) {
635
+ const params = new URLSearchParams();
636
+ if (country) params.set("country", country);
637
+ if (category) params.set("category", category);
638
+ return this.request(`/api/v1/bills/providers?${params}`, { method: "GET" });
639
+ }
640
+ /**
641
+ * Get bill details/validate account
642
+ */
643
+ async validateBillAccount(providerId, accountNumber) {
644
+ return this.request("/api/v1/bills/validate", {
645
+ method: "POST",
646
+ body: JSON.stringify({ providerId, accountNumber })
647
+ });
648
+ }
649
+ /**
650
+ * Pay bill
651
+ */
652
+ async payBill(params) {
653
+ return this.request("/api/v1/bills/pay", {
654
+ method: "POST",
655
+ body: JSON.stringify(params)
656
+ });
657
+ }
658
+ /**
659
+ * Get bill payment history
660
+ */
661
+ async getBillHistory(options) {
662
+ const params = new URLSearchParams();
663
+ if (options?.limit) params.set("limit", options.limit.toString());
664
+ if (options?.offset) params.set("offset", options.offset.toString());
665
+ return this.request(`/api/v1/bills/history?${params}`, { method: "GET" });
666
+ }
667
+ // ===============================
668
+ // STAKING ENDPOINTS
669
+ // ===============================
670
+ /**
671
+ * Get staking pools
672
+ */
673
+ async getStakingPools(chainId) {
674
+ const params = chainId ? `?chainId=${chainId}` : "";
675
+ return this.request(`/api/v1/staking/pools${params}`, { method: "GET" });
676
+ }
677
+ /**
678
+ * Get user's staking positions
679
+ */
680
+ async getStakingPositions() {
681
+ return this.request("/api/v1/staking/positions", { method: "GET" });
682
+ }
683
+ /**
684
+ * Stake tokens
685
+ */
686
+ async stake(params) {
687
+ return this.request("/api/v1/staking/stake", {
688
+ method: "POST",
689
+ body: JSON.stringify(params)
690
+ });
691
+ }
692
+ /**
693
+ * Unstake tokens
694
+ */
695
+ async unstake(params) {
696
+ return this.request("/api/v1/staking/unstake", {
697
+ method: "POST",
698
+ body: JSON.stringify(params)
699
+ });
700
+ }
701
+ /**
702
+ * Claim staking rewards
703
+ */
704
+ async claimStakingRewards(positionId) {
705
+ return this.request("/api/v1/staking/claim", {
706
+ method: "POST",
707
+ body: JSON.stringify({ positionId })
708
+ });
709
+ }
710
+ // ===============================
711
+ // USER PROFILE ENDPOINTS
712
+ // ===============================
713
+ /**
714
+ * Get user profile
715
+ */
716
+ async getUserProfile() {
717
+ return this.request("/api/v1/user/profile", { method: "GET" });
718
+ }
719
+ /**
720
+ * Update user profile
721
+ */
722
+ async updateUserProfile(updates) {
723
+ return this.request("/api/v1/user/profile", {
724
+ method: "PATCH",
725
+ body: JSON.stringify(updates)
726
+ });
727
+ }
728
+ /**
729
+ * Get user settings
730
+ */
731
+ async getUserSettings() {
732
+ return this.request("/api/v1/user/settings", { method: "GET" });
733
+ }
734
+ /**
735
+ * Update user settings
736
+ */
737
+ async updateUserSettings(updates) {
738
+ return this.request("/api/v1/user/settings", {
739
+ method: "PATCH",
740
+ body: JSON.stringify(updates)
741
+ });
742
+ }
743
+ // ===============================
744
+ // NOTIFICATION ENDPOINTS
745
+ // ===============================
746
+ /**
747
+ * Get notifications
748
+ */
749
+ async getNotifications(options) {
750
+ const params = new URLSearchParams();
751
+ if (options?.unreadOnly) params.set("unreadOnly", "true");
752
+ if (options?.limit) params.set("limit", options.limit.toString());
753
+ if (options?.offset) params.set("offset", options.offset.toString());
754
+ return this.request(`/api/v1/notifications?${params}`, { method: "GET" });
755
+ }
756
+ /**
757
+ * Mark notification as read
758
+ */
759
+ async markNotificationRead(notificationId) {
760
+ return this.request(`/api/v1/notifications/${notificationId}/read`, { method: "POST" });
761
+ }
762
+ /**
763
+ * Mark all notifications as read
764
+ */
765
+ async markAllNotificationsRead() {
766
+ return this.request("/api/v1/notifications/read-all", { method: "POST" });
767
+ }
768
+ // ===============================
769
+ // REFERRAL ENDPOINTS
770
+ // ===============================
771
+ /**
772
+ * Get referral info
773
+ */
774
+ async getReferralInfo() {
775
+ return this.request("/api/v1/referral", { method: "GET" });
776
+ }
777
+ /**
778
+ * Get referred users
779
+ */
780
+ async getReferrals() {
781
+ return this.request("/api/v1/referral/list", { method: "GET" });
782
+ }
783
+ /**
784
+ * Apply referral code
785
+ */
786
+ async applyReferralCode(code) {
787
+ return this.request("/api/v1/referral/apply", {
788
+ method: "POST",
789
+ body: JSON.stringify({ code })
790
+ });
791
+ }
792
+ /**
793
+ * Claim referral rewards
794
+ */
795
+ async claimReferralRewards() {
796
+ return this.request("/api/v1/referral/claim", { method: "POST" });
797
+ }
798
+ // ===============================
799
+ // KYC ENDPOINTS
800
+ // ===============================
801
+ /**
802
+ * Get KYC status
803
+ */
804
+ async getKycStatus() {
805
+ return this.request("/api/v1/kyc/status", { method: "GET" });
806
+ }
807
+ /**
808
+ * Start KYC verification
809
+ */
810
+ async startKycVerification(level) {
811
+ return this.request("/api/v1/kyc/start", {
812
+ method: "POST",
813
+ body: JSON.stringify({ level })
814
+ });
815
+ }
816
+ /**
817
+ * Submit KYC documents
818
+ */
819
+ async submitKycDocuments(params) {
820
+ return this.request("/api/v1/kyc/submit", {
821
+ method: "POST",
822
+ body: JSON.stringify(params)
823
+ });
824
+ }
825
+ // ===============================
826
+ // BRIDGE ENDPOINTS
827
+ // ===============================
828
+ /**
829
+ * Get bridge quote
830
+ */
831
+ async getBridgeQuote(params) {
832
+ return this.request("/api/v1/bridge/quote", {
833
+ method: "POST",
834
+ body: JSON.stringify(params)
835
+ });
836
+ }
837
+ /**
838
+ * Execute bridge transaction
839
+ */
840
+ async executeBridge(params) {
841
+ return this.request("/api/v1/bridge/execute", {
842
+ method: "POST",
843
+ body: JSON.stringify(params)
844
+ });
845
+ }
846
+ /**
847
+ * Get bridge transaction status
848
+ */
849
+ async getBridgeStatus(bridgeId) {
850
+ return this.request(`/api/v1/bridge/${bridgeId}`, { method: "GET" });
851
+ }
852
+ /**
853
+ * Get supported bridge routes
854
+ */
855
+ async getSupportedBridgeRoutes() {
856
+ return this.request("/api/v1/bridge/routes", { method: "GET" });
857
+ }
858
+ // ===============================
859
+ // GAS ENDPOINTS
860
+ // ===============================
861
+ /**
862
+ * Get gas estimate for transaction
863
+ */
864
+ async getGasEstimate(params) {
865
+ return this.request("/api/v1/gas/estimate", {
866
+ method: "POST",
867
+ body: JSON.stringify(params)
868
+ });
869
+ }
870
+ /**
871
+ * Get current gas prices for chain
872
+ */
873
+ async getGasPrice(chainId) {
874
+ return this.request(`/api/v1/gas/price?chainId=${chainId}`, { method: "GET" });
875
+ }
876
+ // ===============================
877
+ // WALLET IMPORT/EXPORT ENDPOINTS
878
+ // ===============================
879
+ /**
880
+ * Import wallet from private key or mnemonic
881
+ */
882
+ async importWallet(request) {
883
+ return this.request("/api/v1/wallet/import", {
884
+ method: "POST",
885
+ body: JSON.stringify(request)
886
+ }, true);
887
+ }
888
+ /**
889
+ * Export wallet (get encrypted private key)
890
+ * Requires additional authentication
891
+ */
892
+ async exportWallet(walletId, pin) {
893
+ return this.request("/api/v1/wallet/export", {
894
+ method: "POST",
895
+ body: JSON.stringify({ walletId, pin })
896
+ }, true);
897
+ }
898
+ /**
899
+ * Generate new mnemonic phrase
900
+ */
901
+ async generateMnemonic() {
902
+ return this.request("/api/v1/wallet/generate-mnemonic", { method: "POST" }, true);
903
+ }
904
+ /**
905
+ * Validate mnemonic phrase
906
+ */
907
+ async validateMnemonic(mnemonic) {
908
+ return this.request("/api/v1/wallet/validate-mnemonic", {
909
+ method: "POST",
910
+ body: JSON.stringify({ mnemonic })
911
+ });
912
+ }
913
+ // ===============================
914
+ // PORTFOLIO ANALYTICS ENDPOINTS
915
+ // ===============================
916
+ /**
917
+ * Get portfolio analytics with historical data
918
+ */
919
+ async getPortfolioAnalytics(walletAddress, period = "30d") {
920
+ const params = new URLSearchParams({ address: walletAddress, period });
921
+ return this.request(`/api/v1/analytics/portfolio?${params}`, { method: "GET" });
922
+ }
923
+ /**
924
+ * Get transaction analytics
925
+ */
926
+ async getTransactionAnalytics(walletAddress, period = "30d") {
927
+ const params = new URLSearchParams({ address: walletAddress, period });
928
+ return this.request(`/api/v1/analytics/transactions?${params}`, { method: "GET" });
929
+ }
930
+ // ===============================
931
+ // ADVANCED TRADING ENDPOINTS
932
+ // ===============================
933
+ /**
934
+ * Create limit order
935
+ */
936
+ async createLimitOrder(params) {
937
+ return this.request("/api/v1/trading/limit-orders", {
938
+ method: "POST",
939
+ body: JSON.stringify(params)
940
+ });
941
+ }
942
+ /**
943
+ * Get user's limit orders
944
+ */
945
+ async getLimitOrders(status) {
946
+ const params = status ? `?status=${status}` : "";
947
+ return this.request(`/api/v1/trading/limit-orders${params}`, { method: "GET" });
948
+ }
949
+ /**
950
+ * Cancel limit order
951
+ */
952
+ async cancelLimitOrder(orderId) {
953
+ return this.request(`/api/v1/trading/limit-orders/${orderId}`, { method: "DELETE" });
954
+ }
955
+ /**
956
+ * Set price alert
957
+ */
958
+ async setPriceAlert(params) {
959
+ return this.request("/api/v1/trading/alerts", {
960
+ method: "POST",
961
+ body: JSON.stringify(params)
962
+ });
963
+ }
964
+ /**
965
+ * Get price alerts
966
+ */
967
+ async getPriceAlerts() {
968
+ return this.request("/api/v1/trading/alerts", { method: "GET" });
969
+ }
970
+ /**
971
+ * Delete price alert
972
+ */
973
+ async deletePriceAlert(alertId) {
974
+ return this.request(`/api/v1/trading/alerts/${alertId}`, { method: "DELETE" });
975
+ }
976
+ // ===============================
977
+ // SESSION MANAGEMENT
978
+ // ===============================
979
+ /**
980
+ * Get active sessions
981
+ */
982
+ async getActiveSessions() {
983
+ return this.request("/api/v1/auth/sessions", { method: "GET" });
984
+ }
985
+ /**
986
+ * Revoke session
987
+ */
988
+ async revokeSession(sessionId) {
989
+ return this.request(`/api/v1/auth/sessions/${sessionId}`, { method: "DELETE" });
990
+ }
991
+ /**
992
+ * Revoke all other sessions
993
+ */
994
+ async revokeAllOtherSessions() {
995
+ return this.request("/api/v1/auth/sessions/revoke-all", { method: "POST" });
996
+ }
997
+ // ========== Webhooks ==========
998
+ /**
999
+ * List webhooks for the project
1000
+ */
1001
+ async listWebhooks(options) {
1002
+ const params = new URLSearchParams();
1003
+ if (options?.isActive !== void 0) params.set("isActive", String(options.isActive));
1004
+ const query = params.toString();
1005
+ return this.request(`/api/v1/webhooks${query ? `?${query}` : ""}`, { method: "GET" });
1006
+ }
1007
+ /**
1008
+ * Get webhook by ID
1009
+ */
1010
+ async getWebhook(webhookId) {
1011
+ return this.request(`/api/v1/webhooks/${webhookId}`, { method: "GET" });
1012
+ }
1013
+ /**
1014
+ * Create a webhook
1015
+ */
1016
+ async createWebhook(input) {
1017
+ return this.request("/api/v1/webhooks", {
1018
+ method: "POST",
1019
+ body: JSON.stringify(input)
1020
+ });
1021
+ }
1022
+ /**
1023
+ * Update a webhook
1024
+ */
1025
+ async updateWebhook(webhookId, input) {
1026
+ return this.request(`/api/v1/webhooks/${webhookId}`, {
1027
+ method: "PATCH",
1028
+ body: JSON.stringify(input)
1029
+ });
1030
+ }
1031
+ /**
1032
+ * Delete a webhook
1033
+ */
1034
+ async deleteWebhook(webhookId) {
1035
+ return this.request(`/api/v1/webhooks/${webhookId}`, { method: "DELETE" });
1036
+ }
1037
+ /**
1038
+ * Get webhook deliveries
1039
+ */
1040
+ async getWebhookDeliveries(webhookId, options) {
1041
+ const params = new URLSearchParams();
1042
+ if (options?.status) params.set("status", options.status);
1043
+ if (options?.limit) params.set("limit", String(options.limit));
1044
+ if (options?.offset) params.set("offset", String(options.offset));
1045
+ const query = params.toString();
1046
+ return this.request(`/api/v1/webhooks/${webhookId}/deliveries${query ? `?${query}` : ""}`, { method: "GET" });
1047
+ }
1048
+ /**
1049
+ * Test a webhook
1050
+ */
1051
+ async testWebhook(webhookId) {
1052
+ return this.request(`/api/v1/webhooks/${webhookId}/test`, { method: "POST" });
1053
+ }
1054
+ // ========== Admin (requires admin role) ==========
1055
+ /**
1056
+ * List all users (admin only)
1057
+ */
1058
+ async adminListUsers(options) {
1059
+ const params = new URLSearchParams();
1060
+ if (options?.page) params.set("page", String(options.page));
1061
+ if (options?.limit) params.set("limit", String(options.limit));
1062
+ if (options?.search) params.set("search", options.search);
1063
+ if (options?.sortBy) params.set("sortBy", options.sortBy);
1064
+ if (options?.sortOrder) params.set("sortOrder", options.sortOrder);
1065
+ if (options?.role) params.set("role", options.role);
1066
+ if (options?.kycStatus) params.set("kycStatus", options.kycStatus);
1067
+ if (options?.isActive !== void 0) params.set("isActive", String(options.isActive));
1068
+ const query = params.toString();
1069
+ return this.request(`/api/v1/admin/users${query ? `?${query}` : ""}`, { method: "GET" });
1070
+ }
1071
+ /**
1072
+ * Get user by ID (admin only)
1073
+ */
1074
+ async adminGetUser(userId) {
1075
+ return this.request(`/api/v1/admin/users/${userId}`, { method: "GET" });
1076
+ }
1077
+ /**
1078
+ * Update user (admin only)
1079
+ */
1080
+ async adminUpdateUser(userId, data) {
1081
+ return this.request(`/api/v1/admin/users/${userId}`, {
1082
+ method: "PATCH",
1083
+ body: JSON.stringify(data)
1084
+ });
1085
+ }
1086
+ /**
1087
+ * List all projects (admin only)
1088
+ */
1089
+ async adminListProjects(options) {
1090
+ const params = new URLSearchParams();
1091
+ if (options?.page) params.set("page", String(options.page));
1092
+ if (options?.limit) params.set("limit", String(options.limit));
1093
+ if (options?.search) params.set("search", options.search);
1094
+ if (options?.sortBy) params.set("sortBy", options.sortBy);
1095
+ if (options?.sortOrder) params.set("sortOrder", options.sortOrder);
1096
+ if (options?.isActive !== void 0) params.set("isActive", String(options.isActive));
1097
+ const query = params.toString();
1098
+ return this.request(`/api/v1/admin/projects${query ? `?${query}` : ""}`, { method: "GET" });
1099
+ }
1100
+ /**
1101
+ * Get project by ID (admin only)
1102
+ */
1103
+ async adminGetProject(projectId) {
1104
+ return this.request(`/api/v1/admin/projects/${projectId}`, { method: "GET" });
1105
+ }
1106
+ /**
1107
+ * Update project (admin only)
1108
+ */
1109
+ async adminUpdateProject(projectId, data) {
1110
+ return this.request(`/api/v1/admin/projects/${projectId}`, {
1111
+ method: "PATCH",
1112
+ body: JSON.stringify(data)
1113
+ });
1114
+ }
1115
+ /**
1116
+ * Regenerate project API key (admin only)
1117
+ */
1118
+ async adminRegenerateApiKey(projectId) {
1119
+ return this.request(`/api/v1/admin/projects/${projectId}/regenerate-key`, { method: "POST" });
1120
+ }
1121
+ /**
1122
+ * Get system statistics (admin only)
1123
+ */
1124
+ async adminGetStats(days) {
1125
+ const query = days ? `?days=${days}` : "";
1126
+ return this.request(`/api/v1/admin/stats${query}`, { method: "GET" });
1127
+ }
1128
+ /**
1129
+ * Get system logs (admin only)
1130
+ */
1131
+ async adminGetLogs(options) {
1132
+ const params = new URLSearchParams();
1133
+ if (options?.level) params.set("level", options.level);
1134
+ if (options?.service) params.set("service", options.service);
1135
+ if (options?.limit) params.set("limit", String(options.limit));
1136
+ if (options?.offset) params.set("offset", String(options.offset));
1137
+ if (options?.startDate) params.set("startDate", options.startDate);
1138
+ if (options?.endDate) params.set("endDate", options.endDate);
1139
+ const query = params.toString();
1140
+ return this.request(`/api/v1/admin/logs${query ? `?${query}` : ""}`, { method: "GET" });
1141
+ }
1142
+ /**
1143
+ * Get rate limit status (admin only)
1144
+ */
1145
+ async adminGetRateLimits(options) {
1146
+ const params = new URLSearchParams();
1147
+ if (options?.identifier) params.set("identifier", options.identifier);
1148
+ if (options?.limit) params.set("limit", String(options.limit));
1149
+ const query = params.toString();
1150
+ return this.request(`/api/v1/admin/rate-limits${query ? `?${query}` : ""}`, { method: "GET" });
1151
+ }
1152
+ /**
1153
+ * Clear rate limits for an identifier (admin only)
1154
+ */
1155
+ async adminClearRateLimits(identifier) {
1156
+ return this.request(`/api/v1/admin/rate-limits/${identifier}`, { method: "DELETE" });
1157
+ }
1158
+ // ========== AI Quant Trading ==========
1159
+ /**
1160
+ * Get all AI trading strategies
1161
+ */
1162
+ async getAIStrategies(filters) {
1163
+ const params = new URLSearchParams();
1164
+ if (filters?.category) params.set("category", filters.category);
1165
+ if (filters?.riskLevel) params.set("risk_level", String(filters.riskLevel));
1166
+ if (filters?.minTvl) params.set("min_tvl", String(filters.minTvl));
1167
+ if (filters?.isActive !== void 0) params.set("is_active", String(filters.isActive));
1168
+ const query = params.toString();
1169
+ return this.request(`/api/v1/ai-quant/strategies${query ? `?${query}` : ""}`, { method: "GET" });
1170
+ }
1171
+ /**
1172
+ * Get AI strategy details
1173
+ */
1174
+ async getAIStrategy(strategyId, include) {
1175
+ const params = new URLSearchParams();
1176
+ if (include?.length) params.set("include", include.join(","));
1177
+ const query = params.toString();
1178
+ return this.request(`/api/v1/ai-quant/strategies/${strategyId}${query ? `?${query}` : ""}`, { method: "GET" });
1179
+ }
1180
+ /**
1181
+ * Get strategy performance history
1182
+ */
1183
+ async getAIStrategyPerformance(strategyId, days = 30) {
1184
+ return this.request(`/api/v1/ai-quant/strategies/${strategyId}?include=performance&days=${days}`, { method: "GET" });
1185
+ }
1186
+ /**
1187
+ * Get real-time market data for strategy pairs
1188
+ */
1189
+ async getAIStrategyMarketData(strategyId) {
1190
+ return this.request(`/api/v1/ai-quant/strategies/${strategyId}?include=market`, { method: "GET" });
1191
+ }
1192
+ /**
1193
+ * Create AI trading order
1194
+ */
1195
+ async createAIOrder(request) {
1196
+ return this.request("/api/v1/ai-quant/orders", {
1197
+ method: "POST",
1198
+ body: JSON.stringify(request)
1199
+ });
1200
+ }
1201
+ /**
1202
+ * Get user's AI orders
1203
+ */
1204
+ async getAIOrders(filters) {
1205
+ const params = new URLSearchParams();
1206
+ if (filters?.strategyId) params.set("strategy_id", filters.strategyId);
1207
+ if (filters?.status) params.set("status", filters.status);
1208
+ const query = params.toString();
1209
+ return this.request(`/api/v1/ai-quant/orders${query ? `?${query}` : ""}`, { method: "GET" });
1210
+ }
1211
+ /**
1212
+ * Get AI order details
1213
+ */
1214
+ async getAIOrder(orderId) {
1215
+ return this.request(`/api/v1/ai-quant/orders/${orderId}`, { method: "GET" });
1216
+ }
1217
+ /**
1218
+ * Pause AI order
1219
+ */
1220
+ async pauseAIOrder(orderId) {
1221
+ return this.request(`/api/v1/ai-quant/orders/${orderId}/pause`, { method: "POST" });
1222
+ }
1223
+ /**
1224
+ * Resume AI order
1225
+ */
1226
+ async resumeAIOrder(orderId) {
1227
+ return this.request(`/api/v1/ai-quant/orders/${orderId}/resume`, { method: "POST" });
1228
+ }
1229
+ /**
1230
+ * Request redemption for AI order
1231
+ */
1232
+ async redeemAIOrder(orderId) {
1233
+ return this.request(`/api/v1/ai-quant/orders/${orderId}/redeem`, { method: "POST" });
1234
+ }
1235
+ /**
1236
+ * Get AI portfolio summary
1237
+ */
1238
+ async getAIPortfolio(include) {
1239
+ const params = new URLSearchParams();
1240
+ if (include?.length) params.set("include", include.join(","));
1241
+ const query = params.toString();
1242
+ return this.request(`/api/v1/ai-quant/portfolio${query ? `?${query}` : ""}`, { method: "GET" });
1243
+ }
1244
+ /**
1245
+ * Get user's trade allocations
1246
+ */
1247
+ async getAITradeAllocations(limit = 50) {
1248
+ return this.request(`/api/v1/ai-quant/portfolio?include=allocations&limit=${limit}`, { method: "GET" });
1249
+ }
1250
+ /**
1251
+ * Get trade history for a strategy
1252
+ */
1253
+ async getAITradeHistory(strategyId, limit = 50) {
1254
+ return this.request(`/api/v1/ai-quant/strategies/${strategyId}?include=trades&limit=${limit}`, { method: "GET" });
1255
+ }
1256
+ /**
1257
+ * Execute AI signals for a strategy (admin only)
1258
+ */
1259
+ async executeAISignals(strategyId) {
1260
+ return this.request("/api/v1/ai-quant/execute", {
1261
+ method: "POST",
1262
+ body: JSON.stringify({ strategyId })
1263
+ });
1264
+ }
1265
+ // ========== Free Price APIs (No API Key Required) ==========
1266
+ /**
1267
+ * Get cryptocurrency prices (FREE - uses CoinGecko/Binance/CoinCap)
1268
+ */
1269
+ async getCryptoPrices(symbols) {
1270
+ return this.request(`/api/v1/prices?symbols=${symbols.join(",")}`, { method: "GET" });
1271
+ }
1272
+ /**
1273
+ * Get single cryptocurrency price (FREE)
1274
+ */
1275
+ async getCryptoPrice(symbol) {
1276
+ return this.request(`/api/v1/prices/${symbol}`, { method: "GET" });
1277
+ }
1278
+ /**
1279
+ * Get OHLCV candles for charting (FREE - from Binance)
1280
+ */
1281
+ async getCryptoCandles(symbol, interval = "1h", limit = 100) {
1282
+ return this.request(`/api/v1/prices/${symbol}?candles=true&interval=${interval}&limit=${limit}`, { method: "GET" });
1283
+ }
1284
+ /**
1285
+ * Get top cryptocurrencies by market cap (FREE)
1286
+ */
1287
+ async getTopCryptos(limit = 20) {
1288
+ return this.request(`/api/v1/prices?type=top&limit=${limit}`, { method: "GET" });
1289
+ }
1290
+ /**
1291
+ * Get crypto market overview (FREE)
1292
+ */
1293
+ async getCryptoMarketOverview() {
1294
+ return this.request("/api/v1/prices?type=overview", { method: "GET" });
1295
+ }
1296
+ };
1297
+ function createOneEngineClient(options) {
1298
+ return new OneEngineClient(options);
1299
+ }
1300
+
1301
+ // src/services/price.ts
1302
+ var COINGECKO_API = "https://api.coingecko.com/api/v3";
1303
+ var FALLBACK_PRICES = {
1304
+ ETH: 3500,
1305
+ BTC: 95e3,
1306
+ BNB: 700,
1307
+ MATIC: 0.5,
1308
+ AVAX: 40,
1309
+ USDT: 1,
1310
+ USDC: 1,
1311
+ DAI: 1,
1312
+ WBTC: 95e3,
1313
+ WETH: 3500,
1314
+ ARB: 1.2,
1315
+ OP: 2.5,
1316
+ LINK: 20,
1317
+ UNI: 12,
1318
+ AAVE: 250,
1319
+ SOL: 200
1320
+ };
1321
+ var PriceService = class {
1322
+ constructor() {
1323
+ this.cache = /* @__PURE__ */ new Map();
1324
+ this.cacheTTL = 60 * 1e3;
1325
+ }
1326
+ // 1 minute cache
1327
+ async getPrice(symbol) {
1328
+ const upperSymbol = symbol.toUpperCase();
1329
+ const cached = this.cache.get(upperSymbol);
1330
+ if (cached && Date.now() - cached.timestamp < this.cacheTTL) {
1331
+ return cached.price;
1332
+ }
1333
+ const coinId = COINGECKO_IDS[upperSymbol];
1334
+ if (!coinId) {
1335
+ return this.getFallbackPrice(upperSymbol);
1336
+ }
1337
+ try {
1338
+ const response = await fetch(
1339
+ `${COINGECKO_API}/simple/price?ids=${coinId}&vs_currencies=usd&include_24hr_change=true&include_market_cap=true&include_24hr_vol=true`,
1340
+ { headers: { Accept: "application/json" } }
1341
+ );
1342
+ if (!response.ok) {
1343
+ throw new Error(`CoinGecko API error: ${response.status}`);
1344
+ }
1345
+ const data = await response.json();
1346
+ const coinData = data[coinId];
1347
+ if (!coinData) {
1348
+ return this.getFallbackPrice(upperSymbol);
1349
+ }
1350
+ const change24h = coinData.usd_24h_change || 0;
1351
+ const price = {
1352
+ symbol: upperSymbol,
1353
+ price: coinData.usd || 0,
1354
+ change24h,
1355
+ changePercent24h: change24h,
1356
+ priceChange24h: change24h,
1357
+ marketCap: coinData.usd_market_cap,
1358
+ volume24h: coinData.usd_24h_vol
1359
+ };
1360
+ this.cache.set(upperSymbol, { price, timestamp: Date.now() });
1361
+ return price;
1362
+ } catch (error) {
1363
+ console.warn(`Failed to fetch price for ${upperSymbol}:`, error);
1364
+ return this.getFallbackPrice(upperSymbol);
1365
+ }
1366
+ }
1367
+ async getPrices(symbols) {
1368
+ const results = {};
1369
+ const withIds = [];
1370
+ const withoutIds = [];
1371
+ for (const symbol of symbols) {
1372
+ const upper = symbol.toUpperCase();
1373
+ if (COINGECKO_IDS[upper]) {
1374
+ withIds.push(upper);
1375
+ } else {
1376
+ withoutIds.push(upper);
1377
+ }
1378
+ }
1379
+ for (const symbol of withoutIds) {
1380
+ results[symbol] = this.getFallbackPrice(symbol);
1381
+ }
1382
+ if (withIds.length === 0) {
1383
+ return results;
1384
+ }
1385
+ const coinIds = withIds.map((s) => COINGECKO_IDS[s]).join(",");
1386
+ try {
1387
+ const response = await fetch(
1388
+ `${COINGECKO_API}/simple/price?ids=${coinIds}&vs_currencies=usd&include_24hr_change=true`,
1389
+ { headers: { Accept: "application/json" } }
1390
+ );
1391
+ if (!response.ok) {
1392
+ throw new Error(`CoinGecko API error: ${response.status}`);
1393
+ }
1394
+ const data = await response.json();
1395
+ for (const symbol of withIds) {
1396
+ const coinId = COINGECKO_IDS[symbol];
1397
+ const coinData = data[coinId];
1398
+ if (coinData) {
1399
+ const change24h = coinData.usd_24h_change || 0;
1400
+ results[symbol] = {
1401
+ symbol,
1402
+ price: coinData.usd || 0,
1403
+ change24h,
1404
+ changePercent24h: change24h,
1405
+ priceChange24h: change24h
1406
+ };
1407
+ } else {
1408
+ results[symbol] = this.getFallbackPrice(symbol);
1409
+ }
1410
+ }
1411
+ } catch (error) {
1412
+ console.warn("Failed to fetch batch prices:", error);
1413
+ for (const symbol of withIds) {
1414
+ results[symbol] = this.getFallbackPrice(symbol);
1415
+ }
1416
+ }
1417
+ return results;
1418
+ }
1419
+ getFallbackPrice(symbol) {
1420
+ const price = FALLBACK_PRICES[symbol] || 0;
1421
+ return {
1422
+ symbol,
1423
+ price,
1424
+ change24h: 0,
1425
+ changePercent24h: 0,
1426
+ priceChange24h: 0
1427
+ };
1428
+ }
1429
+ clearCache() {
1430
+ this.cache.clear();
1431
+ }
1432
+ };
1433
+ var priceService = new PriceService();
1434
+
1435
+ // src/utils/index.ts
1436
+ function shortenAddress(address, chars = 4) {
1437
+ if (!address) return "";
1438
+ return `${address.slice(0, chars + 2)}...${address.slice(-chars)}`;
1439
+ }
1440
+ function isValidAddress(address) {
1441
+ return /^0x[a-fA-F0-9]{40}$/.test(address);
1442
+ }
1443
+ function checksumAddress(address) {
1444
+ return address.toLowerCase();
1445
+ }
1446
+ function formatNumber(value, options = {}) {
1447
+ const { decimals = 2, compact = false, currency, locale = "en-US" } = options;
1448
+ if (currency) {
1449
+ return new Intl.NumberFormat(locale, {
1450
+ style: "currency",
1451
+ currency,
1452
+ minimumFractionDigits: decimals,
1453
+ maximumFractionDigits: decimals,
1454
+ notation: compact ? "compact" : "standard"
1455
+ }).format(value);
1456
+ }
1457
+ return new Intl.NumberFormat(locale, {
1458
+ minimumFractionDigits: decimals,
1459
+ maximumFractionDigits: decimals,
1460
+ notation: compact ? "compact" : "standard"
1461
+ }).format(value);
1462
+ }
1463
+ function formatUSD(value, compact = false) {
1464
+ return formatNumber(value, { currency: "USD", compact });
1465
+ }
1466
+ function formatPercent(value, decimals = 2) {
1467
+ const sign = value >= 0 ? "+" : "";
1468
+ return `${sign}${value.toFixed(decimals)}%`;
1469
+ }
1470
+ function formatTokenAmount(amount, decimals = 6) {
1471
+ if (amount === 0) return "0";
1472
+ if (amount < 1e-6) return "<0.000001";
1473
+ if (amount < 1) return amount.toFixed(decimals);
1474
+ if (amount < 1e3) return amount.toFixed(4);
1475
+ if (amount < 1e6) return formatNumber(amount, { decimals: 2 });
1476
+ return formatNumber(amount, { decimals: 2, compact: true });
1477
+ }
1478
+ function formatDate(date, options = {
1479
+ year: "numeric",
1480
+ month: "short",
1481
+ day: "numeric"
1482
+ }) {
1483
+ const d = typeof date === "string" ? new Date(date) : date;
1484
+ return d.toLocaleDateString("en-US", options);
1485
+ }
1486
+ function formatDateTime(date) {
1487
+ const d = typeof date === "string" ? new Date(date) : date;
1488
+ return d.toLocaleString("en-US", {
1489
+ year: "numeric",
1490
+ month: "short",
1491
+ day: "numeric",
1492
+ hour: "2-digit",
1493
+ minute: "2-digit"
1494
+ });
1495
+ }
1496
+ function formatRelativeTime(date) {
1497
+ const d = typeof date === "string" ? new Date(date) : date;
1498
+ const now = /* @__PURE__ */ new Date();
1499
+ const diffMs = now.getTime() - d.getTime();
1500
+ const diffSec = Math.floor(diffMs / 1e3);
1501
+ const diffMin = Math.floor(diffSec / 60);
1502
+ const diffHour = Math.floor(diffMin / 60);
1503
+ const diffDay = Math.floor(diffHour / 24);
1504
+ if (diffSec < 60) return "just now";
1505
+ if (diffMin < 60) return `${diffMin}m ago`;
1506
+ if (diffHour < 24) return `${diffHour}h ago`;
1507
+ if (diffDay < 7) return `${diffDay}d ago`;
1508
+ return formatDate(d);
1509
+ }
1510
+ function isValidEmail(email) {
1511
+ const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
1512
+ return emailRegex.test(email);
1513
+ }
1514
+ function isValidPhone(phone) {
1515
+ const phoneRegex = /^\+?[1-9]\d{1,14}$/;
1516
+ return phoneRegex.test(phone.replace(/[\s-()]/g, ""));
1517
+ }
1518
+ function capitalize(str) {
1519
+ return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();
1520
+ }
1521
+ function truncate(str, length) {
1522
+ if (str.length <= length) return str;
1523
+ return `${str.slice(0, length)}...`;
1524
+ }
1525
+ function slugify(str) {
1526
+ return str.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/(^-|-$)/g, "");
1527
+ }
1528
+ function sleep(ms) {
1529
+ return new Promise((resolve) => setTimeout(resolve, ms));
1530
+ }
1531
+ async function retry(fn, options = {}) {
1532
+ const { maxAttempts = 3, delay = 1e3, backoff = 2 } = options;
1533
+ let lastError;
1534
+ for (let attempt = 1; attempt <= maxAttempts; attempt++) {
1535
+ try {
1536
+ return await fn();
1537
+ } catch (error) {
1538
+ lastError = error instanceof Error ? error : new Error(String(error));
1539
+ if (attempt < maxAttempts) {
1540
+ await sleep(delay * Math.pow(backoff, attempt - 1));
1541
+ }
1542
+ }
1543
+ }
1544
+ throw lastError;
1545
+ }
1546
+ function omit(obj, keys) {
1547
+ const result = { ...obj };
1548
+ for (const key of keys) {
1549
+ delete result[key];
1550
+ }
1551
+ return result;
1552
+ }
1553
+ function pick(obj, keys) {
1554
+ const result = {};
1555
+ for (const key of keys) {
1556
+ if (key in obj) {
1557
+ result[key] = obj[key];
1558
+ }
1559
+ }
1560
+ return result;
1561
+ }
1562
+ var OneSDKError = class extends Error {
1563
+ constructor(message, code, details) {
1564
+ super(message);
1565
+ this.name = "OneSDKError";
1566
+ this.code = code;
1567
+ this.details = details;
1568
+ }
1569
+ };
1570
+ function isOneSDKError(error) {
1571
+ return error instanceof OneSDKError;
1572
+ }
1573
+
1574
+ // src/react-native.ts
1575
+ function createCachedEngineClient(storage, options) {
1576
+ const client = createOneEngineClient(options);
1577
+ return {
1578
+ ...client,
1579
+ /**
1580
+ * Initialize with stored token
1581
+ */
1582
+ async initialize() {
1583
+ const token = await storage.getItem("one_access_token");
1584
+ if (token) {
1585
+ client.setAccessToken(token);
1586
+ return true;
1587
+ }
1588
+ return false;
1589
+ },
1590
+ /**
1591
+ * Login and persist token
1592
+ */
1593
+ async login(email, otp) {
1594
+ const result = await client.verifyEmailOtp(email, otp);
1595
+ if (result.success && result.data?.accessToken) {
1596
+ await storage.setItem("one_access_token", result.data.accessToken);
1597
+ if (result.data.refreshToken) {
1598
+ await storage.setItem("one_refresh_token", result.data.refreshToken);
1599
+ }
1600
+ }
1601
+ return result;
1602
+ },
1603
+ /**
1604
+ * Logout and clear stored tokens
1605
+ */
1606
+ async logout() {
1607
+ await client.signOut();
1608
+ await storage.removeItem("one_access_token");
1609
+ await storage.removeItem("one_refresh_token");
1610
+ client.clearAccessToken();
1611
+ },
1612
+ /**
1613
+ * Refresh token from storage
1614
+ */
1615
+ async refreshFromStorage() {
1616
+ const refreshToken = await storage.getItem("one_refresh_token");
1617
+ if (refreshToken) {
1618
+ const result = await client.refreshToken(refreshToken);
1619
+ if (result.success && result.data?.accessToken) {
1620
+ await storage.setItem("one_access_token", result.data.accessToken);
1621
+ if (result.data.refreshToken) {
1622
+ await storage.setItem("one_refresh_token", result.data.refreshToken);
1623
+ }
1624
+ return true;
1625
+ }
1626
+ }
1627
+ return false;
1628
+ },
1629
+ // Expose underlying client
1630
+ getClient: () => client
1631
+ };
1632
+ }
1633
+ function createDeepLinkHandler(scheme = "onewallet") {
1634
+ return {
1635
+ parse(url) {
1636
+ try {
1637
+ const urlObj = new URL(url);
1638
+ const path = urlObj.pathname.replace(/^\//, "");
1639
+ const params = {};
1640
+ urlObj.searchParams.forEach((value, key) => {
1641
+ params[key] = value;
1642
+ });
1643
+ let type = "unknown";
1644
+ if (path.includes("onramp") || path.includes("callback")) {
1645
+ type = "onramp_callback";
1646
+ } else if (path.includes("wc") || path.includes("walletconnect")) {
1647
+ type = "wallet_connect";
1648
+ } else if (path.includes("pay") || path.includes("payment")) {
1649
+ type = "payment";
1650
+ }
1651
+ return { type, params };
1652
+ } catch {
1653
+ return { type: "unknown", params: {} };
1654
+ }
1655
+ },
1656
+ generate(type, params) {
1657
+ const searchParams = new URLSearchParams(params);
1658
+ return `${scheme}://${type}?${searchParams.toString()}`;
1659
+ }
1660
+ };
1661
+ }
1662
+ function parseQRCode(data) {
1663
+ if (/^0x[a-fA-F0-9]{40}$/.test(data)) {
1664
+ return {
1665
+ type: "address",
1666
+ data,
1667
+ parsed: { address: data }
1668
+ };
1669
+ }
1670
+ if (data.startsWith("ethereum:")) {
1671
+ const match = data.match(/^ethereum:(0x[a-fA-F0-9]{40})(?:@(\d+))?(?:\?(.*))?$/);
1672
+ if (match) {
1673
+ const [, address, chainId, queryString] = match;
1674
+ const params = new URLSearchParams(queryString || "");
1675
+ return {
1676
+ type: "payment_request",
1677
+ data,
1678
+ parsed: {
1679
+ address,
1680
+ chainId: chainId ? parseInt(chainId) : void 0,
1681
+ amount: params.get("value") || void 0,
1682
+ token: params.get("token") || void 0,
1683
+ message: params.get("message") || void 0
1684
+ }
1685
+ };
1686
+ }
1687
+ }
1688
+ if (data.startsWith("wc:")) {
1689
+ return {
1690
+ type: "wallet_connect",
1691
+ data
1692
+ };
1693
+ }
1694
+ return { type: "unknown", data };
1695
+ }
1696
+ function formatCryptoAmount(amount, symbol, options = {}) {
1697
+ const { maxDecimals = 6, showSymbol = true, compact = false } = options;
1698
+ const num = typeof amount === "string" ? parseFloat(amount) : amount;
1699
+ if (isNaN(num)) return showSymbol ? `0 ${symbol}` : "0";
1700
+ let formatted;
1701
+ if (compact && num >= 1e6) {
1702
+ formatted = (num / 1e6).toFixed(2) + "M";
1703
+ } else if (compact && num >= 1e3) {
1704
+ formatted = (num / 1e3).toFixed(2) + "K";
1705
+ } else if (num < 1e-6 && num > 0) {
1706
+ formatted = "<0.000001";
1707
+ } else {
1708
+ const decimals = num < 1 ? maxDecimals : Math.min(maxDecimals, 4);
1709
+ formatted = num.toFixed(decimals).replace(/\.?0+$/, "");
1710
+ }
1711
+ return showSymbol ? `${formatted} ${symbol}` : formatted;
1712
+ }
1713
+ function generateShareContent(params) {
1714
+ const { type, address, amount, token, txHash, chainId } = params;
1715
+ switch (type) {
1716
+ case "receive":
1717
+ return {
1718
+ title: "My Wallet Address",
1719
+ message: `Send ${token || "crypto"} to my wallet:
1720
+ ${address}`,
1721
+ url: address ? `ethereum:${address}${chainId ? `@${chainId}` : ""}` : void 0
1722
+ };
1723
+ case "payment_request":
1724
+ return {
1725
+ title: "Payment Request",
1726
+ message: `Please send ${amount} ${token} to:
1727
+ ${address}`,
1728
+ url: `ethereum:${address}${chainId ? `@${chainId}` : ""}?value=${amount}${token ? `&token=${token}` : ""}`
1729
+ };
1730
+ case "transaction":
1731
+ return {
1732
+ title: "Transaction Sent",
1733
+ message: `Transaction confirmed!
1734
+ Hash: ${txHash}`,
1735
+ url: txHash ? getExplorerUrl(chainId || 1, txHash, "tx") : void 0
1736
+ };
1737
+ default:
1738
+ return { title: "", message: "" };
1739
+ }
1740
+ }
1741
+ function getExplorerUrl(chainId, hash, type = "tx") {
1742
+ const explorers = {
1743
+ 1: "https://etherscan.io",
1744
+ 137: "https://polygonscan.com",
1745
+ 42161: "https://arbiscan.io",
1746
+ 10: "https://optimistic.etherscan.io",
1747
+ 8453: "https://basescan.org",
1748
+ 56: "https://bscscan.com",
1749
+ 43114: "https://snowtrace.io"
1750
+ };
1751
+ const baseUrl = explorers[chainId] || explorers[1];
1752
+ return `${baseUrl}/${type}/${hash}`;
1753
+ }
1754
+
1755
+ exports.CHAIN_CONFIGS = CHAIN_CONFIGS;
1756
+ exports.COINGECKO_IDS = COINGECKO_IDS;
1757
+ exports.OneEngineClient = OneEngineClient;
1758
+ exports.OneSDKError = OneSDKError;
1759
+ exports.PriceService = PriceService;
1760
+ exports.TOKEN_NAMES = TOKEN_NAMES;
1761
+ exports.capitalize = capitalize;
1762
+ exports.checksumAddress = checksumAddress;
1763
+ exports.createCachedEngineClient = createCachedEngineClient;
1764
+ exports.createDeepLinkHandler = createDeepLinkHandler;
1765
+ exports.createOneEngineClient = createOneEngineClient;
1766
+ exports.formatCryptoAmount = formatCryptoAmount;
1767
+ exports.formatDate = formatDate;
1768
+ exports.formatDateTime = formatDateTime;
1769
+ exports.formatNumber = formatNumber;
1770
+ exports.formatPercent = formatPercent;
1771
+ exports.formatRelativeTime = formatRelativeTime;
1772
+ exports.formatTokenAmount = formatTokenAmount;
1773
+ exports.formatUSD = formatUSD;
1774
+ exports.generateShareContent = generateShareContent;
1775
+ exports.getConfig = getConfig;
1776
+ exports.getExplorerUrl = getExplorerUrl;
1777
+ exports.initOneSDK = initOneSDK;
1778
+ exports.isOneSDKError = isOneSDKError;
1779
+ exports.isValidAddress = isValidAddress;
1780
+ exports.isValidEmail = isValidEmail;
1781
+ exports.isValidPhone = isValidPhone;
1782
+ exports.omit = omit;
1783
+ exports.parseQRCode = parseQRCode;
1784
+ exports.pick = pick;
1785
+ exports.priceService = priceService;
1786
+ exports.retry = retry;
1787
+ exports.shortenAddress = shortenAddress;
1788
+ exports.sleep = sleep;
1789
+ exports.slugify = slugify;
1790
+ exports.truncate = truncate;
1791
+ //# sourceMappingURL=react-native.js.map
1792
+ //# sourceMappingURL=react-native.js.map