mirror of
https://github.com/0x1d/drift-keeper.git
synced 2025-12-15 02:42:21 +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": {
|
"dependencies": {
|
||||||
"express": "^4.18.2",
|
"express": "^4.18.2",
|
||||||
"prom-client": "^15.1.0",
|
"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",
|
"@solana/web3.js": "^1.89.1",
|
||||||
"bigint-buffer": "^1.1.5",
|
"bigint-buffer": "^1.1.5",
|
||||||
"dotenv": "^16.4.4"
|
"dotenv": "^16.4.4"
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ app.get('/metrics/:addr?', async (req, res) => {
|
|||||||
console.log(`Gathering metrics for ${walletAddress}`);
|
console.log(`Gathering metrics for ${walletAddress}`);
|
||||||
res.setHeader('Content-Type', registry.contentType);
|
res.setHeader('Content-Type', registry.contentType);
|
||||||
|
|
||||||
registry.resetMetrics();
|
//registry.resetMetrics();
|
||||||
|
|
||||||
let [solBalance, usdcBalance, marketData] = await Promise.all([
|
let [solBalance, usdcBalance, marketData] = await Promise.all([
|
||||||
loadWalletBalance(walletAddress),
|
loadWalletBalance(walletAddress),
|
||||||
@@ -26,8 +26,11 @@ app.get('/metrics/:addr?', async (req, res) => {
|
|||||||
|
|
||||||
solBalanceMetric.set(label, extractWalletBalance(solBalance));
|
solBalanceMetric.set(label, extractWalletBalance(solBalance));
|
||||||
usdcBalanceMetric.set(label, extractUSDCBalance(usdcBalance));
|
usdcBalanceMetric.set(label, extractUSDCBalance(usdcBalance));
|
||||||
solUsdcBalanceMetric.set(label, extractWalletBalance(solBalance) * extractSOLPrice(marketData));
|
let solPrice = extractSOLPrice(marketData);
|
||||||
solPriceMetric.set(extractSOLPrice(marketData));
|
if(solPrice){
|
||||||
|
solUsdcBalanceMetric.set(label, extractWalletBalance(solBalance) * solPrice);
|
||||||
|
solPriceMetric.set(solPrice);
|
||||||
|
}
|
||||||
|
|
||||||
res.send(await registry.metrics());
|
res.send(await registry.metrics());
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ function extractUSDCBalance(usdcBalance) {
|
|||||||
|
|
||||||
// extract SOL price
|
// extract SOL price
|
||||||
function extractSOLPrice(marketData) {
|
function extractSOLPrice(marketData) {
|
||||||
return marketData.data.SOL.price;
|
return marketData.data?.SOL?.price;
|
||||||
}
|
}
|
||||||
|
|
||||||
// export functions
|
// export functions
|
||||||
|
|||||||
Reference in New Issue
Block a user