From 0705c2b188296db0d0144c93f65d77706da081c2 Mon Sep 17 00:00:00 2001 From: Robert Zaremba Date: Tue, 28 May 2024 22:22:36 +0200 Subject: [PATCH 1/4] feat(oracle): add slashing events --- proto/umee/oracle/v1/events.proto | 15 + swagger/swagger.yaml | 508 ++++++++++++++++++++++++++++++ x/oracle/types/events.pb.go | 337 ++++++++++++++++++-- 3 files changed, 839 insertions(+), 21 deletions(-) diff --git a/proto/umee/oracle/v1/events.proto b/proto/umee/oracle/v1/events.proto index cdc9ba3cac..4bbcdb35c2 100644 --- a/proto/umee/oracle/v1/events.proto +++ b/proto/umee/oracle/v1/events.proto @@ -27,3 +27,18 @@ message EventSetFxRate { (gogoproto.nullable) = false ]; } + +// EventSetFxRate is emitted on exchange rate update +message EventSlash { + // validator consensus address + string validator = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + ; + // factor of slashed stake + string factor = 2 [ + (cosmos_proto.scalar) = "cosmos.Dec", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + string reason = 3; + bool jailed = 4; +} diff --git a/swagger/swagger.yaml b/swagger/swagger.yaml index d73ab3669d..85d0ac00da 100644 --- a/swagger/swagger.yaml +++ b/swagger/swagger.yaml @@ -239,6 +239,226 @@ paths: type: string tags: - Query + /umee/leverage/v1/accounts_summary: + get: + summary: >- + AccountSummaries queries USD values representing an account's total + positions and borrowing limits. It requires oracle prices to return + successfully. + operationId: AccountSummaries + responses: + '200': + description: A successful response. + schema: + type: object + properties: + account_summaries: + type: array + items: + type: object + properties: + address: + type: string + account_summary: + type: object + properties: + supplied_value: + type: string + description: >- + Supplied Value is the sum of the USD value of all + tokens the account has supplied, including interest + earned. + + It uses the lower of spot or historic price for each + token. + + Computation skips assets which are missing oracle + prices, potentially resulting in a lower supplied + + value than if prices were all available. + collateral_value: + type: string + description: >- + Collateral Value is the sum of the USD value of all + uTokens the account has collateralized. + + It uses the lower of spot or historic price for each + token. + + Computation skips collateral which is missing an + oracle price, potentially resulting in a lower + collateral + + value than if prices were all available. + borrowed_value: + type: string + description: >- + Borrowed Value is the sum of the USD value of all + tokens the account has borrowed, including interest + owed. + + It uses the higher of spot or historic price for + each token. + + Computation skips borrows which are missing oracle + prices, potentially resulting in a lower borrowed + + value than if prices were all available. + borrow_limit: + type: string + description: >- + Borrow Limit is the maximum Borrowed Value the + account is allowed to reach through direct + borrowing. + + The lower of spot or historic price for each + collateral token is used when calculating borrow + limits. + + Computation skips collateral which is missing an + oracle price, potentially resulting in a lower + borrow + + limit than if prices were all available. Will be + null if an oracle price required for computation is + + missing. + liquidation_threshold: + type: string + description: >- + Liquidation Threshold is the Borrowed Value at which + the account becomes eligible for liquidation. + + Computation skips borrows which are missing an + oracle price, potentially resulting in a lower + borrow + + limit than if prices were all available. Will be + null if an oracle price required for computation is + + missing. + spot_supplied_value: + type: string + description: >- + Spot Supplied Value is supplied value but always + uses the most recent available spot prices. + spot_collateral_value: + type: string + description: >- + Spot Collateral Value is collateral value but always + uses the most recent available spot prices. + spot_borrowed_value: + type: string + description: >- + Spot Borrowed Value is borrowed value but always + uses the most recent available spot prices. + description: >- + QueryAccountSummaryResponse defines the response + structure for the AccountSummary gRPC service handler. + description: AccountSummary is holds account_summary with address. + pagination: + description: pagination defines the pagination in the response. + type: object + properties: + next_key: + type: string + format: byte + description: |- + next_key is the key to be passed to PageRequest.key to + query the next page most efficiently. It will be empty if + there are no more results. + total: + type: string + format: uint64 + title: >- + total is total number of results available if + PageRequest.count_total + + was set, its value is undefined otherwise + description: >- + QueryAccountSummariesResponse defines the response structure for + the AccountSummaries gRPC service handler. + default: + description: An unexpected error response. + schema: + type: object + properties: + error: + type: string + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + type_url: + type: string + value: + type: string + format: byte + parameters: + - name: pagination.key + description: |- + key is a value returned in PageResponse.next_key to begin + querying the next page most efficiently. Only one of offset or key + should be set. + in: query + required: false + type: string + format: byte + - name: pagination.offset + description: >- + offset is a numeric offset that can be used when key is unavailable. + + It is less efficient than using key. Only one of offset or key + should + + be set. + in: query + required: false + type: string + format: uint64 + - name: pagination.limit + description: >- + limit is the total number of results to be returned in the result + page. + + If left empty it will default to a value to be set by each app. + in: query + required: false + type: string + format: uint64 + - name: pagination.count_total + description: >- + count_total is set to true to indicate that the result set should + include + + a count of the total number of items available for pagination in + UIs. + + count_total is only respected when offset is used. It is ignored + when key + + is set. + in: query + required: false + type: boolean + - name: pagination.reverse + description: >- + reverse is set to true if results are to be returned in the + descending order. + + + Since: cosmos-sdk 0.43 + in: query + required: false + type: boolean + tags: + - Query /umee/leverage/v1/bad_debts: get: summary: >- @@ -6040,6 +6260,83 @@ paths: tags: - Query definitions: + cosmos.base.query.v1beta1.PageRequest: + type: object + properties: + key: + type: string + format: byte + description: |- + key is a value returned in PageResponse.next_key to begin + querying the next page most efficiently. Only one of offset or key + should be set. + offset: + type: string + format: uint64 + description: |- + offset is a numeric offset that can be used when key is unavailable. + It is less efficient than using key. Only one of offset or key should + be set. + limit: + type: string + format: uint64 + description: >- + limit is the total number of results to be returned in the result + page. + + If left empty it will default to a value to be set by each app. + count_total: + type: boolean + description: >- + count_total is set to true to indicate that the result set should + include + + a count of the total number of items available for pagination in UIs. + + count_total is only respected when offset is used. It is ignored when + key + + is set. + reverse: + type: boolean + description: >- + reverse is set to true if results are to be returned in the descending + order. + + + Since: cosmos-sdk 0.43 + description: |- + message SomeRequest { + Foo some_parameter = 1; + PageRequest pagination = 2; + } + title: |- + PageRequest is to be embedded in gRPC request messages for efficient + pagination. Ex: + cosmos.base.query.v1beta1.PageResponse: + type: object + properties: + next_key: + type: string + format: byte + description: |- + next_key is the key to be passed to PageRequest.key to + query the next page most efficiently. It will be empty if + there are no more results. + total: + type: string + format: uint64 + title: |- + total is total number of results available if PageRequest.count_total + was set, its value is undefined otherwise + description: |- + PageResponse is to be embedded in gRPC response messages where the + corresponding request message has used PageRequest. + + message SomeResponse { + repeated Bar results = 1; + PageResponse page = 2; + } cosmos.base.v1beta1.Coin: type: object properties: @@ -6403,6 +6700,98 @@ definitions: "@type": "type.googleapis.com/google.protobuf.Duration", "value": "1.212s" } + umee.leverage.v1.AccountSummary: + type: object + properties: + address: + type: string + account_summary: + type: object + properties: + supplied_value: + type: string + description: >- + Supplied Value is the sum of the USD value of all tokens the + account has supplied, including interest earned. + + It uses the lower of spot or historic price for each token. + + Computation skips assets which are missing oracle prices, + potentially resulting in a lower supplied + + value than if prices were all available. + collateral_value: + type: string + description: >- + Collateral Value is the sum of the USD value of all uTokens the + account has collateralized. + + It uses the lower of spot or historic price for each token. + + Computation skips collateral which is missing an oracle price, + potentially resulting in a lower collateral + + value than if prices were all available. + borrowed_value: + type: string + description: >- + Borrowed Value is the sum of the USD value of all tokens the + account has borrowed, including interest owed. + + It uses the higher of spot or historic price for each token. + + Computation skips borrows which are missing oracle prices, + potentially resulting in a lower borrowed + + value than if prices were all available. + borrow_limit: + type: string + description: >- + Borrow Limit is the maximum Borrowed Value the account is allowed + to reach through direct borrowing. + + The lower of spot or historic price for each collateral token is + used when calculating borrow limits. + + Computation skips collateral which is missing an oracle price, + potentially resulting in a lower borrow + + limit than if prices were all available. Will be null if an oracle + price required for computation is + + missing. + liquidation_threshold: + type: string + description: >- + Liquidation Threshold is the Borrowed Value at which the account + becomes eligible for liquidation. + + Computation skips borrows which are missing an oracle price, + potentially resulting in a lower borrow + + limit than if prices were all available. Will be null if an oracle + price required for computation is + + missing. + spot_supplied_value: + type: string + description: >- + Spot Supplied Value is supplied value but always uses the most + recent available spot prices. + spot_collateral_value: + type: string + description: >- + Spot Collateral Value is collateral value but always uses the most + recent available spot prices. + spot_borrowed_value: + type: string + description: >- + Spot Borrowed Value is borrowed value but always uses the most + recent available spot prices. + description: >- + QueryAccountSummaryResponse defines the response structure for the + AccountSummary gRPC service handler. + description: AccountSummary is holds account_summary with address. umee.leverage.v1.BadDebt: type: object properties: @@ -6681,6 +7070,125 @@ definitions: description: >- QueryAccountBalancesResponse defines the response structure for the AccountBalances gRPC service handler. + umee.leverage.v1.QueryAccountSummariesResponse: + type: object + properties: + account_summaries: + type: array + items: + type: object + properties: + address: + type: string + account_summary: + type: object + properties: + supplied_value: + type: string + description: >- + Supplied Value is the sum of the USD value of all tokens the + account has supplied, including interest earned. + + It uses the lower of spot or historic price for each token. + + Computation skips assets which are missing oracle prices, + potentially resulting in a lower supplied + + value than if prices were all available. + collateral_value: + type: string + description: >- + Collateral Value is the sum of the USD value of all uTokens + the account has collateralized. + + It uses the lower of spot or historic price for each token. + + Computation skips collateral which is missing an oracle + price, potentially resulting in a lower collateral + + value than if prices were all available. + borrowed_value: + type: string + description: >- + Borrowed Value is the sum of the USD value of all tokens the + account has borrowed, including interest owed. + + It uses the higher of spot or historic price for each token. + + Computation skips borrows which are missing oracle prices, + potentially resulting in a lower borrowed + + value than if prices were all available. + borrow_limit: + type: string + description: >- + Borrow Limit is the maximum Borrowed Value the account is + allowed to reach through direct borrowing. + + The lower of spot or historic price for each collateral + token is used when calculating borrow limits. + + Computation skips collateral which is missing an oracle + price, potentially resulting in a lower borrow + + limit than if prices were all available. Will be null if an + oracle price required for computation is + + missing. + liquidation_threshold: + type: string + description: >- + Liquidation Threshold is the Borrowed Value at which the + account becomes eligible for liquidation. + + Computation skips borrows which are missing an oracle price, + potentially resulting in a lower borrow + + limit than if prices were all available. Will be null if an + oracle price required for computation is + + missing. + spot_supplied_value: + type: string + description: >- + Spot Supplied Value is supplied value but always uses the + most recent available spot prices. + spot_collateral_value: + type: string + description: >- + Spot Collateral Value is collateral value but always uses + the most recent available spot prices. + spot_borrowed_value: + type: string + description: >- + Spot Borrowed Value is borrowed value but always uses the + most recent available spot prices. + description: >- + QueryAccountSummaryResponse defines the response structure for + the AccountSummary gRPC service handler. + description: AccountSummary is holds account_summary with address. + pagination: + description: pagination defines the pagination in the response. + type: object + properties: + next_key: + type: string + format: byte + description: |- + next_key is the key to be passed to PageRequest.key to + query the next page most efficiently. It will be empty if + there are no more results. + total: + type: string + format: uint64 + title: >- + total is total number of results available if + PageRequest.count_total + + was set, its value is undefined otherwise + description: >- + QueryAccountSummariesResponse defines the response structure for the + AccountSummaries gRPC service handler. umee.leverage.v1.QueryAccountSummaryResponse: type: object properties: diff --git a/x/oracle/types/events.pb.go b/x/oracle/types/events.pb.go index 4efdb99d9c..b9f84ce68b 100644 --- a/x/oracle/types/events.pb.go +++ b/x/oracle/types/events.pb.go @@ -107,35 +107,83 @@ func (m *EventSetFxRate) XXX_DiscardUnknown() { var xxx_messageInfo_EventSetFxRate proto.InternalMessageInfo +// EventSetFxRate is emitted on exchange rate update +type EventSlash struct { + // validator consensus address + Validator string `protobuf:"bytes,1,opt,name=validator,proto3" json:"validator,omitempty"` + // factor of slashed stake + Factor github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=factor,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"factor"` + Reason string `protobuf:"bytes,3,opt,name=reason,proto3" json:"reason,omitempty"` + Jailed bool `protobuf:"varint,4,opt,name=jailed,proto3" json:"jailed,omitempty"` +} + +func (m *EventSlash) Reset() { *m = EventSlash{} } +func (m *EventSlash) String() string { return proto.CompactTextString(m) } +func (*EventSlash) ProtoMessage() {} +func (*EventSlash) Descriptor() ([]byte, []int) { + return fileDescriptor_6380f28dac582975, []int{2} +} +func (m *EventSlash) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventSlash) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EventSlash.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 *EventSlash) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventSlash.Merge(m, src) +} +func (m *EventSlash) XXX_Size() int { + return m.Size() +} +func (m *EventSlash) XXX_DiscardUnknown() { + xxx_messageInfo_EventSlash.DiscardUnknown(m) +} + +var xxx_messageInfo_EventSlash proto.InternalMessageInfo + func init() { proto.RegisterType((*EventDelegateFeedConsent)(nil), "umee.oracle.v1.EventDelegateFeedConsent") proto.RegisterType((*EventSetFxRate)(nil), "umee.oracle.v1.EventSetFxRate") + proto.RegisterType((*EventSlash)(nil), "umee.oracle.v1.EventSlash") } func init() { proto.RegisterFile("umee/oracle/v1/events.proto", fileDescriptor_6380f28dac582975) } var fileDescriptor_6380f28dac582975 = []byte{ - // 317 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x91, 0xb1, 0x4e, 0xc3, 0x30, - 0x10, 0x86, 0x13, 0x04, 0x08, 0x3c, 0x74, 0x88, 0x3a, 0x84, 0x22, 0xb9, 0xa8, 0x03, 0x62, 0x49, - 0xac, 0x0a, 0xc4, 0xc4, 0x42, 0x29, 0x9d, 0x18, 0x50, 0xba, 0xb1, 0xa0, 0x34, 0x3e, 0x85, 0xaa, - 0x8d, 0xaf, 0xb2, 0xdd, 0x50, 0x5e, 0x80, 0x99, 0x87, 0xe9, 0x43, 0x74, 0xac, 0x3a, 0x21, 0x86, - 0x0a, 0x9a, 0x17, 0x41, 0xb1, 0x53, 0x60, 0x63, 0xb2, 0xef, 0xfe, 0xff, 0xbe, 0x3b, 0x9f, 0xc9, - 0xf1, 0x34, 0x03, 0x60, 0x28, 0xe3, 0x64, 0x0c, 0x2c, 0x6f, 0x33, 0xc8, 0x41, 0x68, 0x15, 0x4e, - 0x24, 0x6a, 0xf4, 0x6a, 0xa5, 0x18, 0x5a, 0x31, 0xcc, 0xdb, 0x8d, 0xa3, 0x04, 0x55, 0x86, 0xea, - 0xd1, 0xa8, 0xcc, 0x06, 0xd6, 0xda, 0xa8, 0xa7, 0x98, 0xa2, 0xcd, 0x97, 0x37, 0x9b, 0x6d, 0xbd, - 0xba, 0xc4, 0xbf, 0x2d, 0x89, 0x5d, 0x18, 0x43, 0x1a, 0x6b, 0xe8, 0x01, 0xf0, 0x1b, 0x14, 0x0a, - 0x84, 0xf6, 0x2e, 0xc8, 0x01, 0x4e, 0x40, 0xc6, 0x1a, 0xa5, 0xef, 0x9e, 0xb8, 0x67, 0x87, 0x1d, - 0x7f, 0x35, 0x0f, 0xea, 0x15, 0xf6, 0x9a, 0x73, 0x09, 0x4a, 0xf5, 0xb5, 0x1c, 0x8a, 0x34, 0xfa, - 0x71, 0x96, 0x55, 0xbc, 0x82, 0xf9, 0x3b, 0xff, 0x55, 0x6d, 0x9d, 0xad, 0x19, 0xa9, 0x99, 0x39, - 0xfa, 0xa0, 0x7b, 0xb3, 0x28, 0xd6, 0xe0, 0xd5, 0xc9, 0x1e, 0x07, 0x81, 0x99, 0x6d, 0x1d, 0xd9, - 0xc0, 0xbb, 0x27, 0xbb, 0xf2, 0x97, 0x7c, 0xb5, 0x58, 0x37, 0x9d, 0x8f, 0x75, 0xf3, 0x34, 0x1d, - 0xea, 0xa7, 0xe9, 0x20, 0x4c, 0x30, 0xab, 0x5e, 0x5d, 0x1d, 0x81, 0xe2, 0x23, 0xa6, 0x5f, 0x26, - 0xa0, 0xc2, 0x2e, 0x24, 0xab, 0x79, 0x40, 0xaa, 0x39, 0xba, 0x90, 0x44, 0x86, 0xd4, 0xb9, 0x5b, - 0x7c, 0x51, 0x67, 0xb1, 0xa1, 0xee, 0x72, 0x43, 0xdd, 0xcf, 0x0d, 0x75, 0xdf, 0x0a, 0xea, 0x2c, - 0x0b, 0xea, 0xbc, 0x17, 0xd4, 0x79, 0x08, 0xff, 0x90, 0xcb, 0x65, 0x07, 0x02, 0xf4, 0x33, 0xca, - 0x91, 0x09, 0x58, 0x7e, 0xc9, 0x66, 0xdb, 0xbf, 0x31, 0x5d, 0x06, 0xfb, 0x66, 0xaf, 0xe7, 0xdf, - 0x01, 0x00, 0x00, 0xff, 0xff, 0x85, 0x11, 0x1a, 0xbb, 0xb7, 0x01, 0x00, 0x00, + // 383 bytes of a gzipped FileDescriptorProto + 0x1f,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x45, 0x48, + 0x7e, 0x3e, 0x07, 0x00, 0x00, 0xff, 0xff, 0x7d, 0x83, 0x34, 0xb1, 0x84, 0x02, 0x00, 0x00, } func (m *EventDelegateFeedConsent) Marshal() (dAtA []byte, err error) { @@ -215,6 +263,63 @@ func (m *EventSetFxRate) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *EventSlash) 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 *EventSlash) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventSlash) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Jailed { + i-- + if m.Jailed { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x20 + } + if len(m.Reason) > 0 { + i -= len(m.Reason) + copy(dAtA[i:], m.Reason) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Reason))) + i-- + dAtA[i] = 0x1a + } + { + size := m.Factor.Size() + i -= size + if _, err := m.Factor.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintEvents(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.Validator) > 0 { + i -= len(m.Validator) + copy(dAtA[i:], m.Validator) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Validator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintEvents(dAtA []byte, offset int, v uint64) int { offset -= sovEvents(v) base := offset @@ -258,6 +363,28 @@ func (m *EventSetFxRate) Size() (n int) { return n } +func (m *EventSlash) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Validator) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = m.Factor.Size() + n += 1 + l + sovEvents(uint64(l)) + l = len(m.Reason) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + if m.Jailed { + n += 2 + } + return n +} + func sovEvents(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -494,6 +621,174 @@ func (m *EventSetFxRate) Unmarshal(dAtA []byte) error { } return nil } +func (m *EventSlash) 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: EventSlash: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventSlash: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Validator", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Validator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Factor", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Factor.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Reason", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Reason = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Jailed", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Jailed = bool(v != 0) + 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 From 21775558df2334b2e4ef790f088c6a0f74d0dfdd Mon Sep 17 00:00:00 2001 From: Robert Zaremba Date: Tue, 28 May 2024 22:25:50 +0200 Subject: [PATCH 2/4] add events --- x/oracle/keeper/slash.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/x/oracle/keeper/slash.go b/x/oracle/keeper/slash.go index 086604c2f4..51f225ab22 100644 --- a/x/oracle/keeper/slash.go +++ b/x/oracle/keeper/slash.go @@ -2,6 +2,9 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/umee-network/umee/v6/util/sdkutil" + "github.com/umee-network/umee/v6/x/oracle/types" ) // SlashAndResetMissCounters iterates over all the current missed counters and @@ -42,8 +45,14 @@ func (k Keeper) SlashAndResetMissCounters(ctx sdk.Context) { distributionHeight, validator.GetConsensusPower(powerReduction), slashFraction, ) - k.StakingKeeper.Jail(ctx, consAddr) + + sdkutil.Emit(&ctx, &types.EventSlash{ + Validator: consAddr.String(), + Factor: slashFraction, + Reason: "voting_rate", + Jailed: true, + }) } } From ff0714a63ec98c351392dfde179b840f7595ec07 Mon Sep 17 00:00:00 2001 From: Robert Zaremba Date: Tue, 28 May 2024 22:44:27 +0200 Subject: [PATCH 3/4] changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cc8ab5f790..bb44df2909 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -52,6 +52,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ - [2500](https://github.com/umee-network/umee/pull/2500) (x/leverage): add Rewards Auction fees and `params.rewards_auction_factor`. - [2506](https://github.com/umee-network/umee/pull/2506) (ics20): support leverage/MsgRepay in Memo - [2527](https://github.com/umee-network/umee/pull/2527) (x/leverage):add `accounts_summary` grpc-web api and cli query to leverage module. +- [2532](https://github.com/umee-network/umee/pull/2532) (x/oracle): add slashing event. ### Improvements From 44ff3aee8080f2d5868280e2a5662d7490876701 Mon Sep 17 00:00:00 2001 From: Robert Zaremba Date: Wed, 29 May 2024 16:45:00 +0200 Subject: [PATCH 4/4] lint --- x/auction/keeper/rewards.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x/auction/keeper/rewards.go b/x/auction/keeper/rewards.go index ebc54d0650..de76d659d1 100644 --- a/x/auction/keeper/rewards.go +++ b/x/auction/keeper/rewards.go @@ -121,7 +121,7 @@ func (k Keeper) getAllRewardsBids() ([]auction.BidKV, error) { func (k Keeper) storeAllRewardsBids(elems []auction.BidKV) error { for _, e := range elems { key := k.keyRewardsBid(e.Id) - if err := store.SetValue(k.store, key, &e.Bid, "auction.store_all_bids"); err != nil { //nolint: gosec + if err := store.SetValue(k.store, key, &e.Bid, "auction.store_all_bids"); err != nil { return err } } @@ -163,7 +163,7 @@ func (k Keeper) storeNewRewardsAuction(id uint32, endsAt time.Time, coins sdk.Co func (k Keeper) storeAllRewardsAuctions(elems []auction.RewardsKV) error { for _, e := range elems { key := k.keyRewardsCoins(e.Id) - if err := store.SetValue(k.store, key, &e.Rewards, "auction.store_all_rewards"); err != nil { //nolint: gosec + if err := store.SetValue(k.store, key, &e.Rewards, "auction.store_all_rewards"); err != nil { return err } }