diff --git a/api/elys/amm/params.pulsar.go b/api/elys/amm/params.pulsar.go index 84a1bae93..bf0f49132 100644 --- a/api/elys/amm/params.pulsar.go +++ b/api/elys/amm/params.pulsar.go @@ -14,11 +14,109 @@ import ( sync "sync" ) +var _ protoreflect.List = (*_LegacyParams_3_list)(nil) + +type _LegacyParams_3_list struct { + list *[]string +} + +func (x *_LegacyParams_3_list) Len() int { + if x.list == nil { + return 0 + } + return len(*x.list) +} + +func (x *_LegacyParams_3_list) Get(i int) protoreflect.Value { + return protoreflect.ValueOfString((*x.list)[i]) +} + +func (x *_LegacyParams_3_list) Set(i int, value protoreflect.Value) { + valueUnwrapped := value.String() + concreteValue := valueUnwrapped + (*x.list)[i] = concreteValue +} + +func (x *_LegacyParams_3_list) Append(value protoreflect.Value) { + valueUnwrapped := value.String() + concreteValue := valueUnwrapped + *x.list = append(*x.list, concreteValue) +} + +func (x *_LegacyParams_3_list) AppendMutable() protoreflect.Value { + panic(fmt.Errorf("AppendMutable can not be called on message LegacyParams at list field BaseAssets as it is not of Message kind")) +} + +func (x *_LegacyParams_3_list) Truncate(n int) { + *x.list = (*x.list)[:n] +} + +func (x *_LegacyParams_3_list) NewElement() protoreflect.Value { + v := "" + return protoreflect.ValueOfString(v) +} + +func (x *_LegacyParams_3_list) IsValid() bool { + return x.list != nil +} + +var _ protoreflect.List = (*_LegacyParams_9_list)(nil) + +type _LegacyParams_9_list struct { + list *[]string +} + +func (x *_LegacyParams_9_list) Len() int { + if x.list == nil { + return 0 + } + return len(*x.list) +} + +func (x *_LegacyParams_9_list) Get(i int) protoreflect.Value { + return protoreflect.ValueOfString((*x.list)[i]) +} + +func (x *_LegacyParams_9_list) Set(i int, value protoreflect.Value) { + valueUnwrapped := value.String() + concreteValue := valueUnwrapped + (*x.list)[i] = concreteValue +} + +func (x *_LegacyParams_9_list) Append(value protoreflect.Value) { + valueUnwrapped := value.String() + concreteValue := valueUnwrapped + *x.list = append(*x.list, concreteValue) +} + +func (x *_LegacyParams_9_list) AppendMutable() protoreflect.Value { + panic(fmt.Errorf("AppendMutable can not be called on message LegacyParams at list field AllowedPoolCreators as it is not of Message kind")) +} + +func (x *_LegacyParams_9_list) Truncate(n int) { + *x.list = (*x.list)[:n] +} + +func (x *_LegacyParams_9_list) NewElement() protoreflect.Value { + v := "" + return protoreflect.ValueOfString(v) +} + +func (x *_LegacyParams_9_list) IsValid() bool { + return x.list != nil +} + var ( - md_LegacyParams protoreflect.MessageDescriptor - fd_LegacyParams_pool_creation_fee protoreflect.FieldDescriptor - fd_LegacyParams_slippage_track_duration protoreflect.FieldDescriptor - fd_LegacyParams_enable_base_currency_paired_pool_only protoreflect.FieldDescriptor + md_LegacyParams protoreflect.MessageDescriptor + fd_LegacyParams_pool_creation_fee protoreflect.FieldDescriptor + fd_LegacyParams_slippage_track_duration protoreflect.FieldDescriptor + fd_LegacyParams_base_assets protoreflect.FieldDescriptor + fd_LegacyParams_weight_breaking_fee_exponent protoreflect.FieldDescriptor + fd_LegacyParams_weight_breaking_fee_multiplier protoreflect.FieldDescriptor + fd_LegacyParams_weight_breaking_fee_portion protoreflect.FieldDescriptor + fd_LegacyParams_weight_recovery_fee_portion protoreflect.FieldDescriptor + fd_LegacyParams_threshold_weight_difference protoreflect.FieldDescriptor + fd_LegacyParams_allowed_pool_creators protoreflect.FieldDescriptor ) func init() { @@ -26,7 +124,13 @@ func init() { md_LegacyParams = File_elys_amm_params_proto.Messages().ByName("LegacyParams") fd_LegacyParams_pool_creation_fee = md_LegacyParams.Fields().ByName("pool_creation_fee") fd_LegacyParams_slippage_track_duration = md_LegacyParams.Fields().ByName("slippage_track_duration") - fd_LegacyParams_enable_base_currency_paired_pool_only = md_LegacyParams.Fields().ByName("enable_base_currency_paired_pool_only") + fd_LegacyParams_base_assets = md_LegacyParams.Fields().ByName("base_assets") + fd_LegacyParams_weight_breaking_fee_exponent = md_LegacyParams.Fields().ByName("weight_breaking_fee_exponent") + fd_LegacyParams_weight_breaking_fee_multiplier = md_LegacyParams.Fields().ByName("weight_breaking_fee_multiplier") + fd_LegacyParams_weight_breaking_fee_portion = md_LegacyParams.Fields().ByName("weight_breaking_fee_portion") + fd_LegacyParams_weight_recovery_fee_portion = md_LegacyParams.Fields().ByName("weight_recovery_fee_portion") + fd_LegacyParams_threshold_weight_difference = md_LegacyParams.Fields().ByName("threshold_weight_difference") + fd_LegacyParams_allowed_pool_creators = md_LegacyParams.Fields().ByName("allowed_pool_creators") } var _ protoreflect.Message = (*fastReflection_LegacyParams)(nil) @@ -106,9 +210,45 @@ func (x *fastReflection_LegacyParams) Range(f func(protoreflect.FieldDescriptor, return } } - if x.EnableBaseCurrencyPairedPoolOnly != false { - value := protoreflect.ValueOfBool(x.EnableBaseCurrencyPairedPoolOnly) - if !f(fd_LegacyParams_enable_base_currency_paired_pool_only, value) { + if len(x.BaseAssets) != 0 { + value := protoreflect.ValueOfList(&_LegacyParams_3_list{list: &x.BaseAssets}) + if !f(fd_LegacyParams_base_assets, value) { + return + } + } + if x.WeightBreakingFeeExponent != "" { + value := protoreflect.ValueOfString(x.WeightBreakingFeeExponent) + if !f(fd_LegacyParams_weight_breaking_fee_exponent, value) { + return + } + } + if x.WeightBreakingFeeMultiplier != "" { + value := protoreflect.ValueOfString(x.WeightBreakingFeeMultiplier) + if !f(fd_LegacyParams_weight_breaking_fee_multiplier, value) { + return + } + } + if x.WeightBreakingFeePortion != "" { + value := protoreflect.ValueOfString(x.WeightBreakingFeePortion) + if !f(fd_LegacyParams_weight_breaking_fee_portion, value) { + return + } + } + if x.WeightRecoveryFeePortion != "" { + value := protoreflect.ValueOfString(x.WeightRecoveryFeePortion) + if !f(fd_LegacyParams_weight_recovery_fee_portion, value) { + return + } + } + if x.ThresholdWeightDifference != "" { + value := protoreflect.ValueOfString(x.ThresholdWeightDifference) + if !f(fd_LegacyParams_threshold_weight_difference, value) { + return + } + } + if len(x.AllowedPoolCreators) != 0 { + value := protoreflect.ValueOfList(&_LegacyParams_9_list{list: &x.AllowedPoolCreators}) + if !f(fd_LegacyParams_allowed_pool_creators, value) { return } } @@ -131,8 +271,20 @@ func (x *fastReflection_LegacyParams) Has(fd protoreflect.FieldDescriptor) bool return x.PoolCreationFee != "" case "elys.amm.LegacyParams.slippage_track_duration": return x.SlippageTrackDuration != uint64(0) - case "elys.amm.LegacyParams.enable_base_currency_paired_pool_only": - return x.EnableBaseCurrencyPairedPoolOnly != false + case "elys.amm.LegacyParams.base_assets": + return len(x.BaseAssets) != 0 + case "elys.amm.LegacyParams.weight_breaking_fee_exponent": + return x.WeightBreakingFeeExponent != "" + case "elys.amm.LegacyParams.weight_breaking_fee_multiplier": + return x.WeightBreakingFeeMultiplier != "" + case "elys.amm.LegacyParams.weight_breaking_fee_portion": + return x.WeightBreakingFeePortion != "" + case "elys.amm.LegacyParams.weight_recovery_fee_portion": + return x.WeightRecoveryFeePortion != "" + case "elys.amm.LegacyParams.threshold_weight_difference": + return x.ThresholdWeightDifference != "" + case "elys.amm.LegacyParams.allowed_pool_creators": + return len(x.AllowedPoolCreators) != 0 default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: elys.amm.LegacyParams")) @@ -153,8 +305,20 @@ func (x *fastReflection_LegacyParams) Clear(fd protoreflect.FieldDescriptor) { x.PoolCreationFee = "" case "elys.amm.LegacyParams.slippage_track_duration": x.SlippageTrackDuration = uint64(0) - case "elys.amm.LegacyParams.enable_base_currency_paired_pool_only": - x.EnableBaseCurrencyPairedPoolOnly = false + case "elys.amm.LegacyParams.base_assets": + x.BaseAssets = nil + case "elys.amm.LegacyParams.weight_breaking_fee_exponent": + x.WeightBreakingFeeExponent = "" + case "elys.amm.LegacyParams.weight_breaking_fee_multiplier": + x.WeightBreakingFeeMultiplier = "" + case "elys.amm.LegacyParams.weight_breaking_fee_portion": + x.WeightBreakingFeePortion = "" + case "elys.amm.LegacyParams.weight_recovery_fee_portion": + x.WeightRecoveryFeePortion = "" + case "elys.amm.LegacyParams.threshold_weight_difference": + x.ThresholdWeightDifference = "" + case "elys.amm.LegacyParams.allowed_pool_creators": + x.AllowedPoolCreators = nil default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: elys.amm.LegacyParams")) @@ -177,9 +341,33 @@ func (x *fastReflection_LegacyParams) Get(descriptor protoreflect.FieldDescripto case "elys.amm.LegacyParams.slippage_track_duration": value := x.SlippageTrackDuration return protoreflect.ValueOfUint64(value) - case "elys.amm.LegacyParams.enable_base_currency_paired_pool_only": - value := x.EnableBaseCurrencyPairedPoolOnly - return protoreflect.ValueOfBool(value) + case "elys.amm.LegacyParams.base_assets": + if len(x.BaseAssets) == 0 { + return protoreflect.ValueOfList(&_LegacyParams_3_list{}) + } + listValue := &_LegacyParams_3_list{list: &x.BaseAssets} + return protoreflect.ValueOfList(listValue) + case "elys.amm.LegacyParams.weight_breaking_fee_exponent": + value := x.WeightBreakingFeeExponent + return protoreflect.ValueOfString(value) + case "elys.amm.LegacyParams.weight_breaking_fee_multiplier": + value := x.WeightBreakingFeeMultiplier + return protoreflect.ValueOfString(value) + case "elys.amm.LegacyParams.weight_breaking_fee_portion": + value := x.WeightBreakingFeePortion + return protoreflect.ValueOfString(value) + case "elys.amm.LegacyParams.weight_recovery_fee_portion": + value := x.WeightRecoveryFeePortion + return protoreflect.ValueOfString(value) + case "elys.amm.LegacyParams.threshold_weight_difference": + value := x.ThresholdWeightDifference + return protoreflect.ValueOfString(value) + case "elys.amm.LegacyParams.allowed_pool_creators": + if len(x.AllowedPoolCreators) == 0 { + return protoreflect.ValueOfList(&_LegacyParams_9_list{}) + } + listValue := &_LegacyParams_9_list{list: &x.AllowedPoolCreators} + return protoreflect.ValueOfList(listValue) default: if descriptor.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: elys.amm.LegacyParams")) @@ -204,8 +392,24 @@ func (x *fastReflection_LegacyParams) Set(fd protoreflect.FieldDescriptor, value x.PoolCreationFee = value.Interface().(string) case "elys.amm.LegacyParams.slippage_track_duration": x.SlippageTrackDuration = value.Uint() - case "elys.amm.LegacyParams.enable_base_currency_paired_pool_only": - x.EnableBaseCurrencyPairedPoolOnly = value.Bool() + case "elys.amm.LegacyParams.base_assets": + lv := value.List() + clv := lv.(*_LegacyParams_3_list) + x.BaseAssets = *clv.list + case "elys.amm.LegacyParams.weight_breaking_fee_exponent": + x.WeightBreakingFeeExponent = value.Interface().(string) + case "elys.amm.LegacyParams.weight_breaking_fee_multiplier": + x.WeightBreakingFeeMultiplier = value.Interface().(string) + case "elys.amm.LegacyParams.weight_breaking_fee_portion": + x.WeightBreakingFeePortion = value.Interface().(string) + case "elys.amm.LegacyParams.weight_recovery_fee_portion": + x.WeightRecoveryFeePortion = value.Interface().(string) + case "elys.amm.LegacyParams.threshold_weight_difference": + x.ThresholdWeightDifference = value.Interface().(string) + case "elys.amm.LegacyParams.allowed_pool_creators": + lv := value.List() + clv := lv.(*_LegacyParams_9_list) + x.AllowedPoolCreators = *clv.list default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: elys.amm.LegacyParams")) @@ -226,12 +430,32 @@ func (x *fastReflection_LegacyParams) Set(fd protoreflect.FieldDescriptor, value // Mutable is a mutating operation and unsafe for concurrent use. func (x *fastReflection_LegacyParams) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { + case "elys.amm.LegacyParams.base_assets": + if x.BaseAssets == nil { + x.BaseAssets = []string{} + } + value := &_LegacyParams_3_list{list: &x.BaseAssets} + return protoreflect.ValueOfList(value) + case "elys.amm.LegacyParams.allowed_pool_creators": + if x.AllowedPoolCreators == nil { + x.AllowedPoolCreators = []string{} + } + value := &_LegacyParams_9_list{list: &x.AllowedPoolCreators} + return protoreflect.ValueOfList(value) case "elys.amm.LegacyParams.pool_creation_fee": panic(fmt.Errorf("field pool_creation_fee of message elys.amm.LegacyParams is not mutable")) case "elys.amm.LegacyParams.slippage_track_duration": panic(fmt.Errorf("field slippage_track_duration of message elys.amm.LegacyParams is not mutable")) - case "elys.amm.LegacyParams.enable_base_currency_paired_pool_only": - panic(fmt.Errorf("field enable_base_currency_paired_pool_only of message elys.amm.LegacyParams is not mutable")) + case "elys.amm.LegacyParams.weight_breaking_fee_exponent": + panic(fmt.Errorf("field weight_breaking_fee_exponent of message elys.amm.LegacyParams is not mutable")) + case "elys.amm.LegacyParams.weight_breaking_fee_multiplier": + panic(fmt.Errorf("field weight_breaking_fee_multiplier of message elys.amm.LegacyParams is not mutable")) + case "elys.amm.LegacyParams.weight_breaking_fee_portion": + panic(fmt.Errorf("field weight_breaking_fee_portion of message elys.amm.LegacyParams is not mutable")) + case "elys.amm.LegacyParams.weight_recovery_fee_portion": + panic(fmt.Errorf("field weight_recovery_fee_portion of message elys.amm.LegacyParams is not mutable")) + case "elys.amm.LegacyParams.threshold_weight_difference": + panic(fmt.Errorf("field threshold_weight_difference of message elys.amm.LegacyParams is not mutable")) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: elys.amm.LegacyParams")) @@ -249,8 +473,22 @@ func (x *fastReflection_LegacyParams) NewField(fd protoreflect.FieldDescriptor) return protoreflect.ValueOfString("") case "elys.amm.LegacyParams.slippage_track_duration": return protoreflect.ValueOfUint64(uint64(0)) - case "elys.amm.LegacyParams.enable_base_currency_paired_pool_only": - return protoreflect.ValueOfBool(false) + case "elys.amm.LegacyParams.base_assets": + list := []string{} + return protoreflect.ValueOfList(&_LegacyParams_3_list{list: &list}) + case "elys.amm.LegacyParams.weight_breaking_fee_exponent": + return protoreflect.ValueOfString("") + case "elys.amm.LegacyParams.weight_breaking_fee_multiplier": + return protoreflect.ValueOfString("") + case "elys.amm.LegacyParams.weight_breaking_fee_portion": + return protoreflect.ValueOfString("") + case "elys.amm.LegacyParams.weight_recovery_fee_portion": + return protoreflect.ValueOfString("") + case "elys.amm.LegacyParams.threshold_weight_difference": + return protoreflect.ValueOfString("") + case "elys.amm.LegacyParams.allowed_pool_creators": + list := []string{} + return protoreflect.ValueOfList(&_LegacyParams_9_list{list: &list}) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: elys.amm.LegacyParams")) @@ -327,8 +565,37 @@ func (x *fastReflection_LegacyParams) ProtoMethods() *protoiface.Methods { if x.SlippageTrackDuration != 0 { n += 1 + runtime.Sov(uint64(x.SlippageTrackDuration)) } - if x.EnableBaseCurrencyPairedPoolOnly { - n += 2 + if len(x.BaseAssets) > 0 { + for _, s := range x.BaseAssets { + l = len(s) + n += 1 + l + runtime.Sov(uint64(l)) + } + } + l = len(x.WeightBreakingFeeExponent) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + l = len(x.WeightBreakingFeeMultiplier) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + l = len(x.WeightBreakingFeePortion) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + l = len(x.WeightRecoveryFeePortion) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + l = len(x.ThresholdWeightDifference) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + if len(x.AllowedPoolCreators) > 0 { + for _, s := range x.AllowedPoolCreators { + l = len(s) + n += 1 + l + runtime.Sov(uint64(l)) + } } if x.unknownFields != nil { n += len(x.unknownFields) @@ -359,15 +626,58 @@ func (x *fastReflection_LegacyParams) ProtoMethods() *protoiface.Methods { i -= len(x.unknownFields) copy(dAtA[i:], x.unknownFields) } - if x.EnableBaseCurrencyPairedPoolOnly { - i-- - if x.EnableBaseCurrencyPairedPoolOnly { - dAtA[i] = 1 - } else { - dAtA[i] = 0 + if len(x.AllowedPoolCreators) > 0 { + for iNdEx := len(x.AllowedPoolCreators) - 1; iNdEx >= 0; iNdEx-- { + i -= len(x.AllowedPoolCreators[iNdEx]) + copy(dAtA[i:], x.AllowedPoolCreators[iNdEx]) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.AllowedPoolCreators[iNdEx]))) + i-- + dAtA[i] = 0x4a } + } + if len(x.ThresholdWeightDifference) > 0 { + i -= len(x.ThresholdWeightDifference) + copy(dAtA[i:], x.ThresholdWeightDifference) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.ThresholdWeightDifference))) + i-- + dAtA[i] = 0x42 + } + if len(x.WeightRecoveryFeePortion) > 0 { + i -= len(x.WeightRecoveryFeePortion) + copy(dAtA[i:], x.WeightRecoveryFeePortion) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.WeightRecoveryFeePortion))) + i-- + dAtA[i] = 0x3a + } + if len(x.WeightBreakingFeePortion) > 0 { + i -= len(x.WeightBreakingFeePortion) + copy(dAtA[i:], x.WeightBreakingFeePortion) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.WeightBreakingFeePortion))) + i-- + dAtA[i] = 0x32 + } + if len(x.WeightBreakingFeeMultiplier) > 0 { + i -= len(x.WeightBreakingFeeMultiplier) + copy(dAtA[i:], x.WeightBreakingFeeMultiplier) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.WeightBreakingFeeMultiplier))) + i-- + dAtA[i] = 0x2a + } + if len(x.WeightBreakingFeeExponent) > 0 { + i -= len(x.WeightBreakingFeeExponent) + copy(dAtA[i:], x.WeightBreakingFeeExponent) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.WeightBreakingFeeExponent))) i-- - dAtA[i] = 0x18 + dAtA[i] = 0x22 + } + if len(x.BaseAssets) > 0 { + for iNdEx := len(x.BaseAssets) - 1; iNdEx >= 0; iNdEx-- { + i -= len(x.BaseAssets[iNdEx]) + copy(dAtA[i:], x.BaseAssets[iNdEx]) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.BaseAssets[iNdEx]))) + i-- + dAtA[i] = 0x1a + } } if x.SlippageTrackDuration != 0 { i = runtime.EncodeVarint(dAtA, i, uint64(x.SlippageTrackDuration)) @@ -411,28 +721,175 @@ func (x *fastReflection_LegacyParams) ProtoMethods() *protoiface.Methods { if shift >= 64 { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow } - if iNdEx >= l { + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, 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 protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: LegacyParams: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: LegacyParams: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field PoolCreationFee", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.PoolCreationFee = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field SlippageTrackDuration", wireType) + } + x.SlippageTrackDuration = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + x.SlippageTrackDuration |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field BaseAssets", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.BaseAssets = append(x.BaseAssets, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 4: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field WeightBreakingFeeExponent", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break + x.WeightBreakingFeeExponent = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field WeightBreakingFeeMultiplier", wireType) } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: LegacyParams: wiretype end group for non-group") - } - if fieldNum <= 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: LegacyParams: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.WeightBreakingFeeMultiplier = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: if wireType != 2 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field PoolCreationFee", wireType) + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field WeightBreakingFeePortion", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -460,13 +917,13 @@ func (x *fastReflection_LegacyParams) ProtoMethods() *protoiface.Methods { if postIndex > l { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF } - x.PoolCreationFee = string(dAtA[iNdEx:postIndex]) + x.WeightBreakingFeePortion = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 2: - if wireType != 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field SlippageTrackDuration", wireType) + case 7: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field WeightRecoveryFeePortion", wireType) } - x.SlippageTrackDuration = 0 + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow @@ -476,16 +933,61 @@ func (x *fastReflection_LegacyParams) ProtoMethods() *protoiface.Methods { } b := dAtA[iNdEx] iNdEx++ - x.SlippageTrackDuration |= uint64(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - case 3: - if wireType != 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field EnableBaseCurrencyPairedPoolOnly", wireType) + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.WeightRecoveryFeePortion = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 8: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field ThresholdWeightDifference", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength } - var v int + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.ThresholdWeightDifference = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 9: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field AllowedPoolCreators", wireType) + } + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow @@ -495,12 +997,24 @@ func (x *fastReflection_LegacyParams) ProtoMethods() *protoiface.Methods { } b := dAtA[iNdEx] iNdEx++ - v |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - x.EnableBaseCurrencyPairedPoolOnly = bool(v != 0) + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.AllowedPoolCreators = append(x.AllowedPoolCreators, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := runtime.Skip(dAtA[iNdEx:]) @@ -629,16 +1143,17 @@ func (x *_Params_9_list) IsValid() bool { } var ( - md_Params protoreflect.MessageDescriptor - fd_Params_pool_creation_fee protoreflect.FieldDescriptor - fd_Params_slippage_track_duration protoreflect.FieldDescriptor - fd_Params_base_assets protoreflect.FieldDescriptor - fd_Params_weight_breaking_fee_exponent protoreflect.FieldDescriptor - fd_Params_weight_breaking_fee_multiplier protoreflect.FieldDescriptor - fd_Params_weight_breaking_fee_portion protoreflect.FieldDescriptor - fd_Params_weight_recovery_fee_portion protoreflect.FieldDescriptor - fd_Params_threshold_weight_difference protoreflect.FieldDescriptor - fd_Params_allowed_pool_creators protoreflect.FieldDescriptor + md_Params protoreflect.MessageDescriptor + fd_Params_pool_creation_fee protoreflect.FieldDescriptor + fd_Params_slippage_track_duration protoreflect.FieldDescriptor + fd_Params_base_assets protoreflect.FieldDescriptor + fd_Params_weight_breaking_fee_exponent protoreflect.FieldDescriptor + fd_Params_weight_breaking_fee_multiplier protoreflect.FieldDescriptor + fd_Params_weight_breaking_fee_portion protoreflect.FieldDescriptor + fd_Params_weight_recovery_fee_portion protoreflect.FieldDescriptor + fd_Params_threshold_weight_difference protoreflect.FieldDescriptor + fd_Params_allowed_pool_creators protoreflect.FieldDescriptor + fd_Params_threshold_weight_difference_swap_fee protoreflect.FieldDescriptor ) func init() { @@ -653,6 +1168,7 @@ func init() { fd_Params_weight_recovery_fee_portion = md_Params.Fields().ByName("weight_recovery_fee_portion") fd_Params_threshold_weight_difference = md_Params.Fields().ByName("threshold_weight_difference") fd_Params_allowed_pool_creators = md_Params.Fields().ByName("allowed_pool_creators") + fd_Params_threshold_weight_difference_swap_fee = md_Params.Fields().ByName("threshold_weight_difference_swap_fee") } var _ protoreflect.Message = (*fastReflection_Params)(nil) @@ -774,6 +1290,12 @@ func (x *fastReflection_Params) Range(f func(protoreflect.FieldDescriptor, proto return } } + if x.ThresholdWeightDifferenceSwapFee != "" { + value := protoreflect.ValueOfString(x.ThresholdWeightDifferenceSwapFee) + if !f(fd_Params_threshold_weight_difference_swap_fee, value) { + return + } + } } // Has reports whether a field is populated. @@ -807,6 +1329,8 @@ func (x *fastReflection_Params) Has(fd protoreflect.FieldDescriptor) bool { return x.ThresholdWeightDifference != "" case "elys.amm.Params.allowed_pool_creators": return len(x.AllowedPoolCreators) != 0 + case "elys.amm.Params.threshold_weight_difference_swap_fee": + return x.ThresholdWeightDifferenceSwapFee != "" default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: elys.amm.Params")) @@ -841,6 +1365,8 @@ func (x *fastReflection_Params) Clear(fd protoreflect.FieldDescriptor) { x.ThresholdWeightDifference = "" case "elys.amm.Params.allowed_pool_creators": x.AllowedPoolCreators = nil + case "elys.amm.Params.threshold_weight_difference_swap_fee": + x.ThresholdWeightDifferenceSwapFee = "" default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: elys.amm.Params")) @@ -890,6 +1416,9 @@ func (x *fastReflection_Params) Get(descriptor protoreflect.FieldDescriptor) pro } listValue := &_Params_9_list{list: &x.AllowedPoolCreators} return protoreflect.ValueOfList(listValue) + case "elys.amm.Params.threshold_weight_difference_swap_fee": + value := x.ThresholdWeightDifferenceSwapFee + return protoreflect.ValueOfString(value) default: if descriptor.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: elys.amm.Params")) @@ -932,6 +1461,8 @@ func (x *fastReflection_Params) Set(fd protoreflect.FieldDescriptor, value proto lv := value.List() clv := lv.(*_Params_9_list) x.AllowedPoolCreators = *clv.list + case "elys.amm.Params.threshold_weight_difference_swap_fee": + x.ThresholdWeightDifferenceSwapFee = value.Interface().(string) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: elys.amm.Params")) @@ -978,6 +1509,8 @@ func (x *fastReflection_Params) Mutable(fd protoreflect.FieldDescriptor) protore panic(fmt.Errorf("field weight_recovery_fee_portion of message elys.amm.Params is not mutable")) case "elys.amm.Params.threshold_weight_difference": panic(fmt.Errorf("field threshold_weight_difference of message elys.amm.Params is not mutable")) + case "elys.amm.Params.threshold_weight_difference_swap_fee": + panic(fmt.Errorf("field threshold_weight_difference_swap_fee of message elys.amm.Params is not mutable")) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: elys.amm.Params")) @@ -1011,6 +1544,8 @@ func (x *fastReflection_Params) NewField(fd protoreflect.FieldDescriptor) protor case "elys.amm.Params.allowed_pool_creators": list := []string{} return protoreflect.ValueOfList(&_Params_9_list{list: &list}) + case "elys.amm.Params.threshold_weight_difference_swap_fee": + return protoreflect.ValueOfString("") default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: elys.amm.Params")) @@ -1119,6 +1654,10 @@ func (x *fastReflection_Params) ProtoMethods() *protoiface.Methods { n += 1 + l + runtime.Sov(uint64(l)) } } + l = len(x.ThresholdWeightDifferenceSwapFee) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } if x.unknownFields != nil { n += len(x.unknownFields) } @@ -1148,6 +1687,13 @@ func (x *fastReflection_Params) ProtoMethods() *protoiface.Methods { i -= len(x.unknownFields) copy(dAtA[i:], x.unknownFields) } + if len(x.ThresholdWeightDifferenceSwapFee) > 0 { + i -= len(x.ThresholdWeightDifferenceSwapFee) + copy(dAtA[i:], x.ThresholdWeightDifferenceSwapFee) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.ThresholdWeightDifferenceSwapFee))) + i-- + dAtA[i] = 0x52 + } if len(x.AllowedPoolCreators) > 0 { for iNdEx := len(x.AllowedPoolCreators) - 1; iNdEx >= 0; iNdEx-- { i -= len(x.AllowedPoolCreators[iNdEx]) @@ -1537,6 +2083,38 @@ func (x *fastReflection_Params) ProtoMethods() *protoiface.Methods { } x.AllowedPoolCreators = append(x.AllowedPoolCreators, string(dAtA[iNdEx:postIndex])) iNdEx = postIndex + case 10: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field ThresholdWeightDifferenceSwapFee", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.ThresholdWeightDifferenceSwapFee = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := runtime.Skip(dAtA[iNdEx:]) @@ -1591,9 +2169,15 @@ type LegacyParams struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - PoolCreationFee string `protobuf:"bytes,1,opt,name=pool_creation_fee,json=poolCreationFee,proto3" json:"pool_creation_fee,omitempty"` - SlippageTrackDuration uint64 `protobuf:"varint,2,opt,name=slippage_track_duration,json=slippageTrackDuration,proto3" json:"slippage_track_duration,omitempty"` // default 1 week: 604,800 - EnableBaseCurrencyPairedPoolOnly bool `protobuf:"varint,3,opt,name=enable_base_currency_paired_pool_only,json=enableBaseCurrencyPairedPoolOnly,proto3" json:"enable_base_currency_paired_pool_only,omitempty"` + PoolCreationFee string `protobuf:"bytes,1,opt,name=pool_creation_fee,json=poolCreationFee,proto3" json:"pool_creation_fee,omitempty"` + SlippageTrackDuration uint64 `protobuf:"varint,2,opt,name=slippage_track_duration,json=slippageTrackDuration,proto3" json:"slippage_track_duration,omitempty"` // default 1 week: 604,800 + BaseAssets []string `protobuf:"bytes,3,rep,name=base_assets,json=baseAssets,proto3" json:"base_assets,omitempty"` + WeightBreakingFeeExponent string `protobuf:"bytes,4,opt,name=weight_breaking_fee_exponent,json=weightBreakingFeeExponent,proto3" json:"weight_breaking_fee_exponent,omitempty"` + WeightBreakingFeeMultiplier string `protobuf:"bytes,5,opt,name=weight_breaking_fee_multiplier,json=weightBreakingFeeMultiplier,proto3" json:"weight_breaking_fee_multiplier,omitempty"` + WeightBreakingFeePortion string `protobuf:"bytes,6,opt,name=weight_breaking_fee_portion,json=weightBreakingFeePortion,proto3" json:"weight_breaking_fee_portion,omitempty"` + WeightRecoveryFeePortion string `protobuf:"bytes,7,opt,name=weight_recovery_fee_portion,json=weightRecoveryFeePortion,proto3" json:"weight_recovery_fee_portion,omitempty"` + ThresholdWeightDifference string `protobuf:"bytes,8,opt,name=threshold_weight_difference,json=thresholdWeightDifference,proto3" json:"threshold_weight_difference,omitempty"` + AllowedPoolCreators []string `protobuf:"bytes,9,rep,name=allowed_pool_creators,json=allowedPoolCreators,proto3" json:"allowed_pool_creators,omitempty"` } func (x *LegacyParams) Reset() { @@ -1630,11 +2214,53 @@ func (x *LegacyParams) GetSlippageTrackDuration() uint64 { return 0 } -func (x *LegacyParams) GetEnableBaseCurrencyPairedPoolOnly() bool { +func (x *LegacyParams) GetBaseAssets() []string { + if x != nil { + return x.BaseAssets + } + return nil +} + +func (x *LegacyParams) GetWeightBreakingFeeExponent() string { + if x != nil { + return x.WeightBreakingFeeExponent + } + return "" +} + +func (x *LegacyParams) GetWeightBreakingFeeMultiplier() string { + if x != nil { + return x.WeightBreakingFeeMultiplier + } + return "" +} + +func (x *LegacyParams) GetWeightBreakingFeePortion() string { + if x != nil { + return x.WeightBreakingFeePortion + } + return "" +} + +func (x *LegacyParams) GetWeightRecoveryFeePortion() string { if x != nil { - return x.EnableBaseCurrencyPairedPoolOnly + return x.WeightRecoveryFeePortion + } + return "" +} + +func (x *LegacyParams) GetThresholdWeightDifference() string { + if x != nil { + return x.ThresholdWeightDifference + } + return "" +} + +func (x *LegacyParams) GetAllowedPoolCreators() []string { + if x != nil { + return x.AllowedPoolCreators } - return false + return nil } type Params struct { @@ -1642,15 +2268,16 @@ type Params struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - PoolCreationFee string `protobuf:"bytes,1,opt,name=pool_creation_fee,json=poolCreationFee,proto3" json:"pool_creation_fee,omitempty"` - SlippageTrackDuration uint64 `protobuf:"varint,2,opt,name=slippage_track_duration,json=slippageTrackDuration,proto3" json:"slippage_track_duration,omitempty"` // default 1 week: 604,800 - BaseAssets []string `protobuf:"bytes,3,rep,name=base_assets,json=baseAssets,proto3" json:"base_assets,omitempty"` - WeightBreakingFeeExponent string `protobuf:"bytes,4,opt,name=weight_breaking_fee_exponent,json=weightBreakingFeeExponent,proto3" json:"weight_breaking_fee_exponent,omitempty"` - WeightBreakingFeeMultiplier string `protobuf:"bytes,5,opt,name=weight_breaking_fee_multiplier,json=weightBreakingFeeMultiplier,proto3" json:"weight_breaking_fee_multiplier,omitempty"` - WeightBreakingFeePortion string `protobuf:"bytes,6,opt,name=weight_breaking_fee_portion,json=weightBreakingFeePortion,proto3" json:"weight_breaking_fee_portion,omitempty"` - WeightRecoveryFeePortion string `protobuf:"bytes,7,opt,name=weight_recovery_fee_portion,json=weightRecoveryFeePortion,proto3" json:"weight_recovery_fee_portion,omitempty"` - ThresholdWeightDifference string `protobuf:"bytes,8,opt,name=threshold_weight_difference,json=thresholdWeightDifference,proto3" json:"threshold_weight_difference,omitempty"` - AllowedPoolCreators []string `protobuf:"bytes,9,rep,name=allowed_pool_creators,json=allowedPoolCreators,proto3" json:"allowed_pool_creators,omitempty"` + PoolCreationFee string `protobuf:"bytes,1,opt,name=pool_creation_fee,json=poolCreationFee,proto3" json:"pool_creation_fee,omitempty"` + SlippageTrackDuration uint64 `protobuf:"varint,2,opt,name=slippage_track_duration,json=slippageTrackDuration,proto3" json:"slippage_track_duration,omitempty"` // default 1 week: 604,800 + BaseAssets []string `protobuf:"bytes,3,rep,name=base_assets,json=baseAssets,proto3" json:"base_assets,omitempty"` + WeightBreakingFeeExponent string `protobuf:"bytes,4,opt,name=weight_breaking_fee_exponent,json=weightBreakingFeeExponent,proto3" json:"weight_breaking_fee_exponent,omitempty"` + WeightBreakingFeeMultiplier string `protobuf:"bytes,5,opt,name=weight_breaking_fee_multiplier,json=weightBreakingFeeMultiplier,proto3" json:"weight_breaking_fee_multiplier,omitempty"` + WeightBreakingFeePortion string `protobuf:"bytes,6,opt,name=weight_breaking_fee_portion,json=weightBreakingFeePortion,proto3" json:"weight_breaking_fee_portion,omitempty"` + WeightRecoveryFeePortion string `protobuf:"bytes,7,opt,name=weight_recovery_fee_portion,json=weightRecoveryFeePortion,proto3" json:"weight_recovery_fee_portion,omitempty"` + ThresholdWeightDifference string `protobuf:"bytes,8,opt,name=threshold_weight_difference,json=thresholdWeightDifference,proto3" json:"threshold_weight_difference,omitempty"` + AllowedPoolCreators []string `protobuf:"bytes,9,rep,name=allowed_pool_creators,json=allowedPoolCreators,proto3" json:"allowed_pool_creators,omitempty"` + ThresholdWeightDifferenceSwapFee string `protobuf:"bytes,10,opt,name=threshold_weight_difference_swap_fee,json=thresholdWeightDifferenceSwapFee,proto3" json:"threshold_weight_difference_swap_fee,omitempty"` } func (x *Params) Reset() { @@ -1736,6 +2363,13 @@ func (x *Params) GetAllowedPoolCreators() []string { return nil } +func (x *Params) GetThresholdWeightDifferenceSwapFee() string { + if x != nil { + return x.ThresholdWeightDifferenceSwapFee + } + return "" +} + var File_elys_amm_params_proto protoreflect.FileDescriptor var file_elys_amm_params_proto_rawDesc = []byte{ @@ -1744,7 +2378,7 @@ var file_elys_amm_params_proto_rawDesc = []byte{ 0x6d, 0x1a, 0x14, 0x67, 0x6f, 0x67, 0x6f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x67, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x19, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x22, 0xf0, 0x01, 0x0a, 0x0c, 0x4c, 0x65, 0x67, 0x61, 0x63, 0x79, 0x50, 0x61, 0x72, + 0x74, 0x6f, 0x22, 0xb7, 0x06, 0x0a, 0x0c, 0x4c, 0x65, 0x67, 0x61, 0x63, 0x79, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x57, 0x0a, 0x11, 0x70, 0x6f, 0x6f, 0x6c, 0x5f, 0x63, 0x72, 0x65, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x66, 0x65, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x2b, 0xc8, 0xde, 0x1f, 0x00, 0xda, 0xde, 0x1f, 0x15, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, @@ -1754,72 +2388,117 @@ var file_elys_amm_params_proto_rawDesc = []byte{ 0x73, 0x6c, 0x69, 0x70, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x72, 0x61, 0x63, 0x6b, 0x5f, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x15, 0x73, 0x6c, 0x69, 0x70, 0x70, 0x61, 0x67, 0x65, 0x54, 0x72, 0x61, 0x63, 0x6b, 0x44, 0x75, 0x72, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x4f, 0x0a, 0x25, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x62, - 0x61, 0x73, 0x65, 0x5f, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x5f, 0x70, 0x61, 0x69, - 0x72, 0x65, 0x64, 0x5f, 0x70, 0x6f, 0x6f, 0x6c, 0x5f, 0x6f, 0x6e, 0x6c, 0x79, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x08, 0x52, 0x20, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x42, 0x61, 0x73, 0x65, 0x43, - 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x50, 0x61, 0x69, 0x72, 0x65, 0x64, 0x50, 0x6f, 0x6f, - 0x6c, 0x4f, 0x6e, 0x6c, 0x79, 0x22, 0xb1, 0x06, 0x0a, 0x06, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, - 0x12, 0x57, 0x0a, 0x11, 0x70, 0x6f, 0x6f, 0x6c, 0x5f, 0x63, 0x72, 0x65, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x5f, 0x66, 0x65, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x2b, 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, 0x52, 0x0f, 0x70, 0x6f, 0x6f, 0x6c, 0x43, 0x72, - 0x65, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x46, 0x65, 0x65, 0x12, 0x36, 0x0a, 0x17, 0x73, 0x6c, 0x69, - 0x70, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x72, 0x61, 0x63, 0x6b, 0x5f, 0x64, 0x75, 0x72, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x15, 0x73, 0x6c, 0x69, 0x70, - 0x70, 0x61, 0x67, 0x65, 0x54, 0x72, 0x61, 0x63, 0x6b, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x12, 0x1f, 0x0a, 0x0b, 0x62, 0x61, 0x73, 0x65, 0x5f, 0x61, 0x73, 0x73, 0x65, 0x74, 0x73, - 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0a, 0x62, 0x61, 0x73, 0x65, 0x41, 0x73, 0x73, 0x65, - 0x74, 0x73, 0x12, 0x72, 0x0a, 0x1c, 0x77, 0x65, 0x69, 0x67, 0x68, 0x74, 0x5f, 0x62, 0x72, 0x65, - 0x61, 0x6b, 0x69, 0x6e, 0x67, 0x5f, 0x66, 0x65, 0x65, 0x5f, 0x65, 0x78, 0x70, 0x6f, 0x6e, 0x65, - 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x42, 0x31, 0xc8, 0xde, 0x1f, 0x00, 0xda, 0xde, + 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1f, 0x0a, 0x0b, 0x62, 0x61, 0x73, 0x65, 0x5f, 0x61, 0x73, 0x73, + 0x65, 0x74, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0a, 0x62, 0x61, 0x73, 0x65, 0x41, + 0x73, 0x73, 0x65, 0x74, 0x73, 0x12, 0x72, 0x0a, 0x1c, 0x77, 0x65, 0x69, 0x67, 0x68, 0x74, 0x5f, + 0x62, 0x72, 0x65, 0x61, 0x6b, 0x69, 0x6e, 0x67, 0x5f, 0x66, 0x65, 0x65, 0x5f, 0x65, 0x78, 0x70, + 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x42, 0x31, 0xc8, 0xde, 0x1f, + 0x00, 0xda, 0xde, 0x1f, 0x1b, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, + 0x6f, 0x2f, 0x6d, 0x61, 0x74, 0x68, 0x2e, 0x4c, 0x65, 0x67, 0x61, 0x63, 0x79, 0x44, 0x65, 0x63, + 0xd2, 0xb4, 0x2d, 0x0a, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x44, 0x65, 0x63, 0x52, 0x19, + 0x77, 0x65, 0x69, 0x67, 0x68, 0x74, 0x42, 0x72, 0x65, 0x61, 0x6b, 0x69, 0x6e, 0x67, 0x46, 0x65, + 0x65, 0x45, 0x78, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x12, 0x76, 0x0a, 0x1e, 0x77, 0x65, 0x69, + 0x67, 0x68, 0x74, 0x5f, 0x62, 0x72, 0x65, 0x61, 0x6b, 0x69, 0x6e, 0x67, 0x5f, 0x66, 0x65, 0x65, + 0x5f, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x18, 0x05, 0x20, 0x01, 0x28, + 0x09, 0x42, 0x31, 0xc8, 0xde, 0x1f, 0x00, 0xda, 0xde, 0x1f, 0x1b, 0x63, 0x6f, 0x73, 0x6d, 0x6f, + 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x6d, 0x61, 0x74, 0x68, 0x2e, 0x4c, 0x65, 0x67, + 0x61, 0x63, 0x79, 0x44, 0x65, 0x63, 0xd2, 0xb4, 0x2d, 0x0a, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, + 0x2e, 0x44, 0x65, 0x63, 0x52, 0x1b, 0x77, 0x65, 0x69, 0x67, 0x68, 0x74, 0x42, 0x72, 0x65, 0x61, + 0x6b, 0x69, 0x6e, 0x67, 0x46, 0x65, 0x65, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x69, 0x65, + 0x72, 0x12, 0x70, 0x0a, 0x1b, 0x77, 0x65, 0x69, 0x67, 0x68, 0x74, 0x5f, 0x62, 0x72, 0x65, 0x61, + 0x6b, 0x69, 0x6e, 0x67, 0x5f, 0x66, 0x65, 0x65, 0x5f, 0x70, 0x6f, 0x72, 0x74, 0x69, 0x6f, 0x6e, + 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x42, 0x31, 0xc8, 0xde, 0x1f, 0x00, 0xda, 0xde, 0x1f, 0x1b, + 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x6d, 0x61, 0x74, + 0x68, 0x2e, 0x4c, 0x65, 0x67, 0x61, 0x63, 0x79, 0x44, 0x65, 0x63, 0xd2, 0xb4, 0x2d, 0x0a, 0x63, + 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x44, 0x65, 0x63, 0x52, 0x18, 0x77, 0x65, 0x69, 0x67, 0x68, + 0x74, 0x42, 0x72, 0x65, 0x61, 0x6b, 0x69, 0x6e, 0x67, 0x46, 0x65, 0x65, 0x50, 0x6f, 0x72, 0x74, + 0x69, 0x6f, 0x6e, 0x12, 0x70, 0x0a, 0x1b, 0x77, 0x65, 0x69, 0x67, 0x68, 0x74, 0x5f, 0x72, 0x65, + 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x5f, 0x66, 0x65, 0x65, 0x5f, 0x70, 0x6f, 0x72, 0x74, 0x69, + 0x6f, 0x6e, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x42, 0x31, 0xc8, 0xde, 0x1f, 0x00, 0xda, 0xde, 0x1f, 0x1b, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x6d, 0x61, 0x74, 0x68, 0x2e, 0x4c, 0x65, 0x67, 0x61, 0x63, 0x79, 0x44, 0x65, 0x63, 0xd2, 0xb4, 0x2d, - 0x0a, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x44, 0x65, 0x63, 0x52, 0x19, 0x77, 0x65, 0x69, - 0x67, 0x68, 0x74, 0x42, 0x72, 0x65, 0x61, 0x6b, 0x69, 0x6e, 0x67, 0x46, 0x65, 0x65, 0x45, 0x78, - 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x12, 0x76, 0x0a, 0x1e, 0x77, 0x65, 0x69, 0x67, 0x68, 0x74, - 0x5f, 0x62, 0x72, 0x65, 0x61, 0x6b, 0x69, 0x6e, 0x67, 0x5f, 0x66, 0x65, 0x65, 0x5f, 0x6d, 0x75, - 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x42, 0x31, + 0x0a, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x44, 0x65, 0x63, 0x52, 0x18, 0x77, 0x65, 0x69, + 0x67, 0x68, 0x74, 0x52, 0x65, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x46, 0x65, 0x65, 0x50, 0x6f, + 0x72, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x71, 0x0a, 0x1b, 0x74, 0x68, 0x72, 0x65, 0x73, 0x68, 0x6f, + 0x6c, 0x64, 0x5f, 0x77, 0x65, 0x69, 0x67, 0x68, 0x74, 0x5f, 0x64, 0x69, 0x66, 0x66, 0x65, 0x72, + 0x65, 0x6e, 0x63, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x42, 0x31, 0xc8, 0xde, 0x1f, 0x00, + 0xda, 0xde, 0x1f, 0x1b, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, + 0x2f, 0x6d, 0x61, 0x74, 0x68, 0x2e, 0x4c, 0x65, 0x67, 0x61, 0x63, 0x79, 0x44, 0x65, 0x63, 0xd2, + 0xb4, 0x2d, 0x0a, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x44, 0x65, 0x63, 0x52, 0x19, 0x74, + 0x68, 0x72, 0x65, 0x73, 0x68, 0x6f, 0x6c, 0x64, 0x57, 0x65, 0x69, 0x67, 0x68, 0x74, 0x44, 0x69, + 0x66, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x32, 0x0a, 0x15, 0x61, 0x6c, 0x6c, 0x6f, + 0x77, 0x65, 0x64, 0x5f, 0x70, 0x6f, 0x6f, 0x6c, 0x5f, 0x63, 0x72, 0x65, 0x61, 0x74, 0x6f, 0x72, + 0x73, 0x18, 0x09, 0x20, 0x03, 0x28, 0x09, 0x52, 0x13, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x65, 0x64, + 0x50, 0x6f, 0x6f, 0x6c, 0x43, 0x72, 0x65, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x22, 0xb5, 0x07, 0x0a, + 0x06, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x57, 0x0a, 0x11, 0x70, 0x6f, 0x6f, 0x6c, 0x5f, + 0x63, 0x72, 0x65, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x66, 0x65, 0x65, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x42, 0x2b, 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, 0x52, + 0x0f, 0x70, 0x6f, 0x6f, 0x6c, 0x43, 0x72, 0x65, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x46, 0x65, 0x65, + 0x12, 0x36, 0x0a, 0x17, 0x73, 0x6c, 0x69, 0x70, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x72, 0x61, + 0x63, 0x6b, 0x5f, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x04, 0x52, 0x15, 0x73, 0x6c, 0x69, 0x70, 0x70, 0x61, 0x67, 0x65, 0x54, 0x72, 0x61, 0x63, 0x6b, + 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1f, 0x0a, 0x0b, 0x62, 0x61, 0x73, 0x65, + 0x5f, 0x61, 0x73, 0x73, 0x65, 0x74, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0a, 0x62, + 0x61, 0x73, 0x65, 0x41, 0x73, 0x73, 0x65, 0x74, 0x73, 0x12, 0x72, 0x0a, 0x1c, 0x77, 0x65, 0x69, + 0x67, 0x68, 0x74, 0x5f, 0x62, 0x72, 0x65, 0x61, 0x6b, 0x69, 0x6e, 0x67, 0x5f, 0x66, 0x65, 0x65, + 0x5f, 0x65, 0x78, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x42, + 0x31, 0xc8, 0xde, 0x1f, 0x00, 0xda, 0xde, 0x1f, 0x1b, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, + 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x6d, 0x61, 0x74, 0x68, 0x2e, 0x4c, 0x65, 0x67, 0x61, 0x63, + 0x79, 0x44, 0x65, 0x63, 0xd2, 0xb4, 0x2d, 0x0a, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x44, + 0x65, 0x63, 0x52, 0x19, 0x77, 0x65, 0x69, 0x67, 0x68, 0x74, 0x42, 0x72, 0x65, 0x61, 0x6b, 0x69, + 0x6e, 0x67, 0x46, 0x65, 0x65, 0x45, 0x78, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x12, 0x76, 0x0a, + 0x1e, 0x77, 0x65, 0x69, 0x67, 0x68, 0x74, 0x5f, 0x62, 0x72, 0x65, 0x61, 0x6b, 0x69, 0x6e, 0x67, + 0x5f, 0x66, 0x65, 0x65, 0x5f, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x18, + 0x05, 0x20, 0x01, 0x28, 0x09, 0x42, 0x31, 0xc8, 0xde, 0x1f, 0x00, 0xda, 0xde, 0x1f, 0x1b, 0x63, + 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x6d, 0x61, 0x74, 0x68, + 0x2e, 0x4c, 0x65, 0x67, 0x61, 0x63, 0x79, 0x44, 0x65, 0x63, 0xd2, 0xb4, 0x2d, 0x0a, 0x63, 0x6f, + 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x44, 0x65, 0x63, 0x52, 0x1b, 0x77, 0x65, 0x69, 0x67, 0x68, 0x74, + 0x42, 0x72, 0x65, 0x61, 0x6b, 0x69, 0x6e, 0x67, 0x46, 0x65, 0x65, 0x4d, 0x75, 0x6c, 0x74, 0x69, + 0x70, 0x6c, 0x69, 0x65, 0x72, 0x12, 0x70, 0x0a, 0x1b, 0x77, 0x65, 0x69, 0x67, 0x68, 0x74, 0x5f, + 0x62, 0x72, 0x65, 0x61, 0x6b, 0x69, 0x6e, 0x67, 0x5f, 0x66, 0x65, 0x65, 0x5f, 0x70, 0x6f, 0x72, + 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x42, 0x31, 0xc8, 0xde, 0x1f, 0x00, + 0xda, 0xde, 0x1f, 0x1b, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, + 0x2f, 0x6d, 0x61, 0x74, 0x68, 0x2e, 0x4c, 0x65, 0x67, 0x61, 0x63, 0x79, 0x44, 0x65, 0x63, 0xd2, + 0xb4, 0x2d, 0x0a, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x44, 0x65, 0x63, 0x52, 0x18, 0x77, + 0x65, 0x69, 0x67, 0x68, 0x74, 0x42, 0x72, 0x65, 0x61, 0x6b, 0x69, 0x6e, 0x67, 0x46, 0x65, 0x65, + 0x50, 0x6f, 0x72, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x70, 0x0a, 0x1b, 0x77, 0x65, 0x69, 0x67, 0x68, + 0x74, 0x5f, 0x72, 0x65, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x5f, 0x66, 0x65, 0x65, 0x5f, 0x70, + 0x6f, 0x72, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x42, 0x31, 0xc8, 0xde, + 0x1f, 0x00, 0xda, 0xde, 0x1f, 0x1b, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, + 0x69, 0x6f, 0x2f, 0x6d, 0x61, 0x74, 0x68, 0x2e, 0x4c, 0x65, 0x67, 0x61, 0x63, 0x79, 0x44, 0x65, + 0x63, 0xd2, 0xb4, 0x2d, 0x0a, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x44, 0x65, 0x63, 0x52, + 0x18, 0x77, 0x65, 0x69, 0x67, 0x68, 0x74, 0x52, 0x65, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x46, + 0x65, 0x65, 0x50, 0x6f, 0x72, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x71, 0x0a, 0x1b, 0x74, 0x68, 0x72, + 0x65, 0x73, 0x68, 0x6f, 0x6c, 0x64, 0x5f, 0x77, 0x65, 0x69, 0x67, 0x68, 0x74, 0x5f, 0x64, 0x69, + 0x66, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x42, 0x31, 0xc8, 0xde, 0x1f, 0x00, 0xda, 0xde, 0x1f, 0x1b, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x6d, 0x61, 0x74, 0x68, 0x2e, 0x4c, 0x65, 0x67, 0x61, 0x63, 0x79, 0x44, 0x65, 0x63, 0xd2, 0xb4, 0x2d, 0x0a, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x44, 0x65, - 0x63, 0x52, 0x1b, 0x77, 0x65, 0x69, 0x67, 0x68, 0x74, 0x42, 0x72, 0x65, 0x61, 0x6b, 0x69, 0x6e, - 0x67, 0x46, 0x65, 0x65, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x12, 0x70, - 0x0a, 0x1b, 0x77, 0x65, 0x69, 0x67, 0x68, 0x74, 0x5f, 0x62, 0x72, 0x65, 0x61, 0x6b, 0x69, 0x6e, - 0x67, 0x5f, 0x66, 0x65, 0x65, 0x5f, 0x70, 0x6f, 0x72, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x06, 0x20, - 0x01, 0x28, 0x09, 0x42, 0x31, 0xc8, 0xde, 0x1f, 0x00, 0xda, 0xde, 0x1f, 0x1b, 0x63, 0x6f, 0x73, - 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x6d, 0x61, 0x74, 0x68, 0x2e, 0x4c, - 0x65, 0x67, 0x61, 0x63, 0x79, 0x44, 0x65, 0x63, 0xd2, 0xb4, 0x2d, 0x0a, 0x63, 0x6f, 0x73, 0x6d, - 0x6f, 0x73, 0x2e, 0x44, 0x65, 0x63, 0x52, 0x18, 0x77, 0x65, 0x69, 0x67, 0x68, 0x74, 0x42, 0x72, - 0x65, 0x61, 0x6b, 0x69, 0x6e, 0x67, 0x46, 0x65, 0x65, 0x50, 0x6f, 0x72, 0x74, 0x69, 0x6f, 0x6e, - 0x12, 0x70, 0x0a, 0x1b, 0x77, 0x65, 0x69, 0x67, 0x68, 0x74, 0x5f, 0x72, 0x65, 0x63, 0x6f, 0x76, - 0x65, 0x72, 0x79, 0x5f, 0x66, 0x65, 0x65, 0x5f, 0x70, 0x6f, 0x72, 0x74, 0x69, 0x6f, 0x6e, 0x18, - 0x07, 0x20, 0x01, 0x28, 0x09, 0x42, 0x31, 0xc8, 0xde, 0x1f, 0x00, 0xda, 0xde, 0x1f, 0x1b, 0x63, - 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x6d, 0x61, 0x74, 0x68, - 0x2e, 0x4c, 0x65, 0x67, 0x61, 0x63, 0x79, 0x44, 0x65, 0x63, 0xd2, 0xb4, 0x2d, 0x0a, 0x63, 0x6f, - 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x44, 0x65, 0x63, 0x52, 0x18, 0x77, 0x65, 0x69, 0x67, 0x68, 0x74, - 0x52, 0x65, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x46, 0x65, 0x65, 0x50, 0x6f, 0x72, 0x74, 0x69, - 0x6f, 0x6e, 0x12, 0x71, 0x0a, 0x1b, 0x74, 0x68, 0x72, 0x65, 0x73, 0x68, 0x6f, 0x6c, 0x64, 0x5f, - 0x77, 0x65, 0x69, 0x67, 0x68, 0x74, 0x5f, 0x64, 0x69, 0x66, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, - 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x42, 0x31, 0xc8, 0xde, 0x1f, 0x00, 0xda, 0xde, 0x1f, - 0x1b, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x6d, 0x61, - 0x74, 0x68, 0x2e, 0x4c, 0x65, 0x67, 0x61, 0x63, 0x79, 0x44, 0x65, 0x63, 0xd2, 0xb4, 0x2d, 0x0a, - 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x44, 0x65, 0x63, 0x52, 0x19, 0x74, 0x68, 0x72, 0x65, - 0x73, 0x68, 0x6f, 0x6c, 0x64, 0x57, 0x65, 0x69, 0x67, 0x68, 0x74, 0x44, 0x69, 0x66, 0x66, 0x65, - 0x72, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x32, 0x0a, 0x15, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x65, 0x64, - 0x5f, 0x70, 0x6f, 0x6f, 0x6c, 0x5f, 0x63, 0x72, 0x65, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x18, 0x09, - 0x20, 0x03, 0x28, 0x09, 0x52, 0x13, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x65, 0x64, 0x50, 0x6f, 0x6f, - 0x6c, 0x43, 0x72, 0x65, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x42, 0x87, 0x01, 0x0a, 0x0c, 0x63, 0x6f, - 0x6d, 0x2e, 0x65, 0x6c, 0x79, 0x73, 0x2e, 0x61, 0x6d, 0x6d, 0x42, 0x0b, 0x50, 0x61, 0x72, 0x61, - 0x6d, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x29, 0x67, 0x69, 0x74, 0x68, 0x75, - 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x65, 0x6c, 0x79, 0x73, 0x2d, 0x6e, 0x65, 0x74, 0x77, 0x6f, - 0x72, 0x6b, 0x2f, 0x65, 0x6c, 0x79, 0x73, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x65, 0x6c, 0x79, 0x73, - 0x2f, 0x61, 0x6d, 0x6d, 0xa2, 0x02, 0x03, 0x45, 0x41, 0x58, 0xaa, 0x02, 0x08, 0x45, 0x6c, 0x79, - 0x73, 0x2e, 0x41, 0x6d, 0x6d, 0xca, 0x02, 0x08, 0x45, 0x6c, 0x79, 0x73, 0x5c, 0x41, 0x6d, 0x6d, - 0xe2, 0x02, 0x14, 0x45, 0x6c, 0x79, 0x73, 0x5c, 0x41, 0x6d, 0x6d, 0x5c, 0x47, 0x50, 0x42, 0x4d, - 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x09, 0x45, 0x6c, 0x79, 0x73, 0x3a, 0x3a, - 0x41, 0x6d, 0x6d, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x63, 0x52, 0x19, 0x74, 0x68, 0x72, 0x65, 0x73, 0x68, 0x6f, 0x6c, 0x64, 0x57, 0x65, 0x69, 0x67, + 0x68, 0x74, 0x44, 0x69, 0x66, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x32, 0x0a, 0x15, + 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x65, 0x64, 0x5f, 0x70, 0x6f, 0x6f, 0x6c, 0x5f, 0x63, 0x72, 0x65, + 0x61, 0x74, 0x6f, 0x72, 0x73, 0x18, 0x09, 0x20, 0x03, 0x28, 0x09, 0x52, 0x13, 0x61, 0x6c, 0x6c, + 0x6f, 0x77, 0x65, 0x64, 0x50, 0x6f, 0x6f, 0x6c, 0x43, 0x72, 0x65, 0x61, 0x74, 0x6f, 0x72, 0x73, + 0x12, 0x81, 0x01, 0x0a, 0x24, 0x74, 0x68, 0x72, 0x65, 0x73, 0x68, 0x6f, 0x6c, 0x64, 0x5f, 0x77, + 0x65, 0x69, 0x67, 0x68, 0x74, 0x5f, 0x64, 0x69, 0x66, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, + 0x5f, 0x73, 0x77, 0x61, 0x70, 0x5f, 0x66, 0x65, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x42, + 0x31, 0xc8, 0xde, 0x1f, 0x00, 0xda, 0xde, 0x1f, 0x1b, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, + 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x6d, 0x61, 0x74, 0x68, 0x2e, 0x4c, 0x65, 0x67, 0x61, 0x63, + 0x79, 0x44, 0x65, 0x63, 0xd2, 0xb4, 0x2d, 0x0a, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x44, + 0x65, 0x63, 0x52, 0x20, 0x74, 0x68, 0x72, 0x65, 0x73, 0x68, 0x6f, 0x6c, 0x64, 0x57, 0x65, 0x69, + 0x67, 0x68, 0x74, 0x44, 0x69, 0x66, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x53, 0x77, 0x61, + 0x70, 0x46, 0x65, 0x65, 0x42, 0x87, 0x01, 0x0a, 0x0c, 0x63, 0x6f, 0x6d, 0x2e, 0x65, 0x6c, 0x79, + 0x73, 0x2e, 0x61, 0x6d, 0x6d, 0x42, 0x0b, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x50, 0x72, 0x6f, + 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x29, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, + 0x2f, 0x65, 0x6c, 0x79, 0x73, 0x2d, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2f, 0x65, 0x6c, + 0x79, 0x73, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x65, 0x6c, 0x79, 0x73, 0x2f, 0x61, 0x6d, 0x6d, 0xa2, + 0x02, 0x03, 0x45, 0x41, 0x58, 0xaa, 0x02, 0x08, 0x45, 0x6c, 0x79, 0x73, 0x2e, 0x41, 0x6d, 0x6d, + 0xca, 0x02, 0x08, 0x45, 0x6c, 0x79, 0x73, 0x5c, 0x41, 0x6d, 0x6d, 0xe2, 0x02, 0x14, 0x45, 0x6c, + 0x79, 0x73, 0x5c, 0x41, 0x6d, 0x6d, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, + 0x74, 0x61, 0xea, 0x02, 0x09, 0x45, 0x6c, 0x79, 0x73, 0x3a, 0x3a, 0x41, 0x6d, 0x6d, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/proto/elys/amm/params.proto b/proto/elys/amm/params.proto index 9c6bcceca..eac22081b 100644 --- a/proto/elys/amm/params.proto +++ b/proto/elys/amm/params.proto @@ -14,7 +14,33 @@ message LegacyParams { (gogoproto.nullable) = false ]; uint64 slippage_track_duration = 2; // default 1 week: 604,800 - bool enable_base_currency_paired_pool_only = 3; + repeated string base_assets = 3; + string weight_breaking_fee_exponent = 4 [ + (cosmos_proto.scalar) = "cosmos.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", + (gogoproto.nullable) = false + ]; + string weight_breaking_fee_multiplier = 5 [ + (cosmos_proto.scalar) = "cosmos.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", + (gogoproto.nullable) = false + ]; + string weight_breaking_fee_portion = 6 [ + (cosmos_proto.scalar) = "cosmos.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", + (gogoproto.nullable) = false + ]; + string weight_recovery_fee_portion = 7 [ + (cosmos_proto.scalar) = "cosmos.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", + (gogoproto.nullable) = false + ]; + string threshold_weight_difference = 8 [ + (cosmos_proto.scalar) = "cosmos.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", + (gogoproto.nullable) = false + ]; + repeated string allowed_pool_creators = 9; } message Params { @@ -51,4 +77,9 @@ message Params { (gogoproto.nullable) = false ]; repeated string allowed_pool_creators = 9; + string threshold_weight_difference_swap_fee = 10 [ + (cosmos_proto.scalar) = "cosmos.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", + (gogoproto.nullable) = false + ]; } diff --git a/x/amm/keeper/calc_in_route_spot_price.go b/x/amm/keeper/calc_in_route_spot_price.go index 0d7d1d758..6a70429aa 100644 --- a/x/amm/keeper/calc_in_route_spot_price.go +++ b/x/amm/keeper/calc_in_route_spot_price.go @@ -90,17 +90,17 @@ func (k Keeper) CalcInRouteSpotPrice(ctx sdk.Context, // Apply discount to swap fee swapFee = types.ApplyDiscount(swapFee, discount) - // Calculate the total discounted swap fee - totalDiscountedSwapFee = totalDiscountedSwapFee.Add(swapFee) - // Estimate swap snapshot := k.GetAccountedPoolSnapshotOrSet(ctx, pool) cacheCtx, _ := ctx.CacheContext() - tokenOut, swapSlippage, _, weightBalanceBonus, _, err := k.SwapOutAmtGivenIn(cacheCtx, pool.PoolId, k.oracleKeeper, &snapshot, tokensIn, tokenOutDenom, swapFee, sdkmath.LegacyOneDec()) + tokenOut, swapSlippage, _, weightBalanceBonus, _, swapFee, err := k.SwapOutAmtGivenIn(cacheCtx, pool.PoolId, k.oracleKeeper, &snapshot, tokensIn, tokenOutDenom, swapFee, sdkmath.LegacyOneDec()) if err != nil { return sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdk.Coin{}, sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdk.Coin{}, sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), err } + // Calculate the total discounted swap fee + totalDiscountedSwapFee = totalDiscountedSwapFee.Add(swapFee) + if tokenOut.IsZero() { return sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdk.Coin{}, sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdk.Coin{}, sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), types.ErrAmountTooLow } diff --git a/x/amm/keeper/calc_out_route_spot_price.go b/x/amm/keeper/calc_out_route_spot_price.go index ea05237de..18469d12e 100644 --- a/x/amm/keeper/calc_out_route_spot_price.go +++ b/x/amm/keeper/calc_out_route_spot_price.go @@ -47,17 +47,17 @@ func (k Keeper) CalcOutRouteSpotPrice(ctx sdk.Context, tokenOut sdk.Coin, routes // Apply discount swapFee = types.ApplyDiscount(swapFee, discount) - // Calculate the total discounted swap fee - totalDiscountedSwapFee = totalDiscountedSwapFee.Add(swapFee) - // Estimate swap snapshot := k.GetAccountedPoolSnapshotOrSet(ctx, pool) cacheCtx, _ := ctx.CacheContext() - swapResult, swapSlippage, _, weightBalanceBonus, _, err := k.SwapInAmtGivenOut(cacheCtx, pool.PoolId, k.oracleKeeper, &snapshot, tokensOut, tokenInDenom, swapFee, sdkmath.LegacyOneDec()) + swapResult, swapSlippage, _, weightBalanceBonus, _, swapFee, err := k.SwapInAmtGivenOut(cacheCtx, pool.PoolId, k.oracleKeeper, &snapshot, tokensOut, tokenInDenom, swapFee, sdkmath.LegacyOneDec()) if err != nil { return sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdk.Coin{}, sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdk.Coin{}, sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), err } + // Calculate the total discounted swap fee + totalDiscountedSwapFee = totalDiscountedSwapFee.Add(swapFee) + if swapResult.IsZero() { return sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdk.Coin{}, sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdk.Coin{}, sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), types.ErrAmountTooLow } diff --git a/x/amm/keeper/fee.go b/x/amm/keeper/fee.go index 4f2476c95..6fba7238f 100644 --- a/x/amm/keeper/fee.go +++ b/x/amm/keeper/fee.go @@ -53,7 +53,7 @@ func (k Keeper) SwapFeesToRevenueToken(ctx sdk.Context, pool types.Pool, fee sdk // Executes the swap in the pool and stores the output. Updates pool assets but // does not actually transfer any tokens to or from the pool. snapshot := k.GetAccountedPoolSnapshotOrSet(ctx, pool) - tokenOutCoin, _, _, _, oracleOutAmount, err := pool.SwapOutAmtGivenIn(ctx, k.oracleKeeper, &snapshot, sdk.Coins{tokenIn}, pool.PoolParams.FeeDenom, sdkmath.LegacyZeroDec(), k.accountedPoolKeeper, sdkmath.LegacyOneDec(), params) + tokenOutCoin, _, _, _, oracleOutAmount, _, err := pool.SwapOutAmtGivenIn(ctx, k.oracleKeeper, &snapshot, sdk.Coins{tokenIn}, pool.PoolParams.FeeDenom, sdkmath.LegacyZeroDec(), k.accountedPoolKeeper, sdkmath.LegacyOneDec(), params) if err != nil { return err } diff --git a/x/amm/keeper/keeper_swap_exact_amount_in.go b/x/amm/keeper/keeper_swap_exact_amount_in.go index 1901e40ed..ef217d367 100644 --- a/x/amm/keeper/keeper_swap_exact_amount_in.go +++ b/x/amm/keeper/keeper_swap_exact_amount_in.go @@ -42,7 +42,7 @@ func (k Keeper) InternalSwapExactAmountIn( // Executes the swap in the pool and stores the output. Updates pool assets but // does not actually transfer any tokens to or from the pool. snapshot := k.GetAccountedPoolSnapshotOrSet(ctx, pool) - tokenOutCoin, _, slippageAmount, weightBalanceBonus, oracleOutAmount, err := pool.SwapOutAmtGivenIn(ctx, k.oracleKeeper, &snapshot, tokensIn, tokenOutDenom, swapFee, k.accountedPoolKeeper, math.LegacyOneDec(), params) + tokenOutCoin, _, slippageAmount, weightBalanceBonus, oracleOutAmount, swapFee, err := pool.SwapOutAmtGivenIn(ctx, k.oracleKeeper, &snapshot, tokensIn, tokenOutDenom, swapFee, k.accountedPoolKeeper, math.LegacyOneDec(), params) if err != nil { return math.Int{}, err } diff --git a/x/amm/keeper/keeper_swap_exact_amount_out.go b/x/amm/keeper/keeper_swap_exact_amount_out.go index 9ebcdb015..ecc2daac5 100644 --- a/x/amm/keeper/keeper_swap_exact_amount_out.go +++ b/x/amm/keeper/keeper_swap_exact_amount_out.go @@ -42,7 +42,7 @@ func (k Keeper) InternalSwapExactAmountOut( params := k.GetParams(ctx) snapshot := k.GetAccountedPoolSnapshotOrSet(ctx, pool) - tokenIn, _, slippageAmount, weightBalanceBonus, oracleInAmount, err := pool.SwapInAmtGivenOut(ctx, k.oracleKeeper, &snapshot, sdk.Coins{tokenOut}, tokenInDenom, swapFee, k.accountedPoolKeeper, math.LegacyOneDec(), params) + tokenIn, _, slippageAmount, weightBalanceBonus, oracleInAmount, swapFee, err := pool.SwapInAmtGivenOut(ctx, k.oracleKeeper, &snapshot, sdk.Coins{tokenOut}, tokenInDenom, swapFee, k.accountedPoolKeeper, math.LegacyOneDec(), params) if err != nil { return math.Int{}, err } diff --git a/x/amm/keeper/params.go b/x/amm/keeper/params.go index f0f5bce0f..21e75d00b 100644 --- a/x/amm/keeper/params.go +++ b/x/amm/keeper/params.go @@ -52,6 +52,18 @@ func (k Keeper) CheckBaseAssetExist(ctx sdk.Context, denom string) bool { return found } +func (k Keeper) GetLegacyParams(ctx sdk.Context) (params types.LegacyParams) { + store := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) + + b := store.Get([]byte(types.ParamsKey)) + if b == nil { + return + } + + k.cdc.MustUnmarshal(b, ¶ms) + return +} + func (k Keeper) V8Migrate(ctx sdk.Context) error { baseCurrencyDenom, found := k.assetProfileKeeper.GetUsdcDenom(ctx) if !found { diff --git a/x/amm/keeper/swap_in_amt_given_out.go b/x/amm/keeper/swap_in_amt_given_out.go index f17e473ab..19a386aa0 100644 --- a/x/amm/keeper/swap_in_amt_given_out.go +++ b/x/amm/keeper/swap_in_amt_given_out.go @@ -1,9 +1,10 @@ package keeper import ( - "cosmossdk.io/math" "fmt" + "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/elys-network/elys/x/amm/types" ) @@ -13,11 +14,11 @@ import ( func (k Keeper) SwapInAmtGivenOut( ctx sdk.Context, poolId uint64, oracleKeeper types.OracleKeeper, snapshot *types.Pool, tokensOut sdk.Coins, tokenInDenom string, swapFee math.LegacyDec, weightBreakingFeePerpetualFactor math.LegacyDec) ( - tokenIn sdk.Coin, slippage, slippageAmount math.LegacyDec, weightBalanceBonus math.LegacyDec, oracleInAmount math.LegacyDec, err error, + tokenIn sdk.Coin, slippage, slippageAmount math.LegacyDec, weightBalanceBonus math.LegacyDec, oracleInAmount math.LegacyDec, swapFeeFinal math.LegacyDec, err error, ) { ammPool, found := k.GetPool(ctx, poolId) if !found { - return sdk.Coin{}, math.LegacyZeroDec(), math.LegacyZeroDec(), math.LegacyZeroDec(), math.LegacyZeroDec(), fmt.Errorf("invalid pool: %d", poolId) + return sdk.Coin{}, math.LegacyZeroDec(), math.LegacyZeroDec(), math.LegacyZeroDec(), math.LegacyZeroDec(), math.LegacyZeroDec(), fmt.Errorf("invalid pool: %d", poolId) } params := k.GetParams(ctx) return ammPool.SwapInAmtGivenOut(ctx, oracleKeeper, snapshot, tokensOut, tokenInDenom, swapFee, k.accountedPoolKeeper, weightBreakingFeePerpetualFactor, params) diff --git a/x/amm/keeper/swap_out_amt_given_in.go b/x/amm/keeper/swap_out_amt_given_in.go index e51e22456..acfec92b5 100644 --- a/x/amm/keeper/swap_out_amt_given_in.go +++ b/x/amm/keeper/swap_out_amt_given_in.go @@ -17,10 +17,10 @@ func (k Keeper) SwapOutAmtGivenIn( tokenOutDenom string, swapFee sdkmath.LegacyDec, weightBreakingFeePerpetualFactor sdkmath.LegacyDec, -) (tokenOut sdk.Coin, slippage sdkmath.LegacyDec, slippageAmount sdkmath.LegacyDec, weightBalanceBonus sdkmath.LegacyDec, oracleOutAmount sdkmath.LegacyDec, err error) { +) (tokenOut sdk.Coin, slippage sdkmath.LegacyDec, slippageAmount sdkmath.LegacyDec, weightBalanceBonus sdkmath.LegacyDec, oracleOutAmount sdkmath.LegacyDec, swapFeeFinal sdkmath.LegacyDec, err error) { ammPool, found := k.GetPool(ctx, poolId) if !found { - return sdk.Coin{}, sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), fmt.Errorf("invalid pool: %d", poolId) + return sdk.Coin{}, sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), fmt.Errorf("invalid pool: %d", poolId) } params := k.GetParams(ctx) return ammPool.SwapOutAmtGivenIn(ctx, oracleKeeper, snapshot, tokensIn, tokenOutDenom, swapFee, k.accountedPoolKeeper, weightBreakingFeePerpetualFactor, params) diff --git a/x/amm/migrations/v10_migration.go b/x/amm/migrations/v10_migration.go new file mode 100644 index 000000000..4b526988c --- /dev/null +++ b/x/amm/migrations/v10_migration.go @@ -0,0 +1,26 @@ +package migrations + +import ( + "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/elys-network/elys/x/amm/types" +) + +func (m Migrator) V10Migration(ctx sdk.Context) error { + legacyParams := m.keeper.GetLegacyParams(ctx) + params := types.Params{ + PoolCreationFee: legacyParams.PoolCreationFee, + SlippageTrackDuration: legacyParams.SlippageTrackDuration, + BaseAssets: legacyParams.BaseAssets, + WeightBreakingFeeExponent: legacyParams.WeightBreakingFeeExponent, + WeightBreakingFeeMultiplier: legacyParams.WeightBreakingFeeMultiplier, + WeightBreakingFeePortion: legacyParams.WeightBreakingFeePortion, + WeightRecoveryFeePortion: legacyParams.WeightRecoveryFeePortion, + ThresholdWeightDifference: legacyParams.ThresholdWeightDifference, + AllowedPoolCreators: legacyParams.AllowedPoolCreators, + ThresholdWeightDifferenceSwapFee: math.LegacyMustNewDecFromStr("0.125"), + } + + m.keeper.SetParams(ctx, params) + return nil +} diff --git a/x/amm/module.go b/x/amm/module.go index e184f60b7..9e09a220d 100644 --- a/x/amm/module.go +++ b/x/amm/module.go @@ -132,7 +132,7 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) types.RegisterQueryServer(cfg.QueryServer(), am.keeper) m := migrations.NewMigrator(am.keeper) - err := cfg.RegisterMigration(types.ModuleName, 8, m.V9Migration) + err := cfg.RegisterMigration(types.ModuleName, 9, m.V10Migration) if err != nil { panic(err) } @@ -159,7 +159,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 9 } +func (AppModule) ConsensusVersion() uint64 { return 10 } // BeginBlock contains the logic that is automatically triggered at the beginning of each block func (am AppModule) BeginBlock(_ context.Context) error { diff --git a/x/amm/types/params.go b/x/amm/types/params.go index 29489cb86..e4b0f1040 100644 --- a/x/amm/types/params.go +++ b/x/amm/types/params.go @@ -1,8 +1,9 @@ package types import ( - "cosmossdk.io/math" "errors" + + "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" @@ -11,15 +12,16 @@ import ( // NewParams creates a new Params instance func NewParams(poolCreationFee math.Int, slippageTrackDuration uint64, baseAssets []string) Params { return Params{ - PoolCreationFee: poolCreationFee, - SlippageTrackDuration: slippageTrackDuration, - BaseAssets: baseAssets, - WeightBreakingFeeExponent: math.LegacyMustNewDecFromStr("2.5"), - WeightBreakingFeeMultiplier: math.LegacyMustNewDecFromStr("0.0005"), - WeightBreakingFeePortion: math.LegacyMustNewDecFromStr("0.5"), - WeightRecoveryFeePortion: math.LegacyMustNewDecFromStr("0.1"), - ThresholdWeightDifference: math.LegacyMustNewDecFromStr("0.3"), - AllowedPoolCreators: []string{authtypes.NewModuleAddress(govtypes.ModuleName).String()}, + PoolCreationFee: poolCreationFee, + SlippageTrackDuration: slippageTrackDuration, + BaseAssets: baseAssets, + WeightBreakingFeeExponent: math.LegacyMustNewDecFromStr("2.5"), + WeightBreakingFeeMultiplier: math.LegacyMustNewDecFromStr("0.0005"), + WeightBreakingFeePortion: math.LegacyMustNewDecFromStr("0.5"), + WeightRecoveryFeePortion: math.LegacyMustNewDecFromStr("0.1"), + ThresholdWeightDifference: math.LegacyMustNewDecFromStr("0.3"), + AllowedPoolCreators: []string{authtypes.NewModuleAddress(govtypes.ModuleName).String()}, + ThresholdWeightDifferenceSwapFee: math.LegacyMustNewDecFromStr("1.0"), } } diff --git a/x/amm/types/params.pb.go b/x/amm/types/params.pb.go index 8ee7ce417..93e4b9909 100644 --- a/x/amm/types/params.pb.go +++ b/x/amm/types/params.pb.go @@ -27,9 +27,15 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Params defines the parameters for the module. type LegacyParams struct { - PoolCreationFee cosmossdk_io_math.Int `protobuf:"bytes,1,opt,name=pool_creation_fee,json=poolCreationFee,proto3,customtype=cosmossdk.io/math.Int" json:"pool_creation_fee"` - SlippageTrackDuration uint64 `protobuf:"varint,2,opt,name=slippage_track_duration,json=slippageTrackDuration,proto3" json:"slippage_track_duration,omitempty"` - EnableBaseCurrencyPairedPoolOnly bool `protobuf:"varint,3,opt,name=enable_base_currency_paired_pool_only,json=enableBaseCurrencyPairedPoolOnly,proto3" json:"enable_base_currency_paired_pool_only,omitempty"` + PoolCreationFee cosmossdk_io_math.Int `protobuf:"bytes,1,opt,name=pool_creation_fee,json=poolCreationFee,proto3,customtype=cosmossdk.io/math.Int" json:"pool_creation_fee"` + SlippageTrackDuration uint64 `protobuf:"varint,2,opt,name=slippage_track_duration,json=slippageTrackDuration,proto3" json:"slippage_track_duration,omitempty"` + BaseAssets []string `protobuf:"bytes,3,rep,name=base_assets,json=baseAssets,proto3" json:"base_assets,omitempty"` + WeightBreakingFeeExponent cosmossdk_io_math.LegacyDec `protobuf:"bytes,4,opt,name=weight_breaking_fee_exponent,json=weightBreakingFeeExponent,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"weight_breaking_fee_exponent"` + WeightBreakingFeeMultiplier cosmossdk_io_math.LegacyDec `protobuf:"bytes,5,opt,name=weight_breaking_fee_multiplier,json=weightBreakingFeeMultiplier,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"weight_breaking_fee_multiplier"` + WeightBreakingFeePortion cosmossdk_io_math.LegacyDec `protobuf:"bytes,6,opt,name=weight_breaking_fee_portion,json=weightBreakingFeePortion,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"weight_breaking_fee_portion"` + WeightRecoveryFeePortion cosmossdk_io_math.LegacyDec `protobuf:"bytes,7,opt,name=weight_recovery_fee_portion,json=weightRecoveryFeePortion,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"weight_recovery_fee_portion"` + ThresholdWeightDifference cosmossdk_io_math.LegacyDec `protobuf:"bytes,8,opt,name=threshold_weight_difference,json=thresholdWeightDifference,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"threshold_weight_difference"` + AllowedPoolCreators []string `protobuf:"bytes,9,rep,name=allowed_pool_creators,json=allowedPoolCreators,proto3" json:"allowed_pool_creators,omitempty"` } func (m *LegacyParams) Reset() { *m = LegacyParams{} } @@ -72,23 +78,31 @@ func (m *LegacyParams) GetSlippageTrackDuration() uint64 { return 0 } -func (m *LegacyParams) GetEnableBaseCurrencyPairedPoolOnly() bool { +func (m *LegacyParams) GetBaseAssets() []string { + if m != nil { + return m.BaseAssets + } + return nil +} + +func (m *LegacyParams) GetAllowedPoolCreators() []string { if m != nil { - return m.EnableBaseCurrencyPairedPoolOnly + return m.AllowedPoolCreators } - return false + return nil } type Params struct { - PoolCreationFee cosmossdk_io_math.Int `protobuf:"bytes,1,opt,name=pool_creation_fee,json=poolCreationFee,proto3,customtype=cosmossdk.io/math.Int" json:"pool_creation_fee"` - SlippageTrackDuration uint64 `protobuf:"varint,2,opt,name=slippage_track_duration,json=slippageTrackDuration,proto3" json:"slippage_track_duration,omitempty"` - BaseAssets []string `protobuf:"bytes,3,rep,name=base_assets,json=baseAssets,proto3" json:"base_assets,omitempty"` - WeightBreakingFeeExponent cosmossdk_io_math.LegacyDec `protobuf:"bytes,4,opt,name=weight_breaking_fee_exponent,json=weightBreakingFeeExponent,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"weight_breaking_fee_exponent"` - WeightBreakingFeeMultiplier cosmossdk_io_math.LegacyDec `protobuf:"bytes,5,opt,name=weight_breaking_fee_multiplier,json=weightBreakingFeeMultiplier,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"weight_breaking_fee_multiplier"` - WeightBreakingFeePortion cosmossdk_io_math.LegacyDec `protobuf:"bytes,6,opt,name=weight_breaking_fee_portion,json=weightBreakingFeePortion,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"weight_breaking_fee_portion"` - WeightRecoveryFeePortion cosmossdk_io_math.LegacyDec `protobuf:"bytes,7,opt,name=weight_recovery_fee_portion,json=weightRecoveryFeePortion,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"weight_recovery_fee_portion"` - ThresholdWeightDifference cosmossdk_io_math.LegacyDec `protobuf:"bytes,8,opt,name=threshold_weight_difference,json=thresholdWeightDifference,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"threshold_weight_difference"` - AllowedPoolCreators []string `protobuf:"bytes,9,rep,name=allowed_pool_creators,json=allowedPoolCreators,proto3" json:"allowed_pool_creators,omitempty"` + PoolCreationFee cosmossdk_io_math.Int `protobuf:"bytes,1,opt,name=pool_creation_fee,json=poolCreationFee,proto3,customtype=cosmossdk.io/math.Int" json:"pool_creation_fee"` + SlippageTrackDuration uint64 `protobuf:"varint,2,opt,name=slippage_track_duration,json=slippageTrackDuration,proto3" json:"slippage_track_duration,omitempty"` + BaseAssets []string `protobuf:"bytes,3,rep,name=base_assets,json=baseAssets,proto3" json:"base_assets,omitempty"` + WeightBreakingFeeExponent cosmossdk_io_math.LegacyDec `protobuf:"bytes,4,opt,name=weight_breaking_fee_exponent,json=weightBreakingFeeExponent,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"weight_breaking_fee_exponent"` + WeightBreakingFeeMultiplier cosmossdk_io_math.LegacyDec `protobuf:"bytes,5,opt,name=weight_breaking_fee_multiplier,json=weightBreakingFeeMultiplier,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"weight_breaking_fee_multiplier"` + WeightBreakingFeePortion cosmossdk_io_math.LegacyDec `protobuf:"bytes,6,opt,name=weight_breaking_fee_portion,json=weightBreakingFeePortion,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"weight_breaking_fee_portion"` + WeightRecoveryFeePortion cosmossdk_io_math.LegacyDec `protobuf:"bytes,7,opt,name=weight_recovery_fee_portion,json=weightRecoveryFeePortion,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"weight_recovery_fee_portion"` + ThresholdWeightDifference cosmossdk_io_math.LegacyDec `protobuf:"bytes,8,opt,name=threshold_weight_difference,json=thresholdWeightDifference,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"threshold_weight_difference"` + AllowedPoolCreators []string `protobuf:"bytes,9,rep,name=allowed_pool_creators,json=allowedPoolCreators,proto3" json:"allowed_pool_creators,omitempty"` + ThresholdWeightDifferenceSwapFee cosmossdk_io_math.LegacyDec `protobuf:"bytes,10,opt,name=threshold_weight_difference_swap_fee,json=thresholdWeightDifferenceSwapFee,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"threshold_weight_difference_swap_fee"` } func (m *Params) Reset() { *m = Params{} } @@ -153,41 +167,40 @@ func init() { func init() { proto.RegisterFile("elys/amm/params.proto", fileDescriptor_1209ca218537a425) } var fileDescriptor_1209ca218537a425 = []byte{ - // 538 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x94, 0x41, 0x6b, 0x13, 0x41, - 0x14, 0xc7, 0xb3, 0xb6, 0xc6, 0x66, 0x14, 0xc4, 0xd5, 0xe0, 0xb6, 0x91, 0x4d, 0x28, 0x08, 0x01, - 0x69, 0x16, 0x15, 0xbc, 0x9b, 0xc6, 0x42, 0x41, 0x69, 0x58, 0x84, 0x82, 0x97, 0x61, 0xb2, 0x79, - 0xd9, 0x2c, 0x99, 0x9d, 0x37, 0xce, 0x4c, 0x9a, 0xee, 0xb7, 0xf0, 0xab, 0x08, 0x7e, 0x88, 0x1e, - 0x8b, 0x27, 0xf1, 0x50, 0x24, 0xf9, 0x02, 0x7e, 0x04, 0xd9, 0xd9, 0x4d, 0x88, 0xa4, 0xa7, 0x78, - 0xf1, 0xb6, 0xf3, 0xfe, 0x8f, 0xdf, 0xff, 0xbd, 0x9d, 0x37, 0x8f, 0xd4, 0x81, 0x67, 0x3a, 0x60, - 0x69, 0x1a, 0x48, 0xa6, 0x58, 0xaa, 0x3b, 0x52, 0xa1, 0x41, 0x77, 0x2f, 0x0f, 0x77, 0x58, 0x9a, - 0x1e, 0x3c, 0x89, 0x31, 0x46, 0x1b, 0x0c, 0xf2, 0xaf, 0x42, 0x3f, 0xd8, 0x8f, 0x50, 0xa7, 0xa8, - 0x69, 0x21, 0x14, 0x87, 0x42, 0x3a, 0xfc, 0xed, 0x90, 0x07, 0xef, 0x21, 0x66, 0x51, 0xd6, 0xb7, - 0x44, 0xf7, 0x9c, 0x3c, 0x92, 0x88, 0x9c, 0x46, 0x0a, 0x98, 0x49, 0x50, 0xd0, 0x11, 0x80, 0xe7, - 0xb4, 0x9c, 0x76, 0xad, 0xfb, 0xe2, 0xea, 0xa6, 0x59, 0xf9, 0x79, 0xd3, 0xac, 0x17, 0x04, 0x3d, - 0x9c, 0x74, 0x12, 0x0c, 0x52, 0x66, 0xc6, 0x9d, 0x53, 0x61, 0xbe, 0x7f, 0x3b, 0x22, 0x25, 0xfa, - 0x54, 0x98, 0xf0, 0x61, 0x4e, 0x39, 0x2e, 0x21, 0x27, 0x00, 0xee, 0x1b, 0xf2, 0x54, 0xf3, 0x44, - 0x4a, 0x16, 0x03, 0x35, 0x8a, 0x45, 0x13, 0x3a, 0x9c, 0x2a, 0xab, 0x7a, 0x77, 0x5a, 0x4e, 0x7b, - 0x37, 0xac, 0x2f, 0xe5, 0x8f, 0xb9, 0xda, 0x2b, 0x45, 0xf7, 0x8c, 0x3c, 0x07, 0xc1, 0x06, 0x1c, - 0xe8, 0x80, 0x69, 0xa0, 0xd1, 0x54, 0x29, 0x10, 0x51, 0x46, 0x25, 0x4b, 0x14, 0x0c, 0xa9, 0x2d, - 0x16, 0x05, 0xcf, 0xbc, 0x9d, 0x96, 0xd3, 0xde, 0x0b, 0x5b, 0x45, 0x72, 0x97, 0x69, 0x38, 0x2e, - 0x53, 0xfb, 0x36, 0xb3, 0x8f, 0xc8, 0xcf, 0x04, 0xcf, 0x0e, 0xbf, 0x56, 0x49, 0xf5, 0x7f, 0x6d, - 0xb6, 0x49, 0xee, 0xdb, 0x2e, 0x99, 0xd6, 0x60, 0xb4, 0xb7, 0xd3, 0xda, 0x69, 0xd7, 0x42, 0x92, - 0x87, 0xde, 0xda, 0x88, 0xab, 0xc8, 0xb3, 0x19, 0x24, 0xf1, 0xd8, 0xd0, 0x81, 0x02, 0x36, 0x49, - 0x44, 0x9c, 0xd7, 0x4c, 0xe1, 0x52, 0xa2, 0x00, 0x61, 0xbc, 0x5d, 0x5b, 0xfc, 0xcb, 0xb2, 0xf8, - 0xc6, 0x66, 0xf1, 0xc5, 0x65, 0xf7, 0x20, 0x5a, 0x6b, 0xa1, 0x07, 0x51, 0xb8, 0x5f, 0x60, 0xbb, - 0x25, 0xf5, 0x04, 0xe0, 0x5d, 0xc9, 0x74, 0x2f, 0x88, 0x7f, 0x9b, 0x67, 0x3a, 0xe5, 0x26, 0x91, - 0x3c, 0x01, 0xe5, 0xdd, 0xdd, 0xd6, 0xb5, 0xb1, 0xe1, 0xfa, 0x61, 0x45, 0x75, 0x25, 0x69, 0xdc, - 0xe6, 0x2b, 0x51, 0xd9, 0x1f, 0x59, 0xdd, 0xd6, 0xd4, 0xdb, 0x30, 0xed, 0x17, 0xc8, 0x35, 0x47, - 0x05, 0x11, 0x5e, 0x80, 0xca, 0xfe, 0x72, 0xbc, 0xf7, 0x8f, 0x8e, 0x61, 0x09, 0x5d, 0x73, 0xfc, - 0x4c, 0x1a, 0x66, 0xac, 0x40, 0x8f, 0x91, 0x0f, 0x69, 0xe9, 0x3d, 0x4c, 0x46, 0x23, 0xc8, 0x27, - 0x17, 0xbc, 0xbd, 0xad, 0xaf, 0x73, 0x45, 0x3d, 0xb7, 0xd0, 0xde, 0x8a, 0xe9, 0xbe, 0x22, 0x75, - 0xc6, 0x39, 0xce, 0x96, 0x8f, 0xc7, 0x0e, 0x3f, 0x2a, 0xed, 0xd5, 0xec, 0xb4, 0x3d, 0x2e, 0xc5, - 0xfe, 0x72, 0xa4, 0x51, 0xe9, 0x6e, 0xf7, 0x6a, 0xee, 0x3b, 0xd7, 0x73, 0xdf, 0xf9, 0x35, 0xf7, - 0x9d, 0x2f, 0x0b, 0xbf, 0x72, 0xbd, 0xf0, 0x2b, 0x3f, 0x16, 0x7e, 0xe5, 0x53, 0x3b, 0x4e, 0xcc, - 0x78, 0x3a, 0xe8, 0x44, 0x98, 0x06, 0xf9, 0x1a, 0x3a, 0x12, 0x60, 0x66, 0xa8, 0x26, 0xf6, 0x10, - 0x5c, 0xda, 0x65, 0x65, 0x32, 0x09, 0x7a, 0x50, 0xb5, 0x1b, 0xe7, 0xf5, 0x9f, 0x00, 0x00, 0x00, - 0xff, 0xff, 0xe4, 0xff, 0xe6, 0xa0, 0xc5, 0x04, 0x00, 0x00, + // 523 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x95, 0x41, 0x8b, 0xd3, 0x40, + 0x14, 0xc7, 0x1b, 0x77, 0xed, 0x6e, 0x47, 0x41, 0x8c, 0x16, 0xb3, 0x5b, 0x49, 0xcb, 0xe2, 0xa1, + 0x20, 0xdb, 0xa0, 0x82, 0x77, 0x6b, 0x2d, 0x2c, 0x28, 0x94, 0x28, 0x2c, 0x78, 0x19, 0xa6, 0xc9, + 0x6b, 0x12, 0x9a, 0xe4, 0x8d, 0x33, 0xd3, 0xcd, 0xf6, 0xe8, 0x37, 0xf0, 0xc3, 0x28, 0x7e, 0x85, + 0x3d, 0x2e, 0x9e, 0xc4, 0xc3, 0x22, 0xed, 0x17, 0x91, 0x4c, 0xb2, 0xb5, 0xd2, 0x55, 0xa4, 0x7b, + 0xed, 0x2d, 0xf3, 0xfe, 0xf0, 0xfb, 0xff, 0x27, 0xf3, 0x1e, 0x8f, 0xd4, 0x21, 0x9e, 0x4a, 0x87, + 0x25, 0x89, 0xc3, 0x99, 0x60, 0x89, 0xec, 0x70, 0x81, 0x0a, 0xcd, 0xdd, 0xbc, 0xdc, 0x61, 0x49, + 0xb2, 0x7f, 0x3f, 0xc0, 0x00, 0x75, 0xd1, 0xc9, 0xbf, 0x0a, 0x7d, 0x7f, 0xcf, 0x43, 0x99, 0xa0, + 0xa4, 0x85, 0x50, 0x1c, 0x0a, 0xe9, 0xe0, 0x6b, 0x95, 0xdc, 0x7e, 0x0d, 0x01, 0xf3, 0xa6, 0x03, + 0x4d, 0x34, 0x8f, 0xc9, 0x5d, 0x8e, 0x18, 0x53, 0x4f, 0x00, 0x53, 0x11, 0xa6, 0x74, 0x04, 0x60, + 0x19, 0x2d, 0xa3, 0x5d, 0xeb, 0x3e, 0x3e, 0xbb, 0x68, 0x56, 0x7e, 0x5c, 0x34, 0xeb, 0x05, 0x41, + 0xfa, 0xe3, 0x4e, 0x84, 0x4e, 0xc2, 0x54, 0xd8, 0x39, 0x4a, 0xd5, 0xb7, 0xcf, 0x87, 0xa4, 0x44, + 0x1f, 0xa5, 0xca, 0xbd, 0x93, 0x53, 0x5e, 0x96, 0x90, 0x3e, 0x80, 0xf9, 0x9c, 0x3c, 0x90, 0x71, + 0xc4, 0x39, 0x0b, 0x80, 0x2a, 0xc1, 0xbc, 0x31, 0xf5, 0x27, 0x42, 0xab, 0xd6, 0x8d, 0x96, 0xd1, + 0xde, 0x76, 0xeb, 0x97, 0xf2, 0xbb, 0x5c, 0xed, 0x95, 0xa2, 0xd9, 0x24, 0xb7, 0x86, 0x4c, 0x02, + 0x65, 0x52, 0x82, 0x92, 0xd6, 0x56, 0x6b, 0xab, 0x5d, 0x73, 0x49, 0x5e, 0x7a, 0xa1, 0x2b, 0xa6, + 0x20, 0x0f, 0x33, 0x88, 0x82, 0x50, 0xd1, 0xa1, 0x00, 0x36, 0x8e, 0xd2, 0x20, 0xcf, 0x4c, 0xe1, + 0x94, 0x63, 0x0a, 0xa9, 0xb2, 0xb6, 0x75, 0xf8, 0x27, 0x65, 0xf8, 0xc6, 0x6a, 0xf8, 0xe2, 0xfe, + 0x3d, 0xf0, 0x96, 0xae, 0xd0, 0x03, 0xcf, 0xdd, 0x2b, 0xb0, 0xdd, 0x92, 0xda, 0x07, 0x78, 0x55, + 0x32, 0xcd, 0x13, 0x62, 0x5f, 0xe5, 0x99, 0x4c, 0x62, 0x15, 0xf1, 0x38, 0x02, 0x61, 0xdd, 0x5c, + 0xd7, 0xb5, 0xb1, 0xe2, 0xfa, 0x66, 0x41, 0x35, 0x39, 0x69, 0x5c, 0xe5, 0xcb, 0x51, 0xe8, 0x1f, + 0x59, 0x5d, 0xd7, 0xd4, 0x5a, 0x31, 0x1d, 0x14, 0xc8, 0x25, 0x47, 0x01, 0x1e, 0x9e, 0x80, 0x98, + 0xfe, 0xe1, 0xb8, 0x73, 0x4d, 0x47, 0xb7, 0x84, 0x2e, 0x39, 0x7e, 0x20, 0x0d, 0x15, 0x0a, 0x90, + 0x21, 0xc6, 0x3e, 0x2d, 0xbd, 0xfd, 0x68, 0x34, 0x02, 0x01, 0xa9, 0x07, 0xd6, 0xee, 0xda, 0xcf, + 0xb9, 0xa0, 0x1e, 0x6b, 0x68, 0x6f, 0xc1, 0x34, 0x9f, 0x92, 0x3a, 0x8b, 0x63, 0xcc, 0xc0, 0xa7, + 0xbf, 0x9b, 0x1f, 0x85, 0xb4, 0x6a, 0xba, 0xdb, 0xee, 0x95, 0xe2, 0xe0, 0xb2, 0xa5, 0x51, 0xc8, + 0x83, 0x2f, 0x3b, 0xa4, 0xba, 0x99, 0x99, 0xcd, 0xcc, 0x6c, 0x66, 0xe6, 0xbf, 0x67, 0xc6, 0xfc, + 0x68, 0x90, 0x47, 0xff, 0xc8, 0x49, 0x65, 0xc6, 0xb8, 0x1e, 0x1e, 0xb2, 0x6e, 0xe0, 0xd6, 0x5f, + 0x03, 0xbf, 0xcd, 0x18, 0xef, 0x03, 0x74, 0xbb, 0x67, 0x33, 0xdb, 0x38, 0x9f, 0xd9, 0xc6, 0xcf, + 0x99, 0x6d, 0x7c, 0x9a, 0xdb, 0x95, 0xf3, 0xb9, 0x5d, 0xf9, 0x3e, 0xb7, 0x2b, 0xef, 0xdb, 0x41, + 0xa4, 0xc2, 0xc9, 0xb0, 0xe3, 0x61, 0xe2, 0xe4, 0x1b, 0xf5, 0x30, 0x05, 0x95, 0xa1, 0x18, 0xeb, + 0x83, 0x73, 0xaa, 0xf7, 0xae, 0x9a, 0x72, 0x90, 0xc3, 0xaa, 0x5e, 0x9e, 0xcf, 0x7e, 0x05, 0x00, + 0x00, 0xff, 0xff, 0x08, 0x8f, 0xbe, 0x5d, 0x90, 0x07, 0x00, 0x00, } func (m *LegacyParams) Marshal() (dAtA []byte, err error) { @@ -210,15 +223,73 @@ func (m *LegacyParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if m.EnableBaseCurrencyPairedPoolOnly { - i-- - if m.EnableBaseCurrencyPairedPoolOnly { - dAtA[i] = 1 - } else { - dAtA[i] = 0 + if len(m.AllowedPoolCreators) > 0 { + for iNdEx := len(m.AllowedPoolCreators) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.AllowedPoolCreators[iNdEx]) + copy(dAtA[i:], m.AllowedPoolCreators[iNdEx]) + i = encodeVarintParams(dAtA, i, uint64(len(m.AllowedPoolCreators[iNdEx]))) + i-- + dAtA[i] = 0x4a + } + } + { + size := m.ThresholdWeightDifference.Size() + i -= size + if _, err := m.ThresholdWeightDifference.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x42 + { + size := m.WeightRecoveryFeePortion.Size() + i -= size + if _, err := m.WeightRecoveryFeePortion.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x3a + { + size := m.WeightBreakingFeePortion.Size() + i -= size + if _, err := m.WeightBreakingFeePortion.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + { + size := m.WeightBreakingFeeMultiplier.Size() + i -= size + if _, err := m.WeightBreakingFeeMultiplier.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + { + size := m.WeightBreakingFeeExponent.Size() + i -= size + if _, err := m.WeightBreakingFeeExponent.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + if len(m.BaseAssets) > 0 { + for iNdEx := len(m.BaseAssets) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.BaseAssets[iNdEx]) + copy(dAtA[i:], m.BaseAssets[iNdEx]) + i = encodeVarintParams(dAtA, i, uint64(len(m.BaseAssets[iNdEx]))) + i-- + dAtA[i] = 0x1a } - i-- - dAtA[i] = 0x18 } if m.SlippageTrackDuration != 0 { i = encodeVarintParams(dAtA, i, uint64(m.SlippageTrackDuration)) @@ -258,6 +329,16 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + { + size := m.ThresholdWeightDifferenceSwapFee.Size() + i -= size + if _, err := m.ThresholdWeightDifferenceSwapFee.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x52 if len(m.AllowedPoolCreators) > 0 { for iNdEx := len(m.AllowedPoolCreators) - 1; iNdEx >= 0; iNdEx-- { i -= len(m.AllowedPoolCreators[iNdEx]) @@ -366,8 +447,27 @@ func (m *LegacyParams) Size() (n int) { if m.SlippageTrackDuration != 0 { n += 1 + sovParams(uint64(m.SlippageTrackDuration)) } - if m.EnableBaseCurrencyPairedPoolOnly { - n += 2 + if len(m.BaseAssets) > 0 { + for _, s := range m.BaseAssets { + l = len(s) + n += 1 + l + sovParams(uint64(l)) + } + } + l = m.WeightBreakingFeeExponent.Size() + n += 1 + l + sovParams(uint64(l)) + l = m.WeightBreakingFeeMultiplier.Size() + n += 1 + l + sovParams(uint64(l)) + l = m.WeightBreakingFeePortion.Size() + n += 1 + l + sovParams(uint64(l)) + l = m.WeightRecoveryFeePortion.Size() + n += 1 + l + sovParams(uint64(l)) + l = m.ThresholdWeightDifference.Size() + n += 1 + l + sovParams(uint64(l)) + if len(m.AllowedPoolCreators) > 0 { + for _, s := range m.AllowedPoolCreators { + l = len(s) + n += 1 + l + sovParams(uint64(l)) + } } return n } @@ -405,6 +505,8 @@ func (m *Params) Size() (n int) { n += 1 + l + sovParams(uint64(l)) } } + l = m.ThresholdWeightDifferenceSwapFee.Size() + n += 1 + l + sovParams(uint64(l)) return n } @@ -497,10 +599,144 @@ func (m *LegacyParams) Unmarshal(dAtA []byte) error { } } case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field EnableBaseCurrencyPairedPoolOnly", wireType) + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BaseAssets", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + 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 ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.BaseAssets = append(m.BaseAssets, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field WeightBreakingFeeExponent", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + 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 ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.WeightBreakingFeeExponent.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err } - var v int + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field WeightBreakingFeeMultiplier", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + 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 ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.WeightBreakingFeeMultiplier.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field WeightBreakingFeePortion", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + 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 ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.WeightBreakingFeePortion.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field WeightRecoveryFeePortion", wireType) + } + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowParams @@ -510,12 +746,92 @@ func (m *LegacyParams) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - v |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - m.EnableBaseCurrencyPairedPoolOnly = bool(v != 0) + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.WeightRecoveryFeePortion.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ThresholdWeightDifference", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + 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 ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.ThresholdWeightDifference.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 9: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AllowedPoolCreators", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + 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 ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AllowedPoolCreators = append(m.AllowedPoolCreators, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipParams(dAtA[iNdEx:]) @@ -853,6 +1169,40 @@ func (m *Params) Unmarshal(dAtA []byte) error { } m.AllowedPoolCreators = append(m.AllowedPoolCreators, string(dAtA[iNdEx:postIndex])) iNdEx = postIndex + case 10: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ThresholdWeightDifferenceSwapFee", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + 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 ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.ThresholdWeightDifferenceSwapFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipParams(dAtA[iNdEx:]) diff --git a/x/amm/types/swap_in_amt_given_out.go b/x/amm/types/swap_in_amt_given_out.go index 95be97a60..15a6f3534 100644 --- a/x/amm/types/swap_in_amt_given_out.go +++ b/x/amm/types/swap_in_amt_given_out.go @@ -51,7 +51,7 @@ func (p Pool) CalcGivenOutSlippage( func (p *Pool) SwapInAmtGivenOut( ctx sdk.Context, oracleKeeper OracleKeeper, snapshot *Pool, tokensOut sdk.Coins, tokenInDenom string, swapFee sdkmath.LegacyDec, accPoolKeeper AccountedPoolKeeper, weightBreakingFeePerpetualFactor sdkmath.LegacyDec, params Params) ( - tokenIn sdk.Coin, slippage, slippageAmount sdkmath.LegacyDec, weightBalanceBonus sdkmath.LegacyDec, oracleInAmount sdkmath.LegacyDec, err error, + tokenIn sdk.Coin, slippage, slippageAmount sdkmath.LegacyDec, weightBalanceBonus sdkmath.LegacyDec, oracleInAmount sdkmath.LegacyDec, swapFeeFinal sdkmath.LegacyDec, err error, ) { // Fixed gas consumption per swap to prevent spam ctx.GasMeter().ConsumeGas(BalancerGasFeeForSwap, "balancer swap computation") @@ -60,24 +60,24 @@ func (p *Pool) SwapInAmtGivenOut( if !p.PoolParams.UseOracle { balancerInCoin, slippage, err := p.CalcInAmtGivenOut(ctx, oracleKeeper, snapshot, tokensOut, tokenInDenom, swapFee, accPoolKeeper) if err != nil { - return sdk.Coin{}, sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), err + return sdk.Coin{}, sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), err } - return balancerInCoin, slippage, sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), nil + return balancerInCoin, slippage, sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), swapFee, nil } tokenOut, poolAssetOut, poolAssetIn, err := p.parsePoolAssets(tokensOut, tokenInDenom) if err != nil { - return sdk.Coin{}, sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), err + return sdk.Coin{}, sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), err } // ensure token prices for in/out tokens set properly inTokenPrice := oracleKeeper.GetAssetPriceFromDenom(ctx, tokenInDenom) if inTokenPrice.IsZero() { - return sdk.Coin{}, sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), fmt.Errorf("price for inToken not set: %s", poolAssetIn.Token.Denom) + return sdk.Coin{}, sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), fmt.Errorf("price for inToken not set: %s", poolAssetIn.Token.Denom) } outTokenPrice := oracleKeeper.GetAssetPriceFromDenom(ctx, tokenOut.Denom) if outTokenPrice.IsZero() { - return sdk.Coin{}, sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), fmt.Errorf("price for outToken not set: %s", poolAssetOut.Token.Denom) + return sdk.Coin{}, sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), fmt.Errorf("price for outToken not set: %s", poolAssetOut.Token.Denom) } accountedAssets := p.GetAccountedBalance(ctx, accPoolKeeper, p.PoolAssets) @@ -91,11 +91,11 @@ func (p *Pool) SwapInAmtGivenOut( externalLiquidityRatio, err := p.GetAssetExternalLiquidityRatio(tokenOut.Denom) if err != nil { - return sdk.Coin{}, sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), err + return sdk.Coin{}, sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), err } // Ensure externalLiquidityRatio is not zero to avoid division by zero if externalLiquidityRatio.IsZero() { - return sdk.Coin{}, sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), ErrAmountTooLow + return sdk.Coin{}, sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), ErrAmountTooLow } resizedAmount := sdkmath.LegacyNewDecFromInt(tokenOut.Amount).Quo(externalLiquidityRatio).RoundInt() @@ -108,7 +108,7 @@ func (p *Pool) SwapInAmtGivenOut( accPoolKeeper, ) if err != nil { - return sdk.Coin{}, sdkmath.LegacyOneDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), err + return sdk.Coin{}, sdkmath.LegacyOneDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), err } inAmountAfterSlippage := oracleInAmount.Add(slippageAmount.Mul(externalLiquidityRatio)) slippageAmount = slippageAmount.Mul(externalLiquidityRatio) @@ -120,7 +120,7 @@ func (p *Pool) SwapInAmtGivenOut( tokensOut, accountedAssets, ) if err != nil { - return sdk.Coin{}, sdkmath.LegacyOneDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), err + return sdk.Coin{}, sdkmath.LegacyOneDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), err } weightDistance := p.WeightDistanceFromTarget(ctx, oracleKeeper, newAssetPools) distanceDiff := weightDistance.Sub(initialWeightDistance) @@ -159,10 +159,14 @@ func (p *Pool) SwapInAmtGivenOut( if initialWeightDistance.GT(params.ThresholdWeightDifference) { weightBalanceBonus = weightRecoveryReward } + + if initialWeightDistance.GT(params.ThresholdWeightDifferenceSwapFee) { + swapFee = sdkmath.LegacyZeroDec() + } } if swapFee.GTE(sdkmath.LegacyOneDec()) { - return sdk.Coin{}, sdkmath.LegacyOneDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), ErrTooMuchSwapFee + return sdk.Coin{}, sdkmath.LegacyOneDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), ErrTooMuchSwapFee } // We deduct a swap fee on the input asset. The swap happens by following the invariant curve on the input * (1 - swap fee) @@ -175,5 +179,5 @@ func (p *Pool) SwapInAmtGivenOut( Ceil().TruncateInt() // We round up tokenInAmt, as this is whats charged for the swap, for the precise amount out. // Otherwise, the pool would under-charge by this rounding error. tokenIn = sdk.NewCoin(tokenInDenom, tokenAmountInInt) - return tokenIn, slippage, slippageAmount, weightBalanceBonus, oracleInAmount, nil + return tokenIn, slippage, slippageAmount, weightBalanceBonus, oracleInAmount, swapFee, nil } diff --git a/x/amm/types/swap_in_amt_given_out_test.go b/x/amm/types/swap_in_amt_given_out_test.go index c47f8202f..ff914d609 100644 --- a/x/amm/types/swap_in_amt_given_out_test.go +++ b/x/amm/types/swap_in_amt_given_out_test.go @@ -225,7 +225,7 @@ func (suite *TestSuite) TestSwapInAmtGivenOut() { params.WeightBreakingFeeMultiplier = sdkmath.LegacyNewDecWithPrec(2, 4) params.WeightBreakingFeeExponent = sdkmath.LegacyNewDecWithPrec(25, 1) // 2.5 params.WeightRecoveryFeePortion = sdkmath.LegacyNewDecWithPrec(50, 2) // 50% - tokenOut, _, _, weightBonus, _, err := pool.SwapInAmtGivenOut(suite.ctx, suite.app.OracleKeeper, &pool, sdk.Coins{tc.tokenOut}, tc.inTokenDenom, tc.swapFee, suite.app.AccountedPoolKeeper, sdkmath.LegacyOneDec(), params) + tokenOut, _, _, weightBonus, _, _, err := pool.SwapInAmtGivenOut(suite.ctx, suite.app.OracleKeeper, &pool, sdk.Coins{tc.tokenOut}, tc.inTokenDenom, tc.swapFee, suite.app.AccountedPoolKeeper, sdkmath.LegacyOneDec(), params) if tc.expErr { suite.Require().Error(err) suite.Require().EqualError(err, "amount too low") diff --git a/x/amm/types/swap_out_amt_given_in.go b/x/amm/types/swap_out_amt_given_in.go index 9217b4604..7b61bf3f1 100644 --- a/x/amm/types/swap_out_amt_given_in.go +++ b/x/amm/types/swap_out_amt_given_in.go @@ -181,7 +181,7 @@ func (p *Pool) SwapOutAmtGivenIn( accPoolKeeper AccountedPoolKeeper, weightBreakingFeePerpetualFactor sdkmath.LegacyDec, params Params, -) (tokenOut sdk.Coin, slippage, slippageAmount sdkmath.LegacyDec, weightBalanceBonus sdkmath.LegacyDec, oracleOutAmount sdkmath.LegacyDec, err error) { +) (tokenOut sdk.Coin, slippage, slippageAmount sdkmath.LegacyDec, weightBalanceBonus sdkmath.LegacyDec, oracleOutAmount sdkmath.LegacyDec, swapFeeFinal sdkmath.LegacyDec, err error) { // Fixed gas consumption per swap to prevent spam ctx.GasMeter().ConsumeGas(BalancerGasFeeForSwap, "balancer swap computation") @@ -189,29 +189,29 @@ func (p *Pool) SwapOutAmtGivenIn( // early return with balancer swap if normal amm pool if !p.PoolParams.UseOracle { if len(tokensIn) != 1 { - return sdk.Coin{}, sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), errors.New("expected tokensIn to be of length one") + return sdk.Coin{}, sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), errors.New("expected tokensIn to be of length one") } balancerOutCoin, slippage, err := p.CalcOutAmtGivenIn(ctx, oracleKeeper, snapshot, tokensIn, tokenOutDenom, swapFee, accPoolKeeper) if err != nil { - return sdk.Coin{}, sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), err + return sdk.Coin{}, sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), err } // Pools and it's bank balances are updated in keeper.UpdatePoolForSwap - return balancerOutCoin, slippage, sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), nil + return balancerOutCoin, slippage, sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), swapFee, nil } tokenIn, poolAssetIn, poolAssetOut, err := p.parsePoolAssets(tokensIn, tokenOutDenom) if err != nil { - return sdk.Coin{}, sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), err + return sdk.Coin{}, sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), err } // ensure token prices for in/out tokens set properly inTokenPrice := oracleKeeper.GetAssetPriceFromDenom(ctx, tokenIn.Denom) if inTokenPrice.IsZero() { - return sdk.Coin{}, sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), fmt.Errorf("price for inToken not set: %s", poolAssetIn.Token.Denom) + return sdk.Coin{}, sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), fmt.Errorf("price for inToken not set: %s", poolAssetIn.Token.Denom) } outTokenPrice := oracleKeeper.GetAssetPriceFromDenom(ctx, tokenOutDenom) if outTokenPrice.IsZero() { - return sdk.Coin{}, sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), fmt.Errorf("price for outToken not set: %s", poolAssetOut.Token.Denom) + return sdk.Coin{}, sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), fmt.Errorf("price for outToken not set: %s", poolAssetOut.Token.Denom) } accountedAssets := p.GetAccountedBalance(ctx, accPoolKeeper, p.PoolAssets) @@ -225,12 +225,12 @@ func (p *Pool) SwapOutAmtGivenIn( externalLiquidityRatio, err := p.GetAssetExternalLiquidityRatio(tokenOutDenom) if err != nil { - return sdk.Coin{}, sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), err + return sdk.Coin{}, sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), err } // Ensure externalLiquidityRatio is not zero to avoid division by zero if externalLiquidityRatio.IsZero() { - return sdk.Coin{}, sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), ErrAmountTooLow + return sdk.Coin{}, sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), ErrAmountTooLow } resizedAmount := sdkmath.LegacyNewDecFromInt(tokenIn.Amount).Quo(externalLiquidityRatio).RoundInt() @@ -243,7 +243,7 @@ func (p *Pool) SwapOutAmtGivenIn( accPoolKeeper, ) if err != nil { - return sdk.Coin{}, sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), err + return sdk.Coin{}, sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), err } outAmountAfterSlippage := oracleOutAmount.Sub(slippageAmount.Mul(externalLiquidityRatio)) slippageAmount = slippageAmount.Mul(externalLiquidityRatio) @@ -297,7 +297,7 @@ func (p *Pool) SwapOutAmtGivenIn( sdk.Coins{sdk.NewCoin(tokenOutDenom, outAmountAfterSlippage.TruncateInt())}, accountedAssets, ) if err != nil { - return sdk.Coin{}, sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), err + return sdk.Coin{}, sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), err } weightDistance := p.WeightDistanceFromTarget(ctx, oracleKeeper, newAssetPools) distanceDiff := weightDistance.Sub(initialWeightDistance) @@ -336,17 +336,21 @@ func (p *Pool) SwapOutAmtGivenIn( if initialWeightDistance.GT(params.ThresholdWeightDifference) { weightBalanceBonus = weightRecoveryReward } + + if initialWeightDistance.GT(params.ThresholdWeightDifferenceSwapFee) { + swapFee = sdkmath.LegacyZeroDec() + } } if swapFee.GTE(sdkmath.LegacyOneDec()) { - return sdk.Coin{}, sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), ErrTooMuchSwapFee + return sdk.Coin{}, sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), ErrTooMuchSwapFee } tokenAmountOutInt := outAmountAfterSlippage. Mul(sdkmath.LegacyOneDec().Sub(weightBreakingFee)). Mul(sdkmath.LegacyOneDec().Sub(swapFee)).TruncateInt() // We ignore the decimal component, as we round down the token amount out. oracleOutCoin := sdk.NewCoin(tokenOutDenom, tokenAmountOutInt) - return oracleOutCoin, slippage, slippageAmount, weightBalanceBonus, oracleOutAmount, nil + return oracleOutCoin, slippage, slippageAmount, weightBalanceBonus, oracleOutAmount, swapFee, nil } // TODO: Ideally we should have a single DS for accounted pool to avoid confusion diff --git a/x/amm/types/swap_out_amt_given_in_test.go b/x/amm/types/swap_out_amt_given_in_test.go index beb4f0a54..8ad6f7596 100644 --- a/x/amm/types/swap_out_amt_given_in_test.go +++ b/x/amm/types/swap_out_amt_given_in_test.go @@ -637,7 +637,7 @@ func (suite *TestSuite) TestSwapOutAmtGivenIn() { params.WeightBreakingFeeMultiplier = sdkmath.LegacyNewDecWithPrec(2, 4) params.WeightBreakingFeeExponent = sdkmath.LegacyNewDecWithPrec(25, 1) // 2.5 params.WeightRecoveryFeePortion = sdkmath.LegacyNewDecWithPrec(50, 2) // 50% - tokenOut, _, _, weightBonus, _, err := pool.SwapOutAmtGivenIn(suite.ctx, suite.app.OracleKeeper, &pool, sdk.Coins{tc.tokenIn}, tc.outTokenDenom, tc.swapFee, suite.app.AccountedPoolKeeper, sdkmath.LegacyOneDec(), params) + tokenOut, _, _, weightBonus, _, _, err := pool.SwapOutAmtGivenIn(suite.ctx, suite.app.OracleKeeper, &pool, sdk.Coins{tc.tokenIn}, tc.outTokenDenom, tc.swapFee, suite.app.AccountedPoolKeeper, sdkmath.LegacyOneDec(), params) if tc.expErr { suite.Require().Error(err) suite.Require().EqualError(err, "token out amount is zero") diff --git a/x/perpetual/keeper/estimate_swap.go b/x/perpetual/keeper/estimate_swap.go index 00fd8185d..ba66fe2e3 100644 --- a/x/perpetual/keeper/estimate_swap.go +++ b/x/perpetual/keeper/estimate_swap.go @@ -37,7 +37,7 @@ func (k Keeper) EstimateSwapGivenIn(ctx sdk.Context, tokenInAmount sdk.Coin, tok // Estimate swap snapshot := k.amm.GetAccountedPoolSnapshotOrSet(ctx, ammPool) tokensIn := sdk.Coins{tokenInAmount} - tokenOut, slippage, _, weightBalanceBonus, _, err := k.amm.SwapOutAmtGivenIn(ctx, ammPool.PoolId, k.oracleKeeper, &snapshot, tokensIn, tokenOutDenom, perpetualFees, params.WeightBreakingFeeFactor) + tokenOut, slippage, _, weightBalanceBonus, _, _, err := k.amm.SwapOutAmtGivenIn(ctx, ammPool.PoolId, k.oracleKeeper, &snapshot, tokensIn, tokenOutDenom, perpetualFees, params.WeightBreakingFeeFactor) if err != nil { return math.ZeroInt(), math.LegacyZeroDec(), math.LegacyZeroDec(), errorsmod.Wrapf(err, "unable to swap (EstimateSwapGivenIn) for in %s and out denom %s", tokenInAmount.String(), tokenOutDenom) } @@ -65,7 +65,7 @@ func (k Keeper) EstimateSwapGivenOut(ctx sdk.Context, tokenOutAmount sdk.Coin, t // Estimate swap snapshot := k.amm.GetAccountedPoolSnapshotOrSet(ctx, ammPool) - tokenIn, slippage, _, weightBalanceBonus, _, err := k.amm.SwapInAmtGivenOut(ctx, ammPool.PoolId, k.oracleKeeper, &snapshot, tokensOut, tokenInDenom, perpetualFees, params.WeightBreakingFeeFactor) + tokenIn, slippage, _, weightBalanceBonus, _, _, err := k.amm.SwapInAmtGivenOut(ctx, ammPool.PoolId, k.oracleKeeper, &snapshot, tokensOut, tokenInDenom, perpetualFees, params.WeightBreakingFeeFactor) if err != nil { return math.ZeroInt(), math.LegacyZeroDec(), math.LegacyZeroDec(), errorsmod.Wrapf(err, "unable to swap (EstimateSwapGivenOut) for out %s and in denom %s", tokenOutAmount.String(), tokenInDenom) } diff --git a/x/perpetual/types/expected_keepers.go b/x/perpetual/types/expected_keepers.go index 52e6d916a..2974cadd8 100644 --- a/x/perpetual/types/expected_keepers.go +++ b/x/perpetual/types/expected_keepers.go @@ -2,6 +2,7 @@ package types import ( "context" + "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" ammtypes "github.com/elys-network/elys/x/amm/types" @@ -28,8 +29,8 @@ type AmmKeeper interface { GetAccountedPoolSnapshotOrSet(ctx sdk.Context, pool ammtypes.Pool) (val ammtypes.Pool) - SwapOutAmtGivenIn(ctx sdk.Context, poolId uint64, oracle ammtypes.OracleKeeper, snapshot *ammtypes.Pool, tokensIn sdk.Coins, tokenOutDenom string, swapFee math.LegacyDec, weightBreakingFeePerpetualFactor math.LegacyDec) (tokenOut sdk.Coin, slippage math.LegacyDec, slippageAmount math.LegacyDec, weightBalanceBonus, oracleOut math.LegacyDec, err error) - SwapInAmtGivenOut(ctx sdk.Context, poolId uint64, oracle ammtypes.OracleKeeper, snapshot *ammtypes.Pool, tokensOut sdk.Coins, tokenInDenom string, swapFee math.LegacyDec, weightBreakingFeePerpetualFactor math.LegacyDec) (tokenIn sdk.Coin, slippage, slippageAmount math.LegacyDec, weightBalanceBonus, oracleIn math.LegacyDec, err error) + SwapOutAmtGivenIn(ctx sdk.Context, poolId uint64, oracle ammtypes.OracleKeeper, snapshot *ammtypes.Pool, tokensIn sdk.Coins, tokenOutDenom string, swapFee math.LegacyDec, weightBreakingFeePerpetualFactor math.LegacyDec) (tokenOut sdk.Coin, slippage math.LegacyDec, slippageAmount math.LegacyDec, weightBalanceBonus, oracleOut math.LegacyDec, swapFeeFinal math.LegacyDec, err error) + SwapInAmtGivenOut(ctx sdk.Context, poolId uint64, oracle ammtypes.OracleKeeper, snapshot *ammtypes.Pool, tokensOut sdk.Coins, tokenInDenom string, swapFee math.LegacyDec, weightBreakingFeePerpetualFactor math.LegacyDec) (tokenIn sdk.Coin, slippage, slippageAmount math.LegacyDec, weightBalanceBonus, oracleIn math.LegacyDec, swapFeeFinal math.LegacyDec, err error) AddToPoolBalanceAndUpdateLiquidity(ctx sdk.Context, pool *ammtypes.Pool, addShares math.Int, coins sdk.Coins) error RemoveFromPoolBalanceAndUpdateLiquidity(ctx sdk.Context, pool *ammtypes.Pool, removeShares math.Int, coins sdk.Coins) error