diff --git a/docs/proposals/asymmetric-adds.md b/docs/proposals/asymmetric-adds.md index d4069efe45..b1dcd94a37 100644 --- a/docs/proposals/asymmetric-adds.md +++ b/docs/proposals/asymmetric-adds.md @@ -138,6 +138,26 @@ y'' = y + g.(x - x') Since the add liquidity process involves swapping then the Liquidity protection procedure must be applied. +## CLI + +### Get Estimation of pool share + +```bash +sifnoded query clp estimate-pool-share \ + --externalAmount=0 \ + --nativeAmount=1000000000000000000 \ + --symbol ceth \ + --output json +``` + +```json +{ + "percentage": "0.183227703974514619", + "native_asset_amount": "549683111923543857", + "external_asset_amount": "366455407949029238" +} +``` + ## References Detailed derivation of formulas https://hackmd.io/NjvaZY1qQiS17s_uEgZmTw?both diff --git a/docs/tutorials/asymmetric-adds.md b/docs/tutorials/asymmetric-adds.md index 536f940215..f5f79ba917 100644 --- a/docs/tutorials/asymmetric-adds.md +++ b/docs/tutorials/asymmetric-adds.md @@ -67,7 +67,7 @@ returns: } ``` -3. Query akasha balances: +4. Query akasha balances: ```bash sifnoded q bank balances $(sifnoded keys show akasha -a --keyring-backend=test) @@ -76,7 +76,21 @@ sifnoded q bank balances $(sifnoded keys show akasha -a --keyring-backend=test) ceth: 500000000000000000000000 rowan: 500000000000000000000000 -3. Add liquidity asymmetrically from akasha account to the ceth pool +5. Query pool share estimation: + +``` +sifnoded query clp estimate-pool-share --externalAmount=0 --nativeAmount=1000000000000000000 --symbol ceth --output json +``` + +```json +{ + "percentage": "0.183227703974514619", + "native_asset_amount": "549683111923543857", + "external_asset_amount": "366455407949029238" +} +``` + +6. Add liquidity asymmetrically from akasha account to the ceth pool ```bash sifnoded tx clp add-liquidity \ @@ -90,7 +104,7 @@ sifnoded tx clp add-liquidity \ -y ``` -4. Query akasha balances: +7. Query akasha balances: ``` sifnoded q bank balances $(sifnoded keys show akasha -a --keyring-backend=test) @@ -100,13 +114,13 @@ ceth: 500000000000000000000000 rowan: 499998900000000000000000 -4. Query ceth lps: +8. Query ceth lps: ```bash sifnoded q clp lplist ceth ``` -4. Remove the liquidity added by akasha in the previous step +9. Remove the liquidity added by akasha in the previous step ```bash sifnoded tx clp remove-liquidity \ @@ -120,7 +134,7 @@ sifnoded tx clp remove-liquidity \ -y ``` -5. Query akasha balances: +10. Query akasha balances: ```bash sifnoded q bank balances $(sifnoded keys show akasha -a --keyring-backend=test) @@ -129,13 +143,43 @@ sifnoded q bank balances $(sifnoded keys show akasha -a --keyring-backend=test) ceth: 500000366455407949029238 rowan: 499999349683111923543856 +# Confirm share estimation calculation + +We'll confirm the pool share estimation in step five was correct. The estimated pool share was given as: + +```json +{ + "percentage": "0.183227703974514619", + "native_asset_amount": "549683111923543857", + "external_asset_amount": "366455407949029238" +} +``` + +Before removing liquidity (but after adding liquidity) akasha's balances were: + +ceth: 500000000000000000000000 +rowan: 499998900000000000000000 + +After removing liquidity akasha's balances were: + +ceth: 500000366455407949029238 +rowan: 499999349683111923543856 + +The gain in ceth after removing liquidity equals, 500000366455407949029238 - 500000000000000000000000 = 366455407949029238. This equals the estimated +external asset amount. + +The gain in rowan after removing liquidity equals, 499999349683111923543856 - 499998900000000000000000 = 449683111923543856. 100000000000000000rowan was spent on tx fees, so if we add this to the difference, 449683111923543856 + 100000000000000000 = 549683111923543856. This equals the estimated +external asset amount. + +# Confirm correct pool accounting + akasha started with 500000000000000000000000rowan and now has 499999349683111923543856rowan. So akasha has 500000000000000000000000rowan - 499999349683111923543856rowan = 650316888076456144rowan less rowan. 200000000000000000rowan was spent on tx fees. So 650316888076456144rowan - 200000000000000000rowan = 450316888076456144rowan was given to the pool by akasha. In return akasha has gained 500000366455407949029238 - 500000000000000000000000 = 366455407949029238ceth from the pool. -6. Check akash's gains/losses are reflected in the pool balances +11. Check akash's gains/losses are reflected in the pool balances ``` sifnoded q clp pool ceth @@ -158,17 +202,19 @@ external_asset_balance = original_balance - amount_gained_by_akasha Which equals the queried external asset pool balance. +# Equivalence with swapping + Has akasha had a "cheap" swap? How much would akasha have if instead of adding and removing from the pool they had simply swapped 450316888076456144rowan for ceth? -7. Reset the chain +12. Reset the chain ```bash make init make run ``` -8. Recreate the ceth pool +13. Recreate the ceth pool ```bash sifnoded tx clp create-pool \ @@ -182,7 +228,7 @@ sifnoded tx clp create-pool \ -y ``` -9. Swap 450316888076456144rowan for ceth from akasha: +14. Swap 450316888076456144rowan for ceth from akasha: ```bash sifnoded tx clp swap \ @@ -197,7 +243,7 @@ sifnoded tx clp swap \ -y ``` -5. Query akasha balances: +15. Query akasha balances: ```bash sifnoded q bank balances $(sifnoded keys show akasha -a --keyring-backend=test) diff --git a/proto/sifnode/clp/v1/querier.proto b/proto/sifnode/clp/v1/querier.proto index 8cf4106d3b..e43971a7a4 100644 --- a/proto/sifnode/clp/v1/querier.proto +++ b/proto/sifnode/clp/v1/querier.proto @@ -56,6 +56,9 @@ service Query { rpc GetSwapFeeParams(SwapFeeParamsReq) returns (SwapFeeParamsRes) { option (google.api.http).get = "/sifchain/clp/v1/swap_fee_rate"; }; + rpc GetPoolShareEstimate(PoolShareEstimateReq) returns (PoolShareEstimateRes) { + option (google.api.http).get = "/sifchain/clp/v1/pool_share_estimate"; + }; } message PoolReq { @@ -201,4 +204,31 @@ message SwapFeeParamsRes { (gogoproto.nullable) = false ]; repeated SwapFeeTokenParams token_params = 2; +} + +message PoolShareEstimateReq { + sifnode.clp.v1.Asset external_asset = 1; + string native_asset_amount = 2 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Uint", + (gogoproto.nullable) = false + ]; + string external_asset_amount = 3 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Uint", + (gogoproto.nullable) = false + ]; +} + +message PoolShareEstimateRes { + string percentage = 1 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + string native_asset_amount = 2 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Uint", + (gogoproto.nullable) = false + ]; + string external_asset_amount = 3 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Uint", + (gogoproto.nullable) = false + ]; } \ No newline at end of file diff --git a/x/clp/client/cli/query.go b/x/clp/client/cli/query.go index a770a656a6..36a5c4ced3 100644 --- a/x/clp/client/cli/query.go +++ b/x/clp/client/cli/query.go @@ -3,15 +3,18 @@ package cli import ( "context" "fmt" + "log" "strings" "github.com/Sifchain/sifnode/x/clp/types" "github.com/cosmos/cosmos-sdk/client/flags" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/version" //"github.com/Sifchain/sifnode/x/clp" "github.com/cosmos/cosmos-sdk/client" "github.com/spf13/cobra" + "github.com/spf13/viper" ) func GetQueryCmd(queryRoute string) *cobra.Command { @@ -36,6 +39,7 @@ func GetQueryCmd(queryRoute string) *cobra.Command { GetCmdLiquidityProtectionParams(queryRoute), GetCmdProviderDistributionParams(queryRoute), GetCmdSwapFeeParams(queryRoute), + GetCmdPoolShareEstimate(queryRoute), ) return clpQueryCmd } @@ -397,3 +401,51 @@ func GetCmdSwapFeeParams(queryRoute string) *cobra.Command { flags.AddQueryFlagsToCmd(cmd) return cmd } + +func GetCmdPoolShareEstimate(queryRoute string) *cobra.Command { + cmd := &cobra.Command{ + Use: "estimate-pool-share", + Short: "Estimate the pool share of an add liquidity action", + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + externalAsset := types.NewAsset(viper.GetString(FlagAssetSymbol)) + externalAmount := viper.GetString(FlagExternalAssetAmount) + nativeAmount := viper.GetString(FlagNativeAssetAmount) + + result, err := queryClient.GetPoolShareEstimate(context.Background(), &types.PoolShareEstimateReq{ + ExternalAsset: &externalAsset, + NativeAssetAmount: sdk.NewUintFromString(nativeAmount), + ExternalAssetAmount: sdk.NewUintFromString(externalAmount), + }) + if err != nil { + return err + } + + return clientCtx.PrintProto(result) + }, + } + + cmd.Flags().AddFlagSet(FsAssetSymbol) + cmd.Flags().AddFlagSet(FsExternalAssetAmount) + cmd.Flags().AddFlagSet(FsNativeAssetAmount) + if err := cmd.MarkFlagRequired(FlagAssetSymbol); err != nil { + log.Println("MarkFlagRequired failed: ", err.Error()) + } + if err := cmd.MarkFlagRequired(FlagExternalAssetAmount); err != nil { + log.Println("MarkFlagRequired failed: ", err.Error()) + } + + if err := cmd.MarkFlagRequired(FlagNativeAssetAmount); err != nil { + log.Println("MarkFlagRequired failed: ", err.Error()) + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/clp/keeper/calculations_test.go b/x/clp/keeper/calculations_test.go index d5a65e176b..b245a63254 100644 --- a/x/clp/keeper/calculations_test.go +++ b/x/clp/keeper/calculations_test.go @@ -1160,135 +1160,183 @@ func TestKeeper_GetLiquidityAddSymmetryType(t *testing.T) { func TestKeeper_CalculatePoolUnits(t *testing.T) { testcases := []struct { - name string - oldPoolUnits sdk.Uint - nativeAssetBalance sdk.Uint - externalAssetBalance sdk.Uint - nativeAssetAmount sdk.Uint - externalAssetAmount sdk.Uint - expectedPoolUnits sdk.Uint - expectedLPunits sdk.Uint - expectedSwapStatus int - expectedSwapAmount sdk.Uint - expectedError error + name string + oldPoolUnits sdk.Uint + nativeAssetBalance sdk.Uint + externalAssetBalance sdk.Uint + nativeAssetAmount sdk.Uint + externalAssetAmount sdk.Uint + sellNativeSwapFeeRate sdk.Dec + buyNativeSwapFeeRate sdk.Dec + expectedPoolUnits sdk.Uint + expectedLPunits sdk.Uint + expectedSwapStatus int + expectedSwapAmount sdk.Uint + expectedError error }{ { - name: "empty pool", - oldPoolUnits: sdk.ZeroUint(), - nativeAssetBalance: sdk.ZeroUint(), - externalAssetBalance: sdk.ZeroUint(), - nativeAssetAmount: sdk.NewUint(100), - externalAssetAmount: sdk.NewUint(90), - expectedPoolUnits: sdk.NewUint(100), - expectedLPunits: sdk.NewUint(100), - expectedSwapStatus: clpkeeper.NoSwap, - }, - { - name: "empty pool - no external asset added", - oldPoolUnits: sdk.ZeroUint(), - nativeAssetBalance: sdk.ZeroUint(), - externalAssetBalance: sdk.ZeroUint(), - nativeAssetAmount: sdk.NewUint(100), - externalAssetAmount: sdk.ZeroUint(), - expectedError: errors.New("amount is invalid"), - }, - { - name: "add nothing", - oldPoolUnits: sdk.NewUint(1000), - nativeAssetBalance: sdk.NewUint(12327), - externalAssetBalance: sdk.NewUint(132233), - nativeAssetAmount: sdk.ZeroUint(), - externalAssetAmount: sdk.ZeroUint(), - expectedPoolUnits: sdk.NewUint(1000), - expectedLPunits: sdk.ZeroUint(), - expectedSwapStatus: clpkeeper.NoSwap, - }, - { - name: "positive symmetry", - oldPoolUnits: sdk.NewUint(7656454334323412), - nativeAssetBalance: sdk.NewUint(16767626535600), - externalAssetBalance: sdk.NewUint(2345454545400), - nativeAssetAmount: sdk.ZeroUint(), - externalAssetAmount: sdk.NewUint(4556664545), - expectedPoolUnits: sdk.NewUint(7663887695258361), - expectedLPunits: sdk.NewUint(7433360934949), - expectedSwapStatus: clpkeeper.BuyNative, - expectedSwapAmount: sdk.NewUint(2277340758), - }, - { - name: "symmetric", - oldPoolUnits: sdk.NewUint(7656454334323412), - nativeAssetBalance: sdk.NewUint(16767626535600), - externalAssetBalance: sdk.NewUint(2345454545400), - nativeAssetAmount: sdk.NewUint(167676265356), - externalAssetAmount: sdk.NewUint(23454545454), - expectedPoolUnits: sdk.NewUint(7733018877666646), - expectedLPunits: sdk.NewUint(76564543343234), - expectedSwapStatus: clpkeeper.NoSwap, - }, - { - name: "negative symmetry - zero external", - oldPoolUnits: sdk.NewUint(7656454334323412), - nativeAssetBalance: sdk.NewUint(16767626535600), - externalAssetBalance: sdk.NewUint(2345454545400), - nativeAssetAmount: sdk.NewUint(167676265356), - externalAssetAmount: sdk.ZeroUint(), - expectedPoolUnits: sdk.NewUint(7694639456903696), - expectedLPunits: sdk.NewUint(38185122580284), - expectedSwapStatus: clpkeeper.SellNative, - expectedSwapAmount: sdk.NewUint(83633781363), - }, - { - name: "positive symmetry - non zero external", - oldPoolUnits: sdk.NewUint(7656454334323412), - nativeAssetBalance: sdk.NewUint(16767626535600), - externalAssetBalance: sdk.NewUint(2345454545400), - nativeAssetAmount: sdk.NewUint(167676265356), - externalAssetAmount: sdk.NewUint(46798998888), - expectedPoolUnits: sdk.NewUint(7771026137435008), - expectedLPunits: sdk.NewUint(114571803111596), - expectedSwapStatus: clpkeeper.BuyNative, - expectedSwapAmount: sdk.NewUint(11528907497), - }, - { - name: "very big - positive symmetry", - oldPoolUnits: sdk.NewUintFromString("1606938044258990275541962092341162602522202993782792835301376"), //2**200 - nativeAssetBalance: sdk.NewUintFromString("1606938044258990275541962092341162602522202993782792835301376"), - externalAssetBalance: sdk.NewUintFromString("1606938044258990275541962092341162602522202993782792835301376"), - nativeAssetAmount: sdk.NewUint(0), - externalAssetAmount: sdk.NewUint(1099511627776), // 2**40 - expectedPoolUnits: sdk.NewUintFromString("1606938044258990275541962092341162602522202993783342563626098"), - expectedLPunits: sdk.NewUint(549728324722), - expectedSwapStatus: clpkeeper.BuyNative, - expectedSwapAmount: sdk.NewUint(549783303053), - }, - { - name: "very big - symmetric", - oldPoolUnits: sdk.NewUintFromString("1606938044258990275541962092341162602522202993782792835301376"), //2**200 - nativeAssetBalance: sdk.NewUintFromString("1606938044258990275541962092341162602522202993782792835301376"), - externalAssetBalance: sdk.NewUintFromString("1606938044258990275541962092341162602522202993782792835301376"), - nativeAssetAmount: sdk.NewUint(1099511627776), // 2**40 - externalAssetAmount: sdk.NewUint(1099511627776), - expectedPoolUnits: sdk.NewUintFromString("1606938044258990275541962092341162602522202993783892346929152"), - expectedLPunits: sdk.NewUint(1099511627776), - expectedSwapStatus: clpkeeper.NoSwap, - }, - { - name: "very big - negative symmetry", - oldPoolUnits: sdk.NewUintFromString("1606938044258990275541962092341162602522202993782792835301376"), //2**200 - nativeAssetBalance: sdk.NewUintFromString("1606938044258990275541962092341162602522202993782792835301376"), - externalAssetBalance: sdk.NewUintFromString("1606938044258990275541962092341162602522202993782792835301376"), - nativeAssetAmount: sdk.NewUint(1099511627776), // 2**40 - externalAssetAmount: sdk.ZeroUint(), - expectedPoolUnits: sdk.NewUintFromString("1606938044258990275541962092341162602522202993783342563626098"), - expectedLPunits: sdk.NewUint(549728324722), - expectedSwapStatus: clpkeeper.SellNative, - expectedSwapAmount: sdk.NewUint(549783303053), + name: "empty pool", + oldPoolUnits: sdk.ZeroUint(), + nativeAssetBalance: sdk.ZeroUint(), + externalAssetBalance: sdk.ZeroUint(), + nativeAssetAmount: sdk.NewUint(100), + externalAssetAmount: sdk.NewUint(90), + sellNativeSwapFeeRate: sdk.NewDecWithPrec(1, 4), + buyNativeSwapFeeRate: sdk.NewDecWithPrec(1, 4), + expectedPoolUnits: sdk.NewUint(100), + expectedLPunits: sdk.NewUint(100), + expectedSwapStatus: clpkeeper.NoSwap, + }, + { + name: "empty pool - no external asset added", + oldPoolUnits: sdk.ZeroUint(), + nativeAssetBalance: sdk.ZeroUint(), + externalAssetBalance: sdk.ZeroUint(), + nativeAssetAmount: sdk.NewUint(100), + sellNativeSwapFeeRate: sdk.NewDecWithPrec(1, 4), + buyNativeSwapFeeRate: sdk.NewDecWithPrec(1, 4), + externalAssetAmount: sdk.ZeroUint(), + expectedError: errors.New("amount is invalid"), + }, + { + name: "add nothing", + oldPoolUnits: sdk.NewUint(1000), + nativeAssetBalance: sdk.NewUint(12327), + externalAssetBalance: sdk.NewUint(132233), + nativeAssetAmount: sdk.ZeroUint(), + externalAssetAmount: sdk.ZeroUint(), + sellNativeSwapFeeRate: sdk.NewDecWithPrec(1, 4), + buyNativeSwapFeeRate: sdk.NewDecWithPrec(1, 4), + expectedPoolUnits: sdk.NewUint(1000), + expectedLPunits: sdk.ZeroUint(), + expectedSwapStatus: clpkeeper.NoSwap, + }, + { + name: "positive symmetry - zero native", + oldPoolUnits: sdk.NewUint(7656454334323412), + nativeAssetBalance: sdk.NewUint(16767626535600), + externalAssetBalance: sdk.NewUint(2345454545400), + nativeAssetAmount: sdk.ZeroUint(), + externalAssetAmount: sdk.NewUint(4556664545), + sellNativeSwapFeeRate: sdk.NewDecWithPrec(1, 4), + buyNativeSwapFeeRate: sdk.NewDecWithPrec(1, 4), + expectedPoolUnits: sdk.NewUint(7663887695258361), + expectedLPunits: sdk.NewUint(7433360934949), + expectedSwapStatus: clpkeeper.BuyNative, + expectedSwapAmount: sdk.NewUint(2277340758), + }, + { + name: "symmetric", + oldPoolUnits: sdk.NewUint(7656454334323412), + nativeAssetBalance: sdk.NewUint(16767626535600), + externalAssetBalance: sdk.NewUint(2345454545400), + nativeAssetAmount: sdk.NewUint(167676265356), + externalAssetAmount: sdk.NewUint(23454545454), + sellNativeSwapFeeRate: sdk.NewDecWithPrec(1, 4), + buyNativeSwapFeeRate: sdk.NewDecWithPrec(1, 4), + expectedPoolUnits: sdk.NewUint(7733018877666646), + expectedLPunits: sdk.NewUint(76564543343234), + expectedSwapStatus: clpkeeper.NoSwap, + }, + { + name: "negative symmetry - zero external", + oldPoolUnits: sdk.NewUint(7656454334323412), + nativeAssetBalance: sdk.NewUint(16767626535600), + externalAssetBalance: sdk.NewUint(2345454545400), + nativeAssetAmount: sdk.NewUint(167676265356), + externalAssetAmount: sdk.ZeroUint(), + sellNativeSwapFeeRate: sdk.NewDecWithPrec(1, 4), + buyNativeSwapFeeRate: sdk.NewDecWithPrec(1, 4), + expectedPoolUnits: sdk.NewUint(7694639456903696), + expectedLPunits: sdk.NewUint(38185122580284), + expectedSwapStatus: clpkeeper.SellNative, + expectedSwapAmount: sdk.NewUint(83633781363), + }, + { + name: "positive symmetry - non zero external", + oldPoolUnits: sdk.NewUint(7656454334323412), + nativeAssetBalance: sdk.NewUint(16767626535600), + externalAssetBalance: sdk.NewUint(2345454545400), + nativeAssetAmount: sdk.NewUint(167676265356), + externalAssetAmount: sdk.NewUint(46798998888), + sellNativeSwapFeeRate: sdk.NewDecWithPrec(1, 4), + buyNativeSwapFeeRate: sdk.NewDecWithPrec(1, 4), + expectedPoolUnits: sdk.NewUint(7771026137435008), + expectedLPunits: sdk.NewUint(114571803111596), + expectedSwapStatus: clpkeeper.BuyNative, + expectedSwapAmount: sdk.NewUint(11528907497), + }, + { + name: "very big - positive symmetry", + oldPoolUnits: sdk.NewUintFromString("1606938044258990275541962092341162602522202993782792835301376"), //2**200 + nativeAssetBalance: sdk.NewUintFromString("1606938044258990275541962092341162602522202993782792835301376"), + externalAssetBalance: sdk.NewUintFromString("1606938044258990275541962092341162602522202993782792835301376"), + nativeAssetAmount: sdk.NewUint(0), + externalAssetAmount: sdk.NewUint(1099511627776), // 2**40 + sellNativeSwapFeeRate: sdk.NewDecWithPrec(1, 4), + buyNativeSwapFeeRate: sdk.NewDecWithPrec(1, 4), + expectedPoolUnits: sdk.NewUintFromString("1606938044258990275541962092341162602522202993783342563626098"), + expectedLPunits: sdk.NewUint(549728324722), + expectedSwapStatus: clpkeeper.BuyNative, + expectedSwapAmount: sdk.NewUint(549783303053), + }, + { + name: "very big - symmetric", + oldPoolUnits: sdk.NewUintFromString("1606938044258990275541962092341162602522202993782792835301376"), //2**200 + nativeAssetBalance: sdk.NewUintFromString("1606938044258990275541962092341162602522202993782792835301376"), + externalAssetBalance: sdk.NewUintFromString("1606938044258990275541962092341162602522202993782792835301376"), + nativeAssetAmount: sdk.NewUint(1099511627776), // 2**40 + externalAssetAmount: sdk.NewUint(1099511627776), + sellNativeSwapFeeRate: sdk.NewDecWithPrec(1, 4), + buyNativeSwapFeeRate: sdk.NewDecWithPrec(1, 4), + expectedPoolUnits: sdk.NewUintFromString("1606938044258990275541962092341162602522202993783892346929152"), + expectedLPunits: sdk.NewUint(1099511627776), + expectedSwapStatus: clpkeeper.NoSwap, + }, + { + name: "very big - negative symmetry", + oldPoolUnits: sdk.NewUintFromString("1606938044258990275541962092341162602522202993782792835301376"), //2**200 + nativeAssetBalance: sdk.NewUintFromString("1606938044258990275541962092341162602522202993782792835301376"), + externalAssetBalance: sdk.NewUintFromString("1606938044258990275541962092341162602522202993782792835301376"), + nativeAssetAmount: sdk.NewUint(1099511627776), // 2**40 + externalAssetAmount: sdk.ZeroUint(), + sellNativeSwapFeeRate: sdk.NewDecWithPrec(1, 4), + buyNativeSwapFeeRate: sdk.NewDecWithPrec(1, 4), + expectedPoolUnits: sdk.NewUintFromString("1606938044258990275541962092341162602522202993783342563626098"), + expectedLPunits: sdk.NewUint(549728324722), + expectedSwapStatus: clpkeeper.SellNative, + expectedSwapAmount: sdk.NewUint(549783303053), + }, + { + name: "swap fee rates = 1, zero external asset", + oldPoolUnits: sdk.NewUint(7656454334323412), + nativeAssetBalance: sdk.NewUint(16767626535600), + externalAssetBalance: sdk.NewUint(2345454545400), + nativeAssetAmount: sdk.NewUint(167676265356), + externalAssetAmount: sdk.ZeroUint(), + sellNativeSwapFeeRate: sdk.OneDec(), + buyNativeSwapFeeRate: sdk.OneDec(), + expectedPoolUnits: sdk.NewUint(7656454334323412), + expectedLPunits: sdk.NewUint(0), + expectedSwapStatus: clpkeeper.SellNative, + expectedSwapAmount: sdk.NewUint(167676265356), + }, + { + name: "swap fee rates = 0, zero external asset", + oldPoolUnits: sdk.NewUint(7656454334323412), + nativeAssetBalance: sdk.NewUint(16767626535600), + externalAssetBalance: sdk.NewUint(2345454545400), + nativeAssetAmount: sdk.NewUint(167676265356), + externalAssetAmount: sdk.ZeroUint(), + sellNativeSwapFeeRate: sdk.ZeroDec(), + buyNativeSwapFeeRate: sdk.ZeroDec(), + expectedPoolUnits: sdk.NewUint(7694641375874505), + expectedLPunits: sdk.NewUint(38187041551093), + expectedSwapStatus: clpkeeper.SellNative, + expectedSwapAmount: sdk.NewUint(83629578818), }, } - sellNativeSwapFeeRate := sdk.NewDecWithPrec(1, 4) - buyNativeSwapFeeRate := sdk.NewDecWithPrec(1, 4) pmtpCurrentRunningRate := sdk.ZeroDec() for _, tc := range testcases { t.Run(tc.name, func(t *testing.T) { @@ -1299,8 +1347,8 @@ func TestKeeper_CalculatePoolUnits(t *testing.T) { tc.externalAssetBalance, tc.nativeAssetAmount, tc.externalAssetAmount, - sellNativeSwapFeeRate, - buyNativeSwapFeeRate, + tc.sellNativeSwapFeeRate, + tc.buyNativeSwapFeeRate, pmtpCurrentRunningRate, ) diff --git a/x/clp/keeper/grpc_query.go b/x/clp/keeper/grpc_query.go index 3818f60a04..ada484c01c 100755 --- a/x/clp/keeper/grpc_query.go +++ b/x/clp/keeper/grpc_query.go @@ -274,3 +274,49 @@ func (k Querier) GetSwapFeeParams(c context.Context, _ *types.SwapFeeParamsReq) return &types.SwapFeeParamsRes{DefaultSwapFeeRate: swapFeeParams.DefaultSwapFeeRate, TokenParams: swapFeeParams.TokenParams}, nil } + +func (k Querier) GetPoolShareEstimate(c context.Context, req *types.PoolShareEstimateReq) (*types.PoolShareEstimateRes, error) { + ctx := sdk.UnwrapSDKContext(c) + + pool, err := k.Keeper.GetPool(ctx, req.ExternalAsset.Symbol) + if err != nil { + return nil, types.ErrPoolDoesNotExist + } + + pmtpCurrentRunningRate := k.Keeper.GetPmtpRateParams(ctx).PmtpCurrentRunningRate + sellNativeSwapFeeRate := k.Keeper.GetSwapFeeRate(ctx, types.GetSettlementAsset(), false) + buyNativeSwapFeeRate := k.Keeper.GetSwapFeeRate(ctx, *req.ExternalAsset, false) + + nativeAssetDepth, externalAssetDepth := pool.ExtractDebt(pool.NativeAssetBalance, pool.ExternalAssetBalance, false) + + newPoolUnits, lpUnits, _, _, err := CalculatePoolUnits( + pool.PoolUnits, + nativeAssetDepth, + externalAssetDepth, + req.NativeAssetAmount, + req.ExternalAssetAmount, + sellNativeSwapFeeRate, + buyNativeSwapFeeRate, + pmtpCurrentRunningRate) + if err != nil { + return nil, err + } + + newPoolUnitsD := sdk.NewDecFromBigInt(newPoolUnits.BigInt()) + lpUnitsD := sdk.NewDecFromBigInt(lpUnits.BigInt()) + + newNativeAssetDepthD := sdk.NewDecFromBigInt(nativeAssetDepth.Add(req.NativeAssetAmount).BigInt()) + newExternalAssetDepthD := sdk.NewDecFromBigInt(externalAssetDepth.Add(req.ExternalAssetAmount).BigInt()) + + percentage := lpUnitsD.Quo(newPoolUnitsD) + + nativeAssetAmountD := percentage.Mul(newNativeAssetDepthD) + externalAssetAmountD := percentage.Mul(newExternalAssetDepthD) + + return &types.PoolShareEstimateRes{ + Percentage: percentage, + NativeAssetAmount: sdk.NewUintFromBigInt(nativeAssetAmountD.TruncateInt().BigInt()), + ExternalAssetAmount: sdk.NewUintFromBigInt(externalAssetAmountD.TruncateInt().BigInt()), + }, nil + +} diff --git a/x/clp/keeper/grpc_query_test.go b/x/clp/keeper/grpc_query_test.go index 437d08785b..3eaea7f00a 100644 --- a/x/clp/keeper/grpc_query_test.go +++ b/x/clp/keeper/grpc_query_test.go @@ -5,8 +5,12 @@ import ( "errors" "testing" + sifapp "github.com/Sifchain/sifnode/app" clpkeeper "github.com/Sifchain/sifnode/x/clp/keeper" + "github.com/Sifchain/sifnode/x/clp/test" "github.com/Sifchain/sifnode/x/clp/types" + tokenregistrytypes "github.com/Sifchain/sifnode/x/tokenregistry/types" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" "github.com/stretchr/testify/require" ) @@ -122,3 +126,116 @@ func TestQuerier_GetLiquidityProviders_ReachedLimit(t *testing.T) { _, err := querier.GetLiquidityProviders(ctx, req) require.Error(t, err, errors.New("rpc error: code = InvalidArgument desc = empty request")) } + +func TestQuerier_GetPoolShareEstimate(t *testing.T) { + testcases := []struct { + name string + createBalance bool + createPool bool + poolAsset string + address string + poolNativeAssetBalance sdk.Uint + poolExternalAssetBalance sdk.Uint + poolNativeLiabilities sdk.Uint + poolExternalLiabilities sdk.Uint + poolUnits sdk.Uint + poolAssetPermissions []tokenregistrytypes.Permission + nativeAssetPermissions []tokenregistrytypes.Permission + RequestNativeAssetAmount sdk.Uint + RequestExternalAssetAmount sdk.Uint + expectedExternalAssetAmount sdk.Uint + expectedNativeAssetAmount sdk.Uint + expectedPercentage sdk.Dec + err error + errString error + }{ + { + name: "symmetric", + createBalance: true, + createPool: true, + poolAsset: "eth", + address: "sif1syavy2npfyt9tcncdtsdzf7kny9lh777yqc2nd", + poolNativeAssetBalance: sdk.NewUint(1000), + poolExternalAssetBalance: sdk.NewUint(1000), + poolUnits: sdk.NewUint(1000), + poolAssetPermissions: []tokenregistrytypes.Permission{tokenregistrytypes.Permission_CLP}, + RequestNativeAssetAmount: sdk.NewUint(200), + RequestExternalAssetAmount: sdk.NewUint(200), + expectedExternalAssetAmount: sdk.NewUint(200), + expectedNativeAssetAmount: sdk.NewUint(200), + expectedPercentage: sdk.MustNewDecFromStr("0.166666666666666667"), + }, + { + name: "asymmetric", + createBalance: true, + createPool: true, + poolAsset: "eth", + address: "sif1syavy2npfyt9tcncdtsdzf7kny9lh777yqc2nd", + poolNativeAssetBalance: sdk.NewUint(1000), + poolExternalAssetBalance: sdk.NewUint(1000), + poolUnits: sdk.NewUint(1000), + poolAssetPermissions: []tokenregistrytypes.Permission{tokenregistrytypes.Permission_CLP}, + RequestNativeAssetAmount: sdk.NewUint(200), + RequestExternalAssetAmount: sdk.ZeroUint(), + expectedExternalAssetAmount: sdk.NewUint(115), + expectedNativeAssetAmount: sdk.NewUint(138), + expectedPercentage: sdk.MustNewDecFromStr("0.115826702033598585"), + }, + } + + for _, tc := range testcases { + tc := tc + t.Run(tc.name, func(t *testing.T) { + ctx, app := test.CreateTestAppClpFromGenesis(false, func(app *sifapp.SifchainApp, genesisState sifapp.GenesisState) sifapp.GenesisState { + trGs := &tokenregistrytypes.GenesisState{ + Registry: &tokenregistrytypes.Registry{ + Entries: []*tokenregistrytypes.RegistryEntry{ + {Denom: tc.poolAsset, BaseDenom: tc.poolAsset, Decimals: 18, Permissions: tc.poolAssetPermissions}, + {Denom: "rowan", BaseDenom: "rowan", Decimals: 18, Permissions: tc.nativeAssetPermissions}, + }, + }, + } + bz, _ := app.AppCodec().MarshalJSON(trGs) + genesisState["tokenregistry"] = bz + + if tc.createPool { + pools := []*types.Pool{ + { + ExternalAsset: &types.Asset{Symbol: tc.poolAsset}, + NativeAssetBalance: tc.poolNativeAssetBalance, + ExternalAssetBalance: tc.poolExternalAssetBalance, + PoolUnits: tc.poolUnits, + NativeLiabilities: tc.poolNativeLiabilities, + ExternalLiabilities: tc.poolExternalLiabilities, + }, + } + clpGs := types.DefaultGenesisState() + clpGs.Params = types.Params{ + MinCreatePoolThreshold: 100, + } + clpGs.AddressWhitelist = append(clpGs.AddressWhitelist, tc.address) + clpGs.PoolList = append(clpGs.PoolList, pools...) + bz, _ = app.AppCodec().MarshalJSON(clpGs) + genesisState["clp"] = bz + } + + return genesisState + }) + + querier := clpkeeper.Querier{app.ClpKeeper} + + req := &types.PoolShareEstimateReq{ + ExternalAsset: &types.Asset{Symbol: tc.poolAsset}, + NativeAssetAmount: tc.RequestNativeAssetAmount, + ExternalAssetAmount: tc.RequestExternalAssetAmount, + } + res, err := querier.GetPoolShareEstimate(sdk.WrapSDKContext(ctx), req) + + require.NoError(t, err) + + require.Equal(t, tc.expectedExternalAssetAmount.String(), res.ExternalAssetAmount.String()) + require.Equal(t, tc.expectedNativeAssetAmount.String(), res.NativeAssetAmount.String()) + require.Equal(t, tc.expectedPercentage.String(), res.Percentage.String()) + }) + } +} diff --git a/x/clp/types/querier.pb.go b/x/clp/types/querier.pb.go index 61d5550ebb..64b9a25dc4 100644 --- a/x/clp/types/querier.pb.go +++ b/x/clp/types/querier.pb.go @@ -1262,6 +1262,91 @@ func (m *SwapFeeParamsRes) GetTokenParams() []*SwapFeeTokenParams { return nil } +type PoolShareEstimateReq struct { + ExternalAsset *Asset `protobuf:"bytes,1,opt,name=external_asset,json=externalAsset,proto3" json:"external_asset,omitempty"` + NativeAssetAmount github_com_cosmos_cosmos_sdk_types.Uint `protobuf:"bytes,2,opt,name=native_asset_amount,json=nativeAssetAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Uint" json:"native_asset_amount"` + ExternalAssetAmount github_com_cosmos_cosmos_sdk_types.Uint `protobuf:"bytes,3,opt,name=external_asset_amount,json=externalAssetAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Uint" json:"external_asset_amount"` +} + +func (m *PoolShareEstimateReq) Reset() { *m = PoolShareEstimateReq{} } +func (m *PoolShareEstimateReq) String() string { return proto.CompactTextString(m) } +func (*PoolShareEstimateReq) ProtoMessage() {} +func (*PoolShareEstimateReq) Descriptor() ([]byte, []int) { + return fileDescriptor_5f4edede314ca3fd, []int{26} +} +func (m *PoolShareEstimateReq) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PoolShareEstimateReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PoolShareEstimateReq.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 *PoolShareEstimateReq) XXX_Merge(src proto.Message) { + xxx_messageInfo_PoolShareEstimateReq.Merge(m, src) +} +func (m *PoolShareEstimateReq) XXX_Size() int { + return m.Size() +} +func (m *PoolShareEstimateReq) XXX_DiscardUnknown() { + xxx_messageInfo_PoolShareEstimateReq.DiscardUnknown(m) +} + +var xxx_messageInfo_PoolShareEstimateReq proto.InternalMessageInfo + +func (m *PoolShareEstimateReq) GetExternalAsset() *Asset { + if m != nil { + return m.ExternalAsset + } + return nil +} + +type PoolShareEstimateRes struct { + Percentage github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,1,opt,name=percentage,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"percentage"` + NativeAssetAmount github_com_cosmos_cosmos_sdk_types.Uint `protobuf:"bytes,2,opt,name=native_asset_amount,json=nativeAssetAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Uint" json:"native_asset_amount"` + ExternalAssetAmount github_com_cosmos_cosmos_sdk_types.Uint `protobuf:"bytes,3,opt,name=external_asset_amount,json=externalAssetAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Uint" json:"external_asset_amount"` +} + +func (m *PoolShareEstimateRes) Reset() { *m = PoolShareEstimateRes{} } +func (m *PoolShareEstimateRes) String() string { return proto.CompactTextString(m) } +func (*PoolShareEstimateRes) ProtoMessage() {} +func (*PoolShareEstimateRes) Descriptor() ([]byte, []int) { + return fileDescriptor_5f4edede314ca3fd, []int{27} +} +func (m *PoolShareEstimateRes) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PoolShareEstimateRes) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PoolShareEstimateRes.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 *PoolShareEstimateRes) XXX_Merge(src proto.Message) { + xxx_messageInfo_PoolShareEstimateRes.Merge(m, src) +} +func (m *PoolShareEstimateRes) XXX_Size() int { + return m.Size() +} +func (m *PoolShareEstimateRes) XXX_DiscardUnknown() { + xxx_messageInfo_PoolShareEstimateRes.DiscardUnknown(m) +} + +var xxx_messageInfo_PoolShareEstimateRes proto.InternalMessageInfo + func init() { proto.RegisterType((*PoolReq)(nil), "sifnode.clp.v1.PoolReq") proto.RegisterType((*PoolRes)(nil), "sifnode.clp.v1.PoolRes") @@ -1289,102 +1374,112 @@ func init() { proto.RegisterType((*ProviderDistributionParamsRes)(nil), "sifnode.clp.v1.ProviderDistributionParamsRes") proto.RegisterType((*SwapFeeParamsReq)(nil), "sifnode.clp.v1.SwapFeeParamsReq") proto.RegisterType((*SwapFeeParamsRes)(nil), "sifnode.clp.v1.SwapFeeParamsRes") + proto.RegisterType((*PoolShareEstimateReq)(nil), "sifnode.clp.v1.PoolShareEstimateReq") + proto.RegisterType((*PoolShareEstimateRes)(nil), "sifnode.clp.v1.PoolShareEstimateRes") } func init() { proto.RegisterFile("sifnode/clp/v1/querier.proto", fileDescriptor_5f4edede314ca3fd) } var fileDescriptor_5f4edede314ca3fd = []byte{ - // 1435 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x58, 0xcd, 0x6f, 0x1b, 0x45, - 0x14, 0xcf, 0x26, 0x6d, 0xda, 0x4c, 0xfa, 0x91, 0x3e, 0x92, 0xd4, 0x5d, 0x1c, 0x3b, 0xac, 0x4a, - 0x1a, 0x42, 0xb2, 0xdb, 0xf4, 0x43, 0x50, 0x10, 0x87, 0x44, 0x6d, 0xcd, 0xa1, 0xa0, 0xb0, 0xad, - 0x84, 0x84, 0x54, 0xac, 0xf5, 0x7a, 0x62, 0xaf, 0xba, 0xf6, 0x7e, 0xcc, 0x38, 0xad, 0x55, 0x0a, - 0x12, 0xea, 0x01, 0x89, 0x0b, 0x52, 0xef, 0xa8, 0x07, 0x38, 0x70, 0x40, 0xe2, 0xc0, 0x91, 0x2b, - 0x52, 0x91, 0x90, 0xa8, 0xc4, 0x05, 0x38, 0x14, 0xd4, 0x72, 0xe8, 0x9f, 0x81, 0x66, 0x76, 0xd6, - 0xeb, 0xfd, 0xb2, 0x9d, 0x28, 0x02, 0x71, 0xb2, 0x77, 0xde, 0x6f, 0xde, 0xfb, 0xbd, 0xdf, 0xbc, - 0x9d, 0xf7, 0x6c, 0x54, 0x24, 0xd6, 0x76, 0xdb, 0xa9, 0x63, 0xcd, 0xb4, 0x5d, 0x6d, 0x67, 0x5d, - 0xf3, 0x3a, 0xd8, 0xb7, 0xb0, 0xaf, 0xba, 0xbe, 0x43, 0x1d, 0x38, 0x26, 0xac, 0xaa, 0x69, 0xbb, - 0xea, 0xce, 0xba, 0x3c, 0xdb, 0x70, 0x1a, 0x0e, 0x37, 0x69, 0xec, 0x5b, 0x80, 0x92, 0xe5, 0x84, - 0x0f, 0xda, 0x75, 0x31, 0x11, 0xb6, 0x17, 0x13, 0x36, 0xd7, 0xf0, 0x8d, 0x56, 0x68, 0x5c, 0x31, - 0x1d, 0xd2, 0x72, 0x88, 0x56, 0x33, 0x08, 0xe6, 0x91, 0xbb, 0xda, 0xce, 0x7a, 0x0d, 0x53, 0x83, - 0xe1, 0x1a, 0x56, 0xdb, 0xa0, 0x96, 0xd3, 0x16, 0xd8, 0x62, 0xc3, 0x71, 0x1a, 0x36, 0xd6, 0x0c, - 0xd7, 0xd2, 0x8c, 0x76, 0xdb, 0xa1, 0xdc, 0x28, 0x3c, 0x29, 0xaf, 0xa2, 0x43, 0x5b, 0x8e, 0x63, - 0xeb, 0xd8, 0x83, 0x79, 0x34, 0x49, 0xba, 0xad, 0x9a, 0x63, 0x17, 0xa4, 0x45, 0x69, 0x79, 0x4a, - 0x17, 0x4f, 0x6f, 0x1c, 0xfe, 0xec, 0x61, 0x79, 0xec, 0xf9, 0xc3, 0xf2, 0x98, 0xd2, 0x0d, 0xc1, - 0x04, 0x96, 0xd1, 0x01, 0xd7, 0x11, 0xd0, 0xe9, 0x73, 0xb3, 0x6a, 0x3c, 0x5f, 0x95, 0xc3, 0x38, - 0x02, 0x56, 0x11, 0x98, 0xb6, 0x5b, 0x6d, 0x39, 0xf5, 0x8e, 0x8d, 0xab, 0x46, 0xbd, 0xee, 0x63, - 0x42, 0x0a, 0xe3, 0x3c, 0xc4, 0x8c, 0x69, 0xbb, 0xef, 0x70, 0xc3, 0x46, 0xb0, 0xce, 0x48, 0x34, - 0xb1, 0xd5, 0x68, 0xd2, 0xc2, 0xc4, 0xa2, 0xb4, 0x3c, 0xa1, 0x8b, 0x27, 0x45, 0x47, 0x87, 0x99, - 0x4f, 0xc2, 0x88, 0x5e, 0x45, 0x28, 0xca, 0x52, 0x30, 0x58, 0x52, 0x03, 0x49, 0x54, 0x26, 0x89, - 0xca, 0x25, 0x51, 0x85, 0x24, 0xea, 0x96, 0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, 0xd8, 0x93, 0x47, 0x41, 0x11, 0x65, 0x83, 0x93, 0x78, 0x13, 0x2e, 0xa5, 0x48, 0xa4, 0xfb, - 0x54, 0x2f, 0x75, 0xed, 0x6e, 0x34, 0xef, 0xdd, 0x83, 0x6f, 0x25, 0x54, 0xc8, 0xe2, 0xc9, 0xc7, - 0xa5, 0xe5, 0xd1, 0x86, 0x2d, 0xec, 0xc9, 0xa3, 0x22, 0x89, 0xf2, 0x16, 0xe7, 0xfc, 0x1a, 0x5c, - 0x1c, 0x81, 0x33, 0x1f, 0xfc, 0xe2, 0x7c, 0x3f, 0x42, 0x47, 0x2a, 0x98, 0xf6, 0xc6, 0x6d, 0x28, - 0x66, 0xce, 0xd6, 0x62, 0xe4, 0x92, 0x07, 0x59, 0x89, 0x72, 0x96, 0x53, 0x59, 0x81, 0xe5, 0x14, - 0x95, 0xe0, 0x57, 0x89, 0x6d, 0x11, 0x1a, 0x8f, 0xfe, 0x40, 0x42, 0x73, 0x59, 0x6a, 0x11, 0x18, - 0x3e, 0x97, 0xf2, 0x82, 0x1a, 0x09, 0x46, 0x94, 0x55, 0xce, 0x6c, 0x09, 0x4e, 0x8f, 0x20, 0x12, - 0x81, 0x6f, 0x72, 0xce, 0x90, 0x0b, 0x34, 0xfc, 0x64, 0x42, 0xb1, 0x46, 0x45, 0x12, 0xe5, 0x12, - 0xa7, 0x77, 0x1e, 0xd6, 0x47, 0x39, 0xc3, 0x40, 0xc5, 0xf0, 0xbd, 0xab, 0xa1, 0x29, 0xf6, 0xde, - 0x05, 0x97, 0xec, 0xa9, 0x9c, 0x81, 0x03, 0x7b, 0x72, 0xae, 0x89, 0x28, 0x65, 0x1e, 0xfd, 0x14, - 0x9c, 0x4c, 0xbf, 0x7a, 0x81, 0xdb, 0xbb, 0xe8, 0x78, 0x05, 0xd3, 0xfe, 0xee, 0x0c, 0xe5, 0x81, - 0xbd, 0x1b, 0x7b, 0xf2, 0x10, 0xc0, 0xa0, 0x8b, 0xc5, 0xe7, 0x48, 0x71, 0xfd, 0x01, 0x41, 0x47, - 0x59, 0x82, 0xbd, 0x0e, 0x0e, 0x0b, 0x03, 0xba, 0x3b, 0xf6, 0xe4, 0x81, 0x66, 0xa2, 0x9c, 0xe6, - 0x61, 0x4b, 0x50, 0x4c, 0x27, 0xcb, 0x9a, 0xb8, 0x08, 0xfa, 0x9d, 0x84, 0x8a, 0x89, 0x0a, 0x88, - 0xb5, 0x49, 0x58, 0x1d, 0xbd, 0xa3, 0x62, 0x4f, 0xde, 0x0d, 0x9a, 0x28, 0x17, 0x38, 0x45, 0x15, - 0x56, 0x07, 0x57, 0x83, 0xd8, 0x17, 0x52, 0xfe, 0x5e, 0x42, 0x0b, 0x4c, 0xa8, 0xdc, 0x66, 0x07, - 0x6b, 0xbb, 0x68, 0x8c, 0xd8, 0x93, 0x77, 0x05, 0x27, 0xca, 0x45, 0xce, 0x5a, 0x83, 0xb5, 0xb4, - 0xb0, 0xbd, 0xdb, 0xa7, 0x6f, 0x63, 0x48, 0xfb, 0x63, 0x34, 0x53, 0xc1, 0x34, 0xd6, 0x67, 0x61, - 0x31, 0xa7, 0xd7, 0x45, 0xdc, 0x86, 0x21, 0x06, 0x95, 0x57, 0xac, 0x6f, 0x6f, 0x6e, 0x3c, 0x7a, - 0x5a, 0x92, 0x1e, 0x3f, 0x2d, 0x49, 0x7f, 0x3d, 0x2d, 0x49, 0x5f, 0x3c, 0x2b, 0x8d, 0x3d, 0x7e, - 0x56, 0x1a, 0xfb, 0xed, 0x59, 0x69, 0xec, 0x83, 0x33, 0x7d, 0x3d, 0xfc, 0x7a, 0xe8, 0x23, 0xfc, - 0x2b, 0xf2, 0x0e, 0xf7, 0xc6, 0x1b, 0x79, 0x6d, 0x92, 0xff, 0x7f, 0x78, 0xfe, 0x9f, 0x00, 0x00, - 0x00, 0xff, 0xff, 0x9e, 0xf8, 0x43, 0x25, 0x08, 0x15, 0x00, 0x00, + // 1567 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x58, 0xcd, 0x6f, 0x1b, 0xc5, + 0x1b, 0xce, 0x26, 0x6d, 0xda, 0x4c, 0xda, 0x26, 0x79, 0x9b, 0xa4, 0xee, 0xfe, 0x12, 0x27, 0xbf, + 0x55, 0x49, 0x43, 0x48, 0x76, 0x9b, 0x7e, 0x08, 0xca, 0xc7, 0x21, 0x51, 0x5b, 0x73, 0x28, 0x28, + 0x6c, 0x8b, 0x90, 0x90, 0x8a, 0x35, 0x5e, 0x4f, 0xec, 0x55, 0xd7, 0xde, 0xf5, 0xce, 0x38, 0xad, + 0x55, 0x0a, 0x12, 0xea, 0x01, 0x89, 0x4b, 0xa5, 0xde, 0x38, 0xa0, 0x5e, 0x38, 0x20, 0x81, 0xc4, + 0x01, 0x89, 0x0b, 0x57, 0xa4, 0x22, 0x21, 0x51, 0x89, 0x0b, 0x70, 0x28, 0xa8, 0xe5, 0xd0, 0x3f, + 0x03, 0xcd, 0xec, 0xac, 0xed, 0xfd, 0xb2, 0x9d, 0xa8, 0x02, 0xc1, 0x29, 0xd9, 0x79, 0x9f, 0x79, + 0x3f, 0x9e, 0x79, 0x67, 0xe6, 0x19, 0xa3, 0x39, 0x6a, 0x6f, 0xd7, 0xdd, 0x32, 0x31, 0x2c, 0xc7, + 0x33, 0x76, 0xd6, 0x8d, 0x46, 0x93, 0xf8, 0x36, 0xf1, 0x75, 0xcf, 0x77, 0x99, 0x0b, 0x47, 0xa4, + 0x55, 0xb7, 0x1c, 0x4f, 0xdf, 0x59, 0x57, 0xa7, 0x2b, 0x6e, 0xc5, 0x15, 0x26, 0x83, 0xff, 0x17, + 0xa0, 0x54, 0x35, 0xe6, 0x83, 0xb5, 0x3c, 0x42, 0xa5, 0xed, 0x7f, 0x31, 0x9b, 0x87, 0x7d, 0x5c, + 0x0b, 0x8d, 0x2b, 0x96, 0x4b, 0x6b, 0x2e, 0x35, 0x4a, 0x98, 0x12, 0x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11, 0x54, 0x51, 0xae, + 0xed, 0xde, 0xe7, 0xc9, 0x77, 0x05, 0x19, 0xd9, 0x53, 0x90, 0xd9, 0xd0, 0x9f, 0xc9, 0xdd, 0xb5, + 0x23, 0x69, 0x53, 0x68, 0xc2, 0x24, 0x37, 0xb0, 0x5f, 0xee, 0x30, 0x53, 0x88, 0x0f, 0x51, 0x38, + 0x1b, 0xa3, 0x67, 0x2e, 0x4e, 0x4f, 0x64, 0x82, 0xc4, 0x6a, 0x13, 0xe8, 0xf0, 0x56, 0x8d, 0x79, + 0x1d, 0xcf, 0xbf, 0x2b, 0xd1, 0x11, 0x0a, 0xa7, 0x63, 0x8e, 0xd5, 0x04, 0xef, 0x1d, 0x78, 0xc8, + 0xfd, 0xeb, 0x68, 0xd2, 0xab, 0x31, 0x8f, 0x13, 0x43, 0x8a, 0x72, 0x76, 0xd0, 0xed, 0xf9, 0xb4, + 0xd9, 0x26, 0x66, 0x44, 0x7a, 0x38, 0xe2, 0x45, 0xbe, 0xe1, 0x25, 0x84, 0x84, 0x27, 0xe2, 0xb9, + 0x56, 0x55, 0x76, 0xd6, 0xf1, 0x34, 0x1f, 0x17, 0x39, 0xc0, 0x1c, 0xf3, 0xc2, 0x7f, 0x33, 0x6f, + 0xe0, 0x3c, 0x9a, 0xeb, 0x6e, 0x76, 0x46, 0x2c, 0xde, 0x79, 0x1d, 0x06, 0x7e, 0x50, 0x7a, 0x02, + 0x28, 0x6c, 0xc4, 0x08, 0x79, 0xbe, 0xd7, 0x5e, 0x8a, 0xce, 0x0e, 0xf9, 0x79, 0x13, 0x8d, 0x27, + 0xa9, 0x59, 0x1b, 0xc0, 0x4f, 0x17, 0x53, 0xc8, 0xef, 0xb0, 0x94, 0xa5, 0x66, 0x17, 0xd0, 0x7c, + 0xfb, 0x46, 0xb1, 0x29, 0xf3, 0xed, 0x52, 0x33, 0x5a, 0xac, 0xd5, 0x1b, 0x40, 0x61, 0x33, 0x56, + 0xec, 0x4a, 0x82, 0xfb, 0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 0xcc, 0xd0, 0x4d, 0x9d, 0xdc, + 0xfa, 0x21, 0x7a, 0xb5, 0x57, 0x44, 0x03, 0xc2, 0xdd, 0xe0, 0x5e, 0x49, 0x08, 0x8b, 0xe4, 0xbd, + 0x92, 0x26, 0xcc, 0xd4, 0x41, 0x50, 0xbd, 0x8e, 0x1f, 0x7e, 0xb9, 0x15, 0x29, 0xc7, 0x17, 0x89, + 0x9c, 0xb0, 0xb9, 0xf1, 0xe0, 0x71, 0x5e, 0x79, 0xf8, 0x38, 0xaf, 0xfc, 0xf1, 0x38, 0xaf, 0xdc, + 0x7d, 0x92, 0x1f, 0x7a, 0xf8, 0x24, 0x3f, 0xf4, 0xcb, 0x93, 0xfc, 0xd0, 0xbb, 0xdd, 0x8a, 0xe0, + 0x4a, 0xe8, 0x29, 0xfc, 0xa5, 0xfd, 0xa6, 0xf0, 0x29, 0x64, 0x41, 0x69, 0x54, 0xfc, 0x3c, 0x7e, + 0xe6, 0xaf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x59, 0xf3, 0x98, 0x25, 0xe7, 0x17, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1412,6 +1507,7 @@ type QueryClient interface { GetLiquidityProtectionParams(ctx context.Context, in *LiquidityProtectionParamsReq, opts ...grpc.CallOption) (*LiquidityProtectionParamsRes, error) GetProviderDistributionParams(ctx context.Context, in *ProviderDistributionParamsReq, opts ...grpc.CallOption) (*ProviderDistributionParamsRes, error) GetSwapFeeParams(ctx context.Context, in *SwapFeeParamsReq, opts ...grpc.CallOption) (*SwapFeeParamsRes, error) + GetPoolShareEstimate(ctx context.Context, in *PoolShareEstimateReq, opts ...grpc.CallOption) (*PoolShareEstimateRes, error) } type queryClient struct { @@ -1539,6 +1635,15 @@ func (c *queryClient) GetSwapFeeParams(ctx context.Context, in *SwapFeeParamsReq return out, nil } +func (c *queryClient) GetPoolShareEstimate(ctx context.Context, in *PoolShareEstimateReq, opts ...grpc.CallOption) (*PoolShareEstimateRes, error) { + out := new(PoolShareEstimateRes) + err := c.cc.Invoke(ctx, "/sifnode.clp.v1.Query/GetPoolShareEstimate", 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) @@ -1554,6 +1659,7 @@ type QueryServer interface { GetLiquidityProtectionParams(context.Context, *LiquidityProtectionParamsReq) (*LiquidityProtectionParamsRes, error) GetProviderDistributionParams(context.Context, *ProviderDistributionParamsReq) (*ProviderDistributionParamsRes, error) GetSwapFeeParams(context.Context, *SwapFeeParamsReq) (*SwapFeeParamsRes, error) + GetPoolShareEstimate(context.Context, *PoolShareEstimateReq) (*PoolShareEstimateRes, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -1599,6 +1705,9 @@ func (*UnimplementedQueryServer) GetProviderDistributionParams(ctx context.Conte func (*UnimplementedQueryServer) GetSwapFeeParams(ctx context.Context, req *SwapFeeParamsReq) (*SwapFeeParamsRes, error) { return nil, status.Errorf(codes.Unimplemented, "method GetSwapFeeParams not implemented") } +func (*UnimplementedQueryServer) GetPoolShareEstimate(ctx context.Context, req *PoolShareEstimateReq) (*PoolShareEstimateRes, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetPoolShareEstimate not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -1838,6 +1947,24 @@ func _Query_GetSwapFeeParams_Handler(srv interface{}, ctx context.Context, dec f return interceptor(ctx, in, info, handler) } +func _Query_GetPoolShareEstimate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(PoolShareEstimateReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).GetPoolShareEstimate(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/sifnode.clp.v1.Query/GetPoolShareEstimate", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).GetPoolShareEstimate(ctx, req.(*PoolShareEstimateReq)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "sifnode.clp.v1.Query", HandlerType: (*QueryServer)(nil), @@ -1894,6 +2021,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "GetSwapFeeParams", Handler: _Query_GetSwapFeeParams_Handler, }, + { + MethodName: "GetPoolShareEstimate", + Handler: _Query_GetPoolShareEstimate_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "sifnode/clp/v1/querier.proto", @@ -2966,6 +3097,114 @@ func (m *SwapFeeParamsRes) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *PoolShareEstimateReq) 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 *PoolShareEstimateReq) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PoolShareEstimateReq) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.ExternalAssetAmount.Size() + i -= size + if _, err := m.ExternalAssetAmount.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintQuerier(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + { + size := m.NativeAssetAmount.Size() + i -= size + if _, err := m.NativeAssetAmount.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintQuerier(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if m.ExternalAsset != nil { + { + size, err := m.ExternalAsset.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuerier(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *PoolShareEstimateRes) 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 *PoolShareEstimateRes) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PoolShareEstimateRes) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.ExternalAssetAmount.Size() + i -= size + if _, err := m.ExternalAssetAmount.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintQuerier(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + { + size := m.NativeAssetAmount.Size() + i -= size + if _, err := m.NativeAssetAmount.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintQuerier(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + { + size := m.Percentage.Size() + i -= size + if _, err := m.Percentage.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 @@ -3400,6 +3639,38 @@ func (m *SwapFeeParamsRes) Size() (n int) { return n } +func (m *PoolShareEstimateReq) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ExternalAsset != nil { + l = m.ExternalAsset.Size() + n += 1 + l + sovQuerier(uint64(l)) + } + l = m.NativeAssetAmount.Size() + n += 1 + l + sovQuerier(uint64(l)) + l = m.ExternalAssetAmount.Size() + n += 1 + l + sovQuerier(uint64(l)) + return n +} + +func (m *PoolShareEstimateRes) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Percentage.Size() + n += 1 + l + sovQuerier(uint64(l)) + l = m.NativeAssetAmount.Size() + n += 1 + l + sovQuerier(uint64(l)) + l = m.ExternalAssetAmount.Size() + n += 1 + l + sovQuerier(uint64(l)) + return n +} + func sovQuerier(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -6223,6 +6494,312 @@ func (m *SwapFeeParamsRes) Unmarshal(dAtA []byte) error { } return nil } +func (m *PoolShareEstimateReq) 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: PoolShareEstimateReq: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PoolShareEstimateReq: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ExternalAsset", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuerier + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuerier + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuerier + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.ExternalAsset == nil { + m.ExternalAsset = &Asset{} + } + if err := m.ExternalAsset.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NativeAssetAmount", 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.NativeAssetAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ExternalAssetAmount", 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.ExternalAssetAmount.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 (m *PoolShareEstimateRes) 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: PoolShareEstimateRes: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PoolShareEstimateRes: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Percentage", 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.Percentage.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NativeAssetAmount", 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.NativeAssetAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ExternalAssetAmount", 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.ExternalAssetAmount.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 cd072fcebe..57fd4bb03c 100644 --- a/x/clp/types/querier.pb.gw.go +++ b/x/clp/types/querier.pb.gw.go @@ -557,6 +557,42 @@ func local_request_Query_GetSwapFeeParams_0(ctx context.Context, marshaler runti } +var ( + filter_Query_GetPoolShareEstimate_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Query_GetPoolShareEstimate_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq PoolShareEstimateReq + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_GetPoolShareEstimate_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.GetPoolShareEstimate(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_GetPoolShareEstimate_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq PoolShareEstimateReq + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_GetPoolShareEstimate_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.GetPoolShareEstimate(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. @@ -823,6 +859,26 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_GetPoolShareEstimate_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_GetPoolShareEstimate_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_GetPoolShareEstimate_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -1124,6 +1180,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_GetPoolShareEstimate_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_GetPoolShareEstimate_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_GetPoolShareEstimate_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -1153,6 +1229,8 @@ var ( 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_GetSwapFeeParams_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))) + + pattern_Query_GetPoolShareEstimate_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"sifchain", "clp", "v1", "pool_share_estimate"}, "", runtime.AssumeColonVerbOpt(true))) ) var ( @@ -1181,4 +1259,6 @@ var ( forward_Query_GetProviderDistributionParams_0 = runtime.ForwardResponseMessage forward_Query_GetSwapFeeParams_0 = runtime.ForwardResponseMessage + + forward_Query_GetPoolShareEstimate_0 = runtime.ForwardResponseMessage )