From 1ac3597538e252599dff26429ba33dc435d9e70c Mon Sep 17 00:00:00 2001 From: brentstone Date: Wed, 17 Apr 2024 13:22:16 -0700 Subject: [PATCH] remove slash pool balance from total supply computation --- crates/trans_token/src/storage.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/crates/trans_token/src/storage.rs b/crates/trans_token/src/storage.rs index 4324f0be29..4e7045c88d 100644 --- a/crates/trans_token/src/storage.rs +++ b/crates/trans_token/src/storage.rs @@ -54,14 +54,20 @@ where { let native_token = storage.get_native_token()?; let pgf_address = Address::Internal(InternalAddress::Pgf); + let slash_pool_address = Address::Internal(InternalAddress::PosSlashPool); let raw_total = read_total_supply(storage, &native_token)?; let pgf_balance = read_balance(storage, &native_token, &pgf_address)?; + let slash_pool_balance = + read_balance(storage, &native_token, &slash_pool_address)?; // Remove native balance in PGF address from the total supply - Ok(raw_total - .checked_sub(pgf_balance) - .expect("Raw total supply should be larger than PGF balance")) + let to_remove = pgf_balance + .checked_add(slash_pool_balance) + .expect("Adding PGF and Slash Pool balance should not overflow"); + Ok(raw_total.checked_sub(to_remove).expect( + "Raw total supply should be larger than PGF + Slash Pool balance", + )) } /// Read the denomination of a given token, if any. Note that native