@cygnus-wealth/data-models 1.1.2 → 1.4.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/dist/cjs/enums/ChainFamily.js +54 -0
- package/dist/cjs/enums/DeFiDiscoverySource.js +37 -0
- package/dist/cjs/enums/DeFiPositionType.js +39 -0
- package/dist/cjs/enums/DeFiProtocol.js +46 -0
- package/dist/cjs/enums/IntegrationSource.js +8 -0
- package/dist/cjs/enums/VaultStrategyType.js +34 -0
- package/dist/cjs/index.js +11 -1
- package/dist/cjs/interfaces/AccountAssetEntry.js +2 -0
- package/dist/cjs/interfaces/AccountBalanceList.js +2 -0
- package/dist/cjs/interfaces/AccountGroup.js +2 -0
- package/dist/cjs/interfaces/AccountMetadata.js +2 -0
- package/dist/cjs/interfaces/AccountPortfolio.js +2 -0
- package/dist/cjs/interfaces/AccountSummary.js +2 -0
- package/dist/cjs/interfaces/AddressRequest.js +2 -0
- package/dist/cjs/interfaces/AssetDistribution.js +2 -0
- package/dist/cjs/interfaces/ConnectedAccount.js +2 -0
- package/dist/cjs/interfaces/DeFiPosition.js +2 -0
- package/dist/cjs/interfaces/GroupPortfolio.js +2 -0
- package/dist/cjs/interfaces/TrackedAddress.js +2 -0
- package/dist/cjs/interfaces/VaultPosition.js +2 -0
- package/dist/cjs/interfaces/WalletConnection.js +2 -0
- package/dist/cjs/interfaces/WalletPortfolio.js +2 -0
- package/dist/cjs/interfaces/WatchAddress.js +2 -0
- package/dist/cjs/types/AccountId.js +2 -0
- package/dist/cjs/types/Caip2ChainId.js +2 -0
- package/dist/cjs/types/WalletConnectionId.js +2 -0
- package/dist/cjs/types/WalletProviderId.js +2 -0
- package/dist/enums/ChainFamily.d.ts +50 -0
- package/dist/enums/ChainFamily.js +51 -0
- package/dist/enums/DeFiDiscoverySource.d.ts +33 -0
- package/dist/enums/DeFiDiscoverySource.js +34 -0
- package/dist/enums/DeFiPositionType.d.ts +35 -0
- package/dist/enums/DeFiPositionType.js +36 -0
- package/dist/enums/DeFiProtocol.d.ts +42 -0
- package/dist/enums/DeFiProtocol.js +43 -0
- package/dist/enums/IntegrationSource.d.ts +8 -0
- package/dist/enums/IntegrationSource.js +8 -0
- package/dist/enums/VaultStrategyType.d.ts +30 -0
- package/dist/enums/VaultStrategyType.js +31 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.js +5 -0
- package/dist/interfaces/Account.d.ts +3 -0
- package/dist/interfaces/AccountAssetEntry.d.ts +42 -0
- package/dist/interfaces/AccountAssetEntry.js +1 -0
- package/dist/interfaces/AccountBalanceList.d.ts +85 -0
- package/dist/interfaces/AccountBalanceList.js +1 -0
- package/dist/interfaces/AccountGroup.d.ts +37 -0
- package/dist/interfaces/AccountGroup.js +1 -0
- package/dist/interfaces/AccountMetadata.d.ts +54 -0
- package/dist/interfaces/AccountMetadata.js +1 -0
- package/dist/interfaces/AccountPortfolio.d.ts +47 -0
- package/dist/interfaces/AccountPortfolio.js +1 -0
- package/dist/interfaces/AccountSummary.d.ts +49 -0
- package/dist/interfaces/AccountSummary.js +1 -0
- package/dist/interfaces/AddressRequest.d.ts +36 -0
- package/dist/interfaces/AddressRequest.js +1 -0
- package/dist/interfaces/Asset.d.ts +6 -0
- package/dist/interfaces/AssetDistribution.d.ts +45 -0
- package/dist/interfaces/AssetDistribution.js +1 -0
- package/dist/interfaces/ConnectedAccount.d.ts +52 -0
- package/dist/interfaces/ConnectedAccount.js +1 -0
- package/dist/interfaces/DeFiPosition.d.ts +79 -0
- package/dist/interfaces/DeFiPosition.js +1 -0
- package/dist/interfaces/FilterOptions.d.ts +8 -0
- package/dist/interfaces/GroupPortfolio.d.ts +39 -0
- package/dist/interfaces/GroupPortfolio.js +1 -0
- package/dist/interfaces/IntegrationCredentials.d.ts +3 -0
- package/dist/interfaces/LendingPosition.d.ts +3 -0
- package/dist/interfaces/LiquidityPosition.d.ts +3 -0
- package/dist/interfaces/Portfolio.d.ts +8 -0
- package/dist/interfaces/StakedPosition.d.ts +3 -0
- package/dist/interfaces/TrackedAddress.d.ts +50 -0
- package/dist/interfaces/TrackedAddress.js +1 -0
- package/dist/interfaces/Transaction.d.ts +3 -0
- package/dist/interfaces/VaultPosition.d.ts +113 -0
- package/dist/interfaces/VaultPosition.js +1 -0
- package/dist/interfaces/WalletConnection.d.ts +67 -0
- package/dist/interfaces/WalletConnection.js +1 -0
- package/dist/interfaces/WalletPortfolio.d.ts +40 -0
- package/dist/interfaces/WalletPortfolio.js +1 -0
- package/dist/interfaces/WatchAddress.d.ts +42 -0
- package/dist/interfaces/WatchAddress.js +1 -0
- package/dist/types/AccountId.d.ts +27 -0
- package/dist/types/AccountId.js +1 -0
- package/dist/types/Caip2ChainId.d.ts +27 -0
- package/dist/types/Caip2ChainId.js +1 -0
- package/dist/types/WalletConnectionId.d.ts +19 -0
- package/dist/types/WalletConnectionId.js +1 -0
- package/dist/types/WalletProviderId.d.ts +17 -0
- package/dist/types/WalletProviderId.js +1 -0
- package/package.json +26 -1
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { AccountId } from '../types/AccountId';
|
|
2
|
+
import { Chain } from '../enums/Chain';
|
|
3
|
+
import { ChainFamily } from '../enums/ChainFamily';
|
|
4
|
+
/**
|
|
5
|
+
* A single account within a wallet connection.
|
|
6
|
+
*
|
|
7
|
+
* Represents an address discovered via a wallet provider (EIP-1193) or
|
|
8
|
+
* manually added to a connection's account list. Tracks discovery time,
|
|
9
|
+
* staleness, and active status relative to the wallet provider.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* import { ConnectedAccount } from '@cygnus-wealth/data-models';
|
|
14
|
+
*
|
|
15
|
+
* const account: ConnectedAccount = {
|
|
16
|
+
* accountId: 'metamask:a1b2c3d4:0xAbCdEf1234567890',
|
|
17
|
+
* address: '0xAbCdEf1234567890',
|
|
18
|
+
* accountLabel: 'Main DeFi',
|
|
19
|
+
* chainScope: [Chain.ETHEREUM, Chain.POLYGON],
|
|
20
|
+
* source: 'provider',
|
|
21
|
+
* discoveredAt: '2026-01-15T10:30:00Z',
|
|
22
|
+
* isStale: false,
|
|
23
|
+
* isActive: true
|
|
24
|
+
* };
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* @since 1.3.0
|
|
28
|
+
* @stability extended
|
|
29
|
+
*
|
|
30
|
+
* @see {@link WalletConnection} for the parent connection
|
|
31
|
+
* @see {@link AccountId} for identifier format
|
|
32
|
+
*/
|
|
33
|
+
export interface ConnectedAccount {
|
|
34
|
+
/** Unique account identifier: `{walletConnectionId}:{checksummedAddress}` */
|
|
35
|
+
accountId: AccountId;
|
|
36
|
+
/** Checksummed EVM address */
|
|
37
|
+
address: string;
|
|
38
|
+
/** User-assigned label (default: truncated address) */
|
|
39
|
+
accountLabel: string;
|
|
40
|
+
/** Chain family this account belongs to */
|
|
41
|
+
chainFamily: ChainFamily;
|
|
42
|
+
/** Chains to track this account on (default: all supported by the connection) */
|
|
43
|
+
chainScope: Chain[];
|
|
44
|
+
/** How this account was added: 'provider' = discovered via EIP-1193; 'manual' = user typed the address */
|
|
45
|
+
source: 'provider' | 'manual';
|
|
46
|
+
/** ISO 8601 timestamp when first seen */
|
|
47
|
+
discoveredAt: string;
|
|
48
|
+
/** True if the provider no longer includes this account in eth_requestAccounts responses */
|
|
49
|
+
isStale: boolean;
|
|
50
|
+
/** True if this is the currently selected account in the wallet provider */
|
|
51
|
+
isActive: boolean;
|
|
52
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { Chain } from '../enums/Chain';
|
|
2
|
+
import { DeFiPositionType } from '../enums/DeFiPositionType';
|
|
3
|
+
import { DeFiProtocol } from '../enums/DeFiProtocol';
|
|
4
|
+
import { DeFiDiscoverySource } from '../enums/DeFiDiscoverySource';
|
|
5
|
+
import { AccountId } from '../types/AccountId';
|
|
6
|
+
import { Balance } from './Balance';
|
|
7
|
+
import { Price } from './Price';
|
|
8
|
+
import { Metadata } from './Metadata';
|
|
9
|
+
/**
|
|
10
|
+
* Base interface for all DeFi positions across protocols and chains.
|
|
11
|
+
*
|
|
12
|
+
* Provides a unified shape for any DeFi position — vaults, lending, liquidity
|
|
13
|
+
* pools, staking, farming, and perp positions. Concrete subtypes
|
|
14
|
+
* ({@link VaultPosition}, {@link LendingPosition}, {@link LiquidityPosition},
|
|
15
|
+
* {@link StakedPosition}) add protocol-specific fields.
|
|
16
|
+
*
|
|
17
|
+
* **Discovery Paths:**
|
|
18
|
+
* - `WALLET_TOKEN_SCAN` — position inferred from receipt tokens in wallet
|
|
19
|
+
* - `CONTRACT_QUERY` — position read from protocol contract state
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* import {
|
|
24
|
+
* DeFiPosition,
|
|
25
|
+
* DeFiPositionType,
|
|
26
|
+
* DeFiProtocol,
|
|
27
|
+
* DeFiDiscoverySource,
|
|
28
|
+
* Chain
|
|
29
|
+
* } from '@cygnus-wealth/data-models';
|
|
30
|
+
*
|
|
31
|
+
* const position: DeFiPosition = {
|
|
32
|
+
* id: 'aave-supply-usdc-1',
|
|
33
|
+
* type: DeFiPositionType.LENDING_SUPPLY,
|
|
34
|
+
* protocol: DeFiProtocol.AAVE,
|
|
35
|
+
* chain: Chain.ETHEREUM,
|
|
36
|
+
* underlyingAssets: [{
|
|
37
|
+
* assetId: 'ethereum-usdc',
|
|
38
|
+
* asset: { id: 'ethereum-usdc', symbol: 'USDC', name: 'USD Coin', type: 'CRYPTOCURRENCY', decimals: 6 },
|
|
39
|
+
* amount: '50000'
|
|
40
|
+
* }],
|
|
41
|
+
* value: { value: 50125.50, currency: 'USD', timestamp: new Date() },
|
|
42
|
+
* apy: 3.5,
|
|
43
|
+
* rewards: [],
|
|
44
|
+
* discoverySource: DeFiDiscoverySource.CONTRACT_QUERY
|
|
45
|
+
* };
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* @since 1.3.0
|
|
49
|
+
* @stability extended
|
|
50
|
+
*
|
|
51
|
+
* @see {@link VaultPosition} for vault-specific fields
|
|
52
|
+
* @see {@link LendingPosition} for lending-specific fields
|
|
53
|
+
* @see {@link LiquidityPosition} for LP-specific fields
|
|
54
|
+
* @see {@link StakedPosition} for staking-specific fields
|
|
55
|
+
*/
|
|
56
|
+
export interface DeFiPosition {
|
|
57
|
+
/** Unique identifier for this position */
|
|
58
|
+
id: string;
|
|
59
|
+
/** Classification of the DeFi position */
|
|
60
|
+
type: DeFiPositionType;
|
|
61
|
+
/** Protocol where the position exists */
|
|
62
|
+
protocol: DeFiProtocol;
|
|
63
|
+
/** Blockchain network where the position exists */
|
|
64
|
+
chain: Chain;
|
|
65
|
+
/** Underlying assets in this position (tokens deposited, staked, or provided) */
|
|
66
|
+
underlyingAssets: Balance[];
|
|
67
|
+
/** Current total value of the position */
|
|
68
|
+
value?: Price;
|
|
69
|
+
/** Annual Percentage Yield or Rate (e.g., 8.5 = 8.5%) */
|
|
70
|
+
apy?: number;
|
|
71
|
+
/** Earned rewards (claimable or accrued incentive tokens) */
|
|
72
|
+
rewards: Balance[];
|
|
73
|
+
/** How this position was discovered during portfolio scanning */
|
|
74
|
+
discoverySource?: DeFiDiscoverySource;
|
|
75
|
+
/** Account identifier for multi-wallet attribution (alongside ownerAddress) */
|
|
76
|
+
accountId?: AccountId;
|
|
77
|
+
/** Protocol-specific metadata (version, contract addresses, TVL, etc.) */
|
|
78
|
+
metadata?: Metadata;
|
|
79
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Chain } from '../enums/Chain';
|
|
2
2
|
import { AssetType } from '../enums/AssetType';
|
|
3
3
|
import { IntegrationSource } from '../enums/IntegrationSource';
|
|
4
|
+
import { AccountId } from '../types/AccountId';
|
|
5
|
+
import { WalletConnectionId } from '../types/WalletConnectionId';
|
|
4
6
|
import { TimeRange } from '../types/TimeRange';
|
|
5
7
|
/**
|
|
6
8
|
* Flexible filtering criteria for portfolio and transaction queries.
|
|
@@ -77,4 +79,10 @@ export interface FilterOptions {
|
|
|
77
79
|
minValue?: number;
|
|
78
80
|
/** Maximum value threshold (inclusive, in base currency like USD) */
|
|
79
81
|
maxValue?: number;
|
|
82
|
+
/** Filter by account identifiers (OR within array) */
|
|
83
|
+
accountIds?: AccountId[];
|
|
84
|
+
/** Filter by wallet connection identifiers (OR within array) */
|
|
85
|
+
walletConnectionIds?: WalletConnectionId[];
|
|
86
|
+
/** Filter by account group identifiers (OR within array) */
|
|
87
|
+
groupIds?: string[];
|
|
80
88
|
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { AccountPortfolio } from './AccountPortfolio';
|
|
2
|
+
import { Price } from './Price';
|
|
3
|
+
/**
|
|
4
|
+
* Portfolio slice for a user-defined account group.
|
|
5
|
+
*
|
|
6
|
+
* Aggregates holdings across all accounts in a group, which may span
|
|
7
|
+
* multiple wallet connections and watch addresses.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* import { GroupPortfolio } from '@cygnus-wealth/data-models';
|
|
12
|
+
*
|
|
13
|
+
* const groupPortfolio: GroupPortfolio = {
|
|
14
|
+
* groupId: 'group-defi-1',
|
|
15
|
+
* groupName: 'DeFi Accounts',
|
|
16
|
+
* accounts: [],
|
|
17
|
+
* totalValue: { value: 75000, currency: 'USD', timestamp: new Date() },
|
|
18
|
+
* lastUpdated: '2026-02-19T08:00:00Z'
|
|
19
|
+
* };
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* @since 1.3.0
|
|
23
|
+
* @stability extended
|
|
24
|
+
*
|
|
25
|
+
* @see {@link AccountGroup} for group definition
|
|
26
|
+
* @see {@link AccountPortfolio} for per-account breakdown
|
|
27
|
+
*/
|
|
28
|
+
export interface GroupPortfolio {
|
|
29
|
+
/** Group identifier */
|
|
30
|
+
groupId: string;
|
|
31
|
+
/** User-assigned group name */
|
|
32
|
+
groupName: string;
|
|
33
|
+
/** Per-account portfolio breakdowns within this group */
|
|
34
|
+
accounts: AccountPortfolio[];
|
|
35
|
+
/** Total value across all accounts in this group */
|
|
36
|
+
totalValue: Price;
|
|
37
|
+
/** ISO 8601 timestamp of last data update */
|
|
38
|
+
lastUpdated: string;
|
|
39
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { IntegrationSource } from '../enums/IntegrationSource';
|
|
2
|
+
import { AccountId } from '../types/AccountId';
|
|
2
3
|
import { Metadata } from './Metadata';
|
|
3
4
|
/**
|
|
4
5
|
* Encrypted credentials for CEX/brokerage API integration.
|
|
@@ -60,6 +61,8 @@ export interface IntegrationCredentials {
|
|
|
60
61
|
walletAddress?: string;
|
|
61
62
|
/** Blockchain network ID for wallet connections (e.g., '1' for Ethereum mainnet) */
|
|
62
63
|
chainId?: string;
|
|
64
|
+
/** Account identifier when this integration is account-specific */
|
|
65
|
+
accountId?: AccountId;
|
|
63
66
|
/** Source-specific metadata (permissions, connection settings, etc.) */
|
|
64
67
|
metadata?: Metadata;
|
|
65
68
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Chain } from '../enums/Chain';
|
|
2
2
|
import { LendingPositionType } from '../enums/LendingPositionType';
|
|
3
|
+
import { DeFiDiscoverySource } from '../enums/DeFiDiscoverySource';
|
|
3
4
|
import { Asset } from './Asset';
|
|
4
5
|
import { Price } from './Price';
|
|
5
6
|
import { Metadata } from './Metadata';
|
|
@@ -98,6 +99,8 @@ export interface LendingPosition {
|
|
|
98
99
|
liquidationThreshold?: number;
|
|
99
100
|
/** Current total value of position (positive for supply, negative for borrow debt) */
|
|
100
101
|
value?: Price;
|
|
102
|
+
/** How this position was discovered during portfolio scanning */
|
|
103
|
+
discoverySource?: DeFiDiscoverySource;
|
|
101
104
|
/** Protocol-specific metadata (collateral assets, liquidation price, etc.) */
|
|
102
105
|
metadata?: Metadata;
|
|
103
106
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Chain } from '../enums/Chain';
|
|
2
|
+
import { DeFiDiscoverySource } from '../enums/DeFiDiscoverySource';
|
|
2
3
|
import { Balance } from './Balance';
|
|
3
4
|
import { Price } from './Price';
|
|
4
5
|
import { Metadata } from './Metadata';
|
|
@@ -77,6 +78,8 @@ export interface LiquidityPosition {
|
|
|
77
78
|
feesEarned?: number;
|
|
78
79
|
/** Impermanent loss compared to holding tokens (negative = loss, positive = gain) */
|
|
79
80
|
impermanentLoss?: number;
|
|
81
|
+
/** How this position was discovered during portfolio scanning */
|
|
82
|
+
discoverySource?: DeFiDiscoverySource;
|
|
80
83
|
/** Protocol-specific metadata (pool version, fee tier, range bounds, etc.) */
|
|
81
84
|
metadata?: Metadata;
|
|
82
85
|
}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
+
import { AccountId } from '../types/AccountId';
|
|
2
|
+
import { WalletConnectionId } from '../types/WalletConnectionId';
|
|
1
3
|
import { Account } from './Account';
|
|
4
|
+
import { AccountPortfolio } from './AccountPortfolio';
|
|
5
|
+
import { WalletPortfolio } from './WalletPortfolio';
|
|
2
6
|
import { Price } from './Price';
|
|
3
7
|
import { PortfolioAsset } from './PortfolioAsset';
|
|
4
8
|
import { Metadata } from './Metadata';
|
|
@@ -118,6 +122,10 @@ export interface Portfolio {
|
|
|
118
122
|
};
|
|
119
123
|
/** Timestamp of last portfolio data update */
|
|
120
124
|
lastUpdated: Date;
|
|
125
|
+
/** Per-account portfolio breakdown for multi-wallet attribution */
|
|
126
|
+
accountBreakdown?: Map<AccountId, AccountPortfolio>;
|
|
127
|
+
/** Per-wallet portfolio breakdown for multi-wallet attribution */
|
|
128
|
+
walletBreakdown?: Map<WalletConnectionId, WalletPortfolio>;
|
|
121
129
|
/** Portfolio-specific metadata (theme, display preferences, etc.) */
|
|
122
130
|
metadata?: Metadata;
|
|
123
131
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Chain } from '../enums/Chain';
|
|
2
|
+
import { DeFiDiscoverySource } from '../enums/DeFiDiscoverySource';
|
|
2
3
|
import { Asset } from './Asset';
|
|
3
4
|
import { Balance } from './Balance';
|
|
4
5
|
import { Price } from './Price';
|
|
@@ -91,6 +92,8 @@ export interface StakedPosition {
|
|
|
91
92
|
apr?: number;
|
|
92
93
|
/** Current total value of staked position plus rewards */
|
|
93
94
|
value?: Price;
|
|
95
|
+
/** How this position was discovered during portfolio scanning */
|
|
96
|
+
discoverySource?: DeFiDiscoverySource;
|
|
94
97
|
/** Protocol-specific metadata (validator performance, slashing history, etc.) */
|
|
95
98
|
metadata?: Metadata;
|
|
96
99
|
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { AccountId } from '../types/AccountId';
|
|
2
|
+
import { WalletConnectionId } from '../types/WalletConnectionId';
|
|
3
|
+
import { WalletProviderId } from '../types/WalletProviderId';
|
|
4
|
+
import { Chain } from '../enums/Chain';
|
|
5
|
+
import { ChainFamily } from '../enums/ChainFamily';
|
|
6
|
+
/**
|
|
7
|
+
* An address being tracked for portfolio purposes with full account context.
|
|
8
|
+
*
|
|
9
|
+
* Used by the WalletIntegrationContract to communicate tracked addresses
|
|
10
|
+
* to PortfolioAggregation with all necessary attribution metadata.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* import { TrackedAddress } from '@cygnus-wealth/data-models';
|
|
15
|
+
*
|
|
16
|
+
* const tracked: TrackedAddress = {
|
|
17
|
+
* accountId: 'metamask:a1b2c3d4:0xAbCdEf1234567890',
|
|
18
|
+
* address: '0xAbCdEf1234567890',
|
|
19
|
+
* walletConnectionId: 'metamask:a1b2c3d4',
|
|
20
|
+
* providerId: 'metamask',
|
|
21
|
+
* accountLabel: 'Main DeFi',
|
|
22
|
+
* connectionLabel: 'My MetaMask',
|
|
23
|
+
* chainScope: [Chain.ETHEREUM, Chain.POLYGON]
|
|
24
|
+
* };
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* @since 1.3.0
|
|
28
|
+
* @stability extended
|
|
29
|
+
*
|
|
30
|
+
* @see {@link ConnectedAccount} for the source account data
|
|
31
|
+
* @see {@link WatchAddress} for watch-only tracked addresses
|
|
32
|
+
*/
|
|
33
|
+
export interface TrackedAddress {
|
|
34
|
+
/** Account identifier */
|
|
35
|
+
accountId: AccountId;
|
|
36
|
+
/** Checksummed address */
|
|
37
|
+
address: string;
|
|
38
|
+
/** Wallet connection this address belongs to, or 'watch' */
|
|
39
|
+
walletConnectionId: WalletConnectionId | 'watch';
|
|
40
|
+
/** Wallet provider identifier, or 'watch' */
|
|
41
|
+
providerId: WalletProviderId | 'watch';
|
|
42
|
+
/** User-assigned account label */
|
|
43
|
+
accountLabel: string;
|
|
44
|
+
/** Label of the parent wallet connection */
|
|
45
|
+
connectionLabel: string;
|
|
46
|
+
/** Chain family of this tracked address, used for integration routing */
|
|
47
|
+
chainFamily: ChainFamily;
|
|
48
|
+
/** Chains to query for this address */
|
|
49
|
+
chainScope: Chain[];
|
|
50
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { TransactionType } from '../enums/TransactionType';
|
|
2
2
|
import { Chain } from '../enums/Chain';
|
|
3
|
+
import { WalletConnectionId } from '../types/WalletConnectionId';
|
|
3
4
|
import { Asset } from './Asset';
|
|
4
5
|
import { Price } from './Price';
|
|
5
6
|
import { Metadata } from './Metadata';
|
|
@@ -95,6 +96,8 @@ export interface Transaction {
|
|
|
95
96
|
id: string;
|
|
96
97
|
/** Reference to the Account.id where this transaction occurred */
|
|
97
98
|
accountId: string;
|
|
99
|
+
/** Wallet connection this transaction belongs to, or 'watch' for watch addresses */
|
|
100
|
+
walletConnectionId?: WalletConnectionId | 'watch';
|
|
98
101
|
/** Type of transaction operation */
|
|
99
102
|
type: TransactionType;
|
|
100
103
|
/** Transaction status for lifecycle tracking */
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { Chain } from '../enums/Chain';
|
|
2
|
+
import { VaultStrategyType } from '../enums/VaultStrategyType';
|
|
3
|
+
import { DeFiDiscoverySource } from '../enums/DeFiDiscoverySource';
|
|
4
|
+
import { Asset } from './Asset';
|
|
5
|
+
import { Price } from './Price';
|
|
6
|
+
import { Metadata } from './Metadata';
|
|
7
|
+
/**
|
|
8
|
+
* Yield vault deposit position tracking shares and performance.
|
|
9
|
+
*
|
|
10
|
+
* Represents user deposits in yield-generating vaults (Yearn, Beefy, Harvest,
|
|
11
|
+
* Sommelier, etc.) where assets are deposited into a vault contract that
|
|
12
|
+
* executes automated strategies. Tracks deposited amount, vault share tokens,
|
|
13
|
+
* APY, and underlying asset.
|
|
14
|
+
*
|
|
15
|
+
* **Design Pattern:** DeFi position entity for vault operations. Vaults issue
|
|
16
|
+
* share tokens representing proportional ownership. The share price (pricePerShare)
|
|
17
|
+
* increases over time as the vault earns yield, meaning the same number of shares
|
|
18
|
+
* becomes redeemable for more underlying tokens.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* import { VaultPosition, VaultStrategyType, Chain, AssetType } from '@cygnus-wealth/data-models';
|
|
23
|
+
*
|
|
24
|
+
* // Yearn USDC vault deposit
|
|
25
|
+
* const yearnPosition: VaultPosition = {
|
|
26
|
+
* id: 'yearn-usdc-vault-123',
|
|
27
|
+
* protocol: 'Yearn V3',
|
|
28
|
+
* vaultAddress: '0xa354F35829Ae975e850e23e9615b11Da1B3dC4DE',
|
|
29
|
+
* vaultName: 'USDC yVault',
|
|
30
|
+
* chain: Chain.ETHEREUM,
|
|
31
|
+
* strategyType: VaultStrategyType.YIELD_AGGREGATOR,
|
|
32
|
+
* depositAsset: {
|
|
33
|
+
* id: 'ethereum-usdc',
|
|
34
|
+
* symbol: 'USDC',
|
|
35
|
+
* name: 'USD Coin',
|
|
36
|
+
* type: AssetType.CRYPTOCURRENCY,
|
|
37
|
+
* decimals: 6
|
|
38
|
+
* },
|
|
39
|
+
* depositedAmount: '50000.000000',
|
|
40
|
+
* shareBalance: '48500.000000',
|
|
41
|
+
* pricePerShare: 1.0309,
|
|
42
|
+
* apy: 8.5,
|
|
43
|
+
* value: {
|
|
44
|
+
* value: 50000,
|
|
45
|
+
* currency: 'USD',
|
|
46
|
+
* timestamp: new Date()
|
|
47
|
+
* }
|
|
48
|
+
* };
|
|
49
|
+
*
|
|
50
|
+
* // Beefy auto-compounder on Arbitrum
|
|
51
|
+
* const beefyPosition: VaultPosition = {
|
|
52
|
+
* id: 'beefy-arb-eth-usdc-456',
|
|
53
|
+
* protocol: 'Beefy',
|
|
54
|
+
* vaultAddress: '0xDeadBeef...',
|
|
55
|
+
* vaultName: 'mooArbETH-USDC',
|
|
56
|
+
* chain: Chain.ARBITRUM,
|
|
57
|
+
* strategyType: VaultStrategyType.LIQUIDITY_PROVISION,
|
|
58
|
+
* depositAsset: {
|
|
59
|
+
* id: 'arbitrum-eth',
|
|
60
|
+
* symbol: 'ETH',
|
|
61
|
+
* name: 'Ethereum',
|
|
62
|
+
* type: AssetType.CRYPTOCURRENCY,
|
|
63
|
+
* decimals: 18
|
|
64
|
+
* },
|
|
65
|
+
* depositedAmount: '2.5',
|
|
66
|
+
* shareBalance: '2.35',
|
|
67
|
+
* pricePerShare: 1.0638,
|
|
68
|
+
* apy: 12.3,
|
|
69
|
+
* value: {
|
|
70
|
+
* value: 5000,
|
|
71
|
+
* currency: 'USD',
|
|
72
|
+
* timestamp: new Date()
|
|
73
|
+
* }
|
|
74
|
+
* };
|
|
75
|
+
* ```
|
|
76
|
+
*
|
|
77
|
+
* @since 1.2.0
|
|
78
|
+
* @stability extended
|
|
79
|
+
*
|
|
80
|
+
* @see {@link VaultStrategyType} for vault strategy classification
|
|
81
|
+
* @see {@link Asset} for deposit asset definition
|
|
82
|
+
* @see {@link Account} for position aggregation
|
|
83
|
+
*/
|
|
84
|
+
export interface VaultPosition {
|
|
85
|
+
/** Unique identifier for this vault position */
|
|
86
|
+
id: string;
|
|
87
|
+
/** Vault protocol name (e.g., 'Yearn V3', 'Beefy', 'Harvest', 'Sommelier') */
|
|
88
|
+
protocol: string;
|
|
89
|
+
/** Smart contract address of the vault */
|
|
90
|
+
vaultAddress: string;
|
|
91
|
+
/** Human-readable vault name (e.g., 'USDC yVault', 'mooArbETH-USDC') */
|
|
92
|
+
vaultName: string;
|
|
93
|
+
/** Blockchain network where the vault exists */
|
|
94
|
+
chain: Chain;
|
|
95
|
+
/** Classification of the vault's underlying strategy */
|
|
96
|
+
strategyType: VaultStrategyType;
|
|
97
|
+
/** Asset deposited into the vault (the underlying token) */
|
|
98
|
+
depositAsset: Asset;
|
|
99
|
+
/** Amount of underlying asset deposited (as string for precision) */
|
|
100
|
+
depositedAmount: string;
|
|
101
|
+
/** Amount of vault share tokens held (as string for precision) */
|
|
102
|
+
shareBalance?: string;
|
|
103
|
+
/** Current price per share in terms of deposit asset (e.g., 1.03 means 3% profit) */
|
|
104
|
+
pricePerShare?: number;
|
|
105
|
+
/** Annual Percentage Yield for the vault (e.g., 8.5 = 8.5%) */
|
|
106
|
+
apy?: number;
|
|
107
|
+
/** Current total value of the vault position */
|
|
108
|
+
value?: Price;
|
|
109
|
+
/** How this position was discovered during portfolio scanning */
|
|
110
|
+
discoverySource?: DeFiDiscoverySource;
|
|
111
|
+
/** Protocol-specific metadata (strategy details, harvest frequency, TVL, etc.) */
|
|
112
|
+
metadata?: Metadata;
|
|
113
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { WalletConnectionId } from '../types/WalletConnectionId';
|
|
2
|
+
import { WalletProviderId } from '../types/WalletProviderId';
|
|
3
|
+
import { Chain } from '../enums/Chain';
|
|
4
|
+
import { ChainFamily } from '../enums/ChainFamily';
|
|
5
|
+
import { ConnectedAccount } from './ConnectedAccount';
|
|
6
|
+
/**
|
|
7
|
+
* A connected wallet provider session.
|
|
8
|
+
*
|
|
9
|
+
* Represents a single connection session to a wallet provider. A user may have
|
|
10
|
+
* multiple connections to the same provider (e.g., two WalletConnect sessions)
|
|
11
|
+
* or connections to different providers simultaneously.
|
|
12
|
+
*
|
|
13
|
+
* Each connection maintains its own list of accumulated accounts discovered
|
|
14
|
+
* via EIP-1193 or manually added by the user.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* import { WalletConnection } from '@cygnus-wealth/data-models';
|
|
19
|
+
*
|
|
20
|
+
* const connection: WalletConnection = {
|
|
21
|
+
* connectionId: 'metamask:a1b2c3d4',
|
|
22
|
+
* providerId: 'metamask',
|
|
23
|
+
* providerName: 'MetaMask',
|
|
24
|
+
* providerIcon: 'https://metamask.io/icon.svg',
|
|
25
|
+
* connectionLabel: 'My MetaMask',
|
|
26
|
+
* accounts: [],
|
|
27
|
+
* activeAccountAddress: '0xAbCdEf1234567890',
|
|
28
|
+
* supportedChains: [Chain.ETHEREUM, Chain.POLYGON],
|
|
29
|
+
* connectedAt: '2026-01-15T10:30:00Z',
|
|
30
|
+
* lastActiveAt: '2026-02-19T08:00:00Z',
|
|
31
|
+
* sessionStatus: 'active'
|
|
32
|
+
* };
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* @since 1.3.0
|
|
36
|
+
* @stability extended
|
|
37
|
+
*
|
|
38
|
+
* @see {@link ConnectedAccount} for individual account entries
|
|
39
|
+
* @see {@link WalletProviderId} for provider identification
|
|
40
|
+
* @see {@link WalletConnectionId} for connection identifier format
|
|
41
|
+
*/
|
|
42
|
+
export interface WalletConnection {
|
|
43
|
+
/** Unique connection identifier: `{providerId}:{randomId}` */
|
|
44
|
+
connectionId: WalletConnectionId;
|
|
45
|
+
/** Canonical wallet provider identifier */
|
|
46
|
+
providerId: WalletProviderId;
|
|
47
|
+
/** Human-readable provider name (e.g., "MetaMask") */
|
|
48
|
+
providerName: string;
|
|
49
|
+
/** URL or identifier for the provider's icon */
|
|
50
|
+
providerIcon: string;
|
|
51
|
+
/** User-assigned label (default: provider name) */
|
|
52
|
+
connectionLabel: string;
|
|
53
|
+
/** All accounts accumulated from this connection */
|
|
54
|
+
accounts: ConnectedAccount[];
|
|
55
|
+
/** Currently selected account address in the wallet provider, or null */
|
|
56
|
+
activeAccountAddress: string | null;
|
|
57
|
+
/** Chains this wallet connection supports */
|
|
58
|
+
supportedChains: Chain[];
|
|
59
|
+
/** Chain families this wallet connection supports (e.g., EVM, Solana, SUI) */
|
|
60
|
+
supportedChainFamilies: ChainFamily[];
|
|
61
|
+
/** ISO 8601 timestamp of initial connection */
|
|
62
|
+
connectedAt: string;
|
|
63
|
+
/** ISO 8601 timestamp of last activity */
|
|
64
|
+
lastActiveAt: string;
|
|
65
|
+
/** Session lifecycle status */
|
|
66
|
+
sessionStatus: 'active' | 'stale' | 'disconnected';
|
|
67
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { WalletConnectionId } from '../types/WalletConnectionId';
|
|
2
|
+
import { AccountPortfolio } from './AccountPortfolio';
|
|
3
|
+
import { Price } from './Price';
|
|
4
|
+
/**
|
|
5
|
+
* Portfolio slice for all accounts in a wallet connection.
|
|
6
|
+
*
|
|
7
|
+
* Aggregates holdings across all accounts within a single wallet
|
|
8
|
+
* connection session.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* import { WalletPortfolio } from '@cygnus-wealth/data-models';
|
|
13
|
+
*
|
|
14
|
+
* const walletPortfolio: WalletPortfolio = {
|
|
15
|
+
* walletConnectionId: 'metamask:a1b2c3d4',
|
|
16
|
+
* connectionLabel: 'My MetaMask',
|
|
17
|
+
* providerName: 'MetaMask',
|
|
18
|
+
* accounts: [],
|
|
19
|
+
* totalValue: { value: 50000, currency: 'USD', timestamp: new Date() }
|
|
20
|
+
* };
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @since 1.3.0
|
|
24
|
+
* @stability extended
|
|
25
|
+
*
|
|
26
|
+
* @see {@link AccountPortfolio} for per-account breakdown
|
|
27
|
+
* @see {@link Portfolio} for aggregate portfolio
|
|
28
|
+
*/
|
|
29
|
+
export interface WalletPortfolio {
|
|
30
|
+
/** Wallet connection this portfolio belongs to */
|
|
31
|
+
walletConnectionId: WalletConnectionId;
|
|
32
|
+
/** User-assigned connection label */
|
|
33
|
+
connectionLabel: string;
|
|
34
|
+
/** Human-readable provider name */
|
|
35
|
+
providerName: string;
|
|
36
|
+
/** Per-account portfolio breakdowns within this wallet */
|
|
37
|
+
accounts: AccountPortfolio[];
|
|
38
|
+
/** Total value across all accounts in this wallet connection */
|
|
39
|
+
totalValue: Price;
|
|
40
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { AccountId } from '../types/AccountId';
|
|
2
|
+
import { Chain } from '../enums/Chain';
|
|
3
|
+
import { ChainFamily } from '../enums/ChainFamily';
|
|
4
|
+
/**
|
|
5
|
+
* An address tracked independently of any wallet connection.
|
|
6
|
+
*
|
|
7
|
+
* Represents a read-only monitoring target that the user added manually
|
|
8
|
+
* without connecting a wallet. Watch addresses have no associated provider,
|
|
9
|
+
* no session lifecycle, and never receive `accountsChanged` events.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* import { WatchAddress } from '@cygnus-wealth/data-models';
|
|
14
|
+
*
|
|
15
|
+
* const watched: WatchAddress = {
|
|
16
|
+
* accountId: 'watch:0xAbCdEf1234567890',
|
|
17
|
+
* address: '0xAbCdEf1234567890',
|
|
18
|
+
* addressLabel: 'Vitalik.eth',
|
|
19
|
+
* chainScope: [Chain.ETHEREUM],
|
|
20
|
+
* addedAt: '2026-02-01T12:00:00Z'
|
|
21
|
+
* };
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* @since 1.3.0
|
|
25
|
+
* @stability extended
|
|
26
|
+
*
|
|
27
|
+
* @see {@link AccountId} for identifier format (watch:\{checksummedAddress\})
|
|
28
|
+
*/
|
|
29
|
+
export interface WatchAddress {
|
|
30
|
+
/** Account identifier: `watch:{checksummedAddress}` */
|
|
31
|
+
accountId: AccountId;
|
|
32
|
+
/** Checksummed address being monitored */
|
|
33
|
+
address: string;
|
|
34
|
+
/** User-assigned label */
|
|
35
|
+
addressLabel: string;
|
|
36
|
+
/** Chain family of this watched address */
|
|
37
|
+
chainFamily: ChainFamily;
|
|
38
|
+
/** Chains to track this address on */
|
|
39
|
+
chainScope: Chain[];
|
|
40
|
+
/** ISO 8601 timestamp when this watch address was added */
|
|
41
|
+
addedAt: string;
|
|
42
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unique identifier for a specific account across the system.
|
|
3
|
+
*
|
|
4
|
+
* Format: `{walletConnectionId}:{chainFamily}:{address}` for connected accounts
|
|
5
|
+
* (e.g., `metamask:a1b2c3d4:evm:0xAbC...123`), or `watch:{address}`
|
|
6
|
+
* for watch addresses.
|
|
7
|
+
*
|
|
8
|
+
* The `chainFamily` segment (introduced in en-o8w) disambiguates addresses
|
|
9
|
+
* from the same wallet connection that span different chain families.
|
|
10
|
+
*
|
|
11
|
+
* This is the primary key used throughout the system to reference a specific
|
|
12
|
+
* account. It disambiguates the same address appearing in different wallet
|
|
13
|
+
* connections (e.g., imported into both MetaMask and Rabby).
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* import { AccountId } from '@cygnus-wealth/data-models';
|
|
18
|
+
*
|
|
19
|
+
* const evmAccountId: AccountId = 'metamask:a1b2c3d4:evm:0xAbCdEf1234567890';
|
|
20
|
+
* const solanaAccountId: AccountId = 'phantom:abc123:solana:7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU';
|
|
21
|
+
* const watchAccountId: AccountId = 'watch:0xAbCdEf1234567890';
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* @since 1.3.0
|
|
25
|
+
* @stability extended
|
|
26
|
+
*/
|
|
27
|
+
export type AccountId = string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|