diff --git a/proto/elys/stablestake/genesis.proto b/proto/elys/stablestake/genesis.proto index 5d1c35ca0..89f4cad86 100644 --- a/proto/elys/stablestake/genesis.proto +++ b/proto/elys/stablestake/genesis.proto @@ -3,10 +3,14 @@ package elys.stablestake; import "gogoproto/gogo.proto"; import "elys/stablestake/params.proto"; +import "elys/stablestake/debt.proto"; +import "elys/stablestake/types.proto"; option go_package = "github.com/elys-network/elys/x/stablestake/types"; // GenesisState defines the stablestake module's genesis state. message GenesisState { Params params = 1 [(gogoproto.nullable) = false]; + repeated Debt debt_list = 2 [(gogoproto.nullable) = false]; + repeated InterestBlock interest_list = 3 [(gogoproto.nullable) = false]; } diff --git a/proto/elys/stablestake/types.proto b/proto/elys/stablestake/types.proto index 0646735ee..1eac093ab 100644 --- a/proto/elys/stablestake/types.proto +++ b/proto/elys/stablestake/types.proto @@ -25,4 +25,13 @@ message InterestBlock { (gogoproto.nullable) = false ]; int64 block_time = 2; + uint64 block_height = 3; +} + +message LegacyInterestBlock { + string interest_rate = 1 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + int64 block_time = 2; } \ No newline at end of file diff --git a/x/leveragelp/types/genesis.go b/x/leveragelp/types/genesis.go index 78be73421..9649a68b0 100644 --- a/x/leveragelp/types/genesis.go +++ b/x/leveragelp/types/genesis.go @@ -2,6 +2,7 @@ package types import ( "fmt" + sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -48,7 +49,7 @@ func (gs GenesisState) Validate() error { whitelistMap := make(map[string]struct{}) for _, elem := range gs.AddressWhitelist { index := elem - if _, ok := positionIndexMap[index]; ok { + if _, ok := whitelistMap[index]; ok { return fmt.Errorf("duplicated index for pool") } whitelistMap[index] = struct{}{} diff --git a/x/stablestake/genesis.go b/x/stablestake/genesis.go index 806ef2adc..43f3af7a9 100644 --- a/x/stablestake/genesis.go +++ b/x/stablestake/genesis.go @@ -8,6 +8,16 @@ import ( // InitGenesis initializes the module's state from a provided genesis state. func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) { + // Set all the debts + for _, elem := range genState.DebtList { + k.SetDebt(ctx, elem) + } + + // Set all the interests + for _, elem := range genState.InterestList { + k.SetInterest(ctx, elem.BlockHeight, elem) + } + // this line is used by starport scaffolding # genesis/module/init k.SetParams(ctx, genState.Params) } @@ -17,6 +27,9 @@ func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { genesis := types.DefaultGenesis() genesis.Params = k.GetParams(ctx) + genesis.DebtList = k.AllDebts(ctx) + genesis.InterestList = k.GetAllInterest(ctx) + // this line is used by starport scaffolding # genesis/module/export return genesis diff --git a/x/stablestake/keeper/debt.go b/x/stablestake/keeper/debt.go index 39254cf21..93844d031 100644 --- a/x/stablestake/keeper/debt.go +++ b/x/stablestake/keeper/debt.go @@ -80,6 +80,27 @@ func (k Keeper) GetAllInterest(ctx sdk.Context) []types.InterestBlock { return interests } +func (k Keeper) GetAllLegacyInterest(ctx sdk.Context) []types.InterestBlock { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.InterestPrefixKey) + iterator := sdk.KVStorePrefixIterator(store, nil) + defer iterator.Close() + + interests := []types.InterestBlock{} + for ; iterator.Valid(); iterator.Next() { + interest := types.LegacyInterestBlock{} + k.cdc.MustUnmarshal(iterator.Value(), &interest) + + block := iterator.Key() + newInterest := types.InterestBlock{} + newInterest.InterestRate = interest.InterestRate + newInterest.BlockTime = interest.BlockTime + newInterest.BlockHeight = sdk.BigEndianToUint64(block) + + interests = append(interests, newInterest) + } + return interests +} + func (k Keeper) GetInterest(ctx sdk.Context, startBlock uint64, startTime uint64, borrowed sdk.Dec) sdk.Int { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.InterestPrefixKey) currentBlockKey := sdk.Uint64ToBigEndian(uint64(ctx.BlockHeight())) diff --git a/x/stablestake/migrations/v3_migration.go b/x/stablestake/migrations/v3_migration.go index 5b0184c70..693cef1c6 100644 --- a/x/stablestake/migrations/v3_migration.go +++ b/x/stablestake/migrations/v3_migration.go @@ -5,9 +5,12 @@ import ( ) func (m Migrator) V3Migration(ctx sdk.Context) error { - params := m.keeper.GetParams(ctx) - params.InterestRateMin = sdk.NewDecWithPrec(10, 2) // 10% - params.InterestRateMax = sdk.NewDecWithPrec(50, 2) // 50% - m.keeper.SetParams(ctx, params) + // Migrate the interest blocks + interests := m.keeper.GetAllLegacyInterest(ctx) + + for _, interest := range interests { + m.keeper.SetInterest(ctx, interest.BlockHeight, interest) + } + return nil } diff --git a/x/stablestake/module.go b/x/stablestake/module.go index f2cf81fed..e109c46b2 100644 --- a/x/stablestake/module.go +++ b/x/stablestake/module.go @@ -144,7 +144,7 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw } // ConsensusVersion is a sequence number for state-breaking change of the module. It should be incremented on each consensus-breaking change introduced by the module. To avoid wrong/empty versions, the initial version should be set to 1 -func (AppModule) ConsensusVersion() uint64 { return 2 } +func (AppModule) ConsensusVersion() uint64 { return 3 } // BeginBlock contains the logic that is automatically triggered at the beginning of each block func (am AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) { diff --git a/x/stablestake/types/genesis.go b/x/stablestake/types/genesis.go index 0af9b4416..7d6a13583 100644 --- a/x/stablestake/types/genesis.go +++ b/x/stablestake/types/genesis.go @@ -1,15 +1,21 @@ package types import ( -// this line is used by starport scaffolding # genesis/types/import + sdk "github.com/cosmos/cosmos-sdk/types" + + fmt "fmt" ) +// this line is used by starport scaffolding # genesis/types/import + // DefaultIndex is the default global index const DefaultIndex uint64 = 1 // DefaultGenesis returns the default genesis state func DefaultGenesis() *GenesisState { return &GenesisState{ + DebtList: []Debt{}, + InterestList: []InterestBlock{}, // this line is used by starport scaffolding # genesis/types/default Params: DefaultParams(), } @@ -18,6 +24,26 @@ func DefaultGenesis() *GenesisState { // Validate performs basic genesis state validation returning an error upon any // failure. func (gs GenesisState) Validate() error { + // Check for duplicated index in debt + debtIndexMap := make(map[string]struct{}) + for _, elem := range gs.DebtList { + index := elem.Address + if _, ok := debtIndexMap[index]; ok { + return fmt.Errorf("duplicated index for debt") + } + debtIndexMap[index] = struct{}{} + } + + // Check for duplicated index in interest + interestIndexMap := make(map[string]struct{}) + for _, elem := range gs.InterestList { + index := string(sdk.Uint64ToBigEndian(uint64(elem.BlockTime))) + if _, ok := interestIndexMap[index]; ok { + return fmt.Errorf("duplicated index for interest") + } + interestIndexMap[index] = struct{}{} + } + // this line is used by starport scaffolding # genesis/types/validate return gs.Params.Validate() diff --git a/x/stablestake/types/genesis.pb.go b/x/stablestake/types/genesis.pb.go index 30df512b6..4d32fb782 100644 --- a/x/stablestake/types/genesis.pb.go +++ b/x/stablestake/types/genesis.pb.go @@ -25,7 +25,9 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // GenesisState defines the stablestake module's genesis state. type GenesisState struct { - Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` + DebtList []Debt `protobuf:"bytes,2,rep,name=debt_list,json=debtList,proto3" json:"debt_list"` + InterestList []InterestBlock `protobuf:"bytes,3,rep,name=interest_list,json=interestList,proto3" json:"interest_list"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -68,6 +70,20 @@ func (m *GenesisState) GetParams() Params { return Params{} } +func (m *GenesisState) GetDebtList() []Debt { + if m != nil { + return m.DebtList + } + return nil +} + +func (m *GenesisState) GetInterestList() []InterestBlock { + if m != nil { + return m.InterestList + } + return nil +} + func init() { proto.RegisterType((*GenesisState)(nil), "elys.stablestake.GenesisState") } @@ -75,20 +91,25 @@ func init() { func init() { proto.RegisterFile("elys/stablestake/genesis.proto", fileDescriptor_3bb56992c0b936ea) } var fileDescriptor_3bb56992c0b936ea = []byte{ - // 196 bytes of a gzipped FileDescriptorProto + // 281 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00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0x97, - 0x03, 0x01, 0x00, 0x00, + 0x0c, 0x73, 0x0a, 0x12, 0x8b, 0x12, 0x73, 0xa1, 0xc6, 0x48, 0x49, 0x63, 0x48, 0xa7, 0xa4, 0x26, + 0x95, 0x40, 0x25, 0x65, 0x30, 0x24, 0x4b, 0x2a, 0x0b, 0x52, 0xa1, 0x5a, 0x95, 0xce, 0x32, 0x72, + 0xf1, 0xb8, 0x43, 0xdc, 0x14, 0x5c, 0x92, 0x58, 0x92, 0x2a, 0x64, 0xc6, 0xc5, 0x06, 0x31, 0x5b, + 0x82, 0x51, 0x81, 0x51, 0x83, 0xdb, 0x48, 0x42, 0x0f, 0xdd, 0x8d, 0x7a, 0x01, 0x60, 0x79, 0x27, + 0x96, 0x13, 0xf7, 0xe4, 0x19, 0x82, 0xa0, 0xaa, 0x85, 0x2c, 0xb9, 0x38, 0x41, 0x96, 0xc6, 0xe7, + 0x64, 0x16, 0x97, 0x48, 0x30, 0x29, 0x30, 0x6b, 0x70, 0x1b, 0x89, 0x61, 0x6a, 0x75, 0x49, 0x4d, + 0x2a, 0x81, 0x6a, 0xe4, 0x00, 0x29, 0xf7, 0xc9, 0x2c, 0x2e, 0x11, 0xf2, 0xe2, 0xe2, 0xcd, 0xcc, + 0x2b, 0x49, 0x2d, 0x4a, 0x2d, 0x86, 0x6a, 0x67, 0x06, 0x6b, 0x97, 0xc7, 0xd4, 0xee, 0x09, 0x55, + 0xe6, 0x94, 0x93, 0x9f, 0x9c, 0x0d, 0x35, 0x87, 0x07, 0xa6, 0x17, 0x64, 0x96, 0x93, 0xd7, 0x89, + 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, + 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0x19, 0xa4, 0x67, 0x96, 0x64, 0x94, 0x26, + 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0x83, 0x0c, 0xd6, 0xcd, 0x4b, 0x2d, 0x29, 0xcf, 0x2f, 0xca, 0x06, + 0x73, 0xf4, 0x2b, 0x30, 0x43, 0x28, 0x89, 0x0d, 0x1c, 0x44, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, + 0xff, 0xe2, 0x9b, 0x9b, 0xa0, 0xc6, 0x01, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -111,6 +132,34 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.InterestList) > 0 { + for iNdEx := len(m.InterestList) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.InterestList[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if len(m.DebtList) > 0 { + for iNdEx := len(m.DebtList) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.DebtList[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } { size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) if err != nil { @@ -143,6 +192,18 @@ func (m *GenesisState) Size() (n int) { _ = l l = m.Params.Size() n += 1 + l + sovGenesis(uint64(l)) + if len(m.DebtList) > 0 { + for _, e := range m.DebtList { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.InterestList) > 0 { + for _, e := range m.InterestList { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } return n } @@ -214,6 +275,74 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DebtList", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DebtList = append(m.DebtList, Debt{}) + if err := m.DebtList[len(m.DebtList)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field InterestList", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.InterestList = append(m.InterestList, InterestBlock{}) + if err := m.InterestList[len(m.InterestList)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) diff --git a/x/stablestake/types/types.pb.go b/x/stablestake/types/types.pb.go index 607828e57..180f7bfaa 100644 --- a/x/stablestake/types/types.pb.go +++ b/x/stablestake/types/types.pb.go @@ -66,6 +66,7 @@ var xxx_messageInfo_BalanceBorrowed proto.InternalMessageInfo type InterestBlock struct { InterestRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,1,opt,name=interest_rate,json=interestRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"interest_rate"` BlockTime int64 `protobuf:"varint,2,opt,name=block_time,json=blockTime,proto3" json:"block_time,omitempty"` + BlockHeight uint64 `protobuf:"varint,3,opt,name=block_height,json=blockHeight,proto3" json:"block_height,omitempty"` } func (m *InterestBlock) Reset() { *m = InterestBlock{} } @@ -108,35 +109,91 @@ func (m *InterestBlock) GetBlockTime() int64 { return 0 } +func (m *InterestBlock) GetBlockHeight() uint64 { + if m != nil { + return m.BlockHeight + } + return 0 +} + +type LegacyInterestBlock struct { + InterestRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,1,opt,name=interest_rate,json=interestRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"interest_rate"` + BlockTime int64 `protobuf:"varint,2,opt,name=block_time,json=blockTime,proto3" json:"block_time,omitempty"` +} + +func (m *LegacyInterestBlock) Reset() { *m = LegacyInterestBlock{} } +func (m *LegacyInterestBlock) String() string { return proto.CompactTextString(m) } +func (*LegacyInterestBlock) ProtoMessage() {} +func (*LegacyInterestBlock) Descriptor() ([]byte, []int) { + return fileDescriptor_7179d85642fbc30a, []int{2} +} +func (m *LegacyInterestBlock) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *LegacyInterestBlock) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_LegacyInterestBlock.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 *LegacyInterestBlock) XXX_Merge(src proto.Message) { + xxx_messageInfo_LegacyInterestBlock.Merge(m, src) +} +func (m *LegacyInterestBlock) XXX_Size() int { + return m.Size() +} +func (m *LegacyInterestBlock) XXX_DiscardUnknown() { + xxx_messageInfo_LegacyInterestBlock.DiscardUnknown(m) +} + +var xxx_messageInfo_LegacyInterestBlock proto.InternalMessageInfo + +func (m *LegacyInterestBlock) GetBlockTime() int64 { + if m != nil { + return m.BlockTime + } + return 0 +} + func init() { proto.RegisterType((*BalanceBorrowed)(nil), "elys.stablestake.BalanceBorrowed") proto.RegisterType((*InterestBlock)(nil), "elys.stablestake.InterestBlock") + proto.RegisterType((*LegacyInterestBlock)(nil), "elys.stablestake.LegacyInterestBlock") } func init() { proto.RegisterFile("elys/stablestake/types.proto", fileDescriptor_7179d85642fbc30a) } var fileDescriptor_7179d85642fbc30a = []byte{ - // 318 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x91, 0xcf, 0x4a, 0xfb, 0x40, - 0x10, 0xc7, 0xb3, 0xbf, 0x1f, 0x08, 0x5d, 0x2c, 0x4a, 0xf0, 0x50, 0x8b, 0xa6, 0xd2, 0x83, 0x78, - 0x69, 0x22, 0x78, 0xf5, 0x62, 0xe8, 0x45, 0x8f, 0xd1, 0x93, 0x0a, 0x61, 0xb3, 0x19, 0x62, 0xc8, - 0x9f, 0x29, 0xbb, 0x13, 0x6a, 0xcf, 0xbe, 0x80, 0x0f, 0xe3, 0x43, 0xf4, 0xe0, 0xa1, 0x78, 0x12, - 0x0f, 0x45, 0xda, 0x17, 0x91, 0x24, 0x2b, 0x14, 0x3c, 0x09, 0x9e, 0x76, 0x67, 0x3e, 0xcb, 0x67, - 0x76, 0xf8, 0xf2, 0x03, 0xc8, 0x67, 0xda, 0xd3, 0x24, 0xa2, 0x1c, 0x34, 0x89, 0x0c, 0x3c, 0x9a, - 0x4d, 0x40, 0xbb, 0x13, 0x85, 0x84, 0xf6, 0x6e, 0x4d, 0xdd, 0x0d, 0xda, 0xdf, 0x4b, 0x30, 0xc1, - 0x06, 0x7a, 0xf5, 0xad, 0x7d, 0xd7, 0xdf, 0x97, 0xa8, 0x0b, 0xd4, 0x61, 0x0b, 0xda, 0xa2, 0x45, - 0xc3, 0x57, 0xc6, 0x77, 0x7c, 0x91, 0x8b, 0x52, 0x82, 0x8f, 0x4a, 0xe1, 0x14, 0x62, 0xfb, 0x8e, - 0xf3, 0x4a, 0xc7, 0xa1, 0x28, 0xb0, 0x2a, 0xa9, 0xc7, 0x8e, 0xd8, 0x49, 0xc7, 0x3f, 0x9f, 0x2f, - 0x07, 0xd6, 0xc7, 0x72, 0x70, 0x9c, 0xa4, 0xf4, 0x50, 0x45, 0xae, 0xc4, 0xc2, 0x88, 0xcc, 0x31, - 0xd2, 0x71, 0x66, 0x3e, 0x37, 0x06, 0xf9, 0xf6, 0x32, 0xe2, 0x66, 0xce, 0x18, 0x64, 0xd0, 0xa9, - 0x74, 0x7c, 0xd1, 0xe8, 0xec, 0x7b, 0xce, 0x27, 0xa0, 0x24, 0x94, 0x24, 0x12, 0xe8, 0xfd, 0xfb, - 0x03, 0xf9, 0x86, 0x6f, 0xf8, 0xc4, 0x78, 0xf7, 0xb2, 0x24, 0x50, 0xa0, 0xc9, 0xcf, 0x51, 0x66, - 0xf6, 0x35, 0xef, 0xa6, 0xa6, 0x11, 0x2a, 0x41, 0x60, 0xf6, 0x71, 0x7f, 0x37, 0x32, 0xd8, 0xfe, - 0x96, 0x04, 0x82, 0xc0, 0x3e, 0xe4, 0x3c, 0xaa, 0xed, 0x21, 0xa5, 0x45, 0xbb, 0xc4, 0xff, 0xa0, - 0xd3, 0x74, 0x6e, 0xd2, 0x02, 0xfc, 0xab, 0xf9, 0xca, 0x61, 0x8b, 0x95, 0xc3, 0x3e, 0x57, 0x0e, - 0x7b, 0x5e, 0x3b, 0xd6, 0x62, 0xed, 0x58, 0xef, 0x6b, 0xc7, 0xba, 0x3d, 0xdd, 0x18, 0x57, 0x87, - 0x37, 0x2a, 0x81, 0xa6, 0xa8, 0xb2, 0xa6, 0xf0, 0x1e, 0x7f, 0x26, 0x1d, 0x6d, 0x35, 0x39, 0x9d, - 0x7d, 0x05, 0x00, 0x00, 0xff, 0xff, 0x27, 0x87, 0xc6, 0x09, 0x0a, 0x02, 0x00, 0x00, + // 356 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x92, 0xcf, 0x4a, 0xeb, 0x40, + 0x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13, 0xa5, 0xd3, 0x6f, 0x29, 0x1d, 0x43, 0xc6, + 0x21, 0x45, 0x16, 0x40, 0xeb, 0xcf, 0x0f, 0xc8, 0xd7, 0x7c, 0xbd, 0x47, 0x42, 0x9b, 0x67, 0x29, + 0x42, 0x06, 0x12, 0xed, 0x58, 0xf0, 0x48, 0xbf, 0xa4, 0xcd, 0xb0, 0x0a, 0xdc, 0x8c, 0x21, 0x54, + 0xfb, 0x98, 0xdf, 0x6b, 0xe9, 0x34, 0x3e, 0x25, 0x0e, 0x43, 0xd0, 0xf7, 0x28, 0xf5, 0x0a, 0xbb, + 0x8b, 0x61, 0x52, 0x2e, 0x51, 0x73, 0xea, 0x2a, 0xb9, 0x0a, 0x13, 0xd0, 0xf7, 0x69, 0xa3, 0xc4, + 0x23, 0x08, 0x83, 0x11, 0xb6, 0x6a, 0x5d, 0xd2, 0xff, 0xeb, 0xfc, 0x57, 0xd9, 0xa9, 0x8a, 0x7a, + 0xf7, 0x84, 0x6e, 0x5d, 0x40, 0xc0, 0xf8, 0xf4, 0xd7, 0xc7, 0xb5, 0xcf, 0x67, 0x4b, 0x83, 0xcc, + 0x97, 0x06, 0x79, 0x5f, 0x1a, 0xe4, 0x61, 0x65, 0x68, 0xf3, 0x95, 0xa1, 0xbd, 0xae, 0x0c, 0xed, + 0xfa, 0x70, 0xad, 0x5d, 0x71, 0x6b, 0x83, 0x14, 0x70, 0x22, 0xb2, 0x48, 0x15, 0xd6, 0xdd, 0xd7, + 0xc3, 0xf4, 0xfe, 0xa9, 0xb3, 0x3a, 0xfa, 0x08, 0x00, 0x00, 0xff, 0xff, 0x4c, 0xea, 0x6d, 0xb1, + 0xb9, 0x02, 0x00, 0x00, } func (m *BalanceBorrowed) Marshal() (dAtA []byte, err error) { @@ -198,6 +255,49 @@ func (m *InterestBlock) MarshalTo(dAtA []byte) (int, error) { } func (m *InterestBlock) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.BlockHeight != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.BlockHeight)) + i-- + dAtA[i] = 0x18 + } + if m.BlockTime != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.BlockTime)) + i-- + dAtA[i] = 0x10 + } + { + size := m.InterestRate.Size() + i -= size + if _, err := m.InterestRate.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *LegacyInterestBlock) 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 *LegacyInterestBlock) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *LegacyInterestBlock) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -245,6 +345,23 @@ func (m *BalanceBorrowed) Size() (n int) { } func (m *InterestBlock) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.InterestRate.Size() + n += 1 + l + sovTypes(uint64(l)) + if m.BlockTime != 0 { + n += 1 + sovTypes(uint64(m.BlockTime)) + } + if m.BlockHeight != 0 { + n += 1 + sovTypes(uint64(m.BlockHeight)) + } + return n +} + +func (m *LegacyInterestBlock) Size() (n int) { if m == nil { return 0 } @@ -411,6 +528,128 @@ func (m *InterestBlock) Unmarshal(dAtA []byte) error { return fmt.Errorf("proto: InterestBlock: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field InterestRate", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.InterestRate.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field BlockTime", wireType) + } + m.BlockTime = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.BlockTime |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field BlockHeight", wireType) + } + m.BlockHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.BlockHeight |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *LegacyInterestBlock) 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 ErrIntOverflowTypes + } + 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: LegacyInterestBlock: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: LegacyInterestBlock: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { case 1: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field InterestRate", wireType)