Skip to content

Commit

Permalink
fix: mim share token name and symbol
Browse files Browse the repository at this point in the history
  • Loading branch information
0xkofee committed Jul 26, 2022
1 parent 97b48ac commit 973712a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
7 changes: 7 additions & 0 deletions src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,10 @@ export const API_VERSION_0_3_5 = '0.3.5';
export const ETH_MAINNET_NETWORK = 'mainnet';
export const FTM_MAINNET_NETWORK = 'fantom';
export const ARB_MAINNET_NETWORK = 'arbitrum-one';

// Values that are modified in the contract but don't emit an event to handle
export const shareTokenNames = new Map<string, string>();
shareTokenNames.set('0x0a0b23d9786963de69cb2447dc125c49929419d8', 'MIM yVault');

export const shareTokenSymbol = new Map<string, string>();
shareTokenNames.set('0x0a0b23d9786963de69cb2447dc125c49929419d8', 'yvMIM');
19 changes: 16 additions & 3 deletions src/utils/token.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { Address } from '@graphprotocol/graph-ts';
import { Token } from '../../generated/schema';
import { ERC20 } from '../../generated/Registry/ERC20';
import { DEFAULT_DECIMALS } from '../utils/constants';
import {
DEFAULT_DECIMALS,
shareTokenNames,
shareTokenSymbol,
} from '../utils/constants';

export function getOrCreateToken(address: Address): Token {
let id = address.toHexString();
Expand All @@ -15,8 +19,17 @@ export function getOrCreateToken(address: Address): Token {
let symbol = erc20Contract.try_symbol();
// TODO: add overrides for name and symbol
token.decimals = decimals.reverted ? DEFAULT_DECIMALS : decimals.value;
token.name = name.reverted ? '' : name.value;
token.symbol = symbol.reverted ? '' : symbol.value;
token.name = name.reverted
? shareTokenNames.has(id)
? shareTokenNames.get(id)
: ''
: name.value;
token.symbol = symbol.reverted
? shareTokenSymbol.has(id)
? shareTokenSymbol.get(id)
: ''
: symbol.value;

token.save();
}
return token as Token;
Expand Down

0 comments on commit 973712a

Please sign in to comment.