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

node: Token generator script flags tokens with changed symbols #3976

Merged
merged 1 commit into from
Jun 10, 2024
Merged
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
15 changes: 13 additions & 2 deletions node/hack/governor/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ axios
var significantPriceChanges = [];
var addedTokens = [];
var removedTokens = [];
var changedSymbols = [];
var newTokensCount = 0;

for (let chain in res.data.AllTime) {
Expand Down Expand Up @@ -215,7 +216,9 @@ axios
notional +
"\n";

newTokenKeys[chain + "-" + wormholeAddr] = true;
// We add in the "=" character to ensure an undefined symbol
// does not mess up the removed tokens logic
newTokenKeys[chain + "-" + wormholeAddr] = "=" + data.Symbol;
newTokensCount += 1;
}
}
Expand All @@ -226,9 +229,15 @@ axios
// A token has been removed from the token list
// We cut the symbol off the end of the key as it's possible for a token to change its symbol
var tokenParts = token.split("-");
if (!newTokenKeys[tokenParts[0] + "-" + tokenParts[1]]) {
var newTokenSymbol = newTokenKeys[tokenParts[0] + "-" + tokenParts[1]];
if (!newTokenSymbol) {
removedTokens.push(token);
}
// The token symbol has changed
// We take a substring of the symbol to cut the "=" character we added above
else if (tokenParts[0] + "-" + tokenParts[1] + "-" + newTokenSymbol.substring(1) != token) {
changedSymbols.push(token + "->" + newTokenSymbol);
}
}

// Sanity check to make sure the script is doing what we think it is
Expand All @@ -243,6 +252,8 @@ axios
changedContent += JSON.stringify(addedTokens, null, 1);
changedContent += "\n\nTokens removed = " + removedTokens.length + ":\n<WH_chain_id>-<WH_token_addr>-<token_symbol>\n\n";
changedContent += JSON.stringify(removedTokens, null, 1);
changedContent += "\n\nTokens with changed symbols = " + changedSymbols.length + ":\n<WH_chain_id>-<WH_token_addr>-<old_token_symbol>-><new_token_symbol>\n\n";
changedContent += JSON.stringify(changedSymbols, null, 1);
changedContent += "\n\nTokens with significant price drops (>" + PriceDeltaTolerance + "%) = " + significantPriceChanges.length + ":\n\n"
changedContent += JSON.stringify(significantPriceChanges, null, 1);
changedContent += "\n```";
Expand Down
Loading