diff --git a/CHANGELOG.md b/CHANGELOG.md index f433a951c5..4f122fea5c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -56,6 +56,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ - [2315](https://github.com/umee-network/umee/pull/2315) Improve reliability of MaxBorrow, MaxWithdraw when special asset pairs present. - [2346](https://github.com/umee-network/umee/pull/2346) Fix an issue where metokens were not included in historic data. +- [2365](https://github.com/umee-network/umee/pull/2365) Add fee to metoken price and balances query. ### Improvements diff --git a/proto/umee/metoken/v1/metoken.proto b/proto/umee/metoken/v1/metoken.proto index 0038bea00e..5339b16be6 100644 --- a/proto/umee/metoken/v1/metoken.proto +++ b/proto/umee/metoken/v1/metoken.proto @@ -153,4 +153,18 @@ message AssetPrice { (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false ]; + + // SwapFee charged to the user on a swap, expressed in fraction. + // Valid values: 0-1. + string swap_fee = 7 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + + // RedeemFee charged to the user on a redemption, expressed in fraction. + // Valid values: 0-1. + string redeem_fee = 8 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; } \ No newline at end of file diff --git a/swagger/swagger.yaml b/swagger/swagger.yaml index cc87e915ef..2bd7c1f4c9 100644 --- a/swagger/swagger.yaml +++ b/swagger/swagger.yaml @@ -1889,6 +1889,64 @@ paths: type: string tags: - Query + /umee/oracle/v1/miss_counters: + get: + summary: MissCounters returns oracle missing votes count of validators. + operationId: MissCounters + responses: + '200': + description: A successful response. + schema: + type: object + properties: + miss_counters: + type: array + items: + type: object + properties: + validator: + type: string + miss_counter: + type: string + format: uint64 + title: >- + miss_counter defines the oracle miss counter of a + validator + description: >- + PriceMissCounter is the validator's oracle price votes + missing count. + description: >- + QueryMissCountersResponse is response type for the + Query/MissCounters RPC method. + default: + description: An unexpected error response. + schema: + type: object + properties: + error: + type: string + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + type_url: + type: string + value: + type: string + format: byte + parameters: + - name: validator + in: query + required: false + type: string + tags: + - Query /umee/oracle/v1/params: get: summary: Params queries all parameters. @@ -2445,6 +2503,70 @@ paths: format: byte tags: - Query + /umee/uibc/v1/inflows: + get: + summary: >- + Inflows returns registered IBC denoms inflows in the current quota + period. + + If denom is not specified, returns sum of all registered inflows. + operationId: Inflows + responses: + '200': + description: A successful response. + schema: + type: object + properties: + sum: + type: string + inflows: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + DecCoin defines a token with a denomination and a decimal + amount. + + + NOTE: The amount field is an Dec which implements the custom + method + + signatures required by gogoproto. + title: QueryInflowsResponse defines response type of Query/Inflows + default: + description: An unexpected error response. + schema: + type: object + properties: + error: + type: string + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + type_url: + type: string + value: + type: string + format: byte + parameters: + - name: denom + in: query + required: false + type: string + tags: + - Query /umee/uibc/v1/outflows: get: summary: |- @@ -2576,6 +2698,44 @@ paths: format: byte tags: - Query + /umee/uibc/v1/quota_expires: + get: + summary: QuotaExpires returns when current ibc quota will end. + operationId: QuotaExpires + responses: + '200': + description: A successful response. + schema: + type: object + properties: + end_time: + type: string + format: date-time + title: QueryAllInflowsResponse defines response type of Query/AllInflows + default: + description: An unexpected error response. + schema: + type: object + properties: + error: + type: string + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + type_url: + type: string + value: + type: string + format: byte + tags: + - Query /umee/ugov/v1/emergency_group: get: summary: EmergencyGroup returns emergency group address @@ -3978,6 +4138,20 @@ paths: description: >- RedeemRate used for exchange calculations meToken -> asset. + swap_fee: + type: string + description: >- + SwapFee charged to the user on a swap, expressed + in fraction. + + Valid values: 0-1. + redeem_fee: + type: string + description: >- + RedeemFee charged to the user on a redemption, + expressed in fraction. + + Valid values: 0-1. description: >- AssetPrice information related to the index operations. @@ -4084,6 +4258,20 @@ paths: description: >- RedeemRate used for exchange calculations meToken -> asset. + swap_fee: + type: string + description: >- + SwapFee charged to the user on a swap, expressed + in fraction. + + Valid values: 0-1. + redeem_fee: + type: string + description: >- + RedeemFee charged to the user on a redemption, + expressed in fraction. + + Valid values: 0-1. description: >- AssetPrice information related to the index operations. @@ -6111,6 +6299,16 @@ definitions: type: string format: uint64 title: Price is an instance of a price "stamp" + umee.oracle.v1.PriceMissCounter: + type: object + properties: + validator: + type: string + miss_counter: + type: string + format: uint64 + title: miss_counter defines the oracle miss counter of a validator + description: PriceMissCounter is the validator's oracle price votes missing count. umee.oracle.v1.QueryActiveExchangeRatesResponse: type: object properties: @@ -6375,6 +6573,26 @@ definitions: description: |- QueryMissCounterResponse is response type for the Query/MissCounter RPC method. + umee.oracle.v1.QueryMissCountersResponse: + type: object + properties: + miss_counters: + type: array + items: + type: object + properties: + validator: + type: string + miss_counter: + type: string + format: uint64 + title: miss_counter defines the oracle miss counter of a validator + description: >- + PriceMissCounter is the validator's oracle price votes missing + count. + description: >- + QueryMissCountersResponse is response type for the Query/MissCounters RPC + method. umee.oracle.v1.QueryParamsResponse: type: object properties: @@ -6534,6 +6752,26 @@ definitions: NOTE: The amount field is an Dec which implements the custom method signatures required by gogoproto. title: QueryOutflowResponse defines response type of Query/Outflow + umee.uibc.v1.QueryInflowsResponse: + type: object + properties: + sum: + type: string + inflows: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: |- + DecCoin defines a token with a denomination and a decimal amount. + + NOTE: The amount field is an Dec which implements the custom method + signatures required by gogoproto. + title: QueryInflowsResponse defines response type of Query/Inflows umee.uibc.v1.QueryOutflowsResponse: type: object properties: @@ -6590,6 +6828,13 @@ definitions: description: |- QueryParamsResponse defines the response structure for the Params gRPC service handler. + umee.uibc.v1.QueryQuotaExpiresResponse: + type: object + properties: + end_time: + type: string + format: date-time + title: QueryAllInflowsResponse defines response type of Query/AllInflows umee.ugov.v1.InflationParams: type: object properties: @@ -7491,6 +7736,16 @@ definitions: redeem_rate: type: string description: RedeemRate used for exchange calculations meToken -> asset. + swap_fee: + type: string + description: |- + SwapFee charged to the user on a swap, expressed in fraction. + Valid values: 0-1. + redeem_fee: + type: string + description: |- + RedeemFee charged to the user on a redemption, expressed in fraction. + Valid values: 0-1. description: AssetPrice information related to the index operations. umee.metoken.v1.Fee: type: object @@ -7728,6 +7983,18 @@ definitions: redeem_rate: type: string description: RedeemRate used for exchange calculations meToken -> asset. + swap_fee: + type: string + description: |- + SwapFee charged to the user on a swap, expressed in fraction. + Valid values: 0-1. + redeem_fee: + type: string + description: >- + RedeemFee charged to the user on a redemption, expressed in + fraction. + + Valid values: 0-1. description: AssetPrice information related to the index operations. description: IndexPrices provides meToken price related index information. umee.metoken.v1.Params: @@ -7841,6 +8108,20 @@ definitions: description: >- RedeemRate used for exchange calculations meToken -> asset. + swap_fee: + type: string + description: >- + SwapFee charged to the user on a swap, expressed in + fraction. + + Valid values: 0-1. + redeem_fee: + type: string + description: >- + RedeemFee charged to the user on a redemption, expressed + in fraction. + + Valid values: 0-1. description: AssetPrice information related to the index operations. description: IndexPrices provides meToken price related index information. description: >- @@ -7896,6 +8177,20 @@ definitions: description: >- RedeemRate used for exchange calculations meToken -> asset. + swap_fee: + type: string + description: >- + SwapFee charged to the user on a swap, expressed in + fraction. + + Valid values: 0-1. + redeem_fee: + type: string + description: >- + RedeemFee charged to the user on a redemption, expressed + in fraction. + + Valid values: 0-1. description: AssetPrice information related to the index operations. description: IndexPrices provides meToken price related index information. description: >- diff --git a/util/coin/coin.go b/util/coin/coin.go index 545ad6dc43..7e433c7d8d 100644 --- a/util/coin/coin.go +++ b/util/coin/coin.go @@ -55,6 +55,11 @@ func ZeroDec(denom string) sdk.DecCoin { return sdk.NewInt64DecCoin(denom, 0) } +// One returns new coin with one amount +func One(denom string) sdk.Coin { + return sdk.NewInt64Coin(denom, 1) +} + // Normalize transform nil coins to empty list func Normalize(cs sdk.Coins) sdk.Coins { if cs == nil { diff --git a/x/metoken/client/tests/cli_test.go b/x/metoken/client/tests/cli_test.go index 141450cbaf..ec3fd0c3d9 100644 --- a/x/metoken/client/tests/cli_test.go +++ b/x/metoken/client/tests/cli_test.go @@ -1,6 +1,3 @@ -//go:build experimental -// +build experimental - package tests import ( diff --git a/x/metoken/client/tests/suite.go b/x/metoken/client/tests/suite.go index bd3571f68b..77a2b882a5 100644 --- a/x/metoken/client/tests/suite.go +++ b/x/metoken/client/tests/suite.go @@ -1,6 +1,3 @@ -//go:build experimental -// +build experimental - package tests import ( diff --git a/x/metoken/client/tests/tests.go b/x/metoken/client/tests/tests.go index 2bf970d8ce..64c9322731 100644 --- a/x/metoken/client/tests/tests.go +++ b/x/metoken/client/tests/tests.go @@ -1,6 +1,3 @@ -//go:build experimental -// +build experimental - package tests import ( @@ -106,7 +103,9 @@ func (s *IntegrationTests) TestValidQueries() { Price: sdk.MustNewDecFromStr("34.21"), Exponent: 6, SwapRate: sdk.OneDec(), + SwapFee: sdk.MustNewDecFromStr("0.01"), RedeemRate: sdk.OneDec(), + RedeemFee: sdk.MustNewDecFromStr("0.4"), }, }, }, diff --git a/x/metoken/keeper/fee.go b/x/metoken/keeper/fee.go index f3a16bac00..e043208caf 100644 --- a/x/metoken/keeper/fee.go +++ b/x/metoken/keeper/fee.go @@ -7,48 +7,56 @@ import ( ) // swapFee to be charged to the user, given a specific Index configuration and asset amount. +// It returns fee in fraction, fee amount and error. +// The fee in fraction represents the percentage of the fee, while the fee amount is the actual +// fee applied to the asset amount. func (k Keeper) swapFee(index metoken.Index, indexPrices metoken.IndexPrices, asset sdk.Coin) ( + sdk.Dec, sdk.Coin, error, ) { assetSettings, i := index.AcceptedAsset(asset.Denom) if i < 0 { - return sdk.Coin{}, sdkerrors.ErrNotFound.Wrapf("asset %s is not accepted in the index", asset.Denom) + return sdk.Dec{}, sdk.Coin{}, sdkerrors.ErrNotFound.Wrapf("asset %s is not accepted in the index", asset.Denom) } // charge max fee if we don't want the token in the index. if assetSettings.TargetAllocation.IsZero() { - return sdk.NewCoin(asset.Denom, index.Fee.MaxFee.MulInt(asset.Amount).TruncateInt()), nil + return index.Fee.MaxFee, sdk.NewCoin(asset.Denom, index.Fee.MaxFee.MulInt(asset.Amount).TruncateInt()), nil } currentAllocation, err := k.currentAllocation(index, indexPrices, asset.Denom) if err != nil { - return sdk.Coin{}, err + return sdk.Dec{}, sdk.Coin{}, err } // when current_allocation is zero, we incentivize the swap by charging only min_fee if currentAllocation.IsZero() { - return sdk.NewCoin(asset.Denom, index.Fee.MinFee.MulInt(asset.Amount).TruncateInt()), nil + return index.Fee.MinFee, sdk.NewCoin(asset.Denom, index.Fee.MinFee.MulInt(asset.Amount).TruncateInt()), nil } allocationDeviation := currentAllocation.Sub(assetSettings.TargetAllocation).Quo(assetSettings.TargetAllocation) fee := index.Fee.CalculateFee(allocationDeviation) - return sdk.NewCoin(asset.Denom, fee.MulInt(asset.Amount).TruncateInt()), nil + return fee, sdk.NewCoin(asset.Denom, fee.MulInt(asset.Amount).TruncateInt()), nil } // redeemFee to be charged to the user, given a specific Index configuration and asset amount. +// It returns fee in fraction, fee amount and error. +// The fee in fraction indicates the fee percentage, while the fee amount is the computed +// fee based on the asset amount being redeemed. func (k Keeper) redeemFee(index metoken.Index, indexPrices metoken.IndexPrices, asset sdk.Coin) ( + sdk.Dec, sdk.Coin, error, ) { assetSettings, i := index.AcceptedAsset(asset.Denom) if i < 0 { - return sdk.Coin{}, sdkerrors.ErrNotFound.Wrapf("asset %s is not accepted in the index", asset.Denom) + return sdk.Dec{}, sdk.Coin{}, sdkerrors.ErrNotFound.Wrapf("asset %s is not accepted in the index", asset.Denom) } // charge min fee if we don't want the token in the index. if assetSettings.TargetAllocation.IsZero() { - return sdk.NewCoin(asset.Denom, index.Fee.MinFee.MulInt(asset.Amount).TruncateInt()), nil + return index.Fee.MinFee, sdk.NewCoin(asset.Denom, index.Fee.MinFee.MulInt(asset.Amount).TruncateInt()), nil } allocationDeviation, err := k.redeemAllocationDeviation( @@ -58,11 +66,11 @@ func (k Keeper) redeemFee(index metoken.Index, indexPrices metoken.IndexPrices, assetSettings.TargetAllocation, ) if err != nil { - return sdk.Coin{}, err + return sdk.Dec{}, sdk.Coin{}, err } fee := index.Fee.CalculateFee(allocationDeviation) - return sdk.NewCoin(asset.Denom, fee.MulInt(asset.Amount).TruncateInt()), nil + return fee, sdk.NewCoin(asset.Denom, fee.MulInt(asset.Amount).TruncateInt()), nil } // currentAllocation returns a factor of the assetDenom supply in the index based on the USD price value. diff --git a/x/metoken/keeper/fee_test.go b/x/metoken/keeper/fee_test.go index 714c1c6aed..6e2ecb0956 100644 --- a/x/metoken/keeper/fee_test.go +++ b/x/metoken/keeper/fee_test.go @@ -22,7 +22,7 @@ func TestSwapFee(t *testing.T) { require.NoError(t, err) prices := meUSDIndexPricesAdjustedToBalance(t, balance) - _, err = k.swapFee(index, prices, sdk.NewCoin("inexistingAsset", sdkmath.ZeroInt())) + _, _, err = k.swapFee(index, prices, sdk.NewCoin("inexistingAsset", sdkmath.ZeroInt())) require.ErrorIs(t, err, sdkerrors.ErrNotFound) // target_allocation = 0 -> fee = max_fee * coin_amount @@ -34,20 +34,22 @@ func TestSwapFee(t *testing.T) { index.SetAcceptedAsset(usdtAsset) tenUSDT := sdk.NewCoin(mocks.USDTBaseDenom, sdkmath.NewInt(10_000000)) - fee, err := k.swapFee(index, prices, tenUSDT) + feeFraction, feeAmount, err := k.swapFee(index, prices, tenUSDT) require.NoError(t, err) - require.True(t, fee.Amount.Equal(sdkmath.NewInt(5_000000))) + require.True(t, feeAmount.Amount.Equal(sdkmath.NewInt(5_000000))) + require.True(t, feeFraction.Equal(sdk.MustNewDecFromStr("0.5"))) // swap_fee = balanced_fee + delta_allocation * balanced_fee - // swap_fee = 0.2 + (-0.276727736549164797) * 0.2 = 0.144654452690167041 + // swap_fee = 0.2 + (-0.276727736549164797) * 0.2 = 0.144654452690166976 // fee = swap_fee * coin_amount - // fee = 0.144654452690167041 * 10 = 1.44654452690167041 + // fee = 0.144654452690166976 * 10 = 1.44654452690166976 usdtAsset.TargetAllocation = sdk.MustNewDecFromStr("0.33") index.SetAcceptedAsset(usdtAsset) - fee, err = k.swapFee(index, prices, tenUSDT) + feeFraction, feeAmount, err = k.swapFee(index, prices, tenUSDT) require.NoError(t, err) - require.True(t, fee.Amount.Equal(sdkmath.NewInt(1_446544))) + require.True(t, feeAmount.Amount.Equal(sdkmath.NewInt(1_446544))) + require.True(t, feeFraction.Equal(sdk.MustNewDecFromStr("0.144654452690166976"))) } func TestRedeemFee(t *testing.T) { @@ -60,7 +62,7 @@ func TestRedeemFee(t *testing.T) { require.NoError(t, err) prices := meUSDIndexPricesAdjustedToBalance(t, balance) - _, err = k.redeemFee(index, prices, sdk.NewCoin("inexistingAsset", sdkmath.ZeroInt())) + _, _, err = k.redeemFee(index, prices, sdk.NewCoin("inexistingAsset", sdkmath.ZeroInt())) require.ErrorIs(t, err, sdkerrors.ErrNotFound) // target_allocation = 0 -> fee = min_fee * coin_amount @@ -72,18 +74,20 @@ func TestRedeemFee(t *testing.T) { index.SetAcceptedAsset(usdtAsset) tenUSDT := sdk.NewCoin(mocks.USDTBaseDenom, sdkmath.NewInt(10_000000)) - fee, err := k.redeemFee(index, prices, tenUSDT) + feeFraction, feeAmount, err := k.redeemFee(index, prices, tenUSDT) require.NoError(t, err) - require.True(t, fee.Amount.Equal(sdkmath.NewInt(100000))) + require.True(t, feeAmount.Amount.Equal(sdkmath.NewInt(100000))) + require.True(t, feeFraction.Equal(sdk.MustNewDecFromStr("0.01"))) // redeem_fee = balanced_fee + delta_allocation * balanced_fee - // redeem_fee = 0.2 + (0.276727736549164797) * 0.2 = 0.255345547309832959 + // redeem_fee = 0.2 + (0.276727736549164797) * 0.2 = 0.255345547309833024 // fee = redeem_fee * coin_amount - // fee = 0.255345547309832959 * 10 = 2.55345547309832959 + // fee = 0.255345547309833024 * 10 = 2.55345547309833024 usdtAsset.TargetAllocation = sdk.MustNewDecFromStr("0.33") index.SetAcceptedAsset(usdtAsset) - fee, err = k.redeemFee(index, prices, tenUSDT) + feeFraction, feeAmount, err = k.redeemFee(index, prices, tenUSDT) require.NoError(t, err) - require.True(t, fee.Amount.Equal(sdkmath.NewInt(2_553455))) + require.True(t, feeAmount.Amount.Equal(sdkmath.NewInt(2_553455))) + require.True(t, feeFraction.Equal(sdk.MustNewDecFromStr("0.255345547309833024"))) } diff --git a/x/metoken/keeper/grpc_query.go b/x/metoken/keeper/grpc_query.go index 7c4a9a8732..f342484b0e 100644 --- a/x/metoken/keeper/grpc_query.go +++ b/x/metoken/keeper/grpc_query.go @@ -72,12 +72,12 @@ func (q Querier) SwapFee(goCtx context.Context, req *metoken.QuerySwapFee) (*met } // calculate the fee for the asset amount - swapFee, err := k.swapFee(index, indexPrices, asset) + _, feeAmount, err := k.swapFee(index, indexPrices, asset) if err != nil { return nil, err } - return &metoken.QuerySwapFeeResponse{Asset: swapFee}, nil + return &metoken.QuerySwapFeeResponse{Asset: feeAmount}, nil } // RedeemFee returns the fee for the redeem operation, given a specific amount of meTokens and the asset denom. @@ -116,12 +116,12 @@ func (q Querier) RedeemFee(goCtx context.Context, req *metoken.QueryRedeemFee) ( // calculate the fee for the asset amount that would be given for a redemption toRedeem := sdk.NewCoin(req.AssetDenom, amountFromReserves.Add(amountFromLeverage)) - redeemFee, err := k.redeemFee(index, indexPrices, toRedeem) + _, feeAmount, err := k.redeemFee(index, indexPrices, toRedeem) if err != nil { return nil, err } - return &metoken.QueryRedeemFeeResponse{Asset: redeemFee}, nil + return &metoken.QueryRedeemFeeResponse{Asset: feeAmount}, nil } // IndexBalances returns balances from the x/metoken module. If index balance denom is not specified, diff --git a/x/metoken/keeper/intest/grpc_query_test.go b/x/metoken/keeper/intest/grpc_query_test.go index 39b84fb6c1..d0be650411 100644 --- a/x/metoken/keeper/intest/grpc_query_test.go +++ b/x/metoken/keeper/intest/grpc_query_test.go @@ -368,7 +368,9 @@ func TestQuerier_IndexPrices(t *testing.T) { for _, i := range resp.Prices { for _, a := range i.Assets { assert.Check(t, a.SwapRate.GT(sdk.ZeroDec())) + assert.Check(t, a.SwapFee.GT(sdk.ZeroDec())) assert.Check(t, a.RedeemRate.GT(sdk.ZeroDec())) + assert.Check(t, a.RedeemFee.GT(sdk.ZeroDec())) } } } else { diff --git a/x/metoken/keeper/price.go b/x/metoken/keeper/price.go index 16d2c6ca54..2432341414 100644 --- a/x/metoken/keeper/price.go +++ b/x/metoken/keeper/price.go @@ -7,6 +7,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/umee-network/umee/v6/util/coin" "github.com/umee-network/umee/v6/x/metoken" otypes "github.com/umee-network/umee/v6/x/oracle/types" ) @@ -83,14 +84,24 @@ func (k Keeper) Prices(index metoken.Index) (metoken.IndexPrices, error) { if err != nil { return indexPrices, err } + swapFee, _, err := k.swapFee(index, indexPrices, coin.One(asset.BaseDenom)) + if err != nil { + return indexPrices, err + } redeemRate, err := metoken.Rate(indexPrices.Price, asset.Price, indexPrices.Exponent, asset.Exponent) if err != nil { return indexPrices, err } + redeemFee, _, err := k.redeemFee(index, indexPrices, coin.One(asset.BaseDenom)) + if err != nil { + return indexPrices, err + } indexPrices.Assets[i].SwapRate = swapRate + indexPrices.Assets[i].SwapFee = swapFee indexPrices.Assets[i].RedeemRate = redeemRate + indexPrices.Assets[i].RedeemFee = redeemFee } return indexPrices, nil diff --git a/x/metoken/keeper/redeem.go b/x/metoken/keeper/redeem.go index ae08271161..0655b989da 100644 --- a/x/metoken/keeper/redeem.go +++ b/x/metoken/keeper/redeem.go @@ -93,7 +93,7 @@ func (k Keeper) redeem(userAddr sdk.AccAddress, meToken sdk.Coin, assetDenom str return redeemResponse{}, fmt.Errorf("not enough %s liquidity for redemption", assetDenom) } - fee, err := k.redeemFee( + _, feeAmount, err := k.redeemFee( index, indexPrices, sdk.NewCoin(assetDenom, amountFromReserves.Add(amountFromLeverage)), @@ -111,7 +111,7 @@ func (k Keeper) redeem(userAddr sdk.AccAddress, meToken sdk.Coin, assetDenom str return redeemResponse{}, err } - toRedeem := sdk.NewCoin(assetDenom, amountFromReserves.Add(amountFromLeverage).Sub(fee.Amount)) + toRedeem := sdk.NewCoin(assetDenom, amountFromReserves.Add(amountFromLeverage).Sub(feeAmount.Amount)) if err = k.bankKeeper.SendCoinsFromModuleToAccount( *k.ctx, metoken.ModuleName, @@ -127,7 +127,7 @@ func (k Keeper) redeem(userAddr sdk.AccAddress, meToken sdk.Coin, assetDenom str // update reserved, leveraged and fee balances balance.Reserved = balance.Reserved.Sub(amountFromReserves) balance.Leveraged = balance.Leveraged.Sub(amountFromLeverage) - balance.Fees = balance.Fees.Add(fee.Amount) + balance.Fees = balance.Fees.Add(feeAmount.Amount) balances.SetAssetBalance(balance) // save index balance @@ -141,7 +141,7 @@ func (k Keeper) redeem(userAddr sdk.AccAddress, meToken sdk.Coin, assetDenom str } return newRedeemResponse( - fee, + feeAmount, sdk.NewCoin(assetDenom, amountFromReserves), sdk.NewCoin(assetDenom, amountFromLeverage), ), nil diff --git a/x/metoken/keeper/swap.go b/x/metoken/keeper/swap.go index 1516d81b6e..a793a08f58 100644 --- a/x/metoken/keeper/swap.go +++ b/x/metoken/keeper/swap.go @@ -203,12 +203,12 @@ func (k Keeper) calculateSwap(index metoken.Index, indexPrices metoken.IndexPric ) } - fee, err := k.swapFee(index, indexPrices, asset) + _, feeAmount, err := k.swapFee(index, indexPrices, asset) if err != nil { return sdkmath.ZeroInt(), sdkmath.ZeroInt(), sdkmath.ZeroInt(), sdkmath.ZeroInt(), err } - amountToSwap := asset.Amount.Sub(fee.Amount) + amountToSwap := asset.Amount.Sub(feeAmount.Amount) meTokens, err := indexPrices.SwapRate(sdk.NewCoin(asset.Denom, amountToSwap)) if err != nil { @@ -218,5 +218,5 @@ func (k Keeper) calculateSwap(index metoken.Index, indexPrices metoken.IndexPric amountToReserves := assetSettings.ReservePortion.MulInt(amountToSwap).TruncateInt() amountToLeverage := amountToSwap.Sub(amountToReserves) - return meTokens, fee.Amount, amountToReserves, amountToLeverage, nil + return meTokens, feeAmount.Amount, amountToReserves, amountToLeverage, nil } diff --git a/x/metoken/metoken.pb.go b/x/metoken/metoken.pb.go index c0ed1dea21..1cccf000eb 100644 --- a/x/metoken/metoken.pb.go +++ b/x/metoken/metoken.pb.go @@ -352,6 +352,12 @@ type AssetPrice struct { SwapRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,5,opt,name=swap_rate,json=swapRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"swap_rate"` // RedeemRate used for exchange calculations meToken -> asset. RedeemRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,6,opt,name=redeem_rate,json=redeemRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"redeem_rate"` + // SwapFee charged to the user on a swap, expressed in fraction. + // Valid values: 0-1. + SwapFee github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,7,opt,name=swap_fee,json=swapFee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"swap_fee"` + // RedeemFee charged to the user on a redemption, expressed in fraction. + // Valid values: 0-1. + RedeemFee github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,8,opt,name=redeem_fee,json=redeemFee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"redeem_fee"` } func (m *AssetPrice) Reset() { *m = AssetPrice{} } @@ -420,47 +426,49 @@ func init() { func init() { proto.RegisterFile("umee/metoken/v1/metoken.proto", fileDescriptor_dda977db8ad52437) } var fileDescriptor_dda977db8ad52437 = []byte{ - // 639 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x94, 0xbf, 0x6f, 0xd3, 0x4e, - 0x14, 0xc0, 0xe3, 0x3a, 0xc9, 0xb7, 0x79, 0xe9, 0x8f, 0x6f,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64, 0x03, 0xe3, 0x09, 0x00, 0x25, 0x89, 0xcb, 0xc7, 0x51, 0x34, 0xca, 0x60, 0xb5, 0xce, - 0xfa, 0xe9, 0xf9, 0x46, 0xe9, 0xeb, 0xf9, 0xc6, 0xaa, 0xc7, 0x38, 0x65, 0x9c, 0xfb, 0x43, 0x2b, - 0x60, 0x36, 0x25, 0xe2, 0xc8, 0xda, 0x0f, 0x85, 0x53, 0xa3, 0x24, 0x79, 0x2d, 0xf3, 0x8d, 0x35, - 0x98, 0xc7, 0x24, 0x62, 0x21, 0x86, 0xa2, 0xa9, 0xb7, 0xb4, 0xf6, 0xa2, 0x73, 0x35, 0x36, 0x1e, - 0x80, 0x7e, 0x88, 0xd8, 0x2c, 0xb7, 0xb4, 0x76, 0x7d, 0xa7, 0x61, 0x5d, 0x3b, 0x22, 0xab, 0x87, - 0xd8, 0x29, 0xa7, 0x0b, 0x39, 0x69, 0x9a, 0xf1, 0x02, 0x96, 0x89, 0xe7, 0x61, 0x24, 0xd0, 0x77, - 0x09, 0xe7, 0x28, 0x78, 0xb3, 0xd2, 0xd2, 0xdb, 0xf5, 0x1d, 0xf3, 0x46, 0xe5, 0x9e, 0xca, 0xdb, - 0x4b, 0xd3, 0x14, 0x63, 0x89, 0x4c, 0x4f, 0x72, 0x25, 0xff, 0x53, 0x03, 0xbd, 0x87, 0x68, 0x3c, - 0x83, 0xff, 0x68, 0x10, 0xba, 0xe9, 0x76, 0xa4, 0x7c, 0xc7, 0x52, 0x86, 0xf7, 0x06, 0x81, 0x38, - 0x1a, 0xf7, 0x2d, 0x8f, 0x51, 0x3b, 0x93, 0x55, 0x9f, 0x2d, 0xee, 0x0f, 0x6d, 0x71, 0x12, 0x21, - 0xb7, 0xba, 0xe8, 0x39, 0x55, 0x1a, 0x84, 0x29, 0xe8, 0x15, 0x2c, 0x64, 0x17, 0x83, 0xbe, 0xa4, - 0xcd, 0x15, 0xa2, 0xd5, 0x73, 0x46, 0xbe, 0x37, 0x92, 0x48, 0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0xe9, 0xe9, 0x85, 0xa9, 0x9d, 0x5d, 0x98, 0xda, 0xb7, 0x0b, 0x53, 0xfb, 0x70, 0x69, 0x96, - 0xce, 0x2e, 0xcd, 0xd2, 0x97, 0x4b, 0xb3, 0xf4, 0xf6, 0xfe, 0x14, 0x33, 0xbd, 0xab, 0xad, 0x10, - 0xc5, 0x31, 0x8b, 0x87, 0x72, 0x60, 0x4f, 0x1e, 0xda, 0x49, 0xfe, 0xb2, 0xf7, 0xab, 0xf2, 0xcd, - 0xde, 0xfd, 0x1d, 0x00, 0x00, 0xff, 0xff, 0x4a, 0x84, 0x01, 0x0c, 0xfb, 0x05, 0x00, 0x00, + // 663 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x95, 0x4f, 0x6f, 0xd3, 0x4a, + 0x10, 0xc0, 0xe3, 0x3a, 0x49, 0x9b, 0x49, 0xff, 0xbc, 0x5a, 0xa9, 0x14, 0xf5, 0xa9, 0x6e, 0x5e, + 0x0f, 0x4f, 0x41, 0xa2, 0xb6, 0xda, 0x4a, 0x48, 0x20, 0x2e, 0x0d, 0x51, 0x50, 0x85, 0x10, 0xc5, + 0x1c, 0x90, 0xe0, 0x60, 0x6d, 0xec, 0x69, 0x6a, 0x25, 0xeb, 0x35, 0xde, 0x4d, 0xea, 0x7e, 0x0b, + 0x3e, 0x02, 0x9f, 0x06, 0xf5, 0xd8, 0x23, 0xe2, 0x50, 0x41, 0x7b, 0xe1, 0x84, 0x38, 0x73, 0x42, + 0x5e, 0xaf, 0x43, 0xda, 0xaa, 0x1c, 0x2c, 0x4e, 0xf1, 0xee, 0xcc, 0xfc, 0x76, 0x7e, 0xf6, 0x38, + 0x86, 0x8d, 0x31, 0x45, 0xb4, 0x29, 0x0a, 0x36, 0xc4, 0xd0, 0x9e, 0xec, 0xe4, 0x97, 0x56, 0x14, + 0x33, 0xc1, 0x8c, 0x95, 0x34, 0x6c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, 0xa3, 0x5a, 0x96, 0xa3, 0xfa, 0xef, 0xed, 0x51, 0x4d, 0xc3, 0xb2, 0x4b, 0x35, 0xa7, + 0xaa, 0x40, 0x89, 0x7c, 0xd7, 0x01, 0x7e, 0xa7, 0x18, 0x1b, 0x00, 0x7d, 0xc2, 0xd1, 0x9d, 0x95, + 0xa9, 0xa5, 0x3b, 0x5d, 0x29, 0xf4, 0x1f, 0x2c, 0xf2, 0x53, 0xda, 0x67, 0x23, 0x95, 0x20, 0xbd, + 0x9c, 0x7a, 0xb6, 0xd7, 0xbd, 0xee, 0xac, 0xff, 0x2d, 0xe7, 0xf2, 0x0d, 0xe7, 0x67, 0x50, 0xe3, + 0x27, 0x24, 0x72, 0x63, 0x22, 0xb0, 0x59, 0x29, 0x74, 0xca, 0x42, 0x0a, 0x70, 0x88, 0x40, 0xe3, + 0x05, 0xd4, 0x63, 0xf4, 0x11, 0x69, 0x86, 0xab, 0x16, 0xc2, 0x41, 0x86, 0x90, 0xc0, 0x03, 0x90, + 0x70, 0xf9, 0x36, 0xcd, 0x17, 0xa2, 0xcd, 0xa7, 0xf5, 0x3d, 0xf9, 0x87, 0xa4, 0xc0, 0x12, 0xb6, + 0x50, 0x08, 0x56, 0xcb, 0x08, 0xd3, 0xb7, 0xb3, 0xf3, 0xe4, 0xec, 0xd2, 0xd4, 0xce, 0x2f, 0x4d, + 0xed, 0xcb, 0xa5, 0xa9, 0xbd, 0xbf, 0x32, 0x4b, 0xe7, 0x57, 0x66, 0xe9, 0xd3, 0x95, 0x59, 0x7a, + 0x73, 0x6f, 0x06, 0x99, 0x4e, 0xd1, 0x76, 0x88, 0xe2, 0x84, 0xc5, 0x43, 0xb9, 0xb0, 0x27, 0x0f, + 0xec, 0x24, 0xff, 0xe6, 0xf4, 0xab, 0xf2, 0x6b, 0xb2, 0xf7, 0x2b, 0x00, 0x00, 0xff, 0xff, 0x85, + 0xaa, 0x30, 0x53, 0x95, 0x06, 0x00, 0x00, } func (this *Params) Equal(that interface{}) bool { @@ -666,6 +674,12 @@ func (this *AssetPrice) Equal(that interface{}) bool { if !this.RedeemRate.Equal(that1.RedeemRate) { return false } + if !this.SwapFee.Equal(that1.SwapFee) { + return false + } + if !this.RedeemFee.Equal(that1.RedeemFee) { + return false + } return true } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -952,6 +966,26 @@ func (m *AssetPrice) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + { + size := m.RedeemFee.Size() + i -= size + if _, err := m.RedeemFee.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintMetoken(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x42 + { + size := m.SwapFee.Size() + i -= size + if _, err := m.SwapFee.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintMetoken(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x3a { size := m.RedeemRate.Size() i -= size @@ -1135,6 +1169,10 @@ func (m *AssetPrice) Size() (n int) { n += 1 + l + sovMetoken(uint64(l)) l = m.RedeemRate.Size() n += 1 + l + sovMetoken(uint64(l)) + l = m.SwapFee.Size() + n += 1 + l + sovMetoken(uint64(l)) + l = m.RedeemFee.Size() + n += 1 + l + sovMetoken(uint64(l)) return n } @@ -2119,6 +2157,74 @@ func (m *AssetPrice) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SwapFee", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetoken + } + 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 ErrInvalidLengthMetoken + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMetoken + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.SwapFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RedeemFee", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetoken + } + 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 ErrInvalidLengthMetoken + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMetoken + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.RedeemFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipMetoken(dAtA[iNdEx:]) diff --git a/x/metoken/mocks/metoken.go b/x/metoken/mocks/metoken.go index ef43573282..fa3c1907f1 100644 --- a/x/metoken/mocks/metoken.go +++ b/x/metoken/mocks/metoken.go @@ -124,7 +124,7 @@ func EmptyNonStableIndexBalances(denom string) metoken.IndexBalances { return metoken.NewIndexBalances( sdk.NewCoin(denom, sdkmath.ZeroInt()), []metoken.AssetBalance{ - metoken.NewZeroAssetBalance(USDTBaseDenom), + metoken.NewZeroAssetBalance(CMSTBaseDenom), metoken.NewZeroAssetBalance(WBTCBaseDenom), metoken.NewZeroAssetBalance(ETHBaseDenom), },