diff --git a/proto/elys/leveragelp/types.proto b/proto/elys/leveragelp/types.proto index 57bda4a5a..26eb0deaa 100644 --- a/proto/elys/leveragelp/types.proto +++ b/proto/elys/leveragelp/types.proto @@ -73,6 +73,10 @@ message LegacyPosition { message QueryPosition { Position position = 1; string updated_leverage = 2 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; + string position_usd_value = 3 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; } message PositionAndInterest { diff --git a/x/leveragelp/keeper/query_get_position_test.go b/x/leveragelp/keeper/query_get_position_test.go index 534ae0339..6a80e9900 100644 --- a/x/leveragelp/keeper/query_get_position_test.go +++ b/x/leveragelp/keeper/query_get_position_test.go @@ -101,11 +101,11 @@ func (suite KeeperTestSuite) TestQueryGetPosition() { suite.Require().Equal(position, res.Position.Position) suite.Require().Equal(updated_leverage, res.Position.UpdatedLeverage) - expected := types.PositionAndInterest{ Position: &types.QueryPosition{ Position: position, UpdatedLeverage: updated_leverage, + PositionUsdValue: sdk.NewInt(5000), }, InterestRateHour: sdk.MustNewDecFromStr("0.000017123287671233"), InterestRateHourUsd: sdk.ZeroDec(), @@ -113,5 +113,6 @@ func (suite KeeperTestSuite) TestQueryGetPosition() { pos_for_address_res, _ := k.QueryPositionsForAddress(suite.ctx, &types.PositionsForAddressRequest{Address: addr.String(), Pagination: nil} ) suite.Require().Equal(expected.Position, pos_for_address_res.Positions[0].Position) - suite.Require().Equal(expected.InterestRateHour, pos_for_address_res.Positions[0].InterestRateHour) + suite.Require().True(expected.InterestRateHour.Equal(pos_for_address_res.Positions[0].InterestRateHour)) + suite.Require().True(expected.InterestRateHourUsd.Equal(pos_for_address_res.Positions[0].InterestRateHourUsd)) } diff --git a/x/leveragelp/keeper/utils.go b/x/leveragelp/keeper/utils.go index fd09ccce2..bfc5d1bac 100644 --- a/x/leveragelp/keeper/utils.go +++ b/x/leveragelp/keeper/utils.go @@ -92,6 +92,7 @@ func (k Keeper) GetLeverageLpUpdatedLeverage(ctx sdk.Context, positions []*types updatedLeveragePositions = append(updatedLeveragePositions, &types.QueryPosition{ Position: position, UpdatedLeverage: updated_leverage, + PositionUsdValue: exitAmountAfterFee, }) } return updatedLeveragePositions, nil diff --git a/x/leveragelp/types/types.pb.go b/x/leveragelp/types/types.pb.go index e1d37254d..c286f0dcb 100644 --- a/x/leveragelp/types/types.pb.go +++ b/x/leveragelp/types/types.pb.go @@ -225,8 +225,9 @@ func (m *LegacyPosition) GetAmmPoolId() uint64 { } type QueryPosition struct { - Position *Position `protobuf:"bytes,1,opt,name=position,proto3" json:"position,omitempty"` - UpdatedLeverage github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=updated_leverage,json=updatedLeverage,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"updated_leverage"` + Position *Position `protobuf:"bytes,1,opt,name=position,proto3" json:"position,omitempty"` + UpdatedLeverage github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=updated_leverage,json=updatedLeverage,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"updated_leverage"` + PositionUsdValue github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=position_usd_value,json=positionUsdValue,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"position_usd_value"` } func (m *QueryPosition) Reset() { *m = QueryPosition{} } @@ -326,46 +327,47 @@ func init() { func init() { proto.RegisterFile("elys/leveragelp/types.proto", fileDescriptor_992d513dd201f55b) } var fileDescriptor_992d513dd201f55b = []byte{ - // 613 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x95, 0xc1, 0x6f, 0xd3, 0x3e, - 0x14, 0xc7, 0x9b, 0xfe, 0xba, 0xad, 0xf5, 0x7e, 0x6d, 0x87, 0x8b, 0x50, 0x18, 0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xf5, 0x3b, 0x37, 0xed, 0x99, 0x30, 0x5b, 0x0b, 0xb3, 0x33, 0x61, 0xf6, - 0x23, 0xe0, 0x61, 0xa7, 0x72, 0x7c, 0xba, 0x55, 0x72, 0x17, 0x52, 0x70, 0x1f, 0xad, 0x0b, 0x4e, - 0x06, 0x5c, 0x70, 0xc5, 0x99, 0x34, 0xff, 0xd3, 0xf8, 0x8e, 0xad, 0x97, 0x7d, 0x3f, 0xdd, 0xba, - 0x3d, 0xe4, 0x6a, 0x94, 0x0c, 0x6c, 0x1f, 0x02, 0x27, 0x3b, 0xec, 0xec, 0xb3, 0x2b, 0xe9, 0x61, - 0x56, 0xb2, 0x6e, 0xa8, 0xdc, 0x45, 0x04, 0x7e, 0x82, 0xaa, 0x79, 0xe9, 0xcc, 0xca, 0x5f, 0xe3, - 0x1e, 0x33, 0xdf, 0x9d, 0xe7, 0xe3, 0xb7, 0xa8, 0x95, 0x8f, 0xa9, 0x27, 0x22, 0x8f, 0x04, 0x90, - 0x84, 0xca, 0x5c, 0x29, 0xa4, 0xf2, 0xda, 0x1c, 0xd5, 0x8b, 0xf6, 0x53, 0x10, 0x7e, 0x89, 0x9a, - 0x51, 0x56, 0x64, 0x6f, 0xc4, 0x88, 0x50, 0x23, 0x73, 0xb5, 0x90, 0xe4, 0x46, 0x8e, 0x39, 0x48, - 0x29, 0x59, 0x3b, 0xd7, 0xf2, 0x76, 0x62, 0x0b, 0xad, 0x93, 0x20, 0xf0, 0x22, 0x00, 0xe1, 0x71, - 0x6a, 0x56, 0xd3, 0x40, 0x8d, 0x04, 0x41, 0x1f, 0x40, 0x74, 0x29, 0x7e, 0x81, 0x9a, 0x52, 0x41, - 0xe4, 0x09, 0x90, 0xd2, 0x8b, 0x62, 0xee, 0x33, 0xb3, 0x56, 0x48, 0x48, 0x5d, 0x63, 0x7a, 0x20, - 0x65, 0x5f, 0x43, 0xda, 0x9f, 0x57, 0x50, 0xa3, 0xc7, 0x86, 0xc4, 0x1f, 0xff, 0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, 0xec, 0x86, 0x4c, 0xbd, 0x87, 0xf8, 0x30, 0x9d, 0x38, 0x1f, 0x96, - 0x1e, 0xde, 0xc1, 0x6a, 0xfa, 0x64, 0xde, 0xfd, 0x19, 0x00, 0x00, 0xff, 0xff, 0x86, 0xb6, 0x20, - 0xbd, 0x98, 0x07, 0x00, 0x00, + // 633 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x95, 0x41, 0x6f, 0xd3, 0x30, + 0x18, 0x86, 0x9b, 0xd2, 0x6d, 0xad, 0xc7, 0xd6, 0xe2, 0x22, 0x14, 0x86, 0x94, 0x4d, 0x3d, 0xa0, + 0x5d, 0x96, 0x68, 0x20, 0x2e, 0x70, 0x40, 0x2b, 0x1c, 0x56, 0xd4, 0x43, 0x09, 0xda, 0x10, 0x68, + 0x22, 0x72, 0x63, 0xab, 0xb5, 0xe6, 0xc4, 0x21, 0x76, 0x0a, 0xfd, 0x17, 0x1c, 0xb8, 0xf3, 0x67, + 0x38, 0xec, 0xb8, 0x23, 0xe2, 0x30, 0xa1, 0xf6, 0x87, 0x80, 0x9c, 0xc6, 0x59, 0xb7, 0x0a, 0x04, + 0xd1, 0x76, 0xe0, 0xd4, 0x44, 0x9f, 0xbf, 0x27, 0xaf, 0xdf, 0xef, 0xad, 0x0d, 0xee, 0x11, 0x36, + 0x16, 0x0e, 0x23, 0x23, 0x12, 0xa3, 0x01, 0x61, 0x91, 0x23, 0xc7, 0x11, 0x11, 0x76, 0x14, 0x73, + 0xc9, 0x61, 0x5d, 0x15, 0xed, 0xf3, 0xe2, 0xc6, 0xed, 0x01, 0x1f, 0xf0, 0xb4, 0xe6, 0xa8, 0xa7, + 0xd9, 0xb2, 0x0d, 0xcb, 0xe7, 0x22, 0xe0, 0xc2, 0xe9, 0x23, 0x41, 0x9c, 0xd1, 0x6e, 0x9f, 0x48, + 0xb4, 0xeb, 0xf8, 0x9c, 0x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75, 0x8d, 0xd9, 0x4f, 0x29, + 0xd9, 0x38, 0x57, 0xf4, 0x38, 0xa1, 0x05, 0x56, 0x51, 0x10, 0x78, 0x11, 0xe7, 0xcc, 0xa3, 0xd8, + 0xac, 0xa6, 0x85, 0x1a, 0x0a, 0x82, 0x1e, 0xe7, 0xac, 0x83, 0xe1, 0x21, 0xa8, 0x0b, 0xc9, 0x23, + 0x8f, 0x71, 0x21, 0xbc, 0x28, 0xa6, 0x3e, 0x31, 0x6b, 0x85, 0x84, 0xac, 0x29, 0x4c, 0x97, 0x0b, + 0xd1, 0x53, 0x90, 0xd6, 0x97, 0x25, 0xb0, 0xde, 0x25, 0x03, 0xe4, 0x8f, 0xff, 0xcf, 0x30, 0xbd, + 0x02, 0x6b, 0x34, 0x94, 0x24, 0x26, 0x42, 0x7a, 0x11, 0xa2, 0xb8, 0x40, 0xa2, 0x14, 0xf3, 0xa6, + 0x86, 0xf4, 0x10, 0xc5, 0x17, 0x12, 0xba, 0x74, 0x3d, 0x09, 0x5d, 0xbe, 0xc6, 0x84, 0xae, 0x5c, + 0x61, 0x42, 0xab, 0xbf, 0x4b, 0x68, 0xed, 0x2f, 0x12, 0x0a, 0xae, 0x22, 0xa1, 0x3f, 0x0d, 0xb0, + 0xf6, 0x32, 0x21, 0xf1, 0x79, 0x40, 0x1f, 0x81, 0xaa, 0xd6, 0x9a, 0x26, 0x54, 0x85, 0xf0, 0xd2, + 0x89, 0x6c, 0xe7, 0x07, 0x6b, 0xbe, 0x14, 0xbe, 0x01, 0x8d, 0x24, 0xc2, 0x48, 0xaa, 0x39, 0xe8, + 0xe9, 0x96, 0x0b, 0x29, 0xac, 0x67, 0x9c, 0xae, 0x1e, 0xf2, 0x11, 0x80, 0xf9, 0x10, 0x12, 0x81, + 0xbd, 0x11, 0x62, 0x09, 0x29, 0x18, 0xef, 0x86, 0x26, 0x1d, 0x08, 0x7c, 0xa8, 0x38, 0xad, 0xcf, + 0x65, 0xd0, 0xd4, 0xfb, 0xd9, 0x0b, 0x71, 0x27, 0x8b, 0x2a, 0x7c, 0xbc, 0xe0, 0x83, 0xb5, 0xe0, + 0xc3, 0x05, 0xe7, 0xe6, 0xcc, 0x38, 0x02, 0x30, 0xff, 0xdf, 0xc4, 0x48, 0x12, 0x6f, 0xc8, 0x93, + 0xb8, 0xa0, 0x1d, 0x0d, 0x4d, 0x72, 0x91, 0x24, 0xfb, 0x3c, 0x89, 0xa1, 0x0f, 0xee, 0x2c, 0xd2, + 0x95, 0x33, 0x05, 0x3c, 0x51, 0x5f, 0x68, 0x5e, 0xfe, 0xc2, 0x81, 0xc0, 0xed, 0xce, 0xc9, 0xc4, + 0x32, 0x4e, 0x27, 0x96, 0xf1, 0x63, 0x62, 0x19, 0x9f, 0xa6, 0x56, 0xe9, 0x74, 0x6a, 0x95, 0xbe, + 0x4d, 0xad, 0xd2, 0x5b, 0x67, 0x0e, 0xab, 0x0c, 0xd9, 0x09, 0x89, 0xfc, 0xc0, 0xe3, 0xe3, 0xf4, + 0xc5, 0xf9, 0xb8, 0x70, 0xad, 0xf7, 0x97, 0xd3, 0x0b, 0xf9, 0xe1, 0xaf, 0x00, 0x00, 0x00, 0xff, + 0xff, 0xe1, 0x1e, 0xf1, 0x18, 0xf6, 0x07, 0x00, 0x00, } func (m *PositionRequest) Marshal() (dAtA []byte, err error) { @@ -633,6 +635,16 @@ func (m *QueryPosition) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + { + size := m.PositionUsdValue.Size() + i -= size + if _, err := m.PositionUsdValue.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a { size := m.UpdatedLeverage.Size() i -= size @@ -816,6 +828,8 @@ func (m *QueryPosition) Size() (n int) { } l = m.UpdatedLeverage.Size() n += 1 + l + sovTypes(uint64(l)) + l = m.PositionUsdValue.Size() + n += 1 + l + sovTypes(uint64(l)) return n } @@ -1722,6 +1736,40 @@ func (m *QueryPosition) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PositionUsdValue", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + 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 ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.PositionUsdValue.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTypes(dAtA[iNdEx:])