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: Governor token list update #4253

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
18 changes: 10 additions & 8 deletions node/hack/governor/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const expectedUSDDepeggs = [
"13-000000000000000000000000754288077d0ff82af7a5317c7cb8c444d421d103-oUSDC", // Orbit bridge Klatyn USDC, depegged since December 2023
"13-000000000000000000000000cee8faf64bb97a73bb51e115aa89c17ffa8dd167-oUSDT", // Orbit bridge Klatyn USDT, depegged since December 2023
"16-000000000000000000000000ffffffff52c56a9257bb97f4b2b6f7b2d624ecda-xcaUSD", // Acala USD being converted to aSEED, dead token
"1-689ac099ef657e5d3b7efaf1e36ab8b897e2746232d8a9261b3e49b35c1dead4-xUSD", // Synthetic USD is inactive and deactivated
]

const axios = require("axios");
Expand Down Expand Up @@ -203,7 +204,7 @@ axios

// If the character list is violated, then skip the coin. The error is logged in the function if something happens to have some sort of check on it.
if(!(safetyCheck(chain, wormholeAddr, data.Symbol, data.CoinGeckoId, data.TokenDecimals, data.TokenPrice, data.Address, notional))){
failedInputValidationTokens.push(chain + "-" + wormholeAddr + "-" + data.symbol)
failedInputValidationTokens.push(chain + "-" + wormholeAddr + "-" + data.symbol + " (https://www.coingecko.com/en/coins/" + data.CoinGeckoId + ")")
continue;
}
}
Expand All @@ -215,14 +216,14 @@ axios
var uniqueIdentifier = chain + "-" + wormholeAddr + "-" + data.Symbol;
// Skip tokens that are not expected to be pegged to $1
if (!expectedUSDDepeggs.includes(uniqueIdentifier)) {
depeggedUSDStablecoins.push(uniqueIdentifier + " = " + data.TokenPrice);
depeggedUSDStablecoins.push(uniqueIdentifier + " = " + data.TokenPrice + " (https://www.coingecko.com/en/coins/" + data.CoinGeckoId + ")");
}
}
}

// This is a new token
if (existingTokenPrices[chain] == undefined || existingTokenPrices[chain][wormholeAddr] == undefined) {
addedTokens.push(chain + "-" + wormholeAddr + "-" + data.Symbol);
addedTokens.push(chain + "-" + wormholeAddr + "-" + data.Symbol + " (https://www.coingecko.com/en/coins/" + data.CoinGeckoId + ")");
}
// This is an existing token
else {
Expand All @@ -234,7 +235,8 @@ axios
token: chain + "-" + wormholeAddr + "-" + data.Symbol,
previousPrice: previousPrice,
newPrice: data.TokenPrice,
percentageChange: "-" + (100 - (data.TokenPrice / previousPrice) * 100).toFixed(1).toString()
percentageChange: "-" + (100 - (data.TokenPrice / previousPrice) * 100).toFixed(1).toString(),
url: "https://www.coingecko.com/en/coins/" + data.CoinGeckoId
});
}

Expand Down Expand Up @@ -274,7 +276,7 @@ axios

// We add in the "=" character to ensure an undefined symbol
// does not mess up the removed tokens logic
newTokenKeys[chain + "-" + wormholeAddr] = "=" + data.Symbol;
newTokenKeys[chain + "-" + wormholeAddr] = ["=" + data.Symbol, data.CoinGeckoId];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If data.Symbol is undefined, is this line going to hide that? It might make it look like data.CoinGeckId is the symbol.
It might be worth replacing data.Symbol with a string like UNDEFINED manually if it doesn't exist rather than use an empty string (which I assume is what happens now)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might be misunderstanding but I don't think this is true? The symbol logic is identical to before, I've just changed the mapping from string=>string to string=>[string, string]. And I index into the array with the changes below

newTokensCount += 1;
}
}
Expand All @@ -287,12 +289,12 @@ axios
var tokenParts = token.split("-");
var newTokenSymbol = newTokenKeys[tokenParts[0] + "-" + tokenParts[1]];
if (!newTokenSymbol) {
removedTokens.push(token);
removedTokens.push(token + " (https://www.coingecko.com/en/coins/" + newTokenSymbol[1] + ")");
}
// 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.substring(1));
else if (tokenParts[0] + "-" + tokenParts[1] + "-" + newTokenSymbol[0].substring(1) != token) {
changedSymbols.push(token + "->" + newTokenSymbol[0].substring(1) + " (https://www.coingecko.com/en/coins/" + newTokenSymbol[1] + ")");
}
}

Expand Down
Loading
Loading