diff --git a/api/sunrise/tokenconverter/params.pulsar.go b/api/sunrise/tokenconverter/params.pulsar.go index ce27f6e9..5d91b54f 100644 --- a/api/sunrise/tokenconverter/params.pulsar.go +++ b/api/sunrise/tokenconverter/params.pulsar.go @@ -19,7 +19,7 @@ var ( md_Params protoreflect.MessageDescriptor fd_Params_denom_gov_token protoreflect.FieldDescriptor fd_Params_denom_fee_token protoreflect.FieldDescriptor - fd_Params_supply_cap_fee_token protoreflect.FieldDescriptor + fd_Params_max_supply_fee_token protoreflect.FieldDescriptor ) func init() { @@ -27,7 +27,7 @@ func init() { md_Params = File_sunrise_tokenconverter_params_proto.Messages().ByName("Params") fd_Params_denom_gov_token = md_Params.Fields().ByName("denom_gov_token") fd_Params_denom_fee_token = md_Params.Fields().ByName("denom_fee_token") - fd_Params_supply_cap_fee_token = md_Params.Fields().ByName("supply_cap_fee_token") + fd_Params_max_supply_fee_token = md_Params.Fields().ByName("max_supply_fee_token") } var _ protoreflect.Message = (*fastReflection_Params)(nil) @@ -107,9 +107,9 @@ func (x *fastReflection_Params) Range(f func(protoreflect.FieldDescriptor, proto return } } - if x.SupplyCapFeeToken != "" { - value := protoreflect.ValueOfString(x.SupplyCapFeeToken) - if !f(fd_Params_supply_cap_fee_token, value) { + if x.MaxSupplyFeeToken != "" { + value := protoreflect.ValueOfString(x.MaxSupplyFeeToken) + if !f(fd_Params_max_supply_fee_token, value) { return } } @@ -132,8 +132,8 @@ func (x *fastReflection_Params) Has(fd protoreflect.FieldDescriptor) bool { return x.DenomGovToken != "" case "sunrise.tokenconverter.Params.denom_fee_token": return x.DenomFeeToken != "" - case "sunrise.tokenconverter.Params.supply_cap_fee_token": - return x.SupplyCapFeeToken != "" + case "sunrise.tokenconverter.Params.max_supply_fee_token": + return x.MaxSupplyFeeToken != "" default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: sunrise.tokenconverter.Params")) @@ -154,8 +154,8 @@ func (x *fastReflection_Params) Clear(fd protoreflect.FieldDescriptor) { x.DenomGovToken = "" case "sunrise.tokenconverter.Params.denom_fee_token": x.DenomFeeToken = "" - case "sunrise.tokenconverter.Params.supply_cap_fee_token": - x.SupplyCapFeeToken = "" + case "sunrise.tokenconverter.Params.max_supply_fee_token": + x.MaxSupplyFeeToken = "" default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: sunrise.tokenconverter.Params")) @@ -178,8 +178,8 @@ func (x *fastReflection_Params) Get(descriptor protoreflect.FieldDescriptor) pro case "sunrise.tokenconverter.Params.denom_fee_token": value := x.DenomFeeToken return protoreflect.ValueOfString(value) - case "sunrise.tokenconverter.Params.supply_cap_fee_token": - value := x.SupplyCapFeeToken + case "sunrise.tokenconverter.Params.max_supply_fee_token": + value := x.MaxSupplyFeeToken return protoreflect.ValueOfString(value) default: if descriptor.IsExtension() { @@ -205,8 +205,8 @@ func (x *fastReflection_Params) Set(fd protoreflect.FieldDescriptor, value proto x.DenomGovToken = value.Interface().(string) case "sunrise.tokenconverter.Params.denom_fee_token": x.DenomFeeToken = value.Interface().(string) - case "sunrise.tokenconverter.Params.supply_cap_fee_token": - x.SupplyCapFeeToken = value.Interface().(string) + case "sunrise.tokenconverter.Params.max_supply_fee_token": + x.MaxSupplyFeeToken = value.Interface().(string) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: sunrise.tokenconverter.Params")) @@ -231,8 +231,8 @@ func (x *fastReflection_Params) Mutable(fd protoreflect.FieldDescriptor) protore panic(fmt.Errorf("field denom_gov_token of message sunrise.tokenconverter.Params is not mutable")) case "sunrise.tokenconverter.Params.denom_fee_token": panic(fmt.Errorf("field denom_fee_token of message sunrise.tokenconverter.Params is not mutable")) - case "sunrise.tokenconverter.Params.supply_cap_fee_token": - panic(fmt.Errorf("field supply_cap_fee_token of message sunrise.tokenconverter.Params is not mutable")) + case "sunrise.tokenconverter.Params.max_supply_fee_token": + panic(fmt.Errorf("field max_supply_fee_token of message sunrise.tokenconverter.Params is not mutable")) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: sunrise.tokenconverter.Params")) @@ -250,7 +250,7 @@ func (x *fastReflection_Params) NewField(fd protoreflect.FieldDescriptor) protor return protoreflect.ValueOfString("") case "sunrise.tokenconverter.Params.denom_fee_token": return protoreflect.ValueOfString("") - case "sunrise.tokenconverter.Params.supply_cap_fee_token": + case "sunrise.tokenconverter.Params.max_supply_fee_token": return protoreflect.ValueOfString("") default: if fd.IsExtension() { @@ -329,7 +329,7 @@ func (x *fastReflection_Params) ProtoMethods() *protoiface.Methods { if l > 0 { n += 1 + l + runtime.Sov(uint64(l)) } - l = len(x.SupplyCapFeeToken) + l = len(x.MaxSupplyFeeToken) if l > 0 { n += 1 + l + runtime.Sov(uint64(l)) } @@ -362,10 +362,10 @@ func (x *fastReflection_Params) ProtoMethods() *protoiface.Methods { i -= len(x.unknownFields) copy(dAtA[i:], x.unknownFields) } - if len(x.SupplyCapFeeToken) > 0 { - i -= len(x.SupplyCapFeeToken) - copy(dAtA[i:], x.SupplyCapFeeToken) - i = runtime.EncodeVarint(dAtA, i, uint64(len(x.SupplyCapFeeToken))) + if len(x.MaxSupplyFeeToken) > 0 { + i -= len(x.MaxSupplyFeeToken) + copy(dAtA[i:], x.MaxSupplyFeeToken) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.MaxSupplyFeeToken))) i-- dAtA[i] = 0x1a } @@ -498,7 +498,7 @@ func (x *fastReflection_Params) ProtoMethods() *protoiface.Methods { iNdEx = postIndex case 3: if wireType != 2 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field SupplyCapFeeToken", wireType) + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field MaxSupplyFeeToken", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -526,7 +526,7 @@ func (x *fastReflection_Params) ProtoMethods() *protoiface.Methods { if postIndex > l { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF } - x.SupplyCapFeeToken = string(dAtA[iNdEx:postIndex]) + x.MaxSupplyFeeToken = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex @@ -584,7 +584,7 @@ type Params struct { DenomGovToken string `protobuf:"bytes,1,opt,name=denom_gov_token,json=denomGovToken,proto3" json:"denom_gov_token,omitempty"` DenomFeeToken string `protobuf:"bytes,2,opt,name=denom_fee_token,json=denomFeeToken,proto3" json:"denom_fee_token,omitempty"` - SupplyCapFeeToken string `protobuf:"bytes,3,opt,name=supply_cap_fee_token,json=supplyCapFeeToken,proto3" json:"supply_cap_fee_token,omitempty"` + MaxSupplyFeeToken string `protobuf:"bytes,3,opt,name=max_supply_fee_token,json=maxSupplyFeeToken,proto3" json:"max_supply_fee_token,omitempty"` } func (x *Params) Reset() { @@ -621,9 +621,9 @@ func (x *Params) GetDenomFeeToken() string { return "" } -func (x *Params) GetSupplyCapFeeToken() string { +func (x *Params) GetMaxSupplyFeeToken() string { if x != nil { - return x.SupplyCapFeeToken + return x.MaxSupplyFeeToken } return "" } @@ -645,12 +645,12 @@ var file_sunrise_tokenconverter_params_proto_rawDesc = []byte{ 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x26, 0x0a, 0x0f, 0x64, 0x65, 0x6e, 0x6f, 0x6d, 0x5f, 0x66, 0x65, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x64, 0x65, 0x6e, 0x6f, 0x6d, 0x46, 0x65, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x61, 0x0a, 0x14, - 0x73, 0x75, 0x70, 0x70, 0x6c, 0x79, 0x5f, 0x63, 0x61, 0x70, 0x5f, 0x66, 0x65, 0x65, 0x5f, 0x74, + 0x6d, 0x61, 0x78, 0x5f, 0x73, 0x75, 0x70, 0x70, 0x6c, 0x79, 0x5f, 0x66, 0x65, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x42, 0x30, 0xc8, 0xde, 0x1f, 0x00, 0xda, 0xde, 0x1f, 0x15, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x6d, 0x61, 0x74, 0x68, 0x2e, 0x49, 0x6e, 0x74, 0xd2, 0xb4, 0x2d, 0x0a, 0x63, 0x6f, 0x73, - 0x6d, 0x6f, 0x73, 0x2e, 0x49, 0x6e, 0x74, 0xa8, 0xe7, 0xb0, 0x2a, 0x01, 0x52, 0x11, 0x73, 0x75, - 0x70, 0x70, 0x6c, 0x79, 0x43, 0x61, 0x70, 0x46, 0x65, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x3a, + 0x6d, 0x6f, 0x73, 0x2e, 0x49, 0x6e, 0x74, 0xa8, 0xe7, 0xb0, 0x2a, 0x01, 0x52, 0x11, 0x6d, 0x61, + 0x78, 0x53, 0x75, 0x70, 0x70, 0x6c, 0x79, 0x46, 0x65, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x3a, 0x28, 0xe8, 0xa0, 0x1f, 0x01, 0x8a, 0xe7, 0xb0, 0x2a, 0x1f, 0x73, 0x75, 0x6e, 0x72, 0x69, 0x73, 0x65, 0x2f, 0x78, 0x2f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x63, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x74, 0x65, 0x72, 0x2f, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x42, 0xcb, 0x01, 0x0a, 0x1a, 0x63, 0x6f, diff --git a/proto/sunrise/tokenconverter/params.proto b/proto/sunrise/tokenconverter/params.proto index 0eec4225..934dc098 100644 --- a/proto/sunrise/tokenconverter/params.proto +++ b/proto/sunrise/tokenconverter/params.proto @@ -15,7 +15,7 @@ message Params { string denom_gov_token = 1; string denom_fee_token = 2; - string supply_cap_fee_token = 3 [ + string max_supply_fee_token = 3 [ (cosmos_proto.scalar) = "cosmos.Int", (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.nullable) = false, diff --git a/x/tokenconverter/README.md b/x/tokenconverter/README.md index c41e7961..71b80bf0 100644 --- a/x/tokenconverter/README.md +++ b/x/tokenconverter/README.md @@ -1,9 +1,9 @@ # tokenconverter -This module is for converting `SRG` to `SR` token. +This module is for converting `SSR` to `SR` token. $$ - \text{OutputSR} = \text{InputSSR} \times \min\left(1, \frac{\text{CurrentSupplySR}}{\text{CurrentSupplySSR}} \right) \ \text{if} \ \text{CurrentSupplySR} + \text{OutputSR} \le \text{MaxSupplySR} + \text{OutputSR} = \text{InputSSR} \times \min\left(1, \frac{\text{MaxSupplySR}}{\text{CurrentSupplySSR}} \right) \ \text{if} \ \text{CurrentSupplySR} + \text{OutputSR} \le \text{MaxSupplySR} $$ ## Ante Handler diff --git a/x/tokenconverter/keeper/calculation.go b/x/tokenconverter/keeper/calculation.go index bede27ae..57941cd3 100644 --- a/x/tokenconverter/keeper/calculation.go +++ b/x/tokenconverter/keeper/calculation.go @@ -12,10 +12,9 @@ import ( func (k Keeper) CalculateAmountOutFeeToken(ctx context.Context, amountInGovToken math.Int) math.Int { params := k.GetParams(ctx) - supplyFee := k.bankKeeper.GetSupply(ctx, params.DenomFeeToken) supplyGov := k.bankKeeper.GetSupply(ctx, params.DenomGovToken) - output := types.CalculateAmountOutFeeToken(supplyFee.Amount, supplyGov.Amount, amountInGovToken) + output := types.CalculateAmountOutFeeToken(params.MaxSupplyFeeToken, supplyGov.Amount, amountInGovToken) return output } @@ -23,10 +22,9 @@ func (k Keeper) CalculateAmountOutFeeToken(ctx context.Context, amountInGovToken func (k Keeper) CalculateAmountInGovToken(ctx context.Context, amountOutFeeToken math.Int) math.Int { params := k.GetParams(ctx) - supplyFee := k.bankKeeper.GetSupply(ctx, params.DenomFeeToken) supplyGov := k.bankKeeper.GetSupply(ctx, params.DenomGovToken) - input := types.CalculateAmountInGovToken(supplyFee.Amount, supplyGov.Amount, amountOutFeeToken) + input := types.CalculateAmountInGovToken(params.MaxSupplyFeeToken, supplyGov.Amount, amountOutFeeToken) return input } @@ -45,8 +43,8 @@ func (k Keeper) Convert(ctx context.Context, amountInGovToken math.Int, amountOu supplyFee := k.bankKeeper.GetSupply(ctx, params.DenomFeeToken) - if supplyFee.Amount.Add(amountOutFeeToken).GT(params.SupplyCapFeeToken) { - return types.ErrExceedsSupplyCap + if supplyFee.Amount.Add(amountOutFeeToken).GT(params.MaxSupplyFeeToken) { + return types.ErrExceedsMaxSupply } if err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, address, types.ModuleName, sdk.NewCoins(govToken)); err != nil { diff --git a/x/tokenconverter/types/errors.go b/x/tokenconverter/types/errors.go index 70cf8457..105c359f 100644 --- a/x/tokenconverter/types/errors.go +++ b/x/tokenconverter/types/errors.go @@ -11,7 +11,7 @@ var ( ErrInvalidSigner = sdkerrors.Register(ModuleName, 1100, "expected gov account as only signer for proposal message") ErrSample = sdkerrors.Register(ModuleName, 1101, "sample error") - ErrExceedsSupplyCap = sdkerrors.Register(ModuleName, 1111, "exceeds supply cap") + ErrExceedsMaxSupply = sdkerrors.Register(ModuleName, 1111, "exceeds max supply") ErrInsufficientAmountOut = sdkerrors.Register(ModuleName, 1121, "insufficient amount out") ErrExceededAmountIn = sdkerrors.Register(ModuleName, 1122, "exceeded amount in") diff --git a/x/tokenconverter/types/params.pb.go b/x/tokenconverter/types/params.pb.go index ce22b9ba..4d3c9652 100644 --- a/x/tokenconverter/types/params.pb.go +++ b/x/tokenconverter/types/params.pb.go @@ -30,7 +30,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Params struct { DenomGovToken string `protobuf:"bytes,1,opt,name=denom_gov_token,json=denomGovToken,proto3" json:"denom_gov_token,omitempty"` DenomFeeToken string `protobuf:"bytes,2,opt,name=denom_fee_token,json=denomFeeToken,proto3" json:"denom_fee_token,omitempty"` - SupplyCapFeeToken cosmossdk_io_math.Int `protobuf:"bytes,3,opt,name=supply_cap_fee_token,json=supplyCapFeeToken,proto3,customtype=cosmossdk.io/math.Int" json:"supply_cap_fee_token"` + MaxSupplyFeeToken cosmossdk_io_math.Int `protobuf:"bytes,3,opt,name=max_supply_fee_token,json=maxSupplyFeeToken,proto3,customtype=cosmossdk.io/math.Int" json:"max_supply_fee_token"` } func (m *Params) Reset() { *m = Params{} } @@ -89,7 +89,7 @@ func init() { } var fileDescriptor_376694505fc8864d = []byte{ - // 312 bytes of a gzipped FileDescriptorProto + // 313 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x2e, 0x2e, 0xcd, 0x2b, 0xca, 0x2c, 0x4e, 0xd5, 0x2f, 0xc9, 0xcf, 0x4e, 0xcd, 0x4b, 0xce, 0xcf, 0x2b, 0x4b, 0x2d, 0x2a, 0x49, 0x2d, 0xd2, 0x2f, 0x48, 0x2c, 0x4a, 0xcc, 0x2d, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, @@ -99,17 +99,17 @@ var fileDescriptor_376694505fc8864d = []byte{ 0xd8, 0x02, 0xc0, 0x96, 0x09, 0xa9, 0x71, 0xf1, 0xa7, 0xa4, 0xe6, 0xe5, 0xe7, 0xc6, 0xa7, 0xe7, 0x97, 0xc5, 0x83, 0xad, 0x92, 0x60, 0x54, 0x60, 0xd4, 0xe0, 0x0c, 0xe2, 0x05, 0x0b, 0xbb, 0xe7, 0x97, 0x85, 0x80, 0x04, 0x11, 0xea, 0xd2, 0x52, 0x53, 0xa1, 0xea, 0x98, 0x90, 0xd4, 0xb9, 0xa5, - 0xa6, 0x42, 0xd4, 0x25, 0x72, 0x89, 0x14, 0x97, 0x16, 0x14, 0xe4, 0x54, 0xc6, 0x27, 0x27, 0x16, - 0x20, 0x29, 0x66, 0x06, 0x29, 0x76, 0x32, 0x38, 0x71, 0x4f, 0x9e, 0xe1, 0xd6, 0x3d, 0x79, 0x51, + 0xa6, 0x42, 0xd4, 0x25, 0x72, 0x89, 0xe4, 0x26, 0x56, 0xc4, 0x17, 0x97, 0x16, 0x14, 0xe4, 0x54, + 0x22, 0x29, 0x66, 0x06, 0x29, 0x76, 0x32, 0x38, 0x71, 0x4f, 0x9e, 0xe1, 0xd6, 0x3d, 0x79, 0x51, 0x88, 0x73, 0x8a, 0x53, 0xb2, 0xf5, 0x32, 0xf3, 0xf5, 0x73, 0x13, 0x4b, 0x32, 0xf4, 0x3c, 0xf3, 0x4a, 0x2e, 0x6d, 0xd1, 0xe5, 0x82, 0xba, 0xd3, 0x33, 0xaf, 0x64, 0xc5, 0xf3, 0x0d, 0x5a, 0x8c, - 0x41, 0x82, 0x10, 0xd3, 0x9c, 0x13, 0x0b, 0x60, 0x56, 0x58, 0x69, 0xbc, 0x58, 0x20, 0xcf, 0xd8, - 0xf5, 0x7c, 0x83, 0x96, 0x3c, 0x2c, 0x1c, 0x2b, 0xd0, 0x43, 0x12, 0xe2, 0x39, 0xa7, 0x80, 0x13, - 0x8f, 0xe4, 0x18, 0x2f, 0x3c, 0x92, 0x63, 0x7c, 0xf0, 0x48, 0x8e, 0x71, 0xc2, 0x63, 0x39, 0x86, - 0x0b, 0x8f, 0xe5, 0x18, 0x6e, 0x3c, 0x96, 0x63, 0x88, 0x32, 0x4b, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, - 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x87, 0x9a, 0x92, 0x93, 0x58, 0x99, 0x5a, 0xa4, 0x8f, 0xd3, 0xc8, - 0x92, 0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36, 0x70, 0x00, 0x1a, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, - 0x15, 0x9c, 0x56, 0x61, 0xc3, 0x01, 0x00, 0x00, + 0x41, 0x82, 0xb9, 0x89, 0x15, 0xc1, 0x60, 0xc3, 0x60, 0x56, 0x58, 0x69, 0xbc, 0x58, 0x20, 0xcf, + 0xd8, 0xf5, 0x7c, 0x83, 0x96, 0x3c, 0x2c, 0x1c, 0x2b, 0xd0, 0x43, 0x12, 0xe2, 0x39, 0xa7, 0x80, + 0x13, 0x8f, 0xe4, 0x18, 0x2f, 0x3c, 0x92, 0x63, 0x7c, 0xf0, 0x48, 0x8e, 0x71, 0xc2, 0x63, 0x39, + 0x86, 0x0b, 0x8f, 0xe5, 0x18, 0x6e, 0x3c, 0x96, 0x63, 0x88, 0x32, 0x4b, 0xcf, 0x2c, 0xc9, 0x28, + 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x87, 0x9a, 0x92, 0x93, 0x58, 0x99, 0x5a, 0xa4, 0x8f, 0xd3, + 0xc8, 0x92, 0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36, 0x70, 0x00, 0x1a, 0x03, 0x02, 0x00, 0x00, 0xff, + 0xff, 0xf9, 0x1d, 0x1c, 0xbc, 0xc3, 0x01, 0x00, 0x00, } func (this *Params) Equal(that interface{}) bool { @@ -137,7 +137,7 @@ func (this *Params) Equal(that interface{}) bool { if this.DenomFeeToken != that1.DenomFeeToken { return false } - if !this.SupplyCapFeeToken.Equal(that1.SupplyCapFeeToken) { + if !this.MaxSupplyFeeToken.Equal(that1.MaxSupplyFeeToken) { return false } return true @@ -163,9 +163,9 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { var l int _ = l { - size := m.SupplyCapFeeToken.Size() + size := m.MaxSupplyFeeToken.Size() i -= size - if _, err := m.SupplyCapFeeToken.MarshalTo(dAtA[i:]); err != nil { + if _, err := m.MaxSupplyFeeToken.MarshalTo(dAtA[i:]); err != nil { return 0, err } i = encodeVarintParams(dAtA, i, uint64(size)) @@ -214,7 +214,7 @@ func (m *Params) Size() (n int) { if l > 0 { n += 1 + l + sovParams(uint64(l)) } - l = m.SupplyCapFeeToken.Size() + l = m.MaxSupplyFeeToken.Size() n += 1 + l + sovParams(uint64(l)) return n } @@ -320,7 +320,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SupplyCapFeeToken", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field MaxSupplyFeeToken", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -348,7 +348,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.SupplyCapFeeToken.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.MaxSupplyFeeToken.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex diff --git a/x/tokenconverter/types/types.go b/x/tokenconverter/types/types.go index 428a7985..489f96fa 100644 --- a/x/tokenconverter/types/types.go +++ b/x/tokenconverter/types/types.go @@ -4,8 +4,8 @@ import ( "cosmossdk.io/math" ) -func ratio(supplyFeeToken math.Int, supplyGovToken math.Int) math.LegacyDec { - feeDec := math.LegacyNewDecFromInt(supplyFeeToken) +func ratio(maxSupplyFeeToken math.Int, supplyGovToken math.Int) math.LegacyDec { + feeDec := math.LegacyNewDecFromInt(maxSupplyFeeToken) govDec := math.LegacyNewDecFromInt(supplyGovToken) ratio := feeDec.Quo(govDec) @@ -17,14 +17,14 @@ func ratio(supplyFeeToken math.Int, supplyGovToken math.Int) math.LegacyDec { } -func CalculateAmountOutFeeToken(supplyFeeToken math.Int, supplyGovToken math.Int, amountInGovToken math.Int) math.Int { - ratio := ratio(supplyFeeToken, supplyGovToken) +func CalculateAmountOutFeeToken(maxSupplyFeeToken math.Int, supplyGovToken math.Int, amountInGovToken math.Int) math.Int { + ratio := ratio(maxSupplyFeeToken, supplyGovToken) return ratio.MulInt(amountInGovToken).TruncateInt() } -func CalculateAmountInGovToken(supplyFeeToken math.Int, supplyGovToken math.Int, amountOutFeeToken math.Int) math.Int { - ratio := ratio(supplyFeeToken, supplyGovToken) +func CalculateAmountInGovToken(maxSupplyFeeToken math.Int, supplyGovToken math.Int, amountOutFeeToken math.Int) math.Int { + ratio := ratio(maxSupplyFeeToken, supplyGovToken) return math.LegacyOneDec().Quo(ratio).MulInt(amountOutFeeToken).TruncateInt() }