Skip to content

Commit

Permalink
rebase to develop and use AddMut in CalculateUSDValueForOperator
Browse files Browse the repository at this point in the history
  • Loading branch information
TimmyExogenous committed Feb 18, 2025
1 parent eb328ee commit 97a3e32
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions x/operator/keeper/usd_value.go
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ func (k *Keeper) CalculateUSDValueForOperator(
decimal = assetInfo.AssetBasicInfo.Decimals
usdValue := CalculateUSDValue(state.TotalAmount.Add(state.PendingUndelegationAmount), price.Value, decimal, price.Decimal)
ctx.Logger().Info("CalculateUSDValueForOperator: get price for slash", "assetID", assetID, "assetDecimal", decimal, "price", price, "totalAmount", state.TotalAmount, "pendingUndelegationAmount", state.PendingUndelegationAmount, "StakingAndWaitUnbonding", ret.StakingAndWaitUnbonding, "addUSDValue", usdValue)
ret.StakingAndWaitUnbonding = ret.StakingAndWaitUnbonding.Add(usdValue)
ret.StakingAndWaitUnbonding.AddMut(usdValue)
} else {
if prices == nil {
return errorsmod.Wrap(operatortypes.ErrValueIsNilOrZero, "CalculateUSDValueForOperator prices map is nil")
Expand All @@ -405,13 +405,13 @@ func (k *Keeper) CalculateUSDValueForOperator(
if !ok {
return errorsmod.Wrap(operatortypes.ErrKeyNotExistInMap, "CalculateUSDValueForOperator map: decimals, key: assetID")
}
ret.Staking = ret.Staking.Add(CalculateUSDValue(state.TotalAmount, price.Value, decimal, price.Decimal))
ret.Staking.AddMut(CalculateUSDValue(state.TotalAmount, price.Value, decimal, price.Decimal))
// calculate the token amount from the share for the operator
selfAmount, err := delegationkeeper.TokensFromShares(state.OperatorShare, state.TotalShare, state.TotalAmount)
if err != nil {
return err
}
ret.SelfStaking = ret.SelfStaking.Add(CalculateUSDValue(selfAmount, price.Value, decimal, price.Decimal))
ret.SelfStaking.AddMut(CalculateUSDValue(selfAmount, price.Value, decimal, price.Decimal))
}
return nil
}
Expand Down

0 comments on commit 97a3e32

Please sign in to comment.