diff --git a/README.md b/README.md index 1c62af7..c2b0e3e 100644 --- a/README.md +++ b/README.md @@ -150,4 +150,8 @@ yarn test:lint # run prettier linter - strategy: Harvest(uint256,uint256) - strategy: ClaimedFees(uint256,uint256,uint256,uint256) - strategy: ClaimedOutput(uint256) + +- rewardPoolFactory: ProxyCreated(address) +- rewardPool.stakedToken() +- rewardPool: Initialized(uint8) ``` diff --git a/abis/beefy/concliq/BeefyRewardPool.json b/abis/beefy/concliq/BeefyRewardPool.json new file mode 100644 index 0000000..5a0f0b1 --- /dev/null +++ b/abis/beefy/concliq/BeefyRewardPool.json @@ -0,0 +1,378 @@ +[ + { + "inputs": [{ "internalType": "address", "name": "caller", "type": "address" }], + "name": "NotManager", + "type": "error" + }, + { + "inputs": [{ "internalType": "address", "name": "reward", "type": "address" }], + "name": "RewardNotFound", + "type": "error" + }, + { + "inputs": [{ "internalType": "uint256", "name": "duration", "type": "uint256" }], + "name": "ShortDuration", + "type": "error" + }, + { "inputs": [], "name": "StakedTokenIsNotAReward", "type": "error" }, + { "inputs": [], "name": "TooManyRewards", "type": "error" }, + { + "inputs": [{ "internalType": "address", "name": "reward", "type": "address" }], + "name": "WithdrawingRewardToken", + "type": "error" + }, + { "inputs": [], "name": "WithdrawingStakedToken", "type": "error" }, + { + "anonymous": false, + "inputs": [{ "indexed": false, "internalType": "address", "name": "reward", "type": "address" }], + "name": "AddReward", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "address", "name": "owner", "type": "address" }, + { "indexed": true, "internalType": "address", "name": "spender", "type": "address" }, + { "indexed": false, "internalType": "uint256", "name": "value", "type": "uint256" } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [{ "indexed": false, "internalType": "uint8", "name": "version", "type": "uint8" }], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "address", "name": "reward", "type": "address" }, + { "indexed": false, "internalType": "uint256", "name": "amount", "type": "uint256" }, + { "indexed": false, "internalType": "uint256", "name": "duration", "type": "uint256" } + ], + "name": "NotifyReward", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "address", "name": "previousOwner", "type": "address" }, + { "indexed": true, "internalType": "address", "name": "newOwner", "type": "address" } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": false, "internalType": "address", "name": "reward", "type": "address" }, + { "indexed": false, "internalType": "address", "name": "recipient", "type": "address" } + ], + "name": "RemoveReward", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": false, "internalType": "address", "name": "token", "type": "address" }, + { "indexed": false, "internalType": "address", "name": "recipient", "type": "address" } + ], + "name": "RescueTokens", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "address", "name": "user", "type": "address" }, + { "indexed": true, "internalType": "address", "name": "reward", "type": "address" }, + { "indexed": false, "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "RewardPaid", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": false, "internalType": "address", "name": "manager", "type": "address" }, + { "indexed": false, "internalType": "bool", "name": "whitelist", "type": "bool" } + ], + "name": "SetWhitelist", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "address", "name": "user", "type": "address" }, + { "indexed": false, "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "Staked", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "address", "name": "from", "type": "address" }, + { "indexed": true, "internalType": "address", "name": "to", "type": "address" }, + { "indexed": false, "internalType": "uint256", "name": "value", "type": "uint256" } + ], + "name": "Transfer", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "address", "name": "user", "type": "address" }, + { "indexed": false, "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "Withdrawn", + "type": "event" + }, + { + "inputs": [ + { "internalType": "address", "name": "owner", "type": "address" }, + { "internalType": "address", "name": "spender", "type": "address" } + ], + "name": "allowance", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "spender", "type": "address" }, + { "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "approve", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "account", "type": "address" }], + "name": "balanceOf", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "decimals", + "outputs": [{ "internalType": "uint8", "name": "", "type": "uint8" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "spender", "type": "address" }, + { "internalType": "uint256", "name": "subtractedValue", "type": "uint256" } + ], + "name": "decreaseAllowance", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "_user", "type": "address" }], + "name": "earned", + "outputs": [ + { "internalType": "address[]", "name": "rewardTokens", "type": "address[]" }, + { "internalType": "uint256[]", "name": "earnedAmounts", "type": "uint256[]" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_user", "type": "address" }, + { "internalType": "address", "name": "_reward", "type": "address" } + ], + "name": "earned", + "outputs": [{ "internalType": "uint256", "name": "earnedAmount", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { "inputs": [], "name": "exit", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, + { "inputs": [], "name": "getReward", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, + { + "inputs": [ + { "internalType": "address", "name": "spender", "type": "address" }, + { "internalType": "uint256", "name": "addedValue", "type": "uint256" } + ], + "name": "increaseAllowance", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_stakedToken", "type": "address" }, + { "internalType": "string", "name": "_name", "type": "string" }, + { "internalType": "string", "name": "_symbol", "type": "string" } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [{ "internalType": "string", "name": "", "type": "string" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_reward", "type": "address" }, + { "internalType": "uint256", "name": "_amount", "type": "uint256" }, + { "internalType": "uint256", "name": "_duration", "type": "uint256" } + ], + "name": "notifyRewardAmount", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_reward", "type": "address" }, + { "internalType": "address", "name": "_recipient", "type": "address" } + ], + "name": "removeReward", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { "inputs": [], "name": "renounceOwnership", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, + { + "inputs": [ + { "internalType": "address", "name": "_token", "type": "address" }, + { "internalType": "address", "name": "_recipient", "type": "address" } + ], + "name": "rescueTokens", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "uint256", "name": "_rewardId", "type": "uint256" }], + "name": "rewardInfo", + "outputs": [ + { "internalType": "address", "name": "reward", "type": "address" }, + { "internalType": "uint256", "name": "periodFinish", "type": "uint256" }, + { "internalType": "uint256", "name": "duration", "type": "uint256" }, + { "internalType": "uint256", "name": "lastUpdateTime", "type": "uint256" }, + { "internalType": "uint256", "name": "rate", "type": "uint256" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "name": "rewards", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_manager", "type": "address" }, + { "internalType": "bool", "name": "_whitelisted", "type": "bool" } + ], + "name": "setWhitelist", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "uint256", "name": "_amount", "type": "uint256" }], + "name": "stake", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_user", "type": "address" }, + { "internalType": "uint256", "name": "_amount", "type": "uint256" }, + { "internalType": "uint256", "name": "_deadline", "type": "uint256" }, + { "internalType": "uint8", "name": "_v", "type": "uint8" }, + { "internalType": "bytes32", "name": "_r", "type": "bytes32" }, + { "internalType": "bytes32", "name": "_s", "type": "bytes32" } + ], + "name": "stakeWithPermit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "stakedToken", + "outputs": [{ "internalType": "contract IERC20Upgradeable", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [{ "internalType": "string", "name": "", "type": "string" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalSupply", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_to", "type": "address" }, + { "internalType": "uint256", "name": "_value", "type": "uint256" } + ], + "name": "transfer", + "outputs": [{ "internalType": "bool", "name": "success", "type": "bool" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_from", "type": "address" }, + { "internalType": "address", "name": "_to", "type": "address" }, + { "internalType": "uint256", "name": "_value", "type": "uint256" } + ], + "name": "transferFrom", + "outputs": [{ "internalType": "bool", "name": "success", "type": "bool" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "newOwner", "type": "address" }], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "", "type": "address" }], + "name": "whitelisted", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "uint256", "name": "_amount", "type": "uint256" }], + "name": "withdraw", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } +] diff --git a/abis/beefy/concliq/BeefyRewardPoolFactory.json b/abis/beefy/concliq/BeefyRewardPoolFactory.json new file mode 100644 index 0000000..e8d0608 --- /dev/null +++ b/abis/beefy/concliq/BeefyRewardPoolFactory.json @@ -0,0 +1,27 @@ +[ + { + "inputs": [{ "internalType": "address", "name": "_instance", "type": "address" }], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [{ "indexed": false, "internalType": "address", "name": "proxy", "type": "address" }], + "name": "ProxyCreated", + "type": "event" + }, + { + "inputs": [], + "name": "cloneRewardPool", + "outputs": [{ "internalType": "contract BeefyRewardPool", "name": "", "type": "address" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "instance", + "outputs": [{ "internalType": "contract BeefyRewardPool", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + } +] diff --git a/config/arbitrum.json b/config/arbitrum.json index a83bf75..4bda83e 100644 --- a/config/arbitrum.json +++ b/config/arbitrum.json @@ -8,6 +8,8 @@ "vaultFactoryStartBlock": 198239651, "strategyFactoryAddress": "0xB37c7C935CcE547Eb858Fc8F2d8C3B48597f4aE9", "strategyFactoryStartBlock": 197959279, + "rewardPoolFactoryAddress": "0x26eb26e0aadd5fa70331219c5cec0166114ce71e", + "rewardPoolFactoryStartBlock": 206875840, "clockTickBlocks": 1300, "wrappedNativeAddress": "0x82af49447d8a07e3bd95bd0d56f35241523fbab1", diff --git a/config/base.json b/config/base.json index b26d8d8..677f79f 100644 --- a/config/base.json +++ b/config/base.json @@ -8,6 +8,8 @@ "vaultFactoryStartBlock": 12429065, "strategyFactoryAddress": "0x572E05A3DaF78a480b530eC303F32dC675df3A8c", "strategyFactoryStartBlock": 12429069, + "rewardPoolFactoryAddress": "0x4200000000000000000000000000000000000006", + "rewardPoolFactoryStartBlock": 12429069, "clockTickBlocks": 150, "wrappedNativeAddress": "0x4200000000000000000000000000000000000006", diff --git a/config/optimism.json b/config/optimism.json index 2616e2f..6ca34e9 100644 --- a/config/optimism.json +++ b/config/optimism.json @@ -8,6 +8,8 @@ "vaultFactoryStartBlock": 118020306, "strategyFactoryAddress": "0x9653223Bff898719F5ccc3656e27e6b5415b2616", "strategyFactoryStartBlock": 118020374, + "rewardPoolFactoryAddress": "0x4200000000000000000000000000000000000006", + "rewardPoolFactoryStartBlock": 118020374, "clockTickBlocks": 250, "wrappedNativeAddress": "0x4200000000000000000000000000000000000006", diff --git a/schema.graphql b/schema.graphql index 444e31b..e824a6e 100644 --- a/schema.graphql +++ b/schema.graphql @@ -102,6 +102,8 @@ type BeefyCLVault @entity { createdWith: Transaction! "The strategy of the vault. The strategy is responsible for managing the vault's assets." strategy: BeefyCLStrategy! + "The reward pool of the vault. The reward pool is where the vault's earnings are sent if the vault does not automatically compound." + rewardPool: BeefyCLRewardPool "Technical field to remember if the vault was already initialized" isInitialized: Boolean! "The current lifecycle status of the vault" @@ -218,7 +220,7 @@ type BeefyCLVaultSnapshot @entity { """ A strategy is a contract that manages the assets of a vault. -This is mostly used to start tracking the events and link them to the vault on new event +This entity is mostly used to start tracking the events and link them to the vault on new event """ type BeefyCLStrategy @entity { "The strategy address" @@ -229,6 +231,20 @@ type BeefyCLStrategy @entity { isInitialized: Boolean! } +""" +Some vaults do not automatically compound their earnings. Those earnings are sent to the reward pool instead. + +This entit is mostly used to start tracking the events and link them to the vault on new event +""" +type BeefyCLRewardPool @entity { + "The strategy address" + id: Bytes! + "The vault the strategy is managing" + vault: BeefyCLVault! + "Technical field to remember if the strategy was already initialized" + isInitialized: Boolean! +} + """ Vault are harvested by the strategy. This event is emitted when the strategy harvests the vault. """ diff --git a/src/entity/vault.ts b/src/entity/vault.ts index a3b4b71..105f31e 100644 --- a/src/entity/vault.ts +++ b/src/entity/vault.ts @@ -1,5 +1,5 @@ import { BigInt, Bytes } from "@graphprotocol/graph-ts" -import { BeefyCLStrategy, BeefyCLVault, BeefyCLVaultSnapshot } from "../../generated/schema" +import { BeefyCLRewardPool, BeefyCLStrategy, BeefyCLVault, BeefyCLVaultSnapshot } from "../../generated/schema" import { ADDRESS_ZERO } from "../utils/address" import { ZERO_BI } from "../utils/decimal" import { getIntervalFromTimestamp } from "../utils/time" @@ -55,6 +55,16 @@ export function getBeefyCLStrategy(strategyAddress: Bytes): BeefyCLStrategy { return strategy } +export function getBeefyCLRewardPool(rewardPoolAddress: Bytes): BeefyCLRewardPool { + let rewardPool = BeefyCLRewardPool.load(rewardPoolAddress) + if (!rewardPool) { + rewardPool = new BeefyCLRewardPool(rewardPoolAddress) + rewardPool.vault = ADDRESS_ZERO + rewardPool.isInitialized = false + } + return rewardPool +} + export function getBeefyCLVaultSnapshot(vault: BeefyCLVault, timestamp: BigInt, period: BigInt): BeefyCLVaultSnapshot { const interval = getIntervalFromTimestamp(timestamp, period) const snapshotId = vault.id.concat(getSnapshotIdSuffix(period, interval)) diff --git a/src/mapping/factory.ts b/src/mapping/factory.ts index 2e1a6a0..3b847e4 100644 --- a/src/mapping/factory.ts +++ b/src/mapping/factory.ts @@ -1 +1 @@ -export { handleVaultCreated } from "../vault-lifecycle" +export { handleVaultCreated, handleRewardPoolCreated } from "../vault-lifecycle" diff --git a/src/mapping/reward-pool.ts b/src/mapping/reward-pool.ts new file mode 100644 index 0000000..012c59a --- /dev/null +++ b/src/mapping/reward-pool.ts @@ -0,0 +1 @@ +export { handleRewardPoolInitialized as handleInitialized } from "../vault-lifecycle" diff --git a/src/vault-lifecycle.ts b/src/vault-lifecycle.ts index 49ce78c..e7e9462 100644 --- a/src/vault-lifecycle.ts +++ b/src/vault-lifecycle.ts @@ -1,11 +1,22 @@ -import { Address, BigInt } from "@graphprotocol/graph-ts" -import { BeefyCLVault } from "../generated/schema" -import { BeefyVaultConcLiq as BeefyCLVaultContract } from "../generated/templates/BeefyCLVault/BeefyVaultConcLiq" -import { BEEFY_CL_VAULT_LIFECYCLE_PAUSED, BEEFY_CL_VAULT_LIFECYCLE_RUNNING } from "./entity/vault" -import { Initialized as VaultInitialized } from "../generated/templates/BeefyCLVault/BeefyVaultConcLiq" -import { getBeefyCLStrategy, getBeefyCLVault } from "./entity/vault" +import { Address } from "@graphprotocol/graph-ts" +import { BeefyCLVault, BeefyCLRewardPool } from "../generated/schema" +import { + BeefyVaultConcLiq as BeefyCLVaultContract, + Initialized as VaultInitialized, +} from "../generated/templates/BeefyCLVault/BeefyVaultConcLiq" +import { + BEEFY_CL_VAULT_LIFECYCLE_PAUSED, + BEEFY_CL_VAULT_LIFECYCLE_RUNNING, + getBeefyCLRewardPool, + getBeefyCLStrategy, + getBeefyCLVault, +} from "./entity/vault" import { log } from "@graphprotocol/graph-ts" -import { BeefyCLStrategy as BeefyCLStrategyTemplate } from "../generated/templates" +import { + BeefyCLStrategy as BeefyCLStrategyTemplate, + BeefyCLVault as BeefyCLVaultTemplate, + BeefyCLRewardPool as BeefyCLRewardPoolTemplate, +} from "../generated/templates" import { ADDRESS_ZERO } from "./utils/address" import { Initialized as StrategyInitializedEvent, @@ -14,8 +25,12 @@ import { Unpaused as UnpausedEvent, } from "../generated/templates/BeefyCLStrategy/BeefyStrategy" import { ProxyCreated as VaultCreatedEvent } from "../generated/BeefyCLVaultFactory/BeefyVaultConcLiqFactory" +import { ProxyCreated as RewardPoolCreatedEvent } from "../generated/BeefyRewardPoolFactory/BeefyRewardPoolFactory" +import { + Initialized as RewardPoolInitialized, + BeefyRewardPool as BeefyCLRewardPoolContract, +} from "../generated/BeefyRewardPoolFactory/BeefyRewardPool" import { GlobalPause as GlobalPauseEvent } from "../generated/BeefyCLStrategyFactory/BeefyStrategyFactory" -import { BeefyCLVault as BeefyCLVaultTemplate } from "../generated/templates" import { getTransaction } from "./entity/transaction" import { fetchAndSaveTokenData } from "./utils/token" import { getBeefyCLProtocol } from "./entity/protocol" @@ -78,7 +93,7 @@ export function handleVaultInitialized(event: VaultInitialized): void { strategy.isInitialized = !strategyPool.value.equals(ADDRESS_ZERO) if (strategy.isInitialized) { - vault = fetchInitialVaultData(event.block.timestamp, vault) + vault = fetchInitialVaultData(vault) vault.save() } } @@ -110,7 +125,7 @@ export function handleStrategyInitialized(event: StrategyInitializedEvent): void let vault = getBeefyCLVault(vaultAddress) if (vault.isInitialized) { - vault = fetchInitialVaultData(event.block.timestamp, vault) + vault = fetchInitialVaultData(vault) vault.save() } } @@ -119,7 +134,7 @@ export function handleStrategyInitialized(event: StrategyInitializedEvent): void * Initialize the vault data. * Call this when both the vault and the strategy are initialized. */ -function fetchInitialVaultData(timestamp: BigInt, vault: BeefyCLVault): BeefyCLVault { +function fetchInitialVaultData(vault: BeefyCLVault): BeefyCLVault { const vaultAddress = Address.fromBytes(vault.id) const vaultContract = BeefyCLVaultContract.bind(vaultAddress) @@ -173,3 +188,35 @@ export function handleStrategyUnpaused(event: UnpausedEvent): void { vault.lifecycle = BEEFY_CL_VAULT_LIFECYCLE_RUNNING vault.save() } + +export function handleRewardPoolCreated(event: RewardPoolCreatedEvent): void { + const rewardPoolAddress = event.params.proxy + + const rewardPool = new BeefyCLRewardPool(rewardPoolAddress) + rewardPool.isInitialized = false + rewardPool.save() + + // start indexing the new reward pool + BeefyCLRewardPoolTemplate.create(rewardPoolAddress) +} + +export function handleRewardPoolInitialized(event: RewardPoolInitialized): void { + const rewardPoolAddress = event.address + const rewardPoolContract = BeefyCLRewardPoolContract.bind(rewardPoolAddress) + const vaultAddress = rewardPoolContract.stakedToken() + + const rewardPool = getBeefyCLRewardPool(rewardPoolAddress) + rewardPool.isInitialized = true + rewardPool.vault = vaultAddress + rewardPool.save() + + const vault = getBeefyCLVault(vaultAddress) + vault.rewardPool = rewardPool.id + vault.save() + + log.info("handleRewardPoolInitialized: Reward pool {} initialized for vault {} on block {}", [ + rewardPool.id.toHexString(), + rewardPool.vault.toHexString(), + event.block.number.toString(), + ]) +} diff --git a/subgraph.template.yaml b/subgraph.template.yaml index d2a6c19..561a7ef 100644 --- a/subgraph.template.yaml +++ b/subgraph.template.yaml @@ -26,6 +26,7 @@ dataSources: - ProtocolSnapshot - BeefyCLVault - BeefyCLVaultSnapshot + - BeefyCLRewardPool - BeefyCLStrategy - BeefyCLVaultHarvestEvent - BeefyCLVaultUnderlyingFeesCollectedEvent @@ -43,6 +44,10 @@ dataSources: file: ./abis/beefy/concliq/BeefyStrategyFactory.json - name: BeefyStrategy file: ./abis/beefy/concliq/BeefyStrategy.json + - name: BeefyRewardPoolFactory + file: ./abis/beefy/concliq/BeefyRewardPoolFactory.json + - name: BeefyRewardPool + file: ./abis/beefy/concliq/BeefyRewardPool.json - name: ChainLinkPriceFeed file: ./abis/chainlink/AggregatorV3Interface.json - name: IERC20 @@ -71,6 +76,24 @@ dataSources: - event: GlobalPause(bool) handler: handleGlobalStrategyPause + - kind: ethereum/contract + name: BeefyRewardPoolFactory + network: {{network}} + source: + address: "{{rewardPoolFactoryAddress}}" + abi: BeefyRewardPoolFactory + startBlock: {{rewardPoolFactoryStartBlock}} + mapping: + kind: ethereum/events + apiVersion: 0.0.7 # 0xgraph's version + language: wasm/assemblyscript + file: ./src/mapping/factory.ts + entities: *entities + abis: *abis + eventHandlers: + - event: ProxyCreated(address) + handler: handleRewardPoolCreated + - kind: ethereum/contract name: ChainLinkPriceFeed network: {{network}} @@ -140,4 +163,19 @@ templates: - event: ClaimedOutput(uint256) handler: handleClaimedOutput - \ No newline at end of file + + - name: BeefyCLRewardPool + kind: ethereum/contract + network: {{network}} + source: + abi: BeefyStrategy + mapping: + kind: ethereum/events + apiVersion: 0.0.7 # 0xgraph's version + language: wasm/assemblyscript + file: ./src/mapping/reward-pool.ts + entities: *entities + abis: *abis + eventHandlers: + - event: Initialized(uint8) + handler: handleInitialized \ No newline at end of file