mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-18 03:41:02 +00:00
fix overflow in balance_to_point conversion (#2706)
Closes #416 As I mentioned in the above issue `balance_to_points` conversion currently overflows the `Balance` types even before computing the actual points for the given tokens. This fixes that,
This commit is contained in:
committed by
GitHub
parent
0ce506ef1b
commit
4c0e0e0713
@@ -2955,9 +2955,12 @@ impl<T: Config> Pallet<T> {
|
||||
},
|
||||
(false, false) => {
|
||||
// Equivalent to (current_points / current_balance) * new_funds
|
||||
balance(u256(current_points).saturating_mul(u256(new_funds)))
|
||||
// We check for zero above
|
||||
.div(current_balance)
|
||||
balance(
|
||||
u256(current_points)
|
||||
.saturating_mul(u256(new_funds))
|
||||
// We check for zero above
|
||||
.div(u256(current_balance)),
|
||||
)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user