Skip to content

Commit

Permalink
Cleanup linea tvl unused vaults
Browse files Browse the repository at this point in the history
  • Loading branch information
prevostc committed May 23, 2024
1 parent ab7e868 commit a476a42
Show file tree
Hide file tree
Showing 8 changed files with 91 additions and 454 deletions.
2 changes: 1 addition & 1 deletion config/linea.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"network": "linea",
"shareTokenMintAddress": "0x0000000000000000000000000000000000000000",
"bindConfigAddress": "0xD19ab62F83380908D65E344567378cF104cE46c2",
"bindConfigBlock": 1195340,
"bindConfigBlock": 3174336,
"bindConfigEvent": "ProxyCreated(address)",
"vaultInitializedEvent": "Initialized(uint8)",
"clockTickBlocks": 110
Expand Down
60 changes: 0 additions & 60 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -97,30 +97,6 @@ type BeefyVault @entity {
"The current lifecycle status of the vault"
lifecycle: VaultLifecycle!

"""
The block number at which we started tracking the vault data.
Zero means disabled.
"""
startTrackingVaultDataAtBlock: BigInt!

"""
The block number at which we started tracking the vault balance breakdown.
Zero means disabled.
"""
startTrackingVaultBalanceBreakdownAtBlock: BigInt!

"""
The block number at which we started tracking the investor balance breakdown.
Zero means disabled.
"""
startTrackingInvestorBalanceBreakdownAtBlock: BigInt!

"""
The block number at which we started tracking the investor token balance snapshots.
Zero means disabled.
"""
startTrackingInvestorTokenBalanceSnapshotsAtBlock: BigInt!

"The underlying platform this vault is using"
underlyingPlatform: String!

Expand Down Expand Up @@ -282,39 +258,3 @@ type InvestorPositionBalanceBreakdown @entity {
"last time the balance was updated"
lastUpdateBlock: BigInt!
}

type InvestorTokenBalanceSnapshot @entity {
"Investor address id + token address"
id: Bytes!

"""
Duration of the snapshot period in seconds.
Available periods:
- 1 day: 86400
- 1 week: 604800
- 1 year: 31536000
"""
period: BigInt!
"Timestamp the snapshot was initiated at, rounded to period"
roundedTimestamp: BigInt!
"Actual timestamp snapshot was initiated at"
timestamp: BigInt!

"Investor"
investor: Investor!

"Token address of the breakdown item"
token: Token

"Balance of the breakdown item. Represented with `token.decimals` decimals"
rawBalance: BigInt!

"Balance of the breakdown item"
balance: BigDecimal!

"last block the balance was updated"
lastUpdateBlock: BigInt!

"last time the balance was updated"
lastUpdateTimestamp: BigInt!
}
34 changes: 1 addition & 33 deletions src/entity/investor.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BigInt, Bytes } from "@graphprotocol/graph-ts"
import { Investor, InvestorTokenBalanceSnapshot, Token } from "../../generated/schema"
import { Investor, Token } from "../../generated/schema"
import { getIntervalFromTimestamp } from "../utils/time"
import { getPreviousSnapshotIdSuffix, getSnapshotIdSuffix } from "../utils/snapshot"
import { ZERO_BD, ZERO_BI } from "../utils/decimal"
Expand All @@ -12,35 +12,3 @@ export function getInvestor(accountAddress: Bytes): Investor {

return investor
}

export function getInvestorBalanceSnapshot(investor: Investor, token: Token, timestamp: BigInt, period: BigInt): InvestorTokenBalanceSnapshot {
const interval = getIntervalFromTimestamp(timestamp, period)
const snapshotId = investor.id.concat(token.id).concat(getSnapshotIdSuffix(period, interval))
let snapshot = InvestorTokenBalanceSnapshot.load(snapshotId)
if (!snapshot) {
snapshot = new InvestorTokenBalanceSnapshot(snapshotId)
snapshot.investor = investor.id
snapshot.token = token.id

snapshot.period = period
snapshot.timestamp = timestamp
snapshot.roundedTimestamp = interval

snapshot.rawBalance = ZERO_BI
snapshot.balance = ZERO_BD
snapshot.lastUpdateBlock = ZERO_BI
snapshot.lastUpdateTimestamp = ZERO_BI

// copy non-reseting values from the previous snapshot to the new snapshot
const previousSnapshotId = investor.id.concat(token.id).concat(getPreviousSnapshotIdSuffix(period, interval))
const previousSnapshot = InvestorTokenBalanceSnapshot.load(previousSnapshotId)
if (previousSnapshot) {
snapshot.rawBalance = previousSnapshot.rawBalance
snapshot.balance = previousSnapshot.balance
snapshot.lastUpdateBlock = previousSnapshot.lastUpdateBlock
snapshot.lastUpdateTimestamp = previousSnapshot.lastUpdateTimestamp
}
}

return snapshot
}
4 changes: 0 additions & 4 deletions src/entity/vault.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ export function getBeefyVault(vaultAddress: Bytes): BeefyVault {
vault.initializedAtBlockNumber = ZERO_BI
vault.initializedAtTimestamp = ZERO_BI
vault.lifecycle = BEEFY_VAULT_LIFECYCLE_INITIALIZING
vault.startTrackingVaultDataAtBlock = ZERO_BI
vault.startTrackingVaultBalanceBreakdownAtBlock = ZERO_BI
vault.startTrackingInvestorBalanceBreakdownAtBlock = ZERO_BI
vault.startTrackingInvestorTokenBalanceSnapshotsAtBlock = ZERO_BI
vault.underlyingPlatform = ""
vault.vaultId = ""
vault.rawSharesTokenTotalSupply = ZERO_BI
Expand Down
4 changes: 1 addition & 3 deletions src/platform/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ export function getVaultTokenBreakdown(vault: BeefyVault): Array<TokenBalance> {
} else if (vault.underlyingPlatform == PLATFORM_MENDI_LENDING) {
return getVaultTokenBreakdownMendiLending(vault)
} else if (vault.underlyingPlatform == PLATFORM_MENDI_LEVERAGE) {
// we don't need the break down for mendi leverage atm
// we only care about the moo token time weighted balance
return new Array<TokenBalance>()
return getVaultTokenBreakdownMendiLending(vault)
}

log.error("Not implemented platform {} for vault {}", [vault.underlyingPlatform, vault.id.toHexString()])
Expand Down
Loading

0 comments on commit a476a42

Please sign in to comment.