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 the useless code comment
  • Loading branch information
TimmyExogenous committed Jun 21, 2024
1 parent 693c2e5 commit 6931786
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
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
1 change: 0 additions & 1 deletion x/operator/keeper/usd_value.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ func (k *Keeper) BatchUpdateUSDValueForAVSAndOperator(ctx sdk.Context, avsOperat
// GetAVSUSDValue is a function to retrieve the USD share of specified Avs,
// The key and value to retrieve is:
// AVSAddr -> types.DecValueField(the total USD share of specified Avs)
// It hasn't been used now. but it can serve as an RPC in the future.
func (k *Keeper) GetAVSUSDValue(ctx sdk.Context, avsAddr string) (sdkmath.LegacyDec, error) {
store := prefix.NewStore(
ctx.KVStore(k.storeKey),
Expand Down

0 comments on commit 6931786

Please sign in to comment.