Skip to main content
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
Time
~10 minutes
You need

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.
Key parameters: filter[positions]=only_complex (DeFi positions only), sort=value (highest value first), currency=usd (also supports eur, gbp and others).
2

Filter by position type (optional)

Pass filter[position_types] to return only certain DeFi categories.
Available position types:
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 in receipt: 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_info of a returned position.
  • Not displayable: flags.displayable is false.
Positions that share a 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