diff --git a/proto/umee/auction/v1/events.proto b/proto/umee/auction/v1/events.proto index 89c4ecdef2..9ffb14d39f 100644 --- a/proto/umee/auction/v1/events.proto +++ b/proto/umee/auction/v1/events.proto @@ -16,3 +16,8 @@ message EventRewardsAuctionResult { // Auctioned tokens. repeated cosmos.base.v1beta1.Coin rewards = 4 [(gogoproto.nullable) = false]; } + +// EventFundRewardsAuction is emitted when sending rewards to auction module +message EventFundRewardsAuction { + repeated cosmos.base.v1beta1.Coin assets = 1 [(gogoproto.nullable) = false]; +} diff --git a/proto/umee/leverage/v1/events.proto b/proto/umee/leverage/v1/events.proto index 117ac2918b..3b9eaf7736 100644 --- a/proto/umee/leverage/v1/events.proto +++ b/proto/umee/leverage/v1/events.proto @@ -108,8 +108,3 @@ message EventFundOracle { // Assets sent to oracle module repeated cosmos.base.v1beta1.Coin assets = 1 [(gogoproto.nullable) = false]; } - -// EventFundAuction is emitted when sending rewards to auction module -message EventFundAuction { - repeated cosmos.base.v1beta1.Coin assets = 1 [(gogoproto.nullable) = false]; -} diff --git a/proto/umee/metoken/v1/metoken.proto b/proto/umee/metoken/v1/metoken.proto index 57d3e1ef44..e96ebde122 100644 --- a/proto/umee/metoken/v1/metoken.proto +++ b/proto/umee/metoken/v1/metoken.proto @@ -18,6 +18,14 @@ message Params { // Interest claiming frequency in seconds, determines how often metoken module will claim accrued interest from // leverage module int64 claiming_frequency = 2; + + // Rewards Auction Factor determines the portion of swap and redeem fee that is sent to the + // auction module for the rewards auction. + // Valid values: 0-10000 (in basis points, 2000 = 20%). + uint32 rewards_auction_factor = 3 [ + (gogoproto.customtype) = "github.com/umee-network/umee/v6/util/bpmath.FixedBP", + (gogoproto.nullable) = false + ]; } // Index defines an index of assets that are allowed to swap and redeem for the Index's meToken, @@ -40,7 +48,8 @@ message Index { uint32 exponent = 3; // Fee contains fee parameters used for swap and redemption fee calculations for all underlying - // assets in this index. + // assets in this index. `Params.rewards_auction_factor` of the fee will go for the burn + // auction. Fee fee = 4 [(gogoproto.nullable) = false]; // Accepted Assets is the list of underlying Tokens that can be swapped and redeemed for the Index's meToken, diff --git a/swagger/swagger.yaml b/swagger/swagger.yaml index 5264e5fb3d..f2461760e1 100644 --- a/swagger/swagger.yaml +++ b/swagger/swagger.yaml @@ -5709,7 +5709,10 @@ paths: Fee contains fee parameters used for swap and redemption fee calculations for all underlying - assets in this index. + assets in this index. `Params.rewards_auction_factor` of + the fee will go for the burn + + auction. type: object properties: min_fee: @@ -5867,6 +5870,16 @@ paths: often metoken module will claim accrued interest from leverage module + rewards_auction_factor: + type: integer + format: int64 + description: >- + Rewards Auction Factor determines the portion of swap and + redeem fee that is sent to the + + auction module for the rewards auction. + + Valid values: 0-10000 (in basis points, 2000 = 20%). description: Params defines the parameters for the metoken module. description: >- QueryParamsResponse defines the response structure for the Params @@ -10333,7 +10346,10 @@ definitions: Fee contains fee parameters used for swap and redemption fee calculations for all underlying - assets in this index. + assets in this index. `Params.rewards_auction_factor` of the fee will + go for the burn + + auction. type: object properties: min_fee: @@ -10532,6 +10548,16 @@ definitions: module will claim accrued interest from leverage module + rewards_auction_factor: + type: integer + format: int64 + description: >- + Rewards Auction Factor determines the portion of swap and redeem fee + that is sent to the + + auction module for the rewards auction. + + Valid values: 0-10000 (in basis points, 2000 = 20%). description: Params defines the parameters for the metoken module. umee.metoken.v1.QueryIndexBalancesResponse: type: object @@ -10752,7 +10778,10 @@ definitions: Fee contains fee parameters used for swap and redemption fee calculations for all underlying - assets in this index. + assets in this index. `Params.rewards_auction_factor` of the fee + will go for the burn + + auction. type: object properties: min_fee: @@ -10866,6 +10895,16 @@ definitions: metoken module will claim accrued interest from leverage module + rewards_auction_factor: + type: integer + format: int64 + description: >- + Rewards Auction Factor determines the portion of swap and redeem + fee that is sent to the + + auction module for the rewards auction. + + Valid values: 0-10000 (in basis points, 2000 = 20%). description: Params defines the parameters for the metoken module. description: |- QueryParamsResponse defines the response structure for the Params gRPC diff --git a/util/bpmath/bp.go b/util/bpmath/bp.go index 7d6e2538b3..2ebc3a93d0 100644 --- a/util/bpmath/bp.go +++ b/util/bpmath/bp.go @@ -25,6 +25,11 @@ func (bp BP) MulDec(a sdk.Dec) sdk.Dec { return MulDec(a, bp) } +// Equal returns true if bp==a. +func (bp BP) Equal(a BP) bool { + return bp == a +} + // FromQuo returns a/b in basis points. // Contract: a>=0 and b > 0. // Panics if a/b >= MaxUint32/10'000 or if b==0. diff --git a/util/bpmath/bp_test.go b/util/bpmath/bp_test.go index 319da25364..7cc1097b2b 100644 --- a/util/bpmath/bp_test.go +++ b/util/bpmath/bp_test.go @@ -79,3 +79,15 @@ func TestBPMulDec(t *testing.T) { require.Equal(sdk.MustNewDecFromStr("6.2501"), bp3.MulDec(d)) require.Equal(sdk.MustNewDecFromStr("25.0004"), bp4.MulDec(d)) } + +func TestBPEqual(t *testing.T) { + t.Parallel() + require := require.New(t) + + var b1 BP = 1 + var b2 BP = 1 + var b3 BP = 10 + require.True(b1.Equal(b2)) + require.True(b2.Equal(b2)) + require.False(b1.Equal(b3)) +} diff --git a/util/bpmath/fixed_bp.go b/util/bpmath/fixed_bp.go index 7b660bc183..bc3e7adbe0 100644 --- a/util/bpmath/fixed_bp.go +++ b/util/bpmath/fixed_bp.go @@ -29,3 +29,8 @@ func (bp FixedBP) Mul(a math.Int) math.Int { func (bp FixedBP) MulDec(a sdk.Dec) sdk.Dec { return MulDec(a, bp) } + +// Equal returns true if bp==a. +func (bp FixedBP) Equal(a FixedBP) bool { + return bp == a +} diff --git a/util/bpmath/fixed_bp_test.go b/util/bpmath/fixed_bp_test.go index 05e67deab2..fd47982caa 100644 --- a/util/bpmath/fixed_bp_test.go +++ b/util/bpmath/fixed_bp_test.go @@ -131,3 +131,15 @@ func TestFixedBPMulDec(t *testing.T) { require.Equal(sdk.MustNewDecFromStr("6.2501"), bp3.MulDec(d)) require.Equal(sdk.MustNewDecFromStr("25.0004"), bp4.MulDec(d)) } + +func TestFixedBPEqual(t *testing.T) { + t.Parallel() + require := require.New(t) + + var b1 FixedBP = 1 + var b2 FixedBP = 1 + var b3 FixedBP = 10 + require.True(b1.Equal(b2)) + require.True(b2.Equal(b2)) + require.False(b1.Equal(b3)) +} diff --git a/x/auction/events.go b/x/auction/events.go new file mode 100644 index 0000000000..5355be8a4c --- /dev/null +++ b/x/auction/events.go @@ -0,0 +1,11 @@ +package auction + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/umee-network/umee/v6/util/sdkutil" +) + +func EmitFundRewardsAuction(ctx *sdk.Context, coins sdk.Coins) { + sdkutil.Emit(ctx, &EventFundRewardsAuction{Assets: coins}) +} diff --git a/x/auction/events.pb.go b/x/auction/events.pb.go index b05b729fe1..0c54dbcf56 100644 --- a/x/auction/events.pb.go +++ b/x/auction/events.pb.go @@ -66,33 +66,74 @@ func (m *EventRewardsAuctionResult) XXX_DiscardUnknown() { var xxx_messageInfo_EventRewardsAuctionResult proto.InternalMessageInfo +// EventFundRewardsAuction is emitted when sending rewards to auction module +type EventFundRewardsAuction struct { + Assets []types.Coin `protobuf:"bytes,1,rep,name=assets,proto3" json:"assets"` +} + +func (m *EventFundRewardsAuction) Reset() { *m = EventFundRewardsAuction{} } +func (m *EventFundRewardsAuction) String() string { return proto.CompactTextString(m) } +func (*EventFundRewardsAuction) ProtoMessage() {} +func (*EventFundRewardsAuction) Descriptor() ([]byte, []int) { + return fileDescriptor_b5998c755af8caa1, []int{1} +} +func (m *EventFundRewardsAuction) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventFundRewardsAuction) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EventFundRewardsAuction.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 *EventFundRewardsAuction) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventFundRewardsAuction.Merge(m, src) +} +func (m *EventFundRewardsAuction) XXX_Size() int { + return m.Size() +} +func (m *EventFundRewardsAuction) XXX_DiscardUnknown() { + xxx_messageInfo_EventFundRewardsAuction.DiscardUnknown(m) +} + +var xxx_messageInfo_EventFundRewardsAuction proto.InternalMessageInfo + func init() { proto.RegisterType((*EventRewardsAuctionResult)(nil), "umee.auction.v1.EventRewardsAuctionResult") + proto.RegisterType((*EventFundRewardsAuction)(nil), "umee.auction.v1.EventFundRewardsAuction") } func init() { proto.RegisterFile("umee/auction/v1/events.proto", fileDescriptor_b5998c755af8caa1) } var fileDescriptor_b5998c755af8caa1 = []byte{ - // 294 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x34, 0x90, 0xb1, 0x4a, 0xc4, 0x30, - 0x18, 0xc7, 0x9b, 0xf3, 0x38, 0xb1, 0xa2, 0x42, 0xb9, 0xa1, 0x3d, 0x24, 0x16, 0xa7, 0x3a, 0x5c, - 0x62, 0x15, 0x04, 0xc7, 0xab, 0x88, 0x7b, 0xdd, 0x5c, 0xa4, 0x6d, 0x42, 0x0d, 0xda, 0x44, 0x92, - 0xb4, 0xe7, 0x63, 0x38, 0xfa, 0x20, 0x3e, 0x44, 0xc7, 0xc3, 0xc9, 0x49, 0xb4, 0x7d, 0x11, 0x69, - 0x93, 0xdb, 0xf2, 0xe7, 0xf7, 0x23, 0xff, 0xef, 0xfb, 0xdc, 0xe3, 0xba, 0xa2, 0x14, 0x67, 0x75, - 0xa1, 0x99, 0xe0, 0xb8, 0x89, 0x31, 0x6d, 0x28, 0xd7, 0x0a, 0xbd, 0x4a, 0xa1, 0x85, 0x77, 0x34, - 0x50, 0x64, 0x29, 0x6a, 0xe2, 0xc5, 0xbc, 0x14, 0xa5, 0x18, 0x19, 0x1e, 0x5e, 0x46, 0x5b, 0x04, - 0x85, 0x50, 0x95, 0x50, 0x8f, 0x06, 0x98, 0x60, 0x11, 0x34, 0x09, 0xe7, 0x99, 0xa2, 0xb8, 0x89, - 0x73, 0xaa, 0xb3, 0x18, 0x17, 0x82, 0x71, 0xc3, 0x4f, 0x3f, 0x80, 0x1b, 0xdc, 0x0e, 0x95, 0x29, - 0x5d, 0x67, 0x92, 0xa8, 0x95, 0xe9, 0x4a, 0xa9, 0xaa, 0x5f, 0xb4, 0x77, 0xe8, 0x4e, 0x18, 0xf1, - 0x41, 0x08, 0xa2, 0x83, 0x74, 0xc2, 0x88, 0x77, 0xee, 0xce, 0x72, 0x46, 0x08, 0x95, 0xfe, 0x24, - 0x04, 0xd1, 0x5e, 0xe2, 0x7f, 0x7d, 0x2e, 0xe7, 0xb6, 0x6f, 0x45, 0x88, 0xa4, 0x4a, 0xdd, 0x6b, - 0xc9, 0x78, 0x99, 0x5a, 0xcf, 0xbb, 0x76, 0x77, 0xa5, 0xf9, 0xd9, 0x9f, 0x86, 0x3b, 0xd1, 0xfe, - 0x45, 0x80, 0xac, 0x3f, 0x4c, 0x84, 0xec, 0x44, 0xe8, 0x46, 0x30, 0x9e, 0x4c, 0xdb, 0x9f, 0x13, - 0x27, 0xdd, 0xfa, 0xc9, 0x5d, 0xfb, 0x07, 0x9d, 0xb6, 0x83, 0x60, 0xd3, 0x41, 0xf0, 0xdb, 0x41, - 0xf0, 0xde, 0x43, 0x67, 0xd3, 0x43, 0xe7, 0xbb, 0x87, 0xce, 0xc3, 0x59, 0xc9, 0xf4, 0x53, 0x9d, - 0xa3, 0x42, 0x54, 0x78, 0xb8, 0xd2, 0x92, 0x53, 0xbd, 0x16, 0xf2, 0x79, 0x0c, 0xb8, 0xb9, 0xc2, - 0x6f, 0xdb, 0xab, 0xe6, 0xb3, 0x71, 0xd5, 0xcb, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0x05, 0x11, - 0xf0, 0x01, 0x6c, 0x01, 0x00, 0x00, + // 321 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x91, 0xb1, 0x4a,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x9c, 0x7a, 0x2f, 0xbc, 0x80, 0x9b, 0xda, 0x6d, 0x8e, 0xda, 0x83, + 0x8d, 0xd1, 0xf6, 0x49, 0x0f, 0x7b, 0xbf, 0x6e, 0x84, 0x7d, 0x23, 0x7c, 0xa9, 0x84, 0x9c, 0xb6, + 0x17, 0x5f, 0x87, 0x01, 0x5d, 0xfb, 0x43, 0x0a, 0xf7, 0x9b, 0x66, 0xd7, 0x85, 0x64, 0x7f, 0xdb, + 0x85, 0xe7, 0xb0, 0x93, 0x18, 0xc3, 0xad, 0x89, 0xc0, 0xff, 0x96, 0x7a, 0x7d, 0x7a, 0xb3, 0xf8, + 0x41, 0xc1, 0x62, 0x85, 0xc0, 0x72, 0x85, 0xc0, 0xf7, 0x0a, 0x81, 0xd7, 0x0a, 0x05, 0xcb, 0x0a, + 0x05, 0x9f, 0x15, 0x0a, 0xee, 0x8e, 0x72, 0x61, 0x1f, 0x8a, 0x14, 0x67, 0x6a, 0x46, 0xea, 0xcb, + 0x8f, 0x25, 0xb7, 0x73, 0xa5, 0x1f, 0x9b, 0x81, 0x94, 0x67, 0xe4, 0x65, 0xfd, 0x53, 0x69, 0xa7, + 0x39, 0xdf, 0xe9, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x37, 0xa7, 0x36, 0xeb, 0xc0, 0x01, 0x00, + 0x00, } func (m *EventRewardsAuctionResult) Marshal() (dAtA []byte, err error) { @@ -144,6 +185,43 @@ func (m *EventRewardsAuctionResult) MarshalToSizedBuffer(dAtA []byte) (int, erro return len(dAtA) - i, nil } +func (m *EventFundRewardsAuction) 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 *EventFundRewardsAuction) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventFundRewardsAuction) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Assets) > 0 { + for iNdEx := len(m.Assets) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Assets[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintEvents(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + func encodeVarintEvents(dAtA []byte, offset int, v uint64) int { offset -= sovEvents(v) base := offset @@ -177,6 +255,21 @@ func (m *EventRewardsAuctionResult) Size() (n int) { return n } +func (m *EventFundRewardsAuction) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Assets) > 0 { + for _, e := range m.Assets { + l = e.Size() + n += 1 + l + sovEvents(uint64(l)) + } + } + return n +} + func sovEvents(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -318,6 +411,90 @@ func (m *EventRewardsAuctionResult) Unmarshal(dAtA []byte) error { } return nil } +func (m *EventFundRewardsAuction) 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 ErrIntOverflowEvents + } + 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: EventFundRewardsAuction: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventFundRewardsAuction: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Assets", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthEvents + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Assets = append(m.Assets, types.Coin{}) + if err := m.Assets[len(m.Assets)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipEvents(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvents + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipEvents(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/leverage/keeper/oracle.go b/x/leverage/keeper/oracle.go index b721dcf48b..872f0a7b2b 100644 --- a/x/leverage/keeper/oracle.go +++ b/x/leverage/keeper/oracle.go @@ -296,7 +296,7 @@ func (k Keeper) fundModules(ctx sdk.Context, toOracle, toAuction sdk.Coins) erro } } if !toAuctionCheck.IsZero() { - sdkutil.Emit(&ctx, &types.EventFundAuction{Assets: toOracleCheck}) + auction.EmitFundRewardsAuction(&ctx, toOracleCheck) return send(ctx, types.ModuleName, auction.ModuleName, toAuctionCheck) } diff --git a/x/leverage/types/events.pb.go b/x/leverage/types/events.pb.go index 610e0a47bc..03065ec232 100644 --- a/x/leverage/types/events.pb.go +++ b/x/leverage/types/events.pb.go @@ -487,44 +487,6 @@ func (m *EventFundOracle) XXX_DiscardUnknown() { var xxx_messageInfo_EventFundOracle proto.InternalMessageInfo -// EventFundAuction is emitted when sending rewards to auction module -type EventFundAuction struct { - Assets []types.Coin `protobuf:"bytes,1,rep,name=assets,proto3" json:"assets"` -} - -func (m *EventFundAuction) Reset() { *m = EventFundAuction{} } -func (m *EventFundAuction) String() string { return proto.CompactTextString(m) } -func (*EventFundAuction) ProtoMessage() {} -func (*EventFundAuction) Descriptor() ([]byte, []int) { - return fileDescriptor_aaf62b4902d7471c, []int{11} -} -func (m *EventFundAuction) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *EventFundAuction) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_EventFundAuction.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 *EventFundAuction) XXX_Merge(src proto.Message) { - xxx_messageInfo_EventFundAuction.Merge(m, src) -} -func (m *EventFundAuction) XXX_Size() int { - return m.Size() -} -func (m *EventFundAuction) XXX_DiscardUnknown() { - xxx_messageInfo_EventFundAuction.DiscardUnknown(m) -} - -var xxx_messageInfo_EventFundAuction proto.InternalMessageInfo - func init() { proto.RegisterType((*EventSupply)(nil), "umee.leverage.v1.EventSupply") proto.RegisterType((*EventWithdraw)(nil), "umee.leverage.v1.EventWithdraw") @@ -537,55 +499,53 @@ func init() { proto.RegisterType((*EventRepayBadDebt)(nil), "umee.leverage.v1.EventRepayBadDebt") proto.RegisterType((*EventReservesExhausted)(nil), "umee.leverage.v1.EventReservesExhausted") proto.RegisterType((*EventFundOracle)(nil), "umee.leverage.v1.EventFundOracle") - proto.RegisterType((*EventFundAuction)(nil), "umee.leverage.v1.EventFundAuction") } func init() { proto.RegisterFile("umee/leverage/v1/events.proto", fileDescriptor_aaf62b4902d7471c) } var fileDescriptor_aaf62b4902d7471c = []byte{ - // 660 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x96, 0xcb, 0x6e, 0xd4, 0x30, - 0x14, 0x86, 0xc7, 0x33, 0x43, 0xd5, 0xba, 0xf4, 0x42, 0x54, 0xa1, 0xb4, 0x82, 0x50, 0xb2, 0xea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, 0x78, 0xed, 0x64, 0x9d, 0x67, 0x87, 0xbf, 0x9c, 0xc6, 0xe1, 0xb1, 0x83, - 0x8e, 0x8e, 0x1d, 0xf4, 0xf3, 0xd8, 0x41, 0xef, 0x4f, 0x9c, 0xc6, 0xd1, 0x89, 0xd3, 0xf8, 0x76, - 0xe2, 0x34, 0x5e, 0xde, 0x88, 0x98, 0xee, 0xa7, 0x81, 0x17, 0x8a, 0x81, 0x9f, 0xdd, 0xee, 0xcb, - 0x1c, 0xf4, 0xae, 0x90, 0x3b, 0x66, 0xe1, 0x0f, 0xef, 0xfa, 0x7b, 0xe5, 0xe7, 0x80, 0xde, 0x4f, - 0x40, 0x05, 0x63, 0xe6, 0xa2, 0xbe, 0xf5, 0x3b, 0x00, 0x00, 0xff, 0xff, 0x56, 0x89, 0x02, 0x0b, - 0x2c, 0x08, 0x00, 0x00, + // 647 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x95, 0xcb, 0x6e, 0xd4, 0x3c, + 0x14, 0xc7, 0xc7, 0x33, 0xf3, 0x55, 0xad, 0xfb, 0xf5, 0x42, 0x54, 0xa1, 0xb4, 0x82, 0x50, 0xb2, + 0xea, 0xa6, 0x09, 0xe5, 0x2e, 0xb1, 0x40, 0x9d, 0x5e, 0x04, 0x15, 0x02, 0x69, 0xba, 0x40, 0x62, + 0x33, 0x72, 0xe2, 0xa3, 0x8c, 0xd5, 0x24, 0x0e, 0xb6, 0x93, 0x5e, 0xd8, 0x80, 0x78, 0x01, 0xde, + 0x80, 0x87, 0x00, 0x1e, 0x80, 0x5d, 0x97, 0x15, 0x2b, 0x16, 0x08, 0x41, 0xfb, 0x22, 0x28, 0x4e, + 0x3a, 0x19, 0x56, 0xa4, 0x59, 0xc0, 0x2e, 0x3e, 0xfe, 0xff, 0xcf, 0xf9, 0x1d, 0xfb, 0x44, 0xc6, + 0x57, 0xd3, 0x08, 0xc0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} func (m *EventSupply) Marshal() (dAtA []byte, err error) { @@ -1093,43 +1053,6 @@ func (m *EventFundOracle) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *EventFundAuction) 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 *EventFundAuction) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *EventFundAuction) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Assets) > 0 { - for iNdEx := len(m.Assets) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Assets[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintEvents(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - func encodeVarintEvents(dAtA []byte, offset int, v uint64) int { offset -= sovEvents(v) base := offset @@ -1330,21 +1253,6 @@ func (m *EventFundOracle) Size() (n int) { return n } -func (m *EventFundAuction) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.Assets) > 0 { - for _, e := range m.Assets { - l = e.Size() - n += 1 + l + sovEvents(uint64(l)) - } - } - return n -} - func sovEvents(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -2790,90 +2698,6 @@ func (m *EventFundOracle) Unmarshal(dAtA []byte) error { } return nil } -func (m *EventFundAuction) 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 ErrIntOverflowEvents - } - 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: EventFundAuction: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: EventFundAuction: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Assets", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvents - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthEvents - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthEvents - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Assets = append(m.Assets, types.Coin{}) - if err := m.Assets[len(m.Assets)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipEvents(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthEvents - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} func skipEvents(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/metoken/expected_keepers.go b/x/metoken/expected_keepers.go index 0fbe27a669..b8104d6e70 100644 --- a/x/metoken/expected_keepers.go +++ b/x/metoken/expected_keepers.go @@ -17,6 +17,9 @@ type BankKeeper interface { SendCoinsFromAccountToModule( ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins, ) error + SendCoinsFromModuleToModule( + ctx sdk.Context, senderModule, recipientModule string, amt sdk.Coins, + ) error } // LeverageKeeper interface for interacting with x/leverage diff --git a/x/metoken/genesis.go b/x/metoken/genesis.go index d08de69792..8801884821 100644 --- a/x/metoken/genesis.go +++ b/x/metoken/genesis.go @@ -105,13 +105,11 @@ func (ib IndexBalances) AssetBalance(denom string) (AssetBalance, int) { // SetAssetBalance overrides an asset balance if exists in the list, otherwise add it to the list. func (ib *IndexBalances) SetAssetBalance(balance AssetBalance) { _, i := ib.AssetBalance(balance.Denom) - if i < 0 { ib.AssetBalances = append(ib.AssetBalances, balance) - return + } else { + ib.AssetBalances[i] = balance } - - ib.AssetBalances[i] = balance } // NewZeroAssetBalance creates a new AssetBalance object with all balances in zero. diff --git a/x/metoken/keeper/fee.go b/x/metoken/keeper/fee.go index e043208caf..e3f7c54b88 100644 --- a/x/metoken/keeper/fee.go +++ b/x/metoken/keeper/fee.go @@ -3,6 +3,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/umee-network/umee/v6/x/metoken" ) diff --git a/x/metoken/keeper/intest/msg_server_test.go b/x/metoken/keeper/intest/msg_server_test.go index 62a6f108ee..36b6eded44 100644 --- a/x/metoken/keeper/intest/msg_server_test.go +++ b/x/metoken/keeper/intest/msg_server_test.go @@ -129,6 +129,7 @@ func TestMsgServer_Swap(t *testing.T) { }, } + params := app.MetokenKeeperB.Keeper(&ctx).GetParams() for _, tc := range tcs { msg := &metoken.MsgSwap{ User: tc.addr.String(), @@ -143,15 +144,13 @@ func TestMsgServer_Swap(t *testing.T) { k := app.MetokenKeeperB.Keeper(&ctx) // initial state - iUserBalance := app.BankKeeper.GetAllBalances(ctx, tc.addr) + iUserAllBalances := app.BankKeeper.GetAllBalances(ctx, tc.addr) iUTokenSupply := app.LeverageKeeper.GetAllUTokenSupply(ctx) iMeTokenBalance, err := k.IndexBalances(meTokenDenom) require.NoError(err) - prices, err := k.Prices(index) require.NoError(err) - // verify the outputs of swap function resp, err := msgServer.Swap(ctx, msg) require.NoError(err, tc.name) @@ -164,8 +163,9 @@ func TestMsgServer_Swap(t *testing.T) { verifySwap( t, tc, + params, index, - iUserBalance, + iUserAllBalances, fUserBalance, iUTokenSupply, fUTokenSupply, @@ -225,6 +225,7 @@ func TestMsgServer_Swap_NonStableAssets_DiffExponents(t *testing.T) { }, } + params := app.MetokenKeeperB.Keeper(&ctx).GetParams() for _, tc := range tcs { msg := &metoken.MsgSwap{ User: tc.addr.String(), @@ -239,7 +240,7 @@ func TestMsgServer_Swap_NonStableAssets_DiffExponents(t *testing.T) { k := app.MetokenKeeperB.Keeper(&ctx) // initial state - iUserBalance := app.BankKeeper.GetAllBalances(ctx, tc.addr) + iUserAllBalances := app.BankKeeper.GetAllBalances(ctx, tc.addr) iUTokenSupply := app.LeverageKeeper.GetAllUTokenSupply(ctx) iMeTokenBalance, err := k.IndexBalances(meTokenDenom) require.NoError(err) @@ -263,8 +264,9 @@ func TestMsgServer_Swap_NonStableAssets_DiffExponents(t *testing.T) { verifySwap( t, tc, + params, index, - iUserBalance, + iUserAllBalances, fUserBalance, iUTokenSupply, fUTokenSupply, @@ -324,7 +326,7 @@ func TestMsgServer_Swap_AfterAddingAssetToIndex(t *testing.T) { "", }, } - + params := app.MetokenKeeperB.Keeper(&ctx).GetParams() for _, tc := range tcs { msg := &metoken.MsgSwap{ User: tc.addr.String(), @@ -339,7 +341,7 @@ func TestMsgServer_Swap_AfterAddingAssetToIndex(t *testing.T) { k := app.MetokenKeeperB.Keeper(&ctx) // initial state - iUserBalance := app.BankKeeper.GetAllBalances(ctx, tc.addr) + iUserAllBalances := app.BankKeeper.GetAllBalances(ctx, tc.addr) iUTokenSupply := app.LeverageKeeper.GetAllUTokenSupply(ctx) iMeTokenBalance, err := k.IndexBalances(meTokenDenom) require.NoError(err) @@ -360,8 +362,9 @@ func TestMsgServer_Swap_AfterAddingAssetToIndex(t *testing.T) { verifySwap( t, tc, + params, index, - iUserBalance, + iUserAllBalances, fUserBalance, iUTokenSupply, fUTokenSupply, @@ -443,15 +446,13 @@ func TestMsgServer_Swap_AfterAddingAssetToIndex(t *testing.T) { k := app.MetokenKeeperB.Keeper(&ctx) // initial state - iUserBalance := app.BankKeeper.GetAllBalances(ctx, tc.addr) + iUserAllBalances := app.BankKeeper.GetAllBalances(ctx, tc.addr) iUTokenSupply := app.LeverageKeeper.GetAllUTokenSupply(ctx) iMeTokenBalance, err := k.IndexBalances(meTokenDenom) require.NoError(err) - prices, err := k.Prices(index) require.NoError(err) - // verify the outputs of swap function resp, err := msgServer.Swap(ctx, msg) require.NoError(err, tc.name) @@ -464,8 +465,9 @@ func TestMsgServer_Swap_AfterAddingAssetToIndex(t *testing.T) { verifySwap( t, tc, + params, index, - iUserBalance, + iUserAllBalances, fUserBalance, iUTokenSupply, fUTokenSupply, @@ -525,6 +527,7 @@ func TestMsgServer_Swap_Depegging(t *testing.T) { }, } + params := app.MetokenKeeperB.Keeper(&ctx).GetParams() for _, tc := range tcs { msg := &metoken.MsgSwap{ User: tc.addr.String(), @@ -539,15 +542,13 @@ func TestMsgServer_Swap_Depegging(t *testing.T) { k := app.MetokenKeeperB.Keeper(&ctx) // initial state - iUserBalance := app.BankKeeper.GetAllBalances(ctx, tc.addr) + iUserAllBalances := app.BankKeeper.GetAllBalances(ctx, tc.addr) iUTokenSupply := app.LeverageKeeper.GetAllUTokenSupply(ctx) iMeTokenBalance, err := k.IndexBalances(meTokenDenom) require.NoError(err) - prices, err := k.Prices(index) require.NoError(err) - // verify the outputs of swap function resp, err := msgServer.Swap(ctx, msg) require.NoError(err, tc.name) @@ -560,8 +561,9 @@ func TestMsgServer_Swap_Depegging(t *testing.T) { verifySwap( t, tc, + params, index, - iUserBalance, + iUserAllBalances, fUserBalance, iUTokenSupply, fUTokenSupply, @@ -663,7 +665,7 @@ func TestMsgServer_Swap_Depegging(t *testing.T) { k := app.MetokenKeeperB.Keeper(&ctx) // initial state - iUserBalance := app.BankKeeper.GetAllBalances(ctx, tc.addr) + iUserAllBalances := app.BankKeeper.GetAllBalances(ctx, tc.addr) iUTokenSupply := app.LeverageKeeper.GetAllUTokenSupply(ctx) iMeTokenBalance, err := k.IndexBalances(meTokenDenom) require.NoError(err) @@ -684,8 +686,9 @@ func TestMsgServer_Swap_Depegging(t *testing.T) { verifySwap( t, tc, + params, index, - iUserBalance, + iUserAllBalances, fUserBalance, iUTokenSupply, fUTokenSupply, @@ -760,7 +763,7 @@ func TestMsgServer_Swap_Depegging(t *testing.T) { k := app.MetokenKeeperB.Keeper(&ctx) // initial state - iUserBalance := app.BankKeeper.GetAllBalances(ctx, tc.addr) + iUserAllBalances := app.BankKeeper.GetAllBalances(ctx, tc.addr) iUTokenSupply := app.LeverageKeeper.GetAllUTokenSupply(ctx) iMeTokenBalance, err := k.IndexBalances(meTokenDenom) require.NoError(err) @@ -781,8 +784,9 @@ func TestMsgServer_Swap_Depegging(t *testing.T) { verifySwap( t, tc, + params, index, - iUserBalance, + iUserAllBalances, fUserBalance, iUTokenSupply, fUTokenSupply, @@ -837,9 +841,10 @@ func TestMsgServer_Swap_EdgeCase(t *testing.T) { require.Equal(iMeTokenBalance, fMeTokenBalance) } +// i=initial f=final func verifySwap( - t *testing.T, tc testCase, index metoken.Index, - iUserBalance, fUserBalance, iUTokenSupply, fUTokenSupply sdk.Coins, + t *testing.T, tc testCase, params metoken.Params, index metoken.Index, + iUserAllBalances, fUserBalance, iUTokenSupply, fUTokenSupply sdk.Coins, iMeTokenBalance, fMeTokenBalance metoken.IndexBalances, prices metoken.IndexPrices, resp metoken.MsgSwapResponse, ) { @@ -847,26 +852,24 @@ func verifySwap( // initial state assetPrice, err := prices.PriceByBaseDenom(denom) - assert.NilError(t, err) + assert.NilError(t, err, tc.name) iAssetBalance, i := iMeTokenBalance.AssetBalance(denom) - assert.Check(t, i >= 0) + assert.Check(t, i >= 0, tc.name) assetSupply := iAssetBalance.Leveraged.Add(iAssetBalance.Reserved) - assetExponentFactorVsUSD, err := metoken.ExponentFactor(assetPrice.Exponent, 0) - assert.NilError(t, err) - decAssetSupply := assetExponentFactorVsUSD.MulInt(assetSupply) - assetValue := decAssetSupply.Mul(assetPrice.Price) + factor, err := metoken.ExponentFactor(assetPrice.Exponent, 0) + assert.NilError(t, err, tc.name) + assetValue := factor.MulInt(assetSupply).Mul(assetPrice.Price) - meTokenExponentFactor, err := metoken.ExponentFactor(prices.Exponent, 0) - assert.NilError(t, err) - decMeTokenSupply := meTokenExponentFactor.MulInt(iMeTokenBalance.MetokenSupply.Amount) - meTokenValue := decMeTokenSupply.Mul(prices.Price) + factor, err = metoken.ExponentFactor(prices.Exponent, 0) + assert.NilError(t, err, tc.name) + meTokenValue := factor.MulInt(iMeTokenBalance.MetokenSupply.Amount).Mul(prices.Price) // current_allocation = asset_value / total_value // swap_delta_allocation = (current_allocation - target_allocation) / target_allocation currentAllocation, swapDeltaAllocation := sdk.ZeroDec(), sdk.ZeroDec() aa, i := index.AcceptedAsset(denom) - assert.Check(t, i >= 0) + assert.Check(t, i >= 0, tc.name) targetAllocation := aa.TargetAllocation if assetSupply.IsZero() { @@ -876,38 +879,36 @@ func verifySwap( swapDeltaAllocation = currentAllocation.Sub(targetAllocation).Quo(targetAllocation) } - // fee = delta_allocation * balanced_fee + balanced_fee - fee := swapDeltaAllocation.Mul(index.Fee.BalancedFee).Add(index.Fee.BalancedFee) - if fee.LT(index.Fee.MinFee) { - fee = index.Fee.MinFee - } - if fee.GT(index.Fee.MaxFee) { - fee = index.Fee.MaxFee + // feeRate = delta_allocation * balanced_fee + balanced_fee + feeRate := swapDeltaAllocation.Mul(index.Fee.BalancedFee).Add(index.Fee.BalancedFee) + if feeRate.LT(index.Fee.MinFee) { + feeRate = index.Fee.MinFee + } else if feeRate.GT(index.Fee.MaxFee) { + feeRate = index.Fee.MaxFee } - // if current_allocation = 0, fee = min_fee + // if current_allocation = 0, feeRate = min_fee if !currentAllocation.IsPositive() { - fee = index.Fee.MinFee + feeRate = index.Fee.MinFee } - // expected_fee = fee * amount - expectedFee := sdk.NewCoin(denom, fee.MulInt(tc.asset.Amount).TruncateInt()) + // totalfee = feeRate * amount + totalFee := sdk.NewCoin(denom, feeRate.MulInt(tc.asset.Amount).TruncateInt()) + feeToAuction := params.RewardsAuctionFactor.Mul(totalFee.Amount) + feeToReserve := totalFee.Amount.Sub(feeToAuction) // amount_to_swap = swap_amount - fee - amountToSwap := tc.asset.Amount.Sub(expectedFee.Amount) + amountToSwap := tc.asset.Amount.Sub(totalFee.Amount) // swap_exchange_rate = asset_price / metoken_price exchangeRate := assetPrice.Price.Quo(prices.Price) assetExponentFactorVsMeToken, err := metoken.ExponentFactor(assetPrice.Exponent, prices.Exponent) - assert.NilError(t, err) + assert.NilError(t, err, tc.name) rate := exchangeRate.Mul(assetExponentFactorVsMeToken) // expected_metokens = amount_to_swap * exchange_rate * exponent_factor - expectedMeTokens := sdk.NewCoin( - meTokenDenom, - rate.MulInt(amountToSwap).TruncateInt(), - ) + expectedMeTokens := sdk.NewCoin(meTokenDenom, rate.MulInt(amountToSwap).TruncateInt()) // calculating reserved and leveraged expectedReserved := sdk.NewCoin( @@ -918,32 +919,29 @@ func verifySwap( // verify the outputs of swap function require := require.New(t) - require.Equal(expectedFee, resp.Fee, tc.name) - require.Equal(expectedMeTokens, resp.Returned, tc.name) + require.Equal(totalFee, resp.Fee, tc.name, tc.name) + require.Equal(expectedMeTokens, resp.Returned, tc.name, tc.name) // verify token balance decreased and meToken balance increased by the expected amounts require.Equal( - iUserBalance.Sub(tc.asset).Add(expectedMeTokens), + iUserAllBalances.Sub(tc.asset).Add(expectedMeTokens), fUserBalance, tc.name, - "token balance", ) // verify uToken assetSupply increased by the expected amount require.Equal( iUTokenSupply.Add(sdk.NewCoin("u/"+expectedLeveraged.Denom, expectedLeveraged.Amount)), fUTokenSupply, tc.name, - "uToken assetSupply", ) // reserved + leveraged + fee must be = to total amount supplied by the user for the swap - require.Equal(expectedReserved.Add(expectedLeveraged).Add(expectedFee), tc.asset) + require.Equal(expectedReserved.Add(expectedLeveraged).Add(totalFee), tc.asset, tc.name) // meToken assetSupply is increased by the expected amount require.Equal( iMeTokenBalance.MetokenSupply.Add(expectedMeTokens), fMeTokenBalance.MetokenSupply, tc.name, - "meToken assetSupply", ) fAssetBalance, i := fMeTokenBalance.AssetBalance(denom) @@ -951,17 +949,17 @@ func verifySwap( require.Equal( iAssetBalance.Reserved.Add(expectedReserved.Amount), fAssetBalance.Reserved, - "reserved", + tc.name, ) require.Equal( iAssetBalance.Leveraged.Add(expectedLeveraged.Amount), fAssetBalance.Leveraged, - "leveraged", + tc.name, ) require.Equal( - iAssetBalance.Fees.Add(expectedFee.Amount), + iAssetBalance.Fees.Add(feeToReserve), fAssetBalance.Fees, - "fee", + tc.name, ) } @@ -1090,6 +1088,7 @@ func TestMsgServer_Redeem(t *testing.T) { }, } + params := app.MetokenKeeperB.Keeper(&ctx).GetParams() for _, tc := range tcs { msg := &metoken.MsgRedeem{ User: tc.addr.String(), @@ -1125,6 +1124,7 @@ func TestMsgServer_Redeem(t *testing.T) { verifyRedeem( t, tc, + params, index, iUserBalance, fUserBalance, @@ -1225,6 +1225,7 @@ func TestMsgServer_Redeem_NonStableAssets_DiffExponents(t *testing.T) { }, } + params := app.MetokenKeeperB.Keeper(&ctx).GetParams() for _, tc := range tcs { msg := &metoken.MsgRedeem{ User: tc.addr.String(), @@ -1260,6 +1261,7 @@ func TestMsgServer_Redeem_NonStableAssets_DiffExponents(t *testing.T) { verifyRedeem( t, tc, + params, index, iUserBalance, fUserBalance, @@ -1390,6 +1392,7 @@ func TestMsgServer_Redeem_Depegging(t *testing.T) { }, } + params := app.MetokenKeeperB.Keeper(&ctx).GetParams() for _, tc := range tcs { msg := &metoken.MsgRedeem{ User: tc.addr.String(), @@ -1425,6 +1428,7 @@ func TestMsgServer_Redeem_Depegging(t *testing.T) { verifyRedeem( t, tc, + params, index, iUserBalance, fUserBalance, @@ -1522,6 +1526,7 @@ func TestMsgServer_Redeem_Depegging(t *testing.T) { verifySwap( t, tc, + params, index, iUserBalance, fUserBalance, @@ -1595,6 +1600,7 @@ func TestMsgServer_Redeem_Depegging(t *testing.T) { verifyRedeem( t, tc, + params, index, iUserBalance, fUserBalance, @@ -1657,8 +1663,8 @@ func TestMsgServer_Redeem_EdgeCase(t *testing.T) { } func verifyRedeem( - t *testing.T, tc testCase, index metoken.Index, - iUserBalance, fUserBalance, iUTokenSupply, fUTokenSupply sdk.Coins, + t *testing.T, tc testCase, params metoken.Params, index metoken.Index, + iUserAllBalances, fUserBalance, iUTokenSupply, fUTokenSupply sdk.Coins, iMeTokenBalance, fMeTokenBalance metoken.IndexBalances, prices metoken.IndexPrices, resp metoken.MsgRedeemResponse, ) { @@ -1669,15 +1675,13 @@ func verifyRedeem( assert.Check(t, i >= 0) assetSupply := iAssetBalance.Leveraged.Add(iAssetBalance.Reserved) - assetExponentFactorVsUSD, err := metoken.ExponentFactor(assetPrice.Exponent, 0) + factor, err := metoken.ExponentFactor(assetPrice.Exponent, 0) assert.NilError(t, err) - decAssetSupply := assetExponentFactorVsUSD.MulInt(assetSupply) - assetValue := decAssetSupply.Mul(assetPrice.Price) + assetValue := factor.MulInt(assetSupply).Mul(assetPrice.Price) - meTokenExponentFactor, err := metoken.ExponentFactor(prices.Exponent, 0) + factor, err = metoken.ExponentFactor(prices.Exponent, 0) assert.NilError(t, err) - decMeTokenSupply := meTokenExponentFactor.MulInt(iMeTokenBalance.MetokenSupply.Amount) - meTokenValue := decMeTokenSupply.Mul(prices.Price) + meTokenValue := factor.MulInt(iMeTokenBalance.MetokenSupply.Amount).Mul(prices.Price) // current_allocation = asset_value / total_value // redeem_delta_allocation = (target_allocation - current_allocation) / target_allocation @@ -1692,13 +1696,12 @@ func verifyRedeem( redeemDeltaAllocation = targetAllocation.Sub(currentAllocation).Quo(targetAllocation) } - // fee = delta_allocation * balanced_fee + balanced_fee - fee := redeemDeltaAllocation.Mul(index.Fee.BalancedFee).Add(index.Fee.BalancedFee) - if fee.LT(index.Fee.MinFee) { - fee = index.Fee.MinFee - } - if fee.GT(index.Fee.MaxFee) { - fee = index.Fee.MaxFee + // feeRate = delta_allocation * balanced_fee + balanced_fee + feeRate := redeemDeltaAllocation.Mul(index.Fee.BalancedFee).Add(index.Fee.BalancedFee) + if feeRate.LT(index.Fee.MinFee) { + feeRate = index.Fee.MinFee + } else if feeRate.GT(index.Fee.MaxFee) { + feeRate = index.Fee.MaxFee } // redeem_exchange_rate = metoken_price / asset_price redeemExchangeRate := prices.Price.Quo(assetPrice.Price) @@ -1709,12 +1712,12 @@ func verifyRedeem( // amount_to_redeem = exchange_rate * metoken_amount amountToWithdraw := redeemExchangeRate.MulInt(tc.asset.Amount).Mul(assetExponentFactorVsMeToken).TruncateInt() - // expected_fee = fee * amount_to_redeem - expectedFee := sdk.NewCoin(tc.denom, fee.MulInt(amountToWithdraw).TruncateInt()) - - // amount_to_redeem = amountToWithdraw - expectedFee - amountToRedeem := amountToWithdraw.Sub(expectedFee.Amount) + // totalfee = feeRate * amount_to_redeem + totalFee := sdk.NewCoin(tc.denom, feeRate.MulInt(amountToWithdraw).TruncateInt()) + feeToAuction := params.RewardsAuctionFactor.Mul(totalFee.Amount) + feeToReserve := totalFee.Amount.Sub(feeToAuction) + amountToRedeem := amountToWithdraw.Sub(totalFee.Amount) expectedAssets := sdk.NewCoin( tc.denom, amountToRedeem, @@ -1729,53 +1732,47 @@ func verifyRedeem( require := require.New(t) // verify the outputs of swap function - require.Equal(expectedFee, resp.Fee, tc.name, "expectedFee") + require.Equal(totalFee, resp.Fee, tc.name, "expectedFee") require.Equal(expectedAssets, resp.Returned, tc.name, "expectedAssets") // verify meToken balance decreased and asset balance increased by the expected amounts - require.True( - iUserBalance.Sub(tc.asset).Add(expectedAssets).IsEqual(fUserBalance), + require.Equal( + iUserAllBalances.Sub(tc.asset).Add(expectedAssets), fUserBalance, tc.name, - "token balance", ) // verify uToken assetSupply decreased by the expected amount - require.True( + require.Equal( iUTokenSupply.Sub( sdk.NewCoin( "u/"+expectedFromLeverage.Denom, expectedFromLeverage.Amount, ), - ).IsEqual(fUTokenSupply), + ), fUTokenSupply, tc.name, - "uToken assetSupply", ) // from_reserves + from_leverage must be = to total amount withdrawn from the modules - require.True( - expectedFromReserves.Amount.Add(expectedFromLeverage.Amount).Equal(amountToWithdraw), + require.Equal( + expectedFromReserves.Amount.Add(expectedFromLeverage.Amount), amountToWithdraw, tc.name, - "total withdraw", ) // meToken assetSupply is decreased by the expected amount - require.True( - iMeTokenBalance.MetokenSupply.Sub(tc.asset).IsEqual(fMeTokenBalance.MetokenSupply), + require.Equal( + iMeTokenBalance.MetokenSupply.Sub(tc.asset), fMeTokenBalance.MetokenSupply, tc.name, - "meToken assetSupply", ) fAssetBalance, i := fMeTokenBalance.AssetBalance(tc.denom) assert.Check(t, i >= 0) - require.True( - iAssetBalance.Reserved.Sub(expectedFromReserves.Amount).Equal(fAssetBalance.Reserved), + require.Equal( + iAssetBalance.Reserved.Sub(expectedFromReserves.Amount), fAssetBalance.Reserved, tc.name, - "reserved", ) - require.True( - iAssetBalance.Leveraged.Sub(expectedFromLeverage.Amount).Equal(fAssetBalance.Leveraged), + require.Equal( + iAssetBalance.Leveraged.Sub(expectedFromLeverage.Amount), fAssetBalance.Leveraged, tc.name, - "leveraged", ) - require.True(iAssetBalance.Fees.Add(expectedFee.Amount).Equal(fAssetBalance.Fees), tc.name, "fees") + require.Equal(iAssetBalance.Fees.Add(feeToReserve), fAssetBalance.Fees, tc.name) } func TestMsgServer_GovSetParams(t *testing.T) { diff --git a/x/metoken/keeper/mocks_test.go b/x/metoken/keeper/mocks_test.go index a99f520f48..8f9b11c350 100644 --- a/x/metoken/keeper/mocks_test.go +++ b/x/metoken/keeper/mocks_test.go @@ -103,3 +103,8 @@ func (b Bank) SendCoinsFromModuleToAccount(_ sdk.Context, _ string, _ sdk.AccAdd func (b Bank) SendCoinsFromAccountToModule(_ sdk.Context, _ sdk.AccAddress, _ string, _ sdk.Coins) error { return nil } + +func (b Bank) SendCoinsFromModuleToModule(ctx sdk.Context, senderModule, recipientModule string, amt sdk.Coins, +) error { + return nil +} diff --git a/x/metoken/keeper/redeem.go b/x/metoken/keeper/redeem.go index 0655b989da..5aa92f3260 100644 --- a/x/metoken/keeper/redeem.go +++ b/x/metoken/keeper/redeem.go @@ -93,7 +93,7 @@ func (k Keeper) redeem(userAddr sdk.AccAddress, meToken sdk.Coin, assetDenom str return redeemResponse{}, fmt.Errorf("not enough %s liquidity for redemption", assetDenom) } - _, feeAmount, err := k.redeemFee( + _, fees, err := k.redeemFee( index, indexPrices, sdk.NewCoin(assetDenom, amountFromReserves.Add(amountFromLeverage)), @@ -101,17 +101,17 @@ func (k Keeper) redeem(userAddr sdk.AccAddress, meToken sdk.Coin, assetDenom str if err != nil { return redeemResponse{}, err } + feeToAuction, feeToRevenue := k.breakFee(fees.Amount) + if err = k.fundAuction(fees.Denom, feeToAuction); err != nil { + return redeemResponse{}, err + } - if err = k.bankKeeper.SendCoinsFromAccountToModule( - *k.ctx, - userAddr, - metoken.ModuleName, - sdk.NewCoins(meToken), - ); err != nil { + err = k.bankKeeper.SendCoinsFromAccountToModule(*k.ctx, userAddr, metoken.ModuleName, sdk.Coins{meToken}) + if err != nil { return redeemResponse{}, err } - toRedeem := sdk.NewCoin(assetDenom, amountFromReserves.Add(amountFromLeverage).Sub(feeAmount.Amount)) + toRedeem := sdk.NewCoin(assetDenom, amountFromReserves.Add(amountFromLeverage).Sub(fees.Amount)) if err = k.bankKeeper.SendCoinsFromModuleToAccount( *k.ctx, metoken.ModuleName, @@ -127,7 +127,7 @@ func (k Keeper) redeem(userAddr sdk.AccAddress, meToken sdk.Coin, assetDenom str // update reserved, leveraged and fee balances balance.Reserved = balance.Reserved.Sub(amountFromReserves) balance.Leveraged = balance.Leveraged.Sub(amountFromLeverage) - balance.Fees = balance.Fees.Add(feeAmount.Amount) + balance.Fees = balance.Fees.Add(feeToRevenue) balances.SetAssetBalance(balance) // save index balance @@ -141,7 +141,7 @@ func (k Keeper) redeem(userAddr sdk.AccAddress, meToken sdk.Coin, assetDenom str } return newRedeemResponse( - feeAmount, + fees, sdk.NewCoin(assetDenom, amountFromReserves), sdk.NewCoin(assetDenom, amountFromLeverage), ), nil diff --git a/x/metoken/keeper/redeem_test.go b/x/metoken/keeper/redeem_test.go index c0987c4d90..4884fd712e 100644 --- a/x/metoken/keeper/redeem_test.go +++ b/x/metoken/keeper/redeem_test.go @@ -12,7 +12,7 @@ import ( ) func TestRedeem_Valid(t *testing.T) { - k := initMeUSDKeeper(t, NewBankMock(), NewLeverageMock(), NewOracleMock()) + k := initMeUSDNoopKeper(t) hundredUSDT := sdk.NewCoin(mocks.USDTBaseDenom, sdkmath.NewInt(100_000000)) _, err := k.swap(sdk.AccAddress{}, mocks.MeUSDDenom, hundredUSDT) @@ -44,7 +44,7 @@ func TestRedeem_Valid(t *testing.T) { } func TestRedeem_LeverageUndersupplied(t *testing.T) { - k := initMeUSDKeeper(t, NewBankMock(), NewLeverageMock(), NewOracleMock()) + k := initMeUSDNoopKeper(t) hundredUSDT := sdk.NewCoin(mocks.ISTBaseDenom, sdkmath.NewInt(100_000000)) _, err := k.swap(sdk.AccAddress{}, mocks.MeUSDDenom, hundredUSDT) diff --git a/x/metoken/keeper/swap.go b/x/metoken/keeper/swap.go index a793a08f58..10784efbb7 100644 --- a/x/metoken/keeper/swap.go +++ b/x/metoken/keeper/swap.go @@ -7,6 +7,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/umee-network/umee/v6/x/auction" "github.com/umee-network/umee/v6/x/metoken" "github.com/umee-network/umee/v6/x/metoken/errors" ) @@ -19,7 +20,7 @@ type swapResponse struct { leveraged sdk.Coin } -func newSwapResponse(meTokens sdk.Coin, fee sdk.Coin, reserved sdk.Coin, leveraged sdk.Coin) swapResponse { +func newSwapResponse(meTokens, fee, reserved, leveraged sdk.Coin) swapResponse { return swapResponse{ meTokens: meTokens, fee: fee, @@ -50,12 +51,13 @@ func (k Keeper) swap(userAddr sdk.AccAddress, meTokenDenom string, asset sdk.Coi return swapResponse{}, err } - meTokenAmount, fee, amountToReserves, amountToLeverage, err := k.calculateSwap(index, indexPrices, asset) + // meTokenAmount, fee, amountToReserves, amountToLeverage, err := + swapCarry, err := k.calculateSwap(index, indexPrices, asset) if err != nil { return swapResponse{}, err } - if meTokenAmount.IsZero() { + if swapCarry.meTokens.IsZero() { return swapResponse{}, fmt.Errorf("insufficient %s for swap", asset.Denom) } @@ -64,7 +66,7 @@ func (k Keeper) swap(userAddr sdk.AccAddress, meTokenDenom string, asset sdk.Coi return swapResponse{}, err } - if balances.MetokenSupply.Amount.Add(meTokenAmount).GT(index.MaxSupply) { + if balances.MetokenSupply.Amount.Add(swapCarry.meTokens).GT(index.MaxSupply) { return swapResponse{}, fmt.Errorf( "not possible to mint the desired amount of %s, reaching the max supply", meTokenDenom, @@ -80,39 +82,42 @@ func (k Keeper) swap(userAddr sdk.AccAddress, meTokenDenom string, asset sdk.Coi return swapResponse{}, err } - supplied, err := k.supplyToLeverage(sdk.NewCoin(asset.Denom, amountToLeverage)) + supplied, err := k.supplyToLeverage(sdk.NewCoin(asset.Denom, swapCarry.toLeverage)) if err != nil { return swapResponse{}, err } // adjust amount if supplied to x/leverage is less than the calculated amount - if supplied.LT(amountToLeverage) { - tokenDiff := amountToLeverage.Sub(supplied) - amountToReserves = amountToReserves.Add(tokenDiff) - amountToLeverage = amountToLeverage.Sub(tokenDiff) + if supplied.LT(swapCarry.toLeverage) { + tokenDiff := swapCarry.toLeverage.Sub(supplied) + swapCarry.toReserves = swapCarry.toReserves.Add(tokenDiff) + swapCarry.toLeverage = swapCarry.toLeverage.Sub(tokenDiff) } - meTokens := sdk.NewCoins(sdk.NewCoin(meTokenDenom, meTokenAmount)) + meTokens := sdk.NewCoins(sdk.NewCoin(meTokenDenom, swapCarry.meTokens)) if err = k.bankKeeper.MintCoins(*k.ctx, metoken.ModuleName, meTokens); err != nil { return swapResponse{}, err } + err = k.bankKeeper.SendCoinsFromModuleToAccount(*k.ctx, metoken.ModuleName, userAddr, meTokens) + if err != nil { + return swapResponse{}, err + } - if err = k.bankKeeper.SendCoinsFromModuleToAccount(*k.ctx, metoken.ModuleName, userAddr, meTokens); err != nil { + feeToAuction, feeToRevenue := k.breakFee(swapCarry.fee) + if err = k.fundAuction(asset.Denom, feeToAuction); err != nil { return swapResponse{}, err } - balances.MetokenSupply.Amount = balances.MetokenSupply.Amount.Add(meTokenAmount) + balances.MetokenSupply.Amount = balances.MetokenSupply.Amount.Add(swapCarry.meTokens) balance, i := balances.AssetBalance(asset.Denom) if i < 0 { return swapResponse{}, sdkerrors.ErrNotFound.Wrapf( - "balance for denom %s not found", - asset.Denom, - ) + "balance for denom %s not found", asset.Denom) } - balance.Reserved = balance.Reserved.Add(amountToReserves) - balance.Leveraged = balance.Leveraged.Add(amountToLeverage) - balance.Fees = balance.Fees.Add(fee) + balance.Reserved = balance.Reserved.Add(swapCarry.toReserves) + balance.Leveraged = balance.Leveraged.Add(swapCarry.toLeverage) + balance.Fees = balance.Fees.Add(feeToRevenue) balances.SetAssetBalance(balance) if err = k.setIndexBalances(balances); err != nil { @@ -120,10 +125,10 @@ func (k Keeper) swap(userAddr sdk.AccAddress, meTokenDenom string, asset sdk.Coi } return newSwapResponse( - sdk.NewCoin(meTokenDenom, meTokenAmount), - sdk.NewCoin(asset.Denom, fee), - sdk.NewCoin(asset.Denom, amountToReserves), - sdk.NewCoin(asset.Denom, amountToLeverage), + meTokens[0], + sdk.NewCoin(asset.Denom, swapCarry.fee), + sdk.NewCoin(asset.Denom, swapCarry.toReserves), + sdk.NewCoin(asset.Denom, swapCarry.toLeverage), ), nil } @@ -177,6 +182,13 @@ func (k Keeper) availableToSupply(denom string) (bool, sdkmath.Int, error) { return true, token.MaxSupply.Sub(total.Amount), nil } +// breakFee calculates the protocol fee for the burn auction and the reminder +func (k Keeper) breakFee(fee sdkmath.Int) (sdkmath.Int, sdkmath.Int) { + p := k.GetParams() + toAuction := p.RewardsAuctionFactor.Mul(fee) + return toAuction, fee.Sub(toAuction) +} + // calculateSwap returns the amount of meToken to send to the user, the fee to be charged to him, // the amount of assets to send to x/metoken reserves and to x/leverage pools. // The formulas used for the calculations are: @@ -186,37 +198,47 @@ func (k Keeper) availableToSupply(denom string) (bool, sdkmath.Int, error) { // amount_to_reserves = assets_to_swap * reserve_portion // amount_to_leverage = assets_to_swap - amount_to_reserves // -// It returns meTokens to be minted, fee to be charged, -// amount to transfer to x/metoken reserves and x/leverage liquidity pools +// It returns calculated amount of tokens that need to be transferred as a result of a transfer. func (k Keeper) calculateSwap(index metoken.Index, indexPrices metoken.IndexPrices, asset sdk.Coin) ( - sdkmath.Int, - sdkmath.Int, - sdkmath.Int, - sdkmath.Int, - error, + swapCarry, error, ) { assetSettings, i := index.AcceptedAsset(asset.Denom) if i < 0 { - return sdkmath.ZeroInt(), sdkmath.ZeroInt(), sdkmath.ZeroInt(), sdkmath.ZeroInt(), sdkerrors.ErrNotFound.Wrapf( + return swapCarry{}, sdkerrors.ErrNotFound.Wrapf( "asset %s is not accepted in the index", asset.Denom, ) } - _, feeAmount, err := k.swapFee(index, indexPrices, asset) + _, fee, err := k.swapFee(index, indexPrices, asset) if err != nil { - return sdkmath.ZeroInt(), sdkmath.ZeroInt(), sdkmath.ZeroInt(), sdkmath.ZeroInt(), err + return swapCarry{}, err } - amountToSwap := asset.Amount.Sub(feeAmount.Amount) - + amountToSwap := asset.Amount.Sub(fee.Amount) meTokens, err := indexPrices.SwapRate(sdk.NewCoin(asset.Denom, amountToSwap)) if err != nil { - return sdkmath.ZeroInt(), sdkmath.ZeroInt(), sdkmath.ZeroInt(), sdkmath.ZeroInt(), err + return swapCarry{}, err } - amountToReserves := assetSettings.ReservePortion.MulInt(amountToSwap).TruncateInt() - amountToLeverage := amountToSwap.Sub(amountToReserves) + toReserves := assetSettings.ReservePortion.MulInt(amountToSwap).TruncateInt() + toLeverage := amountToSwap.Sub(toReserves) + + return swapCarry{meTokens: meTokens, fee: fee.Amount, toReserves: toReserves, toLeverage: toLeverage}, nil +} + +func (k Keeper) fundAuction(denom string, amount sdkmath.Int) error { + if amount.IsZero() { + return nil + } + coins := sdk.Coins{sdk.NewCoin(denom, amount)} + auction.EmitFundRewardsAuction(k.ctx, coins) + return k.bankKeeper.SendCoinsFromModuleToModule(*k.ctx, metoken.ModuleName, auction.ModuleName, coins) +} - return meTokens, feeAmount.Amount, amountToReserves, amountToLeverage, nil +type swapCarry struct { + meTokens sdkmath.Int + fee sdkmath.Int + toReserves sdkmath.Int + toLeverage sdkmath.Int } diff --git a/x/metoken/keeper/swap_test.go b/x/metoken/keeper/swap_test.go index 16c9feb469..087ebd3bd3 100644 --- a/x/metoken/keeper/swap_test.go +++ b/x/metoken/keeper/swap_test.go @@ -12,35 +12,46 @@ import ( ) func TestSwap_Valid(t *testing.T) { - k := initMeUSDKeeper(t, NewBankMock(), NewLeverageMock(), NewOracleMock()) + assert := assert.New(t) + k := initMeUSDNoopKeper(t) + params := k.GetParams() + + indexBal1, err := k.IndexBalances(mocks.MeUSDDenom) + assert.NoError(err) tenUSDT := sdk.NewCoin(mocks.USDTBaseDenom, sdkmath.NewInt(10_000000)) resp, err := k.swap(sdk.AccAddress{}, mocks.MeUSDDenom, tenUSDT) - assert.NoError(t, err) + assert.NoError(err) // delta_allocation = (current_allocation - target_allocation) / target_allocation // delta_allocation = (0.238679846938775510 - 0.33) / 0.33 = -0.276727736549165121 // fee = balanced_fee + delta_allocation * balanced_fee // fee = 0.2 - 0.276727736549165121 * 0.2 = 0.144654452690167 - // fee_amount = fee * amount = 0.144654452690167 * 10 = 1.44654452690167 - assert.Equal(t, resp.fee, sdk.NewCoin(tenUSDT.Denom, sdkmath.NewInt(1446544))) + assert.Equal(resp.fee, sdk.NewCoin(tenUSDT.Denom, sdkmath.NewInt(1446544))) // reserved = (amount - fee) * reserve_portion // reserved = (10 - 1.446544) * 0.2 = 1.7106912 - assert.Equal(t, resp.reserved, sdk.NewCoin(tenUSDT.Denom, sdkmath.NewInt(1710691))) + assert.Equal(resp.reserved, sdk.NewCoin(tenUSDT.Denom, sdkmath.NewInt(1710691))) // leveraged = amount - fee - reserved // leveraged = 10 - 1.446544 - 1.710691 = 6.842765 - assert.Equal(t, resp.leveraged, sdk.NewCoin(tenUSDT.Denom, sdkmath.NewInt(6842765))) + assert.Equal(resp.leveraged, sdk.NewCoin(tenUSDT.Denom, sdkmath.NewInt(6842765))) + + indexBal2, err := k.IndexBalances(mocks.MeUSDDenom) + usdBal2, n := indexBal2.AssetBalance(tenUSDT.Denom) + assert.GreaterOrEqual(n, 0) + usdBal1, _ := indexBal1.AssetBalance(tenUSDT.Denom) + toAuction := params.RewardsAuctionFactor.Mul(resp.fee.Amount) + assert.Equal(usdBal2.Fees.Sub(usdBal1.Fees), resp.fee.Amount.Sub(toAuction)) // exchange_rate = coin_price / metoken_price // meTokens = (reserved + leveraged) * exchange_rate i, err := k.RegisteredIndex(mocks.MeUSDDenom) - assert.NoError(t, err) + assert.NoError(err) p, err := k.Prices(i) - assert.NoError(t, err) + assert.NoError(err) assert.Equal( - t, resp.meTokens, sdk.NewCoin( + resp.meTokens, sdk.NewCoin( mocks.MeUSDDenom, mocks.USDTPrice.Quo(p.Price).MulInt( resp. reserved.Amount.Add(resp.leveraged.Amount), @@ -50,7 +61,7 @@ func TestSwap_Valid(t *testing.T) { } func TestSwap_Errors(t *testing.T) { - k := initMeUSDKeeper(t, NewBankMock(), NewLeverageMock(), NewOracleMock()) + k := initMeUSDNoopKeper(t) _, err := k.swap(sdk.AccAddress{}, mocks.MeUSDDenom, sdk.NewCoin("nonexistingMetoken", sdkmath.OneInt())) assert.ErrorContains(t, err, "not found") @@ -72,3 +83,25 @@ func TestSwap_LeverageOversupplied(t *testing.T) { assert.NoError(t, err) assert.True(t, resp.reserved.IsGTE(resp.leveraged)) } + +func TestBreakFees(t *testing.T) { + assert := assert.New(t) + k := initMeUSDNoopKeper(t) + p := k.GetParams() + assert.EqualValues(p.RewardsAuctionFactor, 1000) + + amount := sdkmath.NewInt(2_000) + toAuction, toRevenue := k.breakFee(amount) + assert.Equal(toAuction, sdkmath.NewInt(200)) + assert.Equal(toRevenue, sdkmath.NewInt(1_800)) + + amount = sdkmath.NewInt(9) + toAuction, toRevenue = k.breakFee(amount) + assert.Equal(toAuction, sdkmath.NewInt(0)) + assert.Equal(toRevenue, amount) + + amount = sdkmath.NewInt(2_001) + toAuction, toRevenue = k.breakFee(amount) + assert.Equal(toAuction, sdkmath.NewInt(200)) + assert.Equal(toRevenue, sdkmath.NewInt(1_801)) +} diff --git a/x/metoken/keeper/unit_test.go b/x/metoken/keeper/unit_test.go index 839596fe7c..678b699198 100644 --- a/x/metoken/keeper/unit_test.go +++ b/x/metoken/keeper/unit_test.go @@ -3,17 +3,14 @@ package keeper import ( "testing" - "github.com/umee-network/umee/v6/x/metoken/mocks" - - "github.com/umee-network/umee/v6/x/metoken" - - "github.com/stretchr/testify/require" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/types" storetypes "github.com/cosmos/cosmos-sdk/store/types" + "github.com/stretchr/testify/require" "github.com/umee-network/umee/v6/tests/tsdk" + "github.com/umee-network/umee/v6/x/metoken" + "github.com/umee-network/umee/v6/x/metoken/mocks" ) // initSimpleKeeper creates a simple keeper without external dependencies. @@ -25,7 +22,10 @@ func initSimpleKeeper(t *testing.T) Keeper { kb := NewBuilder(cdc, storeKey, nil, nil, nil, nil) ctx, _ := tsdk.NewCtxOneStore(t, storeKey) - return kb.Keeper(&ctx) + k := kb.Keeper(&ctx) + err := k.SetParams(metoken.DefaultParams()) + require.NoError(t, err) + return k } // initMeUSDKeeper creates a keeper with external dependencies and with meUSD index and balance inserted. @@ -49,3 +49,7 @@ func initMeUSDKeeper( return k } + +func initMeUSDNoopKeper(t *testing.T) Keeper { + return initMeUSDKeeper(t, NewBankMock(), NewLeverageMock(), NewOracleMock()) +} diff --git a/x/metoken/metoken.pb.go b/x/metoken/metoken.pb.go index 32f1e16cd6..b8daf5a481 100644 --- a/x/metoken/metoken.pb.go +++ b/x/metoken/metoken.pb.go @@ -9,6 +9,7 @@ import ( github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" + github_com_umee_network_umee_v6_util_bpmath "github.com/umee-network/umee/v6/util/bpmath" io "io" math "math" math_bits "math/bits" @@ -33,6 +34,10 @@ type Params struct { // Interest claiming frequency in seconds, determines how often metoken module will claim accrued interest from // leverage module ClaimingFrequency int64 `protobuf:"varint,2,opt,name=claiming_frequency,json=claimingFrequency,proto3" json:"claiming_frequency,omitempty"` + // Rewards Auction Factor determines the portion of swap and redeem fee that is sent to the + // auction module for the rewards auction. + // Valid values: 0-10000 (in basis points, 2000 = 20%). + RewardsAuctionFactor github_com_umee_network_umee_v6_util_bpmath.FixedBP `protobuf:"varint,3,opt,name=rewards_auction_factor,json=rewardsAuctionFactor,proto3,customtype=github.com/umee-network/umee/v6/util/bpmath.FixedBP" json:"rewards_auction_factor"` } func (m *Params) Reset() { *m = Params{} } @@ -83,7 +88,8 @@ type Index struct { // Valid value: must be the same as the oracle.Denom.exponent. Exponent uint32 `protobuf:"varint,3,opt,name=exponent,proto3" json:"exponent,omitempty"` // Fee contains fee parameters used for swap and redemption fee calculations for all underlying - // assets in this index. + // assets in this index. `Params.rewards_auction_factor` of the fee will go for the burn + // auction. Fee Fee `protobuf:"bytes,4,opt,name=fee,proto3" json:"fee"` // Accepted Assets is the list of underlying Tokens that can be swapped and redeemed for the Index's meToken, // along with their token-specific parameters. @@ -335,49 +341,53 @@ func init() { func init() { proto.RegisterFile("umee/metoken/v1/metoken.proto", fileDescriptor_dda977db8ad52437) } var fileDescriptor_dda977db8ad52437 = []byte{ - // 667 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x95, 0x4f, 0x4f, 0xdb, 0x4a, - 0x10, 0xc0, 0x63, 0x9c, 0x04, 0x32, 0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5, 0x10, 0x0e, 0x32, 0x84, 0x04, 0x1e, 0x82, - 0x84, 0xcb, 0xb7, 0x69, 0xbe, 0x10, 0x6d, 0x3e, 0xad, 0xef, 0xc9, 0x3f, 0x24, 0x05, 0x96, 0xb0, - 0x85, 0x42, 0xb0, 0x5a, 0x46, 0x98, 0xbe, 0x9d, 0x9d, 0x83, 0xf3, 0x2b, 0xb3, 0x74, 0x7e, 0x6d, - 0x6a, 0x17, 0xd7, 0xa6, 0xf6, 0xe5, 0xda, 0xd4, 0xde, 0xdf, 0x98, 0xa5, 0x8b, 0x1b, 0xb3, 0xf4, - 0xe9, 0xc6, 0x2c, 0xbd, 0xf9, 0x6f, 0x06, 0x9b, 0x4e, 0xd2, 0x76, 0x88, 0xe2, 0x94, 0xc5, 0x43, - 0xb9, 0xb0, 0x27, 0x8f, 0xec, 0x24, 0xff, 0xee, 0xf4, 0xab, 0xf2, 0x8b, 0xb2, 0xf7, 0x33, 0x00, - 0x00, 0xff, 0xff, 0x42, 0x09, 0xab, 0xfe, 0x99, 0x06, 0x00, 0x00, + // 721 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x95, 0x4f, 0x6b, 0xdb, 0x48, + 0x14, 0xc0, 0xad, 0xc8, 0x76, 0xe2, 0xe7, 0xfc, 0xd9, 0x08, 0x67, 0x31, 0x59, 0xa2, 0x78, 0x73, + 0x58, 0xbc, 0xb0, 0x91, 0x48, 0x02, 0x0b, 0xfb, 0xe7, 0x62, 0x63, 0x1c, 0xc2, 0xb2, 0xd4, 0x55, + 0x0f, 0x85, 0xf6, 0x20, 0xc6, 0xd2, 0x8b, 0x23, 0x6c, 0x69, 0x14, 0xcd, 0xd8, 0x51, 0xbe, 0x45, + 0x3f, 0x42, 0x3f, 0x4d, 0xc9, 0x31, 0xc7, 0xd2, 0x43, 0x68, 0x12, 0x0a, 0x3d, 0x95, 0x9e, 0x7b, + 0x2a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b7, 0x32, 0x72, 0x57, 0x82, 0xff, 0x2e, 0x7e, 0x7c, + 0xbd, 0xa9, 0x6d, 0x7d, 0xd1, 0xa0, 0x74, 0x10, 0xf9, 0x98, 0x1a, 0x35, 0x28, 0xf9, 0x18, 0xd1, + 0x50, 0x6a, 0x55, 0x9c, 0x6c, 0x61, 0xfc, 0x0b, 0x10, 0x92, 0xd4, 0x65, 0xe3, 0x38, 0x1e, 0x65, + 0xfd, 0x57, 0xda, 0x1b, 0xaa, 0x99, 0x35, 0x8f, 0xb2, 0x90, 0x32, 0xe6, 0x0f, 0xad, 0x80, 0xda, + 0xf2, 0xc8, 0x83, 0x88, 0x3b, 0x95, 0x90, 0xa4, 0xcf, 0x64, 0xbe, 0xb1, 0x0e, 0x0b, 0x98, 0xc6, + 0x34, 0xc2, 0x88, 0x67, 0x22, 0xce, 0xcd, 0xda, 0xf8, 0x03, 0xf4, 0x43, 0xc4, 0x7a, 0xb1, 0xa1, + 0x35, 0xab, 0xbb, 0x35, 0xeb, 0xde, 0x6d, 0xb1, 0xba, 0x88, 0xed, 0xa2, 0x38, 0xc8, 0x11, 0x69, + 0xc6, 0xff, 0xb0, 0x42, 0x3c, 0x0f, 0x63, 0x8e, 0xbe, 0x4b, 0x18, 0x43, 0xce, 0xea, 0xa5, 0x86, + 0xde, 0xac, 0xee, 0x9a, 0x0f, 0x2a, 0x5b, 0x2a, 0xaf, 0x25, 0xd2, 0x14, 0x63, 0x99, 0xcc, 0x6e, + 0x32, 0x25, 0xff, 0x59, 0x03, 0xbd, 0x8b, 0x68, 0xec, 0xc3, 0x7c, 0x18, 0x44, 0xae, 0x68, 0x47, + 0xca, 0xb7, 0x2d, 0x65, 0xf8, 0xdb, 0xcc, 0xe5, 0xce, 0x64, 0xd5, 0xcf, 0x36, 0xf3, 0x87, 0x36, + 0x3f, 0x8d, 0x91, 0x59, 0x1d, 0xf4, 0x9c, 0x72, 0x18, 0x44, 0x02, 0xf4, 0x14, 0x16, 0xb3, 0x59, +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, 0xb8, 0x72, 0x2e, 0x1c, 0x64, 0x08, 0x09, 0x3c, + 0x00, 0x09, 0x97, 0x4f, 0xd3, 0x7c, 0x2e, 0xda, 0xbc, 0xa8, 0xef, 0xca, 0x17, 0x92, 0x02, 0x4b, + 0xd8, 0x42, 0x2e, 0x58, 0x25, 0x23, 0xdc, 0x3c, 0x9d, 0xed, 0xfd, 0xb3, 0x4b, 0xb3, 0x70, 0x76, + 0x65, 0x6a, 0xe7, 0x57, 0xa6, 0xf6, 0xfe, 0xca, 0xd4, 0x5e, 0x5d, 0x9b, 0x85, 0xf3, 0x6b, 0xb3, + 0xf0, 0xf6, 0xda, 0x2c, 0xbc, 0xf8, 0xfd, 0x7b, 0x2f, 0xff, 0x74, 0xfa, 0xad, 0xeb, 0x97, 0xe5, + 0x57, 0x6c, 0xef, 0x6b, 0x00, 0x00, 0x00, 0xff, 0xff, 0x1d, 0x4b, 0xe7, 0xbf, 0x0d, 0x07, 0x00, + 0x00, } func (this *Params) Equal(that interface{}) bool { @@ -405,6 +415,9 @@ func (this *Params) Equal(that interface{}) bool { if this.ClaimingFrequency != that1.ClaimingFrequency { return false } + if !this.RewardsAuctionFactor.Equal(that1.RewardsAuctionFactor) { + return false + } return true } func (this *Index) Equal(that interface{}) bool { @@ -611,6 +624,11 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.RewardsAuctionFactor != 0 { + i = encodeVarintMetoken(dAtA, i, uint64(m.RewardsAuctionFactor)) + i-- + dAtA[i] = 0x18 + } if m.ClaimingFrequency != 0 { i = encodeVarintMetoken(dAtA, i, uint64(m.ClaimingFrequency)) i-- @@ -970,6 +988,9 @@ func (m *Params) Size() (n int) { if m.ClaimingFrequency != 0 { n += 1 + sovMetoken(uint64(m.ClaimingFrequency)) } + if m.RewardsAuctionFactor != 0 { + n += 1 + sovMetoken(uint64(m.RewardsAuctionFactor)) + } return n } @@ -1158,6 +1179,25 @@ func (m *Params) Unmarshal(dAtA []byte) error { break } } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field RewardsAuctionFactor", wireType) + } + m.RewardsAuctionFactor = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetoken + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.RewardsAuctionFactor |= github_com_umee_network_umee_v6_util_bpmath.FixedBP(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipMetoken(dAtA[iNdEx:]) diff --git a/x/metoken/params.go b/x/metoken/params.go index 3cab5ed3b6..eb6ce7f178 100644 --- a/x/metoken/params.go +++ b/x/metoken/params.go @@ -5,5 +5,6 @@ func DefaultParams() Params { return Params{ RebalancingFrequency: 60 * 60 * 12, // 12h ClaimingFrequency: 60 * 60 * 24 * 7, // 7d + RewardsAuctionFactor: 1000, // 10% of fees goes to rewards auction } }