Last active
August 10, 2024 15:06
-
-
Save Reecepbcups/9223b82dea076b836fded88792a678fb to your computer and use it in GitHub Desktop.
Blocks vesting accounts from delegating their tokens to validators.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package decorators | |
// reference: https://x.com/gtx360ti/status/1760400114361725279 | |
// Stratos VC sells $1,609,926 by staking their "locked" tokens ($DYM), earnings rewards on these vested funds | |
// and selling the rewards. Recouping their entire investment within 3 weeks of mainnet despite not touching | |
// any of the locked funds. | |
import ( | |
"fmt" | |
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" | |
vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" | |
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" | |
sdk "github.com/cosmos/cosmos-sdk/types" | |
) | |
// ante handler decorator | |
type MsgFilterDecorator struct { | |
AuthKeeper authkeeper.AccountKeeper | |
} | |
// AnteHandle performs an AnteHandler check that returns an error if the tx contains a message that is not allowed | |
func (mfd MsgFilterDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) { | |
if mfd.isInsiderTryingToDumpOnRetailWithQuoteLockedFundsUnQuote(ctx, tx.GetMsgs()) { | |
currHeight := ctx.BlockHeight() | |
return ctx, fmt.Errorf("tx contains unsupported message types at height %d", currHeight) | |
} | |
return next(ctx, tx, simulate) | |
} | |
// block from delegating with vesting accounts. | |
func (mfd MsgFilterDecorator) isInsiderTryingToDumpOnRetailWithQuoteLockedFundsUnQuote(ctx sdk.Context, msgs []sdk.Msg) bool { | |
for _, msg := range msgs { | |
for _, signer := range msg.GetSigners() { | |
accType := mfd.AuthKeeper.GetAccount(ctx, signer) | |
isVesting := false | |
switch accType.(type) { | |
case *vestingtypes.ContinuousVestingAccount: | |
isVesting = true | |
case *vestingtypes.DelayedVestingAccount: | |
isVesting = true | |
case *vestingtypes.PeriodicVestingAccount: | |
isVesting = true | |
} | |
// TODO: nested Authz msg check here | |
if isVesting { | |
// TODO: modify more like: https://github.com/alexanderbez/novestingyield | |
// where we instead check `!vacc.GetVestingCoins(sdkCtx.BlockTime()).IsZero()` | |
// this way once the account is done vesting, you can delegate | |
if _, ok := msg.(*stakingtypes.MsgDelegate); ok { | |
return true | |
} | |
} | |
} | |
} | |
return false | |
} |
SDK v50 Solution
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add a
vacc.GetVestingCoins(sdkCtx.BlockTime()).IsZero()
check instead of blank disable from https://github.com/alexanderbez/novestingyield/tree/main