Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: mim share token name and symbol #181

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,10 @@ export const ETH_MAINNET_NETWORK = 'mainnet';
export const FTM_MAINNET_NETWORK = 'fantom';
export const ARB_MAINNET_NETWORK = 'arbitrum-one';
export const OPS_MAINNET_NETWORK = 'optimism';

// 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