@cygnus-wealth/data-models 0.0.3 → 1.1.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 +366 -63
- package/dist/enums/AccountType.d.ts +41 -0
- package/dist/enums/AccountType.js +41 -0
- package/dist/enums/AssetType.d.ts +114 -0
- package/dist/enums/AssetType.js +114 -0
- package/dist/enums/Chain.d.ts +56 -0
- package/dist/enums/Chain.js +56 -0
- package/dist/enums/IntegrationSource.d.ts +46 -0
- package/dist/enums/IntegrationSource.js +46 -4
- package/dist/enums/LendingPositionType.d.ts +25 -0
- package/dist/enums/LendingPositionType.js +26 -0
- package/dist/enums/TransactionType.d.ts +50 -0
- package/dist/enums/TransactionType.js +50 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/interfaces/Account.d.ts +92 -0
- package/dist/interfaces/ApiError.d.ts +61 -0
- package/dist/interfaces/ApiResponse.d.ts +60 -1
- package/dist/interfaces/Asset.d.ts +59 -0
- package/dist/interfaces/Balance.d.ts +52 -0
- package/dist/interfaces/BaseEntity.d.ts +61 -0
- package/dist/interfaces/FilterOptions.d.ts +68 -0
- package/dist/interfaces/IntegrationCredentials.d.ts +54 -0
- package/dist/interfaces/LendingPosition.d.ts +89 -4
- package/dist/interfaces/LiquidityPosition.d.ts +66 -2
- package/dist/interfaces/MarketData.d.ts +53 -0
- package/dist/interfaces/Metadata.d.ts +86 -0
- package/dist/interfaces/NFT.d.ts +55 -0
- package/dist/interfaces/PaginatedResponse.d.ts +59 -0
- package/dist/interfaces/Portfolio.d.ts +98 -0
- package/dist/interfaces/PortfolioAsset.d.ts +63 -0
- package/dist/interfaces/PortfolioItem.d.ts +13 -0
- package/dist/interfaces/Price.d.ts +42 -0
- package/dist/interfaces/StakedPosition.d.ts +77 -0
- package/dist/interfaces/SyncStatus.d.ts +55 -0
- package/dist/interfaces/Transaction.d.ts +114 -2
- package/dist/types/AssetIdentifier.d.ts +61 -0
- package/dist/types/NetworkEnvironment.d.ts +78 -0
- package/dist/types/SortOrder.d.ts +50 -0
- package/dist/types/TimeRange.d.ts +51 -0
- package/package.json +33 -3
- /package/dist/{index.test.d.ts → types/NetworkEnvironment.js} +0 -0
package/README.md
CHANGED
|
@@ -1,14 +1,24 @@
|
|
|
1
1
|
# @cygnus-wealth/data-models
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/@cygnus-wealth/data-models)
|
|
4
|
+
[](https://github.com/cygnus-wealth/data-models)
|
|
5
|
+
[](https://www.typescriptlang.org/)
|
|
6
|
+
[](LICENSE)
|
|
4
7
|
|
|
5
|
-
|
|
8
|
+
**Production-ready TypeScript data models for multi-chain portfolio aggregation and financial data standardization.**
|
|
6
9
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
-
|
|
10
|
+
A comprehensive, battle-tested type system for the CygnusWealth ecosystem with 100% test coverage, complete JSDoc documentation, and automatic breaking change detection.
|
|
11
|
+
|
|
12
|
+
## Features
|
|
13
|
+
|
|
14
|
+
✅ **30+ Standardized Types** - Enums, interfaces, and types for all financial data
|
|
15
|
+
✅ **100% Test Coverage** - 286 tests across unit, integration, and property-based suites
|
|
16
|
+
✅ **Complete JSDoc** - Every type fully documented with examples and design patterns
|
|
17
|
+
✅ **API Contract Enforcement** - Automatic breaking change detection with @microsoft/api-extractor
|
|
18
|
+
✅ **Multi-Chain Support** - EVM chains, Solana, SUI, Bitcoin
|
|
19
|
+
✅ **Multi-Source Integration** - CEX, DEX, wallets, manual entries
|
|
20
|
+
✅ **Type Safety** - Strict TypeScript types with generic constraints
|
|
21
|
+
✅ **Stability Tiers** - Clear guarantees for breaking changes
|
|
12
22
|
|
|
13
23
|
## Installation
|
|
14
24
|
|
|
@@ -16,102 +26,395 @@ This package provides a unified type system for financial data from various sour
|
|
|
16
26
|
npm install @cygnus-wealth/data-models
|
|
17
27
|
```
|
|
18
28
|
|
|
19
|
-
##
|
|
29
|
+
## Quick Start
|
|
20
30
|
|
|
21
31
|
```typescript
|
|
22
|
-
import {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
32
|
+
import {
|
|
33
|
+
Asset,
|
|
34
|
+
AssetType,
|
|
35
|
+
Chain,
|
|
36
|
+
Transaction,
|
|
37
|
+
TransactionType,
|
|
38
|
+
Portfolio,
|
|
39
|
+
LendingPosition,
|
|
40
|
+
LendingPositionType
|
|
27
41
|
} from '@cygnus-wealth/data-models';
|
|
28
42
|
|
|
29
|
-
//
|
|
30
|
-
const
|
|
31
|
-
id: '
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
43
|
+
// Create an asset
|
|
44
|
+
const ethAsset: Asset = {
|
|
45
|
+
id: 'ethereum-eth',
|
|
46
|
+
symbol: 'ETH',
|
|
47
|
+
name: 'Ethereum',
|
|
48
|
+
type: AssetType.CRYPTOCURRENCY,
|
|
49
|
+
chain: Chain.ETHEREUM,
|
|
50
|
+
decimals: 18,
|
|
51
|
+
coingeckoId: 'ethereum'
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
// Track a DeFi lending position
|
|
55
|
+
const aaveSupply: LendingPosition = {
|
|
56
|
+
id: 'aave-usdc-supply',
|
|
57
|
+
protocol: 'Aave V3',
|
|
58
|
+
chain: Chain.ETHEREUM,
|
|
59
|
+
type: LendingPositionType.SUPPLY,
|
|
60
|
+
asset: {
|
|
61
|
+
id: 'ethereum-usdc',
|
|
62
|
+
symbol: 'USDC',
|
|
63
|
+
name: 'USD Coin',
|
|
64
|
+
type: AssetType.CRYPTOCURRENCY,
|
|
65
|
+
decimals: 6
|
|
66
|
+
},
|
|
67
|
+
amount: '50000',
|
|
68
|
+
apy: 3.5,
|
|
69
|
+
accruedInterest: 125.50
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
// Record a transaction
|
|
73
|
+
const swapTx: Transaction = {
|
|
74
|
+
id: 'tx-0x123abc',
|
|
75
|
+
accountId: 'wallet-1',
|
|
76
|
+
type: TransactionType.SWAP,
|
|
77
|
+
status: 'COMPLETED',
|
|
78
|
+
chain: Chain.ETHEREUM,
|
|
79
|
+
timestamp: new Date(),
|
|
80
|
+
assetsOut: [{
|
|
81
|
+
asset: ethAsset,
|
|
82
|
+
amount: '1.5'
|
|
83
|
+
}],
|
|
84
|
+
assetsIn: [{
|
|
85
|
+
asset: { id: 'ethereum-usdc', symbol: 'USDC', name: 'USD Coin', type: AssetType.CRYPTOCURRENCY, decimals: 6 },
|
|
86
|
+
amount: '3000'
|
|
87
|
+
}]
|
|
37
88
|
};
|
|
38
89
|
```
|
|
39
90
|
|
|
40
|
-
##
|
|
91
|
+
## Type Categories
|
|
92
|
+
|
|
93
|
+
### Foundation (2 types)
|
|
94
|
+
- `BaseEntity` - Common fields for all entities (id, timestamps)
|
|
95
|
+
- `Metadata` - Extensible key-value store for source-specific data
|
|
96
|
+
|
|
97
|
+
### Enums (6 types)
|
|
98
|
+
- `AssetType` - Asset classification (CRYPTOCURRENCY, STOCK, NFT, etc.)
|
|
99
|
+
- `Chain` - Blockchain networks (ETHEREUM, SOLANA, SUI, etc.)
|
|
100
|
+
- `IntegrationSource` - Data sources (CEX, DEX, wallets)
|
|
101
|
+
- `TransactionType` - Transaction operations (BUY, SELL, SWAP, STAKE, etc.)
|
|
102
|
+
- `AccountType` - Account categories (SPOT, WALLET, DEFI, etc.)
|
|
103
|
+
- `LendingPositionType` - Lending types (SUPPLY, BORROW)
|
|
104
|
+
|
|
105
|
+
### Assets (4 types)
|
|
106
|
+
- `Asset` - Universal asset representation
|
|
107
|
+
- `NFT` - Non-fungible tokens with metadata
|
|
108
|
+
- `Balance` - Asset quantities with P&L tracking
|
|
109
|
+
- `PortfolioAsset` - Aggregated asset view across accounts
|
|
110
|
+
|
|
111
|
+
### Market Data (2 types)
|
|
112
|
+
- `Price` - Point-in-time asset pricing
|
|
113
|
+
- `MarketData` - Comprehensive market metrics (volume, market cap, ATH/ATL)
|
|
114
|
+
|
|
115
|
+
### Positions (3 types)
|
|
116
|
+
- `LiquidityPosition` - DEX LP positions with impermanent loss tracking
|
|
117
|
+
- `StakedPosition` - Proof-of-stake positions with rewards
|
|
118
|
+
- `LendingPosition` - DeFi lending/borrowing with health factors
|
|
119
|
+
|
|
120
|
+
### Transactions (1 type)
|
|
121
|
+
- `Transaction` - Universal transaction model with asset flow pattern
|
|
122
|
+
|
|
123
|
+
### Integration (3 types)
|
|
124
|
+
- `Account` - Multi-source account aggregation
|
|
125
|
+
- `IntegrationCredentials` - Encrypted API credentials
|
|
126
|
+
- `SyncStatus` - Data synchronization state
|
|
127
|
+
|
|
128
|
+
### Response (3 types)
|
|
129
|
+
- `ApiResponse<T>` - Generic response wrapper with error handling
|
|
130
|
+
- `ApiError` - Structured error with retry metadata
|
|
131
|
+
- `PaginatedResponse<T>` - Paginated data with navigation
|
|
132
|
+
|
|
133
|
+
### Utility (4 types)
|
|
134
|
+
- `AssetIdentifier` - Flexible asset lookup
|
|
135
|
+
- `TimeRange` - Date range queries
|
|
136
|
+
- `SortOrder` - Sort direction
|
|
137
|
+
- `FilterOptions` - Universal filtering
|
|
138
|
+
|
|
139
|
+
### Portfolio (2 types)
|
|
140
|
+
- `Portfolio` - Complete portfolio with performance tracking
|
|
141
|
+
- `PortfolioItem` - ⚠️ **Deprecated** (use `PortfolioAsset`)
|
|
142
|
+
|
|
143
|
+
## Stability Tiers
|
|
144
|
+
|
|
145
|
+
All types follow semantic versioning with documented stability guarantees:
|
|
146
|
+
|
|
147
|
+
| Tier | Types | Breaking Change Process |
|
|
148
|
+
|------|-------|------------------------|
|
|
149
|
+
| **Core** | BaseEntity, Metadata, All Enums | Unanimous Board approval |
|
|
150
|
+
| **Standard** | Asset, Transaction, Account, Portfolio, Price, MarketData | RFC with majority vote |
|
|
151
|
+
| **Extended** | Positions, Integration models | Expedited RFC |
|
|
152
|
+
|
|
153
|
+
Breaking changes are automatically detected via API Extractor in CI/CD.
|
|
154
|
+
|
|
155
|
+
## Testing
|
|
156
|
+
|
|
157
|
+
**286 tests** with **100% coverage** across multiple test types:
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
# Run all tests
|
|
161
|
+
npm test
|
|
162
|
+
|
|
163
|
+
# Run tests once (no watch)
|
|
164
|
+
npm run test:run
|
|
165
|
+
|
|
166
|
+
# Run with coverage report
|
|
167
|
+
npm run test:coverage
|
|
168
|
+
|
|
169
|
+
# Run specific test suites
|
|
170
|
+
npm run test:unit # Unit tests (240+ tests)
|
|
171
|
+
npm run test:integration # Integration tests (10 tests)
|
|
172
|
+
npm run test:property # Property-based tests (22 tests)
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### Test Organization
|
|
176
|
+
|
|
177
|
+
```
|
|
178
|
+
tests/
|
|
179
|
+
├── unit/ # Type creation, validation, edge cases
|
|
180
|
+
├── integration/ # External API mapping (CEX, blockchain → types)
|
|
181
|
+
├── property-based/ # Invariant testing with fast-check
|
|
182
|
+
└── fixtures/ # Reusable test data (76+ samples)
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### Coverage by Section
|
|
186
|
+
|
|
187
|
+
- Foundation & Enums: **100%**
|
|
188
|
+
- Core Models: **100%**
|
|
189
|
+
- Extended Models: **100%**
|
|
190
|
+
- Integration Models: **100%**
|
|
191
|
+
- **Overall: 100%**
|
|
192
|
+
|
|
193
|
+
## API Contract Management
|
|
194
|
+
|
|
195
|
+
This package uses **@microsoft/api-extractor** to enforce API contracts and prevent accidental breaking changes.
|
|
196
|
+
|
|
197
|
+
### For Consumers
|
|
41
198
|
|
|
42
|
-
|
|
43
|
-
- `Portfolio` - Complete portfolio representation
|
|
44
|
-
- `Asset` - Individual asset holdings
|
|
45
|
-
- `Transaction` - Transaction records across platforms
|
|
46
|
-
- `MarketData` - Real-time and historical market data
|
|
47
|
-
- `Position` - Trading positions and holdings
|
|
48
|
-
- `Balance` - Account and wallet balances
|
|
199
|
+
All public API changes are tracked in `etc/data-models.api.md`. The API report serves as a changelog for type signatures.
|
|
49
200
|
|
|
50
|
-
###
|
|
51
|
-
- `DataSource` - Union type for all supported data sources
|
|
52
|
-
- `ChainId` - Blockchain network identifiers
|
|
53
|
-
- `AssetType` - Asset classification (crypto, stock, NFT, etc.)
|
|
201
|
+
### For Contributors
|
|
54
202
|
|
|
55
|
-
|
|
203
|
+
```bash
|
|
204
|
+
# Check for breaking changes (CI also runs this)
|
|
205
|
+
npm run api:check
|
|
206
|
+
|
|
207
|
+
# Update API report after intentional changes
|
|
208
|
+
npm run api:extract
|
|
209
|
+
```
|
|
56
210
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
211
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for detailed guidelines on:
|
|
212
|
+
- Making changes to types
|
|
213
|
+
- API contract validation
|
|
214
|
+
- Breaking change approval process
|
|
215
|
+
- Pull request workflow
|
|
62
216
|
|
|
63
217
|
## Development
|
|
64
218
|
|
|
65
219
|
### Prerequisites
|
|
66
|
-
|
|
67
|
-
-
|
|
220
|
+
|
|
221
|
+
- Node.js 18+ (20+ recommended)
|
|
222
|
+
- npm 9+
|
|
68
223
|
|
|
69
224
|
### Setup
|
|
225
|
+
|
|
70
226
|
```bash
|
|
227
|
+
# Clone repository
|
|
228
|
+
git clone https://github.com/cygnus-wealth/data-models.git
|
|
229
|
+
cd data-models
|
|
230
|
+
|
|
71
231
|
# Install dependencies
|
|
72
232
|
npm install
|
|
73
233
|
|
|
74
|
-
# Build
|
|
234
|
+
# Build project
|
|
75
235
|
npm run build
|
|
76
236
|
|
|
77
237
|
# Run tests
|
|
78
|
-
npm test
|
|
238
|
+
npm run test:coverage
|
|
79
239
|
|
|
80
240
|
# Lint code
|
|
81
241
|
npm run lint
|
|
82
242
|
```
|
|
83
243
|
|
|
84
244
|
### Project Structure
|
|
85
|
-
```
|
|
86
|
-
src/
|
|
87
|
-
├── index.ts # Main entry point with all type exports
|
|
88
|
-
└── index.test.ts # Type definition tests
|
|
89
245
|
|
|
90
|
-
|
|
246
|
+
```
|
|
247
|
+
data-models/
|
|
248
|
+
├── src/
|
|
249
|
+
│ ├── enums/ # 6 enums (Chain, AssetType, etc.)
|
|
250
|
+
│ ├── interfaces/ # 21 interfaces (Asset, Transaction, etc.)
|
|
251
|
+
│ ├── types/ # 4 type aliases (AssetIdentifier, etc.)
|
|
252
|
+
│ └── index.ts # Main export
|
|
253
|
+
├── tests/
|
|
254
|
+
│ ├── unit/ # 10 test files, 240+ tests
|
|
255
|
+
│ ├── integration/ # External mapping tests
|
|
256
|
+
│ ├── property-based/ # Invariant tests with fast-check
|
|
257
|
+
│ └── fixtures/ # 9 fixture files, 76+ samples
|
|
258
|
+
├── etc/
|
|
259
|
+
│ └── data-models.api.md # API contract report
|
|
260
|
+
├── .github/
|
|
261
|
+
│ └── workflows/
|
|
262
|
+
│ └── api-contract.yml # CI/CD for breaking changes
|
|
263
|
+
├── api-extractor.json # API Extractor config
|
|
264
|
+
├── vitest.config.ts # Vitest config (95% thresholds)
|
|
265
|
+
├── tsconfig.json # TypeScript config
|
|
266
|
+
├── CONTRIBUTING.md # Contributor guidelines
|
|
267
|
+
├── UNIT_ARCHITECTURE.md # Complete architecture specs
|
|
268
|
+
└── package.json
|
|
91
269
|
```
|
|
92
270
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
271
|
+
## Documentation
|
|
272
|
+
|
|
273
|
+
Every type includes comprehensive JSDoc with:
|
|
274
|
+
- **Description** - Purpose and use cases
|
|
275
|
+
- **Design patterns** - Architectural rationale
|
|
276
|
+
- **@example** - Realistic usage examples
|
|
277
|
+
- **@since** - Version introduced
|
|
278
|
+
- **@stability** - Stability tier
|
|
279
|
+
- **@see** - Related types
|
|
280
|
+
- **Field docs** - Inline documentation for all properties
|
|
281
|
+
|
|
282
|
+
Example:
|
|
283
|
+
```typescript
|
|
284
|
+
/**
|
|
285
|
+
* Universal transaction representation across all sources.
|
|
286
|
+
*
|
|
287
|
+
* Normalized transaction model supporting blockchain transfers, CEX trades,
|
|
288
|
+
* DEX swaps, DeFi operations, and traditional finance transactions. Uses
|
|
289
|
+
* asset flow pattern (assetsIn/assetsOut) to handle complex multi-asset
|
|
290
|
+
* operations like swaps, liquidity provision, and protocol interactions.
|
|
291
|
+
*
|
|
292
|
+
* **Design Pattern:** Event sourcing pattern with asset flow arrays supporting
|
|
293
|
+
* 1:1 transfers, 1:N distributions, N:1 swaps, and N:M complex operations.
|
|
294
|
+
* Status field enables tracking pending and failed transactions.
|
|
295
|
+
*
|
|
296
|
+
* @example
|
|
297
|
+
* ```typescript
|
|
298
|
+
* // DEX swap (ETH -> USDC)
|
|
299
|
+
* const swap: Transaction = {
|
|
300
|
+
* id: 'tx-0x456def',
|
|
301
|
+
* accountId: 'wallet-1',
|
|
302
|
+
* type: TransactionType.SWAP,
|
|
303
|
+
* status: 'COMPLETED',
|
|
304
|
+
* assetsOut: [{ asset: ethAsset, amount: '2.0' }],
|
|
305
|
+
* assetsIn: [{ asset: usdcAsset, amount: '4000' }]
|
|
306
|
+
* };
|
|
307
|
+
* ```
|
|
308
|
+
*
|
|
309
|
+
* @since 0.0.1
|
|
310
|
+
* @stability standard
|
|
311
|
+
*
|
|
312
|
+
* @see {@link TransactionType} for operation classification
|
|
313
|
+
* @see {@link Account} for transaction aggregation
|
|
314
|
+
*/
|
|
315
|
+
export interface Transaction { ... }
|
|
98
316
|
```
|
|
99
317
|
|
|
318
|
+
## Multi-Chain Support
|
|
319
|
+
|
|
320
|
+
### EVM Chains
|
|
321
|
+
- Ethereum (mainnet)
|
|
322
|
+
- Polygon, Arbitrum, Optimism, Base
|
|
323
|
+
- Avalanche, Binance Smart Chain
|
|
324
|
+
|
|
325
|
+
### Alternative L1s
|
|
326
|
+
- Solana
|
|
327
|
+
- SUI
|
|
328
|
+
- Bitcoin
|
|
329
|
+
|
|
330
|
+
### Coming Soon
|
|
331
|
+
- Cosmos ecosystem
|
|
332
|
+
- Polkadot parachains
|
|
333
|
+
- Additional EVM L2s
|
|
334
|
+
|
|
335
|
+
## Integration Sources
|
|
336
|
+
|
|
337
|
+
### Centralized Exchanges (CEX)
|
|
338
|
+
- Robinhood, Kraken, Coinbase, Binance
|
|
339
|
+
|
|
340
|
+
### Decentralized Exchanges (DEX)
|
|
341
|
+
- Uniswap, SushiSwap, PancakeSwap
|
|
342
|
+
- Curve, Balancer
|
|
343
|
+
|
|
344
|
+
### Wallets
|
|
345
|
+
- MetaMask, Rabby (EVM)
|
|
346
|
+
- Phantom (Solana)
|
|
347
|
+
- Slush, Suiet (SUI)
|
|
348
|
+
|
|
349
|
+
### Other
|
|
350
|
+
- Manual entry
|
|
351
|
+
- Direct blockchain RPC
|
|
352
|
+
|
|
353
|
+
## Use Cases
|
|
354
|
+
|
|
355
|
+
### Portfolio Aggregation
|
|
356
|
+
Combine holdings from CEXs, DEXs, and wallets into unified portfolio view.
|
|
357
|
+
|
|
358
|
+
### Transaction History
|
|
359
|
+
Normalize transaction data across chains and platforms for unified history.
|
|
360
|
+
|
|
361
|
+
### DeFi Position Tracking
|
|
362
|
+
Monitor lending, staking, and liquidity positions with real-time health metrics.
|
|
363
|
+
|
|
364
|
+
### Cross-Chain Analytics
|
|
365
|
+
Aggregate and analyze assets across multiple blockchain networks.
|
|
366
|
+
|
|
367
|
+
### Data Integration
|
|
368
|
+
Transform external API responses into standardized internal types.
|
|
369
|
+
|
|
100
370
|
## Contributing
|
|
101
371
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
372
|
+
We welcome contributions! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for:
|
|
373
|
+
- Development setup
|
|
374
|
+
- Testing requirements (100% coverage)
|
|
375
|
+
- API contract management
|
|
376
|
+
- Stability tier approval process
|
|
377
|
+
- Pull request guidelines
|
|
378
|
+
|
|
379
|
+
**Quick checklist:**
|
|
380
|
+
- [ ] Tests added/updated (100% coverage maintained)
|
|
381
|
+
- [ ] JSDoc added for all public APIs
|
|
382
|
+
- [ ] API contract validated (`npm run api:check`)
|
|
383
|
+
- [ ] Build passes (`npm run build`)
|
|
384
|
+
- [ ] Linting passes (`npm run lint`)
|
|
385
|
+
|
|
386
|
+
## Architecture
|
|
387
|
+
|
|
388
|
+
This package follows Domain-Driven Design (DDD) principles with:
|
|
389
|
+
- **Bounded Context**: Data Models domain
|
|
390
|
+
- **Unit Architecture**: Complete specifications in UNIT_ARCHITECTURE.md
|
|
391
|
+
- **Stability Tiers**: Clear breaking change policies
|
|
392
|
+
- **Contract Testing**: Automated API surface validation
|
|
393
|
+
|
|
394
|
+
See [UNIT_ARCHITECTURE.md](UNIT_ARCHITECTURE.md) for complete architectural specifications.
|
|
395
|
+
|
|
396
|
+
## Version History
|
|
397
|
+
|
|
398
|
+
- **v1.0.0** - 🎉 Production release with 100% coverage, API contract enforcement, complete documentation
|
|
399
|
+
- **v0.0.3** - Initial types and enums (pre-architecture phases)
|
|
108
400
|
|
|
109
401
|
## License
|
|
110
402
|
|
|
111
|
-
Part of the CygnusWealth project.
|
|
403
|
+
ISC License - Part of the CygnusWealth project.
|
|
112
404
|
|
|
113
405
|
## Related Packages
|
|
114
406
|
|
|
115
|
-
- `@cygnus-wealth/web-app` - Main
|
|
116
|
-
- `@cygnus-wealth/crypto-utils` - Blockchain utilities
|
|
117
|
-
- `@cygnus-wealth/api-clients` - Exchange API integrations
|
|
407
|
+
- `@cygnus-wealth/web-app` - Main portfolio aggregation dApp
|
|
408
|
+
- `@cygnus-wealth/crypto-utils` - Blockchain utilities and encryption
|
|
409
|
+
- `@cygnus-wealth/api-clients` - Exchange API integrations
|
|
410
|
+
|
|
411
|
+
## Support
|
|
412
|
+
|
|
413
|
+
- 📖 Documentation: [UNIT_ARCHITECTURE.md](UNIT_ARCHITECTURE.md)
|
|
414
|
+
- 🤝 Contributing: [CONTRIBUTING.md](CONTRIBUTING.md)
|
|
415
|
+
- 🐛 Issues: [GitHub Issues](https://github.com/cygnus-wealth/data-models/issues)
|
|
416
|
+
- 📦 npm: [@cygnus-wealth/data-models](https://www.npmjs.com/package/@cygnus-wealth/data-models)
|
|
417
|
+
|
|
418
|
+
---
|
|
419
|
+
|
|
420
|
+
Built with ❤️ for the CygnusWealth ecosystem
|
|
@@ -1,12 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Classification of account types.
|
|
3
|
+
*
|
|
4
|
+
* Categorizes account containers for display, grouping, and business logic.
|
|
5
|
+
* Enables specialized UI components and processing based on account purpose
|
|
6
|
+
* and characteristics.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { AccountType } from '@cygnus-wealth/data-models';
|
|
11
|
+
*
|
|
12
|
+
* // Route account to specialized handler
|
|
13
|
+
* function processAccount(type: AccountType) {
|
|
14
|
+
* switch(type) {
|
|
15
|
+
* case AccountType.SPOT:
|
|
16
|
+
* return processCEXSpotAccount();
|
|
17
|
+
* case AccountType.WALLET:
|
|
18
|
+
* return processWalletAccount();
|
|
19
|
+
* case AccountType.DEFI:
|
|
20
|
+
* return processDeFiPositions();
|
|
21
|
+
* case AccountType.RETIREMENT:
|
|
22
|
+
* return processTaxAdvantaged();
|
|
23
|
+
* default:
|
|
24
|
+
* return processGenericAccount();
|
|
25
|
+
* }
|
|
26
|
+
* }
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* @since 0.0.1
|
|
30
|
+
* @stability standard
|
|
31
|
+
*/
|
|
1
32
|
export declare enum AccountType {
|
|
33
|
+
/** Spot trading account on centralized exchange */
|
|
2
34
|
SPOT = "SPOT",
|
|
35
|
+
/** Margin trading account with leverage */
|
|
3
36
|
MARGIN = "MARGIN",
|
|
37
|
+
/** Futures or derivatives trading account */
|
|
4
38
|
FUTURES = "FUTURES",
|
|
39
|
+
/** Savings or interest-earning account */
|
|
5
40
|
SAVINGS = "SAVINGS",
|
|
41
|
+
/** Staking account for proof-of-stake rewards */
|
|
6
42
|
STAKING = "STAKING",
|
|
43
|
+
/** Self-custody blockchain wallet */
|
|
7
44
|
WALLET = "WALLET",
|
|
45
|
+
/** DeFi protocol positions (lending, liquidity, etc.) */
|
|
8
46
|
DEFI = "DEFI",
|
|
47
|
+
/** Traditional brokerage account */
|
|
9
48
|
BROKERAGE = "BROKERAGE",
|
|
49
|
+
/** Tax-advantaged retirement account (IRA, 401k, etc.) */
|
|
10
50
|
RETIREMENT = "RETIREMENT",
|
|
51
|
+
/** Other or unclassified account type */
|
|
11
52
|
OTHER = "OTHER"
|
|
12
53
|
}
|
|
@@ -1,13 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Classification of account types.
|
|
3
|
+
*
|
|
4
|
+
* Categorizes account containers for display, grouping, and business logic.
|
|
5
|
+
* Enables specialized UI components and processing based on account purpose
|
|
6
|
+
* and characteristics.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { AccountType } from '@cygnus-wealth/data-models';
|
|
11
|
+
*
|
|
12
|
+
* // Route account to specialized handler
|
|
13
|
+
* function processAccount(type: AccountType) {
|
|
14
|
+
* switch(type) {
|
|
15
|
+
* case AccountType.SPOT:
|
|
16
|
+
* return processCEXSpotAccount();
|
|
17
|
+
* case AccountType.WALLET:
|
|
18
|
+
* return processWalletAccount();
|
|
19
|
+
* case AccountType.DEFI:
|
|
20
|
+
* return processDeFiPositions();
|
|
21
|
+
* case AccountType.RETIREMENT:
|
|
22
|
+
* return processTaxAdvantaged();
|
|
23
|
+
* default:
|
|
24
|
+
* return processGenericAccount();
|
|
25
|
+
* }
|
|
26
|
+
* }
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* @since 0.0.1
|
|
30
|
+
* @stability standard
|
|
31
|
+
*/
|
|
1
32
|
export var AccountType;
|
|
2
33
|
(function (AccountType) {
|
|
34
|
+
/** Spot trading account on centralized exchange */
|
|
3
35
|
AccountType["SPOT"] = "SPOT";
|
|
36
|
+
/** Margin trading account with leverage */
|
|
4
37
|
AccountType["MARGIN"] = "MARGIN";
|
|
38
|
+
/** Futures or derivatives trading account */
|
|
5
39
|
AccountType["FUTURES"] = "FUTURES";
|
|
40
|
+
/** Savings or interest-earning account */
|
|
6
41
|
AccountType["SAVINGS"] = "SAVINGS";
|
|
42
|
+
/** Staking account for proof-of-stake rewards */
|
|
7
43
|
AccountType["STAKING"] = "STAKING";
|
|
44
|
+
/** Self-custody blockchain wallet */
|
|
8
45
|
AccountType["WALLET"] = "WALLET";
|
|
46
|
+
/** DeFi protocol positions (lending, liquidity, etc.) */
|
|
9
47
|
AccountType["DEFI"] = "DEFI";
|
|
48
|
+
/** Traditional brokerage account */
|
|
10
49
|
AccountType["BROKERAGE"] = "BROKERAGE";
|
|
50
|
+
/** Tax-advantaged retirement account (IRA, 401k, etc.) */
|
|
11
51
|
AccountType["RETIREMENT"] = "RETIREMENT";
|
|
52
|
+
/** Other or unclassified account type */
|
|
12
53
|
AccountType["OTHER"] = "OTHER";
|
|
13
54
|
})(AccountType || (AccountType = {}));
|