Skip to main content
What you’ll build:
  • Fetch all DeFi positions (staked, deposited, LP, locked, rewards)
  • Filter by position type and chain
  • Group positions by protocol and calculate per-protocol totals
  • Build a complete runnable DeFi dashboard
Time: ~10 minutes

Prerequisites

Steps

1

Fetch DeFi positions

Call the positions endpoint with filter[positions]=only_complex to get only DeFi protocol positions, excluding regular wallet tokens.
Key parameters: filter[positions]=only_complex (DeFi positions only), sort=value (highest value first), currency=usd (also supports eur, gbp, etc.)
2

Filter by position type (optional)

Use filter[position_types] to narrow results to specific DeFi categories.
Available position types:
3

Filter by chain (optional)

To get DeFi positions on specific chains only, add filter[chain_ids].
4

Full working example

Save as defi-dashboard.mjs and run with node defi-dashboard.mjs:

Response fields reference

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