mirror of
https://github.com/0x1d/drift-keeper.git
synced 2025-12-14 10:26:49 +01:00
Fix missing SOL price metrics
This commit is contained in:
838
user-metrics/package-lock.json
generated
838
user-metrics/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -12,7 +12,7 @@
|
||||
"dependencies": {
|
||||
"express": "^4.18.2",
|
||||
"prom-client": "^15.1.0",
|
||||
"@drift-labs/sdk": "2.78.0-beta.0",
|
||||
"@drift-labs/sdk": "2.93.0-beta.0",
|
||||
"@solana/web3.js": "^1.89.1",
|
||||
"bigint-buffer": "^1.1.5",
|
||||
"dotenv": "^16.4.4"
|
||||
|
||||
@@ -15,7 +15,7 @@ app.get('/metrics/:addr?', async (req, res) => {
|
||||
console.log(`Gathering metrics for ${walletAddress}`);
|
||||
res.setHeader('Content-Type', registry.contentType);
|
||||
|
||||
registry.resetMetrics();
|
||||
//registry.resetMetrics();
|
||||
|
||||
let [solBalance, usdcBalance, marketData] = await Promise.all([
|
||||
loadWalletBalance(walletAddress),
|
||||
@@ -26,8 +26,11 @@ app.get('/metrics/:addr?', async (req, res) => {
|
||||
|
||||
solBalanceMetric.set(label, extractWalletBalance(solBalance));
|
||||
usdcBalanceMetric.set(label, extractUSDCBalance(usdcBalance));
|
||||
solUsdcBalanceMetric.set(label, extractWalletBalance(solBalance) * extractSOLPrice(marketData));
|
||||
solPriceMetric.set(extractSOLPrice(marketData));
|
||||
let solPrice = extractSOLPrice(marketData);
|
||||
if(solPrice){
|
||||
solUsdcBalanceMetric.set(label, extractWalletBalance(solBalance) * solPrice);
|
||||
solPriceMetric.set(solPrice);
|
||||
}
|
||||
|
||||
res.send(await registry.metrics());
|
||||
});
|
||||
|
||||
@@ -59,7 +59,7 @@ function extractUSDCBalance(usdcBalance) {
|
||||
|
||||
// extract SOL price
|
||||
function extractSOLPrice(marketData) {
|
||||
return marketData.data.SOL.price;
|
||||
return marketData.data?.SOL?.price;
|
||||
}
|
||||
|
||||
// export functions
|
||||
|
||||
Reference in New Issue
Block a user