11import { Initialized as ATokenInitialized } from '../../../generated/templates/AToken/AToken' ;
22import { Initialized as VTokenInitialized } from '../../../generated/templates/VariableDebtToken/VariableDebtToken' ;
33import { Initialized as STokenInitialized } from '../../../generated/templates/StableDebtToken/StableDebtToken' ;
4- import { RewardsController } from '../../../generated/templates' ;
54
65import { Address , log } from '@graphprotocol/graph-ts' ;
7- import { zeroAddress } from '../../utils/converters' ;
8- import {
9- ContractToPoolMapping ,
10- RewardsController as RewardsControllerEntity ,
11- MapAssetPool ,
12- } from '../../../generated/schema' ;
6+ import { ContractToPoolMapping , MapAssetPool } from '../../../generated/schema' ;
137export {
148 handleATokenBurn ,
159 handleATokenMint ,
@@ -22,28 +16,7 @@ export {
2216 handleVariableTokenBorrowAllowanceDelegated ,
2317} from './tokenization-v3' ;
2418
25- function createIncentivesController (
26- asset : Address ,
27- incentivesController : Address ,
28- underlyingAsset : Address ,
29- pool : Address
30- ) : void {
31- if ( incentivesController == zeroAddress ( ) ) {
32- log . warning ( 'Incentives controller is 0x0 for asset: {} | underlyingasset: {} | pool: {}' , [
33- asset . toHexString ( ) ,
34- underlyingAsset . toHexString ( ) ,
35- pool . toHexString ( ) ,
36- ] ) ;
37- return ;
38- }
39-
40- let iController = RewardsControllerEntity . load ( incentivesController . toHexString ( ) ) ;
41- if ( ! iController ) {
42- iController = new RewardsControllerEntity ( incentivesController . toHexString ( ) ) ;
43- iController . save ( ) ;
44- RewardsController . create ( incentivesController ) ;
45- }
46-
19+ function initializeToken ( asset : Address , underlyingAsset : Address , pool : Address ) : void {
4720 let poolAddressProvider = ContractToPoolMapping . load ( pool . toHexString ( ) ) ;
4821 if ( poolAddressProvider != null ) {
4922 // save asset pool mapping
@@ -66,28 +39,13 @@ function createIncentivesController(
6639
6740export function handleATokenInitialized ( event : ATokenInitialized ) : void {
6841 log . error ( 'asset: {}' , [ event . address . toHexString ( ) ] ) ;
69- createIncentivesController (
70- event . address ,
71- event . params . incentivesController ,
72- event . params . underlyingAsset ,
73- event . params . pool
74- ) ;
42+ initializeToken ( event . address , event . params . underlyingAsset , event . params . pool ) ;
7543}
7644
7745export function handleSTokenInitialized ( event : STokenInitialized ) : void {
78- createIncentivesController (
79- event . address ,
80- event . params . incentivesController ,
81- event . params . underlyingAsset ,
82- event . params . pool
83- ) ;
46+ initializeToken ( event . address , event . params . underlyingAsset , event . params . pool ) ;
8447}
8548
8649export function handleVTokenInitialized ( event : VTokenInitialized ) : void {
87- createIncentivesController (
88- event . address ,
89- event . params . incentivesController ,
90- event . params . underlyingAsset ,
91- event . params . pool
92- ) ;
50+ initializeToken ( event . address , event . params . underlyingAsset , event . params . pool ) ;
9351}
0 commit comments