Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release Isolated Pools and Core Pool Schema refactor #219

Open
wants to merge 96 commits into
base: main
Choose a base branch
from
Open

Conversation

coreyar
Copy link
Collaborator

@coreyar coreyar commented Dec 16, 2024

Overview

  • Base CrossChain Governance
  • Refactored Isolated Pool
  • Refactored Core Pool

Venus Subgraph Isolated Pools and Core Pool V1 Schema Changes

Not all of these changes are reflected in this.
Below is a summary of the changes to be deployed and published in this release.

The focus of refactoring the subgraphs were

  • Unifying the schema for the Isolated Pool and Core Pool subgraphs
  • Clean up debt from the original schema (clearer names, label units, Token entities, declare address instead of inferring it from the id ect.)

Core Pool

Schema Changes

Adds an explicit address property to the Comptroller entity. The closeFactor property is renamed with its scale.

"""
The Comptroller type has protocol level variables stored
"""
type Comptroller @entity {
    "ID is set to comptroller address"
    id: Bytes!
+   "Comptroller Address"
+   address: Bytes!
    "Factor used to determine repayAmount for liquidating"
-   closeFactor: BigInt!
+   closeFactorMantissa: BigInt!
    ...
}

Token Addresses are now a relationship to the Token entity.

+ """
+ ERC20 Token
+ """
+ type Token @entity(immutable: true) {
+     "Address of the asset"
+     id: Bytes!
+     "Address of the asset"
+     address: Bytes!
+     "Name of the asset"
+     name: String!
+     "Symbol of the asset"
+     symbol: String
+     "Decimals of the asset"
+     decimals: Int!
}

Adds an explicit address property to the Market entity. Underlying token is now a relationship to the Token entity. isListed is a flag indicating if the market is listed. A relationship to accounts with positions in the market is added. The reserveFactor property is renamed with its scale. Add xvsSupplySpeed, xvsBorrowSpeed, xvsSupplyStateBlock, xvsSupplyStateIndex, xvsBorrowStateBlock, and xvsBorrowStateIndex properties to the Market entity to track XVS rewards. borrowerCountAdjusted, which was meant to track dust left over from incomplete liquidations, has been removed.

"""
Market stores all high level variables for a vToken market
"""
type Market @entity {
    "VToken address"
    id: Bytes!
+   "Vtoken Address"
+   address: Bytes!
+   "Flag indicating if the market is listed"
+   isListed: Boolean!
    "Underlying token address"
    underlyingAddress: Bytes!
    "Underlying token name"
    underlyingName: String!
    "Underlying token symbol"
    underlyingSymbol: String!
-   "Underlying token decimal length"
-   underlyingDecimals: Int!
+   "Underlying Token"
+   underlyingToken: Token!
    "Accounts who participate in this market"
-   accounts: [AccountVToken!]! @derivedFrom(field:"market")
+   accounts: [MarketPosition!]! @derivedFrom(field:"market")
    "The factor determining interest that goes to reserves"
-   reserveFactor: BigInt!
+   reserveFactorMantissa: BigInt!
+   "The rate at which XVS is distributed to the corresponding supply market (per block)"
+   xvsSupplySpeed: BigInt!
+   "The rate at which XVS is distributed to the corresponding borrow market (per block)"
+   xvsBorrowSpeed: BigInt!
+   "XVS Supply Distribution Block"
+   xvsSupplyStateBlock:  BigInt!
+   "XVS Supply Distribution Index"
+   xvsSupplyStateIndex:  BigInt!
+   "XVS Reward Distribution Block"
+   xvsBorrowStateBlock:  BigInt!
+   "XVS Reward Distribution Index"
+   xvsBorrowStateIndex:  BigInt!
-   "Number of accounts with reasonable borrow positions in this market (excludes accounts with dust (potentially left over from liquidations))"
-   borrowerCountAdjusted: BigInt!
    ...
}

The Account entity has a declared address property so the address doesn't have to be inferred from the id. The tokens relationship is to the renamed MarketPosition entity. Adds an accrualBlockNumber property to the Market entity to track interest accrual.

"""
Account is an BNB address, with a list of all vToken markets the account has
participated in, along with liquidation information.
"""
type Account @entity {
     "Account address"
     id: Bytes!
+    "Account address"
+    address: Bytes!
     "Array of VTokens user is in"
-    tokens: [AccountVToken!]! @derivedFrom(field: "account")
+    tokens: [MarketPosition!]! @derivedFrom(field: "account")
+   "Block the position is updated to"
+    accrualBlockNumber: BigInt!
}
"""
- AccountVToken is a single account within a single vToken market
+ MarketPosition is a single account within a single vToken market
"""
- type AccountVToken @entity {
+ type MarketPosition @entity {
    "Concatenation of VToken address and user address"
    id: Bytes!
    ...
}

Isolated Pools

Schema Changes

The Pool entity has a declared address property so the address doesn't have to be inferred from the id.

type Pool @entity {
    "Pool Address as id"
    id: Bytes!
+   "Pool Comptroller address"
+   address: Bytes!
    "Name of the pool"
    name: String!
    "Creator of the pool"
}

Token Addresses are now a relationship to the Token entity.

+ """
+ ERC20 Token
+ """
+ type Token @entity(immutable: true) {
+   "Address of the asset"
+   id: Bytes!
+   "Address of the asset"
+   address: Bytes!
+   "Name of the asset"
+   name: String!
+   "Symbol of the asset"
+   symbol: String!
+   "Decimals of the asset"
+   decimals: Int!
}

The MarketAction now uses a relationship to the Market entity instead of the vToken address.

MarketAction is an action that can be taken on a market
type MarketAction @entity {
    "Concatentation of address and action"
    id: Bytes!
    "Market affected"
-   vToken: Bytes!
+   market: Market!
    "VToken symbol"
    symbol: String!
}

The `Market` entity now has a relationship to the underlying token. The accounts relationship is to the renamed `MarketPosition` entity. `borrowIndexMantissa` is renamed to `borrowIndex`. `underlyingPriceCentsMantissa` is renamed to `lastUnderlyingPriceCents` and the block number where the price was recorded is added. `blockTimestamp` is removed. `isListed` flag is added to indicate if the market is listed.

```diff
"""
Market stores all high level variables for a vToken market
"""
type Market @entity {
   "VToken address"
    id: Bytes!
+   "Flag for if the token is listed"
+   isListed: Boolean!
-   "Underlying token address"
-   underlyingAddress: Bytes!
-   "Underlying token name"
-   underlyingName: String!
-   "Underlying token symbol"
-   underlyingSymbol: String!
+   "Underlying Token"
+   underlyingToken: Token!
-   "Timestamp the market was most recently updated"
-   blockTimestamp: Int!
    "The history of the markets borrow index return (Think S&P 500)"
-   borrowIndexMantissa: BigInt!
+   borrowIndex: BigInt!
    "Underlying token price in USD cents (updated based on the last received event)"
-   underlyingPriceCentsMantissa: BigInt!
+   lastUnderlyingPriceCents: BigInt!
+   "Block price was last updated"
+   lastUnderlyingPriceBlockNumber: BigInt!
...
    "Accounts who participate in this market"
+   accounts: [MarketPosition!]! @derivedFrom(field:"market")
}

The Account entity has a declared address property so the address doesn't have to be inferred from the id.

"""diff
Account is an BNB address, with a list of all vToken markets the account has
participated in, along with liquidation information.
"""
type Account @entity {
     "User address"
      id: Bytes!
+     "User address"
+     address: Bytes!
    ...
}

The AccountVToken Entity has been renamed to MarketPosition.

The attributes for supplier and borrower amounts were updated to match the core pool schema. Supply is stored in vToken and borrow is stored in underlyingToken. accountBorrowBalanceMantissa is renamed to borrowIndex

"""
- AccountVToken is a single account within a single vToken market, with data such
+ MarketPosition is a single account within a single vToken market, with data such
as interest earned or paid
"""
- type AccountVToken @entity {
+type MarketPosition @entity {
    ...
     "Bad debt data for the account in the market"
-    badDebt: [AccountVTokenBadDebt!]! @derivedFrom(field:"account")
+    badDebt: [MarketPositionBadDebt!]! @derivedFrom(field:"account")
-    "The value of the borrow index upon users last interaction"
-    accountBorrowIndexMantissa: BigInt!
+    "Borrow Index this position last accrued interest"
+    borrowIndex: BigInt!
     "vToken balance representing underlying supplied to the market, underlying balance can be calculated with the exchange rate"
-    accountVTokenSupplyBalanceMantissa: BigInt!
+   vTokenBalanceMantissa: BigInt!
-   "Current borrow balance stored in contract (exclusive of interest since accrualBlockNumber)"
+   "Stored borrow balance stored in contract (exclusive of interest since accrualBlockNumber)"
-   accountBorrowBalanceMantissa: BigInt!
+   storedBorrowBalanceMantissa: BigInt!
}
"""
- Auxiliary entity for AccountVToken indicating when a certain amount of bad debt was healed
+ Auxiliary entity for MarketPosition indicating when a certain amount of bad debt was healed
"""
+ type AccountVTokenBadDebt @entity {
- type MarketPositionBadDebt @entity {
    "Concatenation of borrower and vToken Address"
    id: Bytes!
    "Market that was healed"
-   account: AccountVToken!
+   account: MarketPosition!
    ...
}

The RewardsDistributor entity reward token address is now a relationship to the Token entity. The rewardSpeeds property has been renamed to marketRewards. An isTimeBased property has been added to indicate if the rewards distributor is time based or block based.

"""`
An interface for rewards distributor that distribute rewards to isolated pools
"""
type RewardsDistributor @entity {
    "Address of the reward token"
-   rewardToken: Token!
+   rewardToken: Token!
    "Distribution rate for suppliers"
-   rewardSpeeds: [RewardSpeed!]! @derivedFrom(field:"rewardsDistributor")
+   marketRewards: [MarketReward!]! @derivedFrom(field:"rewardsDistributor")
    "Depending on the Chain, the rewards distributor is time based or block based"
+   isTimeBased: Boolean!
}

The MarketReward entity has been renamed to RewardSpeed. borrowSpeedPerBlockMantissa and supplySpeedPerBlockMantissa are now required properties. Additional details about reward distributions are now stored.

"""
A interface for rewards distributor that distribute rewards to isolated pools
"""
- type RewardSpeed @entity {
+type MarketReward @entity {
    "ID created from the reward distributor and market this speed applies to"
    id: Bytes!
    "Address of rewards distributor"
    rewardsDistributor: RewardsDistributor!
    "Address of the market this speed applies to"
    market: Market!
    "Distribution rate for borrowers"
-   borrowSpeedPerBlockMantissa: BigInt
+   borrowSpeedPerBlockMantissa: BigInt!
    "Distribution rate for suppliers"
-   supplySpeedPerBlockMantissa: BigInt
+   supplySpeedPerBlockMantissa: BigInt!
+   "Index of the last supply state update"
+   supplyStateIndex: BigInt!
+   "Timestamp or block number of the last supply state update"
+   supplyStateBlockNumberOrTimestamp: BigInt!
+   "Index of the last borrow state update"
+   borrowStateIndex: BigInt!
+   "Timestamp or block number of the last borrow state update"
+   borrowStateBlockNumberOrTimestamp: BigInt!
+   "Supply last rewarding block or timestamp"
+   supplyLastRewardingBlockTimestamp: BigInt!
+   "Borrow last rewarding block or timestamp"
+   borrowLastRewardingBlockTimestamp: BigInt!
}

coreyar and others added 30 commits December 10, 2024 11:32
## [@venusprotocol/etherfi-promo-subgraph-v1.1.0-pre-add-ci-deployments.1](https://github.com/VenusProtocol/subgraphs/compare/@venusprotocol/etherfi-promo-subgraph-v1.0.1...@venusprotocol/etherfi-promo-subgraph-v1.1.0-pre-add-ci-deployments.1) (2024-12-10)

### Features

* add scripts to deploy from ci ([3f036d7](3f036d7))

### Bug Fixes

* update release channel ([ab5f43d](ab5f43d))
## [@venusprotocol/isolated-pools-subgraph-v1.4.0-pre-add-ci-deployments.1](https://github.com/VenusProtocol/subgraphs/compare/@venusprotocol/isolated-pools-subgraph-v1.3.0...@venusprotocol/isolated-pools-subgraph-v1.4.0-pre-add-ci-deployments.1) (2024-12-10)

### Features

* add scripts to deploy from ci ([3f036d7](3f036d7))

### Bug Fixes

* update release channel ([ab5f43d](ab5f43d))
## [@venusprotocol/protocol-reserve-subgraph-v1.2.0-pre-add-ci-deployments.1](https://github.com/VenusProtocol/subgraphs/compare/@venusprotocol/protocol-reserve-subgraph-v1.1.0...@venusprotocol/protocol-reserve-subgraph-v1.2.0-pre-add-ci-deployments.1) (2024-12-10)

### Features

* add scripts to deploy from ci ([3f036d7](3f036d7))

### Bug Fixes

* update release channel ([ab5f43d](ab5f43d))
## [@venusprotocol/core-pool-subgraph-v1.2.0-pre-add-ci-deployments.1](https://github.com/VenusProtocol/subgraphs/compare/@venusprotocol/core-pool-subgraph-v1.1.2...@venusprotocol/core-pool-subgraph-v1.2.0-pre-add-ci-deployments.1) (2024-12-10)

### Features

* add scripts to deploy from ci ([3f036d7](3f036d7))

### Bug Fixes

* update release channel ([ab5f43d](ab5f43d))
## [@venusprotocol/governance-subgraph-v1.1.0-pre-add-ci-deployments.1](https://github.com/VenusProtocol/subgraphs/compare/@venusprotocol/governance-subgraph-v1.0.2...@venusprotocol/governance-subgraph-v1.1.0-pre-add-ci-deployments.1) (2024-12-10)

### Features

* add scripts to deploy from ci ([3f036d7](3f036d7))

### Bug Fixes

* update release channel ([ab5f43d](ab5f43d))
## [@venusprotocol/etherfi-promo-subgraph-v1.1.0-testnet.1](https://github.com/VenusProtocol/subgraphs/compare/@venusprotocol/etherfi-promo-subgraph-v1.0.1...@venusprotocol/etherfi-promo-subgraph-v1.1.0-testnet.1) (2024-12-12)

### Features

* add scripts to deploy from ci ([3f036d7](3f036d7))

### Bug Fixes

* update release channel ([ab5f43d](ab5f43d))
## [@venusprotocol/protocol-reserve-subgraph-v1.2.0-testnet.1](https://github.com/VenusProtocol/subgraphs/compare/@venusprotocol/protocol-reserve-subgraph-v1.1.0...@venusprotocol/protocol-reserve-subgraph-v1.2.0-testnet.1) (2024-12-12)

### Features

* add scripts to deploy from ci ([3f036d7](3f036d7))

### Bug Fixes

* update release channel ([ab5f43d](ab5f43d))
fix: Transfer event import path
## [@venusprotocol/protocol-reserve-subgraph-v1.2.0-testnet.3](https://github.com/VenusProtocol/subgraphs/compare/@venusprotocol/protocol-reserve-subgraph-v1.2.0-testnet.2...@venusprotocol/protocol-reserve-subgraph-v1.2.0-testnet.3) (2024-12-12)

### Bug Fixes

* event handler after block handler ([e1e5409](e1e5409))
* update prerelease version name ([9826fe0](9826fe0))
coreyar and others added 2 commits December 17, 2024 14:32
…rsion

fix: enable transparent workspaces
## [@venusprotocol/cross-chain-governance-subgraph-v1.1.1-testnet.5](https://github.com/VenusProtocol/subgraphs/compare/@venusprotocol/cross-chain-governance-subgraph-v1.1.1-testnet.4...@venusprotocol/cross-chain-governance-subgraph-v1.1.1-testnet.5) (2024-12-17)

### Bug Fixes

* bump semantic release version ([d6343ee](d6343ee))
* enable transparent workspaces ([6becde3](6becde3))
* revert bump in semantic release version for compatibility with monorepo plugin ([3d7dba8](3d7dba8))
* switch from semantic-release-yarn to @semantic-release/npm ([f296f07](f296f07))
@coreyar coreyar force-pushed the testnet branch 9 times, most recently from fbd6d16 to bb6d345 Compare December 17, 2024 19:23
toolsvenus and others added 17 commits December 17, 2024 19:46
## [@venusprotocol/etherfi-promo-subgraph-v1.1.0-testnet.5](https://github.com/VenusProtocol/subgraphs/compare/@venusprotocol/etherfi-promo-subgraph-v1.1.0-testnet.4...@venusprotocol/etherfi-promo-subgraph-v1.1.0-testnet.5) (2024-12-17)

### Bug Fixes

* bump semantic release version ([d6343ee](d6343ee))
* relock in prepare script ([be503c8](be503c8))
* revert bump in semantic release version for compatibility with monorepo plugin ([3d7dba8](3d7dba8))
* switch from semantic-release-yarn to @semantic-release/npm ([f296f07](f296f07))
## [@venusprotocol/isolated-pools-subgraph-v1.4.0-testnet.4](https://github.com/VenusProtocol/subgraphs/compare/@venusprotocol/isolated-pools-subgraph-v1.4.0-testnet.3...@venusprotocol/isolated-pools-subgraph-v1.4.0-testnet.4) (2024-12-17)

### Bug Fixes

* bump semantic release version ([d6343ee](d6343ee))
* enable transparent workspaces ([6becde3](6becde3))
* revert bump in semantic release version for compatibility with monorepo plugin ([3d7dba8](3d7dba8))
* switch from semantic-release-yarn to @semantic-release/npm ([f296f07](f296f07))
## [@venusprotocol/protocol-reserve-subgraph-v1.2.0-testnet.6](https://github.com/VenusProtocol/subgraphs/compare/@venusprotocol/protocol-reserve-subgraph-v1.2.0-testnet.5...@venusprotocol/protocol-reserve-subgraph-v1.2.0-testnet.6) (2024-12-17)

### Bug Fixes

* bump semantic release version ([d6343ee](d6343ee))
* enable transparent workspaces ([6becde3](6becde3))
* revert bump in semantic release version for compatibility with monorepo plugin ([3d7dba8](3d7dba8))
* switch from semantic-release-yarn to @semantic-release/npm ([f296f07](f296f07))
## [@venusprotocol/core-pool-subgraph-v1.2.0-testnet.4](https://github.com/VenusProtocol/subgraphs/compare/@venusprotocol/core-pool-subgraph-v1.2.0-testnet.3...@venusprotocol/core-pool-subgraph-v1.2.0-testnet.4) (2024-12-17)

### Bug Fixes

* bump semantic release version ([d6343ee](d6343ee))
* revert bump in semantic release version for compatibility with monorepo plugin ([3d7dba8](3d7dba8))
* switch from semantic-release-yarn to @semantic-release/npm ([f296f07](f296f07))
## [@venusprotocol/governance-subgraph-v1.1.0-testnet.2](https://github.com/VenusProtocol/subgraphs/compare/@venusprotocol/governance-subgraph-v1.1.0-testnet.1...@venusprotocol/governance-subgraph-v1.1.0-testnet.2) (2024-12-17)

### Bug Fixes

* bump semantic release version ([d6343ee](d6343ee))
* enable transparent workspaces ([6becde3](6becde3))
* relock in prepare script ([be503c8](be503c8))
* revert bump in semantic release version for compatibility with monorepo plugin ([3d7dba8](3d7dba8))
* switch from semantic-release-yarn to @semantic-release/npm ([f296f07](f296f07))
…rlying

fix: hardchade underlying weth token to avoid errors querying before existence
## [@venusprotocol/isolated-pools-subgraph-v1.4.0-testnet.5](https://github.com/VenusProtocol/subgraphs/compare/@venusprotocol/isolated-pools-subgraph-v1.4.0-testnet.4...@venusprotocol/isolated-pools-subgraph-v1.4.0-testnet.5) (2024-12-18)

### Bug Fixes

* hardchade underlying weth token to avoid errors querying before existence ([e4c2adf](e4c2adf))
## [@venusprotocol/core-pool-subgraph-v1.2.0-testnet.5](https://github.com/VenusProtocol/subgraphs/compare/@venusprotocol/core-pool-subgraph-v1.2.0-testnet.4...@venusprotocol/core-pool-subgraph-v1.2.0-testnet.5) (2024-12-18)

### Bug Fixes

* hardchade underlying weth token to avoid errors querying before existence ([e4c2adf](e4c2adf))
fix: Add ankr staked bnb hardcoded overrides
## [@venusprotocol/isolated-pools-subgraph-v1.4.0-testnet.6](https://github.com/VenusProtocol/subgraphs/compare/@venusprotocol/isolated-pools-subgraph-v1.4.0-testnet.5...@venusprotocol/isolated-pools-subgraph-v1.4.0-testnet.6) (2024-12-18)

### Bug Fixes

* hardchade underlying ankrstakedbnb token to avoid errors querying before existence ([0021141](0021141))
refactor: skip recording vbifi positions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants