Get a user position
There are two independent ways to read a user position. Pick one:
On-chain — call the vault contract directly over RPC. Always up to date, no dependency on Lagoon infrastructure.
Lagoon API (GraphQL) — one query returns the user's positions in every vault on a chain, with USD values.
Lagoon vaults are based on ERC7540 ; the standard for asynchronous deposits and redemptions in a vault.
7540 is an extension of 4626 that add functions around requests and tweak others like max functions and deposit/mint/withdraw/redeem functions.
A user total share balance is the addition of the return of three functions:
vault.balanceOf(userAddress);→ ERC20 functionvault.maxMint(userAddress);→ shares ready to be claimed (to not be confused with the ERC4626 maxMint function)vault.pendingRedeemRequest(0, userAddress);→ user shares waiting to be redeemed. Why 0 ?
Send this query to https://api.lagoon.finance/query. It returns every vault position the user holds on the given chain:
query GetUserPositions($address: Address!, $chainId: Int!) {
userByAddress(address: $address, chainId: $chainId) {
vaultPositions {
vault { address name symbol }
state {
shares
assets
usd
balance
claimableDeposit { shares }
pendingRedeem { shares }
}
}
}
}curl -sS -X POST https://api.lagoon.finance/query \
-H "Content-Type: application/json" \
-d '{
"query": "query GetUserPositions($address: Address!, $chainId: Int!) { userByAddress(address: $address, chainId: $chainId) { vaultPositions { vault { address name symbol } state { shares assets usd balance claimableDeposit { shares } pendingRedeem { shares } } } } }",
"variables": { "address": "0xUSER", "chainId": 1 }
}'For a single vault, pick the entry whose vault.address matches.
balance
Shares held in the wallet
balanceOf(user)
claimableDeposit.shares
Shares ready to be claimed
maxMint(user)
pendingRedeem.shares
Shares waiting to be redeemed
pendingRedeemRequest(0, user)
shares / assets / usd
Whole position, including pending and claimable requests
—
More fields (pending deposits, claimable redeems, cancelability) are listed in Common queries.
Balances without a Transfer to the user
A position rebuilt from Transfer events alone under-reports. These states never emit an ERC-20 Transfer to the user's address:
Pending deposit
pendingSilo
pendingDepositRequest(0, user)
Pending redemption
pendingSilo
pendingRedeemRequest(0, user)
Settled, shares unclaimed
Vault
maxMint(user) for the shares; claimableDepositRequest(0, user) gives the deposited assets
Settled, assets unclaimed
Vault
maxWithdraw(user) for the assets, net of the exit fee; claimableRedeemRequest(0, user) gives the redeemed shares
Pending deposit paid in native value
pendingSilo, as the wrapped token
pendingDepositRequest(0, user). No Transfer from the user records it either: only the wrapped token's Deposit event to the pendingSilo and the vault's DepositRequest event
Last updated