import { MarketEntered , MarketExited , NewCloseFactor , NewCollateralFactor , NewLiquidationIncentive , NewMaxAssets , NewPriceOracle , } from '../types/comptroller/Comptroller' ; import { Market , Comptroller } from '../types/schema' ; import { mantissaFactorBD , updateCommonCTokenStats } from './helpers' ; export function handleMarketEntered ( event ) { let market = Market . load ( event . params . cToken . toHexString ( ) ) ; let accountID = event . params . account . toHex ( ) ; let cTokenStats = updateCommonCTokenStats ( market . id , market . symbol , accountID , event . transaction . hash , event . block . timestamp . toI32 ( ) , event . block . number . toI32 ( ) ) ; cTokenStats . enteredMarket = true ; cTokenStats . save ( ) ; } export function handleMarketExited ( event ) { let market = Market . load ( event . params . cToken . toHexString ( ) ) ; let accountID = event . params . account . toHex ( ) ; let cTokenStats = updateCommonCTokenStats ( market . id , market . symbol , accountID , event . transaction . hash , event . block . timestamp . toI32 ( ) , event . block . number . toI32 ( ) ) ; cTokenStats . enteredMarket = false ; cTokenStats . save ( ) ; } export function handleNewCloseFactor ( event ) { let comptroller = Comptroller . load ( '1' ) ; comptroller . closeFactor = event . params . newCloseFactorMantissa ; comptroller . save ( ) ; } export function handleNewCollateralFactor ( event ) { let market = Market . load ( event . params . cToken . toHexString ( ) ) ; market . collateralFactor = event . params . newCollateralFactorMantissa . toBigDecimal ( ) . div ( mantissaFactorBD ) ; market . save ( ) ; } export function handleNewLiquidationIncentive ( event ) { let comptroller = Comptroller . load ( '1' ) ; comptroller . liquidationIncentive = event . params . newLiquidationIncentiveMantissa ; comptroller . save ( ) ; } export function handleNewMaxAssets ( event ) { let comptroller = Comptroller . load ( '1' ) ; comptroller . maxAssets = event . params . newMaxAssets ; comptroller . save ( ) ; } export function handleNewPriceOracle ( event ) { let comptroller = Comptroller . load ( '1' ) ; if ( comptroller == null ) { comptroller = new Comptroller ( '1' ) ; } comptroller . priceOracle = event . params . newPriceOracle ; comptroller . save ( ) ; }