From 3999c649f3bfa15b630808fe11473accda76cce4 Mon Sep 17 00:00:00 2001 From: Dirk Brink Date: Mon, 10 Jun 2024 12:44:53 +0100 Subject: [PATCH] node: Token generator script flags tokens with changed symbols --- node/hack/governor/src/index.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/node/hack/governor/src/index.ts b/node/hack/governor/src/index.ts index 54a38dd5f1..3e1d8ad127 100644 --- a/node/hack/governor/src/index.ts +++ b/node/hack/governor/src/index.ts @@ -93,6 +93,7 @@ axios var significantPriceChanges = []; var addedTokens = []; var removedTokens = []; + var changedSymbols = []; var newTokensCount = 0; for (let chain in res.data.AllTime) { @@ -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; } } @@ -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 @@ -243,6 +252,8 @@ axios changedContent += JSON.stringify(addedTokens, null, 1); changedContent += "\n\nTokens removed = " + removedTokens.length + ":\n--\n\n"; changedContent += JSON.stringify(removedTokens, null, 1); + changedContent += "\n\nTokens with changed symbols = " + changedSymbols.length + ":\n--->\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```";