This subgraph indexes the deposit & withdrawal activity of all ERC4626-compliant vaults.
It can be used to query an account's earnings, vault TVL statistics, and more.
- ERC-4626 Subgraph
- Deployments
- Querying information about an account
- For an account, show all outstanding vault positions
- For a given account, show all deposit, withdraw, and transfer transactions the account has made with a vault.
- Show how much an account has earned by withdrawing from a specific vault.
- For a given transaction, display all of the ERC4626 deposit, withdraw, and transfer events.
- Querying information about a vault
- Developing
- Notes for ERC4626 Vault Developers
- Errata/Compatibility issues
- Disclaimers
Ethereum Mainnet - Deployment - Explorer
{
accountPositions(
where: {account: "0xaccountaddress", shares_gt: 0}
) {
vault {
id
name
underlying {
name
}
}
shares
}
}
For a given account, show all deposit, withdraw, and transfer transactions the account has made with a vault.
{
transferEvents(
where: {receiver: "0xaccountaddress", vault: "0xvaultaddress"}
orderBy: block
orderDirection: desc
) {
block
sharesTransferred
}
depositEvents(
where: {account: "0xaccountaddress", vault: "0xvaultaddress"}
orderBy: block
orderDirection: desc
) {
id
block
assetsDeposited
sharesMinted
}
withdrawEvents(
where: {account: "0xaccountaddress", vault: "0xvaultaddress"}
orderBy: block
orderDirection: desc
) {
id
block
assetsWithdrawn
sharesRedeemed
}
}
{
accountPositions(
where: {account: "0xaccountaddress", vault: "0xvaultaddress"}
) {
earnings(orderBy: block, orderDirection: asc) {
block
sharesRedeemed
assetsWithdrawn
profit
}
}
}
{
transaction(
id: "0xtransactionid"
) {
block
timestamp
depositEvents {
logIndex
account {
id
}
vault {
name
}
assetsDeposited
sharesMinted
}
withdrawEvents {
logIndex
account {
id
}
vault {
name
}
assetsWithdrawn
sharesRedeemed
}
transferEvents {
logIndex
sender {
id
}
receiver {
id
}
vault {
name
}
sharesTransferred
}
}
}
{
erc4626Vaults(
where:{underlying: "0xunderlyingTokenAddress"},
orderBy: assetTvl
orderDirection: desc
) {
id
name
firstBlock
assetTvl
}
}
make install
Make changes to .env
file as needed
Check out the makefile for build/deployment actions.
The subgraph detects new ERC4626 vaults by listening for ERC4626-specified deposit & withdraw events. Once detected, a series of contract calls are issued to verify whether the contract is ERC4626 compliant. The precise series of calls can be found in function doesContractImplement4626(address: Address)
.
If a protocol uses a proxy for its non-ERC4626 vaults, and later migrates to ERC4626, the subgraph will fail to account for user's deposits/withdraw activity before the migration. Users whose deposits occurred after the migration will not have any issues.
Protocols Impacted:
- mStable
Some fields defined by the ERC4626 spec are expected, but not required, to be immutable. The vault's name
, asset
, and decimals
fall under this category. If a vault changes these fields as part of their normal operation, delayed initialziation, or proxy implementation, the subgraph will fail to index those vaults properly.
Protocols Impacted:
- Sommelier