From f04da516db119327d6aec22f896011ce8347c47d Mon Sep 17 00:00:00 2001 From: Walter White <101130700+MatrixHeisenberg@users.noreply.github.com> Date: Sat, 21 May 2022 12:49:02 -0400 Subject: [PATCH] feat(perp): distribute liquidate rewards keeper helper method and LiquidationResp proto (#449) * feat: liquidate proto changes, new params, and new methods on perp interfaces * fix: restore passing state * refactor: coalesce errors to one location * feat (liquidate.go): ExecuteFullLiquidation, distributeLiquidateRewards * test: Check expected fee to liquidator * test (liquidate_test.go): turn tests green with expectedPerpEFBalance * test: Test_distributeLiquidateRewards * typo correction * typo correction * refactor: replace panic(err) with require.NoError * fix: ExecuteFullLiquidation * feat (perp): Emit internal events when positionResp objects are returned * linter * fix, test: perp.go and margin.go tests pass again * fix: settleposition test restored * fix: calc_test.go, calc_unit_test.go * test: liquidate_unit_test passing * fix, refactor: passing margin_test, liquidate_test * fix (clearing_house_test.go): Margin and MarginToVault should be sdk.Int, not sdk.Dec * test, docs (liquidate_test.go): Check correctness of emitted events. Add docs for calculations * refactor: require.EqualValues -> assert.EqualValues + more docs * docs: small decription * refactor: universal sdk.Decs * verify event calls * refactor: consistency b/w assert and require * refactor: rename CalcFee -> CalcPerpTxFee * refactor: rename CalcFee -> CalcPerpTxFee * refactor: Liquidate (0/4) - asserts, String() calls, and new params * refactor: clean up old TODOs in clearing_house.go * feat: add liquidateresp as a proto type * feat: Remove duplicate sdk.AccAddress transform * Update x/perp/keeper/liquidate_test.go Co-authored-by: Walter White <101130700+MatrixHeisenberg@users.noreply.github.com> * fix: added check to please linter * Add distribute liquidate rewards * Small refactoring * Update state.proto Co-authored-by: Unique-Divine Co-authored-by: AgentSmithMatrix <98403347+AgentSmithMatrix@users.noreply.github.com> Co-authored-by: MD Co-authored-by: Mat-Cosmos <97468149+matthiasmatt@users.noreply.github.com> --- proto/perp/v1/state.proto | 24 ++ x/perp/keeper/clearing_house_test.go | 2 - x/perp/keeper/liquidate.go | 83 ++++ x/perp/keeper/liquidate_unit_test.go | 168 ++++++++ x/perp/types/params.go | 12 +- x/perp/types/state.pb.go | 547 +++++++++++++++++++++++---- x/perp/types/types.go | 13 + 7 files changed, 758 insertions(+), 91 deletions(-) create mode 100644 x/perp/keeper/liquidate.go create mode 100644 x/perp/keeper/liquidate_unit_test.go diff --git a/proto/perp/v1/state.proto b/proto/perp/v1/state.proto index 24f86fb4b..11d19b202 100644 --- a/proto/perp/v1/state.proto +++ b/proto/perp/v1/state.proto @@ -94,6 +94,30 @@ message PositionResp { (gogoproto.nullable) = false]; } +message LiquidateResp{ + // Amount of bad debt created by the liquidation event + string bad_debt = 1[ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false]; + + // Fee paid to the liquidator + string fee_to_liquidator = 2[ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false]; + + // Fee paid to the Perp EF fund + string fee_to_perp_ecosystem_fund = 3[ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false]; + + // Address of the liquidator + bytes liquidator = 4[ + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; + + // Position response from the close or open reverse position + PositionResp position_resp = 5; +} + message VirtualPoolInfo { string pair = 1; int64 last_restriction_block = 2; diff --git a/x/perp/keeper/clearing_house_test.go b/x/perp/keeper/clearing_house_test.go index 413204fa4..ae3307b8b 100644 --- a/x/perp/keeper/clearing_house_test.go +++ b/x/perp/keeper/clearing_house_test.go @@ -2013,7 +2013,6 @@ func TestDecreasePosition(t *testing.T) { }, /*==========================SHORT POSITIONS===========================*/ - { name: "decrease short position, positive PnL", // user bought in at 105 BTC for 10.5 NUSD at 10x leverage (1 BTC = 1 NUSD) @@ -2094,7 +2093,6 @@ func TestDecreasePosition(t *testing.T) { assert.EqualValues(t, ctx.BlockHeight(), resp.Position.BlockNumber) }, }, - { name: "decrease short position, negative PnL", // user bought in at 100 BTC for 10 NUSD at 10x leverage (1 BTC = 1 NUSD) diff --git a/x/perp/keeper/liquidate.go b/x/perp/keeper/liquidate.go new file mode 100644 index 000000000..941ca05a4 --- /dev/null +++ b/x/perp/keeper/liquidate.go @@ -0,0 +1,83 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/NibiruChain/nibiru/x/common" + "github.com/NibiruChain/nibiru/x/perp/events" + "github.com/NibiruChain/nibiru/x/perp/types" +) + +func (k Keeper) distributeLiquidateRewards( + ctx sdk.Context, liquidateResp types.LiquidateResp) (err error) { + // -------------------------------------------------------------- + // Preliminary validations + // -------------------------------------------------------------- + + // validate response + err = liquidateResp.Validate() + if err != nil { + return err + } + + // validate pair + pair, err := common.NewTokenPairFromStr(liquidateResp.PositionResp.Position.Pair) + if err != nil { + return err + } + err = k.requireVpool(ctx, pair) + if err != nil { + return err + } + + // -------------------------------------------------------------- + // Distribution of rewards + // -------------------------------------------------------------- + + vaultAddr := k.AccountKeeper.GetModuleAddress(types.VaultModuleAccount) + perpEFAddr := k.AccountKeeper.GetModuleAddress(types.PerpEFModuleAccount) + + // Transfer fee from vault to PerpEF + feeToPerpEF := liquidateResp.FeeToPerpEcosystemFund.RoundInt() + if feeToPerpEF.IsPositive() { + coinToPerpEF := sdk.NewCoin( + pair.GetQuoteTokenDenom(), feeToPerpEF) + err = k.BankKeeper.SendCoinsFromModuleToModule( + ctx, + /* from */ types.VaultModuleAccount, + /* to */ types.PerpEFModuleAccount, + sdk.NewCoins(coinToPerpEF), + ) + if err != nil { + return err + } + events.EmitTransfer(ctx, + /* coin */ coinToPerpEF, + /* from */ vaultAddr.String(), + /* to */ perpEFAddr.String(), + ) + } + + // Transfer fee from PerpEF to liquidator + feeToLiquidator := liquidateResp.FeeToLiquidator.RoundInt() + if feeToLiquidator.IsPositive() { + coinToLiquidator := sdk.NewCoin( + pair.GetQuoteTokenDenom(), feeToLiquidator) + err = k.BankKeeper.SendCoinsFromModuleToAccount( + ctx, + /* from */ types.PerpEFModuleAccount, + /* to */ liquidateResp.Liquidator, + sdk.NewCoins(coinToLiquidator), + ) + if err != nil { + return err + } + events.EmitTransfer(ctx, + /* coin */ coinToLiquidator, + /* from */ perpEFAddr.String(), + /* to */ liquidateResp.Liquidator.String(), + ) + } + + return nil +} diff --git a/x/perp/keeper/liquidate_unit_test.go b/x/perp/keeper/liquidate_unit_test.go new file mode 100644 index 000000000..d0f8bfc2c --- /dev/null +++ b/x/perp/keeper/liquidate_unit_test.go @@ -0,0 +1,168 @@ +package keeper + +import ( + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "github.com/NibiruChain/nibiru/x/common" + "github.com/NibiruChain/nibiru/x/perp/events" + "github.com/NibiruChain/nibiru/x/perp/types" + + "github.com/NibiruChain/nibiru/x/testutil/sample" +) + +func Test_distributeLiquidateRewards_Error(t *testing.T) { + testcases := []struct { + name string + test func() + }{ + { + name: "empty LiquidateResponse fails validation - error", + test: func() { + perpKeeper, _, ctx := getKeeper(t) + err := perpKeeper.distributeLiquidateRewards(ctx, + types.LiquidateResp{}) + require.Error(t, err) + require.ErrorContains(t, err, "must not have nil fields") + }, + }, + { + name: "invalid liquidator - panic", + test: func() { + perpKeeper, _, ctx := getKeeper(t) + + require.Panics(t, func() { + err := perpKeeper.distributeLiquidateRewards(ctx, + types.LiquidateResp{BadDebt: sdk.OneDec(), FeeToLiquidator: sdk.OneDec(), + FeeToPerpEcosystemFund: sdk.OneDec(), + Liquidator: sdk.AccAddress{}, + }, + ) + require.Error(t, err) + }) + }, + }, + { + name: "invalid pair - error", + test: func() { + perpKeeper, _, ctx := getKeeper(t) + liquidator := sample.AccAddress() + err := perpKeeper.distributeLiquidateRewards(ctx, + types.LiquidateResp{BadDebt: sdk.OneDec(), FeeToLiquidator: sdk.OneDec(), + FeeToPerpEcosystemFund: sdk.OneDec(), + Liquidator: liquidator, + PositionResp: &types.PositionResp{ + Position: &types.Position{ + Pair: "dai:usdc:usdt", + }}, + }, + ) + require.Error(t, err) + require.ErrorContains(t, err, common.ErrInvalidTokenPair.Error()) + }, + }, + { + name: "vpool does not exist - error", + test: func() { + perpKeeper, mocks, ctx := getKeeper(t) + liquidator := sample.AccAddress() + pair := common.TokenPair("xxx:yyy") + mocks.mockVpoolKeeper.EXPECT().ExistsPool(ctx, pair).Return(false) + err := perpKeeper.distributeLiquidateRewards(ctx, + types.LiquidateResp{BadDebt: sdk.OneDec(), FeeToLiquidator: sdk.OneDec(), + FeeToPerpEcosystemFund: sdk.OneDec(), + Liquidator: liquidator, + PositionResp: &types.PositionResp{ + Position: &types.Position{ + Pair: pair.String(), + }}, + }, + ) + require.Error(t, err) + require.ErrorContains(t, err, types.ErrPairNotFound.Error()) + }, + }, + } + + for _, tc := range testcases { + tc := tc + t.Run(tc.name, func(t *testing.T) { + tc.test() + }) + } +} + +func Test_distributeLiquidateRewards_Happy(t *testing.T) { + testcases := []struct { + name string + test func() + }{ + { + name: "healthy liquidation", + test: func() { + perpKeeper, mocks, ctx := getKeeper(t) + liquidator := sample.AccAddress() + pair := common.TokenPair("xxx:yyy") + + mocks.mockVpoolKeeper.EXPECT().ExistsPool(ctx, pair).Return(true) + + vaultAddr := authtypes.NewModuleAddress(types.VaultModuleAccount) + perpEFAddr := authtypes.NewModuleAddress(types.VaultModuleAccount) + mocks.mockAccountKeeper.EXPECT().GetModuleAddress( + types.VaultModuleAccount). + Return(vaultAddr) + mocks.mockAccountKeeper.EXPECT().GetModuleAddress( + types.PerpEFModuleAccount). + Return(perpEFAddr) + + mocks.mockBankKeeper.EXPECT().SendCoinsFromModuleToModule( + ctx, types.VaultModuleAccount, types.PerpEFModuleAccount, + sdk.NewCoins(sdk.NewCoin("yyy", sdk.OneInt())), + ).Return(nil) + mocks.mockBankKeeper.EXPECT().SendCoinsFromModuleToAccount( + ctx, types.PerpEFModuleAccount, liquidator, + sdk.NewCoins(sdk.NewCoin("yyy", sdk.OneInt())), + ).Return(nil) + + err := perpKeeper.distributeLiquidateRewards(ctx, + types.LiquidateResp{BadDebt: sdk.OneDec(), FeeToLiquidator: sdk.OneDec(), + FeeToPerpEcosystemFund: sdk.OneDec(), + Liquidator: liquidator, + PositionResp: &types.PositionResp{ + Position: &types.Position{ + Pair: pair.String(), + }}, + }, + ) + require.NoError(t, err) + + expectedEvents := []sdk.Event{ + events.NewTransferEvent( + /* coin */ sdk.NewCoin("yyy", sdk.OneInt()), + /* from */ vaultAddr.String(), + /* to */ perpEFAddr.String(), + ), + events.NewTransferEvent( + /* coin */ sdk.NewCoin("yyy", sdk.OneInt()), + /* from */ perpEFAddr.String(), + /* to */ liquidator.String(), + ), + } + for _, event := range expectedEvents { + assert.Contains(t, ctx.EventManager().Events(), event) + } + }, + }, + } + + for _, tc := range testcases { + tc := tc + t.Run(tc.name, func(t *testing.T) { + tc.test() + }) + } +} diff --git a/x/perp/types/params.go b/x/perp/types/params.go index 9264aecfc..dbb814160 100644 --- a/x/perp/types/params.go +++ b/x/perp/types/params.go @@ -95,23 +95,19 @@ func DefaultParams() Params { } func (p *Params) GetSpreadRatioAsDec() sdk.Dec { - return sdk.NewIntFromUint64(uint64(p.SpreadRatio)). - ToDec().Quo(sdk.MustNewDecFromStr("1000000")) + return sdk.NewDec(p.SpreadRatio).QuoInt64(1_000_000) } func (p *Params) GetTollRatioAsDec() sdk.Dec { - return sdk.NewIntFromUint64(uint64(p.TollRatio)). - ToDec().Quo(sdk.MustNewDecFromStr("1000000")) + return sdk.NewDec(p.TollRatio).QuoInt64(1_000_000) } func (p *Params) GetLiquidationFeeAsDec() sdk.Dec { - return sdk.NewIntFromUint64(uint64(p.LiquidationFee)). - ToDec().Quo(sdk.MustNewDecFromStr("1000000")) + return sdk.NewDec(p.LiquidationFee).QuoInt64(1_000_000) } func (p *Params) GetPartialLiquidationRatioAsDec() sdk.Dec { - return sdk.NewIntFromUint64(uint64(p.PartialLiquidationRatio)). - ToDec().Quo(sdk.MustNewDecFromStr("1000000")) + return sdk.NewDec(p.PartialLiquidationRatio).QuoInt64(1_000_000) } // Validate validates the set of params diff --git a/x/perp/types/state.pb.go b/x/perp/types/state.pb.go index 863ea5870..3d6422396 100644 --- a/x/perp/types/state.pb.go +++ b/x/perp/types/state.pb.go @@ -398,6 +398,66 @@ func (m *PositionResp) GetPosition() *Position { return nil } +type LiquidateResp struct { + // Amount of bad debt created by the liquidation event + BadDebt github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,1,opt,name=bad_debt,json=badDebt,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"bad_debt"` + // Fee paid to the liquidator + FeeToLiquidator github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=fee_to_liquidator,json=feeToLiquidator,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"fee_to_liquidator"` + // Fee paid to the Perp EF fund + FeeToPerpEcosystemFund github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=fee_to_perp_ecosystem_fund,json=feeToPerpEcosystemFund,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"fee_to_perp_ecosystem_fund"` + // Address of the liquidator + Liquidator github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,4,opt,name=liquidator,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"liquidator,omitempty"` + // Position response from the close or open reverse position + PositionResp *PositionResp `protobuf:"bytes,5,opt,name=position_resp,json=positionResp,proto3" json:"position_resp,omitempty"` +} + +func (m *LiquidateResp) Reset() { *m = LiquidateResp{} } +func (m *LiquidateResp) String() string { return proto.CompactTextString(m) } +func (*LiquidateResp) ProtoMessage() {} +func (*LiquidateResp) Descriptor() ([]byte, []int) { + return fileDescriptor_0416b6ef16ef80be, []int{4} +} +func (m *LiquidateResp) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *LiquidateResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_LiquidateResp.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *LiquidateResp) XXX_Merge(src proto.Message) { + xxx_messageInfo_LiquidateResp.Merge(m, src) +} +func (m *LiquidateResp) XXX_Size() int { + return m.Size() +} +func (m *LiquidateResp) XXX_DiscardUnknown() { + xxx_messageInfo_LiquidateResp.DiscardUnknown(m) +} + +var xxx_messageInfo_LiquidateResp proto.InternalMessageInfo + +func (m *LiquidateResp) GetLiquidator() github_com_cosmos_cosmos_sdk_types.AccAddress { + if m != nil { + return m.Liquidator + } + return nil +} + +func (m *LiquidateResp) GetPositionResp() *PositionResp { + if m != nil { + return m.PositionResp + } + return nil +} + type VirtualPoolInfo struct { Pair string `protobuf:"bytes,1,opt,name=pair,proto3" json:"pair,omitempty"` LastRestrictionBlock int64 `protobuf:"varint,2,opt,name=last_restriction_block,json=lastRestrictionBlock,proto3" json:"last_restriction_block,omitempty"` @@ -408,7 +468,7 @@ func (m *VirtualPoolInfo) Reset() { *m = VirtualPoolInfo{} } func (m *VirtualPoolInfo) String() string { return proto.CompactTextString(m) } func (*VirtualPoolInfo) ProtoMessage() {} func (*VirtualPoolInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_0416b6ef16ef80be, []int{4} + return fileDescriptor_0416b6ef16ef80be, []int{5} } func (m *VirtualPoolInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -460,7 +520,7 @@ func (m *PairMetadata) Reset() { *m = PairMetadata{} } func (m *PairMetadata) String() string { return proto.CompactTextString(m) } func (*PairMetadata) ProtoMessage() {} func (*PairMetadata) Descriptor() ([]byte, []int) { - return fileDescriptor_0416b6ef16ef80be, []int{5} + return fileDescriptor_0416b6ef16ef80be, []int{6} } func (m *PairMetadata) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -516,7 +576,7 @@ func (m *PositionChangedEvent) Reset() { *m = PositionChangedEvent{} } func (m *PositionChangedEvent) String() string { return proto.CompactTextString(m) } func (*PositionChangedEvent) ProtoMessage() {} func (*PositionChangedEvent) Descriptor() ([]byte, []int) { - return fileDescriptor_0416b6ef16ef80be, []int{6} + return fileDescriptor_0416b6ef16ef80be, []int{7} } func (m *PositionChangedEvent) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -568,6 +628,7 @@ func init() { proto.RegisterType((*GenesisState)(nil), "nibiru.perp.v1.GenesisState") proto.RegisterType((*Position)(nil), "nibiru.perp.v1.Position") proto.RegisterType((*PositionResp)(nil), "nibiru.perp.v1.PositionResp") + proto.RegisterType((*LiquidateResp)(nil), "nibiru.perp.v1.LiquidateResp") proto.RegisterType((*VirtualPoolInfo)(nil), "nibiru.perp.v1.VirtualPoolInfo") proto.RegisterType((*PairMetadata)(nil), "nibiru.perp.v1.PairMetadata") proto.RegisterType((*PositionChangedEvent)(nil), "nibiru.perp.v1.PositionChangedEvent") @@ -576,84 +637,91 @@ func init() { func init() { proto.RegisterFile("perp/v1/state.proto", fileDescriptor_0416b6ef16ef80be) } var fileDescriptor_0416b6ef16ef80be = []byte{ - // 1224 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x97, 0xcf, 0x6e, 0x1b, 0xb7, - 0x13, 0xc7, 0xb5, 0x96, 0x2d, 0xc9, 0x63, 0xd9, 0xd6, 0x8f, 0x76, 0x1c, 0x39, 0x48, 0x14, 0xff, - 0x54, 0xb4, 0x09, 0x0c, 0x54, 0x82, 0xd3, 0xb4, 0x87, 0x9c, 0x22, 0xc9, 0x4e, 0x2b, 0x40, 0xb6, - 0x37, 0x6b, 0xe7, 0x4f, 0x5b, 0xa0, 0x2c, 0x77, 0x97, 0xb2, 0x89, 0xec, 0x92, 0x9b, 0x5d, 0xae, - 0x10, 0xe7, 0xdc, 0x07, 0xe8, 0xa1, 0x6f, 0x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xd4, 0x73, - 0xd6, 0xc6, 0x78, 0xbb, 0x1a, 0xe7, 0x28, 0x1a, 0xba, 0x06, 0x20, 0x45, 0x10, 0x64, 0xec, 0xfc, - 0x86, 0x75, 0x33, 0xef, 0xcc, 0xab, 0x19, 0x63, 0xfe, 0x3f, 0x94, 0x93, 0x28, 0xa6, 0xc4, 0xcf, - 0x1c, 0x66, 0xb5, 0xc3, 0x82, 0x99, 0x33, 0x2e, 0x37, 0x60, 0x39, 0x60, 0x4f, 0x53, 0xe6, 0xab, - 0x11, 0xc7, 0x7d, 0x4a, 0xab, 0x73, 0xda, 0x6b, 0x69, 0x6c, 0xfa, 0x1e, 0xa5, 0xe8, 0x0e, 0xac, - 0x47, 0x24, 0x96, 0x8c, 0x04, 0x78, 0x7c, 0x81, 0x01, 0x17, 0xf4, 0x92, 0xcb, 0x99, 0x43, 0xef, - 0xd4, 0xae, 0x1f, 0x52, 0xff, 0xc5, 0x82, 0xf2, 0x97, 0x94, 0xd3, 0x84, 0x25, 0x07, 0x2a, 0x5b, - 0xe8, 0x36, 0x14, 0x22, 0x7d, 0x8a, 0xfa, 0xe8, 0x16, 0x6e, 0xad, 0x35, 0xde, 0x4e, 0x5c, 0xc3, - 0x9c, 0x71, 0x7b, 0x56, 0x9d, 0x93, 0x93, 0xf9, 0xa2, 0x01, 0xac, 0x85, 0xc2, 0x4f, 0x03, 0x8a, - 0x89, 0xe7, 0x89, 0x94, 0x4b, 0xec, 0x92, 0x40, 0x1d, 0x89, 0x3e, 0xd5, 0x85, 0x5b, 0xeb, 0x8d, - 0x2c, 0x57, 0x2a, 0xb1, 0x8d, 0x2c, 0xb1, 0x8d, 0x8e, 0x60, 0xbc, 0xfd, 0xb1, 0x02, 0xfd, 0xf5, - 0xea, 0xfa, 0xb5, 0x13, 0x12, 0x06, 0x77, 0xea, 0x67, 0x63, 0xea, 0xce, 0xaa, 0x31, 0xb4, 0xcc, - 0x7c, 0x3b, 0x9b, 0xfe, 0x27, 0x0f, 0x25,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0x8f, 0x6f, 0x6a, 0xb9, 0x97, 0x6f, 0x6a, 0xb9, 0xdf, 0xdf, 0xd4, 0x72, 0xdf, 0x6c, 0x8e, - 0x1d, 0xc7, 0x9e, 0x7e, 0xe5, 0xe9, 0x1c, 0x13, 0xc6, 0x9b, 0xe6, 0xf5, 0xa7, 0xf9, 0xac, 0xa9, - 0x3f, 0xca, 0xf4, 0xb1, 0xb8, 0x05, 0xfd, 0xc5, 0xf4, 0xd9, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, - 0x50, 0x68, 0x1a, 0x4d, 0xa9, 0x0d, 0x00, 0x00, + // 1342 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x57, 0xcd, 0x6e, 0x1b, 0xb7, + 0x16, 0xd6, 0x58, 0xb6, 0x24, 0x1f, 0xc9, 0xb6, 0x42, 0x3b, 0x8e, 0x6c, 0x38, 0xb2, 0xaf, 0x2e, + 0xee, 0x4d, 0x60, 0x20, 0x12, 0x9c, 0xa6, 0x5d, 0x64, 0x15, 0x49, 0xb6, 0x5b, 0x01, 0xb2, 0x3d, + 0x19, 0x3b, 0x3f, 0x4d, 0x81, 0xb2, 0xd4, 0x0c, 0x65, 0xb3, 0x99, 0x21, 0x27, 0x33, 0x1c, 0x21, + 0xca, 0xba, 0x0f, 0xd0, 0x45, 0xdf, 0xa4, 0x9b, 0x2e, 0xfa, 0x00, 0xd9, 0xb4, 0xc8, 0xb2, 0xe8, + 0xc2, 0x28, 0x92, 0x37, 0xe8, 0x32, 0xdd, 0x14, 0xe4, 0x8c, 0x64, 0x05, 0x71, 0xd2, 0x4a, 0xf6, + 0x4a, 0x22, 0xcf, 0xe1, 0xc7, 0xc3, 0x73, 0x3e, 0x7e, 0x87, 0x03, 0x8b, 0x3e, 0x0d, 0xfc, 0x5a, + 0x6f, 0xab, 0x16, 0x4a, 0x22, 0x69, 0xd5, 0x0f, 0x84, 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b, 0x1a, 0x10, 0xb5, 0x20, + 0xd7, 0x21, 0x0e, 0x76, 0x68, 0x47, 0x4e, 0x48, 0xbf, 0x6c, 0x87, 0x38, 0xdb, 0xb4, 0x23, 0x51, + 0x17, 0xae, 0x9d, 0xc5, 0x3e, 0x38, 0x11, 0xd6, 0xc4, 0x9e, 0x8c, 0x92, 0x57, 0x87, 0x70, 0x83, + 0x4c, 0x1d, 0x2a, 0xa6, 0x3f, 0x82, 0x85, 0x6e, 0xc4, 0x1d, 0xc6, 0x8f, 0xb1, 0x4f, 0xfa, 0x1e, + 0xe5, 0x72, 0x42, 0x8e, 0xce, 0x27, 0x30, 0x66, 0x8c, 0x82, 0xee, 0x43, 0x21, 0xa0, 0xc4, 0x65, + 0x2f, 0x54, 0xfc, 0xdc, 0x9d, 0x90, 0x89, 0xf9, 0x01, 0x86, 0xc9, 0x5d, 0xf4, 0x10, 0x16, 0x12, + 0x61, 0x97, 0x02, 0xf7, 0x48, 0xe4, 0x4a, 0xcd, 0xb4, 0xf1, 0x51, 0xe7, 0x62, 0x98, 0x23, 0xf1, + 0x50, 0x81, 0xa0, 0x6f, 0x60, 0x29, 0xe2, 0xa3, 0xc1, 0x62, 0xd2, 0x95, 0x09, 0x33, 0xc7, 0x07, + 0x47, 0x67, 0x58, 0x26, 0x77, 0xeb, 0x0a, 0xa9, 0xf2, 0x53, 0x1a, 0xe6, 0x06, 0x12, 0x4d, 0x35, + 0xa3, 0x47, 0xa9, 0x62, 0x5c, 0x8c, 0x2a, 0x4f, 0xe0, 0x4a, 0x97, 0x52, 0x95, 0x93, 0x41, 0x97, + 0x10, 0xc1, 0x84, 0xdc, 0x5e, 0xe8, 0x52, 0x7a, 0x24, 0xda, 0x43, 0x18, 0xf4, 0x2d, 0xac, 0x26, + 0xd8, 0xea, 0x9e, 0x61, 0x6a, 0x8b, 0xb0, 0x1f, 0x4a, 0xea, 0x61, 0x55, 0xed, 0x09, 0x39, 0xbe, + 0xac, 0x37, 0x31, 0x69, 0xe0, 0xef, 0x0c, 0xe0, 0x76, 0x23, 0xee, 0xa0, 0xfb, 0x00, 0x23, 0x07, + 0x50, 0x2c, 0x2f, 0x34, 0xb6, 0xde, 0x9e, 0xae, 0xdf, 0xfa, 0x17, 0xb8, 0x75, 0xdb, 0xae, 0xc7, + 0x3d, 0xc1, 0x1a, 0x01, 0x41, 0x75, 0x98, 0x1b, 0xde, 0x9d, 0x80, 0x86, 0xbe, 0xe6, 0x76, 0xfe, + 0xf6, 0xda, 0x07, 0xc5, 0x83, 0x86, 0xbe, 0x55, 0xf0, 0x47, 0x46, 0x95, 0x5f, 0x0c, 0x58, 0x78, + 0xc8, 0x02, 0x19, 0x11, 0xd7, 0x14, 0xc2, 0x6d, 0xf1, 0xae, 0x18, 0xb6, 0x1d, 0x63, 0xa4, 0xed, + 0xdc, 0x81, 0x65, 0x2d, 0xca, 0x01, 0x0d, 0x65, 0xc0, 0xb4, 0x44, 0x62, 0xad, 0x69, 0xba, 0x14, + 0x69, 0x6b, 0x49, 0x59, 0xad, 0x33, 0x63, 0x43, 0xd9, 0x90, 0x0f, 0x6b, 0x1f, 0x91, 0xef, 0xb0, + 0x94, 0xde, 0x48, 0x4f, 0x90, 0xe1, 0x55, 0xfb, 0x43, 0xaa, 0x1d, 0x56, 0x7e, 0x30, 0xa0, 0x60, + 0x12, 0x16, 0xec, 0x51, 0x49, 0x1c, 0x22, 0xc9, 0xb9, 0x87, 0xf9, 0xa7, 0xb0, 0xa6, 0x2e, 0x3d, + 0xac, 0xb7, 0x59, 0x58, 0x1a, 0x54, 0xa1, 0x19, 0xeb, 0xd4, 0x4e, 0x4f, 0xe9, 0xc8, 0x32, 0x64, + 0x64, 0x40, 0x1c, 0x3a, 0x08, 0x30, 0x19, 0x9d, 0xdb, 0xfa, 0xcf, 0xda, 0x76, 0xfa, 0x42, 0x6d, + 0xfb, 0x2b, 0xb8, 0x32, 0xa4, 0xcd, 0xb0, 0x75, 0x4f, 0x26, 0xbb, 0xc5, 0x01, 0xd0, 0xb0, 0x7d, + 0x7f, 0x44, 0xd9, 0x67, 0x2e, 0x53, 0xd9, 0xef, 0x41, 0x5a, 0x3d, 0x2d, 0xc7, 0xd7, 0xdd, 0x16, + 0x97, 0x96, 0x5a, 0x8a, 0xbe, 0x86, 0xc5, 0x77, 0xe2, 0x4b, 0x64, 0x71, 0x32, 0xcd, 0x1d, 0x66, + 0x54, 0x05, 0xa7, 0x55, 0xf1, 0xbd, 0x16, 0x91, 0xbb, 0x78, 0x8b, 0xf8, 0x90, 0x94, 0xcf, 0x5e, + 0x96, 0x94, 0xbf, 0x23, 0xdc, 0x70, 0x31, 0xe1, 0xc6, 0xb0, 0x38, 0xfa, 0xae, 0xf7, 0x29, 0x27, + 0xae, 0xec, 0x97, 0xf2, 0x93, 0xc5, 0x3a, 0x02, 0x65, 0xc6, 0x48, 0x68, 0x0f, 0x20, 0xf4, 0x85, + 0xc4, 0x7e, 0xc0, 0x6c, 0x5a, 0x2a, 0x4c, 0x84, 0x3b, 0xab, 0x10, 0x4c, 0x05, 0x70, 0xde, 0x5b, + 0x61, 0xee, 0x32, 0xde, 0x0a, 0x9b, 0x2b, 0x30, 0x7d, 0xc8, 0x1c, 0x8a, 0xb2, 0x90, 0x6e, 0x3c, + 0xf8, 0xb2, 0x98, 0x42, 0x39, 0x98, 0x3e, 0xdc, 0x69, 0xb7, 0x8b, 0xc6, 0xe6, 0xa7, 0x30, 0x67, + 0xf2, 0x76, 0x93, 0xb8, 0xf6, 0x81, 0xaf, 0x1f, 0x75, 0xf3, 0x00, 0x87, 0xe6, 0xc1, 0x11, 0x36, + 0xad, 0x56, 0x73, 0x27, 0x76, 0x3d, 0x7a, 0x54, 0x37, 0x8b, 0x06, 0x02, 0xc8, 0x1c, 0x58, 0xf5, + 0x66, 0x7b, 0xa7, 0x38, 0xb5, 0x79, 0x03, 0x16, 0x4d, 0xde, 0x36, 0x03, 0xda, 0xa5, 0x01, 0xe5, + 0x36, 0x4d, 0x16, 0x67, 0x21, 0xbd, 0x57, 0x7f, 0x5c, 0x4c, 0xe9, 0x3f, 0xad, 0xfd, 0xa2, 0xb1, + 0x79, 0x0f, 0xd6, 0xe2, 0xaf, 0x3b, 0xb5, 0x85, 0x16, 0x27, 0xc1, 0xf5, 0x69, 0x93, 0x15, 0x2a, + 0x12, 0xf3, 0xe0, 0xa8, 0x98, 0x42, 0xb3, 0x30, 0xd3, 0xda, 0xdf, 0xde, 0x79, 0x5c, 0x34, 0x50, + 0x1e, 0xb2, 0x7b, 0xf5, 0xc7, 0xd8, 0xdc, 0x6f, 0x17, 0xa7, 0x1a, 0xdb, 0x2f, 0x5f, 0x97, 0x8d, + 0x57, 0xaf, 0xcb, 0xc6, 0x1f, 0xaf, 0xcb, 0xc6, 0xf7, 0x6f, 0xca, 0xa9, 0x57, 0x6f, 0xca, 0xa9, + 0xdf, 0xde, 0x94, 0x53, 0x4f, 0x36, 0x47, 0xd2, 0xb1, 0xaf, 0x1b, 0x4e, 0xf3, 0x84, 0x30, 0x5e, + 0x8b, 0x9b, 0x4f, 0xed, 0x79, 0x4d, 0x7f, 0x4f, 0xeb, 0xb4, 0x74, 0x32, 0xfa, 0x63, 0xf7, 0x93, + 0xbf, 0x03, 0x00, 0x00, 0xff, 0xff, 0x8e, 0xde, 0x18, 0xdb, 0x64, 0x0f, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -954,6 +1022,78 @@ func (m *PositionResp) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *LiquidateResp) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *LiquidateResp) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *LiquidateResp) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.PositionResp != nil { + { + size, err := m.PositionResp.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintState(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + } + if len(m.Liquidator) > 0 { + i -= len(m.Liquidator) + copy(dAtA[i:], m.Liquidator) + i = encodeVarintState(dAtA, i, uint64(len(m.Liquidator))) + i-- + dAtA[i] = 0x22 + } + { + size := m.FeeToPerpEcosystemFund.Size() + i -= size + if _, err := m.FeeToPerpEcosystemFund.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintState(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + { + size := m.FeeToLiquidator.Size() + i -= size + if _, err := m.FeeToLiquidator.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintState(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + { + size := m.BadDebt.Size() + i -= size + if _, err := m.BadDebt.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintState(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + func (m *VirtualPoolInfo) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1302,6 +1442,29 @@ func (m *PositionResp) Size() (n int) { return n } +func (m *LiquidateResp) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.BadDebt.Size() + n += 1 + l + sovState(uint64(l)) + l = m.FeeToLiquidator.Size() + n += 1 + l + sovState(uint64(l)) + l = m.FeeToPerpEcosystemFund.Size() + n += 1 + l + sovState(uint64(l)) + l = len(m.Liquidator) + if l > 0 { + n += 1 + l + sovState(uint64(l)) + } + if m.PositionResp != nil { + l = m.PositionResp.Size() + n += 1 + l + sovState(uint64(l)) + } + return n +} + func (m *VirtualPoolInfo) Size() (n int) { if m == nil { return 0 @@ -2296,6 +2459,228 @@ func (m *PositionResp) Unmarshal(dAtA []byte) error { } return nil } +func (m *LiquidateResp) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowState + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: LiquidateResp: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: LiquidateResp: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BadDebt", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowState + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthState + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthState + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.BadDebt.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FeeToLiquidator", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowState + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthState + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthState + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.FeeToLiquidator.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FeeToPerpEcosystemFund", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowState + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthState + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthState + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.FeeToPerpEcosystemFund.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Liquidator", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowState + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthState + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthState + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Liquidator = append(m.Liquidator[:0], dAtA[iNdEx:postIndex]...) + if m.Liquidator == nil { + m.Liquidator = []byte{} + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PositionResp", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowState + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthState + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthState + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.PositionResp == nil { + m.PositionResp = &PositionResp{} + } + if err := m.PositionResp.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipState(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthState + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *VirtualPoolInfo) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/x/perp/types/types.go b/x/perp/types/types.go index d242e4c99..55e3ed5ba 100644 --- a/x/perp/types/types.go +++ b/x/perp/types/types.go @@ -2,6 +2,7 @@ package types import ( "errors" + fmt "fmt" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -37,3 +38,15 @@ func ZeroPosition(ctx sdk.Context, vpair common.TokenPair, trader string) *Posit BlockNumber: ctx.BlockHeight(), } } + +func (l *LiquidateResp) Validate() error { + for _, field := range []sdk.Dec{ + l.BadDebt, l.FeeToLiquidator, l.FeeToPerpEcosystemFund} { + if field.IsNil() { + return fmt.Errorf( + `invalid liquidationOutput: %v, + must not have nil fields`, l.String()) + } + } + return nil +}