diff --git a/src/classic/lifecycle.ts b/src/classic/lifecycle.ts index 179895b..f528d08 100644 --- a/src/classic/lifecycle.ts +++ b/src/classic/lifecycle.ts @@ -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 { @@ -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) } } @@ -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) +} diff --git a/src/classic/mapping/vault.ts b/src/classic/mapping/vault.ts new file mode 100644 index 0000000..824f070 --- /dev/null +++ b/src/classic/mapping/vault.ts @@ -0,0 +1 @@ +export { handleClassicVaultInitialized } from "../lifecycle" diff --git a/src/clm/lifecycle.ts b/src/clm/lifecycle.ts index 515c760..b89b471 100644 --- a/src/clm/lifecycle.ts +++ b/src/clm/lifecycle.ts @@ -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) diff --git a/src/clm/mapping/manager.ts b/src/clm/mapping/manager.ts new file mode 100644 index 0000000..043aa1f --- /dev/null +++ b/src/clm/mapping/manager.ts @@ -0,0 +1 @@ +export { handleClmManagerInitialized } from "../lifecycle" diff --git a/src/clm/mapping/reward-pool.ts b/src/clm/mapping/reward-pool.ts new file mode 100644 index 0000000..e4d6385 --- /dev/null +++ b/src/clm/mapping/reward-pool.ts @@ -0,0 +1 @@ +export { handleRewardPoolInitialized } from "../lifecycle" diff --git a/subgraph.template.yaml b/subgraph.template.yaml index 4a33510..3b2ee33 100644 --- a/subgraph.template.yaml +++ b/subgraph.template.yaml @@ -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 @@ -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