Skip to content

Commit

Permalink
Handle innit event
Browse files Browse the repository at this point in the history
  • Loading branch information
prevostc committed Jun 21, 2024
1 parent 5717267 commit d520c22
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 6 deletions.
14 changes: 10 additions & 4 deletions src/classic/lifecycle.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { log } from "@graphprotocol/graph-ts"
import { ProxyCreated as VaultOrStrategyCreated } from "../../generated/ClassicVaultFactory/ClassicVaultFactory"
import { Initialized as VaultInitialized } from "../../generated/ClassicVaultFactory/ClassicVault"
import { BoostDeployed as BoostCreated } from "../../generated/ClassicBoostFactory/ClassicBoostFactory"
import { ClassicVault as ClassicVaultContract } from "../../generated/ClassicVaultFactory/ClassicVault"
import { BeefyERC20Product as BeefyERC20ProductTemplate } from "../../generated/templates"
import { BeefyERC20Product as BeefyERC20ProductTemplate, ClassicVault as ClassicVaultTemplate } from "../../generated/templates"
import { fetchAndSaveTokenData } from "../common/utils/token"

export function handleClassicVaultOrStrategyCreated(event: VaultOrStrategyCreated): void {
Expand All @@ -16,10 +17,9 @@ export function handleClassicVaultOrStrategyCreated(event: VaultOrStrategyCreate
if (vaultStrategyRes.reverted) {
log.debug("`strategy()` method does not exist on contract: {}. It's not a vault", [address.toHexString()])
} else {
log.info("Creating Classic Vault: {}", [address.toHexString()])
log.warning("Creating Classic Vault: {}", [address.toHexString()])

fetchAndSaveTokenData(address)
BeefyERC20ProductTemplate.create(address)
ClassicVaultTemplate.create(address)
}
}

Expand All @@ -29,3 +29,9 @@ export function handleClassicBoostCreated(event: BoostCreated): void {
fetchAndSaveTokenData(address)
BeefyERC20ProductTemplate.create(address)
}

export function handleClassicVaultInitialized(event: VaultInitialized): void {
const address = event.address
fetchAndSaveTokenData(address)
BeefyERC20ProductTemplate.create(address)
}
1 change: 1 addition & 0 deletions src/classic/mapping/vault.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { handleClassicVaultInitialized } from "../lifecycle"
18 changes: 16 additions & 2 deletions src/clm/lifecycle.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,29 @@
import { ProxyCreated as CLMManagerCreatedEvent } from "../../generated/ClmManagerFactory/ClmManagerFactory"
import { ProxyCreated as RewardPoolCreatedEvent } from "../../generated/RewardPoolFactory/RewardPoolFactory"
import { BeefyERC20Product as BeefyERC20ProductTemplate } from "../../generated/templates"
import {
ClmManager as ClmManagerTemplate,
ClmRewardPool as ClmRewardPoolTemplate,
BeefyERC20Product as BeefyERC20ProductTemplate,
} from "../../generated/templates"
import { fetchAndSaveTokenData } from "../common/utils/token"

export function handleClmManagerCreated(event: CLMManagerCreatedEvent): void {
const address = event.params.proxy
ClmManagerTemplate.create(address)
}

export function handleRewardPoolCreated(event: RewardPoolCreatedEvent): void {
const address = event.params.proxy
ClmRewardPoolTemplate.create(address)
}

export function handleClmManagerInitialized(event: CLMManagerCreatedEvent): void {
const address = event.params.proxy
fetchAndSaveTokenData(address)
BeefyERC20ProductTemplate.create(address)
}

export function handleRewardPoolCreated(event: RewardPoolCreatedEvent): void {
export function handleRewardPoolInitialized(event: RewardPoolCreatedEvent): void {
const address = event.params.proxy
fetchAndSaveTokenData(address)
BeefyERC20ProductTemplate.create(address)
Expand Down
1 change: 1 addition & 0 deletions src/clm/mapping/manager.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { handleClmManagerInitialized } from "../lifecycle"
1 change: 1 addition & 0 deletions src/clm/mapping/reward-pool.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { handleRewardPoolInitialized } from "../lifecycle"
51 changes: 51 additions & 0 deletions subgraph.template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@ dataSources:
abis: &abis
- name: ClmManagerFactory
file: ./abis/beefy/clm/ClmManagerFactory.json
- name: ClmManager
file: ./abis/beefy/clm/ClmManager.json
- name: RewardPoolFactory
file: ./abis/beefy/clm/RewardPoolFactory.json
- name: RewardPool
file: ./abis/beefy/clm/RewardPool.json
- name: ClassicVaultFactory
file: ./abis/beefy/classic/ClassicVaultFactory.json
- name: ClassicVault
Expand Down Expand Up @@ -103,6 +107,53 @@ dataSources:
handler: handleClassicBoostCreated

templates:
- name: ClmManager
kind: ethereum/contract
network: {{network}}
source:
abi: ClmManager
mapping:
kind: ethereum/events
apiVersion: 0.0.7 # 0xgraph's version
language: wasm/assemblyscript
file: ./src/clm/mapping/manager.ts
entities: *clmEntities
abis: *abis
eventHandlers:
- event: Initialized(uint8)
handler: handleClmManagerInitialized

- name: ClmRewardPool
kind: ethereum/contract
network: {{network}}
source:
abi: RewardPool
mapping:
kind: ethereum/events
apiVersion: 0.0.7 # 0xgraph's version
language: wasm/assemblyscript
file: ./src/clm/mapping/reward-pool.ts
entities: *clmEntities
abis: *abis
eventHandlers:
- event: Initialized(uint8)
handler: handleRewardPoolInitialized

- name: ClassicVault
kind: ethereum/contract
network: {{network}}
source:
abi: ClassicVault
mapping:
kind: ethereum/events
apiVersion: 0.0.7 # 0xgraph's version
language: wasm/assemblyscript
file: ./src/classic/mapping/vault.ts
entities: *classicEntities
abis: *abis
eventHandlers:
- event: Initialized(uint8)
handler: handleClassicVaultInitialized

- name: BeefyERC20Product
kind: ethereum/contract
Expand Down

0 comments on commit d520c22

Please sign in to comment.