Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove slash pool balance from total supply computation
Browse files Browse the repository at this point in the history
brentstone committed Apr 17, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 11b7e3e commit c3b6d68
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions crates/trans_token/src/storage.rs
Original file line number Diff line number Diff line change
@@ -45,7 +45,8 @@ where
Ok(balance)
}

/// Get the effective circulating total supply of native tokens.
/// Get the effective circulating total supply of native tokens. Does not
/// consider the native balance in the PGF of Slash pool addresses.
pub fn get_effective_total_native_supply<S>(
storage: &S,
) -> namada_storage::Result<token::Amount>
@@ -54,14 +55,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

0 comments on commit c3b6d68

Please sign in to comment.