diff --git a/proto/exocore/operator/v1/query.proto b/proto/exocore/operator/v1/query.proto index 114d66458..7dd6b8cf0 100644 --- a/proto/exocore/operator/v1/query.proto +++ b/proto/exocore/operator/v1/query.proto @@ -39,7 +39,6 @@ message OperatorAVSAddressDetails { string avs_address = 2 [(gogoproto.customname) = "AVSAddress"]; } -// QueryOperatorConsKeyRequest is a request to obtain the consensus public key of the operator. // QueryOperatorUSDValueRequest is the request to obtain the USD value for operator. message QueryOperatorUSDValueRequest { // details is the operator and AVS address diff --git a/x/operator/keeper/abci.go b/x/operator/keeper/abci.go index 4a8ed1f92..cde1a9a86 100644 --- a/x/operator/keeper/abci.go +++ b/x/operator/keeper/abci.go @@ -11,6 +11,18 @@ import ( // CalculateUSDValueForOperator calculates the total and self usd value for the // operator according to the input assets filter and prices. +// This function will be used in slashing calculations and voting power updates per epoch. +// The inputs/outputs and calculation logic for these two cases are different, +// so an `isForSlash` flag is used to distinguish between them. +// When it's called by the voting power update, the needed outputs are the current total +// staking amount and the self-staking amount of the operator. The current total +// staking amount excludes the pending unbonding amount, so it's used to calculate the voting power. +// The self-staking amount is also needed to check if the operator's self-staking is sufficient. +// At the same time, the prices of all assets have been retrieved in the caller's function, so they +// are inputted as a parameter. +// When it's called by the slash execution, the needed output is the sum of the current total amount and +// the pending unbonding amount, because the undelegation also needs to be slashed. And the prices of +// all assets haven't been prepared by the caller, so the prices should be retrieved in this function. func (k *Keeper) CalculateUSDValueForOperator( ctx sdk.Context, isForSlash bool,