Skip to content

Commit

Permalink
Add underlyingProtocolPool
Browse files Browse the repository at this point in the history
  • Loading branch information
prevostc committed Nov 25, 2024
1 parent c795a6a commit aa243e6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,8 @@ type CLM @entity {
manager: ClmManager!
"The strategy of the CLM. The strategy is responsible for managing the CLM's assets."
strategy: ClmStrategy!
"The underlying protocol pool contract address where liquidity is deposited"
underlyingProtocolPool: Bytes!
"""
The reward pool of the CLM.
The reward pool is where the CLM's earnings are sent if the ClmManager does not automatically compound.
Expand Down
1 change: 1 addition & 0 deletions src/clm/entity/clm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export function getCLM(managerAddress: Bytes): CLM {
clm.protocol = getBeefyCLProtocol().id
clm.manager = managerAddress
clm.strategy = ADDRESS_ZERO
clm.underlyingProtocolPool = ADDRESS_ZERO
clm.lifecycle = PRODUCT_LIFECYCLE_INITIALIZING

clm.managerToken = managerAddress
Expand Down
10 changes: 9 additions & 1 deletion src/clm/lifecycle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export function handleClmManagerInitialized(event: ClmManagerInitialized): void
// this is a test to know if that is the case
const strategyContract = ClmStrategyContract.bind(strategyAddress)
const strategyPoolRes = strategyContract.try_pool()
if (strategyAddressRes.reverted) {
if (strategyPoolRes.reverted) {
log.error("handleClmManagerInitialized: Strategy pool reverted for CLM {}", [managerAddress.toHexString()])
return
}
Expand Down Expand Up @@ -160,6 +160,14 @@ function fetchInitialCLMDataAndSave(clm: CLM): void {

const strategyAddress = Address.fromBytes(clm.strategy)
const strategyContract = ClmStrategyContract.bind(strategyAddress)

const strategyPoolRes = strategyContract.try_pool()
if (strategyPoolRes.value) {
clm.underlyingProtocolPool = strategyPoolRes.value
} else {
log.error("fetchInitialCLMDataAndSave: Strategy pool reverted for CLM {}", [clm.id.toHexString()])
}

const outputTokenRes = strategyContract.try_output()
if (!outputTokenRes.reverted) {
const outputTokenAddress = outputTokenRes.value
Expand Down

0 comments on commit aa243e6

Please sign in to comment.