Skip to content

Commit

Permalink
Update morpho blue protocol rates handling (#401)
Browse files Browse the repository at this point in the history
- added missing subgraph config
  • Loading branch information
piekczyk authored Jun 26, 2024
1 parent 8e32143 commit 2557abc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
3 changes: 2 additions & 1 deletion packages/morpho-blue-subgraph/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { CollateralLockedDocument, GetInterestRatesDocument } from './types/grap

const chainIdSubgraphMap: Partial<Record<ChainId, string>> = {
[ChainId.MAINNET]: 'summer-morpho-blue',
[ChainId.BASE]: 'summer-morpho-blue-base',
}

const getEndpoint = (chainId: ChainId, baseUrl: string) => {
Expand All @@ -17,7 +18,7 @@ const getEndpoint = (chainId: ChainId, baseUrl: string) => {
return `${baseUrl}/${subgraph}`
}
interface SubgraphClientConfig {
chainId: ChainId.MAINNET
chainId: ChainId.MAINNET | ChainId.BASE
urlBase: string
logger?: Logger
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,11 @@ export const getUnifiedProtocolRates = async (
let subgraphResult: MorphoBlueMarketInterestRateResult | undefined
if (fromCache) {
subgraphResult = JSON.parse(fromCache) as MorphoBlueMarketInterestRateResult
} else {
} else if (chainId === ChainId.MAINNET || chainId === ChainId.BASE) {
const subgraphClient = getMorphoBlueSubgraphClient({
...subgraphsConfig,
logger,
chainId: ChainId.MAINNET,
chainId,
})

subgraphResult = await subgraphClient.getInterestRate({
Expand All @@ -227,6 +227,11 @@ export const getUnifiedProtocolRates = async (
chainId,
cacheKey,
})
} else {
return {
isValid: false,
message: 'Invalid subgraph chainId - morpho is available on mainnet and base',
}
}

const rates = await getMorphoBlueRates({
Expand Down

0 comments on commit 2557abc

Please sign in to comment.