File tree 1 file changed +4
-4
lines changed
crates/shielded_token/src
1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -107,11 +107,11 @@ where
107
107
storage. read ( & reward_precision_key) ?. map_or_else (
108
108
|| -> Result < u128 > {
109
109
// Since reading reward precision has failed, choose a
110
- // thousandth of the given token
110
+ // thousandth of the given token. But clamp the precision above
111
+ // by 10^38, the maximum power of 10 that can be contained by a
112
+ // u128.
111
113
let precision_denom =
112
- std:: cmp:: max ( u32:: from ( denomination. 0 ) , 3 )
113
- . checked_sub ( 3 )
114
- . expect ( "Cannot underflow" ) ;
114
+ u32:: from ( denomination. 0 ) . saturating_sub ( 3 ) . clamp ( 0 , 38 ) ;
115
115
let reward_precision = checked ! ( 10u128 ^ precision_denom) ?;
116
116
// Record the precision that is now being used so that it does
117
117
// not have to be recomputed each time, and to
You can’t perform that action at this time.
0 commit comments