Skip to content

Commit

Permalink
Yearn v2: Schema update 1.3.0 (messari#332)
Browse files Browse the repository at this point in the history
* Yearn v2: Schema update 1.3.0

* Fix LUSD Coin price
  • Loading branch information
harsh9200 authored and 0xbe1 committed Jun 27, 2022
1 parent 9787feb commit b361de1
Show file tree
Hide file tree
Showing 12 changed files with 270 additions and 101 deletions.
8 changes: 4 additions & 4 deletions subgraphs/yearn-v2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
"build:mainnet": "yarn prepare:mainnet && graph build",
"prepare:mainnet": "mustache config/mainnet.json subgraph.template.yaml > subgraph.yaml",
"thegraph:deploy:mainnet": "graph deploy --node https://api.thegraph.com/deploy/ harsh9200/yearn-v2",
"deploy:mainnet": "yarn prepare:mainnet && yarn build:mainnet && yarn thegraph:deploy:mainnet",
"deploy:mainnet": "yarn prepare:mainnet && yarn codegen && yarn thegraph:deploy:mainnet",

"build:fantom": "yarn prepare:fantom && graph build",
"prepare:fantom": "mustache config/fantom.json subgraph.template.yaml > subgraph.yaml",
"thegraph:deploy:fantom": "graph deploy --node https://api.thegraph.com/deploy/ harsh9200/yearn-v2-fantom",
"deploy:fantom": "yarn prepare:fantom && yarn build:fantom && yarn thegraph:deploy:fantom",
"deploy:fantom": "yarn prepare:fantom && yarn codegen && yarn thegraph:deploy:fantom",

"build:arbitrum": "yarn prepare:arbitrum && graph build",
"prepare:arbitrum": "mustache config/arbitrum.json subgraph.template.yaml > subgraph.yaml",
"thegraph:deploy:arbitrum": "graph deploy --node https://api.thegraph.com/deploy/ harsh9200/yearn-v2-arbitrum",
"deploy:arbitrum": "yarn prepare:arbitrum && yarn build:arbitrum && yarn thegraph:deploy:arbitrum",
"deploy:arbitrum": "yarn prepare:arbitrum && yarn codegen && yarn thegraph:deploy:arbitrum",

"build": "graph build",
"deploy": "graph deploy --node https://api.thegraph.com/deploy/ harsh9200/yearn-v2",
Expand All @@ -26,7 +26,7 @@
},
"dependencies": {
"@graphprotocol/graph-cli": "0.27.0",
"@graphprotocol/graph-ts": "0.24.1",
"@graphprotocol/graph-ts": "0.25.0",
"mustache": "4.1.0"
}
}
148 changes: 111 additions & 37 deletions subgraphs/yearn-v2/schema.graphql
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
# Subgraph Schema: Yield Aggregator
# Version: 1.2.1
# Version: 1.3.0
# See https://github.com/messari/subgraphs/blob/master/docs/Schema.md for details

enum Network {
ARBITRUM_ONE
ARWEAVE_MAINNET
AURORA
AVALANCHE
BOBA
BSC # aka BNB Chain
CELO
COSMOS
CRONOS
MAINNET # Ethereum Mainnet
FANTOM
FUSE
HARMONY
JUNO
MOONBEAM
MOONRIVER
NEAR_MAINNET
OPTIMISM
OSMOSIS
MATIC # aka Polygon
XDAI # aka Gnosis Chain
}
Expand Down Expand Up @@ -70,24 +77,24 @@ type RewardToken @entity {
enum VaultFeeType {
" One-time fee charged by the protocol during deposit, in percentages of the deposit token "
DEPOSIT_FEE

" One-time fee charged by the protocol during withdrawal, in percentages of the withdrawal token "
WITHDRAWAL_FEE

" Fees charged by the protocol during harvest, in percentages of the interest accrued "
PERFORMANCE_FEE

" Fees charged by the protocol on a periodic basis, in percentages of the total principal "
MANAGEMENT_FEE
}

type VaultFee @entity {
" { Vault fee type }-{ Vault address } "
id: ID!

" Fee as a percentage of the trade (swap) amount. Does not always apply "
feePercentage: BigDecimal!
feePercentage: BigDecimal

" Type of fee this vault uses "
feeType: VaultFeeType!
}
Expand Down Expand Up @@ -122,6 +129,7 @@ interface Protocol {
type: ProtocolType!

##### Quantitative Data #####

" Current TVL (Total Value Locked) of the entire protocol "
totalValueLockedUSD: BigDecimal!

Expand All @@ -137,15 +145,21 @@ interface Protocol {
" All revenue generated by the protocol. e.g. 0.30% of swap fee in Sushiswap, all yield generated by Yearn. "
cumulativeTotalRevenueUSD: BigDecimal!

" # of cumulative unique users "
" Number of cumulative unique users "
cumulativeUniqueUsers: Int!

" Total number of pools "
totalPoolCount: Int!

##### Snapshots #####

" Daily usage metrics for this protocol "
dailyUsageMetrics: [UsageMetricsDailySnapshot!]! @derivedFrom(field: "protocol")
dailyUsageMetrics: [UsageMetricsDailySnapshot!]!
@derivedFrom(field: "protocol")

" Hourly usage metrics for this protocol "
hourlyUsageMetrics: [UsageMetricsHourlySnapshot!]! @derivedFrom(field: "protocol")
hourlyUsageMetrics: [UsageMetricsHourlySnapshot!]!
@derivedFrom(field: "protocol")

" Daily financial metrics for this protocol "
financialMetrics: [FinancialsDailySnapshot!]! @derivedFrom(field: "protocol")
Expand Down Expand Up @@ -192,11 +206,15 @@ type YieldAggregator implements Protocol @entity {

" All revenue generated by the protocol. e.g. 0.30% of swap fee in Sushiswap, all yield generated by Yearn. "
cumulativeTotalRevenueUSD: BigDecimal!
" # of cumulative unique users "

" Number of cumulative unique users "
cumulativeUniqueUsers: Int!

" Total number of pools "
totalPoolCount: Int!

##### Snapshots #####

" Daily usage metrics for this protocol "
dailyUsageMetrics: [UsageMetricsDailySnapshot!]!
@derivedFrom(field: "protocol")
Expand Down Expand Up @@ -227,10 +245,10 @@ type UsageMetricsDailySnapshot @entity {
" Protocol this snapshot is associated with "
protocol: YieldAggregator!

" # of unique daily active users "
" Number of unique daily active users "
dailyActiveUsers: Int!

" # of cumulative unique users "
" Number of cumulative unique users "
cumulativeUniqueUsers: Int!

" Total number of transactions occurred in a day. Transactions include all entities that implement the Event interface. "
Expand All @@ -242,6 +260,9 @@ type UsageMetricsDailySnapshot @entity {
" Total number of withdrawals in a day "
dailyWithdrawCount: Int!

" Total number of pools "
totalPoolCount: Int!

" Block number of this snapshot "
blockNumber: BigInt!

Expand All @@ -256,10 +277,10 @@ type UsageMetricsHourlySnapshot @entity {
" Protocol this snapshot is associated with "
protocol: YieldAggregator!

" # of unique hourly active users "
" Number of unique hourly active users "
hourlyActiveUsers: Int!

" # of cumulative unique users "
" Number of cumulative unique users "
cumulativeUniqueUsers: Int!

" Total number of transactions occurred in an hour. Transactions include all entities that implement the Event interface. "
Expand Down Expand Up @@ -305,11 +326,13 @@ type FinancialsDailySnapshot @entity {

" All revenue generated by the protocol. e.g. 0.30% of swap fee in Sushiswap, all yield generated by Yearn. "
dailyTotalRevenueUSD: BigDecimal!

" All revenue generated by the protocol. e.g. 0.30% of swap fee in Sushiswap, all yield generated by Yearn. "
cumulativeTotalRevenueUSD: BigDecimal!

" Block number of this snapshot "
blockNumber: BigInt!

" Timestamp of this snapshot "
timestamp: BigInt!
}
Expand All @@ -321,41 +344,51 @@ type FinancialsDailySnapshot @entity {
type Vault @entity {
" Smart contract address of the vault "
id: ID!

" The protocol this vault belongs to "
protocol: YieldAggregator!

" Name of liquidity pool (e.g. Curve.fi DAI/USDC/USDT) "
name: String!
name: String

" Symbol of liquidity pool (e.g. 3CRV) "
symbol: String!
symbol: String

" Token that need to be deposited to take a position in protocol "
inputToken: Token!

" Token that is minted to track ownership of position in protocol "
outputToken: Token!
outputToken: Token

" Aditional tokens that are given as reward for position in a protocol, usually in liquidity mining programs. e.g. SUSHI in the Onsen program, MATIC for Aave Polygon "
rewardTokens: [RewardToken!]

" Some vaults have a deposit cap. This is in input token amount "
depositLimit: BigInt!

" Type of fees incurred to the user. Should include all fees that apply to the vault "
fees: [VaultFee!]!

" Creation timestamp "
createdTimestamp: BigInt!

" Creation block number "
createdBlockNumber: BigInt!

##### Quantitative Data #####

" Current TVL (Total Value Locked) of this pool in USD "
totalValueLockedUSD: BigDecimal!

" All revenue generated by the vault, accrued to the supply side. "
cumulativeSupplySideRevenueUSD: BigDecimal!

" All revenue generated by the vault, accrued to the protocol. "
cumulativeProtocolSideRevenueUSD: BigDecimal!

" All revenue generated by the vault. "
cumulativeTotalRevenueUSD: BigDecimal!

" Amount of input token in the pool "
inputTokenBalance: BigInt!

Expand All @@ -369,30 +402,33 @@ type Vault @entity {
totalAssets: BigInt!

" Price per share of output token in USD "
outputTokenPriceUSD: BigDecimal!
outputTokenPriceUSD: BigDecimal

" Amount of input token per full share of output token. Usually corresponds to the value of `pricePerShare` or `pricePerFullShare` in the vault contract. "
pricePerShare: BigDecimal!
pricePerShare: BigDecimal

" Total supply of output tokens that are staked (usually in the MasterChef contract). Used to calculate reward APY. "
stakedOutputTokenAmount: BigInt

" Per-block reward token emission as of the current block normalized to a day, in token's native amount. This should be ideally calculated as the theoretical rate instead of the realized amount. "
rewardTokenEmissionsAmount: [BigInt!]

" Per-block reward token emission as of the current block normalized to a day, in USD value. This should be ideally calculated as the theoretical rate instead of the realized amount. "
rewardTokenEmissionsUSD: [BigDecimal!]

##### Snapshots #####

" Vault daily snapshots "
dailySnapshots: [VaultDailySnapshot!]! @derivedFrom(field: "vault")

" Vault hourly snapshots "
hourlySnapshots: [VaultHourlySnapshot!]! @derivedFrom(field: "vault")

##### Events #####

" All deposits made to this vault "
deposits: [Deposit!]! @derivedFrom(field: "vault")

" All withdrawals made from this vault "
withdraws: [Withdraw!]! @derivedFrom(field: "vault")
}
Expand All @@ -414,20 +450,38 @@ type VaultDailySnapshot @entity {
" Current TVL (Total Value Locked) of this pool in USD "
totalValueLockedUSD: BigDecimal!

" All revenue generated by the vault, accrued to the supply side. "
cumulativeSupplySideRevenueUSD: BigDecimal!

" Daily revenue generated by the vault, accrued to the supply side. "
dailySupplySideRevenueUSD: BigDecimal!

" All revenue generated by the vault, accrued to the protocol. "
cumulativeProtocolSideRevenueUSD: BigDecimal!

" Daily revenue generated by the vault, accrued to the protocol. "
dailyProtocolSideRevenueUSD: BigDecimal!

" All revenue generated by the vault. "
cumulativeTotalRevenueUSD: BigDecimal!

" Daily revenue generated by the vault. "
dailyTotalRevenueUSD: BigDecimal!

" Amount of input token in the pool "
inputTokenBalance: BigInt!

" Total supply of output token "
outputTokenSupply: BigInt!

" Price per share of output token in USD "
outputTokenPriceUSD: BigDecimal!
outputTokenPriceUSD: BigDecimal

" Amount of input token per full share of output token. Usually corresponds to the value of `pricePerShare` or `pricePerFullShare` in the vault contract. "
pricePerShare: BigDecimal!
pricePerShare: BigDecimal

" Total supply of output tokens that are staked (usually in the MasterChef contract). Used to calculate reward APY. "
stakedOutputTokenAmount: BigInt!
stakedOutputTokenAmount: BigInt

" Per-block reward token emission as of the current block normalized to a day, in token's native amount. This should be ideally calculated as the theoretical rate instead of the realized amount. "
rewardTokenEmissionsAmount: [BigInt!]
Expand Down Expand Up @@ -455,28 +509,48 @@ type VaultHourlySnapshot @entity {
" Current TVL (Total Value Locked) of this pool in USD "
totalValueLockedUSD: BigDecimal!

" All revenue generated by the vault, accrued to the supply side. "
cumulativeSupplySideRevenueUSD: BigDecimal!

" Hourly revenue generated by the vault, accrued to the supply side. "
hourlySupplySideRevenueUSD: BigDecimal!

" All revenue generated by the vault, accrued to the protocol. "
cumulativeProtocolSideRevenueUSD: BigDecimal!

" Hourly revenue generated by the vault, accrued to the protocol. "
hourlyProtocolSideRevenueUSD: BigDecimal!

" All revenue generated by the vault. "
cumulativeTotalRevenueUSD: BigDecimal!

" Hourly revenue generated by the vault. "
hourlyTotalRevenueUSD: BigDecimal!

" Amount of input token in the pool "
inputTokenBalance: BigInt!

" Total supply of output token "
outputTokenSupply: BigInt!

" Price per share of output token in USD "
outputTokenPriceUSD: BigDecimal!
outputTokenPriceUSD: BigDecimal

" Amount of input token per full share of output token. Usually corresponds to the value of `pricePerShare` or `pricePerFullShare` in the vault contract. "
pricePerShare: BigDecimal!
pricePerShare: BigDecimal

" Total supply of output tokens that are staked (usually in the MasterChef contract). Used to calculate reward APY. "
stakedOutputTokenAmount: BigInt

" Per-block reward token emission as of the current block normalized to a day (not hour), in token's native amount. This should be ideally calculated as the theoretical rate instead of the realized amount. "
rewardTokenEmissionsAmount: [BigInt!]

" Per-block reward token emission as of the current block normalized to a day (not hour), in USD value. This should be ideally calculated as the theoretical rate instead of the realized amount. "
rewardTokenEmissionsUSD: [BigDecimal!]

" Block number of this snapshot "
blockNumber: BigInt!

" Timestamp of this snapshot "
timestamp: BigInt!
}
Expand Down
Loading

0 comments on commit b361de1

Please sign in to comment.