Skip to content

Commit

Permalink
Merge pull request #1858 from joeabbey/constant-factor
Browse files Browse the repository at this point in the history
GetLastTotalPower needs to be scaled to ubedrock
  • Loading branch information
MikeSofaer authored Mar 2, 2023
2 parents 6722f91 + 937c558 commit 5d0e6bc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions app/fix_bonded_tokens_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package app
import (
"fmt"

"cosmossdk.io/math"
"github.com/Pylons-tech/pylons/app/params"
sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
Expand All @@ -25,10 +26,11 @@ func (app *PylonsApp) FixBondedTokensPool(ctx sdk.Context) {
// Account currently has 1 BEDROCK
// There is currently 15202 BEDROCK Total Power Delegated
// Transferring the missing accounting from multisig to bonded_tokens_pool
totalPower := app.StakingKeeper.GetLastTotalPower(ctx)
totalPowerInBedrock := app.StakingKeeper.GetLastTotalPower(ctx)
totalPowerInUbedrock := totalPowerInBedrock.Mul(math.NewInt(1_000_000))

bondeTokensPoolBalance := bk.GetBalance(ctx, bondedTokensPoolAddress, params.StakingBaseCoinUnit)
bondeTokensPoolDelta := totalPower.Sub(bondeTokensPoolBalance.Amount)
bondeTokensPoolDelta := totalPowerInUbedrock.Sub(bondeTokensPoolBalance.Amount)

bondeTokensPoolAdjustment := sdk.NewCoins(sdk.NewCoin(params.StakingBaseCoinUnit, bondeTokensPoolDelta))
err := bk.SendCoinsFromAccountToModule(ctx, multisigAddress, stakingtypes.BondedPoolName, bondeTokensPoolAdjustment)
Expand Down
4 changes: 2 additions & 2 deletions app/fix_bonded_tokens_pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ func (suite *UpgradeTestSuite) TestFixBondedTokensPool() {

// The bonded_tokens_pool should now be restored.
bondedTokensPoolFixed := suite.App.BankKeeper.GetBalance(suite.Ctx, bondedTokensPoolAddress, params.StakingBaseCoinUnit)
suite.Require().NotEqual(bondedTokensPoolBefore.Amount, bondedTokensPoolFixed.Amount)
suite.Require().Equal(bondedTokensPoolBefore.Amount, bondedTokensPoolFixed.Amount)

// The master wallet should now have 9
masterWalletBalance = suite.App.BankKeeper.GetBalance(suite.Ctx, multisigAddress, params.StakingBaseCoinUnit)
suite.Require().Equal(masterWalletBalance.Amount, math.NewInt(9_999_999))
suite.Require().Equal(masterWalletBalance.Amount, math.NewInt(9_000_000))

}

0 comments on commit 5d0e6bc

Please sign in to comment.