Skip to content

Commit

Permalink
node: Token generator script flags tokens with changed symbols
Browse files Browse the repository at this point in the history
  • Loading branch information
djb15 committed Jun 10, 2024
1 parent 0e2ba62 commit 33b2fbe
Showing 1 changed file with 13 additions and 2 deletions.
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

0 comments on commit 33b2fbe

Please sign in to comment.