Skip to content

Commit

Permalink
fix type indexing when upgrading ERC20 to another type
Browse files Browse the repository at this point in the history
  • Loading branch information
0xvv committed Mar 25, 2024
1 parent 1db1a74 commit 694b2ef
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/ERC20.mapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ import {
import { CommissionSharesSold, ExitedCommissionShares } from '../generated/templates/ERC1155/Liquid1155';
import { getOrCreateBalance } from './vPool.mapping';
import { pushEntryToSummaries } from './utils/rewards';
import { Upgraded } from '../generated/templates/TUPProxy/TUPProxy';
import { IntegrationChannel } from '../generated/schema';
import {
CHANNEL_LIQUID_20_A_vPOOL_BYTES32,
CHANNEL_LIQUID_20_C_vPOOL_BYTES32,
CHANNEL_NATIVE_20_vPOOL_BYTES32
} from './utils/IntegrationChannel.utils';

function snapshotSupply(event: ethereum.Event): void {
const blockId = event.block.number;
Expand Down Expand Up @@ -703,3 +710,18 @@ export function handleSetPoolPercentages(event: SetPoolPercentages): void {
pool!.save();
}
}

export function handleUpgraded(event: Upgraded): void {
const erc20 = ERC20.load(event.address);

if (event.params.implementation.equals(IntegrationChannel.load(CHANNEL_NATIVE_20_vPOOL_BYTES32).implementation)) {
erc20!.type = 'Native20';
} else if (event.params.implementation.equals(IntegrationChannel.load(CHANNEL_LIQUID_20_A_vPOOL_BYTES32).implementation)) {
erc20!.type = 'Liquid20A';
} else if (event.params.implementation.equals(IntegrationChannel.load(CHANNEL_LIQUID_20_C_vPOOL_BYTES32).implementation)) {
erc20!.type = 'Liquid20C';
}
erc20!.editedAt = event.block.timestamp;
erc20!.editedAtBlock = event.block.number;
erc20!.save();
}

0 comments on commit 694b2ef

Please sign in to comment.