mukan-core/x/qpos/keeper/voting.go
Mukan Erkin Törük 02226c4bd9
Some checks are pending
/ might_release (push) Waiting to run
initial: sovereign Mukan Network fork
2026-05-11 03:18:23 +03:00

27 lines
562 B
Go

package keeper
import (
"context"
"math"
sdk "github.com/cosmos/cosmos-sdk/types"
)
// GetVotingPower calculates the quadratic voting power of an address.
// Voting Power = sqrt(MC Amount)
func (k Keeper) GetVotingPower(ctx context.Context, address string) float64 {
sdkCtx := sdk.UnwrapSDKContext(ctx)
accAddr, err := k.addressCodec.StringToBytes(address)
if err != nil {
return 0
}
balance := k.bankKeeper.GetBalance(sdkCtx, accAddr, "umc")
amount := balance.Amount.Int64()
if amount <= 0 {
return 0
}
return math.Sqrt(float64(amount))
}