@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
|
@@ -61,6 +61,14 @@ export var IntegrationSource;
|
|
|
61
61
|
IntegrationSource["MANUAL_ENTRY"] = "MANUAL_ENTRY";
|
|
62
62
|
/** Data fetched directly from blockchain via RPC */
|
|
63
63
|
IntegrationSource["BLOCKCHAIN_DIRECT"] = "BLOCKCHAIN_DIRECT";
|
|
64
|
+
/** SUI blockchain integration */
|
|
65
|
+
IntegrationSource["SUI"] = "SUI";
|
|
66
|
+
/** Bitcoin blockchain integration */
|
|
67
|
+
IntegrationSource["BITCOIN"] = "BITCOIN";
|
|
68
|
+
/** Cosmos ecosystem integration */
|
|
69
|
+
IntegrationSource["COSMOS"] = "COSMOS";
|
|
70
|
+
/** Aptos blockchain integration */
|
|
71
|
+
IntegrationSource["APTOS"] = "APTOS";
|
|
64
72
|
/** Other or unclassified data source */
|
|
65
73
|
IntegrationSource["OTHER"] = "OTHER";
|
|
66
74
|
})(IntegrationSource || (IntegrationSource = {}));
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
export { AssetType } from './enums/AssetType';
|
|
2
2
|
export { Chain } from './enums/Chain';
|
|
3
|
+
export { ChainFamily } from './enums/ChainFamily';
|
|
3
4
|
export { IntegrationSource } from './enums/IntegrationSource';
|
|
4
5
|
export { TransactionType } from './enums/TransactionType';
|
|
5
6
|
export { AccountType } from './enums/AccountType';
|
|
6
7
|
export { LendingPositionType } from './enums/LendingPositionType';
|
|
7
8
|
export { VaultStrategyType } from './enums/VaultStrategyType';
|
|
9
|
+
export { DeFiPositionType } from './enums/DeFiPositionType';
|
|
10
|
+
export { DeFiProtocol } from './enums/DeFiProtocol';
|
|
11
|
+
export { DeFiDiscoverySource } from './enums/DeFiDiscoverySource';
|
|
8
12
|
export { BaseEntity } from './interfaces/BaseEntity';
|
|
9
13
|
export { Metadata } from './interfaces/Metadata';
|
|
10
14
|
export { Asset } from './interfaces/Asset';
|
|
@@ -16,9 +20,28 @@ export { LiquidityPosition } from './interfaces/LiquidityPosition';
|
|
|
16
20
|
export { StakedPosition } from './interfaces/StakedPosition';
|
|
17
21
|
export { LendingPosition } from './interfaces/LendingPosition';
|
|
18
22
|
export { VaultPosition } from './interfaces/VaultPosition';
|
|
23
|
+
export { DeFiPosition } from './interfaces/DeFiPosition';
|
|
19
24
|
export { Account } from './interfaces/Account';
|
|
20
25
|
export { Portfolio } from './interfaces/Portfolio';
|
|
21
26
|
export { PortfolioAsset } from './interfaces/PortfolioAsset';
|
|
27
|
+
export type { WalletProviderId } from './types/WalletProviderId';
|
|
28
|
+
export type { WalletConnectionId } from './types/WalletConnectionId';
|
|
29
|
+
export type { AccountId } from './types/AccountId';
|
|
30
|
+
export type { Caip2ChainId } from './types/Caip2ChainId';
|
|
31
|
+
export type { WalletConnection } from './interfaces/WalletConnection';
|
|
32
|
+
export type { ConnectedAccount } from './interfaces/ConnectedAccount';
|
|
33
|
+
export type { WatchAddress } from './interfaces/WatchAddress';
|
|
34
|
+
export type { AccountGroup } from './interfaces/AccountGroup';
|
|
35
|
+
export type { AccountPortfolio } from './interfaces/AccountPortfolio';
|
|
36
|
+
export type { WalletPortfolio } from './interfaces/WalletPortfolio';
|
|
37
|
+
export type { GroupPortfolio } from './interfaces/GroupPortfolio';
|
|
38
|
+
export type { AccountSummary } from './interfaces/AccountSummary';
|
|
39
|
+
export type { AssetDistribution } from './interfaces/AssetDistribution';
|
|
40
|
+
export type { AccountAssetEntry } from './interfaces/AccountAssetEntry';
|
|
41
|
+
export type { TrackedAddress } from './interfaces/TrackedAddress';
|
|
42
|
+
export type { AccountMetadata } from './interfaces/AccountMetadata';
|
|
43
|
+
export type { AddressRequest } from './interfaces/AddressRequest';
|
|
44
|
+
export type { AccountBalanceList, AccountBalance, AccountError } from './interfaces/AccountBalanceList';
|
|
22
45
|
export { Transaction } from './interfaces/Transaction';
|
|
23
46
|
export { IntegrationCredentials } from './interfaces/IntegrationCredentials';
|
|
24
47
|
export { SyncStatus } from './interfaces/SyncStatus';
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
// Enums
|
|
2
2
|
export { AssetType } from './enums/AssetType';
|
|
3
3
|
export { Chain } from './enums/Chain';
|
|
4
|
+
export { ChainFamily } from './enums/ChainFamily';
|
|
4
5
|
export { IntegrationSource } from './enums/IntegrationSource';
|
|
5
6
|
export { TransactionType } from './enums/TransactionType';
|
|
6
7
|
export { AccountType } from './enums/AccountType';
|
|
7
8
|
export { LendingPositionType } from './enums/LendingPositionType';
|
|
8
9
|
export { VaultStrategyType } from './enums/VaultStrategyType';
|
|
10
|
+
export { DeFiPositionType } from './enums/DeFiPositionType';
|
|
11
|
+
export { DeFiProtocol } from './enums/DeFiProtocol';
|
|
12
|
+
export { DeFiDiscoverySource } from './enums/DeFiDiscoverySource';
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { AccountId } from '../types/AccountId';
|
|
2
|
+
import { Balance } from './Balance';
|
|
3
|
+
import { Price } from './Price';
|
|
4
|
+
/**
|
|
5
|
+
* A single account's holding of an asset within an asset distribution.
|
|
6
|
+
*
|
|
7
|
+
* Used as part of {@link AssetDistribution} to show how much of a specific
|
|
8
|
+
* asset is held in each account and what percentage of the total it represents.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* import { AccountAssetEntry } from '@cygnus-wealth/data-models';
|
|
13
|
+
*
|
|
14
|
+
* const entry: AccountAssetEntry = {
|
|
15
|
+
* accountId: 'metamask:a1b2:0xAbc',
|
|
16
|
+
* accountLabel: 'Main DeFi',
|
|
17
|
+
* connectionLabel: 'My MetaMask',
|
|
18
|
+
* quantity: { assetId: 'eth', asset: ethAsset, amount: '7.0' },
|
|
19
|
+
* value: { value: 14000, currency: 'USD', timestamp: new Date() },
|
|
20
|
+
* percentage: 66.67
|
|
21
|
+
* };
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* @since 1.3.0
|
|
25
|
+
* @stability extended
|
|
26
|
+
*
|
|
27
|
+
* @see {@link AssetDistribution} for the parent distribution context
|
|
28
|
+
*/
|
|
29
|
+
export interface AccountAssetEntry {
|
|
30
|
+
/** Account holding this portion of the asset */
|
|
31
|
+
accountId: AccountId;
|
|
32
|
+
/** User-assigned account label */
|
|
33
|
+
accountLabel: string;
|
|
34
|
+
/** Label of the parent wallet connection */
|
|
35
|
+
connectionLabel: string;
|
|
36
|
+
/** Quantity of the asset in this account */
|
|
37
|
+
quantity: Balance;
|
|
38
|
+
/** Value of this account's holding */
|
|
39
|
+
value: Price;
|
|
40
|
+
/** Percentage of total for this asset (e.g., 66.67 = 66.67%) */
|
|
41
|
+
percentage: number;
|
|
42
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { AccountId } from '../types/AccountId';
|
|
2
|
+
import { Chain } from '../enums/Chain';
|
|
3
|
+
import { Balance } from './Balance';
|
|
4
|
+
/**
|
|
5
|
+
* A single account's balance result for a specific chain.
|
|
6
|
+
*
|
|
7
|
+
* Contains the native balance and token balances for one account
|
|
8
|
+
* on one chain, with the AccountId for attribution.
|
|
9
|
+
*
|
|
10
|
+
* @since 1.3.0
|
|
11
|
+
* @stability extended
|
|
12
|
+
*
|
|
13
|
+
* @see {@link AccountBalanceList} for the container type
|
|
14
|
+
*/
|
|
15
|
+
export interface AccountBalance {
|
|
16
|
+
/** Account this balance belongs to */
|
|
17
|
+
accountId: AccountId;
|
|
18
|
+
/** Checksummed address */
|
|
19
|
+
address: string;
|
|
20
|
+
/** Chain this balance was fetched from */
|
|
21
|
+
chainId: Chain;
|
|
22
|
+
/** Native token balance (e.g., ETH on Ethereum) */
|
|
23
|
+
nativeBalance: Balance;
|
|
24
|
+
/** ERC-20 and other token balances */
|
|
25
|
+
tokenBalances: Balance[];
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Error encountered while fetching data for a specific account.
|
|
29
|
+
*
|
|
30
|
+
* Supports partial failure: some accounts may succeed while others fail.
|
|
31
|
+
*
|
|
32
|
+
* @since 1.3.0
|
|
33
|
+
* @stability extended
|
|
34
|
+
*/
|
|
35
|
+
export interface AccountError {
|
|
36
|
+
/** Account that encountered the error */
|
|
37
|
+
accountId: AccountId;
|
|
38
|
+
/** Chain where the error occurred */
|
|
39
|
+
chainId: Chain;
|
|
40
|
+
/** Error message */
|
|
41
|
+
message: string;
|
|
42
|
+
/** Error code for programmatic handling */
|
|
43
|
+
code?: string;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Account-attributed balance results with support for partial failure.
|
|
47
|
+
*
|
|
48
|
+
* Returned by integration contracts when fetching balances for multiple
|
|
49
|
+
* accounts. Each balance carries its AccountId for attribution, and
|
|
50
|
+
* per-account errors are reported separately.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```typescript
|
|
54
|
+
* import { AccountBalanceList } from '@cygnus-wealth/data-models';
|
|
55
|
+
*
|
|
56
|
+
* const result: AccountBalanceList = {
|
|
57
|
+
* balances: [
|
|
58
|
+
* {
|
|
59
|
+
* accountId: 'metamask:a1b2:0xAbc',
|
|
60
|
+
* address: '0xAbc',
|
|
61
|
+
* chainId: Chain.ETHEREUM,
|
|
62
|
+
* nativeBalance: ethBalance,
|
|
63
|
+
* tokenBalances: [usdcBalance, daiBalance]
|
|
64
|
+
* }
|
|
65
|
+
* ],
|
|
66
|
+
* errors: [],
|
|
67
|
+
* timestamp: '2026-02-19T08:00:00Z'
|
|
68
|
+
* };
|
|
69
|
+
* ```
|
|
70
|
+
*
|
|
71
|
+
* @since 1.3.0
|
|
72
|
+
* @stability extended
|
|
73
|
+
*
|
|
74
|
+
* @see {@link AddressRequest} for the request format
|
|
75
|
+
* @see {@link AccountBalance} for individual balance results
|
|
76
|
+
* @see {@link AccountError} for per-account errors
|
|
77
|
+
*/
|
|
78
|
+
export interface AccountBalanceList {
|
|
79
|
+
/** Successful balance results */
|
|
80
|
+
balances: AccountBalance[];
|
|
81
|
+
/** Per-account errors (partial failure) */
|
|
82
|
+
errors: AccountError[];
|
|
83
|
+
/** ISO 8601 timestamp of the fetch */
|
|
84
|
+
timestamp: string;
|
|
85
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { AccountId } from '../types/AccountId';
|
|
2
|
+
/**
|
|
3
|
+
* User-defined grouping of accounts for organizational purposes.
|
|
4
|
+
*
|
|
5
|
+
* Allows users to create custom groups like "DeFi Accounts", "Long-term Holdings",
|
|
6
|
+
* or "Family" that span across wallet connections and watch addresses.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { AccountGroup } from '@cygnus-wealth/data-models';
|
|
11
|
+
*
|
|
12
|
+
* const group: AccountGroup = {
|
|
13
|
+
* groupId: 'group-defi-1',
|
|
14
|
+
* groupName: 'DeFi Accounts',
|
|
15
|
+
* accountIds: [
|
|
16
|
+
* 'metamask:a1b2c3d4:0xAbC...123',
|
|
17
|
+
* 'rabby:e5f6g7h8:0xDef...456'
|
|
18
|
+
* ],
|
|
19
|
+
* createdAt: '2026-02-10T09:00:00Z'
|
|
20
|
+
* };
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @since 1.3.0
|
|
24
|
+
* @stability extended
|
|
25
|
+
*
|
|
26
|
+
* @see {@link AccountId} for account identifier format
|
|
27
|
+
*/
|
|
28
|
+
export interface AccountGroup {
|
|
29
|
+
/** Unique group identifier */
|
|
30
|
+
groupId: string;
|
|
31
|
+
/** User-assigned group name */
|
|
32
|
+
groupName: string;
|
|
33
|
+
/** References to accounts from any connection or watch addresses */
|
|
34
|
+
accountIds: AccountId[];
|
|
35
|
+
/** ISO 8601 timestamp when the group was created */
|
|
36
|
+
createdAt: string;
|
|
37
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { AccountId } from '../types/AccountId';
|
|
2
|
+
import { WalletConnectionId } from '../types/WalletConnectionId';
|
|
3
|
+
import { WalletProviderId } from '../types/WalletProviderId';
|
|
4
|
+
/**
|
|
5
|
+
* Full metadata for an account, including group membership and lifecycle status.
|
|
6
|
+
*
|
|
7
|
+
* Provides comprehensive account context for portfolio aggregation and UI
|
|
8
|
+
* display, combining identity, labeling, and status information.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* import { AccountMetadata } from '@cygnus-wealth/data-models';
|
|
13
|
+
*
|
|
14
|
+
* const metadata: AccountMetadata = {
|
|
15
|
+
* accountId: 'metamask:a1b2c3d4:0xAbCdEf1234567890',
|
|
16
|
+
* address: '0xAbCdEf1234567890',
|
|
17
|
+
* accountLabel: 'Main DeFi',
|
|
18
|
+
* connectionLabel: 'My MetaMask',
|
|
19
|
+
* providerId: 'metamask',
|
|
20
|
+
* walletConnectionId: 'metamask:a1b2c3d4',
|
|
21
|
+
* groups: ['group-defi-1'],
|
|
22
|
+
* discoveredAt: '2026-01-15T10:30:00Z',
|
|
23
|
+
* isStale: false,
|
|
24
|
+
* isActive: true
|
|
25
|
+
* };
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* @since 1.3.0
|
|
29
|
+
* @stability extended
|
|
30
|
+
*
|
|
31
|
+
* @see {@link TrackedAddress} for the lightweight address tracking variant
|
|
32
|
+
*/
|
|
33
|
+
export interface AccountMetadata {
|
|
34
|
+
/** Account identifier */
|
|
35
|
+
accountId: AccountId;
|
|
36
|
+
/** Checksummed address */
|
|
37
|
+
address: string;
|
|
38
|
+
/** User-assigned account label */
|
|
39
|
+
accountLabel: string;
|
|
40
|
+
/** Label of the parent wallet connection */
|
|
41
|
+
connectionLabel: string;
|
|
42
|
+
/** Wallet provider identifier, or 'watch' for watch addresses */
|
|
43
|
+
providerId: WalletProviderId | 'watch';
|
|
44
|
+
/** Wallet connection identifier, or 'watch' for watch addresses */
|
|
45
|
+
walletConnectionId: WalletConnectionId | 'watch';
|
|
46
|
+
/** Group IDs this account belongs to */
|
|
47
|
+
groups: string[];
|
|
48
|
+
/** ISO 8601 timestamp when first discovered */
|
|
49
|
+
discoveredAt: string;
|
|
50
|
+
/** Whether the provider no longer exposes this account */
|
|
51
|
+
isStale: boolean;
|
|
52
|
+
/** Whether this is the currently active account in the provider */
|
|
53
|
+
isActive: boolean;
|
|
54
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { AccountId } from '../types/AccountId';
|
|
2
|
+
import { WalletConnectionId } from '../types/WalletConnectionId';
|
|
3
|
+
import { Asset } from './Asset';
|
|
4
|
+
import { Price } from './Price';
|
|
5
|
+
/**
|
|
6
|
+
* Portfolio slice for a single account.
|
|
7
|
+
*
|
|
8
|
+
* Represents the holdings attributed to one specific account, whether
|
|
9
|
+
* it's a connected wallet account or a watch address.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* import { AccountPortfolio } from '@cygnus-wealth/data-models';
|
|
14
|
+
*
|
|
15
|
+
* const accountPortfolio: AccountPortfolio = {
|
|
16
|
+
* accountId: 'metamask:a1b2c3d4:0xAbCdEf1234567890',
|
|
17
|
+
* accountLabel: 'Main DeFi',
|
|
18
|
+
* walletConnectionId: 'metamask:a1b2c3d4',
|
|
19
|
+
* providerName: 'MetaMask',
|
|
20
|
+
* assets: [],
|
|
21
|
+
* totalValue: { value: 25000, currency: 'USD', timestamp: new Date() },
|
|
22
|
+
* lastUpdated: '2026-02-19T08:00:00Z'
|
|
23
|
+
* };
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @since 1.3.0
|
|
27
|
+
* @stability extended
|
|
28
|
+
*
|
|
29
|
+
* @see {@link WalletPortfolio} for per-wallet rollup
|
|
30
|
+
* @see {@link Portfolio} for aggregate portfolio
|
|
31
|
+
*/
|
|
32
|
+
export interface AccountPortfolio {
|
|
33
|
+
/** Account this portfolio slice belongs to */
|
|
34
|
+
accountId: AccountId;
|
|
35
|
+
/** User-assigned account label */
|
|
36
|
+
accountLabel: string;
|
|
37
|
+
/** Wallet connection this account belongs to, or 'watch' for watch addresses */
|
|
38
|
+
walletConnectionId: WalletConnectionId | 'watch';
|
|
39
|
+
/** Human-readable provider name */
|
|
40
|
+
providerName: string;
|
|
41
|
+
/** Assets held in this account */
|
|
42
|
+
assets: Asset[];
|
|
43
|
+
/** Total value of this account's holdings */
|
|
44
|
+
totalValue: Price;
|
|
45
|
+
/** ISO 8601 timestamp of last data update */
|
|
46
|
+
lastUpdated: string;
|
|
47
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { AccountId } from '../types/AccountId';
|
|
2
|
+
import { WalletProviderId } from '../types/WalletProviderId';
|
|
3
|
+
import { Chain } from '../enums/Chain';
|
|
4
|
+
import { Price } from './Price';
|
|
5
|
+
/**
|
|
6
|
+
* Summary view of an account for cross-account analysis.
|
|
7
|
+
*
|
|
8
|
+
* Lightweight representation containing key metrics for each account,
|
|
9
|
+
* suitable for dashboard summary views and account comparison.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* import { AccountSummary } from '@cygnus-wealth/data-models';
|
|
14
|
+
*
|
|
15
|
+
* const summary: AccountSummary = {
|
|
16
|
+
* accountId: 'metamask:a1b2c3d4:0xAbCdEf1234567890',
|
|
17
|
+
* accountLabel: 'Main DeFi',
|
|
18
|
+
* connectionLabel: 'My MetaMask',
|
|
19
|
+
* providerId: 'metamask',
|
|
20
|
+
* totalValue: { value: 25000, currency: 'USD', timestamp: new Date() },
|
|
21
|
+
* assetCount: 12,
|
|
22
|
+
* chains: [Chain.ETHEREUM, Chain.POLYGON],
|
|
23
|
+
* lastUpdated: '2026-02-19T08:00:00Z'
|
|
24
|
+
* };
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* @since 1.3.0
|
|
28
|
+
* @stability extended
|
|
29
|
+
*
|
|
30
|
+
* @see {@link AccountPortfolio} for full account portfolio details
|
|
31
|
+
*/
|
|
32
|
+
export interface AccountSummary {
|
|
33
|
+
/** Account identifier */
|
|
34
|
+
accountId: AccountId;
|
|
35
|
+
/** User-assigned account label */
|
|
36
|
+
accountLabel: string;
|
|
37
|
+
/** Label of the parent wallet connection */
|
|
38
|
+
connectionLabel: string;
|
|
39
|
+
/** Wallet provider identifier, or 'watch' for watch addresses */
|
|
40
|
+
providerId: WalletProviderId | 'watch';
|
|
41
|
+
/** Total value of the account's holdings */
|
|
42
|
+
totalValue: Price;
|
|
43
|
+
/** Number of distinct assets held */
|
|
44
|
+
assetCount: number;
|
|
45
|
+
/** Chains this account has activity on */
|
|
46
|
+
chains: Chain[];
|
|
47
|
+
/** ISO 8601 timestamp of last data update */
|
|
48
|
+
lastUpdated: string;
|
|
49
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { AccountId } from '../types/AccountId';
|
|
2
|
+
import { Chain } from '../enums/Chain';
|
|
3
|
+
import { ChainFamily } from '../enums/ChainFamily';
|
|
4
|
+
/**
|
|
5
|
+
* Request to query data for a specific account address.
|
|
6
|
+
*
|
|
7
|
+
* Used by integration contracts to request data with account attribution.
|
|
8
|
+
* Carries the AccountId so results can be attributed back to the originating
|
|
9
|
+
* account, and includes chain scope for per-account chain filtering.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* import { AddressRequest, Chain } from '@cygnus-wealth/data-models';
|
|
14
|
+
*
|
|
15
|
+
* const request: AddressRequest = {
|
|
16
|
+
* accountId: 'metamask:a1b2c3d4:0xAbCdEf1234567890',
|
|
17
|
+
* address: '0xAbCdEf1234567890',
|
|
18
|
+
* chainScope: [Chain.ETHEREUM, Chain.POLYGON, Chain.ARBITRUM]
|
|
19
|
+
* };
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* @since 1.3.0
|
|
23
|
+
* @stability extended
|
|
24
|
+
*
|
|
25
|
+
* @see {@link AccountBalanceList} for the response format
|
|
26
|
+
*/
|
|
27
|
+
export interface AddressRequest {
|
|
28
|
+
/** Account identifier for result attribution */
|
|
29
|
+
accountId: AccountId;
|
|
30
|
+
/** Checksummed address to query */
|
|
31
|
+
address: string;
|
|
32
|
+
/** Chain family for routing to the correct integration */
|
|
33
|
+
chainFamily: ChainFamily;
|
|
34
|
+
/** Chains to query for this address */
|
|
35
|
+
chainScope: Chain[];
|
|
36
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { AssetType } from '../enums/AssetType';
|
|
2
2
|
import { Chain } from '../enums/Chain';
|
|
3
|
+
import { AccountId } from '../types/AccountId';
|
|
4
|
+
import { WalletConnectionId } from '../types/WalletConnectionId';
|
|
3
5
|
import { Metadata } from './Metadata';
|
|
4
6
|
/**
|
|
5
7
|
* Universal asset representation normalizing data from multiple sources.
|
|
@@ -72,6 +74,10 @@ export interface Asset {
|
|
|
72
74
|
cusip?: string;
|
|
73
75
|
/** ISIN identifier for international securities */
|
|
74
76
|
isin?: string;
|
|
77
|
+
/** Account holding this asset (for multi-wallet multi-account attribution) */
|
|
78
|
+
accountId?: AccountId;
|
|
79
|
+
/** Wallet connection this asset belongs to, or 'watch' for watch addresses */
|
|
80
|
+
walletConnectionId?: WalletConnectionId | 'watch';
|
|
75
81
|
/** Source-specific additional data and custom fields */
|
|
76
82
|
metadata?: Metadata;
|
|
77
83
|
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Balance } from './Balance';
|
|
2
|
+
import { Price } from './Price';
|
|
3
|
+
import { AccountAssetEntry } from './AccountAssetEntry';
|
|
4
|
+
/**
|
|
5
|
+
* Distribution of a specific asset across multiple accounts.
|
|
6
|
+
*
|
|
7
|
+
* Shows how holdings of a single asset (by symbol) are distributed
|
|
8
|
+
* across the user's accounts, useful for concentration analysis.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* import { AssetDistribution } from '@cygnus-wealth/data-models';
|
|
13
|
+
*
|
|
14
|
+
* const ethDistribution: AssetDistribution = {
|
|
15
|
+
* symbol: 'ETH',
|
|
16
|
+
* totalQuantity: { assetId: 'eth', asset: ethAsset, amount: '10.5' },
|
|
17
|
+
* totalValue: { value: 21000, currency: 'USD', timestamp: new Date() },
|
|
18
|
+
* distribution: [
|
|
19
|
+
* {
|
|
20
|
+
* accountId: 'metamask:a1b2:0xAbc',
|
|
21
|
+
* accountLabel: 'Main',
|
|
22
|
+
* connectionLabel: 'MetaMask',
|
|
23
|
+
* quantity: { assetId: 'eth', asset: ethAsset, amount: '7.0' },
|
|
24
|
+
* value: { value: 14000, currency: 'USD', timestamp: new Date() },
|
|
25
|
+
* percentage: 66.67
|
|
26
|
+
* }
|
|
27
|
+
* ]
|
|
28
|
+
* };
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @since 1.3.0
|
|
32
|
+
* @stability extended
|
|
33
|
+
*
|
|
34
|
+
* @see {@link AccountAssetEntry} for per-account breakdown
|
|
35
|
+
*/
|
|
36
|
+
export interface AssetDistribution {
|
|
37
|
+
/** Asset trading symbol */
|
|
38
|
+
symbol: string;
|
|
39
|
+
/** Total quantity across all accounts */
|
|
40
|
+
totalQuantity: Balance;
|
|
41
|
+
/** Total value across all accounts */
|
|
42
|
+
totalValue: Price;
|
|
43
|
+
/** Per-account breakdown of this asset's distribution */
|
|
44
|
+
distribution: AccountAssetEntry[];
|
|
45
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -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 {};
|