import { Address } from '@graphprotocol/graph-ts' ; import { Pool } from '../../generated/schema' ; import { LendingPoolAddressesProvider } from '../../generated/templates' ; import { AddressesProviderRegistered , AddressesProviderUnregistered , } from '../../generated/LendingPoolAddressesProviderRegistry/LendingPoolAddressesProviderRegistry' ; import { getProtocol } from '../helpers/initializers' ; export function handleAddressesProviderRegistered ( event ) { let protocol = getProtocol ( ) ; let address = event . params . newAddress . toHexString ( ) ; if ( Pool . load ( address ) == null ) { let pool = new Pool ( address ) ; pool . protocol = protocol . id ; pool . active = true ; pool . paused = false ; pool . lastUpdateTimestamp = event . block . timestamp . toI32 ( ) ; pool . save ( ) ; LendingPoolAddressesProvider . create ( Address . fromString ( address ) ) ; } } export function handleAddressesProviderUnregistered ( event ) { let pool = Pool . load ( event . params . newAddress . toHexString ( ) ) ; pool . active = false ; pool . save ( ) ; }