@one_deploy/sdk 1.0.6 → 1.2.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.
- package/README.md +339 -0
- package/dist/ForexPoolDataGenerator--__twRwl.d.mts +76 -0
- package/dist/ForexPoolDataGenerator-eUgwsU_B.d.ts +76 -0
- package/dist/OneForexTradeHistory-TlKxjbFF.d.ts +250 -0
- package/dist/OneForexTradeHistory-iDySMcw0.d.mts +250 -0
- package/dist/components/index.d.mts +539 -0
- package/dist/components/index.d.ts +539 -0
- package/dist/components/index.js +7295 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/index.mjs +7243 -0
- package/dist/components/index.mjs.map +1 -0
- package/dist/config/index.d.mts +1 -0
- package/dist/config/index.d.ts +1 -0
- package/dist/console-BfTMA7ah.d.mts +504 -0
- package/dist/console-BfTMA7ah.d.ts +504 -0
- package/dist/hooks/index.d.mts +323 -1
- package/dist/hooks/index.d.ts +323 -1
- package/dist/hooks/index.js +3223 -0
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +3204 -1
- package/dist/hooks/index.mjs.map +1 -1
- package/dist/index.d.mts +18 -352
- package/dist/index.d.ts +18 -352
- package/dist/index.js +8646 -574
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +8449 -432
- package/dist/index.mjs.map +1 -1
- package/dist/providers/index.d.mts +31 -31
- package/dist/providers/index.d.ts +31 -31
- package/dist/providers/index.js +140 -153
- package/dist/providers/index.js.map +1 -1
- package/dist/providers/index.mjs +100 -109
- package/dist/providers/index.mjs.map +1 -1
- package/dist/react-native.d.mts +8 -140
- package/dist/react-native.d.ts +8 -140
- package/dist/react-native.js +2527 -0
- package/dist/react-native.js.map +1 -1
- package/dist/react-native.mjs +2497 -2
- package/dist/react-native.mjs.map +1 -1
- package/dist/services/index.d.mts +85 -4
- package/dist/services/index.d.ts +85 -4
- package/dist/services/index.js +1621 -0
- package/dist/services/index.js.map +1 -1
- package/dist/services/index.mjs +1619 -1
- package/dist/services/index.mjs.map +1 -1
- package/dist/types/index.d.mts +203 -1
- package/dist/types/index.d.ts +203 -1
- package/dist/types/index.js +275 -0
- package/dist/types/index.js.map +1 -1
- package/dist/types/index.mjs +251 -0
- package/dist/types/index.mjs.map +1 -1
- package/dist/useForexTrading-BleeSor8.d.mts +80 -0
- package/dist/useForexTrading-ZgW_G40Q.d.ts +80 -0
- package/package.json +9 -2
- package/src/components/OneConnectButton.tsx +24 -1
- package/src/components/OneNFTGallery.tsx +13 -7
- package/src/components/OneOfframpWidget.tsx +4 -3
- package/src/components/OnePayWidget.tsx +10 -1
- package/src/components/OneSendWidget.tsx +3 -3
- package/src/components/OneSwapWidget.tsx +4 -4
- package/src/components/OneTransactionButton.tsx +28 -3
- package/src/components/OneWalletBalance.tsx +1 -1
- package/src/components/ai/OneForexCapitalSplit.tsx +112 -0
- package/src/components/ai/OneForexConsoleView.tsx +90 -0
- package/src/components/ai/OneForexPairSelector.tsx +101 -0
- package/src/components/ai/OneForexPoolCard.tsx +105 -0
- package/src/components/ai/OneForexTradeHistory.tsx +107 -0
- package/src/components/ai/console/OneAIQuantConsole.tsx +423 -0
- package/src/components/ai/console/OneAgentCard.tsx +383 -0
- package/src/components/ai/console/OneAgentConsole.tsx +469 -0
- package/src/components/ai/console/OneDecisionTimeline.tsx +433 -0
- package/src/components/ai/console/OneMetricsDashboard.tsx +493 -0
- package/src/components/ai/console/OnePositionCard.tsx +406 -0
- package/src/components/ai/console/OnePositionDetail.tsx +600 -0
- package/src/components/ai/console/OneRiskIndicator.tsx +464 -0
- package/src/components/ai/console/OneTradingConsole.tsx +660 -0
- package/src/components/ai/console/index.ts +17 -0
- package/src/components/ai/index.ts +10 -0
- package/src/hooks/index.ts +46 -0
- package/src/hooks/useAIDecisions.ts +280 -0
- package/src/hooks/useAIPositions.ts +349 -0
- package/src/hooks/useAIQuantConsole.ts +283 -0
- package/src/hooks/useAIRiskStatus.ts +276 -0
- package/src/hooks/useAITrading.ts +190 -0
- package/src/hooks/useBotSimulation.ts +201 -0
- package/src/hooks/useForexTrading.ts +430 -0
- package/src/hooks/useTradingConsole.ts +243 -0
- package/src/index.ts +123 -5
- package/src/providers/OneProvider.tsx +181 -5
- package/src/providers/index.ts +22 -8
- package/src/react-native.ts +41 -0
- package/src/services/forex/BotSimulationEngine.ts +968 -0
- package/src/services/forex/ForexPoolDataGenerator.ts +542 -0
- package/src/services/forex/ForexSimulationEngine.ts +482 -0
- package/src/services/forex/index.ts +21 -0
- package/src/services/index.ts +16 -0
- package/src/types/aiTrading.ts +151 -0
- package/src/types/console.ts +380 -0
- package/src/types/forex.ts +282 -0
- package/src/types/index.ts +106 -0
- package/dist/price-CgqXPnT3.d.ts +0 -13
- package/dist/price-ClbLHHjv.d.mts +0 -13
- package/dist/supabase-BT0c7q9e.d.mts +0 -82
- package/dist/supabase-BT0c7q9e.d.ts +0 -82
package/README.md
ADDED
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
# @one_deploy/sdk
|
|
2
|
+
|
|
3
|
+
The complete Web3 SDK for wallet, payments, AI trading, and on-chain forex. Build production-ready decentralized applications with pre-built UI components, React hooks, and a unified API client supporting 200+ EVM chains.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@one_deploy/sdk)
|
|
6
|
+
[](LICENSE)
|
|
7
|
+
|
|
8
|
+
## Features
|
|
9
|
+
|
|
10
|
+
- **Multi-Chain Wallets** -- Smart wallets and EOA support across 200+ EVM chains
|
|
11
|
+
- **Payment Widgets** -- On-ramp, off-ramp, swap, and send components out of the box
|
|
12
|
+
- **AI Trading** -- Automated trading strategies with configurable risk levels and cycles
|
|
13
|
+
- **StableFX Forex** -- On-chain forex trading with stablecoin pairs and pool allocation
|
|
14
|
+
- **React & React Native** -- Separate optimized entry points for web and mobile
|
|
15
|
+
- **TypeScript** -- Comprehensive type definitions for all APIs and components
|
|
16
|
+
- **Tree-Shakable** -- Modular exports with CJS + ESM dual build
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm install @one_deploy/sdk
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### Peer Dependencies
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
# Required for React web apps
|
|
28
|
+
npm install react react-dom
|
|
29
|
+
|
|
30
|
+
# Required for Web3 features
|
|
31
|
+
npm install thirdweb
|
|
32
|
+
|
|
33
|
+
# Required for React Native apps
|
|
34
|
+
npm install react-native
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Quick Start
|
|
38
|
+
|
|
39
|
+
### Web (React)
|
|
40
|
+
|
|
41
|
+
```tsx
|
|
42
|
+
import { OneProvider, OneThirdwebProvider, initOneSDK } from '@one_deploy/sdk';
|
|
43
|
+
|
|
44
|
+
// Initialize the SDK
|
|
45
|
+
initOneSDK({
|
|
46
|
+
clientId: process.env.ONE_CLIENT_ID!,
|
|
47
|
+
secretKey: process.env.ONE_SECRET_KEY!,
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
function App() {
|
|
51
|
+
return (
|
|
52
|
+
<OneThirdwebProvider clientId={process.env.THIRDWEB_CLIENT_ID!}>
|
|
53
|
+
<OneProvider>
|
|
54
|
+
<YourApp />
|
|
55
|
+
</OneProvider>
|
|
56
|
+
</OneThirdwebProvider>
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### React Native
|
|
62
|
+
|
|
63
|
+
```tsx
|
|
64
|
+
import {
|
|
65
|
+
OneEngineClient,
|
|
66
|
+
createCachedEngineClient,
|
|
67
|
+
StorageAdapter,
|
|
68
|
+
} from '@one_deploy/sdk/react-native';
|
|
69
|
+
|
|
70
|
+
const storage: StorageAdapter = {
|
|
71
|
+
getItem: async (key) => AsyncStorage.getItem(key),
|
|
72
|
+
setItem: async (key, value) => AsyncStorage.setItem(key, value),
|
|
73
|
+
removeItem: async (key) => AsyncStorage.removeItem(key),
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const engine = createCachedEngineClient({
|
|
77
|
+
apiKey: 'YOUR_API_KEY',
|
|
78
|
+
projectId: 'YOUR_PROJECT_ID',
|
|
79
|
+
storage,
|
|
80
|
+
});
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Package Exports
|
|
84
|
+
|
|
85
|
+
The SDK provides modular entry points for tree-shaking:
|
|
86
|
+
|
|
87
|
+
```typescript
|
|
88
|
+
import { ... } from '@one_deploy/sdk'; // Full web entry
|
|
89
|
+
import { ... } from '@one_deploy/sdk/react-native'; // Mobile entry
|
|
90
|
+
import { ... } from '@one_deploy/sdk/services'; // Services only
|
|
91
|
+
import { ... } from '@one_deploy/sdk/types'; // Type definitions
|
|
92
|
+
import { ... } from '@one_deploy/sdk/hooks'; // React hooks
|
|
93
|
+
import { ... } from '@one_deploy/sdk/components'; // UI components
|
|
94
|
+
import { ... } from '@one_deploy/sdk/providers'; // React providers
|
|
95
|
+
import { ... } from '@one_deploy/sdk/utils'; // Utility functions
|
|
96
|
+
import { ... } from '@one_deploy/sdk/config'; // Configuration
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Components
|
|
100
|
+
|
|
101
|
+
### Wallet & Connection
|
|
102
|
+
|
|
103
|
+
| Component | Description |
|
|
104
|
+
|-----------|-------------|
|
|
105
|
+
| `OneConnectButton` | Wallet connection with auth options |
|
|
106
|
+
| `OneConnectButtonSimple` | Minimal connect button preset |
|
|
107
|
+
| `OneConnectButtonFull` | Full-featured connect button preset |
|
|
108
|
+
| `OneWalletBalance` | Display wallet balance |
|
|
109
|
+
| `OneBalanceDisplay` | Formatted balance display |
|
|
110
|
+
|
|
111
|
+
### Payments
|
|
112
|
+
|
|
113
|
+
| Component | Description |
|
|
114
|
+
|-----------|-------------|
|
|
115
|
+
| `OnePayWidget` | Flexible payment interface (fund, direct pay, crypto-only, fiat-only) |
|
|
116
|
+
| `OneOnrampWidget` | Buy crypto with fiat (BTC, ETH, USDT, USDC presets) |
|
|
117
|
+
| `OneOfframpWidget` | Sell crypto for fiat (ETH, USDT, USDC presets) |
|
|
118
|
+
| `OneSwapWidget` | Token swap (same-chain and cross-chain presets) |
|
|
119
|
+
| `OneSendWidget` | Send crypto (ETH, USDC presets) |
|
|
120
|
+
| `OneReceiveWidget` | Receive funds with QR code |
|
|
121
|
+
|
|
122
|
+
### Transactions
|
|
123
|
+
|
|
124
|
+
| Component | Description |
|
|
125
|
+
|-----------|-------------|
|
|
126
|
+
| `OneTransactionButton` | Generic transaction executor |
|
|
127
|
+
| `OneSendETHButton` | One-click ETH send |
|
|
128
|
+
| `OneApproveButton` | Token approval button |
|
|
129
|
+
|
|
130
|
+
### AI Trading
|
|
131
|
+
|
|
132
|
+
| Component | Description |
|
|
133
|
+
|-----------|-------------|
|
|
134
|
+
| `OneChainSelector` | Blockchain network selection |
|
|
135
|
+
| `OneTierSelector` | Investment tier selection |
|
|
136
|
+
| `OneCycleSelector` | Cycle duration selection |
|
|
137
|
+
| `OnePairSelector` | Trading pair selection |
|
|
138
|
+
|
|
139
|
+
### StableFX Forex
|
|
140
|
+
|
|
141
|
+
| Component | Description |
|
|
142
|
+
|-----------|-------------|
|
|
143
|
+
| `OneForexPoolCard` | Pool information display |
|
|
144
|
+
| `OneForexCapitalSplit` | Capital allocation visualization |
|
|
145
|
+
| `OneForexConsoleView` | Trading console with live logs |
|
|
146
|
+
| `OneForexPairSelector` | Currency pair selector |
|
|
147
|
+
| `OneForexTradeHistory` | Trade history table |
|
|
148
|
+
|
|
149
|
+
## Hooks
|
|
150
|
+
|
|
151
|
+
### General
|
|
152
|
+
|
|
153
|
+
| Hook | Description |
|
|
154
|
+
|------|-------------|
|
|
155
|
+
| `useWalletBalance` | Wallet balance with auto-refresh |
|
|
156
|
+
| `useTokenPrice` | Single token price |
|
|
157
|
+
| `useTokenPrices` | Multiple token prices |
|
|
158
|
+
|
|
159
|
+
### Provider Hooks (require `OneProvider`)
|
|
160
|
+
|
|
161
|
+
| Hook | Description |
|
|
162
|
+
|------|-------------|
|
|
163
|
+
| `useOne` | Core SDK context |
|
|
164
|
+
| `useOneAuth` | Authentication state and methods |
|
|
165
|
+
| `useOneWallet` | Wallet operations |
|
|
166
|
+
| `useOneOnramp` | On-ramp operations |
|
|
167
|
+
| `useOneSwap` | Swap operations |
|
|
168
|
+
| `useOneTrading` | Trading operations |
|
|
169
|
+
| `useOneEngine` | Direct engine client access |
|
|
170
|
+
|
|
171
|
+
### AI Trading Hooks
|
|
172
|
+
|
|
173
|
+
| Hook | Description |
|
|
174
|
+
|------|-------------|
|
|
175
|
+
| `useAIStrategies` | List available strategies |
|
|
176
|
+
| `useAIStrategy` | Single strategy details |
|
|
177
|
+
| `useAIOrders` | User's AI orders |
|
|
178
|
+
| `useAIPortfolio` | Portfolio summary and metrics |
|
|
179
|
+
| `useAIMarketData` | Live market data |
|
|
180
|
+
| `useAITrading` | Combined AI trading hook |
|
|
181
|
+
|
|
182
|
+
### Forex Hooks
|
|
183
|
+
|
|
184
|
+
| Hook | Description |
|
|
185
|
+
|------|-------------|
|
|
186
|
+
| `useForexPools` | Pool data and allocations |
|
|
187
|
+
| `useForexInvestments` | User investments |
|
|
188
|
+
| `useForexSimulation` | Simulation engine |
|
|
189
|
+
| `useForexPoolData` | Pool statistics and snapshots |
|
|
190
|
+
| `useForexTrading` | Combined forex trading hook |
|
|
191
|
+
|
|
192
|
+
## API Client
|
|
193
|
+
|
|
194
|
+
The `OneEngineClient` provides 91+ methods covering all platform features:
|
|
195
|
+
|
|
196
|
+
```typescript
|
|
197
|
+
import { OneEngineClient } from '@one_deploy/sdk';
|
|
198
|
+
|
|
199
|
+
const engine = new OneEngineClient({
|
|
200
|
+
apiKey: 'YOUR_API_KEY',
|
|
201
|
+
projectId: 'YOUR_PROJECT_ID',
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
// Authentication
|
|
205
|
+
await engine.sendOTP({ email: 'user@example.com' });
|
|
206
|
+
const session = await engine.verifyOTP({ email: 'user@example.com', code: '123456' });
|
|
207
|
+
|
|
208
|
+
// Wallet
|
|
209
|
+
const balance = await engine.getWalletBalance({ address, chainId: 8453 });
|
|
210
|
+
|
|
211
|
+
// Swap
|
|
212
|
+
const quote = await engine.getSwapQuote({ fromToken, toToken, amount, chainId });
|
|
213
|
+
await engine.executeSwap(quote);
|
|
214
|
+
|
|
215
|
+
// AI Trading
|
|
216
|
+
const strategies = await engine.getAIStrategies();
|
|
217
|
+
const order = await engine.createAIOrder({ strategyId, chainId, tierId, cycleDays, pair, amount });
|
|
218
|
+
|
|
219
|
+
// Contracts
|
|
220
|
+
const result = await engine.readContract({ contractAddress, functionName, args, chainId });
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
### API Categories
|
|
224
|
+
|
|
225
|
+
| Category | Methods |
|
|
226
|
+
|----------|---------|
|
|
227
|
+
| Authentication | 6 methods (OTP, wallet signature, sessions) |
|
|
228
|
+
| Wallet & Assets | 7 methods (balance, portfolio, transactions) |
|
|
229
|
+
| Swap | 5 methods (quotes, execution, routes) |
|
|
230
|
+
| On/Off Ramp | 8 methods (fiat conversions) |
|
|
231
|
+
| AI Trading | 18 methods (strategies, orders, portfolio) |
|
|
232
|
+
| Forex | Pool, investment, and trade endpoints |
|
|
233
|
+
| Contracts & NFTs | 9 methods (read, write, deploy) |
|
|
234
|
+
| Bills & Staking | 9 methods |
|
|
235
|
+
| Bridge & Gas | 6 methods |
|
|
236
|
+
| Price | 5 methods (no auth required) |
|
|
237
|
+
| Webhooks | 7 methods |
|
|
238
|
+
| Admin | 11 methods |
|
|
239
|
+
| Project | 8 methods |
|
|
240
|
+
|
|
241
|
+
## Supported Chains
|
|
242
|
+
|
|
243
|
+
Default chain configurations include:
|
|
244
|
+
|
|
245
|
+
| Chain | ID |
|
|
246
|
+
|-------|----|
|
|
247
|
+
| Ethereum | 1 |
|
|
248
|
+
| Polygon | 137 |
|
|
249
|
+
| BNB Chain | 56 |
|
|
250
|
+
| Arbitrum | 42161 |
|
|
251
|
+
| Optimism | 10 |
|
|
252
|
+
| Base | 8453 |
|
|
253
|
+
| Avalanche | 43114 |
|
|
254
|
+
| zkSync Era | 324 |
|
|
255
|
+
| Linea | 59144 |
|
|
256
|
+
| Scroll | 534352 |
|
|
257
|
+
| Blast | 81457 |
|
|
258
|
+
|
|
259
|
+
Testnets: Sepolia (11155111), Base Sepolia (84532), Arbitrum Sepolia (421614)
|
|
260
|
+
|
|
261
|
+
Additional chains are loaded dynamically from the ONE Engine API.
|
|
262
|
+
|
|
263
|
+
## Services
|
|
264
|
+
|
|
265
|
+
| Service | Description |
|
|
266
|
+
|---------|-------------|
|
|
267
|
+
| `OneEngineClient` | Main API gateway to ONE Engine |
|
|
268
|
+
| `SupabaseService` | Direct database access layer |
|
|
269
|
+
| `PriceService` | Token price caching with fallback |
|
|
270
|
+
| `UsageService` | Usage tracking and analytics |
|
|
271
|
+
| `ForexSimulationEngine` | Forex trading simulation |
|
|
272
|
+
| `ForexPoolDataGenerator` | Pool data generation |
|
|
273
|
+
| `BotSimulationEngine` | Trading bot simulation |
|
|
274
|
+
|
|
275
|
+
## Utilities
|
|
276
|
+
|
|
277
|
+
```typescript
|
|
278
|
+
import {
|
|
279
|
+
shortenAddress,
|
|
280
|
+
isValidAddress,
|
|
281
|
+
formatUSD,
|
|
282
|
+
formatTokenAmount,
|
|
283
|
+
formatRelativeTime,
|
|
284
|
+
retry,
|
|
285
|
+
OneSDKError,
|
|
286
|
+
} from '@one_deploy/sdk/utils';
|
|
287
|
+
|
|
288
|
+
shortenAddress('0x1234...5678'); // "0x1234...5678"
|
|
289
|
+
formatUSD(1234.56); // "$1,234.56"
|
|
290
|
+
formatTokenAmount(1.23456789, 'ETH'); // "1.2346 ETH"
|
|
291
|
+
formatRelativeTime(new Date()); // "just now"
|
|
292
|
+
await retry(() => fetchData(), 3); // Retry with exponential backoff
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
## Project Structure
|
|
296
|
+
|
|
297
|
+
```
|
|
298
|
+
src/
|
|
299
|
+
├── index.ts # Web entry point
|
|
300
|
+
├── react-native.ts # Mobile entry point
|
|
301
|
+
├── config/ # SDK configuration & chain data
|
|
302
|
+
├── types/ # TypeScript type definitions
|
|
303
|
+
├── providers/ # OneProvider & OneThirdwebProvider
|
|
304
|
+
├── components/ # UI components (web + RN)
|
|
305
|
+
├── hooks/ # React hooks
|
|
306
|
+
├── services/ # API clients & simulation engines
|
|
307
|
+
└── utils/ # Utility functions
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
## Build
|
|
311
|
+
|
|
312
|
+
```bash
|
|
313
|
+
# Development
|
|
314
|
+
npm run dev
|
|
315
|
+
|
|
316
|
+
# Production build (CJS + ESM)
|
|
317
|
+
npm run build
|
|
318
|
+
|
|
319
|
+
# Type checking
|
|
320
|
+
npm run typecheck
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
Built with [tsup](https://tsup.egoist.dev/) -- outputs both CommonJS and ESM formats with TypeScript declarations and source maps.
|
|
324
|
+
|
|
325
|
+
## Documentation
|
|
326
|
+
|
|
327
|
+
Full documentation is available at **[docs.one23.io](https://docs.one23.io)**.
|
|
328
|
+
|
|
329
|
+
- [Getting Started](https://docs.one23.io/docs/getting-started/overview)
|
|
330
|
+
- [Wallet Integration](https://docs.one23.io/docs/wallet/overview)
|
|
331
|
+
- [Payments](https://docs.one23.io/docs/payments/overview)
|
|
332
|
+
- [AI Trading](https://docs.one23.io/docs/ai-trading/overview)
|
|
333
|
+
- [Forex](https://docs.one23.io/docs/forex/overview)
|
|
334
|
+
- [API Reference](https://docs.one23.io/docs/api-reference/overview)
|
|
335
|
+
- [Hooks Reference](https://docs.one23.io/docs/hooks/overview)
|
|
336
|
+
|
|
337
|
+
## License
|
|
338
|
+
|
|
339
|
+
MIT
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { TokenPrice } from './types/index.mjs';
|
|
2
|
+
import { t as ForexLogEntry, m as ForexPoolTransaction, g as ForexCurrencyPair, i as ForexPoolType, n as ForexPoolDailySnapshot, r as ForexTradeRecord, l as ForexPoolTransactionType } from './console-BfTMA7ah.mjs';
|
|
3
|
+
|
|
4
|
+
declare class PriceService {
|
|
5
|
+
private cache;
|
|
6
|
+
private cacheTTL;
|
|
7
|
+
getPrice(symbol: string): Promise<TokenPrice>;
|
|
8
|
+
getPrices(symbols: string[]): Promise<Record<string, TokenPrice>>;
|
|
9
|
+
private getFallbackPrice;
|
|
10
|
+
clearCache(): void;
|
|
11
|
+
}
|
|
12
|
+
declare const priceService: PriceService;
|
|
13
|
+
|
|
14
|
+
type LogCallback = (entry: ForexLogEntry) => void;
|
|
15
|
+
type PoolTxCallback = (tx: ForexPoolTransaction) => void;
|
|
16
|
+
interface PairState {
|
|
17
|
+
pair: ForexCurrencyPair;
|
|
18
|
+
currentPrice: number;
|
|
19
|
+
bidPrice: number;
|
|
20
|
+
askPrice: number;
|
|
21
|
+
lastSpread: number;
|
|
22
|
+
}
|
|
23
|
+
declare class ForexSimulationEngine {
|
|
24
|
+
private listeners;
|
|
25
|
+
private poolTxListeners;
|
|
26
|
+
private cycleTimer;
|
|
27
|
+
private pairStates;
|
|
28
|
+
private running;
|
|
29
|
+
private openPositions;
|
|
30
|
+
private totalPnl;
|
|
31
|
+
private totalTrades;
|
|
32
|
+
private totalPips;
|
|
33
|
+
private totalLots;
|
|
34
|
+
constructor();
|
|
35
|
+
start(): void;
|
|
36
|
+
stop(): void;
|
|
37
|
+
onLog(callback: LogCallback): () => void;
|
|
38
|
+
onPoolTransaction(callback: PoolTxCallback): () => void;
|
|
39
|
+
isRunning(): boolean;
|
|
40
|
+
getStats(): {
|
|
41
|
+
totalPnl: number;
|
|
42
|
+
totalTrades: number;
|
|
43
|
+
totalPips: number;
|
|
44
|
+
totalLots: number;
|
|
45
|
+
positions: number;
|
|
46
|
+
};
|
|
47
|
+
getPairStates(): Map<string, PairState>;
|
|
48
|
+
emitBootSequence(): void;
|
|
49
|
+
destroy(): void;
|
|
50
|
+
private emit;
|
|
51
|
+
private emitPoolTx;
|
|
52
|
+
private generatePoolTxFromEvent;
|
|
53
|
+
private scheduleCycle;
|
|
54
|
+
private simulatePrice;
|
|
55
|
+
private runTradeCycle;
|
|
56
|
+
}
|
|
57
|
+
declare const forexSimulationEngine: ForexSimulationEngine;
|
|
58
|
+
|
|
59
|
+
declare class ForexPoolDataGeneratorClass {
|
|
60
|
+
private snapshotCache;
|
|
61
|
+
private transactionCache;
|
|
62
|
+
private baseBlockNumber;
|
|
63
|
+
generateAllSnapshots(): Record<ForexPoolType, ForexPoolDailySnapshot[]>;
|
|
64
|
+
generateAllTransactions(): ForexPoolTransaction[];
|
|
65
|
+
generateTradeHistory(investmentAmount: number, startDate: string, selectedPairs: string[]): ForexTradeRecord[];
|
|
66
|
+
generateLiveTransaction(poolId: ForexPoolType, type: ForexPoolTransactionType, baseAmount?: number): ForexPoolTransaction;
|
|
67
|
+
private generatePoolSnapshots;
|
|
68
|
+
private generatePoolTransactions;
|
|
69
|
+
private gaussianRandom;
|
|
70
|
+
private getTxDescription;
|
|
71
|
+
}
|
|
72
|
+
declare const ForexPoolDataGenerator: {
|
|
73
|
+
getInstance(): ForexPoolDataGeneratorClass;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export { ForexPoolDataGenerator as F, PriceService as P, type PairState as a, forexSimulationEngine as f, priceService as p };
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { TokenPrice } from './types/index.js';
|
|
2
|
+
import { t as ForexLogEntry, m as ForexPoolTransaction, g as ForexCurrencyPair, i as ForexPoolType, n as ForexPoolDailySnapshot, r as ForexTradeRecord, l as ForexPoolTransactionType } from './console-BfTMA7ah.js';
|
|
3
|
+
|
|
4
|
+
declare class PriceService {
|
|
5
|
+
private cache;
|
|
6
|
+
private cacheTTL;
|
|
7
|
+
getPrice(symbol: string): Promise<TokenPrice>;
|
|
8
|
+
getPrices(symbols: string[]): Promise<Record<string, TokenPrice>>;
|
|
9
|
+
private getFallbackPrice;
|
|
10
|
+
clearCache(): void;
|
|
11
|
+
}
|
|
12
|
+
declare const priceService: PriceService;
|
|
13
|
+
|
|
14
|
+
type LogCallback = (entry: ForexLogEntry) => void;
|
|
15
|
+
type PoolTxCallback = (tx: ForexPoolTransaction) => void;
|
|
16
|
+
interface PairState {
|
|
17
|
+
pair: ForexCurrencyPair;
|
|
18
|
+
currentPrice: number;
|
|
19
|
+
bidPrice: number;
|
|
20
|
+
askPrice: number;
|
|
21
|
+
lastSpread: number;
|
|
22
|
+
}
|
|
23
|
+
declare class ForexSimulationEngine {
|
|
24
|
+
private listeners;
|
|
25
|
+
private poolTxListeners;
|
|
26
|
+
private cycleTimer;
|
|
27
|
+
private pairStates;
|
|
28
|
+
private running;
|
|
29
|
+
private openPositions;
|
|
30
|
+
private totalPnl;
|
|
31
|
+
private totalTrades;
|
|
32
|
+
private totalPips;
|
|
33
|
+
private totalLots;
|
|
34
|
+
constructor();
|
|
35
|
+
start(): void;
|
|
36
|
+
stop(): void;
|
|
37
|
+
onLog(callback: LogCallback): () => void;
|
|
38
|
+
onPoolTransaction(callback: PoolTxCallback): () => void;
|
|
39
|
+
isRunning(): boolean;
|
|
40
|
+
getStats(): {
|
|
41
|
+
totalPnl: number;
|
|
42
|
+
totalTrades: number;
|
|
43
|
+
totalPips: number;
|
|
44
|
+
totalLots: number;
|
|
45
|
+
positions: number;
|
|
46
|
+
};
|
|
47
|
+
getPairStates(): Map<string, PairState>;
|
|
48
|
+
emitBootSequence(): void;
|
|
49
|
+
destroy(): void;
|
|
50
|
+
private emit;
|
|
51
|
+
private emitPoolTx;
|
|
52
|
+
private generatePoolTxFromEvent;
|
|
53
|
+
private scheduleCycle;
|
|
54
|
+
private simulatePrice;
|
|
55
|
+
private runTradeCycle;
|
|
56
|
+
}
|
|
57
|
+
declare const forexSimulationEngine: ForexSimulationEngine;
|
|
58
|
+
|
|
59
|
+
declare class ForexPoolDataGeneratorClass {
|
|
60
|
+
private snapshotCache;
|
|
61
|
+
private transactionCache;
|
|
62
|
+
private baseBlockNumber;
|
|
63
|
+
generateAllSnapshots(): Record<ForexPoolType, ForexPoolDailySnapshot[]>;
|
|
64
|
+
generateAllTransactions(): ForexPoolTransaction[];
|
|
65
|
+
generateTradeHistory(investmentAmount: number, startDate: string, selectedPairs: string[]): ForexTradeRecord[];
|
|
66
|
+
generateLiveTransaction(poolId: ForexPoolType, type: ForexPoolTransactionType, baseAmount?: number): ForexPoolTransaction;
|
|
67
|
+
private generatePoolSnapshots;
|
|
68
|
+
private generatePoolTransactions;
|
|
69
|
+
private gaussianRandom;
|
|
70
|
+
private getTxDescription;
|
|
71
|
+
}
|
|
72
|
+
declare const ForexPoolDataGenerator: {
|
|
73
|
+
getInstance(): ForexPoolDataGeneratorClass;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export { ForexPoolDataGenerator as F, PriceService as P, type PairState as a, forexSimulationEngine as f, priceService as p };
|