Overview

The goal of this subgraph is to index historical data for the exact fees earned by each staked user in each vault.

The basic calculation for fees earned is poolShare * allocPoint * fee where poolShare is the user’s % ownership of the staked pool (stakedTokens / totalSupplyOfStakedTokens) and allocPoint is the % fee split given to the fee receiver i.e. Inventory (20%) or Liquidity (80%). The fee is generated whenever the vault has a Mint, Redeem or Swap transaction. The fee is then split and transferred to the Inventory and Liquidity receivers.

The Inventory and Liquidity receivers can be set in the subgraph’s config. However it would be desirable to find a way to future proof against future receivers being added.

Requirements

Overview

Index the exact amount of fee received for every staked individual when a fee receipt is created via mint/redeem/swap.

# VaultDayData
# tracks the fees generated for this vault and assigns to either
# inventory or liquidity with one day resolution

{
  id: ID
  # timestamp rounded to current day by dividing by 86400
  date: Int
  vault: Vault
}

# VaultHourData

# UserShareData
# tracks all user pool share of inventory and liquidity with
# one day resolution

Config

inventoryStaking: address
liquidityStaking: address

Entities

# FeeReceipt

{
  id: ID
	date: BigInt
  vault: Vault
  amount: BigInt
  feeDistribution: [Earnings] @derivedFrom(field: "feeReceipt")
}

# Vault

{
  id: ID
  vaultId: BigInt
  ticker: String # i.e. PUNK
}

# User

{
  id: ID
  poolsShare: [PoolShare]
}

# PoolShare
# Every time a user stakes or unstakes all user shares are updated for that pool.

{
  id: ID
  vault: Vault
  user: User
  inventoryShare: BigInt
  liquidityShare: BigInt
}

# Earnings

{
  id: ID
  feeReceipt: FeeReceipt
  user: User
  amount: BigInt
}

# FeeReceiver

{
  id: ID
  allocPoint: BigInt
}

Comments