Skip to content

Commit

Permalink
remove slash pool balance from total supply computation
Browse files Browse the repository at this point in the history
  • Loading branch information
brentstone committed Apr 17, 2024
1 parent 11b7e3e commit 1ac3597
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions crates/trans_token/src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1ac3597

Please sign in to comment.