From b81079606df2dbca3f92ec60c62540fc6600965d Mon Sep 17 00:00:00 2001 From: jelysn <129082781+jelysn@users.noreply.github.com> Date: Fri, 24 Nov 2023 11:19:13 +0800 Subject: [PATCH] Implement partial close on leveragelp (#270) * implement partial close on leveragelp * implement ForceCloseLongPartial --- proto/elys/leveragelp/tx.proto | 4 + x/leveragelp/keeper/begin_blocker.go | 2 +- x/leveragelp/keeper/position_close.go | 31 +++-- x/leveragelp/keeper/position_close_test.go | 20 ++- x/leveragelp/types/errors.go | 1 + x/leveragelp/types/tx.pb.go | 134 ++++++++++++++------- 6 files changed, 137 insertions(+), 55 deletions(-) diff --git a/proto/elys/leveragelp/tx.proto b/proto/elys/leveragelp/tx.proto index 05e747ce2..e86c4e61e 100644 --- a/proto/elys/leveragelp/tx.proto +++ b/proto/elys/leveragelp/tx.proto @@ -41,6 +41,10 @@ message MsgOpenResponse {} message MsgClose { string creator = 1; uint64 id = 2; + string lp_amount = 3 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; } message MsgCloseResponse {} diff --git a/x/leveragelp/keeper/begin_blocker.go b/x/leveragelp/keeper/begin_blocker.go index f1fc73a58..bbb1b8b39 100644 --- a/x/leveragelp/keeper/begin_blocker.go +++ b/x/leveragelp/keeper/begin_blocker.go @@ -61,7 +61,7 @@ func (k Keeper) LiquidatePositionIfUnhealthy(ctx sdk.Context, position *types.Po return } - repayAmount, err := k.ForceCloseLong(ctx, *position, pool) + repayAmount, err := k.ForceCloseLong(ctx, *position, pool, position.LeveragedLpAmount) if err == nil { ctx.EventManager().EmitEvent(sdk.NewEvent(types.EventClose, sdk.NewAttribute("id", strconv.FormatInt(int64(position.Id), 10)), diff --git a/x/leveragelp/keeper/position_close.go b/x/leveragelp/keeper/position_close.go index 7a3ca1ac8..dfe8c0370 100644 --- a/x/leveragelp/keeper/position_close.go +++ b/x/leveragelp/keeper/position_close.go @@ -6,16 +6,20 @@ import ( "github.com/elys-network/elys/x/leveragelp/types" ) -func (k Keeper) ForceCloseLong(ctx sdk.Context, position types.Position, pool types.Pool) (sdk.Int, error) { +func (k Keeper) ForceCloseLong(ctx sdk.Context, position types.Position, pool types.Pool, lpAmount sdk.Int) (sdk.Int, error) { + if lpAmount.GT(position.LeveragedLpAmount) || lpAmount.IsNegative() { + return sdk.ZeroInt(), types.ErrInvalidCloseSize + } + // Exit liquidity with collateral token - exitCoins, err := k.amm.ExitPool(ctx, position.GetPositionAddress(), position.AmmPoolId, position.LeveragedLpAmount, sdk.Coins{}, position.Collateral.Denom) + exitCoins, err := k.amm.ExitPool(ctx, position.GetPositionAddress(), position.AmmPoolId, lpAmount, sdk.Coins{}, position.Collateral.Denom) if err != nil { return sdk.ZeroInt(), err } // Repay with interest debt := k.stableKeeper.UpdateInterestStackedByAddress(ctx, position.GetPositionAddress()) - repayAmount := debt.Borrowed.Add(debt.InterestStacked).Sub(debt.InterestPaid) + repayAmount := debt.Borrowed.Add(debt.InterestStacked).Sub(debt.InterestPaid).Mul(lpAmount).Quo(position.LeveragedLpAmount) if err != nil { return sdk.ZeroInt(), err } @@ -32,12 +36,17 @@ func (k Keeper) ForceCloseLong(ctx sdk.Context, position types.Position, pool ty return sdk.ZeroInt(), err } - err = k.DestroyPosition(ctx, position.Address, position.Id) - if err != nil { - return sdk.ZeroInt(), err + position.LeveragedLpAmount = position.LeveragedLpAmount.Sub(lpAmount) + if position.LeveragedLpAmount.IsZero() { + err = k.DestroyPosition(ctx, position.Address, position.Id) + if err != nil { + return sdk.ZeroInt(), err + } + } else { + k.SetPosition(ctx, &position) } - pool.LeveragedLpAmount = pool.LeveragedLpAmount.Sub(position.LeveragedLpAmount) + pool.LeveragedLpAmount = pool.LeveragedLpAmount.Sub(lpAmount) k.UpdatePoolHealth(ctx, &pool) // Hooks after leveragelp position closed @@ -60,6 +69,12 @@ func (k Keeper) CloseLong(ctx sdk.Context, msg *types.MsgClose) (*types.Position return nil, sdk.ZeroInt(), sdkerrors.Wrap(types.ErrInvalidBorrowingAsset, "invalid pool id") } - repayAmount, err := k.ForceCloseLong(ctx, position, pool) + // If lpAmount is lower than zero, close full amount + lpAmount := msg.LpAmount + if lpAmount.LTE(sdk.ZeroInt()) { + lpAmount = position.LeveragedLpAmount + } + + repayAmount, err := k.ForceCloseLong(ctx, position, pool, lpAmount) return &position, repayAmount, err } diff --git a/x/leveragelp/keeper/position_close_test.go b/x/leveragelp/keeper/position_close_test.go index 8a0010766..a2e8fb86a 100644 --- a/x/leveragelp/keeper/position_close_test.go +++ b/x/leveragelp/keeper/position_close_test.go @@ -103,8 +103,9 @@ func (suite KeeperTestSuite) TestCloseLong() { var ( msg = &types.MsgClose{ - Creator: addr.String(), - Id: 1, + Creator: addr.String(), + Id: 1, + LpAmount: sdk.ZeroInt(), } repayAmount = math.NewInt(0) ) @@ -121,11 +122,24 @@ func (suite KeeperTestSuite) TestForceCloseLong() { repayAmount := math.NewInt(4000) suite.ctx = suite.ctx.WithBlockTime(suite.ctx.BlockTime().Add(time.Hour)) - repayAmountOut, err := k.ForceCloseLong(suite.ctx, *position, pool) + repayAmountOut, err := k.ForceCloseLong(suite.ctx, *position, pool, position.LeveragedLpAmount) suite.Require().NoError(err) suite.Require().Equal(repayAmount.String(), repayAmountOut.String()) } +func (suite KeeperTestSuite) TestForceCloseLongPartial() { + k := suite.app.LeveragelpKeeper + addr := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address()) + position, pool := suite.OpenPosition(addr) + repayAmount := math.NewInt(4000) + + suite.ctx = suite.ctx.WithBlockTime(suite.ctx.BlockTime().Add(time.Hour)) + // close 50% + repayAmountOut, err := k.ForceCloseLong(suite.ctx, *position, pool, position.LeveragedLpAmount.Quo(sdk.NewInt(2))) + suite.Require().NoError(err) + suite.Require().Equal(repayAmount.Quo(sdk.NewInt(2)).String(), repayAmountOut.String()) +} + func (suite KeeperTestSuite) TestHealthDecreaseForInterest() { k := suite.app.LeveragelpKeeper addr := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address()) diff --git a/x/leveragelp/types/errors.go b/x/leveragelp/types/errors.go index 811955e8d..8e66bd446 100644 --- a/x/leveragelp/types/errors.go +++ b/x/leveragelp/types/errors.go @@ -27,4 +27,5 @@ var ( ErrAmmPoolNotFound = sdkerrors.Register(ModuleName, 34, "amm pool not found") ErrOnlyBaseCurrencyAllowed = sdkerrors.Register(ModuleName, 35, "only base currency is allowed for leverage lp") ErrInsufficientUsdcAfterOp = sdkerrors.Register(ModuleName, 36, "insufficient amount of usdc after the operation for leveragelp withdrawal") + ErrInvalidCloseSize = sdkerrors.Register(ModuleName, 37, "invalid close size") ) diff --git a/x/leveragelp/types/tx.pb.go b/x/leveragelp/types/tx.pb.go index 02aaa84fd..81a4acd80 100644 --- a/x/leveragelp/types/tx.pb.go +++ b/x/leveragelp/types/tx.pb.go @@ -129,8 +129,9 @@ func (m *MsgOpenResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgOpenResponse proto.InternalMessageInfo type MsgClose struct { - Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` - Id uint64 `protobuf:"varint,2,opt,name=id,proto3" json:"id,omitempty"` + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + Id uint64 `protobuf:"varint,2,opt,name=id,proto3" json:"id,omitempty"` + LpAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=lp_amount,json=lpAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"lp_amount"` } func (m *MsgClose) Reset() { *m = MsgClose{} } @@ -589,47 +590,48 @@ func init() { func init() { proto.RegisterFile("elys/leveragelp/tx.proto", fileDescriptor_307315ea7a77a411) } var fileDescriptor_307315ea7a77a411 = []byte{ - // 637 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x55, 0xdd, 0x4e, 0x13, 0x5d, - 0x14, 0xed, 0x1f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x44, 0xc6, - 0x4e, 0x69, 0xe6, 0x32, 0x2c, 0xdd, 0x70, 0xc8, 0xcd, 0x29, 0xcc, 0x0e, 0x20, 0x44, 0x3e, 0xce, - 0xfb, 0x19, 0x4c, 0xa8, 0x9b, 0x54, 0xd6, 0xd5, 0x56, 0x63, 0xe3, 0xde, 0xb0, 0x35, 0x22, 0xef, - 0xd4, 0xd4, 0xba, 0xed, 0x84, 0x69, 0x6a, 0xb0, 0x78, 0xdd, 0x22, 0x37, 0xff, 0x04, 0x33, 0x5d, - 0xe1, 0xed, 0x1e, 0xf8, 0x92, 0x71, 0x5f, 0xc8, 0xb1, 0x63, 0xff, 0x7f, 0x9c, 0x51, 0x99, 0xeb, - 0x50, 0xd7, 0x8d, 0x98, 0x10, 0x69, 0xa6, 0x49, 0x01, 0xda, 0x4c, 0x10, 0x73, 0x11, 0x16, 0x8a, - 0xf2, 0xb9, 0xad, 0x13, 0xcf, 0xbc, 0xc5, 0x8e, 0xff, 0x95, 0x71, 0x32, 0x71, 0xc1, 0x20, 0xb3, - 0xde, 0xf8, 0x55, 0x85, 0x6a, 0x57, 0x78, 0xa4, 0x03, 0xb5, 0xe4, 0xe7, 0x3b, 0xb4, 0xbf, 0x34, - 0x67, 0xfa, 0xda, 0x6d, 0x48, 0xa6, 0x45, 0x5e, 0xc1, 0x44, 0x12, 0xbf, 0xe5, 0x51, 0xd4, 0x18, - 0xd2, 0x1f, 0xde, 0x0a, 0xe5, 0x32, 0x7b, 0x30, 0x73, 0x2d, 0x7b, 0x23, 0x8d, 0x8b, 0x0c, 0xbd, - 0x35, 0x8e, 0x91, 0x6b, 0xef, 0x42, 0xa3, 0x18, 0xad, 0xd5, 0x3b, 0x0a, 0x15, 0x41, 0x7f, 0x32, - 0x86, 0x90, 0x0b, 0xbf, 0x83, 0xfa, 0x20, 0x36, 0x0f, 0x46, 0x55, 0xe5, 0xb0, 0xfe, 0xe8, 0x4e, - 0xb8, 0xd8, 0x6b, 0x31, 0x12, 0x23, 0x7b, 0x2d, 0x10, 0x46, 0xf7, 0x3a, 0xe2, 0xce, 0x3b, 0xdb, - 0x67, 0x97, 0x46, 0xf9, 0xfc, 0xd2, 0x28, 0xff, 0xb8, 0x34, 0xca, 0x5f, 0xaf, 0x8c, 0xd2, 0xf9, - 0x95, 0x51, 0xfa, 0x76, 0x65, 0x94, 0xf6, 0xac, 0xc2, 0xbf, 0x91, 0x12, 0x5b, 0xef, 0x33, 0x79, - 0x8c, 0xd1, 0x61, 0xfc, 0x60, 0x9d, 0x0c, 0xbd, 0x1b, 0xf6, 0x27, 0xe3, 0x17, 0xc0, 0xf3, 0xdf, - 0x01, 0x00, 0x00, 0xff, 0xff, 0xdd, 0x9f, 0xd0, 0x73, 0x9a, 0x06, 0x00, 0x00, + // 652 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x55, 0x5f, 0x4f, 0xd3, 0x5e, + 0x18, 0x5e, 0xb7, 0xf1, 0x67, 0xef, 0xf8, 0x31, 0x38, 0x3f, 0x84, 0x52, 0xb1, 0x60, 0x13, 0x75, + 0x5e, 0xb0, 0x46, 0xfc, 0x04, 0x4c, 0xbc, 0x40, 0x5d, 0xc4, 0x26, 0x4a, 0x82, 0x31, 0xf5, 0xb0, + 0x9e, 0x94, 0x86, 0xd3, 0xbd, 0x4d, 0xcf, 0x41, 0xe0, 0xd2, 0x6f, 0xe0, 0xc7, 0xe2, 0x92, 0x4b, + 0xe3, 0x05, 0x31, 0xf0, 0x01, 0x8c, 0xdf, 0xc0, 0xf4, 0xef, 0x0a, 0x1b, 0x5b, 0xd4, 0x78, 0xb5, + 0xf5, 0x3c, 0xcf, 0x79, 0x9e, 0xe7, 0xbc, 0x7d, 0xda, 0x82, 0xca, 0xf8, 0xa9, 0x30, 0x39, 0xfb, + 0xc4, 0x42, 0xea, 0x32, 0x1e, 0x98, 0xf2, 0xa4, 0x15, 0x84, 0x28, 0x91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, 0x68, 0x33, 0x41, 0x8c, 0x45, 0x58, 0x28, 0xca, + 0xe7, 0xb6, 0x76, 0x7c, 0xe6, 0x2d, 0x76, 0xfc, 0xaf, 0x8c, 0x93, 0x13, 0x17, 0x0c, 0x32, 0xeb, + 0x8d, 0x9f, 0x15, 0xa8, 0x74, 0x84, 0x4b, 0xda, 0x50, 0x4d, 0x5e, 0x06, 0x03, 0xf3, 0x4b, 0x5b, + 0xab, 0xad, 0xdd, 0x86, 0x64, 0x5a, 0xe4, 0x39, 0x4c, 0x24, 0x5d, 0x5e, 0x1e, 0x46, 0x8d, 0x21, + 0xed, 0xfe, 0xad, 0x50, 0x2e, 0xb3, 0x07, 0x33, 0xd7, 0xba, 0x37, 0xd4, 0xb8, 0xc8, 0xd0, 0x9a, + 0xe3, 0x18, 0xb9, 0xf6, 0x2e, 0xd4, 0x8b, 0xd5, 0x5a, 0x1d, 0xb1, 0x31, 0x22, 0x68, 0x8f, 0xc6, + 0x10, 0x72, 0xe1, 0x37, 0x50, 0xeb, 0xd7, 0xe6, 0xde, 0xb0, 0x5d, 0x39, 0xac, 0x3d, 0x18, 0x09, + 0x17, 0xb3, 0x16, 0x2b, 0x31, 0x34, 0x6b, 0x81, 0x30, 0x3c, 0xeb, 0x90, 0x7b, 0xde, 0xde, 0x3e, + 0xbb, 0xd4, 0x95, 0xf3, 0x4b, 0x5d, 0xf9, 0x7e, 0xa9, 0x2b, 0x5f, 0xae, 0xf4, 0xd2, 0xf9, 0x95, + 0x5e, 0xfa, 0x7a, 0xa5, 0x97, 0xf6, 0xcc, 0xc2, 0xfb, 0x23, 0x12, 0x5b, 0xef, 0x31, 0x79, 0x8c, + 0xe1, 0x61, 0x7c, 0x61, 0x9e, 0x0c, 0x7c, 0x69, 0xf6, 0x27, 0xe3, 0xcf, 0xc9, 0xd3, 0x5f, 0x01, + 0x00, 0x00, 0xff, 0xff, 0x59, 0x2f, 0x16, 0xc9, 0xe8, 0x06, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1007,6 +1009,16 @@ func (m *MsgClose) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + { + size := m.LpAmount.Size() + i -= size + if _, err := m.LpAmount.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a if m.Id != 0 { i = encodeVarintTx(dAtA, i, uint64(m.Id)) i-- @@ -1356,6 +1368,8 @@ func (m *MsgClose) Size() (n int) { if m.Id != 0 { n += 1 + sovTx(uint64(m.Id)) } + l = m.LpAmount.Size() + n += 1 + l + sovTx(uint64(l)) return n } @@ -1845,6 +1859,40 @@ func (m *MsgClose) Unmarshal(dAtA []byte) error { break } } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field LpAmount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.LpAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:])