What you’ll build
- A list of every DeFi position: staked, deposited, LP, locked and rewards
- Filters by position type and chain
- Per-protocol totals, with positions grouped by protocol
- A complete, runnable DeFi dashboard
Steps
1
Fetch DeFi positions
Call the positions endpoint with
filter[positions]=only_complex. It returns DeFi protocol positions only and leaves out regular wallet tokens.2
Filter by position type (optional)
Pass Available position types:
filter[position_types] to return only certain DeFi categories.3
Filter by chain (optional)
Add
filter[chain_ids] to return DeFi positions on specific chains only.4
Full working example
Save as
defi-dashboard.mjs and run with node defi-dashboard.mjs. It groups positions by protocol and subtracts loans from the totals.Response fields
Each DeFi position includes:Deduplicating share tokens
Many DeFi positions come with a share token in the wallet, such as an aToken, a vault share or an LP token. The position names it inreceipt: receipt.fungible_info is the share token and receipt.quantity is the amount held. The position’s own quantity and value are the underlying asset.
With filter[positions]=no_filter, Zerion API often leaves out the share token’s wallet row, but not always. To count each holding once, drop a wallet row when either is true:
- Receipt match: Its chain and contract address match the
receipt.fungible_infoof a returned position. - Not displayable:
flags.displayableisfalse.
group_id, such as the legs of a liquidity pool, can carry the same receipt. Count receipt.quantity once per group_id.
For example, on October 1, 2026, wallet address 0x9026A229b535ecF0162Dfe48fDeb3c75f7b2A7AE returned a Compound V2 deposit with a receipt of 0.2442 cETH, and a separate wallet row for the same 0.2442 cETH. Each is worth about $13. The code below drops the duplicate row.
Next steps
- Use
filter[positions]=no_filterto get DeFi and wallet positions in one call, then deduplicate share tokens. - Combine with the portfolio endpoint to see how total value splits by type.