diff --git a/subgraphs/isolated-pools/schema.graphql b/subgraphs/isolated-pools/schema.graphql index f75f240c..905d6409 100644 --- a/subgraphs/isolated-pools/schema.graphql +++ b/subgraphs/isolated-pools/schema.graphql @@ -250,6 +250,7 @@ type RewardsDistributor @entity { rewardTokenAddress: Bytes! "Distribution rate for suppliers" marketRewards: [MarketReward!]! @derivedFrom(field:"rewardsDistributor") + "Depending on the Chain, the rewards distributor is time based or block based" isTimeBased: Boolean! } diff --git a/subgraphs/isolated-pools/src/operations/create.ts b/subgraphs/isolated-pools/src/operations/create.ts index bc1592d2..d14af97f 100644 --- a/subgraphs/isolated-pools/src/operations/create.ts +++ b/subgraphs/isolated-pools/src/operations/create.ts @@ -48,6 +48,7 @@ import { getRewardsDistributorId, getTransactionEventId, } from '../utilities/ids'; +import valueOrFalseIfReverted from '../utilities/valueOrFalseIfReverted'; export function createPool(comptroller: Address): Pool { const pool = new Pool(getPoolId(comptroller)); @@ -311,7 +312,9 @@ export function createRewardDistributor( rewardsDistributor.address = rewardsDistributorAddress; rewardsDistributor.pool = comptrollerAddress; rewardsDistributor.rewardTokenAddress = rewardToken; - rewardsDistributor.isTimeBased = rewardDistributorContract.isTimeBased(); + rewardsDistributor.isTimeBased = valueOrFalseIfReverted( + rewardDistributorContract.try_isTimeBased(), + ); rewardsDistributor.save(); // we get the current speeds for all known markets at this point in time diff --git a/subgraphs/isolated-pools/src/utilities/valueOrFalseIfReverted.ts b/subgraphs/isolated-pools/src/utilities/valueOrFalseIfReverted.ts new file mode 100644 index 00000000..44f7212e --- /dev/null +++ b/subgraphs/isolated-pools/src/utilities/valueOrFalseIfReverted.ts @@ -0,0 +1,8 @@ +import { ethereum } from '@graphprotocol/graph-ts'; + +// checks if a call reverted, in case it is we return false to indicate the wanted value is not available +function valueOrFalseIfReverted(callResult: ethereum.CallResult): boolean { + return callResult.reverted ? false : callResult.value; +} + +export default valueOrFalseIfReverted;