Skip to content

Commit

Permalink
fix: check address
Browse files Browse the repository at this point in the history
  • Loading branch information
hieronx committed Aug 15, 2024
1 parent 92dd349 commit a5d8c73
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/mappings/handlers/ethHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ async function _handleEthBlock(block: EthereumBlock): Promise<void> {
const latestNavFeed = getLatestContract(tinlakePool.navFeed, blockNumber)
const latestReserve = getLatestContract(tinlakePool.reserve, blockNumber)

if (latestNavFeed) {
if (latestNavFeed?.address) {
poolUpdateCalls.push({
id: tinlakePool.id,
type: 'currentNAV',
Expand All @@ -90,7 +90,7 @@ async function _handleEthBlock(block: EthereumBlock): Promise<void> {
result: '',
})
}
if (latestReserve) {
if (latestReserve?.address) {
poolUpdateCalls.push({
id: tinlakePool.id,
type: 'totalBalance',
Expand All @@ -112,7 +112,7 @@ async function _handleEthBlock(block: EthereumBlock): Promise<void> {
const pool = await PoolService.getOrSeed(tinlakePool?.id, false, false, blockchain.id)

// Update pool
if (callResult.type === 'currentNAV' && latestNavFeed) {
if (callResult.type === 'currentNAV' && latestNavFeed?.address) {
const currentNAV = NavfeedAbi__factory.createInterface().decodeFunctionResult(
'currentNAV',
callResult.result
Expand All @@ -123,7 +123,7 @@ async function _handleEthBlock(block: EthereumBlock): Promise<void> {
await pool.save()
logger.info(`Updating pool ${tinlakePool?.id} with portfolioValuation: ${pool.portfolioValuation}`)
}
if (callResult.type === 'totalBalance' && latestReserve) {
if (callResult.type === 'totalBalance' && latestReserve?.address) {
const totalBalance = ReserveAbi__factory.createInterface().decodeFunctionResult(
'totalBalance',
callResult.result
Expand All @@ -136,7 +136,7 @@ async function _handleEthBlock(block: EthereumBlock): Promise<void> {
}

// Update loans (only index if fully synced)
if (latestNavFeed && date.toDateString() === new Date().toDateString()) {
if (latestNavFeed?.address && date.toDateString() === new Date().toDateString()) {
await updateLoans(
tinlakePool?.id as string,
date,
Expand Down

0 comments on commit a5d8c73

Please sign in to comment.