From 90456d035830368fb33008f1ae58d5bdcbb67c96 Mon Sep 17 00:00:00 2001 From: Benjamin DENEUX Date: Wed, 23 Aug 2023 09:49:20 +0200 Subject: [PATCH] feat(mint): new mint params --- docs/proto/mint.md | 7 +- proto/mint/v1beta1/mint.proto | 25 ++-- x/mint/types/mint.pb.go | 215 +++++++++++++++++++++------------- 3 files changed, 152 insertions(+), 95 deletions(-) diff --git a/docs/proto/mint.md b/docs/proto/mint.md index ebffced7..14a60bf2 100644 --- a/docs/proto/mint.md +++ b/docs/proto/mint.md @@ -70,7 +70,6 @@ and `target_supply` 230M. | ----- | ---- | ----- | ----------- | | `inflation` | [string](#string) | | current annual inflation rate | | `annual_provisions` | [string](#string) | | current annual expected provisions | -| `target_supply` | [string](#string) | | target supply at end of period | @@ -86,8 +85,10 @@ new inflation will be 12%. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | | `mint_denom` | [string](#string) | | type of coin to mint | -| `annual_reduction_factor` | [string](#string) | | annual reduction factor inflation rate change | -| `blocks_per_year` | [uint64](#uint64) | | expected blocks per year | +| `inflation_coef` | [string](#string) | | annual inflation coefficient | +| `bounding_adjustment` | [string](#string) | | bounding adjustment | +| `target_bounding_ratio` | [string](#string) | | target boudning ratio | +| `blocks_per_year` | [uint64](#uint64) | | expected blocks per yearmake p | [//]: # (end messages) diff --git a/proto/mint/v1beta1/mint.proto b/proto/mint/v1beta1/mint.proto index 4a3729da..3915952a 100644 --- a/proto/mint/v1beta1/mint.proto +++ b/proto/mint/v1beta1/mint.proto @@ -26,11 +26,6 @@ message Minter { (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false ]; - // target supply at end of period - string target_supply = 3 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", - (gogoproto.nullable) = false - ]; } // Params holds parameters for the mint module. @@ -44,12 +39,24 @@ message Params { // type of coin to mint string mint_denom = 1; - // annual reduction factor inflation rate change - string annual_reduction_factor = 2 [ + // annual inflation coefficient + string inflation_coef = 2 [ + (cosmos_proto.scalar) = "cosmos.Dec", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + // bounding adjustment + string bounding_adjustment = 3 [ + (cosmos_proto.scalar) = "cosmos.Dec", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + // target boudning ratio + string target_bounding_ratio = 4 [ (cosmos_proto.scalar) = "cosmos.Dec", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false ]; - // expected blocks per year - uint64 blocks_per_year = 3; + // expected blocks per yearmake p + uint64 blocks_per_year = 5; } diff --git a/x/mint/types/mint.pb.go b/x/mint/types/mint.pb.go index 14252479..b5c103f2 100644 --- a/x/mint/types/mint.pb.go +++ b/x/mint/types/mint.pb.go @@ -36,8 +36,6 @@ type Minter struct { Inflation github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,1,opt,name=inflation,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"inflation"` // current annual expected provisions AnnualProvisions github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=annual_provisions,json=annualProvisions,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"annual_provisions"` - // target supply at end of period - TargetSupply github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=target_supply,json=targetSupply,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"target_supply"` } func (m *Minter) Reset() { *m = Minter{} } @@ -82,10 +80,14 @@ var xxx_messageInfo_Minter proto.InternalMessageInfo type Params struct { // type of coin to mint MintDenom string `protobuf:"bytes,1,opt,name=mint_denom,json=mintDenom,proto3" json:"mint_denom,omitempty"` - // annual reduction factor inflation rate change - AnnualReductionFactor github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=annual_reduction_factor,json=annualReductionFactor,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"annual_reduction_factor"` - // expected blocks per year - BlocksPerYear uint64 `protobuf:"varint,3,opt,name=blocks_per_year,json=blocksPerYear,proto3" json:"blocks_per_year,omitempty"` + // annual inflation coefficient + InflationCoef github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=inflation_coef,json=inflationCoef,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"inflation_coef"` + // bounding adjustment + BoundingAdjustment github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=bounding_adjustment,json=boundingAdjustment,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"bounding_adjustment"` + // target boudning ratio + TargetBoundingRatio github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,4,opt,name=target_bounding_ratio,json=targetBoundingRatio,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"target_bounding_ratio"` + // expected blocks per yearmake p + BlocksPerYear uint64 `protobuf:"varint,5,opt,name=blocks_per_year,json=blocksPerYear,proto3" json:"blocks_per_year,omitempty"` } func (m *Params) Reset() { *m = Params{} } @@ -142,31 +144,32 @@ func init() { func init() { proto.RegisterFile("mint/v1beta1/mint.proto", fileDescriptor_06339c129491fd39) } var fileDescriptor_06339c129491fd39 = []byte{ - // 379 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x92, 0xcf, 0x6a, 0xea, 0x40, - 0x14, 0xc6, 0x13, 0xaf, 0x08, 0x0e, 0xca, 0xbd, 0x37, 0xdc, 0x8b, 0x56, 0x68, 0x2c, 0x2e, 0xa4, - 0x1b, 0x13, 0xa4, 0x5d, 0x15, 0x57, 0x22, 0x85, 0x2e, 0x0a, 0x12, 0x57, 0x75, 0x13, 0x26, 0xc9, - 0x98, 0x0e, 0x26, 0x33, 0x61, 0x66, 0x22, 0xf5, 0x2d, 0xba, 0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x13, 0xc5, 0xe8, 0x3c, 0x99, 0xa0, 0x32, 0x86, 0x0c, 0xa6, 0xdc, 0x3a, 0x04, 0x40, 0x8e, - 0xdc, 0x8f, 0x10, 0xa1, 0xa9, 0x9e, 0x93, 0x57, 0x95, 0xca, 0x48, 0x0a, 0x96, 0x00, 0x8d, 0x22, - 0x29, 0x43, 0x51, 0x1e, 0xca, 0xf4, 0xfe, 0x0c, 0x86, 0x82, 0xb2, 0xbd, 0xe4, 0xfd, 0xaf, 0xe1, - 0xde, 0x07, 0xfb, 0x5c, 0xa1, 0xad, 0x2e, 0xf8, 0x1d, 0x24, 0x34, 0x9c, 0x73, 0x3f, 0x43, 0xcc, - 0x5f, 0x22, 0xc8, 0x54, 0xec, 0xb2, 0x57, 0xd7, 0xf2, 0x18, 0xb1, 0x2b, 0x04, 0xd9, 0x59, 0xf9, - 0xee, 0xbe, 0x6d, 0x0c, 0x07, 0xab, 0xad, 0x6d, 0xae, 0xb7, 0xb6, 0xf9, 0xb6, 0xb5, 0xcd, 0xdb, - 0x9d, 0x6d, 0xac, 0x77, 0xb6, 0xf1, 0xb2, 0xb3, 0x8d, 0x69, 0xe7, 0x5b, 0x53, 0x74, 0x9e, 0x9d, - 0xaa, 0x4f, 0xe4, 0xde, 0xa8, 0x8d, 0xd3, 0x4d, 0x05, 0x15, 0xb5, 0x39, 0x27, 0xef, 0x01, 0x00, - 0x00, 0xff, 0xff, 0x71, 0x98, 0x4c, 0x41, 0x93, 0x02, 0x00, 0x00, + // 394 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x92, 0x4f, 0x6e, 0xe2, 0x30, + 0x14, 0xc6, 0x93, 0x81, 0x41, 0xc2, 0x1a, 0xe6, 0x8f, 0x99, 0xd1, 0x64, 0x90, 0x26, 0x20, 0x16, + 0x88, 0x0d, 0x44, 0x68, 0x66, 0x35, 0x62, 0x33, 0x94, 0x6d, 0x25, 0x94, 0x5d, 0xd9, 0x44, 0x4e, + 0x62, 0x52, 0x17, 0x62, 0x47, 0xb6, 0x83, 0xca, 0x2d, 0xba, 0xac, 0xd4, 0x4d, 0x0f, 0xd1, 0x43, + 0xb0, 0x2b, 0xea, 0xaa, 0xea, 0x02, 0x55, 0x70, 0x91, 0xca, 0x71, 0x9a, 0xf6, 0x00, 0xd9, 0x24, + 0xef, 0x7d, 0xcf, 0xfa, 0x7d, 0x9f, 0xad, 0x07, 0x7e, 0xc6, 0x84, 0x4a, 0x67, 0x3d, 0xf2, 0xb1, + 0x44, 0x23, 0x47, 0x35, 0xc3, 0x84, 0x33, 0xc9, 0xe0, 0xa7, 0xac, 0xce, 0x07, 0xad, 0x5f, 0x01, + 0x13, 0x31, 0x13, 0x5e, 0x36, 0x73, 0x74, 0xa3, 0x0f, 0xb6, 0xbe, 0x47, 0x2c, 0x62, 0x5a, 0x57, + 0x95, 0x56, 0xbb, 0xf7, 0x26, 0xa8, 0x9d, 0x12, 0x2a, 0x31, 0x87, 0x73, 0x50, 0x27, 0x74, 0xb1, + 0x42, 0x92, 0x30, 0x6a, 0x99, 0x1d, 0xb3, 0x5f, 0x9f, 0x8c, 0xb7, 0xfb, 0xb6, 0xf1, 0xb4, 0x6f, + 0xf7, 0x22, 0x22, 0xcf, 0x53, 0x7f, 0x18, 0xb0, 0x38, 0x87, 0xe6, 0xbf, 0x81, 0x08, 0x97, 0x8e, + 0xdc, 0x24, 0x58, 0x0c, 0xa7, 0x38, 0x78, 0xb8, 0x1b, 0x80, 0xdc, 0x73, 0x8a, 0x03, 0xf7, 0x0d, + 0x07, 0x09, 0xf8, 0x86, 0x28, 0x4d, 0xd1, 0x4a, 0x25, 0x5b, 0x13, 0x41, 0x18, 0x15, 0xd6, 0x87, + 0x12, 0x3c, 0xbe, 0x6a, 0xec, 0xac, 0xa0, 0x76, 0x6f, 0x2a, 0xa0, 0x36, 0x43, 0x1c, 0xc5, 0x02, + 0xfe, 0x06, 0x40, 0xbd, 0x8e, 0x17, 0x62, 0xca, 0x62, 0x7d, 0x25, 0xb7, 0xae, 0x94, 0xa9, 0x12, + 0x60, 0x00, 0x3e, 0x17, 0x09, 0xbd, 0x80, 0xe1, 0x45, 0x29, 0x89, 0x1a, 0x05, 0xf3, 0x84, 0xe1, + 0x05, 0x8c, 0x41, 0xd3, 0x67, 0x29, 0x0d, 0x09, 0x8d, 0x3c, 0x14, 0x5e, 0xa4, 0x42, 0xc6, 0x98, + 0x4a, 0xab, 0x52, 0x82, 0x13, 0x7c, 0x05, 0xff, 0x2f, 0xb8, 0x30, 0x01, 0x3f, 0x24, 0xe2, 0x11, + 0x96, 0x5e, 0xe1, 0xca, 0x55, 0x18, 0xab, 0x5a, 0x82, 0x61, 0x53, 0xa3, 0x27, 0x39, 0xd9, 0x55, + 0x60, 0xd8, 0x03, 0x5f, 0xfc, 0x15, 0x0b, 0x96, 0xc2, 0x4b, 0x30, 0xf7, 0x36, 0x18, 0x71, 0xeb, + 0x63, 0xc7, 0xec, 0x57, 0xdd, 0x86, 0x96, 0x67, 0x98, 0x9f, 0x61, 0xc4, 0xff, 0x55, 0xaf, 0x6f, + 0xdb, 0xc6, 0x64, 0xbc, 0x3d, 0xd8, 0xe6, 0xee, 0x60, 0x9b, 0xcf, 0x07, 0xdb, 0xbc, 0x3a, 0xda, + 0xc6, 0xee, 0x68, 0x1b, 0x8f, 0x47, 0xdb, 0x98, 0x77, 0xdf, 0x45, 0x62, 0xcb, 0xe4, 0x6f, 0xf6, + 0x09, 0x9d, 0xcb, 0x6c, 0xd9, 0x75, 0x24, 0xbf, 0x96, 0x2d, 0xed, 0x9f, 0x97, 0x00, 0x00, 0x00, + 0xff, 0xff, 0xf8, 0x24, 0xd5, 0x53, 0x0e, 0x03, 0x00, 0x00, } func (m *Minter) Marshal() (dAtA []byte, err error) { @@ -189,16 +192,6 @@ func (m *Minter) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - { - size := m.TargetSupply.Size() - i -= size - if _, err := m.TargetSupply.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintMint(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a { size := m.AnnualProvisions.Size() i -= size @@ -245,12 +238,32 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { if m.BlocksPerYear != 0 { i = encodeVarintMint(dAtA, i, uint64(m.BlocksPerYear)) i-- - dAtA[i] = 0x18 + dAtA[i] = 0x28 } { - size := m.AnnualReductionFactor.Size() + size := m.TargetBoundingRatio.Size() i -= size - if _, err := m.AnnualReductionFactor.MarshalTo(dAtA[i:]); err != nil { + if _, err := m.TargetBoundingRatio.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintMint(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + { + size := m.BoundingAdjustment.Size() + i -= size + if _, err := m.BoundingAdjustment.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintMint(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + { + size := m.InflationCoef.Size() + i -= size + if _, err := m.InflationCoef.MarshalTo(dAtA[i:]); err != nil { return 0, err } i = encodeVarintMint(dAtA, i, uint64(size)) @@ -288,8 +301,6 @@ func (m *Minter) Size() (n int) { n += 1 + l + sovMint(uint64(l)) l = m.AnnualProvisions.Size() n += 1 + l + sovMint(uint64(l)) - l = m.TargetSupply.Size() - n += 1 + l + sovMint(uint64(l)) return n } @@ -303,7 +314,11 @@ func (m *Params) Size() (n int) { if l > 0 { n += 1 + l + sovMint(uint64(l)) } - l = m.AnnualReductionFactor.Size() + l = m.InflationCoef.Size() + n += 1 + l + sovMint(uint64(l)) + l = m.BoundingAdjustment.Size() + n += 1 + l + sovMint(uint64(l)) + l = m.TargetBoundingRatio.Size() n += 1 + l + sovMint(uint64(l)) if m.BlocksPerYear != 0 { n += 1 + sovMint(uint64(m.BlocksPerYear)) @@ -414,40 +429,6 @@ func (m *Minter) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TargetSupply", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMint - } - 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 ErrInvalidLengthMint - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMint - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.TargetSupply.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipMint(dAtA[iNdEx:]) @@ -532,7 +513,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AnnualReductionFactor", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field InflationCoef", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -560,11 +541,79 @@ func (m *Params) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.AnnualReductionFactor.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.InflationCoef.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BoundingAdjustment", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMint + } + 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 ErrInvalidLengthMint + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMint + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.BoundingAdjustment.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TargetBoundingRatio", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMint + } + 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 ErrInvalidLengthMint + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMint + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.TargetBoundingRatio.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field BlocksPerYear", wireType) }