Skip to content

Commit 694b2ef

Browse files
committed
fix type indexing when upgrading ERC20 to another type
1 parent 1db1a74 commit 694b2ef

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/ERC20.mapping.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,13 @@ import {
5050
import { CommissionSharesSold, ExitedCommissionShares } from '../generated/templates/ERC1155/Liquid1155';
5151
import { getOrCreateBalance } from './vPool.mapping';
5252
import { pushEntryToSummaries } from './utils/rewards';
53+
import { Upgraded } from '../generated/templates/TUPProxy/TUPProxy';
54+
import { IntegrationChannel } from '../generated/schema';
55+
import {
56+
CHANNEL_LIQUID_20_A_vPOOL_BYTES32,
57+
CHANNEL_LIQUID_20_C_vPOOL_BYTES32,
58+
CHANNEL_NATIVE_20_vPOOL_BYTES32
59+
} from './utils/IntegrationChannel.utils';
5360

5461
function snapshotSupply(event: ethereum.Event): void {
5562
const blockId = event.block.number;
@@ -703,3 +710,18 @@ export function handleSetPoolPercentages(event: SetPoolPercentages): void {
703710
pool!.save();
704711
}
705712
}
713+
714+
export function handleUpgraded(event: Upgraded): void {
715+
const erc20 = ERC20.load(event.address);
716+
717+
if (event.params.implementation.equals(IntegrationChannel.load(CHANNEL_NATIVE_20_vPOOL_BYTES32).implementation)) {
718+
erc20!.type = 'Native20';
719+
} else if (event.params.implementation.equals(IntegrationChannel.load(CHANNEL_LIQUID_20_A_vPOOL_BYTES32).implementation)) {
720+
erc20!.type = 'Liquid20A';
721+
} else if (event.params.implementation.equals(IntegrationChannel.load(CHANNEL_LIQUID_20_C_vPOOL_BYTES32).implementation)) {
722+
erc20!.type = 'Liquid20C';
723+
}
724+
erc20!.editedAt = event.block.timestamp;
725+
erc20!.editedAtBlock = event.block.number;
726+
erc20!.save();
727+
}

0 commit comments

Comments
 (0)