diff --git a/app/setup_handlers.go b/app/setup_handlers.go index ddc61a7dc2..9d52c8ce22 100644 --- a/app/setup_handlers.go +++ b/app/setup_handlers.go @@ -4,11 +4,10 @@ import ( storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" m "github.com/cosmos/cosmos-sdk/types/module" - "github.com/cosmos/cosmos-sdk/x/authz" "github.com/cosmos/cosmos-sdk/x/upgrade/types" ) -const releaseVersion = "0.16.0" +const releaseVersion = "0.17.0" func SetupHandlers(app *SifchainApp) { app.UpgradeKeeper.SetUpgradeHandler(releaseVersion, func(ctx sdk.Context, plan types.Plan, vm m.VersionMap) (m.VersionMap, error) { @@ -21,9 +20,7 @@ func SetupHandlers(app *SifchainApp) { panic(err) } if upgradeInfo.Name == releaseVersion && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) { - storeUpgrades := storetypes.StoreUpgrades{ - Added: []string{authz.ModuleName}, - } + storeUpgrades := storetypes.StoreUpgrades{} // Use upgrade store loader for the initial loading of all stores when app starts, // it checks if version == upgradeHeight and applies store upgrades before loading the stores, // so that new stores start with the correct version (the current height of chain), diff --git a/docs/proposals/fixed_rate_swap_fees.md b/docs/proposals/fixed_rate_swap_fees.md new file mode 100644 index 0000000000..3e20c273d8 --- /dev/null +++ b/docs/proposals/fixed_rate_swap_fees.md @@ -0,0 +1,77 @@ +# Fixed Rate Swap Fees + +Sifchain is switching from a slip-based fee model to a fixed-rate fee model. This requires +the swap formula and the liquidity fee formula within sifnode to be updated. + +## Fixed-rate formuals + +Due to ratio shifting, the updated swap and liquidity fee formulas depend on whether the swap is +from Rowan or to Rowan. + +In the following formulas: + +``` +X - Input balance +Y - Output balance +x - Input amount +y - Output amount +r - Current ratio shifting running rate +f - Swap fee rate. This must satisfy `0 =< f =< 1` +``` + +### Swapping to Rowan: + +``` +y = (1 - f) * x * Y / ((x + X)(1 + r)) +fee = f * x * Y / ((x + X)(1 + r)) +``` + +### Swapping from Rowan: + +``` +y = (1 - f) * (1 + r) * x * Y / (x + X) +fee = f * (1 + r) * x * Y / (x + X) +``` + +## Changing the swap rate fee + +The swap fee rate, `f`, in the above formulas must be updatable with a regular Cosmos transaction +however the transaction must be signed by the PMTP/rewards admin key. The swap rate fee must +satisfy `0 =< f =< 1` otherwise the transaction is rejected. + +## Events + +There are no new events or updates to existing events. + +## CLI + +CLI options for setting and querying the swap fee rate must be implemented. + +### Setting + +The CLI should validate that the value of the swap rate fee satisfies `0 =< f =< 1` + +```bash +sifnoded tx clp set-swap-fee-rate \ + --from sif \ + --swapFeeRate 0.01 \ + --keyring-backend test \ + --fees 100000000000000000rowan \ + --chain-id localnet \ + -y +``` + +### Querying + +```bash +sifnoded q clp swap-fee-rate --output json +``` + +```json +{ + "swap_fee_rate": "0.010000000000000000" +} +``` +## References + +Background on the use of fixed rate fee swap formula for asymmetric adds https://hackmd.io/NjvaZY1qQiS17s_uEgZmTw?both \ No newline at end of file diff --git a/docs/tutorials/swap-fee-rate.md b/docs/tutorials/swap-fee-rate.md new file mode 100644 index 0000000000..d6fc3064d3 --- /dev/null +++ b/docs/tutorials/swap-fee-rate.md @@ -0,0 +1,279 @@ +# Fixed Rate Fee Model + +The swap formula uses the fixed rate fee model to calculate swap fees and consequently +the amount of received token. + +## Formulas + +Due to ratio shifting the formula depends on whether the swap is from Rowan or to Rowan. + +In the following formulas: + +``` +X - Input balance +Y - Output balance +x - Input amount +y - Output amount +r - Current ratio shifting running rate +f - Swap fee rate +``` + +### Swapping to Rowan: + +``` +y = (1 - f) * x * Y / ((x + X)(1 + r)) +fee = f * x * Y / ((x + X)(1 + r)) +``` +### Swapping rom Rowan: + +``` +y = (1 - f) * (1 + r) * x * Y / (x + X) +fee = f * (1 + r) * x * Y / (x + X) +``` + +## Examples + +1. Start and run the chain: + +```bash +make init +make run +``` + +2. Create a pool: + +```bash +sifnoded tx clp create-pool \ + --from sif \ + --keyring-backend test \ + --symbol ceth \ + --nativeAmount 2000000000000000000 \ + --externalAmount 2000000000000000000 \ + --fees 100000000000000000rowan \ + --chain-id localnet \ + -y +``` + +3. Confirm pool has been created: + +```bash +sifnoded q clp pools --output json | jq +``` + +returns: + +```json +{ + "pools": [{ + "external_asset": { + "symbol": "ceth" + }, + "native_asset_balance": "2000000000000000000", + "external_asset_balance": "2000000000000000000", + "pool_units": "2000000000000000000", + "swap_price_native": "1.000000000000000000", + "swap_price_external": "1.000000000000000000", + "reward_period_native_distributed": "0" + }], + "clp_module_address": "sif1pjm228rsgwqf23arkx7lm9ypkyma7mzr3y2n85", + "height": "50", + "pagination": { + "next_key": null, + "total": "0" + } +} +``` + +4. Query the current swap fee rate: + +```bash +sifnoded q clp swap-fee-rate --output json | jq +``` + +```json +{ + "swap_fee_rate": "0.003000000000000000" +} +``` + +5. Do a swap: + +``` +sifnoded tx clp swap \ + --from sif \ + --keyring-backend test \ + --sentSymbol ceth \ + --receivedSymbol rowan \ + --sentAmount 200000000000000 \ + --minReceivingAmount 0 \ + --fees 100000000000000000rowan \ + --chain-id localnet \ + -y +``` + +This will return a tx hash. + +6. Use the tx hash to get the swap amount and liquidity fee: + +```bash +TXHASH=1AB7D2B0C4EDC2B18893334E60BFCF3C3F9587314082D314CA641D895F216E62 +sifnoded q tx $TXHASH --output json | jq '.logs[0].events[] | select(.type=="swap_successful").attributes[] | select(.key=="swap_amount" or .key=="liquidity_fee")' +``` + +which returns: + +```json +{ + "key": "swap_amount", + "value": "199380061993800" +} +{ + "key": "liquidity_fee", + "value": "599940005999" +} +``` + +The swap amount is as expected: +``` +y = (1 - f) * x * Y / ((x + X)(1 + r)) + = (1 - 0.003) * 200000000000000 * 2000000000000000000 / ((200000000000000 + 2000000000000000000) * (1 + 0)) + = 199380061993800 +``` + +And the swap fee is as expected +``` +fee = f * x * Y / ((x + X)(1 + r)) + = 0.003 * 200000000000000 * 2000000000000000000 / ((200000000000000 + 2000000000000000000) * (1 + 0)) + = 599940005999 +``` + +7. Check the pool balances + +```bash +sifnoded q clp pools --output json | jq +``` + +```json + { + "native_asset_balance": "1999800619938006200", + "external_asset_balance": "2000200000000000000" + } +``` + +These are as expected: +``` +native_asset_balance = init_native - y + = 2000000000000000000 - 199380061993800 + = 1999800619938006200 + + +external_asset_balance = init_external + x + = 2000000000000000000 + 200000000000000 + = 2000200000000000000 +``` +8. Change the swap fee rate to 0.01 + +```bash +sifnoded tx clp set-swap-fee-rate \ + --from sif \ + --swapFeeRate 0.01 \ + --keyring-backend test \ + --fees 100000000000000000rowan \ + --chain-id localnet \ + -y +``` + +Confirm the new rate: + +```bash +sifnoded q clp swap-fee-rate --output json | jq +``` + +```json +{ + "swap_fee_rate": "0.010000000000000000" +} +``` + +9. Do another swap, this time the other way around (rowan to ceth): + +``` +sifnoded tx clp swap \ + --from sif \ + --keyring-backend test \ + --sentSymbol rowan \ + --receivedSymbol ceth \ + --sentAmount 200000000000000 \ + --minReceivingAmount 0 \ + --fees 100000000000000000rowan \ + --chain-id localnet \ + -y +``` + +10. Repeat steps 6 & 7, confirm the results: + +```json +{ + "key": "swap_amount", + "value": "198019738620019" +} +{ + "key": "liquidity_fee", + "value": "2000199380000" +} +``` + +```json +{ + "native_asset_balance": "2000000619938006200", + "external_asset_balance": "2000001980261379981" +} +``` + +Which are as expected: +``` +y = (1 - f) * (1 + r) * x * Y / (x + X) + = (1 - 0.01) * (1 + 0) * 200000000000000 * 2000200000000000000 / (200000000000000 + 1999800619938006200) + = 198019738620019 + +fee = f * (1 + r) * x * Y / (x + X) + = 0.01 * (1 + 0) * 200000000000000 * 2000200000000000000 / ((200000000000000 + 1999800619938006200)) + = 2000199380000 + +native_asset_balance = init_native + x + = 1999800619938006200 + 200000000000000 + = 2000000619938006200 + +external_asset_balance = init_external - y + = 2000200000000000000 - 198019738620019 + = 2000001980261379981 +``` +10. Try to change swap fee > 1. This should fail: + +``` +sifnoded tx clp set-swap-fee-rate \ + --from sif \ + --swapFeeRate 1.00001 \ + --keyring-backend test \ + --fees 100000000000000000rowan \ + --chain-id localnet \ + -y +``` + +Which returns: + +`Error: swap rate fee must be less than or equal to one` + +11. Try to change swap fee < 0. This should fail: + +``` +sifnoded tx clp set-swap-fee-rate \ + --from sif \ + --swapFeeRate -0.0001 \ + --keyring-backend test \ + --fees 100000000000000000rowan \ + --chain-id localnet \ + -y +``` + +`Error: swap rate fee must be greater than or equal to zero` diff --git a/proto/sifnode/clp/v1/params.proto b/proto/sifnode/clp/v1/params.proto index d23d926312..082e620331 100644 --- a/proto/sifnode/clp/v1/params.proto +++ b/proto/sifnode/clp/v1/params.proto @@ -94,4 +94,11 @@ message ProviderDistributionPeriod { message ProviderDistributionParams { repeated ProviderDistributionPeriod distribution_periods = 1; +} + +message SwapFeeRate { + string swap_fee_rate = 1 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; } \ No newline at end of file diff --git a/proto/sifnode/clp/v1/querier.proto b/proto/sifnode/clp/v1/querier.proto index 1bed28e0e5..95810e559c 100644 --- a/proto/sifnode/clp/v1/querier.proto +++ b/proto/sifnode/clp/v1/querier.proto @@ -54,6 +54,9 @@ service Query { rpc GetProviderDistributionParams(ProviderDistributionParamsReq) returns (ProviderDistributionParamsRes) { option (google.api.http).get = "/sifchain/clp/v1/provider_distribution_params"; }; + rpc GetSwapFeeRate(SwapFeeRateReq) returns (SwapFeeRateRes) { + option (google.api.http).get = "/sifchain/clp/v1/swap_fee_rate"; + }; } message PoolReq { @@ -189,4 +192,13 @@ message ProviderDistributionParamsReq {} message ProviderDistributionParamsRes { ProviderDistributionParams params = 1; +} + +message SwapFeeRateReq {} + +message SwapFeeRateRes { + string swap_fee_rate = 1 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; } \ No newline at end of file diff --git a/proto/sifnode/clp/v1/tx.proto b/proto/sifnode/clp/v1/tx.proto index a5ca4adfa1..9401e53ad1 100644 --- a/proto/sifnode/clp/v1/tx.proto +++ b/proto/sifnode/clp/v1/tx.proto @@ -34,6 +34,7 @@ service Msg { rpc UpdateLiquidityProtectionParams(MsgUpdateLiquidityProtectionParams) returns (MsgUpdateLiquidityProtectionParamsResponse); rpc ModifyLiquidityProtectionRates(MsgModifyLiquidityProtectionRates) returns (MsgModifyLiquidityProtectionRatesResponse); rpc AddProviderDistributionPeriod(MsgAddProviderDistributionPeriodRequest) returns (MsgAddProviderDistributionPeriodResponse); + rpc UpdateSwapFeeRate(MsgUpdateSwapFeeRateRequest) returns (MsgUpdateSwapFeeRateResponse); } // message MsgUpdateStakingRewardParams{ @@ -270,3 +271,13 @@ message MsgAddProviderDistributionPeriodRequest { } message MsgAddProviderDistributionPeriodResponse {} + +message MsgUpdateSwapFeeRateRequest { + string signer = 1 [ (gogoproto.moretags) = "yaml:\"signer\"" ]; + string swap_fee_rate = 2 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; +} + +message MsgUpdateSwapFeeRateResponse {} diff --git a/version b/version index 04a373efe6..c5523bd09b 100644 --- a/version +++ b/version @@ -1 +1 @@ -0.16.0 +0.17.0 diff --git a/x/clp/client/cli/flags.go b/x/clp/client/cli/flags.go index 61cc39c034..1ea3750396 100644 --- a/x/clp/client/cli/flags.go +++ b/x/clp/client/cli/flags.go @@ -38,6 +38,7 @@ const ( FlagCurrentRowanLiquidityThreshold = "currentRowanLiquidityThreshold" FlagLiquidityProtectionIsActive = "isActive" FlagProviderDistributionPeriods = "path" + FlagSwapFeeRate = "swapFeeRate" ) // common flagsets to add to various functions @@ -75,6 +76,7 @@ var ( FsLiquidityProtectionEpochLength = flag.NewFlagSet("", flag.ContinueOnError) FsCurrentRowanLiquidityThreshold = flag.NewFlagSet("", flag.ContinueOnError) FsFlagProviderDistributionPeriods = flag.NewFlagSet("", flag.ContinueOnError) + FsFlagSwapFeeRate = flag.NewFlagSet("", flag.ContinueOnError) ) func init() { @@ -112,4 +114,5 @@ func init() { FsLiquidityThresholdIsActive.String(FlagLiquidityProtectionIsActive, "", "Set liquidity protection isActive") FsCurrentRowanLiquidityThreshold.String(FlagCurrentRowanLiquidityThreshold, "", "Set current rowan liquidity threshold value") FsFlagProviderDistributionPeriods.String(FlagProviderDistributionPeriods, "", "Path to Json File containing LP provider distribution periods") + FsFlagSwapFeeRate.String(FlagSwapFeeRate, "", "Set swap fee rate") } diff --git a/x/clp/client/cli/query.go b/x/clp/client/cli/query.go index d75cf5a95f..db01302392 100644 --- a/x/clp/client/cli/query.go +++ b/x/clp/client/cli/query.go @@ -35,6 +35,7 @@ func GetQueryCmd(queryRoute string) *cobra.Command { GetCmdPmtpParams(queryRoute), GetCmdLiquidityProtectionParams(queryRoute), GetCmdProviderDistributionParams(queryRoute), + GetCmdSwapFeeRate(queryRoute), ) return clpQueryCmd } @@ -374,3 +375,25 @@ func GetCmdProviderDistributionParams(queryRoute string) *cobra.Command { flags.AddQueryFlagsToCmd(cmd) return cmd } + +func GetCmdSwapFeeRate(queryRoute string) *cobra.Command { + cmd := &cobra.Command{ + Use: "swap-fee-rate", + Short: "Get swap fee rate", + Args: cobra.ExactArgs(0), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + queryClient := types.NewQueryClient(clientCtx) + result, err := queryClient.GetSwapFeeRate(context.Background(), &types.SwapFeeRateReq{}) + if err != nil { + return err + } + return clientCtx.PrintProto(result) + }, + } + flags.AddQueryFlagsToCmd(cmd) + return cmd +} diff --git a/x/clp/client/cli/tx.go b/x/clp/client/cli/tx.go index a8c8643f54..b91a0bea9e 100644 --- a/x/clp/client/cli/tx.go +++ b/x/clp/client/cli/tx.go @@ -47,6 +47,7 @@ func GetTxCmd() *cobra.Command { GetCmdUpdateLiquidityProtectionParams(), GetCmdModifyLiquidityProtectionRates(), GetCmdSetProviderDistributionPeriods(), + GetCmdSetSwapFeeRate(), ) return clpTxCmd @@ -158,6 +159,42 @@ func GetCmdSetSymmetryThreshold() *cobra.Command { return cmd } +func GetCmdSetSwapFeeRate() *cobra.Command { + cmd := &cobra.Command{ + Use: "set-swap-fee-rate", + Short: "Set swap fee rate", + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + signer := clientCtx.GetFromAddress() + if err != nil { + return err + } + swapFeeRate, err := sdk.NewDecFromStr(viper.GetString(FlagSwapFeeRate)) + if err != nil { + return err + } + + msg := types.MsgUpdateSwapFeeRateRequest{ + Signer: signer.String(), + SwapFeeRate: swapFeeRate, + } + if err := msg.ValidateBasic(); err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg) + }, + } + cmd.Flags().AddFlagSet(FsFlagSwapFeeRate) + if err := cmd.MarkFlagRequired(FlagSwapFeeRate); err != nil { + log.Println("MarkFlagRequired failed: ", err.Error()) + } + flags.AddTxFlagsToCmd(cmd) + return cmd +} + func GetCmdCreatePool() *cobra.Command { cmd := &cobra.Command{ Use: "create-pool --from [key] --symbol [asset-symbol] --nativeAmount [amount] --externalAmount [amount]", diff --git a/x/clp/handler.go b/x/clp/handler.go index becbb2e229..d8ab51329d 100644 --- a/x/clp/handler.go +++ b/x/clp/handler.go @@ -64,6 +64,9 @@ func NewHandler(k keeper.Keeper) sdk.Handler { case *types.MsgAddProviderDistributionPeriodRequest: res, err := msgServer.AddProviderDistributionPeriod(sdk.WrapSDKContext(ctx), msg) return sdk.WrapServiceResult(ctx, res, err) + case *types.MsgUpdateSwapFeeRateRequest: + res, err := msgServer.UpdateSwapFeeRate(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) default: errMsg := fmt.Sprintf("unrecognized %s message type: %T", types.ModuleName, msg) return nil, errors.Wrap(errors.ErrUnknownRequest, errMsg) diff --git a/x/clp/handler_FEATURE_TOGGLE_MARGIN_CLI_ALPHA_test.go b/x/clp/handler_FEATURE_TOGGLE_MARGIN_CLI_ALPHA_test.go index c4332d4cd1..58123a128d 100644 --- a/x/clp/handler_FEATURE_TOGGLE_MARGIN_CLI_ALPHA_test.go +++ b/x/clp/handler_FEATURE_TOGGLE_MARGIN_CLI_ALPHA_test.go @@ -16,9 +16,9 @@ func FEATURE_TOGGLE_MARGIN_CLI_ALPHA_SwapOne(ctx sdk.Context, sentAmount sdk.Uint, nativeAsset types.Asset, inPool types.Pool, - pmtpCurrentRunningRate sdk.Dec) (sdk.Uint, sdk.Uint, sdk.Uint, types.Pool, error) { + pmtpCurrentRunningRate, swapFeeRate sdk.Dec) (sdk.Uint, sdk.Uint, sdk.Uint, types.Pool, error) { marginEnabled := k.GetMarginKeeper().IsPoolEnabled(ctx, inPool.String()) - return clpkeeper.SwapOne(sentAsset, sentAmount, nativeAsset, inPool, pmtpCurrentRunningRate, marginEnabled) + return clpkeeper.SwapOne(sentAsset, sentAmount, nativeAsset, inPool, pmtpCurrentRunningRate, swapFeeRate, marginEnabled) } func FEATURE_TOGGLE_MARGIN_CLI_ALPHA_GetSwapFee(ctx sdk.Context, @@ -26,7 +26,7 @@ func FEATURE_TOGGLE_MARGIN_CLI_ALPHA_GetSwapFee(ctx sdk.Context, ReceivedAsset *types.Asset, liquidityFeeNative sdk.Uint, outPool types.Pool, - pmtpCurrentRunningRate sdk.Dec) sdk.Uint { + pmtpCurrentRunningRate, swapFeeRate sdk.Dec) sdk.Uint { marginEnabled := k.GetMarginKeeper().IsPoolEnabled(ctx, outPool.String()) - return clpkeeper.GetSwapFee(liquidityFeeNative, *ReceivedAsset, outPool, pmtpCurrentRunningRate, marginEnabled) + return clpkeeper.GetSwapFee(liquidityFeeNative, *ReceivedAsset, outPool, pmtpCurrentRunningRate, swapFeeRate, marginEnabled) } diff --git a/x/clp/handler_NO_FEATURE_TOGGLE_MARGIN_CLI_ALPHA_test.go b/x/clp/handler_NO_FEATURE_TOGGLE_MARGIN_CLI_ALPHA_test.go index 15f24d2ed6..295df7881e 100644 --- a/x/clp/handler_NO_FEATURE_TOGGLE_MARGIN_CLI_ALPHA_test.go +++ b/x/clp/handler_NO_FEATURE_TOGGLE_MARGIN_CLI_ALPHA_test.go @@ -16,8 +16,8 @@ func FEATURE_TOGGLE_MARGIN_CLI_ALPHA_SwapOne(ctx sdk.Context, sentAmount sdk.Uint, nativeAsset types.Asset, inPool types.Pool, - pmtpCurrentRunningRate sdk.Dec) (sdk.Uint, sdk.Uint, sdk.Uint, types.Pool, error) { - return clpkeeper.SwapOne(sentAsset, sentAmount, nativeAsset, inPool, pmtpCurrentRunningRate) + pmtpCurrentRunningRate, swapFeeRate sdk.Dec) (sdk.Uint, sdk.Uint, sdk.Uint, types.Pool, error) { + return clpkeeper.SwapOne(sentAsset, sentAmount, nativeAsset, inPool, pmtpCurrentRunningRate, swapFeeRate) } /* func FEATURE_TOGGLE_MARGIN_CLI_ALPHA_GetSwapFee(ctx sdk.Context, diff --git a/x/clp/handler_test.go b/x/clp/handler_test.go index 7727632d6e..deca1cdd36 100644 --- a/x/clp/handler_test.go +++ b/x/clp/handler_test.go @@ -398,13 +398,13 @@ func CalculateWithdraw(t *testing.T, keeper clpkeeper.Keeper, ctx sdk.Context, a _, err = app.TokenRegistryKeeper.GetEntry(registry, pool.ExternalAsset.Symbol) assert.NoError(t, err) if asymmetry.IsPositive() { - swapResult, _, _, _, err := FEATURE_TOGGLE_MARGIN_CLI_ALPHA_SwapOne(ctx, app.ClpKeeper, clptypes.GetSettlementAsset(), swapAmount, asset, pool, sdk.OneDec()) + swapResult, _, _, _, err := FEATURE_TOGGLE_MARGIN_CLI_ALPHA_SwapOne(ctx, app.ClpKeeper, clptypes.GetSettlementAsset(), swapAmount, asset, pool, sdk.OneDec(), sdk.NewDecWithPrec(3, 3)) assert.NoError(t, err) externalAssetCoin = sdk.NewCoin(asset.Symbol, sdk.Int(withdrawExternalAssetAmount.Add(swapResult))) nativeAssetCoin = sdk.NewCoin(clptypes.GetSettlementAsset().Symbol, sdk.Int(withdrawNativeAssetAmount)) } if asymmetry.IsNegative() { - swapResult, _, _, _, err := FEATURE_TOGGLE_MARGIN_CLI_ALPHA_SwapOne(ctx, app.ClpKeeper, asset, swapAmount, clptypes.GetSettlementAsset(), pool, sdk.OneDec()) + swapResult, _, _, _, err := FEATURE_TOGGLE_MARGIN_CLI_ALPHA_SwapOne(ctx, app.ClpKeeper, asset, swapAmount, clptypes.GetSettlementAsset(), pool, sdk.OneDec(), sdk.NewDecWithPrec(3, 3)) assert.NoError(t, err) externalAssetCoin = sdk.NewCoin(asset.Symbol, sdk.Int(withdrawExternalAssetAmount)) nativeAssetCoin = sdk.NewCoin(clptypes.GetSettlementAsset().Symbol, sdk.Int(withdrawNativeAssetAmount.Add(swapResult))) @@ -424,11 +424,11 @@ func CalculateSwapReceived(t *testing.T, keeper clpkeeper.Keeper, tokenRegistryK registry := tokenRegistryKeeper.GetRegistry(ctx) _, err = tokenRegistryKeeper.GetEntry(registry, inPool.ExternalAsset.Symbol) assert.NoError(t, err) - emitAmount, _, _, _, err := FEATURE_TOGGLE_MARGIN_CLI_ALPHA_SwapOne(ctx, keeper, assetSent, swapAmount, clptypes.GetSettlementAsset(), inPool, sdk.OneDec()) + emitAmount, _, _, _, err := FEATURE_TOGGLE_MARGIN_CLI_ALPHA_SwapOne(ctx, keeper, assetSent, swapAmount, clptypes.GetSettlementAsset(), inPool, sdk.OneDec(), sdk.NewDecWithPrec(3, 3)) assert.NoError(t, err) _, err = tokenRegistryKeeper.GetEntry(registry, outPool.ExternalAsset.Symbol) assert.NoError(t, err) - emitAmount2, _, _, _, err := FEATURE_TOGGLE_MARGIN_CLI_ALPHA_SwapOne(ctx, keeper, clptypes.GetSettlementAsset(), emitAmount, assetReceived, outPool, sdk.OneDec()) + emitAmount2, _, _, _, err := FEATURE_TOGGLE_MARGIN_CLI_ALPHA_SwapOne(ctx, keeper, clptypes.GetSettlementAsset(), emitAmount, assetReceived, outPool, sdk.OneDec(), sdk.NewDecWithPrec(3, 3)) assert.NoError(t, err) return emitAmount2 } diff --git a/x/clp/keeper/calculations.go b/x/clp/keeper/calculations.go index 510f235d26..0fd6a84191 100644 --- a/x/clp/keeper/calculations.go +++ b/x/clp/keeper/calculations.go @@ -239,7 +239,7 @@ func calculateSlipAdjustment(R, A, r, a *big.Int) *slipAdjustmentValues { return &slipAdjustmentValues{slipAdjustment: &slipAdjustment, RTimesa: &RTimesa, rTimesA: &rTimesA} } -func CalcLiquidityFee(X, x, Y sdk.Uint) sdk.Uint { +func CalcLiquidityFee(toRowan bool, X, x, Y sdk.Uint, swapFeeRate, pmtpCurrentRunningRate sdk.Dec) sdk.Uint { if IsAnyZero([]sdk.Uint{X, x, Y}) { return sdk.ZeroUint() } @@ -247,27 +247,34 @@ func CalcLiquidityFee(X, x, Y sdk.Uint) sdk.Uint { Xb := X.BigInt() xb := x.BigInt() Yb := Y.BigInt() + rawXYK := calcRawXYK(xb, Xb, Yb) - var sq, n, s, d, fee big.Int + var fee big.Rat + f := DecToRat(&swapFeeRate) + fee.Mul(&f, &rawXYK) - sq.Mul(xb, xb) // sq = x**2 - n.Mul(&sq, Yb) // n = x**2 * Y - s.Add(Xb, xb) // s = x + X - d.Mul(&s, &s) // d = (x + X)**2 - fee.Quo(&n, &d) // fee = n / d = (x**2 * Y) / (x + X)**2 + pmtpFac := calcPmtpFactor(pmtpCurrentRunningRate) + + if toRowan { + fee.Quo(&fee, &pmtpFac) // res = y / pmtpFac + } else { + fee.Mul(&fee, &pmtpFac) // res = y * pmtpFac + } - return sdk.NewUintFromBigInt(&fee) + return sdk.NewUintFromBigInt(RatIntQuo(&fee)) } func CalcSwapResult(toRowan bool, X, x, Y sdk.Uint, - pmtpCurrentRunningRate sdk.Dec) sdk.Uint { + pmtpCurrentRunningRate, swapFeeRate sdk.Dec) sdk.Uint { if IsAnyZero([]sdk.Uint{X, x, Y}) { return sdk.ZeroUint() } - y := calcSwap(x.BigInt(), X.BigInt(), Y.BigInt()) + swapFeeRateR := DecToRat(&swapFeeRate) + + y := calcSwap(x.BigInt(), X.BigInt(), Y.BigInt(), &swapFeeRateR) pmtpFac := calcPmtpFactor(pmtpCurrentRunningRate) var res big.Rat @@ -281,18 +288,28 @@ func CalcSwapResult(toRowan bool, return sdk.NewUintFromBigInt(num) } -func calcSwap(x, X, Y *big.Int) big.Rat { - var s, d, d2, d3 big.Int - var numerator, denominator, y big.Rat +// y = (1-f)*x*Y/(x+X) +func calcSwap(x, X, Y *big.Int, swapFeeRate *big.Rat) big.Rat { + var diff big.Rat + one := big.NewRat(1, 1) + diff.Sub(one, swapFeeRate) // diff = 1 - f + + rawYXK := calcRawXYK(x, X, Y) + diff.Mul(&diff, &rawYXK) + + return diff +} + +func calcRawXYK(x, X, Y *big.Int) big.Rat { + var numerator, denominator, xR, XR, YR, y big.Rat - s.Add(X, x) // s = X + x - d.Mul(&s, &s) // d = (X + x)**2 - d2.Mul(X, Y) // d2 = X * Y - d3.Mul(x, &d2) // d3 = x * X * Y + xR.SetInt(x) + XR.SetInt(X) + YR.SetInt(Y) + numerator.Mul(&xR, &YR) // x * Y + denominator.Add(&XR, &xR) // X + x - denominator.SetInt(&d) - numerator.SetInt(&d3) - y.Quo(&numerator, &denominator) // y = d3 / d = (x * X * Y) / (X + x)**2 + y.Quo(&numerator, &denominator) // y = (x * Y) / (X + x) return y } @@ -335,8 +352,7 @@ func CalcSpotPriceX(X, Y sdk.Uint, decimalsX, decimalsY uint8, pmtpCurrentRunnin dcm := CalcDenomChangeMultiplier(decimalsX, decimalsY) pmtpPrice.Mul(&pmtpPrice, &dcm) - res := RatToDec(&pmtpPrice) - return res, nil + return RatToDec(&pmtpPrice) } func CalcRowanValue(pool *types.Pool, pmtpCurrentRunningRate sdk.Dec, rowanAmount sdk.Uint) (sdk.Uint, error) { spotPrice, err := CalcRowanSpotPrice(pool, pmtpCurrentRunningRate) diff --git a/x/clp/keeper/calculations_FEATURE_TOGGLE_MARGIN_CLI_ALPHA.go b/x/clp/keeper/calculations_FEATURE_TOGGLE_MARGIN_CLI_ALPHA.go index fffb90c980..bdbc318925 100644 --- a/x/clp/keeper/calculations_FEATURE_TOGGLE_MARGIN_CLI_ALPHA.go +++ b/x/clp/keeper/calculations_FEATURE_TOGGLE_MARGIN_CLI_ALPHA.go @@ -33,7 +33,7 @@ func CalculateWithdrawalRowanValue( sentAmount sdk.Uint, to types.Asset, pool types.Pool, - pmtpCurrentRunningRate sdk.Dec, marginEnabled bool) sdk.Uint { + pmtpCurrentRunningRate, swapFeeRate sdk.Dec, marginEnabled bool) sdk.Uint { X, Y, toRowan := pool.ExtractValues(to) @@ -41,14 +41,14 @@ func CalculateWithdrawalRowanValue( X, Y = pool.ExtractDebt(X, Y, toRowan) } - return CalcSwapResult(toRowan, X, sentAmount, Y, pmtpCurrentRunningRate) + return CalcSwapResult(toRowan, X, sentAmount, Y, pmtpCurrentRunningRate, swapFeeRate) } func SwapOne(from types.Asset, sentAmount sdk.Uint, to types.Asset, pool types.Pool, - pmtpCurrentRunningRate sdk.Dec, + pmtpCurrentRunningRate, swapFeeRate sdk.Dec, marginEnabled bool) (sdk.Uint, sdk.Uint, sdk.Uint, types.Pool, error) { X, Y, toRowan := pool.ExtractValues(to) @@ -57,9 +57,9 @@ func SwapOne(from types.Asset, X, Y = pool.ExtractDebt(X, Y, toRowan) } - liquidityFee := CalcLiquidityFee(X, sentAmount, Y) + liquidityFee := CalcLiquidityFee(toRowan, X, sentAmount, Y, swapFeeRate, pmtpCurrentRunningRate) priceImpact := calcPriceImpact(X, sentAmount) - swapResult := CalcSwapResult(toRowan, X, sentAmount, Y, pmtpCurrentRunningRate) + swapResult := CalcSwapResult(toRowan, X, sentAmount, Y, pmtpCurrentRunningRate, swapFeeRate) // NOTE: impossible... pre-pmtp at least if swapResult.GTE(Y) { @@ -74,7 +74,7 @@ func SwapOne(from types.Asset, func GetSwapFee(sentAmount sdk.Uint, to types.Asset, pool types.Pool, - pmtpCurrentRunningRate sdk.Dec, + pmtpCurrentRunningRate, swapFeeRate sdk.Dec, marginEnabled bool) sdk.Uint { X, Y, toRowan := pool.ExtractValues(to) @@ -82,7 +82,7 @@ func GetSwapFee(sentAmount sdk.Uint, X, Y = pool.ExtractDebt(X, Y, toRowan) } - swapResult := CalcSwapResult(toRowan, X, sentAmount, Y, pmtpCurrentRunningRate) + swapResult := CalcSwapResult(toRowan, X, sentAmount, Y, pmtpCurrentRunningRate, swapFeeRate) if swapResult.GTE(Y) { return sdk.ZeroUint() diff --git a/x/clp/keeper/calculations_FEATURE_TOGGLE_MARGIN_CLI_ALPHA_test.go b/x/clp/keeper/calculations_FEATURE_TOGGLE_MARGIN_CLI_ALPHA_test.go index 28e9f5f1e5..48160fdf30 100644 --- a/x/clp/keeper/calculations_FEATURE_TOGGLE_MARGIN_CLI_ALPHA_test.go +++ b/x/clp/keeper/calculations_FEATURE_TOGGLE_MARGIN_CLI_ALPHA_test.go @@ -25,9 +25,10 @@ func FEATURE_TOGGLE_MARGIN_CLI_ALPHA_SwapOne(ctx sdk.Context, sentAmount sdk.Uint, nativeAsset types.Asset, inPool types.Pool, - pmtpCurrentRunningRate sdk.Dec) (sdk.Uint, sdk.Uint, sdk.Uint, types.Pool, error) { + pmtpCurrentRunningRate, swapFeeRate sdk.Dec) (sdk.Uint, sdk.Uint, sdk.Uint, types.Pool, error) { + marginEnabled := k.GetMarginKeeper().IsPoolEnabled(ctx, inPool.String()) - return clpkeeper.SwapOne(sentAsset, sentAmount, nativeAsset, inPool, pmtpCurrentRunningRate, marginEnabled) + return clpkeeper.SwapOne(sentAsset, sentAmount, nativeAsset, inPool, pmtpCurrentRunningRate, swapFeeRate, marginEnabled) } func FEATURE_TOGGLE_MARGIN_CLI_ALPHA_GetSwapFee(ctx sdk.Context, @@ -35,11 +36,10 @@ func FEATURE_TOGGLE_MARGIN_CLI_ALPHA_GetSwapFee(ctx sdk.Context, ReceivedAsset *types.Asset, liquidityFeeNative sdk.Uint, outPool types.Pool, - pmtpCurrentRunningRate sdk.Dec) sdk.Uint { + pmtpCurrentRunningRate, swapFeeRate sdk.Dec) sdk.Uint { marginEnabled := k.GetMarginKeeper().IsPoolEnabled(ctx, outPool.String()) - return clpkeeper.GetSwapFee(liquidityFeeNative, *ReceivedAsset, outPool, pmtpCurrentRunningRate, marginEnabled) + return clpkeeper.GetSwapFee(liquidityFeeNative, *ReceivedAsset, outPool, pmtpCurrentRunningRate, swapFeeRate, marginEnabled) } - func TestKeeper_SwapOneFromGenesis(t *testing.T) { const address = "sif1syavy2npfyt9tcncdtsdzf7kny9lh777yqc2nd" SwapPriceNative := sdk.ZeroDec() @@ -70,38 +70,6 @@ func TestKeeper_SwapOneFromGenesis(t *testing.T) { err error errString error }{ - { - name: "successful swap with single pool units", - poolAsset: "eth", - address: address, - nativeBalance: sdk.NewInt(10000), - externalBalance: sdk.NewInt(10000), - nativeAssetAmount: sdk.NewUint(998), - externalAssetAmount: sdk.NewUint(998), - poolUnits: sdk.OneUint(), - calculateWithdraw: true, - wBasis: sdk.NewInt(1000), - asymmetry: sdk.NewInt(10000), - pmtpCurrentRunningRate: sdk.OneDec(), - swapResult: sdk.NewUint(19), - liquidityFee: sdk.NewUint(978), - priceImpact: sdk.ZeroUint(), - expectedPool: types.Pool{ - ExternalAsset: &types.Asset{Symbol: "eth"}, - NativeAssetBalance: sdk.NewUint(100598), - ExternalAssetBalance: sdk.NewUint(979), - PoolUnits: sdk.NewUint(1), - NativeCustody: sdk.ZeroUint(), - ExternalCustody: sdk.ZeroUint(), - NativeLiabilities: sdk.ZeroUint(), - ExternalLiabilities: sdk.ZeroUint(), - Health: sdk.ZeroDec(), - InterestRate: sdk.NewDecWithPrec(1, 1), - SwapPriceNative: &SwapPriceNative, - SwapPriceExternal: &SwapPriceExternal, - RewardPeriodNativeDistributed: sdk.ZeroUint(), - }, - }, { name: "successful swap with equal amount of pool units", poolAsset: "eth", @@ -115,13 +83,13 @@ func TestKeeper_SwapOneFromGenesis(t *testing.T) { wBasis: sdk.NewInt(1000), asymmetry: sdk.NewInt(10000), pmtpCurrentRunningRate: sdk.OneDec(), - swapResult: sdk.NewUint(165), - liquidityFee: sdk.NewUint(8), + swapResult: sdk.NewUint(181), + liquidityFee: sdk.NewUint(0), priceImpact: sdk.ZeroUint(), expectedPool: types.Pool{ ExternalAsset: &types.Asset{Symbol: "eth"}, NativeAssetBalance: sdk.NewUint(1098), - ExternalAssetBalance: sdk.NewUint(833), + ExternalAssetBalance: sdk.NewUint(817), PoolUnits: sdk.NewUint(998), NativeCustody: sdk.ZeroUint(), ExternalCustody: sdk.ZeroUint(), @@ -183,12 +151,12 @@ func TestKeeper_SwapOneFromGenesis(t *testing.T) { from: types.Asset{Symbol: "eth"}, to: types.Asset{Symbol: "rowan"}, pmtpCurrentRunningRate: sdk.OneDec(), - swapResult: sdk.NewUint(41), - liquidityFee: sdk.NewUint(8), + swapResult: sdk.NewUint(45), + liquidityFee: sdk.NewUint(0), priceImpact: sdk.ZeroUint(), expectedPool: types.Pool{ ExternalAsset: &types.Asset{Symbol: "eth"}, - NativeAssetBalance: sdk.NewUint(957), + NativeAssetBalance: sdk.NewUint(953), ExternalAssetBalance: sdk.NewUint(1098), PoolUnits: sdk.NewUint(998), NativeCustody: sdk.ZeroUint(), @@ -215,13 +183,13 @@ func TestKeeper_SwapOneFromGenesis(t *testing.T) { wBasis: sdk.NewInt(1000), asymmetry: sdk.NewInt(10000), pmtpCurrentRunningRate: sdk.MustNewDecFromStr("0.0"), - swapResult: sdk.NewUint(82), - liquidityFee: sdk.NewUint(8), + swapResult: sdk.NewUint(90), + liquidityFee: sdk.NewUint(0), priceImpact: sdk.ZeroUint(), expectedPool: types.Pool{ ExternalAsset: &types.Asset{Symbol: "eth"}, NativeAssetBalance: sdk.NewUint(1098), - ExternalAssetBalance: sdk.NewUint(916), + ExternalAssetBalance: sdk.NewUint(908), PoolUnits: sdk.NewUint(998), NativeCustody: sdk.ZeroUint(), ExternalCustody: sdk.ZeroUint(), @@ -247,13 +215,13 @@ func TestKeeper_SwapOneFromGenesis(t *testing.T) { wBasis: sdk.NewInt(1000), asymmetry: sdk.NewInt(10000), pmtpCurrentRunningRate: sdk.MustNewDecFromStr("0.1"), - swapResult: sdk.NewUint(90), - liquidityFee: sdk.NewUint(8), + swapResult: sdk.NewUint(99), + liquidityFee: sdk.NewUint(0), priceImpact: sdk.ZeroUint(), expectedPool: types.Pool{ ExternalAsset: &types.Asset{Symbol: "eth"}, NativeAssetBalance: sdk.NewUint(1098), - ExternalAssetBalance: sdk.NewUint(908), + ExternalAssetBalance: sdk.NewUint(899), PoolUnits: sdk.NewUint(998), NativeCustody: sdk.ZeroUint(), ExternalCustody: sdk.ZeroUint(), @@ -279,13 +247,13 @@ func TestKeeper_SwapOneFromGenesis(t *testing.T) { wBasis: sdk.NewInt(1000), asymmetry: sdk.NewInt(10000), pmtpCurrentRunningRate: sdk.MustNewDecFromStr("0.2"), - swapResult: sdk.NewUint(99), - liquidityFee: sdk.NewUint(8), + swapResult: sdk.NewUint(108), + liquidityFee: sdk.NewUint(0), priceImpact: sdk.ZeroUint(), expectedPool: types.Pool{ ExternalAsset: &types.Asset{Symbol: "eth"}, NativeAssetBalance: sdk.NewUint(1098), - ExternalAssetBalance: sdk.NewUint(899), + ExternalAssetBalance: sdk.NewUint(890), PoolUnits: sdk.NewUint(998), NativeCustody: sdk.ZeroUint(), ExternalCustody: sdk.ZeroUint(), @@ -311,13 +279,13 @@ func TestKeeper_SwapOneFromGenesis(t *testing.T) { wBasis: sdk.NewInt(1000), asymmetry: sdk.NewInt(10000), pmtpCurrentRunningRate: sdk.MustNewDecFromStr("0.3"), - swapResult: sdk.NewUint(107), - liquidityFee: sdk.NewUint(8), + swapResult: sdk.NewUint(117), + liquidityFee: sdk.NewUint(0), priceImpact: sdk.ZeroUint(), expectedPool: types.Pool{ ExternalAsset: &types.Asset{Symbol: "eth"}, NativeAssetBalance: sdk.NewUint(1098), - ExternalAssetBalance: sdk.NewUint(891), + ExternalAssetBalance: sdk.NewUint(881), PoolUnits: sdk.NewUint(998), NativeCustody: sdk.ZeroUint(), ExternalCustody: sdk.ZeroUint(), @@ -343,13 +311,13 @@ func TestKeeper_SwapOneFromGenesis(t *testing.T) { wBasis: sdk.NewInt(1000), asymmetry: sdk.NewInt(10000), pmtpCurrentRunningRate: sdk.MustNewDecFromStr("0.4"), - swapResult: sdk.NewUint(115), - liquidityFee: sdk.NewUint(8), + swapResult: sdk.NewUint(126), + liquidityFee: sdk.NewUint(0), priceImpact: sdk.ZeroUint(), expectedPool: types.Pool{ ExternalAsset: &types.Asset{Symbol: "eth"}, NativeAssetBalance: sdk.NewUint(1098), - ExternalAssetBalance: sdk.NewUint(883), + ExternalAssetBalance: sdk.NewUint(872), PoolUnits: sdk.NewUint(998), NativeCustody: sdk.ZeroUint(), ExternalCustody: sdk.ZeroUint(), @@ -375,13 +343,13 @@ func TestKeeper_SwapOneFromGenesis(t *testing.T) { wBasis: sdk.NewInt(1000), asymmetry: sdk.NewInt(10000), pmtpCurrentRunningRate: sdk.MustNewDecFromStr("0.5"), - swapResult: sdk.NewUint(123), - liquidityFee: sdk.NewUint(8), + swapResult: sdk.NewUint(135), + liquidityFee: sdk.NewUint(0), priceImpact: sdk.ZeroUint(), expectedPool: types.Pool{ ExternalAsset: &types.Asset{Symbol: "eth"}, NativeAssetBalance: sdk.NewUint(1098), - ExternalAssetBalance: sdk.NewUint(875), + ExternalAssetBalance: sdk.NewUint(863), PoolUnits: sdk.NewUint(998), NativeCustody: sdk.ZeroUint(), ExternalCustody: sdk.ZeroUint(), @@ -407,13 +375,13 @@ func TestKeeper_SwapOneFromGenesis(t *testing.T) { wBasis: sdk.NewInt(1000), asymmetry: sdk.NewInt(10000), pmtpCurrentRunningRate: sdk.MustNewDecFromStr("0.6"), - swapResult: sdk.NewUint(132), - liquidityFee: sdk.NewUint(8), + swapResult: sdk.NewUint(144), + liquidityFee: sdk.NewUint(0), priceImpact: sdk.ZeroUint(), expectedPool: types.Pool{ ExternalAsset: &types.Asset{Symbol: "eth"}, NativeAssetBalance: sdk.NewUint(1098), - ExternalAssetBalance: sdk.NewUint(866), + ExternalAssetBalance: sdk.NewUint(854), PoolUnits: sdk.NewUint(998), NativeCustody: sdk.ZeroUint(), ExternalCustody: sdk.ZeroUint(), @@ -439,13 +407,13 @@ func TestKeeper_SwapOneFromGenesis(t *testing.T) { wBasis: sdk.NewInt(1000), asymmetry: sdk.NewInt(10000), pmtpCurrentRunningRate: sdk.MustNewDecFromStr("0.7"), - swapResult: sdk.NewUint(140), - liquidityFee: sdk.NewUint(8), + swapResult: sdk.NewUint(154), + liquidityFee: sdk.NewUint(0), priceImpact: sdk.ZeroUint(), expectedPool: types.Pool{ ExternalAsset: &types.Asset{Symbol: "eth"}, NativeAssetBalance: sdk.NewUint(1098), - ExternalAssetBalance: sdk.NewUint(858), + ExternalAssetBalance: sdk.NewUint(844), PoolUnits: sdk.NewUint(998), NativeCustody: sdk.ZeroUint(), ExternalCustody: sdk.ZeroUint(), @@ -471,13 +439,13 @@ func TestKeeper_SwapOneFromGenesis(t *testing.T) { wBasis: sdk.NewInt(1000), asymmetry: sdk.NewInt(10000), pmtpCurrentRunningRate: sdk.MustNewDecFromStr("0.8"), - swapResult: sdk.NewUint(148), - liquidityFee: sdk.NewUint(8), + swapResult: sdk.NewUint(163), + liquidityFee: sdk.NewUint(0), priceImpact: sdk.ZeroUint(), expectedPool: types.Pool{ ExternalAsset: &types.Asset{Symbol: "eth"}, NativeAssetBalance: sdk.NewUint(1098), - ExternalAssetBalance: sdk.NewUint(850), + ExternalAssetBalance: sdk.NewUint(835), PoolUnits: sdk.NewUint(998), NativeCustody: sdk.ZeroUint(), ExternalCustody: sdk.ZeroUint(), @@ -503,13 +471,13 @@ func TestKeeper_SwapOneFromGenesis(t *testing.T) { wBasis: sdk.NewInt(1000), asymmetry: sdk.NewInt(10000), pmtpCurrentRunningRate: sdk.MustNewDecFromStr("0.9"), - swapResult: sdk.NewUint(156), - liquidityFee: sdk.NewUint(8), + swapResult: sdk.NewUint(172), + liquidityFee: sdk.NewUint(0), priceImpact: sdk.ZeroUint(), expectedPool: types.Pool{ ExternalAsset: &types.Asset{Symbol: "eth"}, NativeAssetBalance: sdk.NewUint(1098), - ExternalAssetBalance: sdk.NewUint(842), + ExternalAssetBalance: sdk.NewUint(826), PoolUnits: sdk.NewUint(998), NativeCustody: sdk.ZeroUint(), ExternalCustody: sdk.ZeroUint(), @@ -535,13 +503,13 @@ func TestKeeper_SwapOneFromGenesis(t *testing.T) { wBasis: sdk.NewInt(1000), asymmetry: sdk.NewInt(10000), pmtpCurrentRunningRate: sdk.MustNewDecFromStr("1.0"), - swapResult: sdk.NewUint(165), - liquidityFee: sdk.NewUint(8), + swapResult: sdk.NewUint(181), + liquidityFee: sdk.NewUint(0), priceImpact: sdk.ZeroUint(), expectedPool: types.Pool{ ExternalAsset: &types.Asset{Symbol: "eth"}, NativeAssetBalance: sdk.NewUint(1098), - ExternalAssetBalance: sdk.NewUint(833), + ExternalAssetBalance: sdk.NewUint(817), PoolUnits: sdk.NewUint(998), NativeCustody: sdk.ZeroUint(), ExternalCustody: sdk.ZeroUint(), @@ -567,13 +535,13 @@ func TestKeeper_SwapOneFromGenesis(t *testing.T) { wBasis: sdk.NewInt(1000), asymmetry: sdk.NewInt(10000), pmtpCurrentRunningRate: sdk.MustNewDecFromStr("2.0"), - swapResult: sdk.NewUint(247), - liquidityFee: sdk.NewUint(8), + swapResult: sdk.NewUint(271), + liquidityFee: sdk.NewUint(0), priceImpact: sdk.ZeroUint(), expectedPool: types.Pool{ ExternalAsset: &types.Asset{Symbol: "eth"}, NativeAssetBalance: sdk.NewUint(1098), - ExternalAssetBalance: sdk.NewUint(751), + ExternalAssetBalance: sdk.NewUint(727), PoolUnits: sdk.NewUint(998), NativeCustody: sdk.ZeroUint(), ExternalCustody: sdk.ZeroUint(), @@ -599,13 +567,13 @@ func TestKeeper_SwapOneFromGenesis(t *testing.T) { wBasis: sdk.NewInt(1000), asymmetry: sdk.NewInt(10000), pmtpCurrentRunningRate: sdk.MustNewDecFromStr("3.0"), - swapResult: sdk.NewUint(330), - liquidityFee: sdk.NewUint(8), + swapResult: sdk.NewUint(362), + liquidityFee: sdk.NewUint(1), priceImpact: sdk.ZeroUint(), expectedPool: types.Pool{ ExternalAsset: &types.Asset{Symbol: "eth"}, NativeAssetBalance: sdk.NewUint(1098), - ExternalAssetBalance: sdk.NewUint(668), + ExternalAssetBalance: sdk.NewUint(636), PoolUnits: sdk.NewUint(998), NativeCustody: sdk.ZeroUint(), ExternalCustody: sdk.ZeroUint(), @@ -631,13 +599,13 @@ func TestKeeper_SwapOneFromGenesis(t *testing.T) { wBasis: sdk.NewInt(1000), asymmetry: sdk.NewInt(10000), pmtpCurrentRunningRate: sdk.MustNewDecFromStr("4.0"), - swapResult: sdk.NewUint(413), - liquidityFee: sdk.NewUint(8), + swapResult: sdk.NewUint(453), + liquidityFee: sdk.NewUint(1), priceImpact: sdk.ZeroUint(), expectedPool: types.Pool{ ExternalAsset: &types.Asset{Symbol: "eth"}, NativeAssetBalance: sdk.NewUint(1098), - ExternalAssetBalance: sdk.NewUint(585), + ExternalAssetBalance: sdk.NewUint(545), PoolUnits: sdk.NewUint(998), NativeCustody: sdk.ZeroUint(), ExternalCustody: sdk.ZeroUint(), @@ -663,13 +631,13 @@ func TestKeeper_SwapOneFromGenesis(t *testing.T) { wBasis: sdk.NewInt(1000), asymmetry: sdk.NewInt(10000), pmtpCurrentRunningRate: sdk.MustNewDecFromStr("5.0"), - swapResult: sdk.NewUint(495), - liquidityFee: sdk.NewUint(8), + swapResult: sdk.NewUint(543), + liquidityFee: sdk.NewUint(1), priceImpact: sdk.ZeroUint(), expectedPool: types.Pool{ ExternalAsset: &types.Asset{Symbol: "eth"}, NativeAssetBalance: sdk.NewUint(1098), - ExternalAssetBalance: sdk.NewUint(503), + ExternalAssetBalance: sdk.NewUint(455), PoolUnits: sdk.NewUint(998), NativeCustody: sdk.ZeroUint(), ExternalCustody: sdk.ZeroUint(), @@ -695,13 +663,13 @@ func TestKeeper_SwapOneFromGenesis(t *testing.T) { wBasis: sdk.NewInt(1000), asymmetry: sdk.NewInt(10000), pmtpCurrentRunningRate: sdk.MustNewDecFromStr("6.0"), - swapResult: sdk.NewUint(578), - liquidityFee: sdk.NewUint(8), + swapResult: sdk.NewUint(634), + liquidityFee: sdk.NewUint(1), priceImpact: sdk.ZeroUint(), expectedPool: types.Pool{ ExternalAsset: &types.Asset{Symbol: "eth"}, NativeAssetBalance: sdk.NewUint(1098), - ExternalAssetBalance: sdk.NewUint(420), + ExternalAssetBalance: sdk.NewUint(364), PoolUnits: sdk.NewUint(998), NativeCustody: sdk.ZeroUint(), ExternalCustody: sdk.ZeroUint(), @@ -727,13 +695,13 @@ func TestKeeper_SwapOneFromGenesis(t *testing.T) { wBasis: sdk.NewInt(1000), asymmetry: sdk.NewInt(10000), pmtpCurrentRunningRate: sdk.MustNewDecFromStr("7.0"), - swapResult: sdk.NewUint(660), - liquidityFee: sdk.NewUint(8), + swapResult: sdk.NewUint(724), + liquidityFee: sdk.NewUint(2), priceImpact: sdk.ZeroUint(), expectedPool: types.Pool{ ExternalAsset: &types.Asset{Symbol: "eth"}, NativeAssetBalance: sdk.NewUint(1098), - ExternalAssetBalance: sdk.NewUint(338), + ExternalAssetBalance: sdk.NewUint(274), PoolUnits: sdk.NewUint(998), NativeCustody: sdk.ZeroUint(), ExternalCustody: sdk.ZeroUint(), @@ -759,13 +727,13 @@ func TestKeeper_SwapOneFromGenesis(t *testing.T) { wBasis: sdk.NewInt(1000), asymmetry: sdk.NewInt(10000), pmtpCurrentRunningRate: sdk.MustNewDecFromStr("8.0"), - swapResult: sdk.NewUint(743), - liquidityFee: sdk.NewUint(8), + swapResult: sdk.NewUint(815), + liquidityFee: sdk.NewUint(2), priceImpact: sdk.ZeroUint(), expectedPool: types.Pool{ ExternalAsset: &types.Asset{Symbol: "eth"}, NativeAssetBalance: sdk.NewUint(1098), - ExternalAssetBalance: sdk.NewUint(255), + ExternalAssetBalance: sdk.NewUint(183), PoolUnits: sdk.NewUint(998), NativeCustody: sdk.ZeroUint(), ExternalCustody: sdk.ZeroUint(), @@ -791,13 +759,13 @@ func TestKeeper_SwapOneFromGenesis(t *testing.T) { wBasis: sdk.NewInt(1000), asymmetry: sdk.NewInt(10000), pmtpCurrentRunningRate: sdk.MustNewDecFromStr("9.0"), - swapResult: sdk.NewUint(826), - liquidityFee: sdk.NewUint(8), + swapResult: sdk.NewUint(906), + liquidityFee: sdk.NewUint(2), priceImpact: sdk.ZeroUint(), expectedPool: types.Pool{ ExternalAsset: &types.Asset{Symbol: "eth"}, NativeAssetBalance: sdk.NewUint(1098), - ExternalAssetBalance: sdk.NewUint(172), + ExternalAssetBalance: sdk.NewUint(92), PoolUnits: sdk.NewUint(998), NativeCustody: sdk.ZeroUint(), ExternalCustody: sdk.ZeroUint(), @@ -823,13 +791,13 @@ func TestKeeper_SwapOneFromGenesis(t *testing.T) { wBasis: sdk.NewInt(1000), asymmetry: sdk.NewInt(10000), pmtpCurrentRunningRate: sdk.MustNewDecFromStr("10.0"), - swapResult: sdk.NewUint(908), - liquidityFee: sdk.NewUint(8), + swapResult: sdk.NewUint(996), + liquidityFee: sdk.NewUint(2), priceImpact: sdk.ZeroUint(), expectedPool: types.Pool{ ExternalAsset: &types.Asset{Symbol: "eth"}, NativeAssetBalance: sdk.NewUint(1098), - ExternalAssetBalance: sdk.NewUint(90), + ExternalAssetBalance: sdk.NewUint(2), PoolUnits: sdk.NewUint(998), NativeCustody: sdk.ZeroUint(), ExternalCustody: sdk.ZeroUint(), @@ -994,6 +962,7 @@ func TestKeeper_SwapOneFromGenesis(t *testing.T) { to, pool, tc.pmtpCurrentRunningRate, + sdk.NewDecWithPrec(3, 3), ) if tc.errString != nil { @@ -1006,10 +975,10 @@ func TestKeeper_SwapOneFromGenesis(t *testing.T) { } require.NoError(t, err) - require.Equal(t, swapResult, tc.swapResult, "swapResult") - require.Equal(t, liquidityFee, tc.liquidityFee) - require.Equal(t, priceImpact, tc.priceImpact) - require.Equal(t, newPool, tc.expectedPool) + require.Equal(t, tc.swapResult.String(), swapResult.String(), "swapResult") + require.Equal(t, tc.liquidityFee.String(), liquidityFee.String()) + require.Equal(t, tc.priceImpact.String(), priceImpact.String()) + require.Equal(t, tc.expectedPool.String(), newPool.String()) }) } } diff --git a/x/clp/keeper/calculations_NO_FEATURE_TOGGLE_MARGIN_CLI_ALPHA.go b/x/clp/keeper/calculations_NO_FEATURE_TOGGLE_MARGIN_CLI_ALPHA.go index d6b8259f6f..a447de0141 100644 --- a/x/clp/keeper/calculations_NO_FEATURE_TOGGLE_MARGIN_CLI_ALPHA.go +++ b/x/clp/keeper/calculations_NO_FEATURE_TOGGLE_MARGIN_CLI_ALPHA.go @@ -9,20 +9,20 @@ import ( "github.com/Sifchain/sifnode/x/clp/types" ) -//------------------------------------------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------------------------------------------ // More details on the formula // https://github.com/Sifchain/sifnode/blob/develop/docs/1.Liquidity%20Pools%20Architecture.md func SwapOne(from types.Asset, sentAmount sdk.Uint, to types.Asset, pool types.Pool, - pmtpCurrentRunningRate sdk.Dec) (sdk.Uint, sdk.Uint, sdk.Uint, types.Pool, error) { + pmtpCurrentRunningRate, swapFeeRate sdk.Dec) (sdk.Uint, sdk.Uint, sdk.Uint, types.Pool, error) { X, Y, toRowan := pool.ExtractValues(to) - liquidityFee := CalcLiquidityFee(X, sentAmount, Y) + liquidityFee := CalcLiquidityFee(toRowan, X, sentAmount, Y, swapFeeRate, pmtpCurrentRunningRate) priceImpact := calcPriceImpact(X, sentAmount) - swapResult := CalcSwapResult(toRowan, X, sentAmount, Y, pmtpCurrentRunningRate) + swapResult := CalcSwapResult(toRowan, X, sentAmount, Y, pmtpCurrentRunningRate, swapFeeRate) // NOTE: impossible... pre-pmtp at least if swapResult.GTE(Y) { @@ -37,10 +37,10 @@ func SwapOne(from types.Asset, func GetSwapFee(sentAmount sdk.Uint, to types.Asset, pool types.Pool, - pmtpCurrentRunningRate sdk.Dec) sdk.Uint { + pmtpCurrentRunningRate, swapFeeRate sdk.Dec) sdk.Uint { X, Y, toRowan := pool.ExtractValues(to) - swapResult := CalcSwapResult(toRowan, X, sentAmount, Y, pmtpCurrentRunningRate) + swapResult := CalcSwapResult(toRowan, X, sentAmount, Y, pmtpCurrentRunningRate, swapFeeRate) if swapResult.GTE(Y) { return sdk.ZeroUint() diff --git a/x/clp/keeper/calculations_NO_FEATURE_TOGGLE_MARGIN_CLI_ALPHA_test.go b/x/clp/keeper/calculations_NO_FEATURE_TOGGLE_MARGIN_CLI_ALPHA_test.go index b7f2a265ae..ad898a914c 100644 --- a/x/clp/keeper/calculations_NO_FEATURE_TOGGLE_MARGIN_CLI_ALPHA_test.go +++ b/x/clp/keeper/calculations_NO_FEATURE_TOGGLE_MARGIN_CLI_ALPHA_test.go @@ -25,8 +25,9 @@ func FEATURE_TOGGLE_MARGIN_CLI_ALPHA_SwapOne(ctx sdk.Context, sentAmount sdk.Uint, nativeAsset types.Asset, inPool types.Pool, - pmtpCurrentRunningRate sdk.Dec) (sdk.Uint, sdk.Uint, sdk.Uint, types.Pool, error) { - return clpkeeper.SwapOne(sentAsset, sentAmount, nativeAsset, inPool, pmtpCurrentRunningRate) + pmtpCurrentRunningRate, swapFeeRate sdk.Dec) (sdk.Uint, sdk.Uint, sdk.Uint, types.Pool, error) { + + return clpkeeper.SwapOne(sentAsset, sentAmount, nativeAsset, inPool, pmtpCurrentRunningRate, swapFeeRate) } func FEATURE_TOGGLE_MARGIN_CLI_ALPHA_GetSwapFee(ctx sdk.Context, @@ -34,8 +35,8 @@ func FEATURE_TOGGLE_MARGIN_CLI_ALPHA_GetSwapFee(ctx sdk.Context, ReceivedAsset *types.Asset, liquidityFeeNative sdk.Uint, outPool types.Pool, - pmtpCurrentRunningRate sdk.Dec) sdk.Uint { - return clpkeeper.GetSwapFee(liquidityFeeNative, *ReceivedAsset, outPool, pmtpCurrentRunningRate) + pmtpCurrentRunningRate, swapFeeRate sdk.Dec) sdk.Uint { + return clpkeeper.GetSwapFee(liquidityFeeNative, *ReceivedAsset, outPool, pmtpCurrentRunningRate, swapFeeRate) } func TestKeeper_SwapOneFromGenesis(t *testing.T) { @@ -68,32 +69,6 @@ func TestKeeper_SwapOneFromGenesis(t *testing.T) { err error errString error }{ - { - name: "successful swap with single pool units", - poolAsset: "eth", - address: address, - nativeBalance: sdk.NewInt(10000), - externalBalance: sdk.NewInt(10000), - nativeAssetAmount: sdk.NewUint(998), - externalAssetAmount: sdk.NewUint(998), - poolUnits: sdk.OneUint(), - calculateWithdraw: true, - wBasis: sdk.NewInt(1000), - asymmetry: sdk.NewInt(10000), - pmtpCurrentRunningRate: sdk.OneDec(), - swapResult: sdk.NewUint(19), - liquidityFee: sdk.NewUint(978), - priceImpact: sdk.ZeroUint(), - expectedPool: types.Pool{ - ExternalAsset: &types.Asset{Symbol: "eth"}, - NativeAssetBalance: sdk.NewUint(100598), - ExternalAssetBalance: sdk.NewUint(979), - PoolUnits: sdk.NewUint(1), - SwapPriceNative: &SwapPriceNative, - SwapPriceExternal: &SwapPriceExternal, - RewardPeriodNativeDistributed: sdk.ZeroUint(), - }, - }, { name: "successful swap with equal amount of pool units", poolAsset: "eth", @@ -107,13 +82,13 @@ func TestKeeper_SwapOneFromGenesis(t *testing.T) { wBasis: sdk.NewInt(1000), asymmetry: sdk.NewInt(10000), pmtpCurrentRunningRate: sdk.OneDec(), - swapResult: sdk.NewUint(165), - liquidityFee: sdk.NewUint(8), + swapResult: sdk.NewUint(181), + liquidityFee: sdk.NewUint(0), priceImpact: sdk.ZeroUint(), expectedPool: types.Pool{ ExternalAsset: &types.Asset{Symbol: "eth"}, NativeAssetBalance: sdk.NewUint(1098), - ExternalAssetBalance: sdk.NewUint(833), + ExternalAssetBalance: sdk.NewUint(817), PoolUnits: sdk.NewUint(998), SwapPriceNative: &SwapPriceNative, SwapPriceExternal: &SwapPriceExternal, @@ -135,7 +110,7 @@ func TestKeeper_SwapOneFromGenesis(t *testing.T) { swapAmount: sdk.NewUint(0), pmtpCurrentRunningRate: sdk.OneDec(), swapResult: sdk.NewUint(166), - liquidityFee: sdk.NewUint(8), + liquidityFee: sdk.NewUint(0), priceImpact: sdk.ZeroUint(), expectedPool: types.Pool{ ExternalAsset: &types.Asset{Symbol: "eth"}, @@ -163,12 +138,12 @@ func TestKeeper_SwapOneFromGenesis(t *testing.T) { from: types.Asset{Symbol: "eth"}, to: types.Asset{Symbol: "rowan"}, pmtpCurrentRunningRate: sdk.OneDec(), - swapResult: sdk.NewUint(41), - liquidityFee: sdk.NewUint(8), + swapResult: sdk.NewUint(45), + liquidityFee: sdk.NewUint(0), priceImpact: sdk.ZeroUint(), expectedPool: types.Pool{ ExternalAsset: &types.Asset{Symbol: "eth"}, - NativeAssetBalance: sdk.NewUint(957), + NativeAssetBalance: sdk.NewUint(953), ExternalAssetBalance: sdk.NewUint(1098), PoolUnits: sdk.NewUint(998), SwapPriceNative: &SwapPriceNative, @@ -189,13 +164,13 @@ func TestKeeper_SwapOneFromGenesis(t *testing.T) { wBasis: sdk.NewInt(1000), asymmetry: sdk.NewInt(10000), pmtpCurrentRunningRate: sdk.MustNewDecFromStr("0.0"), - swapResult: sdk.NewUint(82), - liquidityFee: sdk.NewUint(8), + swapResult: sdk.NewUint(90), + liquidityFee: sdk.NewUint(0), priceImpact: sdk.ZeroUint(), expectedPool: types.Pool{ ExternalAsset: &types.Asset{Symbol: "eth"}, NativeAssetBalance: sdk.NewUint(1098), - ExternalAssetBalance: sdk.NewUint(916), + ExternalAssetBalance: sdk.NewUint(908), PoolUnits: sdk.NewUint(998), SwapPriceNative: &SwapPriceNative, SwapPriceExternal: &SwapPriceExternal, @@ -215,13 +190,13 @@ func TestKeeper_SwapOneFromGenesis(t *testing.T) { wBasis: sdk.NewInt(1000), asymmetry: sdk.NewInt(10000), pmtpCurrentRunningRate: sdk.MustNewDecFromStr("0.1"), - swapResult: sdk.NewUint(90), - liquidityFee: sdk.NewUint(8), + swapResult: sdk.NewUint(99), + liquidityFee: sdk.NewUint(0), priceImpact: sdk.ZeroUint(), expectedPool: types.Pool{ ExternalAsset: &types.Asset{Symbol: "eth"}, NativeAssetBalance: sdk.NewUint(1098), - ExternalAssetBalance: sdk.NewUint(908), + ExternalAssetBalance: sdk.NewUint(899), PoolUnits: sdk.NewUint(998), SwapPriceNative: &SwapPriceNative, SwapPriceExternal: &SwapPriceExternal, @@ -241,13 +216,13 @@ func TestKeeper_SwapOneFromGenesis(t *testing.T) { wBasis: sdk.NewInt(1000), asymmetry: sdk.NewInt(10000), pmtpCurrentRunningRate: sdk.MustNewDecFromStr("0.2"), - swapResult: sdk.NewUint(99), - liquidityFee: sdk.NewUint(8), + swapResult: sdk.NewUint(108), + liquidityFee: sdk.NewUint(0), priceImpact: sdk.ZeroUint(), expectedPool: types.Pool{ ExternalAsset: &types.Asset{Symbol: "eth"}, NativeAssetBalance: sdk.NewUint(1098), - ExternalAssetBalance: sdk.NewUint(899), + ExternalAssetBalance: sdk.NewUint(890), PoolUnits: sdk.NewUint(998), SwapPriceNative: &SwapPriceNative, SwapPriceExternal: &SwapPriceExternal, @@ -267,13 +242,13 @@ func TestKeeper_SwapOneFromGenesis(t *testing.T) { wBasis: sdk.NewInt(1000), asymmetry: sdk.NewInt(10000), pmtpCurrentRunningRate: sdk.MustNewDecFromStr("0.3"), - swapResult: sdk.NewUint(107), - liquidityFee: sdk.NewUint(8), + swapResult: sdk.NewUint(117), + liquidityFee: sdk.NewUint(0), priceImpact: sdk.ZeroUint(), expectedPool: types.Pool{ ExternalAsset: &types.Asset{Symbol: "eth"}, NativeAssetBalance: sdk.NewUint(1098), - ExternalAssetBalance: sdk.NewUint(891), + ExternalAssetBalance: sdk.NewUint(881), PoolUnits: sdk.NewUint(998), SwapPriceNative: &SwapPriceNative, SwapPriceExternal: &SwapPriceExternal, @@ -293,13 +268,13 @@ func TestKeeper_SwapOneFromGenesis(t *testing.T) { wBasis: sdk.NewInt(1000), asymmetry: sdk.NewInt(10000), pmtpCurrentRunningRate: sdk.MustNewDecFromStr("0.4"), - swapResult: sdk.NewUint(115), - liquidityFee: sdk.NewUint(8), + swapResult: sdk.NewUint(126), + liquidityFee: sdk.NewUint(0), priceImpact: sdk.ZeroUint(), expectedPool: types.Pool{ ExternalAsset: &types.Asset{Symbol: "eth"}, NativeAssetBalance: sdk.NewUint(1098), - ExternalAssetBalance: sdk.NewUint(883), + ExternalAssetBalance: sdk.NewUint(872), PoolUnits: sdk.NewUint(998), SwapPriceNative: &SwapPriceNative, SwapPriceExternal: &SwapPriceExternal, @@ -319,13 +294,13 @@ func TestKeeper_SwapOneFromGenesis(t *testing.T) { wBasis: sdk.NewInt(1000), asymmetry: sdk.NewInt(10000), pmtpCurrentRunningRate: sdk.MustNewDecFromStr("0.5"), - swapResult: sdk.NewUint(123), - liquidityFee: sdk.NewUint(8), + swapResult: sdk.NewUint(135), + liquidityFee: sdk.NewUint(0), priceImpact: sdk.ZeroUint(), expectedPool: types.Pool{ ExternalAsset: &types.Asset{Symbol: "eth"}, NativeAssetBalance: sdk.NewUint(1098), - ExternalAssetBalance: sdk.NewUint(875), + ExternalAssetBalance: sdk.NewUint(863), PoolUnits: sdk.NewUint(998), SwapPriceNative: &SwapPriceNative, SwapPriceExternal: &SwapPriceExternal, @@ -345,13 +320,13 @@ func TestKeeper_SwapOneFromGenesis(t *testing.T) { wBasis: sdk.NewInt(1000), asymmetry: sdk.NewInt(10000), pmtpCurrentRunningRate: sdk.MustNewDecFromStr("0.6"), - swapResult: sdk.NewUint(132), - liquidityFee: sdk.NewUint(8), + swapResult: sdk.NewUint(144), + liquidityFee: sdk.NewUint(0), priceImpact: sdk.ZeroUint(), expectedPool: types.Pool{ ExternalAsset: &types.Asset{Symbol: "eth"}, NativeAssetBalance: sdk.NewUint(1098), - ExternalAssetBalance: sdk.NewUint(866), + ExternalAssetBalance: sdk.NewUint(854), PoolUnits: sdk.NewUint(998), SwapPriceNative: &SwapPriceNative, SwapPriceExternal: &SwapPriceExternal, @@ -371,13 +346,13 @@ func TestKeeper_SwapOneFromGenesis(t *testing.T) { wBasis: sdk.NewInt(1000), asymmetry: sdk.NewInt(10000), pmtpCurrentRunningRate: sdk.MustNewDecFromStr("0.7"), - swapResult: sdk.NewUint(140), - liquidityFee: sdk.NewUint(8), + swapResult: sdk.NewUint(154), + liquidityFee: sdk.NewUint(0), priceImpact: sdk.ZeroUint(), expectedPool: types.Pool{ ExternalAsset: &types.Asset{Symbol: "eth"}, NativeAssetBalance: sdk.NewUint(1098), - ExternalAssetBalance: sdk.NewUint(858), + ExternalAssetBalance: sdk.NewUint(844), PoolUnits: sdk.NewUint(998), SwapPriceNative: &SwapPriceNative, SwapPriceExternal: &SwapPriceExternal, @@ -397,13 +372,13 @@ func TestKeeper_SwapOneFromGenesis(t *testing.T) { wBasis: sdk.NewInt(1000), asymmetry: sdk.NewInt(10000), pmtpCurrentRunningRate: sdk.MustNewDecFromStr("0.8"), - swapResult: sdk.NewUint(148), - liquidityFee: sdk.NewUint(8), + swapResult: sdk.NewUint(163), + liquidityFee: sdk.NewUint(0), priceImpact: sdk.ZeroUint(), expectedPool: types.Pool{ ExternalAsset: &types.Asset{Symbol: "eth"}, NativeAssetBalance: sdk.NewUint(1098), - ExternalAssetBalance: sdk.NewUint(850), + ExternalAssetBalance: sdk.NewUint(835), PoolUnits: sdk.NewUint(998), SwapPriceNative: &SwapPriceNative, SwapPriceExternal: &SwapPriceExternal, @@ -423,13 +398,13 @@ func TestKeeper_SwapOneFromGenesis(t *testing.T) { wBasis: sdk.NewInt(1000), asymmetry: sdk.NewInt(10000), pmtpCurrentRunningRate: sdk.MustNewDecFromStr("0.9"), - swapResult: sdk.NewUint(156), - liquidityFee: sdk.NewUint(8), + swapResult: sdk.NewUint(172), + liquidityFee: sdk.NewUint(0), priceImpact: sdk.ZeroUint(), expectedPool: types.Pool{ ExternalAsset: &types.Asset{Symbol: "eth"}, NativeAssetBalance: sdk.NewUint(1098), - ExternalAssetBalance: sdk.NewUint(842), + ExternalAssetBalance: sdk.NewUint(826), PoolUnits: sdk.NewUint(998), SwapPriceNative: &SwapPriceNative, SwapPriceExternal: &SwapPriceExternal, @@ -449,13 +424,13 @@ func TestKeeper_SwapOneFromGenesis(t *testing.T) { wBasis: sdk.NewInt(1000), asymmetry: sdk.NewInt(10000), pmtpCurrentRunningRate: sdk.MustNewDecFromStr("1.0"), - swapResult: sdk.NewUint(165), - liquidityFee: sdk.NewUint(8), + swapResult: sdk.NewUint(181), + liquidityFee: sdk.NewUint(0), priceImpact: sdk.ZeroUint(), expectedPool: types.Pool{ ExternalAsset: &types.Asset{Symbol: "eth"}, NativeAssetBalance: sdk.NewUint(1098), - ExternalAssetBalance: sdk.NewUint(833), + ExternalAssetBalance: sdk.NewUint(817), PoolUnits: sdk.NewUint(998), SwapPriceNative: &SwapPriceNative, SwapPriceExternal: &SwapPriceExternal, @@ -475,13 +450,13 @@ func TestKeeper_SwapOneFromGenesis(t *testing.T) { wBasis: sdk.NewInt(1000), asymmetry: sdk.NewInt(10000), pmtpCurrentRunningRate: sdk.MustNewDecFromStr("2.0"), - swapResult: sdk.NewUint(247), - liquidityFee: sdk.NewUint(8), + swapResult: sdk.NewUint(271), + liquidityFee: sdk.NewUint(0), priceImpact: sdk.ZeroUint(), expectedPool: types.Pool{ ExternalAsset: &types.Asset{Symbol: "eth"}, NativeAssetBalance: sdk.NewUint(1098), - ExternalAssetBalance: sdk.NewUint(751), + ExternalAssetBalance: sdk.NewUint(727), PoolUnits: sdk.NewUint(998), SwapPriceNative: &SwapPriceNative, SwapPriceExternal: &SwapPriceExternal, @@ -501,13 +476,13 @@ func TestKeeper_SwapOneFromGenesis(t *testing.T) { wBasis: sdk.NewInt(1000), asymmetry: sdk.NewInt(10000), pmtpCurrentRunningRate: sdk.MustNewDecFromStr("3.0"), - swapResult: sdk.NewUint(330), - liquidityFee: sdk.NewUint(8), + swapResult: sdk.NewUint(362), + liquidityFee: sdk.NewUint(1), priceImpact: sdk.ZeroUint(), expectedPool: types.Pool{ ExternalAsset: &types.Asset{Symbol: "eth"}, NativeAssetBalance: sdk.NewUint(1098), - ExternalAssetBalance: sdk.NewUint(668), + ExternalAssetBalance: sdk.NewUint(636), PoolUnits: sdk.NewUint(998), SwapPriceNative: &SwapPriceNative, SwapPriceExternal: &SwapPriceExternal, @@ -527,13 +502,13 @@ func TestKeeper_SwapOneFromGenesis(t *testing.T) { wBasis: sdk.NewInt(1000), asymmetry: sdk.NewInt(10000), pmtpCurrentRunningRate: sdk.MustNewDecFromStr("4.0"), - swapResult: sdk.NewUint(413), - liquidityFee: sdk.NewUint(8), + swapResult: sdk.NewUint(453), + liquidityFee: sdk.NewUint(1), priceImpact: sdk.ZeroUint(), expectedPool: types.Pool{ ExternalAsset: &types.Asset{Symbol: "eth"}, NativeAssetBalance: sdk.NewUint(1098), - ExternalAssetBalance: sdk.NewUint(585), + ExternalAssetBalance: sdk.NewUint(545), PoolUnits: sdk.NewUint(998), SwapPriceNative: &SwapPriceNative, SwapPriceExternal: &SwapPriceExternal, @@ -553,13 +528,13 @@ func TestKeeper_SwapOneFromGenesis(t *testing.T) { wBasis: sdk.NewInt(1000), asymmetry: sdk.NewInt(10000), pmtpCurrentRunningRate: sdk.MustNewDecFromStr("5.0"), - swapResult: sdk.NewUint(495), - liquidityFee: sdk.NewUint(8), + swapResult: sdk.NewUint(543), + liquidityFee: sdk.NewUint(1), priceImpact: sdk.ZeroUint(), expectedPool: types.Pool{ ExternalAsset: &types.Asset{Symbol: "eth"}, NativeAssetBalance: sdk.NewUint(1098), - ExternalAssetBalance: sdk.NewUint(503), + ExternalAssetBalance: sdk.NewUint(455), PoolUnits: sdk.NewUint(998), SwapPriceNative: &SwapPriceNative, SwapPriceExternal: &SwapPriceExternal, @@ -579,13 +554,13 @@ func TestKeeper_SwapOneFromGenesis(t *testing.T) { wBasis: sdk.NewInt(1000), asymmetry: sdk.NewInt(10000), pmtpCurrentRunningRate: sdk.MustNewDecFromStr("6.0"), - swapResult: sdk.NewUint(578), - liquidityFee: sdk.NewUint(8), + swapResult: sdk.NewUint(634), + liquidityFee: sdk.NewUint(1), priceImpact: sdk.ZeroUint(), expectedPool: types.Pool{ ExternalAsset: &types.Asset{Symbol: "eth"}, NativeAssetBalance: sdk.NewUint(1098), - ExternalAssetBalance: sdk.NewUint(420), + ExternalAssetBalance: sdk.NewUint(364), PoolUnits: sdk.NewUint(998), SwapPriceNative: &SwapPriceNative, SwapPriceExternal: &SwapPriceExternal, @@ -605,13 +580,13 @@ func TestKeeper_SwapOneFromGenesis(t *testing.T) { wBasis: sdk.NewInt(1000), asymmetry: sdk.NewInt(10000), pmtpCurrentRunningRate: sdk.MustNewDecFromStr("7.0"), - swapResult: sdk.NewUint(660), - liquidityFee: sdk.NewUint(8), + swapResult: sdk.NewUint(724), + liquidityFee: sdk.NewUint(2), priceImpact: sdk.ZeroUint(), expectedPool: types.Pool{ ExternalAsset: &types.Asset{Symbol: "eth"}, NativeAssetBalance: sdk.NewUint(1098), - ExternalAssetBalance: sdk.NewUint(338), + ExternalAssetBalance: sdk.NewUint(274), PoolUnits: sdk.NewUint(998), SwapPriceNative: &SwapPriceNative, SwapPriceExternal: &SwapPriceExternal, @@ -631,13 +606,13 @@ func TestKeeper_SwapOneFromGenesis(t *testing.T) { wBasis: sdk.NewInt(1000), asymmetry: sdk.NewInt(10000), pmtpCurrentRunningRate: sdk.MustNewDecFromStr("8.0"), - swapResult: sdk.NewUint(743), - liquidityFee: sdk.NewUint(8), + swapResult: sdk.NewUint(815), + liquidityFee: sdk.NewUint(2), priceImpact: sdk.ZeroUint(), expectedPool: types.Pool{ ExternalAsset: &types.Asset{Symbol: "eth"}, NativeAssetBalance: sdk.NewUint(1098), - ExternalAssetBalance: sdk.NewUint(255), + ExternalAssetBalance: sdk.NewUint(183), PoolUnits: sdk.NewUint(998), SwapPriceNative: &SwapPriceNative, SwapPriceExternal: &SwapPriceExternal, @@ -657,13 +632,13 @@ func TestKeeper_SwapOneFromGenesis(t *testing.T) { wBasis: sdk.NewInt(1000), asymmetry: sdk.NewInt(10000), pmtpCurrentRunningRate: sdk.MustNewDecFromStr("9.0"), - swapResult: sdk.NewUint(826), - liquidityFee: sdk.NewUint(8), + swapResult: sdk.NewUint(906), + liquidityFee: sdk.NewUint(2), priceImpact: sdk.ZeroUint(), expectedPool: types.Pool{ ExternalAsset: &types.Asset{Symbol: "eth"}, NativeAssetBalance: sdk.NewUint(1098), - ExternalAssetBalance: sdk.NewUint(172), + ExternalAssetBalance: sdk.NewUint(92), PoolUnits: sdk.NewUint(998), SwapPriceNative: &SwapPriceNative, SwapPriceExternal: &SwapPriceExternal, @@ -683,13 +658,13 @@ func TestKeeper_SwapOneFromGenesis(t *testing.T) { wBasis: sdk.NewInt(1000), asymmetry: sdk.NewInt(10000), pmtpCurrentRunningRate: sdk.MustNewDecFromStr("10.0"), - swapResult: sdk.NewUint(908), - liquidityFee: sdk.NewUint(8), + swapResult: sdk.NewUint(996), + liquidityFee: sdk.NewUint(2), priceImpact: sdk.ZeroUint(), expectedPool: types.Pool{ ExternalAsset: &types.Asset{Symbol: "eth"}, NativeAssetBalance: sdk.NewUint(1098), - ExternalAssetBalance: sdk.NewUint(90), + ExternalAssetBalance: sdk.NewUint(2), PoolUnits: sdk.NewUint(998), SwapPriceNative: &SwapPriceNative, SwapPriceExternal: &SwapPriceExternal, @@ -836,6 +811,7 @@ func TestKeeper_SwapOneFromGenesis(t *testing.T) { to, pool, tc.pmtpCurrentRunningRate, + sdk.NewDecWithPrec(3, 3), ) if tc.errString != nil { @@ -848,10 +824,10 @@ func TestKeeper_SwapOneFromGenesis(t *testing.T) { } require.NoError(t, err) - require.Equal(t, swapResult, tc.swapResult, "swapResult") - require.Equal(t, liquidityFee, tc.liquidityFee) - require.Equal(t, priceImpact, tc.priceImpact) - require.Equal(t, newPool, tc.expectedPool) + require.Equal(t, tc.swapResult.String(), swapResult.String(), "swapResult") + require.Equal(t, tc.liquidityFee.String(), liquidityFee.String()) + require.Equal(t, tc.priceImpact.String(), priceImpact.String()) + require.Equal(t, tc.expectedPool, newPool) }) } } diff --git a/x/clp/keeper/calculations_test.go b/x/clp/keeper/calculations_test.go index 23605e42b2..10580057db 100644 --- a/x/clp/keeper/calculations_test.go +++ b/x/clp/keeper/calculations_test.go @@ -60,37 +60,88 @@ func TestKeeper_CheckBalances(t *testing.T) { } func TestKeeper_SwapOne(t *testing.T) { - ctx, app := test.CreateTestAppClp(false) - signer := test.GenerateAddress(test.AddressKey1) - //Parameters for create pool - nativeAssetAmount := sdk.NewUintFromString("998") - externalAssetAmount := sdk.NewUintFromString("998") - asset := types.NewAsset("eth") - externalCoin := sdk.NewCoin(asset.Symbol, sdk.Int(sdk.NewUint(10000))) - nativeCoin := sdk.NewCoin(types.NativeSymbol, sdk.Int(sdk.NewUint(10000))) - wBasis := sdk.NewInt(1000) - asymmetry := sdk.NewInt(10000) - err := sifapp.AddCoinsToAccount(types.ModuleName, app.BankKeeper, ctx, signer, sdk.NewCoins(externalCoin, nativeCoin)) - require.NoError(t, err) - msgCreatePool := types.NewMsgCreatePool(signer, asset, nativeAssetAmount, externalAssetAmount) - // Create Pool - pool, err := app.ClpKeeper.CreatePool(ctx, sdk.NewUint(1), &msgCreatePool) - assert.NoError(t, err) - msg := types.NewMsgAddLiquidity(signer, asset, nativeAssetAmount, externalAssetAmount) - app.ClpKeeper.CreateLiquidityProvider(ctx, &asset, sdk.NewUint(1), signer) - lp, err := app.ClpKeeper.AddLiquidity(ctx, &msg, *pool, sdk.NewUint(1), sdk.NewUint(998)) - assert.NoError(t, err) - registry := app.TokenRegistryKeeper.GetRegistry(ctx) - _, err = app.TokenRegistryKeeper.GetEntry(registry, pool.ExternalAsset.Symbol) - assert.NoError(t, err) - // asymmetry is positive - _, _, _, swapAmount := clpkeeper.CalculateWithdrawal(pool.PoolUnits, - pool.NativeAssetBalance.String(), pool.ExternalAssetBalance.String(), lp.LiquidityProviderUnits.String(), wBasis.String(), asymmetry) - swapResult, liquidityFee, priceImpact, _, err := FEATURE_TOGGLE_MARGIN_CLI_ALPHA_SwapOne(ctx, app.ClpKeeper, types.GetSettlementAsset(), swapAmount, asset, *pool, sdk.OneDec()) - assert.NoError(t, err) - assert.Equal(t, "19", swapResult.String()) - assert.Equal(t, "978", liquidityFee.String()) - assert.Equal(t, "0", priceImpact.String()) + testcases := []struct { + name string + nativeAssetBalance sdk.Uint + externalAssetBalance sdk.Uint + sentAmount sdk.Uint + fromAsset types.Asset + toAsset types.Asset + pmtpCurrentRunningRate sdk.Dec + errString error + expectedSwapResult sdk.Uint + expectedLiquidityFee sdk.Uint + expectedPriceImpact sdk.Uint + expectedExternalAssetBalance sdk.Uint + expectedNativeAssetBalance sdk.Uint + }{ + { + name: "test1", + nativeAssetBalance: sdk.NewUint(1000), + externalAssetBalance: sdk.NewUint(877), + sentAmount: sdk.NewUint(50), + fromAsset: types.GetSettlementAsset(), + toAsset: types.NewAsset("eth"), + pmtpCurrentRunningRate: sdk.NewDec(0), + expectedSwapResult: sdk.NewUint(41), + expectedLiquidityFee: sdk.NewUint(0), + expectedPriceImpact: sdk.ZeroUint(), + expectedExternalAssetBalance: sdk.NewUint(836), + expectedNativeAssetBalance: sdk.NewUint(1050), + }, + { + name: "test2", + nativeAssetBalance: sdk.NewUint(10000000), + externalAssetBalance: sdk.NewUint(8770000), + sentAmount: sdk.NewUint(50000), + fromAsset: types.GetSettlementAsset(), + toAsset: types.NewAsset("eth"), + pmtpCurrentRunningRate: sdk.NewDec(0), + expectedSwapResult: sdk.NewUint(43500), + expectedLiquidityFee: sdk.NewUint(130), + expectedPriceImpact: sdk.ZeroUint(), + expectedExternalAssetBalance: sdk.NewUint(8726500), + expectedNativeAssetBalance: sdk.NewUint(10050000), + }, + { + name: "test3", + nativeAssetBalance: sdk.NewUintFromString("157007500498726220240179086"), + externalAssetBalance: sdk.NewUint(2674623482959), + sentAmount: sdk.NewUint(200000000), + toAsset: types.GetSettlementAsset(), + fromAsset: types.NewAsset("cusdt"), + pmtpCurrentRunningRate: sdk.NewDec(0), + expectedSwapResult: sdk.NewUintFromString("11704434254784015637542"), + expectedLiquidityFee: sdk.NewUintFromString("35218959643281892590"), + expectedPriceImpact: sdk.ZeroUint(), + expectedExternalAssetBalance: sdk.NewUint(2674823482959), + expectedNativeAssetBalance: sdk.NewUintFromString("156995796064471436224541544"), + }, + } + + for _, tc := range testcases { + tc := tc + t.Run(tc.name, func(t *testing.T) { + ctx, app := test.CreateTestAppClp(false) + poolUnits := sdk.NewUint(2000) //don't care + pool := types.NewPool(&tc.toAsset, tc.nativeAssetBalance, tc.externalAssetBalance, poolUnits) + + swapResult, liquidityFee, priceImpact, pool, err := FEATURE_TOGGLE_MARGIN_CLI_ALPHA_SwapOne(ctx, app.ClpKeeper, tc.fromAsset, tc.sentAmount, tc.toAsset, pool, tc.pmtpCurrentRunningRate, sdk.NewDecWithPrec(3, 3)) + + if tc.errString != nil { + require.EqualError(t, err, tc.errString.Error()) + return + } + + assert.NoError(t, err) + require.Equal(t, tc.expectedSwapResult.String(), swapResult.String()) + require.Equal(t, tc.expectedLiquidityFee.String(), liquidityFee.String()) + require.Equal(t, tc.expectedPriceImpact.String(), priceImpact.String()) + require.Equal(t, tc.expectedExternalAssetBalance.String(), pool.ExternalAssetBalance.String()) + require.Equal(t, tc.expectedNativeAssetBalance.String(), pool.NativeAssetBalance.String()) + }) + } + } func TestKeeper_ExtractValuesFromPool(t *testing.T) { @@ -128,7 +179,7 @@ func TestKeeper_GetSwapFee(t *testing.T) { msgCreatePool := types.NewMsgCreatePool(signer, asset, nativeAssetAmount, externalAssetAmount) // Create Pool pool, _ := app.ClpKeeper.CreatePool(ctx, sdk.NewUint(1), &msgCreatePool) - swapResult := FEATURE_TOGGLE_MARGIN_CLI_ALPHA_GetSwapFee(ctx, app.ClpKeeper, &asset, sdk.NewUint(1), *pool, sdk.OneDec()) + swapResult := FEATURE_TOGGLE_MARGIN_CLI_ALPHA_GetSwapFee(ctx, app.ClpKeeper, &asset, sdk.NewUint(1), *pool, sdk.OneDec(), sdk.NewDecWithPrec(3, 3)) assert.Equal(t, "1", swapResult.String()) } @@ -140,7 +191,7 @@ func TestKeeper_GetSwapFee_PmtpParams(t *testing.T) { } asset := types.Asset{} - swapResult := FEATURE_TOGGLE_MARGIN_CLI_ALPHA_GetSwapFee(ctx, app.ClpKeeper, &asset, sdk.NewUint(1), pool, sdk.NewDec(100)) + swapResult := FEATURE_TOGGLE_MARGIN_CLI_ALPHA_GetSwapFee(ctx, app.ClpKeeper, &asset, sdk.NewUint(1), pool, sdk.NewDec(100), sdk.NewDecWithPrec(3, 3)) require.Equal(t, swapResult, sdk.ZeroUint()) } @@ -531,53 +582,59 @@ func TestKeeper_CalcLiquidityFee(t *testing.T) { errString error }{ { - name: "success", - X: sdk.NewUint(0), - x: sdk.NewUint(0), - Y: sdk.NewUint(1), - fee: sdk.NewUint(0), + name: "success", + toRowan: true, + X: sdk.NewUint(0), + x: sdk.NewUint(0), + Y: sdk.NewUint(1), + fee: sdk.NewUint(0), }, { - name: "success", - X: sdk.NewUint(1), - x: sdk.NewUint(1), - Y: sdk.NewUint(1), - fee: sdk.NewUint(0), + name: "success", + toRowan: true, + X: sdk.NewUint(1), + x: sdk.NewUint(1), + Y: sdk.NewUint(1), + fee: sdk.NewUint(0), }, { - name: "success", - X: sdk.NewUint(1), - x: sdk.NewUint(1), - Y: sdk.NewUint(4), - fee: sdk.NewUint(1), + name: "success", + toRowan: true, + X: sdk.NewUint(1), + x: sdk.NewUint(1), + Y: sdk.NewUint(4), + fee: sdk.NewUint(0), }, { - name: "success", - X: sdk.NewUint(2), - x: sdk.NewUint(2), - Y: sdk.NewUint(16), - fee: sdk.NewUint(4), + name: "success", + toRowan: true, + X: sdk.NewUint(2), + x: sdk.NewUint(2), + Y: sdk.NewUint(16), + fee: sdk.NewUint(0), }, { - name: "success", - X: sdk.NewUint(1054677676764), - x: sdk.NewUint(2567655449999), - Y: sdk.NewUint(1099511627776), - fee: sdk.NewUint(552454535440), + name: "success", + toRowan: true, + X: sdk.NewUint(1054677676764), + x: sdk.NewUint(2567655449999), + Y: sdk.NewUint(1099511627776), + fee: sdk.NewUint(2292288459), }, { - name: "success", - X: sdk.NewUintFromString("20300000000000000000000000000000000000000000000000000000000000000000000000"), - x: sdk.NewUintFromString("10000000000000000658000000000000000000000000000000000000000000000000000000"), - Y: sdk.NewUintFromString("10000000000000000000000000000000000000000000000000000000000000000000021344"), - fee: sdk.NewUintFromString("1089217832674356640599131638158097447402363655799918705091874559386226334"), + name: "success", + toRowan: true, + X: sdk.NewUintFromString("20300000000000000000000000000000000000000000000000000000000000000000000000"), + x: sdk.NewUintFromString("10000000000000000658000000000000000000000000000000000000000000000000000000"), + Y: sdk.NewUintFromString("10000000000000000000000000000000000000000000000000000000000000000000021344"), + fee: sdk.NewUintFromString("9706853038245001398600547299925090963413469041036560829464056119132287"), }, } for _, tc := range testcases { tc := tc t.Run(tc.name, func(t *testing.T) { - fee := clpkeeper.CalcLiquidityFee(tc.X, tc.x, tc.Y) + fee := clpkeeper.CalcLiquidityFee(tc.toRowan, tc.X, tc.x, tc.Y, sdk.NewDecWithPrec(3, 3), sdk.NewDecWithPrec(2, 2)) require.Equal(t, tc.fee.String(), fee.String()) // compare strings so that the expected amounts can be read from the failure message }) } @@ -589,6 +646,7 @@ func TestKeeper_CalcSwapResult(t *testing.T) { toRowan bool X, x, Y, y sdk.Uint pmtpCurrentRunningRate sdk.Dec + swapFeeRate sdk.Dec err error errString error }{ @@ -600,6 +658,7 @@ func TestKeeper_CalcSwapResult(t *testing.T) { Y: sdk.NewUint(1), y: sdk.NewUint(0), pmtpCurrentRunningRate: sdk.NewDec(1), + swapFeeRate: sdk.NewDecWithPrec(3, 3), }, { name: "adjust external token without rowan", @@ -609,6 +668,7 @@ func TestKeeper_CalcSwapResult(t *testing.T) { Y: sdk.NewUint(1), y: sdk.NewUint(0), pmtpCurrentRunningRate: sdk.NewDec(1), + swapFeeRate: sdk.NewDecWithPrec(3, 3), }, { name: "x=0, X=0, Y=0", @@ -618,6 +678,7 @@ func TestKeeper_CalcSwapResult(t *testing.T) { Y: sdk.NewUint(0), y: sdk.NewUint(0), pmtpCurrentRunningRate: sdk.NewDec(0), + swapFeeRate: sdk.NewDecWithPrec(3, 3), }, { name: "x=1, X=1, Y=1", @@ -627,6 +688,7 @@ func TestKeeper_CalcSwapResult(t *testing.T) { Y: sdk.NewUint(1), y: sdk.NewUint(0), pmtpCurrentRunningRate: sdk.NewDec(0), + swapFeeRate: sdk.NewDecWithPrec(3, 3), }, { name: "x=1, X=1, Y=4", @@ -636,6 +698,7 @@ func TestKeeper_CalcSwapResult(t *testing.T) { Y: sdk.NewUint(4), y: sdk.NewUint(1), pmtpCurrentRunningRate: sdk.NewDec(0), + swapFeeRate: sdk.NewDecWithPrec(3, 3), }, { name: "x=1, X=1, Y=4, nf=10", @@ -645,13 +708,34 @@ func TestKeeper_CalcSwapResult(t *testing.T) { Y: sdk.NewUint(4), y: sdk.NewUint(1), pmtpCurrentRunningRate: sdk.NewDec(0), + swapFeeRate: sdk.NewDecWithPrec(3, 3), + }, + { + name: "x=23, X=42, Y=1337", + toRowan: true, + X: sdk.NewUint(42), + x: sdk.NewUint(23), + Y: sdk.NewUint(1337), + y: sdk.NewUint(471), + pmtpCurrentRunningRate: sdk.NewDec(0), + swapFeeRate: sdk.NewDecWithPrec(3, 3), + }, + { + name: "swap fee rate = 0.01", + toRowan: false, + X: sdk.NewUint(1999800619938006200), + x: sdk.NewUint(200000000000000), + Y: sdk.NewUint(2000200000000000000), + y: sdk.NewUint(198019738620019), + pmtpCurrentRunningRate: sdk.NewDec(0), + swapFeeRate: sdk.NewDecWithPrec(1, 2), }, } for _, tc := range testcases { tc := tc t.Run(tc.name, func(t *testing.T) { - y := clpkeeper.CalcSwapResult(tc.toRowan, tc.X, tc.x, tc.Y, tc.pmtpCurrentRunningRate) + y := clpkeeper.CalcSwapResult(tc.toRowan, tc.X, tc.x, tc.Y, tc.pmtpCurrentRunningRate, tc.swapFeeRate) require.Equal(t, tc.y.String(), y.String()) // compare strings so that the expected amounts can be read from the failure message }) @@ -730,7 +814,7 @@ func TestKeeper_CalcDenomChangeMultiplier(t *testing.T) { } } -//nolint +// nolint func TestKeeper_CalcSpotPriceX(t *testing.T) { testcases := []struct { @@ -815,14 +899,14 @@ func TestKeeper_CalcSpotPriceX(t *testing.T) { expected: sdk.NewDecFromBigIntWithPrec(getFirstArg(big.NewInt(1).SetString("1606938044258990275541962092341162602522202993782792835301376000000000000000000", 10)), 18), }, { - name: "success big decimals", + name: "failure big decimals", X: sdk.NewUint(100), Y: sdk.NewUint(100), decimalsX: 255, decimalsY: 0, pmtpCurrentRunningRate: sdk.NewDec(0), isXNative: true, - expected: sdk.NewDecFromBigIntWithPrec(getFirstArg(big.NewInt(1).SetString("1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", 10)), 18), + errString: errors.New("decimal out of range; bitLen: got 907, max 315"), }, { name: "success big decimals, small answer", @@ -1027,12 +1111,12 @@ func TestKeeper_CalcSpotPriceExternal(t *testing.T) { expected: sdk.NewDecFromBigIntWithPrec(getFirstArg(big.NewInt(1).SetString("1606938044258990275541962092341162602522202993782792835301376000000000000000000", 10)), 18), }, { - name: "success big decimals", + name: "failure big decimals", nativeAssetBalance: sdk.NewUint(100), externalAssetBalance: sdk.NewUint(100), decimalsExternal: 255, pmtpCurrentRunningRate: sdk.NewDec(0), - expected: sdk.NewDecFromBigIntWithPrec(getFirstArg(big.NewInt(1).SetString("1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", 10)), 18), + errString: errors.New("decimal out of range; bitLen: got 848, max 315"), }, { name: "success small decimals", @@ -1112,7 +1196,7 @@ func TestKeeper_CalculateRatioDiff(t *testing.T) { require.NoError(t, err) - ratioDec := clpkeeper.RatToDec(&ratio) + ratioDec, _ := clpkeeper.RatToDec(&ratio) require.Equal(t, tc.expected.String(), ratioDec.String()) }) diff --git a/x/clp/keeper/executors_FEATURE_TOGGLE_MARGIN_CLI_ALPHA.go b/x/clp/keeper/executors_FEATURE_TOGGLE_MARGIN_CLI_ALPHA.go index dbe9b082e9..51c560e024 100644 --- a/x/clp/keeper/executors_FEATURE_TOGGLE_MARGIN_CLI_ALPHA.go +++ b/x/clp/keeper/executors_FEATURE_TOGGLE_MARGIN_CLI_ALPHA.go @@ -28,6 +28,7 @@ func (k Keeper) ProcessRemoveLiquidityMsg(ctx sdk.Context, msg *types.MsgRemoveL poolOriginalEB := pool.ExternalAssetBalance poolOriginalNB := pool.NativeAssetBalance pmtpCurrentRunningRate := k.GetPmtpRateParams(ctx).PmtpCurrentRunningRate + swapFeeRate := k.GetSwapFeeRate(ctx).SwapFeeRate //Calculate amount to withdraw withdrawNativeAssetAmount, withdrawExternalAssetAmount, lpUnitsLeft, swapAmount := CalculateWithdrawal(pool.PoolUnits, @@ -35,7 +36,7 @@ func (k Keeper) ProcessRemoveLiquidityMsg(ctx sdk.Context, msg *types.MsgRemoveL msg.WBasisPoints.String(), msg.Asymmetry) marginEnabled := k.getMarginKeeper().IsPoolEnabled(ctx, pool.String()) - extRowanValue := CalculateWithdrawalRowanValue(withdrawExternalAssetAmount, types.GetSettlementAsset(), pool, pmtpCurrentRunningRate, marginEnabled) + extRowanValue := CalculateWithdrawalRowanValue(withdrawExternalAssetAmount, types.GetSettlementAsset(), pool, pmtpCurrentRunningRate, swapFeeRate, marginEnabled) withdrawExternalAssetAmountInt, ok := k.ParseToInt(withdrawExternalAssetAmount.String()) if !ok { @@ -58,7 +59,7 @@ func (k Keeper) ProcessRemoveLiquidityMsg(ctx sdk.Context, msg *types.MsgRemoveL // Swapping between Native and External based on Asymmetry if msg.Asymmetry.IsPositive() { marginEnabled := k.getMarginKeeper().IsPoolEnabled(ctx, pool.String()) - swapResult, _, _, swappedPool, err := SwapOne(types.GetSettlementAsset(), swapAmount, *msg.ExternalAsset, pool, pmtpCurrentRunningRate, marginEnabled) + swapResult, _, _, swappedPool, err := SwapOne(types.GetSettlementAsset(), swapAmount, *msg.ExternalAsset, pool, pmtpCurrentRunningRate, swapFeeRate, marginEnabled) if err != nil { return sdk.ZeroInt(), sdk.ZeroInt(), sdk.ZeroUint(), sdkerrors.Wrap(types.ErrUnableToSwap, err.Error()) } @@ -80,7 +81,7 @@ func (k Keeper) ProcessRemoveLiquidityMsg(ctx sdk.Context, msg *types.MsgRemoveL } if msg.Asymmetry.IsNegative() { marginEnabled := k.getMarginKeeper().IsPoolEnabled(ctx, pool.String()) - swapResult, _, _, swappedPool, err := SwapOne(*msg.ExternalAsset, swapAmount, types.GetSettlementAsset(), pool, pmtpCurrentRunningRate, marginEnabled) + swapResult, _, _, swappedPool, err := SwapOne(*msg.ExternalAsset, swapAmount, types.GetSettlementAsset(), pool, pmtpCurrentRunningRate, swapFeeRate, marginEnabled) if err != nil { return sdk.ZeroInt(), sdk.ZeroInt(), sdk.ZeroUint(), sdkerrors.Wrap(types.ErrUnableToSwap, err.Error()) } diff --git a/x/clp/keeper/grpc_query.go b/x/clp/keeper/grpc_query.go index 5c9015abe1..7909029d84 100755 --- a/x/clp/keeper/grpc_query.go +++ b/x/clp/keeper/grpc_query.go @@ -267,3 +267,10 @@ func (k Querier) GetProviderDistributionParams(c context.Context, _ *types.Provi return &types.ProviderDistributionParamsRes{Params: params}, nil } + +func (k Querier) GetSwapFeeRate(c context.Context, _ *types.SwapFeeRateReq) (*types.SwapFeeRateRes, error) { + ctx := sdk.UnwrapSDKContext(c) + swapFeeRate := k.Keeper.GetSwapFeeRate(ctx) + + return &types.SwapFeeRateRes{SwapFeeRate: swapFeeRate.SwapFeeRate}, nil +} diff --git a/x/clp/keeper/keeper.go b/x/clp/keeper/keeper.go index 727e8764c5..6ce164555e 100644 --- a/x/clp/keeper/keeper.go +++ b/x/clp/keeper/keeper.go @@ -3,8 +3,6 @@ package keeper import ( "fmt" - tokenregistrytypes "github.com/Sifchain/sifnode/x/tokenregistry/types" - "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/tendermint/tendermint/libs/log" @@ -42,35 +40,6 @@ func (k Keeper) HasBalance(ctx sdk.Context, addr sdk.AccAddress, coin sdk.Coin) return k.bankKeeper.HasBalance(ctx, addr, coin) } -func (k Keeper) GetNormalizationFactor(decimals int64) (sdk.Dec, bool) { - normalizationFactor := sdk.NewDec(1) - adjustExternalToken := false - nf := decimals - if nf != 18 { - var diffFactor int64 - if nf < 18 { - diffFactor = 18 - nf - adjustExternalToken = true - } else { - diffFactor = nf - 18 - } - normalizationFactor = sdk.NewDec(10).Power(uint64(diffFactor)) - } - return normalizationFactor, adjustExternalToken -} - -func (k Keeper) GetNormalizationFactorFromAsset(ctx sdk.Context, asset types.Asset) (sdk.Dec, bool, error) { - registry := k.tokenRegistryKeeper.GetRegistry(ctx) - registryEntry, err := k.tokenRegistryKeeper.GetEntry(registry, asset.Symbol) - if err != nil { - return sdk.Dec{}, false, tokenregistrytypes.ErrNotFound - } - - nf, adjust := k.GetNormalizationFactor(registryEntry.Decimals) - - return nf, adjust, nil -} - func (k Keeper) GetAssetDecimals(ctx sdk.Context, asset types.Asset) (uint8, error) { registry := k.tokenRegistryKeeper.GetRegistry(ctx) registryEntry, err := k.tokenRegistryKeeper.GetEntry(registry, asset.Symbol) diff --git a/x/clp/keeper/keeper_test.go b/x/clp/keeper/keeper_test.go index 9d4f32b2a6..c870abd9cb 100644 --- a/x/clp/keeper/keeper_test.go +++ b/x/clp/keeper/keeper_test.go @@ -80,142 +80,7 @@ func TestKeeper_GetBankKeeper(t *testing.T) { require.NotNil(t, got) } -func TestKeeper_GetNormalizationFactor(t *testing.T) { - testcases := - []struct { - name string - decimals int64 - normalizationFactor sdk.Dec - adjustExternalToken bool - expPanic bool - expPanicMsg string - }{ - { - name: "big decimals number throws error", - decimals: 100000000, - expPanic: true, - expPanicMsg: "Int overflow", - }, - { - name: "decimals less than 18", - decimals: 10, - normalizationFactor: sdk.NewDec(100000000), - adjustExternalToken: true, - }, - { - name: "decimals greater than or equal to 18", - decimals: 20, - normalizationFactor: sdk.NewDec(100), - adjustExternalToken: false, - }, - { - name: "with 6 decimals", - decimals: 6, - normalizationFactor: sdk.NewDec(1000000000000), - adjustExternalToken: true, - }, - } - - for _, tc := range testcases { - tc := tc - t.Run(tc.name, func(t *testing.T) { - _, app := test.CreateTestAppClp(false) - clpKeeper := app.ClpKeeper - - if tc.expPanic { - require.PanicsWithValue(t, tc.expPanicMsg, func() { - clpKeeper.GetNormalizationFactor(tc.decimals) - }) - } else { - normalizationFactor, adjustExternalToken := clpKeeper.GetNormalizationFactor(tc.decimals) - - require.NotNil(t, normalizationFactor) - require.Equal(t, tc.normalizationFactor, normalizationFactor) - require.Equal(t, tc.adjustExternalToken, adjustExternalToken) - } - }) - } -} - -func TestKeeper_GetNormalizationFactorFromAsset(t *testing.T) { - testcases := - []struct { - name string - denom string - expPanicMsg string - asset types.Asset - decimals int64 - normalizationFactor sdk.Dec - createToken bool - adjustExternalToken bool - expPanic bool - }{ - { - name: "big decimals number throws error", - asset: types.Asset{Symbol: "xxx"}, - createToken: true, - denom: "xxx", - decimals: 100000000, - expPanic: true, - expPanicMsg: "Int overflow", - }, - { - name: "unknown symbol", - createToken: false, - asset: types.Asset{Symbol: "xxx"}, - adjustExternalToken: false, - }, - { - name: "decimals less than 18", - asset: types.Asset{Symbol: "xxx"}, - createToken: true, - denom: "xxx", - decimals: 10, - normalizationFactor: sdk.NewDec(100000000), - adjustExternalToken: true, - }, - { - name: "decimals greater than or equal to 18", - asset: types.Asset{Symbol: "xxx"}, - createToken: true, - denom: "xxx", - decimals: 20, - normalizationFactor: sdk.NewDec(100), - adjustExternalToken: false, - }, - } - - for _, tc := range testcases { - tc := tc - t.Run(tc.name, func(t *testing.T) { - ctx, app := test.CreateTestAppClp(false) - clpKeeper := app.ClpKeeper - - if tc.createToken { - app.TokenRegistryKeeper.SetToken(ctx, &tokenregistrytypes.RegistryEntry{ - Denom: tc.denom, - Decimals: tc.decimals, - Permissions: []tokenregistrytypes.Permission{tokenregistrytypes.Permission_CLP}, - }) - } - - if tc.expPanic { - require.PanicsWithValue(t, tc.expPanicMsg, func() { - // nolint:errcheck - clpKeeper.GetNormalizationFactorFromAsset(ctx, tc.asset) - }) - } else { - normalizationFactor, adjustExternalToken, _ := clpKeeper.GetNormalizationFactorFromAsset(ctx, tc.asset) - - require.NotNil(t, normalizationFactor) - require.Equal(t, tc.normalizationFactor, normalizationFactor) - require.Equal(t, tc.adjustExternalToken, adjustExternalToken) - } - }) - } -} - -//nolint +// nolint func TestKeeper_GetAssetDecimals(t *testing.T) { testcases := []struct { diff --git a/x/clp/keeper/msg_server.go b/x/clp/keeper/msg_server.go index f1f2006759..98597fd57f 100644 --- a/x/clp/keeper/msg_server.go +++ b/x/clp/keeper/msg_server.go @@ -473,6 +473,7 @@ func (k msgServer) Swap(goCtx context.Context, msg *types.MsgSwap) (*types.MsgSw } pmtpCurrentRunningRate := k.GetPmtpRateParams(ctx).PmtpCurrentRunningRate + swapFeeRate := k.GetSwapFeeRate(ctx).SwapFeeRate liquidityProtectionParams := k.GetLiquidityProtectionParams(ctx) maxRowanLiquidityThreshold := liquidityProtectionParams.MaxRowanLiquidityThreshold @@ -536,7 +537,7 @@ func (k msgServer) Swap(goCtx context.Context, msg *types.MsgSwap) (*types.MsgSw // Check if its a two way swap, swapping non native fro non native . // If its one way we can skip this if condition and add balance to users account from outpool if !msg.SentAsset.Equals(nativeAsset) && !msg.ReceivedAsset.Equals(nativeAsset) { - emitAmount, lp, ts, finalPool, err := FEATURE_TOGGLE_MARGIN_CLI_ALPHA_SwapOne(ctx, k, *sentAsset, sentAmount, nativeAsset, inPool, pmtpCurrentRunningRate) + emitAmount, lp, ts, finalPool, err := FEATURE_TOGGLE_MARGIN_CLI_ALPHA_SwapOne(ctx, k, *sentAsset, sentAmount, nativeAsset, inPool, pmtpCurrentRunningRate, swapFeeRate) if err != nil { return nil, err } @@ -562,7 +563,7 @@ func (k msgServer) Swap(goCtx context.Context, msg *types.MsgSwap) (*types.MsgSw } } // Calculating amount user receives - emitAmount, lp, ts, finalPool, err := FEATURE_TOGGLE_MARGIN_CLI_ALPHA_SwapOne(ctx, k, *sentAsset, sentAmount, *receivedAsset, outPool, pmtpCurrentRunningRate) + emitAmount, lp, ts, finalPool, err := FEATURE_TOGGLE_MARGIN_CLI_ALPHA_SwapOne(ctx, k, *sentAsset, sentAmount, *receivedAsset, outPool, pmtpCurrentRunningRate, swapFeeRate) if err != nil { return nil, err } @@ -591,7 +592,7 @@ func (k msgServer) Swap(goCtx context.Context, msg *types.MsgSwap) (*types.MsgSw } if liquidityFeeNative.GT(sdk.ZeroUint()) { liquidityFeeExternal = liquidityFeeExternal.Add(lp) - firstSwapFeeInOutputAsset := FEATURE_TOGGLE_MARGIN_CLI_ALPHA_GetSwapFee(ctx, k, msg.ReceivedAsset, liquidityFeeNative, outPool, pmtpCurrentRunningRate) + firstSwapFeeInOutputAsset := FEATURE_TOGGLE_MARGIN_CLI_ALPHA_GetSwapFee(ctx, k, msg.ReceivedAsset, liquidityFeeNative, outPool, pmtpCurrentRunningRate, swapFeeRate) totalLiquidityFee = liquidityFeeExternal.Add(firstSwapFeeInOutputAsset) } else { totalLiquidityFee = liquidityFeeNative.Add(lp) @@ -742,6 +743,7 @@ func (k msgServer) RemoveLiquidityUnits(goCtx context.Context, msg *types.MsgRem poolOriginalEB := pool.ExternalAssetBalance poolOriginalNB := pool.NativeAssetBalance pmtpCurrentRunningRate := k.GetPmtpRateParams(ctx).PmtpCurrentRunningRate + swapFeeRate := k.GetSwapFeeRate(ctx).SwapFeeRate // Prune pools params := k.GetRewardsParams(ctx) k.PruneUnlockRecords(ctx, &lp, params.LiquidityRemovalLockPeriod, params.LiquidityRemovalCancelPeriod) @@ -756,7 +758,7 @@ func (k msgServer) RemoveLiquidityUnits(goCtx context.Context, msg *types.MsgRem return nil, err } - err = FEATURE_TOGGLE_MARGIN_CLI_ALPHA_QueueRemovalWithWithdrawUnits(ctx, k, msg, lp, pool, withdrawNativeAssetAmount, withdrawExternalAssetAmount, eAsset, pmtpCurrentRunningRate) + err = FEATURE_TOGGLE_MARGIN_CLI_ALPHA_QueueRemovalWithWithdrawUnits(ctx, k, msg, lp, pool, withdrawNativeAssetAmount, withdrawExternalAssetAmount, eAsset, pmtpCurrentRunningRate, swapFeeRate) if err != nil { return nil, err } @@ -823,6 +825,7 @@ func (k msgServer) RemoveLiquidity(goCtx context.Context, msg *types.MsgRemoveLi poolOriginalEB := pool.ExternalAssetBalance poolOriginalNB := pool.NativeAssetBalance pmtpCurrentRunningRate := k.GetPmtpRateParams(ctx).PmtpCurrentRunningRate + swapFeeRate := k.GetSwapFeeRate(ctx).SwapFeeRate // Prune pools params := k.GetRewardsParams(ctx) k.PruneUnlockRecords(ctx, &lp, params.LiquidityRemovalLockPeriod, params.LiquidityRemovalCancelPeriod) @@ -847,7 +850,7 @@ func (k msgServer) RemoveLiquidity(goCtx context.Context, msg *types.MsgRemoveLi return nil, err } - err = FEATURE_TOGGLE_MARGIN_CLI_ALPHA_QueueRemovalWithWBasisPoints(ctx, k, msg, lp, pool, withdrawNativeAssetAmount, withdrawExternalAssetAmount, eAsset, pmtpCurrentRunningRate) + err = FEATURE_TOGGLE_MARGIN_CLI_ALPHA_QueueRemovalWithWBasisPoints(ctx, k, msg, lp, pool, withdrawNativeAssetAmount, withdrawExternalAssetAmount, eAsset, pmtpCurrentRunningRate, swapFeeRate) if err != nil { return nil, err } @@ -873,7 +876,7 @@ func (k msgServer) RemoveLiquidity(goCtx context.Context, msg *types.MsgRemoveLi } // Swapping between Native and External based on Asymmetry if msg.Asymmetry.IsPositive() { - swapResult, _, _, swappedPool, err := FEATURE_TOGGLE_MARGIN_CLI_ALPHA_SwapOne(ctx, k, types.GetSettlementAsset(), swapAmount, *msg.ExternalAsset, pool, pmtpCurrentRunningRate) + swapResult, _, _, swappedPool, err := FEATURE_TOGGLE_MARGIN_CLI_ALPHA_SwapOne(ctx, k, types.GetSettlementAsset(), swapAmount, *msg.ExternalAsset, pool, pmtpCurrentRunningRate, swapFeeRate) if err != nil { return nil, sdkerrors.Wrap(types.ErrUnableToSwap, err.Error()) } @@ -894,7 +897,7 @@ func (k msgServer) RemoveLiquidity(goCtx context.Context, msg *types.MsgRemoveLi pool = swappedPool } if msg.Asymmetry.IsNegative() { - swapResult, _, _, swappedPool, err := FEATURE_TOGGLE_MARGIN_CLI_ALPHA_SwapOne(ctx, k, *msg.ExternalAsset, swapAmount, types.GetSettlementAsset(), pool, pmtpCurrentRunningRate) + swapResult, _, _, swappedPool, err := FEATURE_TOGGLE_MARGIN_CLI_ALPHA_SwapOne(ctx, k, *msg.ExternalAsset, swapAmount, types.GetSettlementAsset(), pool, pmtpCurrentRunningRate, swapFeeRate) if err != nil { return nil, sdkerrors.Wrap(types.ErrUnableToSwap, err.Error()) } @@ -998,3 +1001,30 @@ func (k msgServer) ModifyLiquidityProtectionRates(goCtx context.Context, msg *ty ctx.EventManager().EmitEvents(events) return response, nil } + +func (k msgServer) UpdateSwapFeeRate(goCtx context.Context, msg *types.MsgUpdateSwapFeeRateRequest) (*types.MsgUpdateSwapFeeRateResponse, error) { + response := &types.MsgUpdateSwapFeeRateResponse{} + + // defensive programming + if msg == nil { + return response, errors.Errorf("msg was nil") + } + + if err := msg.ValidateBasic(); err != nil { + return response, err + } + + ctx := sdk.UnwrapSDKContext(goCtx) + signer, err := sdk.AccAddressFromBech32(msg.Signer) + if err != nil { + return response, err + } + + if !k.adminKeeper.IsAdminAccount(ctx, admintypes.AdminType_PMTPREWARDS, signer) { + return response, errors.Wrap(types.ErrNotEnoughPermissions, fmt.Sprintf("Sending Account : %s", msg.Signer)) + } + + k.SetSwapFeeRate(ctx, &types.SwapFeeRate{SwapFeeRate: msg.SwapFeeRate}) + + return response, nil +} diff --git a/x/clp/keeper/msg_server_FEATURE_TOGGLE_MARGIN_CLI_ALPHA.go b/x/clp/keeper/msg_server_FEATURE_TOGGLE_MARGIN_CLI_ALPHA.go index dd638bc619..1c186c1e21 100644 --- a/x/clp/keeper/msg_server_FEATURE_TOGGLE_MARGIN_CLI_ALPHA.go +++ b/x/clp/keeper/msg_server_FEATURE_TOGGLE_MARGIN_CLI_ALPHA.go @@ -23,7 +23,7 @@ func FEATURE_TOGGLE_MARGIN_CLI_ALPHA_ProcessRemovelQueue(ctx sdk.Context, k msgS } } -// ensure requested removal amount is less than available - what is already on the queue +// ensure requested removal amount is less than available - what is already on the queue func FEATURE_TOGGLE_MARGIN_CLI_ALPHA_VerifyEnoughWithdrawUnitsAvailableForLP(ctx sdk.Context, k msgServer, msg *types.MsgRemoveLiquidityUnits, lp types.LiquidityProvider) error { lpQueuedUnits := k.GetRemovalQueueUnitsForLP(ctx, lp) if msg.WithdrawUnits.GT(lp.LiquidityProviderUnits.Sub(lpQueuedUnits)) { @@ -32,7 +32,7 @@ func FEATURE_TOGGLE_MARGIN_CLI_ALPHA_VerifyEnoughWithdrawUnitsAvailableForLP(ctx return nil } -// ensure requested removal amount is less than available - what is already on the queue +// ensure requested removal amount is less than available - what is already on the queue func FEATURE_TOGGLE_MARGIN_CLI_ALPHA_VerifyEnoughWBasisPointsAvailableForLP(ctx sdk.Context, k msgServer, msg *types.MsgRemoveLiquidity, lp types.LiquidityProvider) error { lpQueuedUnits := k.GetRemovalQueueUnitsForLP(ctx, lp) msgUnits := ConvWBasisPointsToUnits(lp.LiquidityProviderUnits, msg.WBasisPoints) @@ -42,14 +42,14 @@ func FEATURE_TOGGLE_MARGIN_CLI_ALPHA_VerifyEnoughWBasisPointsAvailableForLP(ctx return nil } -func FEATURE_TOGGLE_MARGIN_CLI_ALPHA_QueueRemovalWithWithdrawUnits(ctx sdk.Context, k msgServer, msg *types.MsgRemoveLiquidityUnits, lp types.LiquidityProvider, pool types.Pool, withdrawNativeAssetAmount, withdrawExternalAssetAmount sdk.Uint, eAsset *tokenregistrytypes.RegistryEntry, pmtpCurrentRunningRate sdk.Dec) error { +func FEATURE_TOGGLE_MARGIN_CLI_ALPHA_QueueRemovalWithWithdrawUnits(ctx sdk.Context, k msgServer, msg *types.MsgRemoveLiquidityUnits, lp types.LiquidityProvider, pool types.Pool, withdrawNativeAssetAmount, withdrawExternalAssetAmount sdk.Uint, eAsset *tokenregistrytypes.RegistryEntry, pmtpCurrentRunningRate, swapFeeRate sdk.Dec) error { // Skip pools that are not margin enabled, to avoid health being zero and queueing being triggered. if !k.GetMarginKeeper().IsPoolEnabled(ctx, eAsset.Denom) { return nil } marginEnabled := k.getMarginKeeper().IsPoolEnabled(ctx, pool.String()) - extRowanValue := CalculateWithdrawalRowanValue(withdrawExternalAssetAmount, types.GetSettlementAsset(), pool, pmtpCurrentRunningRate, marginEnabled) + extRowanValue := CalculateWithdrawalRowanValue(withdrawExternalAssetAmount, types.GetSettlementAsset(), pool, pmtpCurrentRunningRate, swapFeeRate, marginEnabled) futurePool := pool futurePool.NativeAssetBalance = futurePool.NativeAssetBalance.Sub(withdrawNativeAssetAmount) @@ -70,14 +70,14 @@ func FEATURE_TOGGLE_MARGIN_CLI_ALPHA_QueueRemovalWithWithdrawUnits(ctx sdk.Conte return nil } -func FEATURE_TOGGLE_MARGIN_CLI_ALPHA_QueueRemovalWithWBasisPoints(ctx sdk.Context, k msgServer, msg *types.MsgRemoveLiquidity, lp types.LiquidityProvider, pool types.Pool, withdrawNativeAssetAmount, withdrawExternalAssetAmount sdk.Uint, eAsset *tokenregistrytypes.RegistryEntry, pmtpCurrentRunningRate sdk.Dec) error { +func FEATURE_TOGGLE_MARGIN_CLI_ALPHA_QueueRemovalWithWBasisPoints(ctx sdk.Context, k msgServer, msg *types.MsgRemoveLiquidity, lp types.LiquidityProvider, pool types.Pool, withdrawNativeAssetAmount, withdrawExternalAssetAmount sdk.Uint, eAsset *tokenregistrytypes.RegistryEntry, pmtpCurrentRunningRate, swapFeeRate sdk.Dec) error { // Skip pools that are not margin enabled, to avoid health being zero and queueing being triggered. if !k.GetMarginKeeper().IsPoolEnabled(ctx, eAsset.Denom) { return nil } marginEnabled := k.getMarginKeeper().IsPoolEnabled(ctx, pool.String()) - extRowanValue := CalculateWithdrawalRowanValue(withdrawExternalAssetAmount, types.GetSettlementAsset(), pool, pmtpCurrentRunningRate, marginEnabled) + extRowanValue := CalculateWithdrawalRowanValue(withdrawExternalAssetAmount, types.GetSettlementAsset(), pool, pmtpCurrentRunningRate, swapFeeRate, marginEnabled) futurePool := pool futurePool.NativeAssetBalance = futurePool.NativeAssetBalance.Sub(withdrawNativeAssetAmount) @@ -100,9 +100,9 @@ func FEATURE_TOGGLE_MARGIN_CLI_ALPHA_SwapOne(ctx sdk.Context, sentAmount sdk.Uint, nativeAsset types.Asset, inPool types.Pool, - pmtpCurrentRunningRate sdk.Dec) (sdk.Uint, sdk.Uint, sdk.Uint, types.Pool, error) { + pmtpCurrentRunningRate, swapFeeRate sdk.Dec) (sdk.Uint, sdk.Uint, sdk.Uint, types.Pool, error) { marginEnabled := k.getMarginKeeper().IsPoolEnabled(ctx, inPool.String()) - return SwapOne(sentAsset, sentAmount, nativeAsset, inPool, pmtpCurrentRunningRate, marginEnabled) + return SwapOne(sentAsset, sentAmount, nativeAsset, inPool, pmtpCurrentRunningRate, swapFeeRate, marginEnabled) } func FEATURE_TOGGLE_MARGIN_CLI_ALPHA_GetSwapFee(ctx sdk.Context, @@ -110,7 +110,7 @@ func FEATURE_TOGGLE_MARGIN_CLI_ALPHA_GetSwapFee(ctx sdk.Context, ReceivedAsset *types.Asset, liquidityFeeNative sdk.Uint, outPool types.Pool, - pmtpCurrentRunningRate sdk.Dec) sdk.Uint { + pmtpCurrentRunningRate, swapFeeRate sdk.Dec) sdk.Uint { marginEnabled := k.getMarginKeeper().IsPoolEnabled(ctx, outPool.String()) - return GetSwapFee(liquidityFeeNative, *ReceivedAsset, outPool, pmtpCurrentRunningRate, marginEnabled) + return GetSwapFee(liquidityFeeNative, *ReceivedAsset, outPool, pmtpCurrentRunningRate, swapFeeRate, marginEnabled) } diff --git a/x/clp/keeper/msg_server_NO_FEATURE_TOGGLE_MARGIN_CLI_ALPHA.go b/x/clp/keeper/msg_server_NO_FEATURE_TOGGLE_MARGIN_CLI_ALPHA.go index 4a061ff28c..5ff6a40abc 100644 --- a/x/clp/keeper/msg_server_NO_FEATURE_TOGGLE_MARGIN_CLI_ALPHA.go +++ b/x/clp/keeper/msg_server_NO_FEATURE_TOGGLE_MARGIN_CLI_ALPHA.go @@ -16,7 +16,7 @@ import ( func FEATURE_TOGGLE_MARGIN_CLI_ALPHA_ProcessRemovelQueue(ctx sdk.Context, k msgServer, msg *types.MsgAddLiquidity, newPoolUnits sdk.Uint) { } -// ensure requested removal amount is less than available - what is already on the queue +// ensure requested removal amount is less than available - what is already on the queue func FEATURE_TOGGLE_MARGIN_CLI_ALPHA_VerifyEnoughWithdrawUnitsAvailableForLP(ctx sdk.Context, k msgServer, msg *types.MsgRemoveLiquidityUnits, lp types.LiquidityProvider) error { if msg.WithdrawUnits.GT(lp.LiquidityProviderUnits) { return sdkerrors.Wrap(types.ErrUnableToRemoveLiquidity, fmt.Sprintf("WithdrawUnits %s greater than total LP units %s", msg.WithdrawUnits, lp.LiquidityProviderUnits)) @@ -24,16 +24,16 @@ func FEATURE_TOGGLE_MARGIN_CLI_ALPHA_VerifyEnoughWithdrawUnitsAvailableForLP(ctx return nil } -// ensure requested removal amount is less than available - what is already on the queue +// ensure requested removal amount is less than available - what is already on the queue func FEATURE_TOGGLE_MARGIN_CLI_ALPHA_VerifyEnoughWBasisPointsAvailableForLP(ctx sdk.Context, k msgServer, msg *types.MsgRemoveLiquidity, lp types.LiquidityProvider) error { return nil } -func FEATURE_TOGGLE_MARGIN_CLI_ALPHA_QueueRemovalWithWithdrawUnits(ctx sdk.Context, k msgServer, msg *types.MsgRemoveLiquidityUnits, lp types.LiquidityProvider, pool types.Pool, withdrawNativeAssetAmount, withdrawExternalAssetAmount sdk.Uint, eAsset *tokenregistrytypes.RegistryEntry, pmtpCurrentRunningRate sdk.Dec) error { +func FEATURE_TOGGLE_MARGIN_CLI_ALPHA_QueueRemovalWithWithdrawUnits(ctx sdk.Context, k msgServer, msg *types.MsgRemoveLiquidityUnits, lp types.LiquidityProvider, pool types.Pool, withdrawNativeAssetAmount, withdrawExternalAssetAmount sdk.Uint, eAsset *tokenregistrytypes.RegistryEntry, pmtpCurrentRunningRate, swapFeeRate sdk.Dec) error { return nil } -func FEATURE_TOGGLE_MARGIN_CLI_ALPHA_QueueRemovalWithWBasisPoints(ctx sdk.Context, k msgServer, msg *types.MsgRemoveLiquidity, lp types.LiquidityProvider, pool types.Pool, withdrawNativeAssetAmount, withdrawExternalAssetAmount sdk.Uint, eAsset *tokenregistrytypes.RegistryEntry, pmtpCurrentRunningRate sdk.Dec) error { +func FEATURE_TOGGLE_MARGIN_CLI_ALPHA_QueueRemovalWithWBasisPoints(ctx sdk.Context, k msgServer, msg *types.MsgRemoveLiquidity, lp types.LiquidityProvider, pool types.Pool, withdrawNativeAssetAmount, withdrawExternalAssetAmount sdk.Uint, eAsset *tokenregistrytypes.RegistryEntry, pmtpCurrentRunningRate, swapFeeRate sdk.Dec) error { return nil } @@ -43,8 +43,8 @@ func FEATURE_TOGGLE_MARGIN_CLI_ALPHA_SwapOne(ctx sdk.Context, sentAmount sdk.Uint, nativeAsset types.Asset, inPool types.Pool, - pmtpCurrentRunningRate sdk.Dec) (sdk.Uint, sdk.Uint, sdk.Uint, types.Pool, error) { - return SwapOne(sentAsset, sentAmount, nativeAsset, inPool, pmtpCurrentRunningRate) + pmtpCurrentRunningRate, swapFeeRate sdk.Dec) (sdk.Uint, sdk.Uint, sdk.Uint, types.Pool, error) { + return SwapOne(sentAsset, sentAmount, nativeAsset, inPool, pmtpCurrentRunningRate, swapFeeRate) } func FEATURE_TOGGLE_MARGIN_CLI_ALPHA_GetSwapFee(ctx sdk.Context, @@ -52,6 +52,6 @@ func FEATURE_TOGGLE_MARGIN_CLI_ALPHA_GetSwapFee(ctx sdk.Context, ReceivedAsset *types.Asset, liquidityFeeNative sdk.Uint, outPool types.Pool, - pmtpCurrentRunningRate sdk.Dec) sdk.Uint { - return GetSwapFee(liquidityFeeNative, *ReceivedAsset, outPool, pmtpCurrentRunningRate) + pmtpCurrentRunningRate, swapFeeRate sdk.Dec) sdk.Uint { + return GetSwapFee(liquidityFeeNative, *ReceivedAsset, outPool, pmtpCurrentRunningRate, swapFeeRate) } diff --git a/x/clp/keeper/msg_server_test.go b/x/clp/keeper/msg_server_test.go index 77e030badf..138a82277f 100644 --- a/x/clp/keeper/msg_server_test.go +++ b/x/clp/keeper/msg_server_test.go @@ -2,7 +2,6 @@ package keeper_test import ( "errors" - "fmt" "testing" sifapp "github.com/Sifchain/sifnode/app" @@ -357,12 +356,12 @@ func TestMsgServer_Swap(t *testing.T) { nativeAssetAmount: sdk.NewUint(1000), externalAssetAmount: sdk.NewUint(1000), poolUnits: sdk.NewUint(1000), - nativeBalanceEnd: sdk.NewInt(10082), + nativeBalanceEnd: sdk.NewInt(10090), externalBalanceEnd: sdk.NewInt(9900), poolAssetPermissions: []tokenregistrytypes.Permission{tokenregistrytypes.Permission_CLP}, nativeAssetPermissions: []tokenregistrytypes.Permission{tokenregistrytypes.Permission_CLP}, currentRowanLiquidityThreshold: sdk.NewUint(1000), - expectedRunningThresholdEnd: sdk.NewUint(1082), + expectedRunningThresholdEnd: sdk.NewUint(1090), maxRowanLiquidityThresholdAsset: "rowan", maxRowanLiquidityThreshold: sdk.NewUint(2000), msg: &types.MsgSwap{ @@ -1548,9 +1547,6 @@ func TestMsgServer_AddLiquidity(t *testing.T) { pool, _ := app.ClpKeeper.GetPool(ctx, tc.poolAsset) require.Equal(t, tc.expectedPoolUnits.String(), pool.PoolUnits.String()) // compare strings so that the expected amounts can be read from the failure message - - fmt.Printf("LP units: %s\n", lp.LiquidityProviderUnits.String()) - fmt.Printf("Expected pool units: %s\n", tc.expectedPoolUnits.String()) require.Equal(t, tc.expectedLPUnits.String(), lp.LiquidityProviderUnits.String()) }) } diff --git a/x/clp/keeper/pmtp.go b/x/clp/keeper/pmtp.go index 6879e2e292..6d907086d7 100644 --- a/x/clp/keeper/pmtp.go +++ b/x/clp/keeper/pmtp.go @@ -54,11 +54,12 @@ func (k Keeper) PolicyCalculations(ctx sdk.Context) sdk.Dec { return pmtpCurrentRunningRate } +// NOTE: the code in this method must not panic otherwise the chain will halt +// see: https://bytemeta.vip/repo/osmosis-labs/osmosis/issues/1305 func (k Keeper) PolicyRun(ctx sdk.Context, pmtpCurrentRunningRate sdk.Dec) error { pools := k.GetPools(ctx) - // NOTE: the code in this loop must not panic otherwise the remaining pools will not be updated - // similarly if an error occurs we must continue to update the remaining pools + // NOTE: if an error occurs in this loop we must continue to update the remaining pools for _, pool := range pools { decimalsExternal, err := k.GetAssetDecimals(ctx, *pool.ExternalAsset) if err != nil { @@ -72,12 +73,12 @@ func (k Keeper) PolicyRun(ctx sdk.Context, pmtpCurrentRunningRate sdk.Dec) error spotPriceNative, err := CalcSpotPriceNative(pool, decimalsExternal, pmtpCurrentRunningRate) if err != nil { - // Error occurs if native asset pool depth is zero + // Error occurs if native asset pool depth is zero or result overflows spotPriceNative = sdk.ZeroDec() } spotPriceExternal, err := CalcSpotPriceExternal(pool, decimalsExternal, pmtpCurrentRunningRate) if err != nil { - // Error occurs if external asset pool depth is zero + // Error occurs if external asset pool depth is zero or result overflows spotPriceExternal = sdk.ZeroDec() } diff --git a/x/clp/keeper/pureCalculation.go b/x/clp/keeper/pureCalculation.go index d1f704d05c..919fc03f01 100644 --- a/x/clp/keeper/pureCalculation.go +++ b/x/clp/keeper/pureCalculation.go @@ -1,6 +1,7 @@ package keeper import ( + "fmt" "math" "math/big" @@ -8,6 +9,10 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) +const ( + maxDecBitLen = 315 // sdk.Dec doesn't export this value but see here: https://github.com/cosmos/cosmos-sdk/blob/main/types/decimal.go#L34 +) + func DecToRat(d *sdk.Dec) big.Rat { var rat big.Rat @@ -19,8 +24,7 @@ func DecToRat(d *sdk.Dec) big.Rat { return rat } -// The sdk.Dec returned by this method can exceed the sdk.Decimal maxDecBitLen -func RatToDec(r *big.Rat) sdk.Dec { +func RatToDec(r *big.Rat) (sdk.Dec, error) { num := r.Num() denom := r.Denom() // big.Rat guarantees that denom is always > 0 @@ -30,7 +34,13 @@ func RatToDec(r *big.Rat) sdk.Dec { d.Mul(num, multiplier) d.Quo(&d, denom) - return sdk.NewDecFromBigIntWithPrec(&d, sdk.Precision) + // There's a bug in the SDK which allows sdk.NewDecFromBigIntWithPrec to create an sdk.Dec with > maxDecBitLen bits + // This leads to an error when attempting to unmarshal such sdk.Decs + if d.BitLen() > maxDecBitLen { + return sdk.ZeroDec(), fmt.Errorf("decimal out of range; bitLen: got %d, max %d", d.BitLen(), maxDecBitLen) + } + + return sdk.NewDecFromBigIntWithPrec(&d, sdk.Precision), nil } func RatIntQuo(r *big.Rat) *big.Int { diff --git a/x/clp/keeper/pureCalculation_test.go b/x/clp/keeper/pureCalculation_test.go index a0a918139f..50b5f283a6 100644 --- a/x/clp/keeper/pureCalculation_test.go +++ b/x/clp/keeper/pureCalculation_test.go @@ -21,7 +21,7 @@ func TestKeeper_DecRatIdentity(t *testing.T) { expected := genDec(t) rat := clpkeeper.DecToRat(&expected) - actual := clpkeeper.RatToDec(&rat) + actual, _ := clpkeeper.RatToDec(&rat) if !expected.Equal(actual) { t.Fatalf("\nexpected %s\nactual %s", expected.String(), actual.String()) @@ -64,6 +64,7 @@ func TestKeeper_RatToDec(t *testing.T) { num *big.Int denom *big.Int expected sdk.Dec + err error }{ { name: "small values", @@ -84,10 +85,10 @@ func TestKeeper_RatToDec(t *testing.T) { expected: sdk.MustNewDecFromStr("-2.333333333333333333"), }, { - name: "big numbers", - num: big.NewInt(1).Exp(big.NewInt(2), big.NewInt(400), nil), // 2**400 - denom: big.NewInt(3), - expected: sdk.NewDecFromBigIntWithPrec(getFirstArg(big.NewInt(1).SetString("860749959362302863218639724001003958109901930943074504276886452180215874005613731543215117760045943811967723990915831125333333333333333333", 10)), 18), + name: "big numbers", + num: big.NewInt(1).Exp(big.NewInt(2), big.NewInt(400), nil), // 2**400 + denom: big.NewInt(3), + err: errors.New("decimal out of range; bitLen: got 459, max 315"), }, } @@ -97,13 +98,42 @@ func TestKeeper_RatToDec(t *testing.T) { var rat big.Rat rat.SetFrac(tc.num, tc.denom) - y := clpkeeper.RatToDec(&rat) + y, err := clpkeeper.RatToDec(&rat) + + if tc.err != nil { + require.EqualError(t, err, tc.err.Error()) + return + } + require.NoError(t, err) require.Equal(t, tc.expected, y) }) } } +// If the cosmos SDK reduces the value of maxDecBitLen below 315 then (without +// further changes) RatToDec will be able to return an sdk.Dec with 316 bits. +// Such sdk.Decs would cause panics and errors when unmarshaling. This test +// will fail if the cosmos SDK reduces the value of maxDecBitLen < 315. +func TestKeeper_RatToDec_Overflow(t *testing.T) { + numerator, _ := big.NewInt(1).SetString("66749594872528440074844428317798503581334516323645399060845050244444366430645", 10) // (2**315 - 1) / 10**18 + denominator := big.NewInt(1) + + var rat big.Rat + rat.SetFrac(numerator, denominator) + + // The rat passed here uses 315 bits when represented as an sdk.Dec. Even if the SDK + // reduces the maxDecBitLen < 315 (without fixing sdk.NewDecFromBigIntWithPrec) the RatToDec + // will still succeed - returning an sdk.Dec which cannot be unmarshaled or that will cause a panic + // even when adding zero. + dec, err := clpkeeper.RatToDec(&rat) + + require.NoError(t, err) + + // If the SDK ever reduces the value of maxDecBitLen < 315 then this will panic + dec.Add(sdk.NewDec(0)) +} + func TestKeeper_Int64ToUint8Safe(t *testing.T) { testcases := []struct { diff --git a/x/clp/keeper/swap_FEATURE_TOGGLE_MARGIN_CLI_ALPHA.go b/x/clp/keeper/swap_FEATURE_TOGGLE_MARGIN_CLI_ALPHA.go index 9788ec6ee7..803c35993b 100644 --- a/x/clp/keeper/swap_FEATURE_TOGGLE_MARGIN_CLI_ALPHA.go +++ b/x/clp/keeper/swap_FEATURE_TOGGLE_MARGIN_CLI_ALPHA.go @@ -17,8 +17,9 @@ func (k Keeper) CLPCalcSwap(ctx sdk.Context, sentAmount sdk.Uint, to types.Asset } pmtpCurrentRunningRate := k.GetPmtpRateParams(ctx).PmtpCurrentRunningRate + swapFeeRate := k.GetSwapFeeRate(ctx).SwapFeeRate - swapResult := CalcSwapResult(toRowan, X, sentAmount, Y, pmtpCurrentRunningRate) + swapResult := CalcSwapResult(toRowan, X, sentAmount, Y, pmtpCurrentRunningRate, swapFeeRate) if swapResult.GTE(Y) { return sdk.ZeroUint(), types.ErrNotEnoughAssetTokens diff --git a/x/clp/keeper/swap_NO_FEATURE_TOGGLE_MARGIN_CLI_ALPHA.go b/x/clp/keeper/swap_NO_FEATURE_TOGGLE_MARGIN_CLI_ALPHA.go index 998f57ca5e..c5eb4400a0 100644 --- a/x/clp/keeper/swap_NO_FEATURE_TOGGLE_MARGIN_CLI_ALPHA.go +++ b/x/clp/keeper/swap_NO_FEATURE_TOGGLE_MARGIN_CLI_ALPHA.go @@ -13,8 +13,9 @@ func (k Keeper) CLPCalcSwap(ctx sdk.Context, sentAmount sdk.Uint, to types.Asset X, Y, toRowan := pool.ExtractValues(to) pmtpCurrentRunningRate := k.GetPmtpRateParams(ctx).PmtpCurrentRunningRate + swapFeeRate := k.GetSwapFeeRate(ctx).SwapFeeRate - swapResult := CalcSwapResult(toRowan, X, sentAmount, Y, pmtpCurrentRunningRate) + swapResult := CalcSwapResult(toRowan, X, sentAmount, Y, pmtpCurrentRunningRate, swapFeeRate) if swapResult.GTE(Y) { return sdk.ZeroUint(), types.ErrNotEnoughAssetTokens diff --git a/x/clp/keeper/swapfeerate_params.go b/x/clp/keeper/swapfeerate_params.go new file mode 100644 index 0000000000..5d86da4fd4 --- /dev/null +++ b/x/clp/keeper/swapfeerate_params.go @@ -0,0 +1,22 @@ +package keeper + +import ( + "github.com/Sifchain/sifnode/x/clp/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func (k Keeper) SetSwapFeeRate(ctx sdk.Context, params *types.SwapFeeRate) { + store := ctx.KVStore(k.storeKey) + store.Set(types.SwapFeeRatePrefix, k.cdc.MustMarshal(params)) +} + +func (k Keeper) GetSwapFeeRate(ctx sdk.Context) *types.SwapFeeRate { + params := types.SwapFeeRate{} + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.SwapFeeRatePrefix) + if bz == nil { + return &types.SwapFeeRate{SwapFeeRate: sdk.NewDecWithPrec(3, 3)} //0.003 + } + k.cdc.MustUnmarshal(bz, ¶ms) + return ¶ms +} diff --git a/x/clp/types/keys.go b/x/clp/types/keys.go index 3e78006f88..cb97395338 100644 --- a/x/clp/types/keys.go +++ b/x/clp/types/keys.go @@ -40,6 +40,7 @@ var ( LiquidityProtectionRateParamsPrefix = []byte{0x09} // Key to store the Liquidity Protection rate params ProviderDistributionParamsPrefix = []byte{0x0a} RewardsBlockDistributionPrefix = []byte{0x0b} + SwapFeeRatePrefix = []byte{0x0c} ) // Generates a key for storing a specific pool diff --git a/x/clp/types/msgs.go b/x/clp/types/msgs.go index 7e70dece75..a595fc0a97 100644 --- a/x/clp/types/msgs.go +++ b/x/clp/types/msgs.go @@ -27,6 +27,7 @@ var ( _ sdk.Msg = &MsgUpdateLiquidityProtectionParams{} _ sdk.Msg = &MsgModifyLiquidityProtectionRates{} _ sdk.Msg = &MsgAddProviderDistributionPeriodRequest{} + _ sdk.Msg = &MsgUpdateSwapFeeRateRequest{} _ legacytx.LegacyMsg = &MsgRemoveLiquidity{} _ legacytx.LegacyMsg = &MsgRemoveLiquidityUnits{} @@ -43,6 +44,7 @@ var ( _ legacytx.LegacyMsg = &MsgSetSymmetryThreshold{} _ legacytx.LegacyMsg = &MsgCancelUnlock{} _ legacytx.LegacyMsg = &MsgAddProviderDistributionPeriodRequest{} + _ legacytx.LegacyMsg = &MsgUpdateSwapFeeRateRequest{} ) func (m MsgCancelUnlock) Route() string { @@ -643,3 +645,39 @@ func (m MsgAddProviderDistributionPeriodRequest) GetSigners() []sdk.AccAddress { } return []sdk.AccAddress{addr} } + +func (m MsgUpdateSwapFeeRateRequest) Route() string { + return RouterKey +} + +func (m MsgUpdateSwapFeeRateRequest) Type() string { + return "update_swap_fee_rate" +} + +func (m MsgUpdateSwapFeeRateRequest) ValidateBasic() error { + if m.Signer == "" { + return sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, m.Signer) + } + + if m.SwapFeeRate.LT(sdk.ZeroDec()) { + return fmt.Errorf("swap rate fee must be greater than or equal to zero") + } + + if m.SwapFeeRate.GT(sdk.OneDec()) { + return fmt.Errorf("swap rate fee must be less than or equal to one") + } + + return nil +} + +func (m MsgUpdateSwapFeeRateRequest) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) +} + +func (m MsgUpdateSwapFeeRateRequest) GetSigners() []sdk.AccAddress { + addr, err := sdk.AccAddressFromBech32(m.Signer) + if err != nil { + panic(err) + } + return []sdk.AccAddress{addr} +} diff --git a/x/clp/types/params.pb.go b/x/clp/types/params.pb.go index 8ef34e1436..a97113fa0a 100644 --- a/x/clp/types/params.pb.go +++ b/x/clp/types/params.pb.go @@ -580,6 +580,43 @@ func (m *ProviderDistributionParams) GetDistributionPeriods() []*ProviderDistrib return nil } +type SwapFeeRate struct { + SwapFeeRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,1,opt,name=swap_fee_rate,json=swapFeeRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"swap_fee_rate"` +} + +func (m *SwapFeeRate) Reset() { *m = SwapFeeRate{} } +func (m *SwapFeeRate) String() string { return proto.CompactTextString(m) } +func (*SwapFeeRate) ProtoMessage() {} +func (*SwapFeeRate) Descriptor() ([]byte, []int) { + return fileDescriptor_61de66e331088d04, []int{10} +} +func (m *SwapFeeRate) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *SwapFeeRate) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_SwapFeeRate.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *SwapFeeRate) XXX_Merge(src proto.Message) { + xxx_messageInfo_SwapFeeRate.Merge(m, src) +} +func (m *SwapFeeRate) XXX_Size() int { + return m.Size() +} +func (m *SwapFeeRate) XXX_DiscardUnknown() { + xxx_messageInfo_SwapFeeRate.DiscardUnknown(m) +} + +var xxx_messageInfo_SwapFeeRate proto.InternalMessageInfo + func init() { proto.RegisterType((*Params)(nil), "sifnode.clp.v1.Params") proto.RegisterType((*RewardParams)(nil), "sifnode.clp.v1.RewardParams") @@ -591,77 +628,80 @@ func init() { proto.RegisterType((*LiquidityProtectionRateParams)(nil), "sifnode.clp.v1.LiquidityProtectionRateParams") proto.RegisterType((*ProviderDistributionPeriod)(nil), "sifnode.clp.v1.ProviderDistributionPeriod") proto.RegisterType((*ProviderDistributionParams)(nil), "sifnode.clp.v1.ProviderDistributionParams") + proto.RegisterType((*SwapFeeRate)(nil), "sifnode.clp.v1.SwapFeeRate") } func init() { proto.RegisterFile("sifnode/clp/v1/params.proto", fileDescriptor_61de66e331088d04) } var fileDescriptor_61de66e331088d04 = []byte{ - // 1036 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0x5f, 0x6f, 0x1b, 0xc5, - 0x17, 0xcd, 0xda, 0x6e, 0x7e, 0xf1, 0x6d, 0x7f, 0x06, 0x36, 0x76, 0xb2, 0xb1, 0xe3, 0xb5, 0x6b, - 0x24, 0xb0, 0x82, 0xb0, 0x49, 0x51, 0x29, 0x3c, 0x3a, 0x7f, 0x84, 0x8a, 0x52, 0xc9, 0x6c, 0xcb, - 0x0b, 0x12, 0x5a, 0xad, 0x77, 0x27, 0xf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xdd, 0xd8, 0x1e, 0x6b, 0x73, 0x99, 0x9e, 0x1d, 0x0c, 0x5e, 0x5d, - 0x99, 0xda, 0xeb, 0x2b, 0x53, 0xfb, 0xfb, 0xca, 0xd4, 0x5e, 0x5e, 0x9b, 0x6b, 0xaf, 0xaf, 0xcd, - 0xb5, 0xbf, 0xae, 0xcd, 0xb5, 0xef, 0xb3, 0x53, 0xf3, 0x14, 0x9f, 0xba, 0x13, 0x07, 0x87, 0xfd, - 0xd9, 0x0b, 0xf7, 0x5c, 0xbe, 0x71, 0x65, 0x8b, 0x46, 0xeb, 0xf2, 0xe9, 0xfa, 0xf9, 0x3f, 0x01, - 0x00, 0x00, 0xff, 0xff, 0x84, 0x7c, 0x96, 0xe4, 0xff, 0x0a, 0x00, 0x00, + // 1059 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0x5d, 0x6f, 0x1b, 0x45, + 0x14, 0xcd, 0xda, 0x69, 0x49, 0x6e, 0xda, 0x00, 0x9b, 0xaf, 0xcd, 0xd7, 0xda, 0x5d, 0x24, 0xb0, + 0x82, 0xb0, 0x49, 0x51, 0x29, 0x3c, 0x3a, 0x1f, 0xa0, 0xa2, 0x54, 0x32, 0x9b, 0xf2, 0x82, 0x84, + 0x56, 0xe3, 0xdd, 0x89, 0x3d, 0xca, 0xee, 0xce, 0x76, 0x66, 0xd6, 0x49, 0xe0, 0x4f, 0xf4, 0x89, + 0x17, 0x04, 0xff, 0x06, 0xa9, 0x8f, 0x45, 0xbc, 0xa0, 0x3e, 0x44, 0x28, 0xf9, 0x23, 0x68, 0x66, + 0xd6, 0xeb, 0x5d, 0xdb, 0x41, 0x6d, 0xe0, 0xa9, 0x75, 0xee, 0xdc, 0x73, 0xee, 0x9c, 0x7b, 0xe7, + 0xdc, 0x85, 0x4d, 0x4e, 0x4e, 0x62, 0x1a, 0xe0, 0x96, 0x1f, 0x26, 0xad,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0xbe, 0x2f, 0x0e, 0xe6, + 0x31, 0x39, 0xf1, 0xfb, 0x88, 0xc4, 0xad, 0xe1, 0x47, 0xf4, 0xb9, 0xfa, 0x8c, 0x56, 0x98, 0xdd, + 0xbb, 0xea, 0xeb, 0xf8, 0xb3, 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, 0x61, 0x17, 0x52, 0x26, 0x62, + 0x0b, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -1165,6 +1205,39 @@ func (m *ProviderDistributionParams) MarshalToSizedBuffer(dAtA []byte) (int, err return len(dAtA) - i, nil } +func (m *SwapFeeRate) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *SwapFeeRate) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *SwapFeeRate) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.SwapFeeRate.Size() + i -= size + if _, err := m.SwapFeeRate.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + func encodeVarintParams(dAtA []byte, offset int, v uint64) int { offset -= sovParams(v) base := offset @@ -1374,6 +1447,17 @@ func (m *ProviderDistributionParams) Size() (n int) { return n } +func (m *SwapFeeRate) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.SwapFeeRate.Size() + n += 1 + l + sovParams(uint64(l)) + return n +} + func sovParams(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -2763,6 +2847,90 @@ func (m *ProviderDistributionParams) Unmarshal(dAtA []byte) error { } return nil } +func (m *SwapFeeRate) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: SwapFeeRate: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SwapFeeRate: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SwapFeeRate", 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.SwapFeeRate.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipParams(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthParams + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipParams(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/clp/types/querier.pb.go b/x/clp/types/querier.pb.go index c027420277..6e27c4cbd0 100644 --- a/x/clp/types/querier.pb.go +++ b/x/clp/types/querier.pb.go @@ -1181,6 +1181,79 @@ func (m *ProviderDistributionParamsRes) GetParams() *ProviderDistributionParams return nil } +type SwapFeeRateReq struct { +} + +func (m *SwapFeeRateReq) Reset() { *m = SwapFeeRateReq{} } +func (m *SwapFeeRateReq) String() string { return proto.CompactTextString(m) } +func (*SwapFeeRateReq) ProtoMessage() {} +func (*SwapFeeRateReq) Descriptor() ([]byte, []int) { + return fileDescriptor_5f4edede314ca3fd, []int{24} +} +func (m *SwapFeeRateReq) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *SwapFeeRateReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_SwapFeeRateReq.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *SwapFeeRateReq) XXX_Merge(src proto.Message) { + xxx_messageInfo_SwapFeeRateReq.Merge(m, src) +} +func (m *SwapFeeRateReq) XXX_Size() int { + return m.Size() +} +func (m *SwapFeeRateReq) XXX_DiscardUnknown() { + xxx_messageInfo_SwapFeeRateReq.DiscardUnknown(m) +} + +var xxx_messageInfo_SwapFeeRateReq proto.InternalMessageInfo + +type SwapFeeRateRes struct { + SwapFeeRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,1,opt,name=swap_fee_rate,json=swapFeeRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"swap_fee_rate"` +} + +func (m *SwapFeeRateRes) Reset() { *m = SwapFeeRateRes{} } +func (m *SwapFeeRateRes) String() string { return proto.CompactTextString(m) } +func (*SwapFeeRateRes) ProtoMessage() {} +func (*SwapFeeRateRes) Descriptor() ([]byte, []int) { + return fileDescriptor_5f4edede314ca3fd, []int{25} +} +func (m *SwapFeeRateRes) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *SwapFeeRateRes) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_SwapFeeRateRes.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *SwapFeeRateRes) XXX_Merge(src proto.Message) { + xxx_messageInfo_SwapFeeRateRes.Merge(m, src) +} +func (m *SwapFeeRateRes) XXX_Size() int { + return m.Size() +} +func (m *SwapFeeRateRes) XXX_DiscardUnknown() { + xxx_messageInfo_SwapFeeRateRes.DiscardUnknown(m) +} + +var xxx_messageInfo_SwapFeeRateRes proto.InternalMessageInfo + func init() { proto.RegisterType((*PoolReq)(nil), "sifnode.clp.v1.PoolReq") proto.RegisterType((*PoolRes)(nil), "sifnode.clp.v1.PoolRes") @@ -1206,97 +1279,102 @@ func init() { proto.RegisterType((*LiquidityProtectionParamsRes)(nil), "sifnode.clp.v1.LiquidityProtectionParamsRes") proto.RegisterType((*ProviderDistributionParamsReq)(nil), "sifnode.clp.v1.ProviderDistributionParamsReq") proto.RegisterType((*ProviderDistributionParamsRes)(nil), "sifnode.clp.v1.ProviderDistributionParamsRes") + proto.RegisterType((*SwapFeeRateReq)(nil), "sifnode.clp.v1.SwapFeeRateReq") + proto.RegisterType((*SwapFeeRateRes)(nil), "sifnode.clp.v1.SwapFeeRateRes") } func init() { proto.RegisterFile("sifnode/clp/v1/querier.proto", fileDescriptor_5f4edede314ca3fd) } var fileDescriptor_5f4edede314ca3fd = []byte{ - // 1349 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x58, 0xcb, 0x6f, 0x1b, 0xd5, - 0x17, 0xce, 0x24, 0x6d, 0xda, 0xdc, 0xbe, 0xcf, 0x2f, 0x49, 0x9d, 0xf9, 0x39, 0x76, 0x18, 0x95, - 0x34, 0x84, 0x64, 0xa6, 0xe9, 0x43, 0x50, 0x10, 0x8b, 0x44, 0xa5, 0x61, 0x51, 0x50, 0x18, 0x90, - 0x90, 0x90, 0x8a, 0x35, 0x1e, 0x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x1a, 0xbb, 0xed, 0xba, 0xe7, - 0x96, 0x94, 0x25, 0x65, 0x65, 0xc6, 0x94, 0x4f, 0xaf, 0x1c, 0xfe, 0xec, 0x5e, 0x75, 0xe2, 0xc9, - 0xbd, 0xea, 0x84, 0xd6, 0x8d, 0xc1, 0x08, 0x2b, 0xe4, 0x00, 0x27, 0x2b, 0xa0, 0x47, 0xce, 0xcf, - 0xea, 0x49, 0x29, 0x74, 0x01, 0x13, 0x08, 0x58, 0x23, 0x60, 0xbb, 0x7e, 0xad, 0xed, 0x35, 0x76, - 0x5d, 0x5a, 0xb3, 0x1a, 0x8d, 0x90, 0x22, 0x96, 0x26, 0x45, 0x8a, 0x93, 0xb6, 0xeb, 0xbf, 0x29, - 0x0c, 0x9b, 0xd1, 0x7b, 0x4e, 0xa2, 0x45, 0x9d, 0x66, 0x8b, 0x95, 0xa6, 0x96, 0x94, 0x95, 0x29, - 0x53, 0x3e, 0x69, 0x26, 0x39, 0xcc, 0x63, 0x22, 0x27, 0x7a, 0x95, 0x90, 0x7e, 0x95, 0x92, 0xc1, - 0xb2, 0x1e, 0x49, 0xa2, 0x73, 0x49, 0x74, 0x21, 0x89, 0x2e, 0x25, 0xd1, 0x77, 0xac, 0x26, 0x35, - 0x69, 0xb0, 0x4b, 0x91, 0x99, 0x03, 0x9e, 0xda, 0x0f, 0x4a, 0x2f, 0x28, 0xc2, 0x2a, 0x39, 0xc8, - 0xe9, 0x62, 0x49, 0x59, 0x9a, 0x2a, 0xac, 0x28, 0x82, 0x3c, 0x9b, 0x92, 0x60, 0x3b, 0x51, 0xc6, - 0x01, 0x51, 0xc6, 0xd9, 0x91, 0x65, 0xa0, 0xef, 0x75, 0x90, 0x26, 0xea, 0x78, 0x8f, 0xcc, 0x5e, - 0x73, 0x82, 0x5d, 0xa7, 0xe1, 0xb0, 0xee, 0x4e, 0xe8, 0xed, 0x39, 0x0d, 0x1a, 0x0e, 0x39, 0x50, - 0x58, 0x24, 0xc4, 0xf5, 0x53, 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xba, 0xf0, 0x77, 0x00, 0x00, 0x00, 0xff, 0xff, 0x2f, 0xc0, 0x01, - 0x15, 0xd0, 0x13, 0x00, 0x00, + // 1407 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x58, 0xcf, 0x6f, 0x1b, 0xc5, + 0x17, 0xcf, 0x26, 0x6d, 0xda, 0x4c, 0xda, 0xb4, 0x7d, 0xdf, 0x24, 0x75, 0xf6, 0xeb, 0xd8, 0x61, + 0x55, 0xd2, 0x10, 0x92, 0x75, 0xd3, 0x1f, 0x82, 0x82, 0x38, 0x24, 0x2a, 0x35, 0x87, 0x82, 0xc2, + 0x16, 0x09, 0x09, 0xa9, 0x58, 0x6b, 0x7b, 0x6a, 0xaf, 0x58, 0x7b, 0x7f, 0xbc, 0x49, 0x5a, 0xab, + 0x54, 0x48, 0xa8, 0x07, 0x24, 0x2e, 0x48, 0xbd, 0x57, 0xbd, 0x70, 0xe0, 0x80, 0xc4, 0x81, 0x7f, + 0x01, 0xa9, 0x48, 0x48, 0x54, 0xe2, 0x02, 0x1c, 0x0a, 0x6a, 0x39, 0xf4, 0xcf, 0x40, 0x33, 0x3b, + 0x6b, 0x7b, 0x7f, 0xc6, 0x89, 0x2a, 0x10, 0x27, 0x7b, 0xe7, 0x7d, 0xe6, 0xbd, 0xcf, 0xfb, 0xcc, + 0xdb, 0x79, 0xcf, 0x26, 0x45, 0xb4, 0x6e, 0x76, 0x9d, 0x26, 0xad, 0x34, 0x6c, 0xb7, 0xb2, 0xbb, + 0x51, 0xf1, 0x76, 0xa8, 0x6f, 0x51, 0x5f, 0x77, 0x7d, 0x87, 0x39, 0x30, 0x23, 0xad, 0x7a, 0xc3, + 0x76, 0xf5, 0xdd, 0x0d, 0x75, 0xb6, 0xe5, 0xb4, 0x1c, 0x61, 0xaa, 0xf0, 0x6f, 0x01, 0x4a, 0x55, + 0x63, 0x3e, 0x58, 0xcf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x89, 0x30, 0x40, 0x58, 0x27, 0x93, 0x22, 0xad, 0xb0, 0x22, 0xe7, 0xe2, 0xba, 0x0a, + 0xb4, 0x21, 0x41, 0x43, 0x89, 0x8d, 0xe7, 0x54, 0xd9, 0xc4, 0xc1, 0xab, 0xec, 0x4b, 0x85, 0x14, + 0x12, 0x47, 0x79, 0xc5, 0x64, 0xe6, 0xbf, 0x22, 0xd7, 0x6f, 0xd9, 0x6c, 0x10, 0x6e, 0x90, 0xd3, + 0xc9, 0xf2, 0xac, 0x35, 0x4d, 0x66, 0x4a, 0x2d, 0x5f, 0xde, 0xb3, 0x46, 0x85, 0xab, 0x39, 0x3b, + 0x6d, 0x39, 0x53, 0xea, 0xab, 0x29, 0x52, 0x1f, 0xe4, 0x5e, 0xba, 0x97, 0x96, 0x5b, 0x58, 0x98, + 0x59, 0x2f, 0xf5, 0x8b, 0x97, 0xf8, 0xe7, 0x6c, 0x1a, 0x08, 0x06, 0xf9, 0x5f, 0x52, 0xe2, 0xb0, + 0x54, 0x47, 0xb8, 0x02, 0x20, 0x21, 0xed, 0x3f, 0x50, 0xc2, 0x16, 0x99, 0x4b, 0x30, 0x49, 0xe9, + 0x28, 0x2f, 0x42, 0xbc, 0x9f, 0x94, 0xf4, 0x58, 0xff, 0x51, 0xe5, 0xa6, 0xc9, 0xd4, 0xb6, 0x18, + 0x40, 0x0c, 0xea, 0x69, 0xf7, 0xc6, 0x07, 0x4f, 0x08, 0x3a, 0x99, 0x0c, 0x66, 0x13, 0x79, 0xff, + 0xcf, 0x27, 0x3a, 0x67, 0x00, 0x95, 0x28, 0xb8, 0x41, 0x00, 0x7b, 0x9d, 0x0e, 0x65, 0x7e, 0xaf, + 0xc6, 0xda, 0x3e, 0xc5, 0xb6, 0x63, 0x37, 0x83, 0x7b, 0x7e, 0x4b, 0x7f, 0xf4, 0xa4, 0x3c, 0xf6, + 0xfb, 0x93, 0xf2, 0x72, 0xcb, 0x62, 0xed, 0x9d, 0xba, 0xde, 0x70, 0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, 0xda, 0x44, 0x44, 0x3d, 0x75, 0x54, 0x24, + 0x6a, 0x6f, 0x09, 0xce, 0xaf, 0xc1, 0xa5, 0x11, 0x38, 0x8b, 0xe9, 0x2c, 0xca, 0xf7, 0x53, 0x72, + 0xac, 0x4a, 0x59, 0x7f, 0x26, 0x86, 0x62, 0xea, 0x00, 0x2c, 0xe7, 0x22, 0x35, 0xcf, 0x8a, 0xda, + 0x39, 0x41, 0x65, 0x15, 0x56, 0x12, 0x54, 0x82, 0x9f, 0x0e, 0xb6, 0x85, 0x2c, 0x1a, 0xfd, 0xbe, + 0x42, 0xe6, 0xd2, 0xd4, 0x42, 0xd8, 0x7b, 0x78, 0x14, 0x05, 0x35, 0x12, 0x0c, 0xb5, 0x35, 0xc1, + 0x6c, 0x19, 0xce, 0x8c, 0x20, 0x12, 0xc2, 0x37, 0x19, 0x67, 0x28, 0x04, 0xda, 0xfb, 0x64, 0x42, + 0xb1, 0x46, 0x45, 0xa2, 0x76, 0x59, 0xd0, 0xbb, 0x00, 0x1b, 0xa3, 0x9c, 0x61, 0xa0, 0x62, 0xf8, + 0xde, 0xd5, 0xc9, 0x14, 0x7f, 0xef, 0x82, 0x9b, 0x70, 0x21, 0x63, 0x2a, 0xa0, 0x9e, 0x9a, 0x69, + 0x42, 0xad, 0x2c, 0xa2, 0x2f, 0xc0, 0xe9, 0xe4, 0xab, 0x17, 0xb8, 0xbd, 0x43, 0x4e, 0x54, 0x29, + 0x1b, 0x6e, 0xa1, 0x50, 0xce, 0x6d, 0xb0, 0xd4, 0x53, 0xf7, 0x00, 0xe4, 0x5d, 0x2c, 0xbe, 0x40, + 0xca, 0xf6, 0x00, 0x48, 0x8e, 0xf3, 0x04, 0xfb, 0x6d, 0x16, 0x16, 0x73, 0x5a, 0x30, 0xf5, 0xd4, + 0x5c, 0x33, 0x6a, 0x67, 0x44, 0xd8, 0x12, 0x14, 0x93, 0xc9, 0xf2, 0x4e, 0x2b, 0x83, 0x7e, 0xa7, + 0x90, 0x62, 0xac, 0x02, 0x22, 0xbd, 0x0c, 0xd6, 0x46, 0x6f, 0x7b, 0xd4, 0x53, 0xf7, 0x83, 0x46, + 0xed, 0xa2, 0xa0, 0xa8, 0xc3, 0x5a, 0x7e, 0x35, 0xc8, 0x7d, 0x21, 0xe5, 0xef, 0x15, 0xb2, 0xc8, + 0x85, 0xca, 0xec, 0x48, 0xb0, 0xbe, 0x8f, 0xee, 0x45, 0x3d, 0x75, 0x5f, 0x70, 0xd4, 0x2e, 0x09, + 0xd6, 0x15, 0x58, 0x4f, 0x0a, 0xdb, 0xbf, 0x7d, 0x86, 0x36, 0x86, 0xb4, 0x6f, 0x93, 0x99, 0x2a, + 0x65, 0x43, 0xfd, 0x10, 0x12, 0x43, 0x52, 0xb4, 0x7d, 0xaa, 0xf9, 0xf6, 0xbc, 0xc2, 0x8a, 0xf4, + 0xd8, 0xad, 0xcd, 0x47, 0x4f, 0x4b, 0xca, 0xe3, 0xa7, 0x25, 0xe5, 0xcf, 0xa7, 0x25, 0xe5, 0xab, + 0x67, 0xa5, 0xb1, 0xc7, 0xcf, 0x4a, 0x63, 0xbf, 0x3e, 0x2b, 0x8d, 0x7d, 0x74, 0x76, 0xa8, 0xdf, + 0x5e, 0x0f, 0x7d, 0x84, 0xff, 0x14, 0xde, 0x16, 0xde, 0x44, 0xd3, 0xad, 0x4f, 0x8a, 0xbf, 0xf7, + 0x2e, 0xfc, 0x1d, 0x00, 0x00, 0xff, 0xff, 0x2b, 0xea, 0x2f, 0xba, 0xc2, 0x14, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1323,6 +1401,7 @@ type QueryClient interface { GetPmtpParams(ctx context.Context, in *PmtpParamsReq, opts ...grpc.CallOption) (*PmtpParamsRes, error) GetLiquidityProtectionParams(ctx context.Context, in *LiquidityProtectionParamsReq, opts ...grpc.CallOption) (*LiquidityProtectionParamsRes, error) GetProviderDistributionParams(ctx context.Context, in *ProviderDistributionParamsReq, opts ...grpc.CallOption) (*ProviderDistributionParamsRes, error) + GetSwapFeeRate(ctx context.Context, in *SwapFeeRateReq, opts ...grpc.CallOption) (*SwapFeeRateRes, error) } type queryClient struct { @@ -1441,6 +1520,15 @@ func (c *queryClient) GetProviderDistributionParams(ctx context.Context, in *Pro return out, nil } +func (c *queryClient) GetSwapFeeRate(ctx context.Context, in *SwapFeeRateReq, opts ...grpc.CallOption) (*SwapFeeRateRes, error) { + out := new(SwapFeeRateRes) + err := c.cc.Invoke(ctx, "/sifnode.clp.v1.Query/GetSwapFeeRate", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QueryServer is the server API for Query service. type QueryServer interface { GetPool(context.Context, *PoolReq) (*PoolRes, error) @@ -1455,6 +1543,7 @@ type QueryServer interface { GetPmtpParams(context.Context, *PmtpParamsReq) (*PmtpParamsRes, error) GetLiquidityProtectionParams(context.Context, *LiquidityProtectionParamsReq) (*LiquidityProtectionParamsRes, error) GetProviderDistributionParams(context.Context, *ProviderDistributionParamsReq) (*ProviderDistributionParamsRes, error) + GetSwapFeeRate(context.Context, *SwapFeeRateReq) (*SwapFeeRateRes, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -1497,6 +1586,9 @@ func (*UnimplementedQueryServer) GetLiquidityProtectionParams(ctx context.Contex func (*UnimplementedQueryServer) GetProviderDistributionParams(ctx context.Context, req *ProviderDistributionParamsReq) (*ProviderDistributionParamsRes, error) { return nil, status.Errorf(codes.Unimplemented, "method GetProviderDistributionParams not implemented") } +func (*UnimplementedQueryServer) GetSwapFeeRate(ctx context.Context, req *SwapFeeRateReq) (*SwapFeeRateRes, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetSwapFeeRate not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -1718,6 +1810,24 @@ func _Query_GetProviderDistributionParams_Handler(srv interface{}, ctx context.C return interceptor(ctx, in, info, handler) } +func _Query_GetSwapFeeRate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(SwapFeeRateReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).GetSwapFeeRate(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/sifnode.clp.v1.Query/GetSwapFeeRate", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).GetSwapFeeRate(ctx, req.(*SwapFeeRateReq)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "sifnode.clp.v1.Query", HandlerType: (*QueryServer)(nil), @@ -1770,6 +1880,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "GetProviderDistributionParams", Handler: _Query_GetProviderDistributionParams_Handler, }, + { + MethodName: "GetSwapFeeRate", + Handler: _Query_GetSwapFeeRate_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "sifnode/clp/v1/querier.proto", @@ -2772,6 +2886,62 @@ func (m *ProviderDistributionParamsRes) MarshalToSizedBuffer(dAtA []byte) (int, return len(dAtA) - i, nil } +func (m *SwapFeeRateReq) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *SwapFeeRateReq) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *SwapFeeRateReq) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *SwapFeeRateRes) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *SwapFeeRateRes) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *SwapFeeRateRes) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.SwapFeeRate.Size() + i -= size + if _, err := m.SwapFeeRate.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintQuerier(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + func encodeVarintQuerier(dAtA []byte, offset int, v uint64) int { offset -= sovQuerier(v) base := offset @@ -3180,6 +3350,26 @@ func (m *ProviderDistributionParamsRes) Size() (n int) { return n } +func (m *SwapFeeRateReq) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *SwapFeeRateRes) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.SwapFeeRate.Size() + n += 1 + l + sovQuerier(uint64(l)) + return n +} + func sovQuerier(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -5835,6 +6025,140 @@ func (m *ProviderDistributionParamsRes) Unmarshal(dAtA []byte) error { } return nil } +func (m *SwapFeeRateReq) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuerier + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: SwapFeeRateReq: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SwapFeeRateReq: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuerier(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuerier + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *SwapFeeRateRes) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuerier + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: SwapFeeRateRes: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SwapFeeRateRes: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SwapFeeRate", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuerier + } + 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 ErrInvalidLengthQuerier + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuerier + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.SwapFeeRate.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuerier(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuerier + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipQuerier(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/clp/types/querier.pb.gw.go b/x/clp/types/querier.pb.gw.go index a91e121ced..829e8cd840 100644 --- a/x/clp/types/querier.pb.gw.go +++ b/x/clp/types/querier.pb.gw.go @@ -539,6 +539,24 @@ func local_request_Query_GetProviderDistributionParams_0(ctx context.Context, ma } +func request_Query_GetSwapFeeRate_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq SwapFeeRateReq + var metadata runtime.ServerMetadata + + msg, err := client.GetSwapFeeRate(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_GetSwapFeeRate_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq SwapFeeRateReq + var metadata runtime.ServerMetadata + + msg, err := server.GetSwapFeeRate(ctx, &protoReq) + return msg, metadata, err + +} + // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -785,6 +803,26 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_GetSwapFeeRate_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_GetSwapFeeRate_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_GetSwapFeeRate_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -1066,6 +1104,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_GetSwapFeeRate_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_GetSwapFeeRate_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_GetSwapFeeRate_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -1093,6 +1151,8 @@ var ( pattern_Query_GetLiquidityProtectionParams_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"sifchain", "clp", "v1", "liquidity_protection_params"}, "", runtime.AssumeColonVerbOpt(true))) pattern_Query_GetProviderDistributionParams_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"sifchain", "clp", "v1", "provider_distribution_params"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_GetSwapFeeRate_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"sifchain", "clp", "v1", "swap_fee_rate"}, "", runtime.AssumeColonVerbOpt(true))) ) var ( @@ -1119,4 +1179,6 @@ var ( forward_Query_GetLiquidityProtectionParams_0 = runtime.ForwardResponseMessage forward_Query_GetProviderDistributionParams_0 = runtime.ForwardResponseMessage + + forward_Query_GetSwapFeeRate_0 = runtime.ForwardResponseMessage ) diff --git a/x/clp/types/tx.pb.go b/x/clp/types/tx.pb.go index 936cb397ba..9761fb1620 100644 --- a/x/clp/types/tx.pb.go +++ b/x/clp/types/tx.pb.go @@ -1656,6 +1656,87 @@ func (m *MsgAddProviderDistributionPeriodResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgAddProviderDistributionPeriodResponse proto.InternalMessageInfo +type MsgUpdateSwapFeeRateRequest struct { + Signer string `protobuf:"bytes,1,opt,name=signer,proto3" json:"signer,omitempty" yaml:"signer"` + SwapFeeRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=swap_fee_rate,json=swapFeeRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"swap_fee_rate"` +} + +func (m *MsgUpdateSwapFeeRateRequest) Reset() { *m = MsgUpdateSwapFeeRateRequest{} } +func (m *MsgUpdateSwapFeeRateRequest) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateSwapFeeRateRequest) ProtoMessage() {} +func (*MsgUpdateSwapFeeRateRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_a3bff5b30808c4f3, []int{35} +} +func (m *MsgUpdateSwapFeeRateRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateSwapFeeRateRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateSwapFeeRateRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgUpdateSwapFeeRateRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateSwapFeeRateRequest.Merge(m, src) +} +func (m *MsgUpdateSwapFeeRateRequest) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateSwapFeeRateRequest) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateSwapFeeRateRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateSwapFeeRateRequest proto.InternalMessageInfo + +func (m *MsgUpdateSwapFeeRateRequest) GetSigner() string { + if m != nil { + return m.Signer + } + return "" +} + +type MsgUpdateSwapFeeRateResponse struct { +} + +func (m *MsgUpdateSwapFeeRateResponse) Reset() { *m = MsgUpdateSwapFeeRateResponse{} } +func (m *MsgUpdateSwapFeeRateResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateSwapFeeRateResponse) ProtoMessage() {} +func (*MsgUpdateSwapFeeRateResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_a3bff5b30808c4f3, []int{36} +} +func (m *MsgUpdateSwapFeeRateResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateSwapFeeRateResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateSwapFeeRateResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgUpdateSwapFeeRateResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateSwapFeeRateResponse.Merge(m, src) +} +func (m *MsgUpdateSwapFeeRateResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateSwapFeeRateResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateSwapFeeRateResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateSwapFeeRateResponse proto.InternalMessageInfo + func init() { proto.RegisterType((*MsgUpdateStakingRewardParams)(nil), "sifnode.clp.v1.MsgUpdateStakingRewardParams") proto.RegisterType((*MsgUpdateStakingRewardParamsResponse)(nil), "sifnode.clp.v1.MsgUpdateStakingRewardParamsResponse") @@ -1692,122 +1773,127 @@ func init() { proto.RegisterType((*MsgUpdateLiquidityProtectionParamsResponse)(nil), "sifnode.clp.v1.MsgUpdateLiquidityProtectionParamsResponse") proto.RegisterType((*MsgAddProviderDistributionPeriodRequest)(nil), "sifnode.clp.v1.MsgAddProviderDistributionPeriodRequest") proto.RegisterType((*MsgAddProviderDistributionPeriodResponse)(nil), "sifnode.clp.v1.MsgAddProviderDistributionPeriodResponse") + proto.RegisterType((*MsgUpdateSwapFeeRateRequest)(nil), "sifnode.clp.v1.MsgUpdateSwapFeeRateRequest") + proto.RegisterType((*MsgUpdateSwapFeeRateResponse)(nil), "sifnode.clp.v1.MsgUpdateSwapFeeRateResponse") } func init() { proto.RegisterFile("sifnode/clp/v1/tx.proto", fileDescriptor_a3bff5b30808c4f3) } var fileDescriptor_a3bff5b30808c4f3 = []byte{ - // 1752 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x59, 0x5f, 0x6f, 0xe3, 0x58, - 0x15, 0x1f, 0x37, 0xd3, 0x61, 0x7a, 0x3a, 0xcd, 0xec, 0xb8, 0x0d, 0x6d, 0xdd, 0x26, 0x99, 0x7a, - 0x60, 0xe7, 0xcf, 0xee, 0x26, 0xcc, 0xb0, 0x68, 0x97, 0x95, 0x90, 0x68, 0x67, 0x46, 0x0b, 0xa2, - 0x81, 0xc8, 0x65, 0xb4, 0x08, 0x09, 0x19, 0xd7, 0xbe, 0x93, 0x5c, 0xd5, 0xf6, 0xf5, 0xfa, 0xde, - 0xa4, 0x2d, 0x12, 0x02, 0x89, 0x47, 0xa4, 0x15, 0xf0, 0x84, 0x90, 0x90, 0x10, 0x5f, 0x81, 0xcf, - 0x80, 0xb4, 0xf0, 0xb4, 0x08, 0x1e, 0x10, 0x0f, 0x15, 0x9a, 0x91, 0x90, 0x78, 0xe0, 0x65, 0x3e, - 0x01, 0xba, 0x7f, 0xe2, 0x38, 0x8e, 0x9d, 0xc4, 0x23, 0x1e, 0xfa, 0xc0, 0x53, 0xeb, 0x7b, 0xce, - 0xf9, 0x9d, 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 0x94, 0x5b, 0x12, 0x45, 0x2f, 0xca, 0xfa, 0x4f, 0x60, 0xbb, - 0xf8, 0xb7, 0x86, 0xb7, 0x0b, 0x91, 0x72, 0xb8, 0x8d, 0x77, 0xcb, 0x70, 0xa7, 0x67, 0x4b, 0xee, - 0x4a, 0x9a, 0xd7, 0x7c, 0x79, 0x8c, 0xb9, 0xb3, 0x65, 0xd6, 0x76, 0xa8, 0x3b, 0x50, 0x4b, 0xaf, - 0x53, 0xb3, 0x07, 0x42, 0x9a, 0x33, 0x77, 0x20, 0xe4, 0x6d, 0x66, 0xfa, 0x2f, 0x35, 0x68, 0xce, - 0xbb, 0xfc, 0x1f, 0x15, 0x86, 0xab, 0x50, 0xc6, 0xf8, 0xa0, 0xbc, 0x4c, 0x62, 0xd3, 0x27, 0x1a, - 0x34, 0xe6, 0xac, 0x62, 0x0f, 0x0b, 0xcb, 0xb3, 0x48, 0xc4, 0xf8, 0x6a, 0x69, 0x91, 0xc4, 0xa0, - 0x5f, 0x69, 0x50, 0x9f, 0x79, 0xd5, 0xe9, 0xef, 0xe5, 0x77, 0xe4, 0xdc, 0x1b, 0xdd, 0x78, 0xbf, - 0xbc, 0xa0, 0x34, 0xea, 0x60, 0xff, 0xd3, 0x17, 0x0d, 0xed, 0xb3, 0x17, 0x0d, 0xed, 0x9f, 0x2f, - 0x1a, 0xda, 0x2f, 0x5e, 0x36, 0xae, 0x7c, 0xf6, 0xb2, 0x71, 0xe5, 0xef, 0x2f, 0x1b, 0x57, 0xbe, - 0x9f, 0x5e, 0xa9, 0x8e, 0xf0, 0x73, 0xb7, 0xef, 0xe0, 0xb0, 0x3d, 0xfa, 0x29, 0xef, 0x4c, 0xfc, - 0x98, 0x27, 0xf6, 0xaa, 0xe3, 0x6b, 0xe2, 0x97, 0xbc, 0x2f, 0xff, 0x37, 0x00, 0x00, 0xff, 0xff, - 0x27, 0x09, 0xcb, 0x9f, 0x5e, 0x1c, 0x00, 0x00, + // 1807 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x59, 0x5b, 0x6f, 0xe3, 0x58, + 0x1d, 0x1f, 0x37, 0xd3, 0x61, 0xfa, 0xef, 0xb4, 0xb3, 0x75, 0x5b, 0xda, 0xba, 0x6d, 0x32, 0xf5, + 0xc0, 0xce, 0x65, 0x67, 0x13, 0x66, 0x58, 0xb4, 0xcb, 0x4a, 0x48, 0xb4, 0x33, 0xc3, 0x82, 0x68, + 0x20, 0x72, 0x19, 0x2d, 0x42, 0x42, 0xc6, 0xb5, 0x4f, 0x93, 0xa3, 0xda, 0x3e, 0x5e, 0x9f, 0x93, + 0xa4, 0x45, 0x42, 0x20, 0xf1, 0x88, 0xb4, 0x02, 0x9e, 0x10, 0x02, 0x09, 0xf1, 0x15, 0xf8, 0x08, + 0x08, 0x69, 0xe1, 0x69, 0x91, 0x78, 0x40, 0x3c, 0x54, 0x68, 0x46, 0x42, 0xe2, 0x81, 0x97, 0xf9, + 0x04, 0xe8, 0x5c, 0xe2, 0x38, 0x8e, 0x9d, 0xc4, 0x15, 0x0f, 0x7d, 0xe0, 0xa9, 0xf5, 0xf9, 0xdf, + 0xaf, 0xe7, 0x67, 0x07, 0x36, 0x28, 0x3e, 0x09, 0x89, 0x87, 0x1a, 0xae, 0x1f, 0x35, 0x7a, 0x8f, + 0x1b, 0xec, 0xac, 0x1e, 0xc5, 0x84, 0x11, 0x7d, 0x59, 0x11, 0xea, 0xae, 0x1f, 0xd5, 0x7b, 0x8f, + 0x8d, 0xb5, 0x36, 0x69, 0x13, 0x41, 0x6a, 0xf0, 0xff, 0x24, 0x97, 0x61, 0x64, 0xc5, 0xcf, 0x23, + 0x44, 0x15, 0x6d, 0x2b, 0x43, 0x8b, 0x08, 0xf1, 0x15, 0x69, 0x3b, 0x4b, 0x72, 0x62, 0x27, 0x50, + 0x72, 0xe6, 0x7f, 0x34, 0xd8, 0x69, 0xd2, 0xf6, 0x8b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0x62, 0x47, 0x0a, 0xe8, 0x7f, 0xa7, 0x13, + 0x23, 0xda, 0x21, 0xbe, 0xa7, 0x7f, 0x76, 0xd4, 0xd3, 0xc4, 0xad, 0x43, 0x58, 0x60, 0x03, 0x26, + 0x35, 0x2c, 0xf5, 0x12, 0xef, 0x1a, 0xcf, 0x90, 0x6b, 0x0d, 0x15, 0xe8, 0xcf, 0x60, 0x3e, 0x76, + 0x18, 0x26, 0xaa, 0x17, 0xcb, 0x6a, 0x92, 0xc2, 0x0a, 0x6e, 0xe7, 0x85, 0x91, 0x84, 0xfa, 0x67, + 0x4d, 0xac, 0x0d, 0x59, 0x4c, 0xd9, 0xb4, 0x85, 0x21, 0x5e, 0xf5, 0xc9, 0x93, 0x48, 0x27, 0x1d, + 0x4a, 0x12, 0xe6, 0x6f, 0x35, 0x58, 0x56, 0x7d, 0x3b, 0x68, 0xb9, 0x65, 0x98, 0xc3, 0x9e, 0x88, + 0xb0, 0x62, 0xcd, 0x61, 0x3e, 0x09, 0xf3, 0x3d, 0xc7, 0xef, 0xaa, 0x2b, 0xff, 0x12, 0x4e, 0x08, + 0x69, 0xfd, 0x1d, 0xa8, 0x04, 0xb4, 0xad, 0xee, 0x2f, 0x33, 0x9b, 0x99, 0x9c, 0x97, 0x45, 0xce, + 0x6e, 0xfe, 0x45, 0x83, 0xbd, 0x04, 0xe7, 0x24, 0xb4, 0x56, 0x4c, 0x18, 0x72, 0x19, 0x26, 0x61, + 0x69, 0x60, 0xf6, 0x43, 0xd8, 0x73, 0xbb, 0x71, 0xcc, 0xef, 0xab, 0x98, 0xf4, 0x9d, 0xd0, 0x1e, + 0x4e, 0x79, 0xb6, 0x4d, 0x4b, 0x47, 0x5a, 0x55, 0x9a, 0x2d, 0xae, 0x38, 0x71, 0x36, 0xe9, 0x2d, + 0xf3, 0x2d, 0x78, 0x30, 0x35, 0x96, 0xa4, 0x32, 0x7f, 0x9d, 0x03, 0x33, 0x59, 0x1d, 0x39, 0xdc, + 0xe5, 0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d, 0x32, + 0x09, 0xdc, 0xea, 0x0e, 0xac, 0xa7, 0xd1, 0xe0, 0xe4, 0x85, 0x90, 0xe6, 0xcc, 0x5d, 0x08, 0x79, + 0xc0, 0x52, 0xff, 0x85, 0x06, 0xb5, 0x69, 0xd8, 0xe5, 0x49, 0x61, 0xba, 0x0a, 0x65, 0x8c, 0xf7, + 0xcb, 0xcb, 0x24, 0x3e, 0x7d, 0xac, 0x41, 0x75, 0x0a, 0x92, 0x7c, 0x5c, 0xd8, 0x9e, 0x45, 0x22, + 0xc6, 0x97, 0x4b, 0x8b, 0x24, 0x0e, 0xfd, 0x52, 0x83, 0xdd, 0x89, 0x37, 0xb5, 0xfe, 0x6e, 0xfe, + 0x44, 0x4e, 0x05, 0x24, 0xc6, 0x7b, 0xe5, 0x05, 0x95, 0x53, 0x21, 0xac, 0x8c, 0x5d, 0xb9, 0x7a, + 0xf1, 0x44, 0x8d, 0xc3, 0x06, 0xe3, 0xd1, 0x6c, 0xcc, 0xd2, 0xde, 0xc1, 0xfe, 0x27, 0x2f, 0xab, + 0xda, 0xa7, 0x2f, 0xab, 0xda, 0x3f, 0x5f, 0x56, 0xb5, 0x9f, 0xbf, 0xaa, 0x5e, 0xfb, 0xf4, 0x55, + 0xf5, 0xda, 0xdf, 0x5f, 0x55, 0xaf, 0x7d, 0x2f, 0x8d, 0x40, 0x8f, 0xf0, 0x89, 0xdb, 0x71, 0x70, + 0xd8, 0x18, 0xfc, 0xf2, 0x79, 0x26, 0x7e, 0xfb, 0x14, 0xc8, 0xe1, 0xf8, 0x86, 0xf8, 0xe1, 0xf3, + 0x8b, 0xff, 0x0d, 0x00, 0x00, 0xff, 0xff, 0xdf, 0x5b, 0xfc, 0xda, 0x8d, 0x1d, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1839,6 +1925,7 @@ type MsgClient interface { UpdateLiquidityProtectionParams(ctx context.Context, in *MsgUpdateLiquidityProtectionParams, opts ...grpc.CallOption) (*MsgUpdateLiquidityProtectionParamsResponse, error) ModifyLiquidityProtectionRates(ctx context.Context, in *MsgModifyLiquidityProtectionRates, opts ...grpc.CallOption) (*MsgModifyLiquidityProtectionRatesResponse, error) AddProviderDistributionPeriod(ctx context.Context, in *MsgAddProviderDistributionPeriodRequest, opts ...grpc.CallOption) (*MsgAddProviderDistributionPeriodResponse, error) + UpdateSwapFeeRate(ctx context.Context, in *MsgUpdateSwapFeeRateRequest, opts ...grpc.CallOption) (*MsgUpdateSwapFeeRateResponse, error) } type msgClient struct { @@ -2002,6 +2089,15 @@ func (c *msgClient) AddProviderDistributionPeriod(ctx context.Context, in *MsgAd return out, nil } +func (c *msgClient) UpdateSwapFeeRate(ctx context.Context, in *MsgUpdateSwapFeeRateRequest, opts ...grpc.CallOption) (*MsgUpdateSwapFeeRateResponse, error) { + out := new(MsgUpdateSwapFeeRateResponse) + err := c.cc.Invoke(ctx, "/sifnode.clp.v1.Msg/UpdateSwapFeeRate", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // MsgServer is the server API for Msg service. type MsgServer interface { RemoveLiquidity(context.Context, *MsgRemoveLiquidity) (*MsgRemoveLiquidityResponse, error) @@ -2021,6 +2117,7 @@ type MsgServer interface { UpdateLiquidityProtectionParams(context.Context, *MsgUpdateLiquidityProtectionParams) (*MsgUpdateLiquidityProtectionParamsResponse, error) ModifyLiquidityProtectionRates(context.Context, *MsgModifyLiquidityProtectionRates) (*MsgModifyLiquidityProtectionRatesResponse, error) AddProviderDistributionPeriod(context.Context, *MsgAddProviderDistributionPeriodRequest) (*MsgAddProviderDistributionPeriodResponse, error) + UpdateSwapFeeRate(context.Context, *MsgUpdateSwapFeeRateRequest) (*MsgUpdateSwapFeeRateResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. @@ -2078,6 +2175,9 @@ func (*UnimplementedMsgServer) ModifyLiquidityProtectionRates(ctx context.Contex func (*UnimplementedMsgServer) AddProviderDistributionPeriod(ctx context.Context, req *MsgAddProviderDistributionPeriodRequest) (*MsgAddProviderDistributionPeriodResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method AddProviderDistributionPeriod not implemented") } +func (*UnimplementedMsgServer) UpdateSwapFeeRate(ctx context.Context, req *MsgUpdateSwapFeeRateRequest) (*MsgUpdateSwapFeeRateResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateSwapFeeRate not implemented") +} func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) @@ -2389,6 +2489,24 @@ func _Msg_AddProviderDistributionPeriod_Handler(srv interface{}, ctx context.Con return interceptor(ctx, in, info, handler) } +func _Msg_UpdateSwapFeeRate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateSwapFeeRateRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).UpdateSwapFeeRate(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/sifnode.clp.v1.Msg/UpdateSwapFeeRate", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UpdateSwapFeeRate(ctx, req.(*MsgUpdateSwapFeeRateRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "sifnode.clp.v1.Msg", HandlerType: (*MsgServer)(nil), @@ -2461,6 +2579,10 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "AddProviderDistributionPeriod", Handler: _Msg_AddProviderDistributionPeriod_Handler, }, + { + MethodName: "UpdateSwapFeeRate", + Handler: _Msg_UpdateSwapFeeRate_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "sifnode/clp/v1/tx.proto", @@ -3796,6 +3918,69 @@ func (m *MsgAddProviderDistributionPeriodResponse) MarshalToSizedBuffer(dAtA []b return len(dAtA) - i, nil } +func (m *MsgUpdateSwapFeeRateRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgUpdateSwapFeeRateRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateSwapFeeRateRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.SwapFeeRate.Size() + i -= size + if _, err := m.SwapFeeRate.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.Signer) > 0 { + i -= len(m.Signer) + copy(dAtA[i:], m.Signer) + i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgUpdateSwapFeeRateResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgUpdateSwapFeeRateResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateSwapFeeRateResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + func encodeVarintTx(dAtA []byte, offset int, v uint64) int { offset -= sovTx(v) base := offset @@ -4321,6 +4506,30 @@ func (m *MsgAddProviderDistributionPeriodResponse) Size() (n int) { return n } +func (m *MsgUpdateSwapFeeRateRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.SwapFeeRate.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *MsgUpdateSwapFeeRateResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + func sovTx(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -7958,6 +8167,172 @@ func (m *MsgAddProviderDistributionPeriodResponse) Unmarshal(dAtA []byte) error } return nil } +func (m *MsgUpdateSwapFeeRateRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgUpdateSwapFeeRateRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateSwapFeeRateRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Signer = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SwapFeeRate", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.SwapFeeRate.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpdateSwapFeeRateResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgUpdateSwapFeeRateResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateSwapFeeRateResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipTx(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/margin/keeper/msg_server_test.go b/x/margin/keeper/msg_server_test.go index a60203f0f1..46fc876391 100644 --- a/x/margin/keeper/msg_server_test.go +++ b/x/margin/keeper/msg_server_test.go @@ -974,9 +974,9 @@ func TestKeeper_OpenClose(t *testing.T) { InterestPaidCustody: sdk.ZeroUint(), InterestUnpaidCollateral: sdk.ZeroUint(), CustodyAsset: tt.externalAsset, - CustodyAmount: sdk.NewUint(1999), + CustodyAmount: sdk.NewUint(1993), Leverage: sdk.NewDec(2), - MtpHealth: sdk.MustNewDecFromStr("2.001001001001001001"), + MtpHealth: sdk.MustNewDecFromStr("2.001004016064257028"), Position: types.Position_LONG, } @@ -990,9 +990,9 @@ func TestKeeper_OpenClose(t *testing.T) { openExpectedPool := clptypes.Pool{ ExternalAsset: &externalAsset, NativeAssetBalance: sdk.NewUint(1000000001000), - ExternalAssetBalance: sdk.NewUint(999999998001), + ExternalAssetBalance: sdk.NewUint(999999998007), NativeCustody: sdk.ZeroUint(), - ExternalCustody: sdk.NewUint(1999), + ExternalCustody: sdk.NewUint(1993), NativeLiabilities: sdk.NewUint(1000), ExternalLiabilities: sdk.ZeroUint(), PoolUnits: sdk.ZeroUint(), @@ -1008,13 +1008,12 @@ func TestKeeper_OpenClose(t *testing.T) { _, closeError := msgServer.Close(sdk.WrapSDKContext(ctx), &msgClose) require.Nil(t, closeError) - - require.Equal(t, sdk.NewCoin(nativeAsset, sdk.Int(sdk.NewUint(99999999999998))), app.BankKeeper.GetBalance(ctx, signer, nativeAsset)) + require.Equal(t, sdk.NewCoin(nativeAsset, sdk.Int(sdk.NewUint(99999999999987))), app.BankKeeper.GetBalance(ctx, signer, nativeAsset)) require.Equal(t, sdk.NewCoin(tt.externalAsset, sdk.Int(sdk.NewUint(1000000000000000))), app.BankKeeper.GetBalance(ctx, signer, tt.externalAsset)) closeExpectedPool := clptypes.Pool{ ExternalAsset: &externalAsset, - NativeAssetBalance: sdk.NewUint(1000000000002), + NativeAssetBalance: sdk.NewUint(1000000000013), ExternalAssetBalance: sdk.NewUint(1000000000000), NativeCustody: sdk.ZeroUint(), ExternalCustody: sdk.ZeroUint(), @@ -1247,12 +1246,12 @@ func TestKeeper_EC(t *testing.T) { chunk: sdk.NewUint(10), signerNativeAssetBalanceAfterOpen: sdk.NewUint(99999999990000), signerExternalAssetBalanceAfterOpen: sdk.NewUint(100000000000000), - signerNativeAssetBalanceAfterClose: sdk.NewUint(99999999997544), + signerNativeAssetBalanceAfterClose: sdk.NewUint(99999999999055), signerExternalAssetBalanceAfterClose: sdk.NewUint(100000000000000), poolNativeAssetBalanceAfterOpen: sdk.NewUint(90000), poolExternalAssetBalanceAfterOpen: sdk.NewUint(69), poolHealthAfterOpen: sdk.NewDecWithPrec(1000000000000000000, 18), - poolNativeAssetBalanceAfterClose: sdk.NewUint(102456), + poolNativeAssetBalanceAfterClose: sdk.NewUint(100945), poolExternalAssetBalanceAfterClose: sdk.NewUint(100), poolHealthAfterClose: sdk.NewDecWithPrec(1000000000000000000, 18), mtpCustodyAmount: sdk.NewUint(31), @@ -1262,12 +1261,12 @@ func TestKeeper_EC(t *testing.T) { chunk: sdk.NewUint(55), signerNativeAssetBalanceAfterOpen: sdk.NewUint(99999999935000), signerExternalAssetBalanceAfterOpen: sdk.NewUint(100000000000000), - signerNativeAssetBalanceAfterClose: sdk.NewUint(99999999965817), + signerNativeAssetBalanceAfterClose: sdk.NewUint(99999999984363), signerExternalAssetBalanceAfterClose: sdk.NewUint(100000000000000), poolNativeAssetBalanceAfterOpen: sdk.NewUint(11692600000), poolExternalAssetBalanceAfterOpen: sdk.NewUint(13), poolHealthAfterOpen: sdk.NewDecWithPrec(1000000000000000000, 18), - poolNativeAssetBalanceAfterClose: sdk.NewUint(134183), + poolNativeAssetBalanceAfterClose: sdk.NewUint(115637), poolExternalAssetBalanceAfterClose: sdk.NewUint(100), poolHealthAfterClose: sdk.NewDecWithPrec(1000000000000000000, 18), mtpCustodyAmount: sdk.NewUint(77), @@ -1277,12 +1276,12 @@ func TestKeeper_EC(t *testing.T) { chunk: sdk.NewUint(99), signerNativeAssetBalanceAfterOpen: sdk.NewUint(99999999965817), signerExternalAssetBalanceAfterOpen: sdk.NewUint(100000000000000), - signerNativeAssetBalanceAfterClose: sdk.NewUint(99999999903213), + signerNativeAssetBalanceAfterClose: sdk.NewUint(99999999951774), signerExternalAssetBalanceAfterClose: sdk.NewUint(100000000000000), poolNativeAssetBalanceAfterOpen: sdk.NewUint(110000), poolExternalAssetBalanceAfterOpen: sdk.NewUint(69), poolHealthAfterOpen: sdk.NewDecWithPrec(1000000000000000000, 18), - poolNativeAssetBalanceAfterClose: sdk.NewUint(196787), + poolNativeAssetBalanceAfterClose: sdk.NewUint(148226), poolExternalAssetBalanceAfterClose: sdk.NewUint(100), poolHealthAfterClose: sdk.NewDecWithPrec(1000000000000000000, 18), mtpCustodyAmount: sdk.NewUint(87), @@ -1313,12 +1312,12 @@ func TestKeeper_EC(t *testing.T) { chunk: sdk.NewUint(55), signerNativeAssetBalanceAfterOpen: sdk.NewUint(99999999935000), signerExternalAssetBalanceAfterOpen: sdk.NewUint(100000000000000), - signerNativeAssetBalanceAfterClose: sdk.NewUint(99999999957916), + signerNativeAssetBalanceAfterClose: sdk.NewUint(99999999972962), signerExternalAssetBalanceAfterClose: sdk.NewUint(100000000000000), poolNativeAssetBalanceAfterOpen: sdk.NewUint(118006), poolExternalAssetBalanceAfterOpen: sdk.NewUint(1), poolHealthAfterOpen: sdk.NewDecWithPrec(1000000000000000000, 18), - poolNativeAssetBalanceAfterClose: sdk.NewUint(142084), + poolNativeAssetBalanceAfterClose: sdk.NewUint(127038), poolExternalAssetBalanceAfterClose: sdk.NewUint(10), poolHealthAfterClose: sdk.NewDecWithPrec(1000000000000000000, 18), mtpCustodyAmount: sdk.NewUint(8), @@ -1328,12 +1327,12 @@ func TestKeeper_EC(t *testing.T) { chunk: sdk.NewUint(99), signerNativeAssetBalanceAfterOpen: sdk.NewUint(99999999983074), signerExternalAssetBalanceAfterOpen: sdk.NewUint(100000000000000), - signerNativeAssetBalanceAfterClose: sdk.NewUint(99999999892399), + signerNativeAssetBalanceAfterClose: sdk.NewUint(99999999938350), signerExternalAssetBalanceAfterClose: sdk.NewUint(100000000000000), poolNativeAssetBalanceAfterOpen: sdk.NewUint(110000), poolExternalAssetBalanceAfterOpen: sdk.NewUint(69), poolHealthAfterOpen: sdk.NewDecWithPrec(1000000000000000000, 18), - poolNativeAssetBalanceAfterClose: sdk.NewUint(207601), + poolNativeAssetBalanceAfterClose: sdk.NewUint(161650), poolExternalAssetBalanceAfterClose: sdk.NewUint(10), poolHealthAfterClose: sdk.NewDecWithPrec(1000000000000000000, 18), mtpCustodyAmount: sdk.NewUint(87), @@ -1406,12 +1405,12 @@ func TestKeeper_EC(t *testing.T) { chunk: sdk.NewUint(10), signerNativeAssetBalanceAfterOpen: sdk.NewUint(99999999990000), signerExternalAssetBalanceAfterOpen: sdk.NewUint(100000000000000), - signerNativeAssetBalanceAfterClose: sdk.NewUint(99999999997755), + signerNativeAssetBalanceAfterClose: sdk.NewUint(99999999999113), signerExternalAssetBalanceAfterClose: sdk.NewUint(100000000000000), poolNativeAssetBalanceAfterOpen: sdk.NewUint(90000), poolExternalAssetBalanceAfterOpen: sdk.NewUint(69444), poolHealthAfterOpen: sdk.NewDecWithPrec(1000000000000000000, 18), - poolNativeAssetBalanceAfterClose: sdk.NewUint(102245), + poolNativeAssetBalanceAfterClose: sdk.NewUint(100887), poolExternalAssetBalanceAfterClose: sdk.NewUint(100000), poolHealthAfterClose: sdk.NewDecWithPrec(1000000000000000000, 18), mtpCustodyAmount: sdk.NewUint(30556), @@ -1421,12 +1420,12 @@ func TestKeeper_EC(t *testing.T) { chunk: sdk.NewUint(55), signerNativeAssetBalanceAfterOpen: sdk.NewUint(99999999935000), signerExternalAssetBalanceAfterOpen: sdk.NewUint(100000000000000), - signerNativeAssetBalanceAfterClose: sdk.NewUint(99999999966492), + signerNativeAssetBalanceAfterClose: sdk.NewUint(99999999984556), signerExternalAssetBalanceAfterClose: sdk.NewUint(100000000000000), poolNativeAssetBalanceAfterOpen: sdk.NewUint(117402), poolExternalAssetBalanceAfterOpen: sdk.NewUint(13101), poolHealthAfterOpen: sdk.NewDecWithPrec(1000000000000000000, 18), - poolNativeAssetBalanceAfterClose: sdk.NewUint(133508), + poolNativeAssetBalanceAfterClose: sdk.NewUint(115444), poolExternalAssetBalanceAfterClose: sdk.NewUint(100000), poolHealthAfterClose: sdk.NewDecWithPrec(1000000000000000000, 18), mtpCustodyAmount: sdk.NewUint(86899), @@ -1436,12 +1435,12 @@ func TestKeeper_EC(t *testing.T) { chunk: sdk.NewUint(99), signerNativeAssetBalanceAfterOpen: sdk.NewUint(99999999983074), signerExternalAssetBalanceAfterOpen: sdk.NewUint(100000000000000), - signerNativeAssetBalanceAfterClose: sdk.NewUint(99999999904196), + signerNativeAssetBalanceAfterClose: sdk.NewUint(99999999952944), signerExternalAssetBalanceAfterClose: sdk.NewUint(100000000000000), poolNativeAssetBalanceAfterOpen: sdk.NewUint(110000), poolExternalAssetBalanceAfterOpen: sdk.NewUint(69), poolHealthAfterOpen: sdk.NewDecWithPrec(1000000000000000000, 18), - poolNativeAssetBalanceAfterClose: sdk.NewUint(195804), + poolNativeAssetBalanceAfterClose: sdk.NewUint(147056), poolExternalAssetBalanceAfterClose: sdk.NewUint(100000), poolHealthAfterClose: sdk.NewDecWithPrec(1000000000000000000, 18), mtpCustodyAmount: sdk.NewUint(87), @@ -1457,12 +1456,12 @@ func TestKeeper_EC(t *testing.T) { chunk: sdk.NewUint(10), signerNativeAssetBalanceAfterOpen: sdk.NewUint(99999999990000), signerExternalAssetBalanceAfterOpen: sdk.NewUint(100000000000000), - signerNativeAssetBalanceAfterClose: sdk.NewUint(99999999997755), + signerNativeAssetBalanceAfterClose: sdk.NewUint(99999999999113), signerExternalAssetBalanceAfterClose: sdk.NewUint(100000000000000), poolNativeAssetBalanceAfterOpen: sdk.NewUint(90000), poolExternalAssetBalanceAfterOpen: sdk.NewUint(138889), poolHealthAfterOpen: sdk.NewDecWithPrec(1000000000000000000, 18), - poolNativeAssetBalanceAfterClose: sdk.NewUint(102245), + poolNativeAssetBalanceAfterClose: sdk.NewUint(100887), poolExternalAssetBalanceAfterClose: sdk.NewUint(200000), poolHealthAfterClose: sdk.NewDecWithPrec(1000000000000000000, 18), mtpCustodyAmount: sdk.NewUint(61111), @@ -1472,12 +1471,12 @@ func TestKeeper_EC(t *testing.T) { chunk: sdk.NewUint(55), signerNativeAssetBalanceAfterOpen: sdk.NewUint(99999999935000), signerExternalAssetBalanceAfterOpen: sdk.NewUint(100000000000000), - signerNativeAssetBalanceAfterClose: sdk.NewUint(99999999966492), + signerNativeAssetBalanceAfterClose: sdk.NewUint(99999999984556), signerExternalAssetBalanceAfterClose: sdk.NewUint(100000000000000), poolNativeAssetBalanceAfterOpen: sdk.NewUint(117403), poolExternalAssetBalanceAfterOpen: sdk.NewUint(26203), poolHealthAfterOpen: sdk.NewDecWithPrec(1000000000000000000, 18), - poolNativeAssetBalanceAfterClose: sdk.NewUint(133508), + poolNativeAssetBalanceAfterClose: sdk.NewUint(115444), poolExternalAssetBalanceAfterClose: sdk.NewUint(200000), poolHealthAfterClose: sdk.NewDecWithPrec(1000000000000000000, 18), mtpCustodyAmount: sdk.NewUint(173797), @@ -1487,12 +1486,12 @@ func TestKeeper_EC(t *testing.T) { chunk: sdk.NewUint(99), signerNativeAssetBalanceAfterOpen: sdk.NewUint(99999999983074), signerExternalAssetBalanceAfterOpen: sdk.NewUint(100000000000000), - signerNativeAssetBalanceAfterClose: sdk.NewUint(99999999904196), + signerNativeAssetBalanceAfterClose: sdk.NewUint(99999999952944), signerExternalAssetBalanceAfterClose: sdk.NewUint(100000000000000), poolNativeAssetBalanceAfterOpen: sdk.NewUint(110000), poolExternalAssetBalanceAfterOpen: sdk.NewUint(69), poolHealthAfterOpen: sdk.NewDecWithPrec(1000000000000000000, 18), - poolNativeAssetBalanceAfterClose: sdk.NewUint(195804), + poolNativeAssetBalanceAfterClose: sdk.NewUint(147056), poolExternalAssetBalanceAfterClose: sdk.NewUint(200000), poolHealthAfterClose: sdk.NewDecWithPrec(1000000000000000000, 18), mtpCustodyAmount: sdk.NewUint(87), @@ -1565,12 +1564,12 @@ func TestKeeper_EC(t *testing.T) { chunk: sdk.NewUint(10), signerNativeAssetBalanceAfterOpen: sdk.NewUint(99999999990000), signerExternalAssetBalanceAfterOpen: sdk.NewUint(100000000000000), - signerNativeAssetBalanceAfterClose: sdk.NewUint(99999999997752), + signerNativeAssetBalanceAfterClose: sdk.NewUint(99999999999110), signerExternalAssetBalanceAfterClose: sdk.NewUint(100000000000000), poolNativeAssetBalanceAfterOpen: sdk.NewUint(90000), poolExternalAssetBalanceAfterOpen: sdk.NewUint(3472), poolHealthAfterOpen: sdk.NewDecWithPrec(1000000000000000000, 18), - poolNativeAssetBalanceAfterClose: sdk.NewUint(102248), + poolNativeAssetBalanceAfterClose: sdk.NewUint(100890), poolExternalAssetBalanceAfterClose: sdk.NewUint(5000), poolHealthAfterClose: sdk.NewDecWithPrec(1000000000000000000, 18), mtpCustodyAmount: sdk.NewUint(1528), @@ -1580,12 +1579,12 @@ func TestKeeper_EC(t *testing.T) { chunk: sdk.NewUint(55), signerNativeAssetBalanceAfterOpen: sdk.NewUint(99999999935000), signerExternalAssetBalanceAfterOpen: sdk.NewUint(100000000000000), - signerNativeAssetBalanceAfterClose: sdk.NewUint(99999999966487), + signerNativeAssetBalanceAfterClose: sdk.NewUint(99999999984540), signerExternalAssetBalanceAfterClose: sdk.NewUint(100000000000000), poolNativeAssetBalanceAfterOpen: sdk.NewUint(117398), poolExternalAssetBalanceAfterOpen: sdk.NewUint(655), poolHealthAfterOpen: sdk.NewDecWithPrec(1000000000000000000, 18), - poolNativeAssetBalanceAfterClose: sdk.NewUint(133513), + poolNativeAssetBalanceAfterClose: sdk.NewUint(115460), poolExternalAssetBalanceAfterClose: sdk.NewUint(5000), poolHealthAfterClose: sdk.NewDecWithPrec(1000000000000000000, 18), mtpCustodyAmount: sdk.NewUint(4345), @@ -1595,12 +1594,12 @@ func TestKeeper_EC(t *testing.T) { chunk: sdk.NewUint(99), signerNativeAssetBalanceAfterOpen: sdk.NewUint(99999999983074), signerExternalAssetBalanceAfterOpen: sdk.NewUint(100000000000000), - signerNativeAssetBalanceAfterClose: sdk.NewUint(99999999904183), + signerNativeAssetBalanceAfterClose: sdk.NewUint(99999999952926), signerExternalAssetBalanceAfterClose: sdk.NewUint(100000000000000), poolNativeAssetBalanceAfterOpen: sdk.NewUint(110000), poolExternalAssetBalanceAfterOpen: sdk.NewUint(69), poolHealthAfterOpen: sdk.NewDecWithPrec(1000000000000000000, 18), - poolNativeAssetBalanceAfterClose: sdk.NewUint(195817), + poolNativeAssetBalanceAfterClose: sdk.NewUint(147074), poolExternalAssetBalanceAfterClose: sdk.NewUint(5000), poolHealthAfterClose: sdk.NewDecWithPrec(1000000000000000000, 18), mtpCustodyAmount: sdk.NewUint(87), @@ -1616,12 +1615,12 @@ func TestKeeper_EC(t *testing.T) { chunk: sdk.NewUint(10), signerNativeAssetBalanceAfterOpen: sdk.NewUint(99999999999000), signerExternalAssetBalanceAfterOpen: sdk.NewUint(100000000000000), - signerNativeAssetBalanceAfterClose: sdk.NewUint(99999999999754), + signerNativeAssetBalanceAfterClose: sdk.NewUint(99999999999905), signerExternalAssetBalanceAfterClose: sdk.NewUint(100000000000000), poolNativeAssetBalanceAfterOpen: sdk.NewUint(9000), poolExternalAssetBalanceAfterOpen: sdk.NewUint(69), poolHealthAfterOpen: sdk.NewDecWithPrec(1000000000000000000, 18), - poolNativeAssetBalanceAfterClose: sdk.NewUint(10246), + poolNativeAssetBalanceAfterClose: sdk.NewUint(10095), poolExternalAssetBalanceAfterClose: sdk.NewUint(100), poolHealthAfterClose: sdk.NewDecWithPrec(1000000000000000000, 18), mtpCustodyAmount: sdk.NewUint(31), @@ -1631,12 +1630,12 @@ func TestKeeper_EC(t *testing.T) { chunk: sdk.NewUint(55), signerNativeAssetBalanceAfterOpen: sdk.NewUint(99999999993500), signerExternalAssetBalanceAfterOpen: sdk.NewUint(100000000000000), - signerNativeAssetBalanceAfterClose: sdk.NewUint(99999999996581), + signerNativeAssetBalanceAfterClose: sdk.NewUint(99999999998436), signerExternalAssetBalanceAfterClose: sdk.NewUint(100000000000000), poolNativeAssetBalanceAfterOpen: sdk.NewUint(11693), poolExternalAssetBalanceAfterOpen: sdk.NewUint(13), poolHealthAfterOpen: sdk.NewDecWithPrec(1000000000000000000, 18), - poolNativeAssetBalanceAfterClose: sdk.NewUint(13419), + poolNativeAssetBalanceAfterClose: sdk.NewUint(11564), poolExternalAssetBalanceAfterClose: sdk.NewUint(100), poolHealthAfterClose: sdk.NewDecWithPrec(1000000000000000000, 18), mtpCustodyAmount: sdk.NewUint(87), @@ -1646,12 +1645,12 @@ func TestKeeper_EC(t *testing.T) { chunk: sdk.NewUint(99), signerNativeAssetBalanceAfterOpen: sdk.NewUint(99999999983074), signerExternalAssetBalanceAfterOpen: sdk.NewUint(100000000000000), - signerNativeAssetBalanceAfterClose: sdk.NewUint(99999999990320), + signerNativeAssetBalanceAfterClose: sdk.NewUint(99999999995177), signerExternalAssetBalanceAfterClose: sdk.NewUint(100000000000000), poolNativeAssetBalanceAfterOpen: sdk.NewUint(110000), poolExternalAssetBalanceAfterOpen: sdk.NewUint(69), poolHealthAfterOpen: sdk.NewDecWithPrec(1000000000000000000, 18), - poolNativeAssetBalanceAfterClose: sdk.NewUint(19680), + poolNativeAssetBalanceAfterClose: sdk.NewUint(14823), poolExternalAssetBalanceAfterClose: sdk.NewUint(100), poolHealthAfterClose: sdk.NewDecWithPrec(1000000000000000000, 18), mtpCustodyAmount: sdk.NewUint(87), @@ -2013,7 +2012,7 @@ func TestKeeper_AddUpExistingMTP(t *testing.T) { InterestPaidCustody: sdk.ZeroUint(), InterestUnpaidCollateral: sdk.ZeroUint(), CustodyAsset: externalAsset.Symbol, - CustodyAmount: sdk.NewUintFromString("999800029996000499940"), + CustodyAmount: sdk.NewUintFromString("996900309969003099690"), Leverage: sdk.NewDec(1), MtpHealth: sdk.ZeroDec(), Position: types.Position_LONG, @@ -2047,7 +2046,7 @@ func TestKeeper_AddUpExistingMTP(t *testing.T) { InterestPaidCustody: sdk.ZeroUint(), InterestUnpaidCollateral: sdk.ZeroUint(), CustodyAsset: externalAsset.Symbol, - CustodyAmount: sdk.NewUintFromString("999800029996000499940"), + CustodyAmount: sdk.NewUintFromString("996900309969003099690"), Leverage: sdk.NewDec(1), MtpHealth: sdk.ZeroDec(), Position: types.Position_LONG, @@ -2067,7 +2066,7 @@ func TestKeeper_AddUpExistingMTP(t *testing.T) { InterestPaidCustody: sdk.ZeroUint(), InterestUnpaidCollateral: sdk.ZeroUint(), CustodyAsset: externalAsset.Symbol, - CustodyAmount: sdk.NewUintFromString("499850038741251802776"), + CustodyAmount: sdk.NewUintFromString("498375548187319947203"), Leverage: sdk.NewDec(1), MtpHealth: sdk.ZeroDec(), Position: types.Position_LONG, diff --git a/x/margin/types/expected_keepers.go b/x/margin/types/expected_keepers.go index 10ce8f75ff..02cdd40d3b 100644 --- a/x/margin/types/expected_keepers.go +++ b/x/margin/types/expected_keepers.go @@ -23,7 +23,6 @@ type CLPKeeper interface { GetPools(ctx sdk.Context) []*clptypes.Pool GetPool(ctx sdk.Context, symbol string) (clptypes.Pool, error) SetPool(ctx sdk.Context, pool *clptypes.Pool) error - GetNormalizationFactorFromAsset(ctx sdk.Context, asset clptypes.Asset) (sdk.Dec, bool, error) CLPCalcSwap(ctx sdk.Context, sentAmount sdk.Uint, to clptypes.Asset, pool clptypes.Pool, marginEnabled bool) (sdk.Uint, error) diff --git a/x/tokenregistry/types/msgs.go b/x/tokenregistry/types/msgs.go index 9c8936ae2a..5dffaba8d1 100644 --- a/x/tokenregistry/types/msgs.go +++ b/x/tokenregistry/types/msgs.go @@ -38,8 +38,8 @@ func (m *MsgRegister) ValidateBasic() error { if err != nil { return sdkerrors.Wrap(err, "invalid from address") } - if m.Entry.Decimals <= 0 { - return errors.New("Decimals cannot be zero") + if m.Entry.Decimals < 0 { + return errors.New("Decimals cannot be less than zero") } return nil } @@ -83,8 +83,8 @@ func (m *MsgSetRegistry) ValidateBasic() error { if !coin.IsValid() { return errors.New("Denom is not valid") } - if entry.Decimals <= 0 { - return errors.New("Decimals cannot be zero") + if entry.Decimals < 0 { + return errors.New("Decimals cannot be less than zero") } } @@ -106,6 +106,7 @@ func (m *MsgSetRegistry) GetSigners() []sdk.AccAddress { } return []sdk.AccAddress{addr} } + // MsgDeregister func (m *MsgDeregister) Route() string { diff --git a/x/tokenregistry/types/msgs_test.go b/x/tokenregistry/types/msgs_test.go index 05de8201d8..415d5f33f1 100644 --- a/x/tokenregistry/types/msgs_test.go +++ b/x/tokenregistry/types/msgs_test.go @@ -43,7 +43,7 @@ func TestMsgUpdateWhitelist_ValidateBasic(t *testing.T) { From: admin.String(), Entry: &types.RegistryEntry{ Denom: "TestDenom", - Decimals: 0, + Decimals: -1, }, }, assertion: assert.Error,