11// Shared domain types used across all modules.
22
3- import type { SupportedChain } from "./chains.js" ;
4- import type {
5- LendingPositionUnion ,
6- LPPosition ,
7- StakingPosition ,
8- TokenAmount ,
9- } from "./positions.js" ;
10- import type {
11- PortfolioCoverage ,
12- SolanaPortfolioSlice ,
13- TronPortfolioSlice ,
14- } from "./portfolio.js" ;
15-
163export * from "./chains.js" ;
174
185export * from "./positions.js" ;
@@ -21,193 +8,6 @@ export * from "./portfolio.js";
218
229export * from "./security.js" ;
2310
24- /**
25- * Bitcoin slice of a portfolio summary. Parallel to `TronPortfolioSlice`
26- * + `SolanaPortfolioSlice`. Bitcoin has no fungible token model in
27- * Phase 1 (BRC-20 / Runes / Ordinals deferred), so the slice carries
28- * only per-address native balances + the rolled-up USD totals.
29- *
30- * Multi-address: every BTC address the caller passed via
31- * `bitcoinAddress` (single) or `bitcoinAddresses` (array) is surfaced
32- * here. This mirrors `get_btc_balances` shape so callers who already
33- * use that tool see the same per-address projection inside the
34- * portfolio response.
35- */
36- export interface BitcoinPortfolioSlice {
37- /** All addresses queried for this slice — at least one. */
38- addresses : string [ ] ;
39- /**
40- * Per-address breakdown. Each entry carries confirmed + mempool +
41- * total sats, the BTC-decimal projection, the address type, and the
42- * USD valuation. Identical shape to `BitcoinBalance` from the
43- * `btc/balances.ts` reader.
44- */
45- balances : Array < {
46- address : string ;
47- addressType : "p2pkh" | "p2sh" | "p2wpkh" | "p2wsh" | "p2tr" ;
48- confirmedSats : string ;
49- mempoolSats : string ;
50- totalSats : string ;
51- confirmedBtc : string ;
52- totalBtc : string ;
53- symbol : "BTC" ;
54- decimals : 8 ;
55- txCount : number ;
56- valueUsd ?: number ;
57- /** True when DefiLlama returned no price; balance is excluded from totals. */
58- priceMissing ?: boolean ;
59- } > ;
60- /** Rolled-up USD value across all addresses (uses confirmed balance). */
61- walletBalancesUsd : number ;
62- }
63-
64- /**
65- * Litecoin slice of a portfolio summary. Mirror of `BitcoinPortfolioSlice`.
66- * Same UTXO model, same balance projection, different symbol/HRP.
67- */
68- export interface LitecoinPortfolioSlice {
69- addresses : string [ ] ;
70- balances : Array < {
71- address : string ;
72- addressType : "p2pkh" | "p2sh" | "p2wpkh" | "p2wsh" | "p2tr" ;
73- confirmedSats : string ;
74- mempoolSats : string ;
75- totalSats : string ;
76- confirmedLtc : string ;
77- totalLtc : string ;
78- symbol : "LTC" ;
79- decimals : 8 ;
80- txCount : number ;
81- valueUsd ?: number ;
82- priceMissing ?: boolean ;
83- } > ;
84- walletBalancesUsd : number ;
85- }
86-
87- /** Per-wallet slice of a multi-wallet portfolio, or a stand-alone single-wallet summary. */
88- export interface PortfolioSummary {
89- wallet : `0x${string } `;
90- chains : SupportedChain [ ] ;
91- walletBalancesUsd : number ;
92- lendingNetUsd : number ;
93- lpUsd : number ;
94- stakingUsd : number ;
95- totalUsd : number ;
96- perChain : Record < SupportedChain , number > ;
97- /**
98- * TRON totals folded into the same number as EVM. Present when the caller
99- * passed a `tronAddress` (or TRON is in the default chain set and an
100- * address was resolvable).
101- */
102- tronUsd ?: number ;
103- /**
104- * TRON staking USD (frozen + pending-unfreeze + claimable). Already included
105- * in `tronUsd` — this field surfaces it separately for UI. Present only when
106- * staking was fetched successfully.
107- */
108- tronStakingUsd ?: number ;
109- /**
110- * Solana totals folded into the same aggregate as EVM/TRON. Present when
111- * the caller passed a `solanaAddress`. Phase 1 covers balances; Phase 3
112- * adds MarginFi lending (surfaced separately via `solanaLendingUsd`).
113- */
114- solanaUsd ?: number ;
115- /**
116- * Solana lending net USD — MarginFi (Phase 3). Parallels `tronStakingUsd`
117- * as a carve-out that's separately surfaced in UIs but also folded into
118- * `totalUsd`. Present only when at least one MarginfiAccount was found
119- * for the wallet.
120- */
121- solanaLendingUsd ?: number ;
122- /**
123- * Solana staking net USD — Marinade mSOL + Jito jitoSOL + native stake
124- * accounts (roadmap #2). Computed as `totalSolEquivalent * SOL price`
125- * using the same SOL price that valued the native-SOL balance line.
126- * Folded into `totalUsd`; carve-out here for UIs. Present only when the
127- * wallet holds at least some Solana staking.
128- */
129- solanaStakingUsd ?: number ;
130- /**
131- * Bitcoin totals (sum across every address passed via `bitcoinAddress` /
132- * `bitcoinAddresses`). Present only when the caller supplied at least
133- * one BTC address. Folded into `totalUsd`.
134- */
135- bitcoinUsd ?: number ;
136- /**
137- * Litecoin totals (sum across every address passed via `litecoinAddress` /
138- * `litecoinAddresses`). Present only when the caller supplied at least
139- * one LTC address. Folded into `totalUsd`.
140- */
141- litecoinUsd ?: number ;
142- breakdown : {
143- native : TokenAmount [ ] ;
144- erc20 : TokenAmount [ ] ;
145- lending : LendingPositionUnion [ ] ;
146- lp : LPPosition [ ] ;
147- staking : StakingPosition [ ] ;
148- /** TRON slice — absent when no TRON address was queried. */
149- tron ?: TronPortfolioSlice ;
150- /** Solana slice — absent when no Solana address was queried. */
151- solana ?: SolanaPortfolioSlice ;
152- /** Bitcoin slice — absent when no BTC address(es) were queried. */
153- bitcoin ?: BitcoinPortfolioSlice ;
154- /** Litecoin slice — absent when no LTC address(es) were queried. */
155- litecoin ?: LitecoinPortfolioSlice ;
156- } ;
157- coverage : PortfolioCoverage ;
158- }
159-
160- /** Multi-wallet portfolio aggregation. */
161- export interface MultiWalletPortfolioSummary {
162- wallets : `0x${string } `[ ] ;
163- chains : SupportedChain [ ] ;
164- totalUsd : number ;
165- walletBalancesUsd : number ;
166- lendingNetUsd : number ;
167- lpUsd : number ;
168- stakingUsd : number ;
169- perChain : Record < SupportedChain , number > ;
170- perWallet : PortfolioSummary [ ] ;
171- /**
172- * Non-EVM holdings surfaced as PARALLEL siblings of the EVM wallets,
173- * NOT folded into any specific `perWallet[i]`. Issue #201 — TRON / BTC /
174- * Solana addresses on a Ledger are independent identities (different
175- * BIP-44 derivation paths), so attributing them to "the first EVM
176- * wallet" produced misleading per-wallet rollups.
177- *
178- * Each chain's slice is surfaced when the corresponding address arg
179- * (`tronAddress`/`tronAddresses`, `solanaAddress`/`solanaAddresses`,
180- * `bitcoinAddress`/`bitcoinAddresses`) was passed to
181- * `getPortfolioSummary`. The USD rollups below sum across whichever
182- * slices were fetched.
183- */
184- nonEvm ?: {
185- /** Per-address TRON slice; one entry per requested tronAddress. */
186- tron ?: TronPortfolioSlice [ ] ;
187- /** Per-address Solana slice; one entry per requested solanaAddress. */
188- solana ?: SolanaPortfolioSlice [ ] ;
189- /** Multi-address Bitcoin slice; aggregates every requested btc address. */
190- bitcoin ?: BitcoinPortfolioSlice ;
191- /** Multi-address Litecoin slice; aggregates every requested ltc address. */
192- litecoin ?: LitecoinPortfolioSlice ;
193- } ;
194- /** Sum of all TRON wallet balances (TRX + TRC-20) across the queried addresses. */
195- tronUsd ?: number ;
196- /** Sum of TRON staking (frozen TRX + claimable rewards). */
197- tronStakingUsd ?: number ;
198- /** Sum of all Solana wallet balances (SOL + SPL) across queried addresses. */
199- solanaUsd ?: number ;
200- /** Sum of MarginFi + Kamino netValueUsd across queried Solana addresses. */
201- solanaLendingUsd ?: number ;
202- /** Sum of Marinade + Jito + native-stake totals across queried Solana addresses. */
203- solanaStakingUsd ?: number ;
204- /** Sum of BTC × USD-price across queried Bitcoin addresses. */
205- bitcoinUsd ?: number ;
206- /** Sum of LTC × USD-price across queried Litecoin addresses. */
207- litecoinUsd ?: number ;
208- coverage : PortfolioCoverage ;
209- }
210-
21111export * from "./tx.js" ;
21212
21313export * from "./devices.js" ;
0 commit comments