Skip to content

Commit 40cd80a

Browse files
committed
add total_supply_balance_and_apy metric datapoint
1 parent 6cd67d8 commit 40cd80a

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

src/bin/sys-lend.rs

+23-3
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,19 @@ mod dp {
110110
.field("apy_bps", apy_bps as f64)
111111
}
112112

113+
pub fn total_supply_balance_and_apy(
114+
address: &Pubkey,
115+
maybe_token: MaybeToken,
116+
ui_amount: f64,
117+
apy_bps: u64,
118+
) -> metrics::Point {
119+
metrics::Point::new("sys_lend::total_supply_balance_and_apy")
120+
.tag("address", metrics::dp::pubkey_to_value(address))
121+
.tag("token", maybe_token.name())
122+
.field("amount", ui_amount)
123+
.field("apy_bps", apy_bps as f64)
124+
}
125+
113126
pub fn principal_balance_change(
114127
pool: &str,
115128
address: &Pubkey,
@@ -1057,6 +1070,15 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
10571070
}
10581071

10591072
let (total_apr, total_balance) = pools_supply_balance_apr(&supply_balance);
1073+
let total_apy = apr_to_apy(total_apr) * 100.;
1074+
1075+
metrics::push(dp::total_supply_balance_and_apy(
1076+
&address,
1077+
maybe_token,
1078+
token.ui_amount(total_balance),
1079+
(total_apy * 100.) as u64,
1080+
))
1081+
.await;
10601082

10611083
if raw && total_only {
10621084
println!("{}", token.ui_amount(total_balance));
@@ -1066,7 +1088,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
10661088
println!(
10671089
"Total supply: {} at {:.2}%",
10681090
token.format_amount(total_balance),
1069-
apr_to_apy(total_apr) * 100.
1091+
total_apy,
10701092
);
10711093

10721094
let wallet_balance = maybe_token.balance(rpc_client, &address)?;
@@ -1496,8 +1518,6 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
14961518
notifier
14971519
.send(&format!("{} via via {signature}", operation_info.op_msg))
14981520
.await;
1499-
1500-
return Ok(());
15011521
}
15021522
_ => unreachable!(),
15031523
}

0 commit comments

Comments
 (0)