Skip to content

Commit

Permalink
add detailed code comments for CalculateUSDValueForOperator and remov…
Browse files Browse the repository at this point in the history
…e a useless code comment in protobuf
  • Loading branch information
TimmyExogenous committed Jun 21, 2024
1 parent 693c2e5 commit 08cace9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 0 additions & 1 deletion proto/exocore/operator/v1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions x/operator/keeper/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 08cace9

Please sign in to comment.