From fa06394da9443dc7711af91d50c7318852a056ed Mon Sep 17 00:00:00 2001 From: Mikhail Kornilov Date: Mon, 12 Oct 2020 15:15:14 +0300 Subject: [PATCH] [Release] Cosmos SDK version bump (#217) * simulator: readme added, refactoring, new Cosmos SDK query results added to the report * Cosmos SDK version bump * genesis update: LPRation 1.0 -> 2.0 --- cmd/config/genesis/genesis.go | 2 +- go.mod | 2 +- go.sum | 2 + helpers/tests/simulator/README.md | 148 ++++++++++++++++++ helpers/tests/simulator/inflation_test.go | 70 ++++----- helpers/tests/simulator/sim.go | 30 ++-- helpers/tests/simulator/sim_ops_delegate.go | 4 +- helpers/tests/simulator/sim_ops_redelegate.go | 6 +- .../simulator/sim_ops_rewards_delegator.go | 60 +++---- .../tests/simulator/sim_ops_rewards_lock.go | 3 +- .../simulator/sim_ops_rewards_validator.go | 53 ++++--- helpers/tests/simulator/sim_ops_undelegate.go | 6 +- helpers/tests/simulator/sim_queries.go | 24 +++ helpers/tests/simulator/sim_report.go | 59 +++++-- helpers/tests/simulator/sim_report_csv.go | 73 ++++++--- 15 files changed, 406 insertions(+), 136 deletions(-) create mode 100644 helpers/tests/simulator/README.md diff --git a/cmd/config/genesis/genesis.go b/cmd/config/genesis/genesis.go index 85ea04be..8b254f89 100644 --- a/cmd/config/genesis/genesis.go +++ b/cmd/config/genesis/genesis.go @@ -101,7 +101,7 @@ func OverrideGenesisStateDefaults(cdc *codec.Codec, genState map[string]json.Raw // moduleState.Params.BondDenom = defaults.StakingDenom moduleState.Params.LPDenom = defaults.LiquidityProviderDenom - moduleState.Params.LPDistrRatio = sdk.NewDecWithPrec(1, 0) // 100% + moduleState.Params.LPDistrRatio = sdk.NewDecWithPrec(2, 0) // 200% // moduleState.Params.MinSelfDelegationLvl = defaults.MinSelfDelegationCoin.Amount // 2500.0 moduleState.Params.MaxDelegationsRatio = sdk.NewDecWithPrec(10, 0) // 10.0 diff --git a/go.mod b/go.mod index 55f57d85..57951703 100644 --- a/go.mod +++ b/go.mod @@ -2,7 +2,7 @@ module github.com/dfinance/dnode go 1.14 -replace github.com/cosmos/cosmos-sdk => github.com/dfinance/cosmos-sdk v0.38.4-0.20201006151646-1ac22b3a4a09 +replace github.com/cosmos/cosmos-sdk => github.com/dfinance/cosmos-sdk v0.38.4-0.20201009185146-b579213ebb05 // Local development option //replace github.com/cosmos/cosmos-sdk => /Users/boris/go/src/github.com/dfinance/cosmos-sdk diff --git a/go.sum b/go.sum index 46e9fad1..3a09ec5c 100644 --- a/go.sum +++ b/go.sum @@ -154,6 +154,8 @@ github.com/dfinance/cosmos-sdk v0.38.4-0.20201002151830-6c83c28b89f4 h1:sUQDCT0d github.com/dfinance/cosmos-sdk v0.38.4-0.20201002151830-6c83c28b89f4/go.mod h1:6A7WcR5vEsVN5MSi5gkMJmJIMulHZftD7q63tBdt2r0= github.com/dfinance/cosmos-sdk v0.38.4-0.20201006151646-1ac22b3a4a09 h1:hNzQYh6QR6K097fL0HYDtgfyN2KgUXLu17/zRxSJezc= github.com/dfinance/cosmos-sdk v0.38.4-0.20201006151646-1ac22b3a4a09/go.mod h1:6A7WcR5vEsVN5MSi5gkMJmJIMulHZftD7q63tBdt2r0= +github.com/dfinance/cosmos-sdk v0.38.4-0.20201008094428-b46810ed3864/go.mod h1:6A7WcR5vEsVN5MSi5gkMJmJIMulHZftD7q63tBdt2r0= +github.com/dfinance/cosmos-sdk v0.38.4-0.20201009185146-b579213ebb05/go.mod h1:6A7WcR5vEsVN5MSi5gkMJmJIMulHZftD7q63tBdt2r0= github.com/dfinance/dvm-proto/go v0.0.0-20200819065410-6b70956c85de h1:PZfrjeOs9epAU0n+FpX/JAr/e+5m5/GdfUsgtO8gCOY= github.com/dfinance/dvm-proto/go v0.0.0-20200819065410-6b70956c85de/go.mod h1:Vt1T0G56AYXbsduNKzSkq1RDTNa8PFraSqB9DaTCV0U= github.com/dfinance/glav v0.0.0-20200814081332-c4701f6c12a6 h1:fZIYncA5BRad0+YnP88cfBfo0ZPgxPSVeuh/jvoGrLc= diff --git a/helpers/tests/simulator/README.md b/helpers/tests/simulator/README.md new file mode 100644 index 00000000..494fbc92 --- /dev/null +++ b/helpers/tests/simulator/README.md @@ -0,0 +1,148 @@ +# Simulation parameters + +Simulation: +* `ID` - simulation id; +* `SimDuration` - simulation duration; +* `BlockTimeMin` - minimum block duration; +* `BlockTimeMax` - maximum block duration; + +Account balances: +* `MainTokens` - initial account balance for main tokens (`xfi`); +* `StakingTokens` - initial account balance for staking tokens (`sxfi`); +* `LPTokens` - initial account balance for LP tokens (`lpt`); + +Validators: +* `PoA validator` - number of PegZone validators, ATM has no influence on simulation; +* `TM validators (total)` - total number of PoS validators (some of them might become `unbonded`); +* `TM validators (active)` - number of active PoS validators (they would be `bonded`); + +`DelegateBondingOp` / `DelegateLPOp` operation: +* `Delegate bonding/LP tokens every` - period of operation in simulated time; +* `Delegate amount ratio (of acc balance)` - % of account balance for delegation; +* `Max limit ratio (staked ratio)` - operation limit: % of staked tokens to total tokens supply; + +`RedelegateBondingOp` / `RedelegateLPOp` operation: +* `Redelegate bonding/LP tokens every` - period of operation in simulated time; +* `Redelegate amount ratio (of del shares)` - % of delegation shares for redelegation; + +`UndelegateBondingOp` / `UndelegateLPOp` operation: +* `Undelegate bonding/LP tokens every` - period of operation in simulated time; +* `Undelegate amount ratio (of del shares)` - % of delegation shares for undelegation; + +`ValidatorRewardOp` operation: +* `Withdraw all validators comissions every` - period of operation in simulated time; + +`DelegatorRewardOp` operation: +* `Withdraw all delegators rewards every` - period of operation in simulated time; + +`LockValidatorRewardsOp` operation: +* `Lock rewards every` - period of operation in simulated time; +* `Ratio of all validators` - operation limit: % of all validators to lock rewards; + +# Operations + +## `DelegateBondingOp` / `DelegateLPOp` operation + +Picks a validator and searches for an account to delegate bonding tokens. +* SelfStake increment is allowed; +* Delegation amount = current account balance * {delegateRatio}; +* Delegation is allowed if ratio (current staking bonding pools supply / total bonding tokens supply) < {maxBondingRatio}; + +Op priorities: +- validator: + - bonded; + - lowest bonding tokens amount; +- account: + - highest bonding tokens balance; + - enough coins; + +## `RedelegateBondingOp` / `RedelegateLPOp` operation + +* Picks a validator and redelegate bonding tokens to an other validator; +* Redelegation amount = current account delegation amount * {redelegateRatio}; + +Op priorities: +- dstValidator: + - bonded; + - lowest bonding tokens amount; +- srcValidator - highest account delegation bonding shares; +- account: + - random; + - has no active redelegations with srcValidator and dstValidator; + - has enough bonding coins; + - not a dstValidator owner; + +## `UndelegateBondingOp` / `UndelegateLPOp` operation + +Picks a validator and undelegates bonding tokens. +* Undelegation amount = current account delegation amount * {undelegateRatio}. + +Op priorities: +- validator - highest bonding tokens amount (all statuses); +- account: + - random; + - has a validators bonding delegation; + - not a validator owner; + +## `ValidatorRewardOp` operation + +Takes all validators commissions rewards. + +## `DelegatorRewardOp` operation + +Takes all delegators rewards (excluding locked ones). + +## `LockValidatorRewardsOp` operation + +Takes validator commissions rewards. + +Op priority: +- validator - random; + +# CSV report + +Report item is generated every simulated day. + +* `BlockHeight` - block height; +* `BlockTime` - block time; +* `SimDuration` - simulation time (real world time); +* `Validators: Bonded` - number of `bonded` PoS validator; +* `Validators: Unbonding` - number of `unbonding` PoS validator;; +* `Validators: Unbonded` - number of `unbonded` PoS validator;; +* `Staking: Bonded` - amount of bonded staking tokens (`bonded` validators); +* `Staking: NotBonded` - amount of not-bonded staking tokens (`unbonding`/`unbonded` validators); +* `Staking: LPs` - amount of staked LP tokens; +* `Staking: ActiveRedelegations` - number of current redelegations; +* `Mint: MinInflation` - minimum inflation rate; +* `Mint: MaxInflation` - maximum inflation rate; +* `Mint: AnnualProvision` - annual minted tokens estimation (tokens per year); +* `Mint: BlocksPerYear` - number of blocks per year estimation; +* `Dist: FoundationPool` - FoundationPool supply (decimals); +* `Dist: PTreasuryPool` - PublicTreasuryPool supply (decimals); +* `Dist: LiquidityPPool` - LiquidityProvidersPool supply (decimals); +* `Dist: HARP` - HARP supply (decimals); +* `Dist: MAccBalance [main]` - rewards balance keeped by the distribution module (mail tokens); +* `Dist: MAccBalance [staking]` - rewards balance keeped by the distribution module (staking tokens); +* `Dist: BankBalance [main]` - rewards balance keeped by the distribution bank (mail tokens); +* `Dist: BankBalance [staking]` - rewards balance keeped by the distribution bank (staking tokens); +* `Dist: LockedRatio` - rate of bonded delegated tokens for locked validators to all bonded delegated tokens; +* `Supply: Total [main]` - total tokens supply (main tokens); +* `Supply: Total [staking]` - total tokens supply (staking tokens); +* `Supply: Total [LP]` - total tokens supply (LP tokens); +* `Stats: Staked/TotalSupply [staking]` - rate of (bonded + not-bonded tokens) to total supply of staking tokens; +* `Stats: Staked/TotalSupply [LPs]` - rate of staked LP tokens to total supply; +* `Accounts: TotalBalance [main]` - sum of all accounts balances (main tokens); +* `Accounts: TotalBalance [staking]` - sum of all accounts balances (staking tokens); +* `Counters: Bonding: Delegations` - number of bonding delegation operations; +* `Counters: Bonding: Redelegations` - number of bonding redelegation operations; +* `Counters: Bonding: Undelegations` - number of bonding undelegation operations; +* `Counters: LP: Delegations` - number of LP delegation operations; +* `Counters: LP: Redelegations` - number of LP redelegation operations; +* `Counters: LP: Undelegations` - number of LP undelegation operations; +* `Counters: RewardWithdraws` - number of delegators rewards withdraw operations; +* `Counters: RewardsCollected [main]` - accumulated amount of delegators rewards collected (main tokens); +* `Counters: RewardsCollected [staking]` - accumulated amount of delegators rewards collected (staking tokens); +* `Counters: CommissionWithdraws` - number of validators commission rewards operations; +* `Counters: CommissionsCollected [main]` - accumulated amount of validators commission rewards collected (main tokens); +* `Counters: CommissionsCollected [staking]` - accumulated amount of validators commission rewards collected (staking tokens); +* `Counters: LockedRewards` - number of validators rewards lock operations; diff --git a/helpers/tests/simulator/inflation_test.go b/helpers/tests/simulator/inflation_test.go index 35da2711..e1e91fd3 100644 --- a/helpers/tests/simulator/inflation_test.go +++ b/helpers/tests/simulator/inflation_test.go @@ -70,38 +70,38 @@ func (p SimProfile) String() string { str := strings.Builder{} str.WriteString("Simulation:\n") str.WriteString(fmt.Sprintf(" - ID: %s\n", p.ID)) - str.WriteString(fmt.Sprintf(" - SimDuration: %s\n", FormatDuration(p.SimDuration))) - str.WriteString(fmt.Sprintf(" - BlockTimeMin: %s\n", FormatDuration(p.BlockTimeMin))) - str.WriteString(fmt.Sprintf(" - BlockTimeMax: %s\n", FormatDuration(p.BlockTimeMax))) + str.WriteString(fmt.Sprintf(" - SimDuration: %v\n", p.SimDuration)) + str.WriteString(fmt.Sprintf(" - BlockTimeMin: %v\n", p.BlockTimeMin)) + str.WriteString(fmt.Sprintf(" - BlockTimeMax: %v\n", p.BlockTimeMax)) str.WriteString("Initial balances:\n") str.WriteString(fmt.Sprintf(" - MainTokens: %d.0%s\n", p.MainTokensBalanceWODec, defaults.MainDenom)) str.WriteString(fmt.Sprintf(" - StakingTokens: %d.0%s\n", p.BondingTokensBalanceWODec, defaults.StakingDenom)) str.WriteString(fmt.Sprintf(" - LPTokens: %d.0%s\n", p.LPTokensBalanceWODec, defaults.LiquidityProviderDenom)) str.WriteString("Total number of:\n") - str.WriteString(fmt.Sprintf(" - Account: %d\n", p.Accounts)) + str.WriteString(fmt.Sprintf(" - Accounts: %d\n", p.Accounts)) str.WriteString(fmt.Sprintf(" - PoA validators: %d\n", p.POAValidators)) str.WriteString(fmt.Sprintf(" - TM validators (total): %d\n", p.TMValidatorsTotal)) str.WriteString(fmt.Sprintf(" - TM validators (active): %d\n", p.TMValidatorsActive)) str.WriteString("Operations:\n") - str.WriteString(fmt.Sprintf(" - Create validators: %s\n", FormatDuration(p.OpCreateValidator))) - str.WriteString(fmt.Sprintf(" - Delegate bonding tokens: %s\n", FormatDuration(p.OpDelegateBonding))) - str.WriteString(fmt.Sprintf(" Amount ratio: %s\n", p.OpDelegateBondingAmountRatio)) - str.WriteString(fmt.Sprintf(" Max limit ratio: %s\n", p.OpDelegateBondingMaxSupplyRatio)) - str.WriteString(fmt.Sprintf(" - Delegate LP tokens: %s\n", FormatDuration(p.OpDelegateLP))) - str.WriteString(fmt.Sprintf(" Amount ratio: %s\n", p.OpDelegateLPAmountRatio)) - str.WriteString(fmt.Sprintf(" Max limit ratio: %s\n", p.OpDelegateLPMaxSupplyRatio)) - str.WriteString(fmt.Sprintf(" - Redelegate bonding tokens: %s\n", FormatDuration(p.OpRedelegateBonding))) - str.WriteString(fmt.Sprintf(" Amount ratio: %s\n", p.OpRedelegateBondingAmountRatio)) - str.WriteString(fmt.Sprintf(" - Redelegate LP tokens: %s\n", FormatDuration(p.OpRedelegateLP))) - str.WriteString(fmt.Sprintf(" Amount ratio: %s\n", p.OpRedelegateLPAmountRatio)) - str.WriteString(fmt.Sprintf(" - Undelegate bonding tokens: %s\n", FormatDuration(p.OpUndelegateBonding))) - str.WriteString(fmt.Sprintf(" Amount ratio: %s\n", p.OpUndelegateBondingAmountRatio)) - str.WriteString(fmt.Sprintf(" - Undelegate LP tokens: %s\n", FormatDuration(p.OpUndelegateLP))) - str.WriteString(fmt.Sprintf(" Amount ratio: %s\n", p.OpUndelegateLPAmountRatio)) - str.WriteString(fmt.Sprintf(" - Withdraw validator comission: %s\n", FormatDuration(p.OpGetValidatorRewards))) - str.WriteString(fmt.Sprintf(" - Withdraw delegator reward: %s\n", FormatDuration(p.OpGetDelegatorRewards))) - str.WriteString(fmt.Sprintf(" - Lock rewards: %s\n", FormatDuration(p.OpLockRewards))) - str.WriteString(fmt.Sprintf(" Ratio: %s\n", p.OpLockRewardsRatio)) + str.WriteString(fmt.Sprintf(" - Create validator every: %s\n", FormatDuration(p.OpCreateValidator))) + str.WriteString(fmt.Sprintf(" - Delegate bonding tokens every: %s\n", FormatDuration(p.OpDelegateBonding))) + str.WriteString(fmt.Sprintf(" Delegate amount ratio (of acc balance): %s\n", p.OpDelegateBondingAmountRatio)) + str.WriteString(fmt.Sprintf(" Max limit ratio (staked ratio): %s\n", p.OpDelegateBondingMaxSupplyRatio)) + str.WriteString(fmt.Sprintf(" - Delegate LP tokens every: %s\n", FormatDuration(p.OpDelegateLP))) + str.WriteString(fmt.Sprintf(" Delegate amount ratio (of acc balance): %s\n", p.OpDelegateLPAmountRatio)) + str.WriteString(fmt.Sprintf(" Max limit ratio (staked ratio): %s\n", p.OpDelegateLPMaxSupplyRatio)) + str.WriteString(fmt.Sprintf(" - Redelegate bonding tokens every: %s\n", FormatDuration(p.OpRedelegateBonding))) + str.WriteString(fmt.Sprintf(" Redelegate amount ratio (of del shares): %s\n", p.OpRedelegateBondingAmountRatio)) + str.WriteString(fmt.Sprintf(" - Redelegate LP tokens every: %s\n", FormatDuration(p.OpRedelegateLP))) + str.WriteString(fmt.Sprintf(" Redelegate amount ratio (of del shares): %s\n", p.OpRedelegateLPAmountRatio)) + str.WriteString(fmt.Sprintf(" - Undelegate bonding tokens every: %s\n", FormatDuration(p.OpUndelegateBonding))) + str.WriteString(fmt.Sprintf(" Undelegate amount ratio (of del shares): %s\n", p.OpUndelegateBondingAmountRatio)) + str.WriteString(fmt.Sprintf(" - Undelegate LP tokens every: %s\n", FormatDuration(p.OpUndelegateLP))) + str.WriteString(fmt.Sprintf(" Undelegate amount ratio (of del shares): %s\n", p.OpUndelegateLPAmountRatio)) + str.WriteString(fmt.Sprintf(" - Withdraw all validators comissions every: %s\n", FormatDuration(p.OpGetValidatorRewards))) + str.WriteString(fmt.Sprintf(" - Withdraw all delegators rewards every: %s\n", FormatDuration(p.OpGetDelegatorRewards))) + str.WriteString(fmt.Sprintf(" - Lock rewards every: %s\n", FormatDuration(p.OpLockRewards))) + str.WriteString(fmt.Sprintf(" Ratio of all validators: %s\n", p.OpLockRewardsRatio)) return str.String() } @@ -187,27 +187,27 @@ func simulate(t *testing.T, profile SimProfile) { func TestSimInflation(t *testing.T) { profile := SimProfile{ ID: "low_staking", - SimDuration: 1*Year + 6*Month, - BlockTimeMin: 120 * time.Second, - BlockTimeMax: 125 * time.Second, + SimDuration: 3*Month, + BlockTimeMin: 300 * time.Second, + BlockTimeMax: 305 * time.Second, // MainTokensBalanceWODec: 50000, BondingTokensBalanceWODec: 500000, LPTokensBalanceWODec: 100000, // - Accounts: 300, + Accounts: 150, POAValidators: 3, - TMValidatorsTotal: 150, + TMValidatorsTotal: 110, TMValidatorsActive: 100, // OpCreateValidator: 3 * time.Hour, // - OpDelegateBonding: 6 * time.Hour, - OpDelegateBondingAmountRatio: sdk.NewDecWithPrec(40, 2), + OpDelegateBonding: 2 * time.Hour, + OpDelegateBondingAmountRatio: sdk.NewDecWithPrec(50, 2), OpDelegateBondingMaxSupplyRatio: sdk.NewDecWithPrec(30, 2), // - OpDelegateLP: 1 * Day, - OpDelegateLPAmountRatio: sdk.NewDecWithPrec(40, 2), + OpDelegateLP: 4 * time.Hour, + OpDelegateLPAmountRatio: sdk.NewDecWithPrec(50, 2), OpDelegateLPMaxSupplyRatio: sdk.NewDecWithPrec(30, 2), // OpRedelegateBonding: 4 * Day, @@ -222,10 +222,10 @@ func TestSimInflation(t *testing.T) { OpUndelegateLP: 4 * Day, OpUndelegateLPAmountRatio: sdk.NewDecWithPrec(15, 2), // - OpGetValidatorRewards: 1 * Week, - OpGetDelegatorRewards: 1 * Day, + OpGetValidatorRewards: 1 * Month, + OpGetDelegatorRewards: 1 * Month, // - OpLockRewards: 1 * Week, + OpLockRewards: 4 * Day, OpLockRewardsRatio: sdk.NewDecWithPrec(30, 2), } diff --git a/helpers/tests/simulator/sim.go b/helpers/tests/simulator/sim.go index 5e47bf73..4373a6df 100644 --- a/helpers/tests/simulator/sim.go +++ b/helpers/tests/simulator/sim.go @@ -71,17 +71,19 @@ type Simulator struct { } type Counter struct { - BDelegations int64 - BUndelegations int64 - BRedelegations int64 - LPDelegations int64 - LPUndelegations int64 - LPRedelegations int64 - LockedRewards int64 - Rewards int64 - Commissions int64 - RewardsCollected sdk.Coins - CommissionsCollected sdk.Coins + BDelegations int64 + BUndelegations int64 + BRedelegations int64 + LPDelegations int64 + LPUndelegations int64 + LPRedelegations int64 + LockedRewards int64 + RewardsWithdraws int64 + CommissionWithdraws int64 + RewardsCollectedMain sdk.Int + RewardsCollectedStaking sdk.Int + CommissionsCollectedMain sdk.Int + CommissionsCollectedStaking sdk.Int } // BuildTmpFilePath builds file name inside of the Simulator working dir. @@ -338,8 +340,10 @@ func NewSimulator(t *testing.T, workingDir string, defferQueue *DefferOps, optio cdc: app.MakeCodec(), defferQueue: defferQueue, } - s.counter.RewardsCollected = sdk.NewCoins() - s.counter.CommissionsCollected = sdk.NewCoins() + s.counter.RewardsCollectedMain = sdk.ZeroInt() + s.counter.RewardsCollectedStaking = sdk.ZeroInt() + s.counter.CommissionsCollectedMain = sdk.ZeroInt() + s.counter.CommissionsCollectedStaking = sdk.ZeroInt() defaultGenesis, err := genesis.OverrideGenesisStateDefaults(s.cdc, app.ModuleBasics.DefaultGenesis()) require.NoError(t, err) diff --git a/helpers/tests/simulator/sim_ops_delegate.go b/helpers/tests/simulator/sim_ops_delegate.go index ac138aed..49e6b366 100644 --- a/helpers/tests/simulator/sim_ops_delegate.go +++ b/helpers/tests/simulator/sim_ops_delegate.go @@ -118,7 +118,8 @@ func delegateOpFindTarget(s *Simulator, bondingD bool, delegateRatio sdk.Dec) (t // pick an account with max tokens var delAmt sdk.Int - for _, acc := range s.GetAllAccounts().GetSortedByBalance(denom, true) { + accs := s.GetAllAccounts().GetSortedByBalance(denom, true) + for _, acc := range accs { // estimate delegation amount accCoinAmtDec := sdk.NewDecFromInt(acc.Coins.AmountOf(denom)) delAmt = accCoinAmtDec.Mul(delegateRatio).TruncateInt() @@ -128,6 +129,7 @@ func delegateOpFindTarget(s *Simulator, bondingD bool, delegateRatio sdk.Dec) (t targetAcc = acc delCoin = sdk.NewCoin(denom, delAmt) + return } return diff --git a/helpers/tests/simulator/sim_ops_redelegate.go b/helpers/tests/simulator/sim_ops_redelegate.go index 03f62115..6c051c9c 100644 --- a/helpers/tests/simulator/sim_ops_redelegate.go +++ b/helpers/tests/simulator/sim_ops_redelegate.go @@ -98,7 +98,8 @@ func redelegateOpFindTarget(s *Simulator, bondingRD bool, rdRatio sdk.Dec) (targ } // pick a target account - for _, acc := range s.GetAllAccounts().GetShuffled() { + accs := s.GetAllAccounts().GetShuffled() + for _, acc := range accs { accValAddr := sdk.ValAddress{} if acc.IsValOperator() { accValAddr = acc.OperatedValidator.GetAddress() @@ -110,7 +111,8 @@ func redelegateOpFindTarget(s *Simulator, bondingRD bool, rdRatio sdk.Dec) (targ } // pick a delegation with the highest share - for _, delegation := range acc.GetSortedDelegations(bondingRD, true) { + delegations := acc.GetSortedDelegations(bondingRD, true) + for _, delegation := range delegations { srcValidatorApplicant := validators.GetByAddress(delegation.ValidatorAddress) // check if applicant was found (that validator can be unbonded by now) diff --git a/helpers/tests/simulator/sim_ops_rewards_delegator.go b/helpers/tests/simulator/sim_ops_rewards_delegator.go index f75f8821..d61b3b88 100644 --- a/helpers/tests/simulator/sim_ops_rewards_delegator.go +++ b/helpers/tests/simulator/sim_ops_rewards_delegator.go @@ -7,26 +7,24 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -// NewGetDelegatorRewardOp takes delegator rewards. -// Op priority: -// account; -// - random; -// - has delegations; -// validator -// - random account delegation; -// - rewards are not locked; +type delegatorRewardOpTarget struct { + Acc *SimAccount + Val *SimValidator +} + +// NewGetDelegatorRewardOp takes all delegators rewards (excluding locked ones). func NewGetDelegatorRewardOp(period time.Duration) *SimOperation { id := "DelegatorRewardOp" handler := func(s *Simulator) (bool, string) { - targetAcc, targetVal, rewardCoins := getDelegatorRewardOpFindTarget(s) - if targetAcc == nil || targetVal == nil { + targets, rewardCoins := getDelegatorRewardOpFindTarget(s) + if len(targets) == 0 { return false, "target not found" } - getDelegatorRewardOpHandle(s, targetAcc, targetVal) + getDelegatorRewardOpHandle(s, targets) - getDelegatorRewardOpPost(s, targetAcc, rewardCoins) - msg := fmt.Sprintf("%s from %s: %s", targetAcc.Address, targetVal.GetAddress(), s.FormatCoins(rewardCoins)) + getDelegatorRewardOpPost(s, targets, rewardCoins) + msg := fmt.Sprintf("total from %d targets: %s", len(targets), s.FormatCoins(rewardCoins)) return true, msg } @@ -34,11 +32,11 @@ func NewGetDelegatorRewardOp(period time.Duration) *SimOperation { return NewSimOperation(id, period, NewPeriodicNextExecFn(), handler) } -func getDelegatorRewardOpFindTarget(s *Simulator) (targetAcc *SimAccount, targetVal *SimValidator, rewardCoins sdk.Coins) { +func getDelegatorRewardOpFindTarget(s *Simulator) (targets []delegatorRewardOpTarget, rewardCoins sdk.Coins) { rewardCoins = sdk.NewCoins() validators := s.GetAllValidators() - for _, acc := range s.GetAllAccounts().GetShuffled() { + for _, acc := range s.GetAllAccounts() { for _, delegation := range acc.GetShuffledDelegations(true) { validator := validators.GetByAddress(delegation.ValidatorAddress) if validator.RewardsLocked() { @@ -46,33 +44,41 @@ func getDelegatorRewardOpFindTarget(s *Simulator) (targetAcc *SimAccount, target } // estimate reward coins + curRewardCoins := sdk.NewCoins() for _, decCoin := range s.QueryDistDelReward(acc.Address, delegation.ValidatorAddress) { coin, _ := decCoin.TruncateDecimal() - rewardCoins = rewardCoins.Add(coin) + curRewardCoins = curRewardCoins.Add(coin) } // check there are some rewards - if rewardCoins.Empty() { + if curRewardCoins.Empty() { continue } - targetAcc = acc - targetVal = validator - return + targets = append(targets, delegatorRewardOpTarget{ + Acc: acc, + Val: validator, + }) + rewardCoins = rewardCoins.Add(curRewardCoins...) } } return } -func getDelegatorRewardOpHandle(s *Simulator, targetAcc *SimAccount, targetVal *SimValidator) { - s.TxDistDelegatorRewards(targetAcc, targetVal.GetAddress()) +func getDelegatorRewardOpHandle(s *Simulator, targets []delegatorRewardOpTarget) { + for _, target := range targets { + s.TxDistDelegatorRewards(target.Acc, target.Val.GetAddress()) + } } -func getDelegatorRewardOpPost(s *Simulator, targetAcc *SimAccount, rewardCoins sdk.Coins) { - // update account - s.UpdateAccount(targetAcc) +func getDelegatorRewardOpPost(s *Simulator, targets []delegatorRewardOpTarget, rewardCoins sdk.Coins) { + // update accounts + for _, target := range targets { + s.UpdateAccount(target.Acc) + } // update stats - s.counter.Rewards++ - s.counter.RewardsCollected = s.counter.RewardsCollected.Add(rewardCoins...) + s.counter.RewardsWithdraws += int64(len(targets)) + s.counter.RewardsCollectedMain = s.counter.RewardsCollectedMain.Add(rewardCoins.AmountOf(s.mainDenom)) + s.counter.RewardsCollectedStaking = s.counter.RewardsCollectedStaking.Add(rewardCoins.AmountOf(s.stakingDenom)) } diff --git a/helpers/tests/simulator/sim_ops_rewards_lock.go b/helpers/tests/simulator/sim_ops_rewards_lock.go index f97cbcf2..cfac3275 100644 --- a/helpers/tests/simulator/sim_ops_rewards_lock.go +++ b/helpers/tests/simulator/sim_ops_rewards_lock.go @@ -49,7 +49,8 @@ func lockValidatorRewardsOpCheckInput(s *Simulator, maxRatio sdk.Dec) (stop bool } func lockValidatorRewardsOpFindTarget(s *Simulator) (targetAcc *SimAccount, targetVal *SimValidator) { - for _, val := range s.GetAllValidators().GetShuffled() { + vals := s.GetAllValidators().GetShuffled() + for _, val := range vals { if val.RewardsLocked() { continue } diff --git a/helpers/tests/simulator/sim_ops_rewards_validator.go b/helpers/tests/simulator/sim_ops_rewards_validator.go index 1cfcb9e3..de5463cf 100644 --- a/helpers/tests/simulator/sim_ops_rewards_validator.go +++ b/helpers/tests/simulator/sim_ops_rewards_validator.go @@ -7,25 +7,28 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -// NewGetValidatorRewardOp takes validator commissions rewards. -// Op priority: -// validator - random; +type validatorRewardOp struct { + Acc *SimAccount + Val *SimValidator +} + +// NewGetValidatorRewardOp takes all validators commissions rewards. func NewGetValidatorRewardOp(period time.Duration) *SimOperation { id := "ValidatorRewardOp" handler := func(s *Simulator) (bool, string) { - targetAcc, targetVal, rewardCoins := getValidatorRewardOpFindTarget(s) - if targetAcc == nil || targetVal == nil { + targets, rewardCoins := getValidatorRewardOpFindTarget(s) + if len(targets) == 0 { return false, "target not found" } - if getValidatorRewardOpHandle(s, targetAcc, targetVal) { - msg := fmt.Sprintf("can't withdraw %s validator commission", targetVal.GetAddress()) + if stopMsg := getValidatorRewardOpHandle(s, targets); stopMsg != "" { + msg := fmt.Sprintf("withdraw validator commission failed: %s", stopMsg) return false, msg } - getValidatorRewardOpPost(s, targetAcc, rewardCoins) - msg := fmt.Sprintf("%s for %s: %s", targetVal.GetAddress(), targetAcc.Address, s.FormatCoins(rewardCoins)) + getValidatorRewardOpPost(s, targets, rewardCoins) + msg := fmt.Sprintf("total from %d targets: %s", len(targets), s.FormatCoins(rewardCoins)) return true, msg } @@ -33,7 +36,7 @@ func NewGetValidatorRewardOp(period time.Duration) *SimOperation { return NewSimOperation(id, period, NewPeriodicNextExecFn(), handler) } -func getValidatorRewardOpFindTarget(s *Simulator) (targetAcc *SimAccount, targetVal *SimValidator, rewardCoins sdk.Coins) { +func getValidatorRewardOpFindTarget(s *Simulator) (targets []validatorRewardOp, rewardCoins sdk.Coins) { rewardCoins = sdk.NewCoins() for _, val := range s.GetAllValidators().GetShuffled() { @@ -44,30 +47,40 @@ func getValidatorRewardOpFindTarget(s *Simulator) (targetAcc *SimAccount, target } // estimate reward coins + curRewardCoins := sdk.NewCoins() for _, decCoin := range decCoins { coin, _ := decCoin.TruncateDecimal() - rewardCoins = rewardCoins.Add(coin) + curRewardCoins = curRewardCoins.Add(coin) } - targetVal = val - targetAcc = s.GetAllAccounts().GetByAddress(targetVal.GetOperatorAddress()) + targets = append(targets, validatorRewardOp{ + Acc: s.GetAllAccounts().GetByAddress(val.GetOperatorAddress()), + Val: val, + }) + rewardCoins = rewardCoins.Add(curRewardCoins...) } return } -func getValidatorRewardOpHandle(s *Simulator, targetAcc *SimAccount, targetVal *SimValidator) (stop bool) { - if s.TxDistValidatorCommission(targetAcc, targetVal.GetAddress()) { - stop = true +func getValidatorRewardOpHandle(s *Simulator, targets []validatorRewardOp) (stopMsg string) { + for _, target := range targets { + if s.TxDistValidatorCommission(target.Acc, target.Val.GetAddress()) { + stopMsg = fmt.Sprintf("targetVal %s", target.Val.GetAddress()) + return + } } return } -func getValidatorRewardOpPost(s *Simulator, targetAcc *SimAccount, rewardCoins sdk.Coins) { +func getValidatorRewardOpPost(s *Simulator, targets []validatorRewardOp, rewardCoins sdk.Coins) { // update account - s.UpdateAccount(targetAcc) + for _, target := range targets { + s.UpdateAccount(target.Acc) + } // update stats - s.counter.Commissions++ - s.counter.CommissionsCollected = s.counter.CommissionsCollected.Add(rewardCoins...) + s.counter.CommissionWithdraws += int64(len(targets)) + s.counter.CommissionsCollectedMain = s.counter.CommissionsCollectedMain.Add(rewardCoins.AmountOf(s.mainDenom)) + s.counter.CommissionsCollectedStaking = s.counter.CommissionsCollectedStaking.Add(rewardCoins.AmountOf(s.stakingDenom)) } diff --git a/helpers/tests/simulator/sim_ops_undelegate.go b/helpers/tests/simulator/sim_ops_undelegate.go index ed41b3bc..437367c5 100644 --- a/helpers/tests/simulator/sim_ops_undelegate.go +++ b/helpers/tests/simulator/sim_ops_undelegate.go @@ -70,9 +70,11 @@ func undelegateOpFindTarget(s *Simulator, bondingUD bool, udRatio sdk.Dec) (targ } // pick a validator with the highest tokens amount (all statuses) - for _, val := range s.GetAllValidators().GetSortedByTokens(bondingUD, true) { + vals := s.GetAllValidators().GetSortedByTokens(bondingUD, true) + for _, val := range vals { // pick a random account - for _, acc := range s.GetAllAccounts().GetShuffled() { + accs := s.GetAllAccounts().GetShuffled() + for _, acc := range accs { accValAddr := sdk.ValAddress{} if acc.IsValOperator() { accValAddr = acc.OperatedValidator.GetAddress() diff --git a/helpers/tests/simulator/sim_queries.go b/helpers/tests/simulator/sim_queries.go index 2602660a..2a8840ef 100644 --- a/helpers/tests/simulator/sim_queries.go +++ b/helpers/tests/simulator/sim_queries.go @@ -289,6 +289,18 @@ func (s *Simulator) QueryDistLockState(val sdk.ValAddress) (res distribution.Que return res } +// QueryDistLockedRatio queries current locked ratio. +func (s *Simulator) QueryDistLockedRatio() (res sdk.Dec) { + resp := s.RunQuery( + nil, + "/custom/"+distribution.QuerierRoute+"/"+distribution.QueryLockedRatio, + &res, + ) + require.True(s.t, resp.IsOK()) + + return res +} + // QueryDistPool queries supply total supply. func (s *Simulator) QuerySupplyTotal() (res sdk.Coins) { resp := s.RunQuery( @@ -304,6 +316,18 @@ func (s *Simulator) QuerySupplyTotal() (res sdk.Coins) { return res } +// QuerySupplyModuleBalance queries module account balance. +func (s *Simulator) QuerySupplyModuleBalance(moduleName string) (res sdk.Coins) { + resp := s.RunQuery( + nil, + "/custom/"+supply.QuerierRoute+"/"+supply.QueryModuleBalance+"/"+moduleName, + &res, + ) + require.True(s.t, resp.IsOK()) + + return res +} + // QueryReadAllValidators reads out all validators independent of their status. func (s *Simulator) QueryReadAllValidators() (validators staking.Validators) { valsPage := 1 diff --git a/helpers/tests/simulator/sim_report.go b/helpers/tests/simulator/sim_report.go index 2078e42a..b1bb9b68 100644 --- a/helpers/tests/simulator/sim_report.go +++ b/helpers/tests/simulator/sim_report.go @@ -37,6 +37,11 @@ type SimReportItem struct { DistFoundationPool sdk.Dec // FoundationPool funds DistLiquidityProvidersPool sdk.Dec // LiquidityProvidersPool funds DistHARP sdk.Dec // HARP funds + DistModuleBalanceMain sdk.Int // Distribution module balance [main] + DistModuleBalanceStaking sdk.Int // Distribution module balance [staking] + DistBankBalanceMain sdk.Int // Distribution bank balance [main] + DistBankBalanceStaking sdk.Int // Distribution bank balance [staking] + DistLockedRatio sdk.Dec // Current locked ratio // SupplyTotalMain sdk.Int // total supply [main denom] SupplyTotalStaking sdk.Int // total supply [staking denom] @@ -45,6 +50,9 @@ type SimReportItem struct { StatsBondedRatio sdk.Dec // BondedTokens / TotalSupply ratio [staking denom] StatsLPRatio sdk.Dec // BondedTokens / TotalSupply ratio [LP denom] // + AccsBalanceMain sdk.Int + AccsBalanceStaking sdk.Int + // Counters Counter // formatIntDecimals func(value sdk.Int) string @@ -92,9 +100,19 @@ func NewReportOp(period time.Duration, debug bool, writers ...SimReportWriter) * foundationPool := s.QueryDistPool(distribution.FoundationPoolName) liquidityPool := s.QueryDistPool(distribution.LiquidityProvidersPoolName) harpPool := s.QueryDistPool(distribution.HARPName) + distrMAccBalance := s.QuerySupplyModuleBalance(distribution.ModuleName) + distrBankBalance := s.QuerySupplyModuleBalance(distribution.RewardsBankPoolName) + // supply totalSupply := s.QuerySupplyTotal() + // accounts + accsTotalMain, accsTotalStaking := sdk.ZeroInt(), sdk.ZeroInt() + for _, acc := range s.GetAllAccounts() { + accsTotalMain = accsTotalMain.Add(acc.Coins.AmountOf(s.mainDenom)) + accsTotalStaking = accsTotalStaking.Add(acc.Coins.AmountOf(s.stakingDenom)) + } + item := SimReportItem{ Index: reportItemIdx, BlockHeight: simBlockHeight, @@ -119,11 +137,19 @@ func NewReportOp(period time.Duration, debug bool, writers ...SimReportWriter) * DistFoundationPool: foundationPool.AmountOf(s.stakingDenom), DistLiquidityProvidersPool: liquidityPool.AmountOf(s.stakingDenom), DistHARP: harpPool.AmountOf(s.stakingDenom), + DistModuleBalanceMain: distrMAccBalance.AmountOf(s.mainDenom), + DistModuleBalanceStaking: distrMAccBalance.AmountOf(s.stakingDenom), + DistBankBalanceMain: distrBankBalance.AmountOf(s.mainDenom), + DistBankBalanceStaking: distrBankBalance.AmountOf(s.stakingDenom), + DistLockedRatio: s.QueryDistLockedRatio(), // SupplyTotalMain: totalSupply.AmountOf(s.mainDenom), SupplyTotalStaking: totalSupply.AmountOf(s.stakingDenom), SupplyTotalLP: totalSupply.AmountOf(s.lpDenom), // + AccsBalanceMain: accsTotalMain, + AccsBalanceStaking: accsTotalStaking, + // Counters: s.counter, // formatIntDecimals: func(value sdk.Int) string { @@ -184,25 +210,34 @@ func (w *SimReportConsoleWriter) Write(item SimReportItem) { str.WriteString(fmt.Sprintf(" Dist: PTreasuryPool: %s\n", item.formatDecDecimals(item.DistPublicTreasuryPool))) str.WriteString(fmt.Sprintf(" Dist: LiquidityPPool: %s\n", item.formatDecDecimals(item.DistLiquidityProvidersPool))) str.WriteString(fmt.Sprintf(" Dist: HARP: %s\n", item.formatDecDecimals(item.DistHARP))) + str.WriteString(fmt.Sprintf(" Dist: MAccBalance [m] %s\n", item.formatIntDecimals(item.DistModuleBalanceMain))) + str.WriteString(fmt.Sprintf(" Dist: MAccBalance [s] %s\n", item.formatIntDecimals(item.DistModuleBalanceStaking))) + str.WriteString(fmt.Sprintf(" Dist: BankBalance [m] %s\n", item.formatIntDecimals(item.DistBankBalanceMain))) + str.WriteString(fmt.Sprintf(" Dist: BankBalance [s] %s\n", item.formatIntDecimals(item.DistBankBalanceStaking))) + str.WriteString(fmt.Sprintf(" Dist: LockedRatio %s\n", item.DistLockedRatio)) str.WriteString(fmt.Sprintf(" Supply: TotalMain: %s\n", item.formatIntDecimals(item.SupplyTotalMain))) str.WriteString(fmt.Sprintf(" Supply: TotalStaking: %s\n", item.formatIntDecimals(item.SupplyTotalStaking))) str.WriteString(fmt.Sprintf(" Supply: LPs: %s\n", item.formatIntDecimals(item.SupplyTotalLP))) - str.WriteString(fmt.Sprintf(" Stats: Bonded/TotalSupply [B]: %s\n", item.StatsBondedRatio)) + str.WriteString(fmt.Sprintf(" Stats: Bonded/TotalSupply [s]: %s\n", item.StatsBondedRatio)) str.WriteString(fmt.Sprintf(" Stats: Bonded/TotalSupply [LP]: %s\n", item.StatsLPRatio)) + str.WriteString(fmt.Sprintf(" Accounts: Balance [m]: %s\n", item.formatIntDecimals(item.AccsBalanceMain))) + str.WriteString(fmt.Sprintf(" Accounts: Balance [s]: %s\n", item.formatIntDecimals(item.AccsBalanceStaking))) str.WriteString(" Counters:\n") str.WriteString(" Bonding:\n") - str.WriteString(fmt.Sprintf(" Delegations: %d\n", item.Counters.BDelegations)) - str.WriteString(fmt.Sprintf(" Redelegations: %d\n", item.Counters.BRedelegations)) - str.WriteString(fmt.Sprintf(" Undelegations: %d\n", item.Counters.BUndelegations)) + str.WriteString(fmt.Sprintf(" Delegations: %d\n", item.Counters.BDelegations)) + str.WriteString(fmt.Sprintf(" Redelegations: %d\n", item.Counters.BRedelegations)) + str.WriteString(fmt.Sprintf(" Undelegations: %d\n", item.Counters.BUndelegations)) str.WriteString(" LP:\n") - str.WriteString(fmt.Sprintf(" Delegations: %d\n", item.Counters.LPDelegations)) - str.WriteString(fmt.Sprintf(" Redelegations: %d\n", item.Counters.LPRedelegations)) - str.WriteString(fmt.Sprintf(" Undelegations: %d\n", item.Counters.LPUndelegations)) - str.WriteString(fmt.Sprintf(" Rewards: %d\n", item.Counters.Rewards)) - str.WriteString(fmt.Sprintf(" RewardsCollected: %s\n", item.formatCoinsDecimals(item.Counters.RewardsCollected))) - str.WriteString(fmt.Sprintf(" Commissions: %d\n", item.Counters.Commissions)) - str.WriteString(fmt.Sprintf(" CommissionsCollected: %s\n", item.formatCoinsDecimals(item.Counters.CommissionsCollected))) - str.WriteString(fmt.Sprintf(" Locked rewards: %d\n", item.Counters.LockedRewards)) + str.WriteString(fmt.Sprintf(" Delegations: %d\n", item.Counters.LPDelegations)) + str.WriteString(fmt.Sprintf(" Redelegations: %d\n", item.Counters.LPRedelegations)) + str.WriteString(fmt.Sprintf(" Undelegations: %d\n", item.Counters.LPUndelegations)) + str.WriteString(fmt.Sprintf(" RewardWithdraws: %d\n", item.Counters.RewardsWithdraws)) + str.WriteString(fmt.Sprintf(" RewardsCollected [m]: %s\n", item.formatIntDecimals(item.Counters.RewardsCollectedMain))) + str.WriteString(fmt.Sprintf(" RewardsCollected [s]: %s\n", item.formatIntDecimals(item.Counters.RewardsCollectedStaking))) + str.WriteString(fmt.Sprintf(" CommissionWithdraws: %d\n", item.Counters.CommissionWithdraws)) + str.WriteString(fmt.Sprintf(" CommissionsCollected [m]: %s\n", item.formatIntDecimals(item.Counters.CommissionsCollectedMain))) + str.WriteString(fmt.Sprintf(" CommissionsCollected [s]: %s\n", item.formatIntDecimals(item.Counters.CommissionsCollectedStaking))) + str.WriteString(fmt.Sprintf(" Locked rewards: %d\n", item.Counters.LockedRewards)) fmt.Println(str.String()) } diff --git a/helpers/tests/simulator/sim_report_csv.go b/helpers/tests/simulator/sim_report_csv.go index c1a08aa7..41612a4d 100644 --- a/helpers/tests/simulator/sim_report_csv.go +++ b/helpers/tests/simulator/sim_report_csv.go @@ -34,21 +34,30 @@ var Headers = []string{ "Dist: PTreasuryPool", "Dist: LiquidityPPool", "Dist: HARP", + "Dist: MAccBalance [main]", + "Dist: MAccBalance [staking]", + "Dist: BankBalance [main]", + "Dist: BankBalance [staking]", + "Dist: LockedRatio", "Supply: Total [main]", "Supply: Total [staking]", "Supply: Total [LP]", - "Stats: Bonded/TotalSupply [bonding]", - "Stats: Bonded/TotalSupply [LPs]", + "Stats: Staked/TotalSupply [staking]", + "Stats: Staked/TotalSupply [LPs]", + "Accounts: TotalBalance [main]", + "Accounts: TotalBalance [staking]", "Counters: Bonding: Delegations", "Counters: Bonding: Redelegations", "Counters: Bonding: Undelegations", "Counters: LP: Delegations", "Counters: LP: Redelegations", "Counters: LP: Undelegations", - "Counters: Rewards", - "Counters: RewardsCollected", - "Counters: Commissions", - "Counters: CommissionsCollected", + "Counters: RewardWithdraws", + "Counters: RewardsCollected [main]", + "Counters: RewardsCollected [staking]", + "Counters: CommissionWithdraws", + "Counters: CommissionsCollected [main]", + "Counters: CommissionsCollected [staking]", "Counters: LockedRewards", } @@ -76,36 +85,58 @@ func (w *SimReportCSVWriter) Write(item SimReportItem) { strconv.FormatInt(item.BlockHeight, 10), item.BlockTime.Format("02.01.2006T15:04:05"), FormatDuration(item.SimulationDur), + // validators strconv.Itoa(item.ValidatorsBonded), strconv.Itoa(item.ValidatorsUnbonding), strconv.Itoa(item.ValidatorsUnbonded), - item.StakingBonded.String(), - item.StakingNotBonded.String(), - item.StakingLPs.String(), + // staking + item.formatIntDecimals(item.StakingBonded), + item.formatIntDecimals(item.StakingNotBonded), + item.formatIntDecimals(item.StakingLPs), strconv.Itoa(item.RedelegationsInProcess), + // mint item.MintMinInflation.String(), item.MintMaxInflation.String(), - item.MintAnnualProvisions.String(), + item.formatDecDecimals(item.MintAnnualProvisions), strconv.FormatUint(item.MintBlocksPerYear, 10), - item.DistFoundationPool.String(), - item.DistPublicTreasuryPool.String(), - item.DistLiquidityProvidersPool.String(), - item.DistHARP.String(), - item.SupplyTotalMain.String(), - item.SupplyTotalStaking.String(), - item.SupplyTotalLP.String(), + // distribution + item.formatDecDecimals(item.DistFoundationPool), + item.formatDecDecimals(item.DistPublicTreasuryPool), + item.formatDecDecimals(item.DistLiquidityProvidersPool), + item.formatDecDecimals(item.DistHARP), + item.formatIntDecimals(item.DistModuleBalanceMain), + item.formatIntDecimals(item.DistModuleBalanceStaking), + item.formatIntDecimals(item.DistBankBalanceMain), + item.formatIntDecimals(item.DistBankBalanceStaking), + item.DistLockedRatio.String(), + // supply + item.formatIntDecimals(item.SupplyTotalMain), + item.formatIntDecimals(item.SupplyTotalStaking), + item.formatIntDecimals(item.SupplyTotalLP), + // stats item.StatsBondedRatio.String(), item.StatsLPRatio.String(), + // accounts + item.formatIntDecimals(item.AccsBalanceMain), + item.formatIntDecimals(item.AccsBalanceStaking), + // counters + // - bonding strconv.FormatInt(item.Counters.BDelegations, 10), strconv.FormatInt(item.Counters.BRedelegations, 10), strconv.FormatInt(item.Counters.BUndelegations, 10), + // - LP strconv.FormatInt(item.Counters.LPDelegations, 10), strconv.FormatInt(item.Counters.LPRedelegations, 10), strconv.FormatInt(item.Counters.LPUndelegations, 10), - strconv.FormatInt(item.Counters.Rewards, 10), - item.Counters.RewardsCollected.String(), - strconv.FormatInt(item.Counters.Commissions, 10), - item.Counters.CommissionsCollected.String(), + // - rewards + strconv.FormatInt(item.Counters.RewardsWithdraws, 10), + item.formatIntDecimals(item.Counters.RewardsCollectedMain), + item.formatIntDecimals(item.Counters.RewardsCollectedStaking), + // - commissions + strconv.FormatInt(item.Counters.CommissionWithdraws, 10), + item.formatIntDecimals(item.Counters.CommissionsCollectedMain), + item.formatIntDecimals(item.Counters.CommissionsCollectedStaking), + // - locking strconv.FormatInt(item.Counters.LockedRewards, 10), }