@cygnus-wealth/data-models 1.2.0 → 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/index.js +9 -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/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/index.d.ts +23 -0
- package/dist/index.js +4 -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 +3 -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
|
@@ -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 */
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Chain } from '../enums/Chain';
|
|
2
2
|
import { VaultStrategyType } from '../enums/VaultStrategyType';
|
|
3
|
+
import { DeFiDiscoverySource } from '../enums/DeFiDiscoverySource';
|
|
3
4
|
import { Asset } from './Asset';
|
|
4
5
|
import { Price } from './Price';
|
|
5
6
|
import { Metadata } from './Metadata';
|
|
@@ -105,6 +106,8 @@ export interface VaultPosition {
|
|
|
105
106
|
apy?: number;
|
|
106
107
|
/** Current total value of the vault position */
|
|
107
108
|
value?: Price;
|
|
109
|
+
/** How this position was discovered during portfolio scanning */
|
|
110
|
+
discoverySource?: DeFiDiscoverySource;
|
|
108
111
|
/** Protocol-specific metadata (strategy details, harvest frequency, TVL, etc.) */
|
|
109
112
|
metadata?: Metadata;
|
|
110
113
|
}
|
|
@@ -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 {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CAIP-2 chain identifier string type.
|
|
3
|
+
*
|
|
4
|
+
* Format: `{namespace}:{reference}` as defined by the Chain Agnostic
|
|
5
|
+
* Improvement Proposal 2. Used for WalletConnect v2 interoperability.
|
|
6
|
+
*
|
|
7
|
+
* Common namespace prefixes map to ChainFamily values:
|
|
8
|
+
* - `eip155` → ChainFamily.EVM (e.g., `eip155:1` for Ethereum mainnet)
|
|
9
|
+
* - `solana` → ChainFamily.SOLANA (e.g., `solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp`)
|
|
10
|
+
* - `bip122` → ChainFamily.BITCOIN
|
|
11
|
+
* - `cosmos` → ChainFamily.COSMOS
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* import { Caip2ChainId } from '@cygnus-wealth/data-models';
|
|
16
|
+
*
|
|
17
|
+
* const ethereumMainnet: Caip2ChainId = 'eip155:1';
|
|
18
|
+
* const polygon: Caip2ChainId = 'eip155:137';
|
|
19
|
+
* const solanaMainnet: Caip2ChainId = 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp';
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* @since 1.5.0
|
|
23
|
+
* @stability extended
|
|
24
|
+
*
|
|
25
|
+
* @see {@link ChainFamily} for chain family classification
|
|
26
|
+
*/
|
|
27
|
+
export type Caip2ChainId = string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unique identifier for a specific wallet connection session.
|
|
3
|
+
*
|
|
4
|
+
* Format: `{providerId}:{randomId}` (e.g., `metamask:a1b2c3d4`).
|
|
5
|
+
* The randomId component ensures uniqueness when the same provider
|
|
6
|
+
* is connected multiple times (e.g., two WalletConnect sessions).
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { WalletConnectionId } from '@cygnus-wealth/data-models';
|
|
11
|
+
*
|
|
12
|
+
* const connectionId: WalletConnectionId = 'metamask:a1b2c3d4';
|
|
13
|
+
* const wcConnectionId: WalletConnectionId = 'walletconnect:x9y8z7w6';
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @since 1.3.0
|
|
17
|
+
* @stability extended
|
|
18
|
+
*/
|
|
19
|
+
export type WalletConnectionId = string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical identifier for a wallet provider.
|
|
3
|
+
*
|
|
4
|
+
* String union type representing supported wallet providers. Extensible
|
|
5
|
+
* without breaking changes when new wallets are supported.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { WalletProviderId } from '@cygnus-wealth/data-models';
|
|
10
|
+
*
|
|
11
|
+
* const provider: WalletProviderId = 'metamask';
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* @since 1.3.0
|
|
15
|
+
* @stability extended
|
|
16
|
+
*/
|
|
17
|
+
export type WalletProviderId = 'metamask' | 'rabby' | 'walletconnect' | 'coinbase-wallet' | 'trust-wallet' | 'frame' | 'crypto-com-onchain' | 'phantom' | 'solflare' | 'backpack' | 'exodus' | 'manual';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cygnus-wealth/data-models",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "Shared TypeScript data models for CygnusWealth project",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -21,6 +21,11 @@
|
|
|
21
21
|
"import": "./dist/enums/Chain.js",
|
|
22
22
|
"require": "./dist/cjs/enums/Chain.js"
|
|
23
23
|
},
|
|
24
|
+
"./enums/ChainFamily": {
|
|
25
|
+
"types": "./dist/enums/ChainFamily.d.ts",
|
|
26
|
+
"import": "./dist/enums/ChainFamily.js",
|
|
27
|
+
"require": "./dist/cjs/enums/ChainFamily.js"
|
|
28
|
+
},
|
|
24
29
|
"./enums/IntegrationSource": {
|
|
25
30
|
"types": "./dist/enums/IntegrationSource.d.ts",
|
|
26
31
|
"import": "./dist/enums/IntegrationSource.js",
|
|
@@ -41,6 +46,26 @@
|
|
|
41
46
|
"import": "./dist/enums/LendingPositionType.js",
|
|
42
47
|
"require": "./dist/cjs/enums/LendingPositionType.js"
|
|
43
48
|
},
|
|
49
|
+
"./enums/VaultStrategyType": {
|
|
50
|
+
"types": "./dist/enums/VaultStrategyType.d.ts",
|
|
51
|
+
"import": "./dist/enums/VaultStrategyType.js",
|
|
52
|
+
"require": "./dist/cjs/enums/VaultStrategyType.js"
|
|
53
|
+
},
|
|
54
|
+
"./enums/DeFiPositionType": {
|
|
55
|
+
"types": "./dist/enums/DeFiPositionType.d.ts",
|
|
56
|
+
"import": "./dist/enums/DeFiPositionType.js",
|
|
57
|
+
"require": "./dist/cjs/enums/DeFiPositionType.js"
|
|
58
|
+
},
|
|
59
|
+
"./enums/DeFiProtocol": {
|
|
60
|
+
"types": "./dist/enums/DeFiProtocol.d.ts",
|
|
61
|
+
"import": "./dist/enums/DeFiProtocol.js",
|
|
62
|
+
"require": "./dist/cjs/enums/DeFiProtocol.js"
|
|
63
|
+
},
|
|
64
|
+
"./enums/DeFiDiscoverySource": {
|
|
65
|
+
"types": "./dist/enums/DeFiDiscoverySource.d.ts",
|
|
66
|
+
"import": "./dist/enums/DeFiDiscoverySource.js",
|
|
67
|
+
"require": "./dist/cjs/enums/DeFiDiscoverySource.js"
|
|
68
|
+
},
|
|
44
69
|
"./interfaces/*": {
|
|
45
70
|
"types": "./dist/interfaces/*.d.ts",
|
|
46
71
|
"import": "./dist/interfaces/*.js",
|