Skip to content

Commit

Permalink
Delete code slated for removal (osmosis-labs#7517)
Browse files Browse the repository at this point in the history
  • Loading branch information
ValarDragon authored Feb 17, 2024
1 parent 49cd790 commit 1606b76
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 74 deletions.
6 changes: 3 additions & 3 deletions app/upgrades/v16/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,9 @@ func CreateUpgradeHandler(
updateTokenFactoryParams(ctx, keepers.TokenFactoryKeeper)

// Transfers out all the dev fees in kvstore to dev account during upgrade
if err := keepers.ProtoRevKeeper.SendDeveloperFeesToDeveloperAccount(ctx); err != nil {
return nil, err
}
// if err := keepers.ProtoRevKeeper.SendDeveloperFeesToDeveloperAccount(ctx); err != nil {
// return nil, err
// }

ctx.Logger().Info(`
.:^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^:.
Expand Down
28 changes: 16 additions & 12 deletions app/upgrades/v16/upgrades_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ func (s *UpgradeTestSuite) TestUpgrade() {
s.Require().False(params.IsPermissionlessPoolCreationEnabled)

// Ensure that the protorev upgrade was successful
verifyProtorevUpdateSuccess(s)
// verifyProtorevUpdateSuccess(s)

// Validate MsgExecuteContract and MsgInstantiateContract were added to the whitelist
icaHostAllowList := s.App.ICAHostKeeper.GetParams(s.Ctx)
Expand Down Expand Up @@ -219,6 +219,10 @@ func (s *UpgradeTestSuite) TestUpgrade() {
}
}

func verifyProtorevUpdateSuccess(s *UpgradeTestSuite) {
panic("unimplemented")
}

func upgradeProtorevSetup(s *UpgradeTestSuite) error {
account := apptesting.CreateRandomAccounts(1)[0]
s.App.ProtoRevKeeper.SetDeveloperAccount(s.Ctx, account)
Expand All @@ -237,14 +241,14 @@ func upgradeProtorevSetup(s *UpgradeTestSuite) error {
return nil
}

func verifyProtorevUpdateSuccess(s *UpgradeTestSuite) {
// Ensure balance was transferred to the developer account
devAcc, err := s.App.ProtoRevKeeper.GetDeveloperAccount(s.Ctx)
s.Require().NoError(err)
s.Require().Equal(s.App.BankKeeper.GetBalance(s.Ctx, devAcc, "uosmo"), sdk.NewCoin("uosmo", osmomath.NewInt(1000000)))

// Ensure developer fees are empty
coins, err := s.App.ProtoRevKeeper.GetAllDeveloperFees(s.Ctx)
s.Require().NoError(err)
s.Require().Equal(coins, []sdk.Coin{})
}
// func verifyProtorevUpdateSuccess(s *UpgradeTestSuite) {
// // Ensure balance was transferred to the developer account
// devAcc, err := s.App.ProtoRevKeeper.GetDeveloperAccount(s.Ctx)
// s.Require().NoError(err)
// s.Require().Equal(s.App.BankKeeper.GetBalance(s.Ctx, devAcc, "uosmo"), sdk.NewCoin("uosmo", osmomath.NewInt(1000000)))

// // Ensure developer fees are empty
// coins, err := s.App.ProtoRevKeeper.GetAllDeveloperFees(s.Ctx)
// s.Require().NoError(err)
// s.Require().Equal(coins, []sdk.Coin{})
// }
59 changes: 0 additions & 59 deletions x/protorev/keeper/developer_fees.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,65 +7,6 @@ import (
"github.com/osmosis-labs/osmosis/v23/x/protorev/types"
)

// Used in v16 upgrade, can be removed in v17
// SendDeveloperFeesToDeveloperAccount sends the developer fees from the module account to the developer account
func (k Keeper) SendDeveloperFeesToDeveloperAccount(ctx sdk.Context) error {
// Developer account must be set in order to be able to withdraw developer fees
developerAccount, err := k.GetDeveloperAccount(ctx)
if err != nil {
return err
}

coins, err := k.GetAllDeveloperFees(ctx)
if err != nil {
return err
}

for _, coin := range coins {
// Send the coins to the developer account
if err := k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, developerAccount, sdk.NewCoins(coin)); err != nil {
return err
}

// Reset the developer fees for the coin
k.DeleteDeveloperFees(ctx, coin.Denom)
}

return nil
}

// Deprecated: Can be removed in v16
// UpdateDeveloperFees updates the fees that developers can withdraw from the module account
func (k Keeper) UpdateDeveloperFees(ctx sdk.Context, denom string, profit osmomath.Int) error {
daysSinceGenesis, err := k.GetDaysSinceModuleGenesis(ctx)
if err != nil {
return err
}

// Calculate the developer fee
if daysSinceGenesis < types.Phase1Length {
profit = profit.MulRaw(types.ProfitSplitPhase1).QuoRaw(100)
} else if daysSinceGenesis < types.Phase2Length {
profit = profit.MulRaw(types.ProfitSplitPhase2).QuoRaw(100)
} else {
profit = profit.MulRaw(types.ProfitSplitPhase3).QuoRaw(100)
}

// Get the developer fees for the denom, if not there then set it to 0 and initialize it
currentDeveloperFee, err := k.GetDeveloperFees(ctx, denom)
if err != nil {
currentDeveloperFee = sdk.NewCoin(denom, osmomath.ZeroInt())
}
currentDeveloperFee.Amount = currentDeveloperFee.Amount.Add(profit)

// Set the developer fees for the denom
if err = k.SetDeveloperFees(ctx, currentDeveloperFee); err != nil {
return err
}

return nil
}

// SendDeveloperFee sends the developer fee from the module account to the developer account
func (k Keeper) SendDeveloperFee(ctx sdk.Context, arbProfit sdk.Coin) error {
// Developer account must be set in order to be able to withdraw developer fees
Expand Down

0 comments on commit 1606b76

Please sign in to comment.