diff --git a/.github/labeler.yml b/.github/labeler.yml index 077b143a..ac186236 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -6,6 +6,8 @@ - x/liquidity/**/* "x/liquidstaking": - x/liquidstaking/**/* +"x/liquidfarming": + - x/liquidfarming/**/* "x/mint": - x/mint/**/* "x/marketmaker": @@ -19,6 +21,8 @@ - x/liquidstaking/**/* - x/mint/**/* - x/marketmaker/**/* + - x/farm/**/* + - x/liquidfarming/**/* - docs/**/* - Makefile "documentation": @@ -28,4 +32,4 @@ - scripts/* "ci": - buf.yaml - - .golangci.yml \ No newline at end of file + - .golangci.yml diff --git a/CHANGELOG.md b/CHANGELOG.md index 94fbdb03..8165e16c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,95 +42,100 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Features -* (x/marketmaker) [\#321](https://github.com/cosmosquad-labs/squad/pull/321) feat: add marketmaker module -* (x/liquidity) [\#339](https://github.com/cosmosquad-labs/squad/pull/339) feat: add market making order type +- (x/marketmaker) [\#321](https://github.com/cosmosquad-labs/squad/pull/321) feat: add marketmaker module +- (x/liquidity) [\#339](https://github.com/cosmosquad-labs/squad/pull/339) feat: add market making order type +- (x/farm) [\#362](https://github.com/cosmosquad-labs/squad/pull/362) feat: add farm module +- (x/liquidfarming) [\#332](https://github.com/cosmosquad-labs/squad/pull/332) feat: add liquidfarming module ### State Machine Breaking -* (ibc) [\#352](https://github.com/cosmosquad-labs/squad/pull/352) fix!: upgrade ibc-go for pool coin blacklisting +- (ibc) [\#352](https://github.com/cosmosquad-labs/squad/pull/352) fix!: upgrade ibc-go for pool coin blacklisting ### Bug Fixes -* (x/liquidstaking) [\#346](https://github.com/cosmosquad-labs/squad/pull/346) fix: calculation bug of liquidstaking voting_power +- (x/liquidstaking) [\#346](https://github.com/cosmosquad-labs/squad/pull/346) fix: calculation bug of liquidstaking voting_power +- (x/liquidity) [\#365](https://github.com/cosmosquad-labs/squad/pull/365) fix: reject same base/quote coin denom in MsgCreatePair ### Improvements -* (x/mint) [\#361](https://github.com/cosmosquad-labs/squad/pull/361) feat: add last block time endpoint +- (x/mint) [\#361](https://github.com/cosmosquad-labs/squad/pull/361) feat: add last block time endpoint ## v2.1.1 ### Improvements -* (x/liquidity) [\#344](https://github.com/cosmosquad-labs/squad/pull/344), [\#341](https://github.com/cosmosquad-labs/squad/pull/341) Enable detailed configuration for order book responses +- (x/liquidity) [\#344](https://github.com/cosmosquad-labs/squad/pull/344), [\#341](https://github.com/cosmosquad-labs/squad/pull/341) Enable detailed configuration for order book responses ### Bug Fixes -* (x/liquidstaking) [\#342](https://github.com/cosmosquad-labs/squad/pull/342) fix: calculation bug of liquidstaking voting_power endpoint + +- (x/liquidstaking) [\#342](https://github.com/cosmosquad-labs/squad/pull/342) fix: calculation bug of liquidstaking voting_power endpoint ## [v2.1.0] - 2022-07-18 ### Client Breaking Changes -* (x/liquidity) [\#338](https://github.com/cosmosquad-labs/squad/pull/338) Refactor `OrderBooks` query: - * `tick_precisions` field has been removed from `QueryOrderBooksRequest` - * `tick_precision` field has been removed from `OrderBookResponse` and `price_unit` has been added instead - * The order between `sells` and `buys` has been changed -* (x/liquidity) [\#335](https://github.com/cosmosquad-labs/squad/pull/335) Modify `PoolResponse`: - * `balances` field has been modified to contain `base_coin` and `quote_coin` fields - * `pool_coin_supply` field has been added - * `price` field has been added -* (x/farming) [\#334](https://github.com/cosmosquad-labs/squad/pull/334) Add `HistoricalRewards` query endpoint: - * `HistoricalRewards`: `/squad/farming/v1beta1/historical_rewards/{staking_coin_denom}` -* (x/liquidity) [\#318](https://github.com/cosmosquad-labs/squad/pull/318) Add `OrderBooks` query endpoint: - * `OrderBooks`: `/squad/liquidity/v1beta1/order_books` -* (x/farming) [\#305](https://github.com/cosmosquad-labs/squad/pull/305) Rename existing `Stakings` endpoint to `Position` and add three new endpoints: - * `Stakings`: `/squad/farming/v1beta1/stakings/{farmer}` - * `QueuedStakings`: `/squad/farming/v1beta1/queued_stakings/{farmer}` - * `UnharvestedRewards`: `/squad/farming/v1beta1/unharvested_reward/{farmer}` +- (x/liquidity) [\#338](https://github.com/cosmosquad-labs/squad/pull/338) Refactor `OrderBooks` query: + - `tick_precisions` field has been removed from `QueryOrderBooksRequest` + - `tick_precision` field has been removed from `OrderBookResponse` and `price_unit` has been added instead + - The order between `sells` and `buys` has been changed +- (x/liquidity) [\#335](https://github.com/cosmosquad-labs/squad/pull/335) Modify `PoolResponse`: + - `balances` field has been modified to contain `base_coin` and `quote_coin` fields + - `pool_coin_supply` field has been added + - `price` field has been added +- (x/farming) [\#334](https://github.com/cosmosquad-labs/squad/pull/334) Add `HistoricalRewards` query endpoint: + - `HistoricalRewards`: `/squad/farming/v1beta1/historical_rewards/{staking_coin_denom}` +- (x/liquidity) [\#318](https://github.com/cosmosquad-labs/squad/pull/318) Add `OrderBooks` query endpoint: + - `OrderBooks`: `/squad/liquidity/v1beta1/order_books` +- (x/farming) [\#305](https://github.com/cosmosquad-labs/squad/pull/305) Rename existing `Stakings` endpoint to `Position` and add three new endpoints: + - `Stakings`: `/squad/farming/v1beta1/stakings/{farmer}` + - `QueuedStakings`: `/squad/farming/v1beta1/queued_stakings/{farmer}` + - `UnharvestedRewards`: `/squad/farming/v1beta1/unharvested_reward/{farmer}` ### CLI Breaking Changes -* (x/liquidity) [\#338](https://github.com/cosmosquad-labs/squad/pull/338) Refactor `order-books` query cmd: - * `[tick-precisions]` argument has been removed: `order-books [pair-ids]` - * Response structure has been changed -* (x/farming) [\#334](https://github.com/cosmosquad-labs/squad/pull/334) Add `historical-rewards` query cmd: - * `historical-rewards [staking-coin-denom]` -* (x/liquidity) [\#318](https://github.com/cosmosquad-labs/squad/pull/318) Add `create-ranged-pool` tx cmd and `order-books` query cmd: - * `create-ranged-pool [pair-id] [deposit-coins] [min-price] [max-price] [initial-price]` - * `order-books [pair-ids] [tick-precisions]` -* (x/farming) [\#305](https://github.com/cosmosquad-labs/squad/pull/305) Rename existing `stakings` query to `position` and add three new queries: - * `stakings [farmer]` - * `queued-stakings [farmer]` - * `unharvested-rewards [farmer]` +- (x/liquidity) [\#338](https://github.com/cosmosquad-labs/squad/pull/338) Refactor `order-books` query cmd: + - `[tick-precisions]` argument has been removed: `order-books [pair-ids]` + - Response structure has been changed +- (x/farming) [\#334](https://github.com/cosmosquad-labs/squad/pull/334) Add `historical-rewards` query cmd: + - `historical-rewards [staking-coin-denom]` +- (x/liquidity) [\#318](https://github.com/cosmosquad-labs/squad/pull/318) Add `create-ranged-pool` tx cmd and `order-books` query cmd: + - `create-ranged-pool [pair-id] [deposit-coins] [min-price] [max-price] [initial-price]` + - `order-books [pair-ids] [tick-precisions]` +- (x/farming) [\#305](https://github.com/cosmosquad-labs/squad/pull/305) Rename existing `stakings` query to `position` and add three new queries: + - `stakings [farmer]` + - `queued-stakings [farmer]` + - `unharvested-rewards [farmer]` ### State Machine Breaking -* (x/liquidity) [\#340](https://github.com/cosmosquad-labs/squad/pull/340) Add `MaxNumActivePoolsPerPair` global constant -* (x/liquidity) [\#318](https://github.com/cosmosquad-labs/squad/pull/318) Change `Pool` struct for ranged pools and refactor matching logic - * Add `type`, `creator`, `min_price` and `max_price` fields to `Pool` struct - * Refactor matching logic both for fairness of matching and efficiency of pool order placement - * Change the liquidity module's `TickPrecisions` param from 3 to 4 -* (x/farming) [\#305](https://github.com/cosmosquad-labs/squad/pull/305) Time-based queued staking and new UnharvestedRewards struct - * Changed/added kv-store keys: - * QueuedStaking: `0x23 | EndTimeLen (1 byte) | sdk.FormatTimeBytes(EndTime) | StakingCoinDenomLen (1 byte) | StakingCoinDenom | FarmerAddr -> ProtocolBuffer(QueuedStaking)` - * QueuedStakingIndex: `0x24 | FarmerAddrLen (1 byte) | FarmerAddr | StakingCoinDenomLen (1 byte) | StakingCoinDenom | sdk.FormatTimeBytes(EndTime) -> nil` - * UnharvestedRewards: `0x34 | FarmerAddrLen (1 byte) | FarmerAddr | StakingCoinDenom -> ProtocolBuffer(UnharvestedRewards)` -* (x/mint, x/budget) [\#316](https://github.com/cosmosquad-labs/squad/pull/316) feat!: add mint pool address for mint module #316 - * Add `params.MintPoolAddress` on the mint module `cre1m3h30wlvsf8llruxtpukdvsy0km2kum8ve5ajd` - * Change Mint Pool from default `cre17xpfvakm2amg962yls6f84z3kell8c5l53s97s` (fee_collector) to `cre1m3h30wlvsf8llruxtpukdvsy0km2kum8ve5ajd` (params.MintPoolAddress) to prevent mixing of inflation and tx fee - * Change the source address of Budgets whose source address is `cre17xpfvakm2amg962yls6f84z3kell8c5l53s97s` to `cre1m3h30wlvsf8llruxtpukdvsy0km2kum8ve5ajd` - * Add Budget to sending staking reward, and community fund to `cre17xpfvakm2amg962yls6f84z3kell8c5l53s97s` from `cre1m3h30wlvsf8llruxtpukdvsy0km2kum8ve5ajd` - -* [\#303](https://github.com/cosmosquad-labs/squad/pull/303) build!: bump cosmos-sdk to v0.45.3, tendermint v0.34.19, ibc-go v2.2.0, budget v1.2.0, go 1.17 +- (x/liquidity) [\#340](https://github.com/cosmosquad-labs/squad/pull/340) Add `MaxNumActivePoolsPerPair` global constant +- (x/liquidity) [\#318](https://github.com/cosmosquad-labs/squad/pull/318) Change `Pool` struct for ranged pools and refactor matching logic + - Add `type`, `creator`, `min_price` and `max_price` fields to `Pool` struct + - Refactor matching logic both for fairness of matching and efficiency of pool order placement + - Change the liquidity module's `TickPrecisions` param from 3 to 4 +- (x/farming) [\#305](https://github.com/cosmosquad-labs/squad/pull/305) Time-based queued staking and new UnharvestedRewards struct + - Changed/added kv-store keys: + - QueuedStaking: `0x23 | EndTimeLen (1 byte) | sdk.FormatTimeBytes(EndTime) | StakingCoinDenomLen (1 byte) | StakingCoinDenom | FarmerAddr -> ProtocolBuffer(QueuedStaking)` + - QueuedStakingIndex: `0x24 | FarmerAddrLen (1 byte) | FarmerAddr | StakingCoinDenomLen (1 byte) | StakingCoinDenom | sdk.FormatTimeBytes(EndTime) -> nil` + - UnharvestedRewards: `0x34 | FarmerAddrLen (1 byte) | FarmerAddr | StakingCoinDenom -> ProtocolBuffer(UnharvestedRewards)` +- (x/mint, x/budget) [\#316](https://github.com/cosmosquad-labs/squad/pull/316) feat!: add mint pool address for mint module #316 + + - Add `params.MintPoolAddress` on the mint module `cre1m3h30wlvsf8llruxtpukdvsy0km2kum8ve5ajd` + - Change Mint Pool from default `cre17xpfvakm2amg962yls6f84z3kell8c5l53s97s` (fee_collector) to `cre1m3h30wlvsf8llruxtpukdvsy0km2kum8ve5ajd` (params.MintPoolAddress) to prevent mixing of inflation and tx fee + - Change the source address of Budgets whose source address is `cre17xpfvakm2amg962yls6f84z3kell8c5l53s97s` to `cre1m3h30wlvsf8llruxtpukdvsy0km2kum8ve5ajd` + - Add Budget to sending staking reward, and community fund to `cre17xpfvakm2amg962yls6f84z3kell8c5l53s97s` from `cre1m3h30wlvsf8llruxtpukdvsy0km2kum8ve5ajd` + +- [\#303](https://github.com/cosmosquad-labs/squad/pull/303) build!: bump cosmos-sdk to v0.45.3, tendermint v0.34.19, ibc-go v2.2.0, budget v1.2.0, go 1.17 ### Improvements -* (x/liquidity) [\#310](https://github.com/cosmosquad-labs/squad/pull/310) feat: add emit events for order trading volume +- (x/liquidity) [\#310](https://github.com/cosmosquad-labs/squad/pull/310) feat: add emit events for order trading volume ### Bug Fixes -* (x/liquidity) [\#296](https://github.com/cosmosquad-labs/squad/pull/296) [\#299](https://github.com/cosmosquad-labs/squad/pull/299) fix: optimize CancelAllOrders gas usage, fix offer coin checking -* (x/claim) [\#292](https://github.com/cosmosquad-labs/squad/pull/292) [\#304](https://github.com/cosmosquad-labs/squad/pull/304) fix: fix simulation for the claim module -* [\#298](https://github.com/cosmosquad-labs/squad/pull/298) fix: fix to use query context +- (x/liquidity) [\#296](https://github.com/cosmosquad-labs/squad/pull/296) [\#299](https://github.com/cosmosquad-labs/squad/pull/299) fix: optimize CancelAllOrders gas usage, fix offer coin checking +- (x/claim) [\#292](https://github.com/cosmosquad-labs/squad/pull/292) [\#304](https://github.com/cosmosquad-labs/squad/pull/304) fix: fix simulation for the claim module +- [\#298](https://github.com/cosmosquad-labs/squad/pull/298) fix: fix to use query context ## [v1.1.0] - 2022-04-18 @@ -138,24 +143,24 @@ Ref: https://keepachangelog.com/en/1.0.0/ Running a full node will encounter wrong app hash issue if it doesn't upgrade to this version prior to `UpgradeHeight (48000)`. Instead of going through on-chain governance proposal by using `UpgradeProposal`, this upgrade mechanism is chosen as it is security hot fix that is better to be fixed as soon as it can and also it is directly related to governance proposal. -* (x/claim) [\#294](https://github.com/cosmosquad-labs/squad/pull/294) Fix gas consumption issue for `ConditionTypeVote`. `UpgradeHeight` is set as `48000`. +- (x/claim) [\#294](https://github.com/cosmosquad-labs/squad/pull/294) Fix gas consumption issue for `ConditionTypeVote`. `UpgradeHeight` is set as `48000`. ## [v1.0.0] - 2022-04-12 ### Features -* (squad) feat: add `x/liquidity` module -* (squad) feat: add `x/liquidstaking` module -* (squad) feat: add `x/farming` module -* (squad) feat: add `x/mint`(constant inflation) module -* (squad) feat: add `x/claim` module -* (sdk) Squad Core uses a customized Cosmos SDK [v1.0.2-sdk-0.44.5](https://github.com/cosmosquad-labs/cosmos-sdk/releases/v1.0.2-sdk-0.44.5). Please check the differences on [here](https://github.com/cosmosquad-labs/cosmos-sdk/compare/v0.44.5...v1.0.2-sdk-0.44.5). - * `x/staking` fix: allow delegate only spendable coins - * `x/gov` feat: add additional voting powers hook on tally (liquid governance) - * `x/vesting` feat: periodic vesting msg - * `x/bank` feat: Add dynamic blockedAddrs - -[Unreleased]: https://github.com/cosmosquad-labs/squad/compare/v2.1.0...HEAD +- (squad) feat: add `x/liquidity` module +- (squad) feat: add `x/liquidstaking` module +- (squad) feat: add `x/farming` module +- (squad) feat: add `x/mint`(constant inflation) module +- (squad) feat: add `x/claim` module +- (sdk) Squad Core uses a customized Cosmos SDK [v1.0.2-sdk-0.44.5](https://github.com/cosmosquad-labs/cosmos-sdk/releases/v1.0.2-sdk-0.44.5). Please check the differences on [here](https://github.com/cosmosquad-labs/cosmos-sdk/compare/v0.44.5...v1.0.2-sdk-0.44.5). + - `x/staking` fix: allow delegate only spendable coins + - `x/gov` feat: add additional voting powers hook on tally (liquid governance) + - `x/vesting` feat: periodic vesting msg + - `x/bank` feat: Add dynamic blockedAddrs + +[unreleased]: https://github.com/cosmosquad-labs/squad/compare/v2.1.0...HEAD [v1.0.0]: https://github.com/cosmosquad-labs/squad/releases/tag/v1.0.0 [v1.1.0]: https://github.com/cosmosquad-labs/squad/releases/tag/v1.1.0 -[v2.1.0]: https://github.com/cosmosquad-labs/squad/releases/tag/v2.1.0 \ No newline at end of file +[v2.1.0]: https://github.com/cosmosquad-labs/squad/releases/tag/v2.1.0 diff --git a/app/app.go b/app/app.go index 55f6cf3b..fccfd887 100644 --- a/app/app.go +++ b/app/app.go @@ -108,6 +108,9 @@ import ( farmingclient "github.com/cosmosquad-labs/squad/v3/x/farming/client" farmingkeeper "github.com/cosmosquad-labs/squad/v3/x/farming/keeper" farmingtypes "github.com/cosmosquad-labs/squad/v3/x/farming/types" + "github.com/cosmosquad-labs/squad/v3/x/liquidfarming" + liquidfarmingkeeper "github.com/cosmosquad-labs/squad/v3/x/liquidfarming/keeper" + liquidfarmingtypes "github.com/cosmosquad-labs/squad/v3/x/liquidfarming/types" "github.com/cosmosquad-labs/squad/v3/x/liquidity" liquiditykeeper "github.com/cosmosquad-labs/squad/v3/x/liquidity/keeper" liquiditytypes "github.com/cosmosquad-labs/squad/v3/x/liquidity/types" @@ -165,6 +168,7 @@ var ( farming.AppModuleBasic{}, liquidity.AppModuleBasic{}, liquidstaking.AppModuleBasic{}, + liquidfarming.AppModuleBasic{}, claim.AppModuleBasic{}, marketmaker.AppModuleBasic{}, farm.AppModuleBasic{}, @@ -182,6 +186,7 @@ var ( farmingtypes.ModuleName: nil, liquiditytypes.ModuleName: {authtypes.Minter, authtypes.Burner}, liquidstakingtypes.ModuleName: {authtypes.Minter, authtypes.Burner}, + liquidfarmingtypes.ModuleName: {authtypes.Minter, authtypes.Burner}, claimtypes.ModuleName: nil, ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner}, marketmakertypes.ModuleName: nil, @@ -232,6 +237,7 @@ type App struct { FarmingKeeper farmingkeeper.Keeper LiquidityKeeper liquiditykeeper.Keeper LiquidStakingKeeper liquidstakingkeeper.Keeper + LiquidFarmingKeeper liquidfarmingkeeper.Keeper ClaimKeeper claimkeeper.Keeper MarketMakerKeeper marketmakerkeeper.Keeper FarmKeeper farmkeeper.Keeper @@ -301,6 +307,7 @@ func NewApp( farmingtypes.StoreKey, liquiditytypes.StoreKey, liquidstakingtypes.StoreKey, + liquidfarmingtypes.StoreKey, claimtypes.StoreKey, marketmakertypes.StoreKey, farmtypes.StoreKey, @@ -495,6 +502,16 @@ func NewApp( app.SlashingKeeper, ) + app.LiquidFarmingKeeper = liquidfarmingkeeper.NewKeeper( + appCodec, + keys[liquidfarmingtypes.StoreKey], + app.GetSubspace(liquidfarmingtypes.ModuleName), + app.AccountKeeper, + app.BankKeeper, + app.FarmKeeper, + app.LiquidityKeeper, + ) + app.GovKeeper = *app.GovKeeper.SetHooks( govtypes.NewMultiGovHooks( app.LiquidStakingKeeper.Hooks(), @@ -569,6 +586,7 @@ func NewApp( liquidity.NewAppModule(appCodec, app.LiquidityKeeper, app.AccountKeeper, app.BankKeeper), farming.NewAppModule(appCodec, app.FarmingKeeper, app.AccountKeeper, app.BankKeeper), liquidstaking.NewAppModule(appCodec, app.LiquidStakingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.GovKeeper), + liquidfarming.NewAppModule(appCodec, app.LiquidFarmingKeeper, app.AccountKeeper, app.BankKeeper), claim.NewAppModule(appCodec, app.ClaimKeeper, app.AccountKeeper, app.BankKeeper, app.DistrKeeper, app.GovKeeper, app.LiquidityKeeper, app.LiquidStakingKeeper), marketmaker.NewAppModule(appCodec, app.MarketMakerKeeper, app.AccountKeeper, app.BankKeeper), farm.NewAppModule(appCodec, app.FarmKeeper, app.AccountKeeper, app.BankKeeper, app.LiquidityKeeper), @@ -590,6 +608,7 @@ func NewApp( stakingtypes.ModuleName, liquidstakingtypes.ModuleName, liquiditytypes.ModuleName, + liquidfarmingtypes.ModuleName, ibchost.ModuleName, farmtypes.ModuleName, @@ -616,6 +635,7 @@ func NewApp( liquiditytypes.ModuleName, farmingtypes.ModuleName, liquidstakingtypes.ModuleName, + liquidfarmingtypes.ModuleName, // empty logic modules capabilitytypes.ModuleName, @@ -663,6 +683,7 @@ func NewApp( farmingtypes.ModuleName, liquiditytypes.ModuleName, liquidstakingtypes.ModuleName, + liquidfarmingtypes.ModuleName, claimtypes.ModuleName, marketmakertypes.ModuleName, farmtypes.ModuleName, @@ -705,6 +726,7 @@ func NewApp( liquidity.NewAppModule(appCodec, app.LiquidityKeeper, app.AccountKeeper, app.BankKeeper), liquidstaking.NewAppModule(appCodec, app.LiquidStakingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.GovKeeper), claim.NewAppModule(appCodec, app.ClaimKeeper, app.AccountKeeper, app.BankKeeper, app.DistrKeeper, app.GovKeeper, app.LiquidityKeeper, app.LiquidStakingKeeper), + liquidfarming.NewAppModule(appCodec, app.LiquidFarmingKeeper, app.AccountKeeper, app.BankKeeper), marketmaker.NewAppModule(appCodec, app.MarketMakerKeeper, app.AccountKeeper, app.BankKeeper), farm.NewAppModule(appCodec, app.FarmKeeper, app.AccountKeeper, app.BankKeeper, app.LiquidityKeeper), ibc.NewAppModule(app.IBCKeeper), @@ -911,6 +933,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino paramsKeeper.Subspace(farmingtypes.ModuleName) paramsKeeper.Subspace(liquiditytypes.ModuleName) paramsKeeper.Subspace(liquidstakingtypes.ModuleName) + paramsKeeper.Subspace(liquidfarmingtypes.ModuleName) paramsKeeper.Subspace(marketmakertypes.ModuleName) paramsKeeper.Subspace(farmtypes.ModuleName) diff --git a/app/app_test.go b/app/app_test.go index 51b29d19..d7997dcc 100644 --- a/app/app_test.go +++ b/app/app_test.go @@ -38,6 +38,7 @@ import ( "github.com/cosmosquad-labs/squad/v3/x/claim" "github.com/cosmosquad-labs/squad/v3/x/farm" "github.com/cosmosquad-labs/squad/v3/x/farming" + "github.com/cosmosquad-labs/squad/v3/x/liquidfarming" "github.com/cosmosquad-labs/squad/v3/x/liquidity" "github.com/cosmosquad-labs/squad/v3/x/liquidstaking" "github.com/cosmosquad-labs/squad/v3/x/marketmaker" @@ -193,6 +194,7 @@ func TestRunMigrations(t *testing.T) { "farming": farming.AppModule{}.ConsensusVersion(), "liquidity": liquidity.AppModule{}.ConsensusVersion(), "liquidstaking": liquidstaking.AppModule{}.ConsensusVersion(), + "liquidfarming": liquidfarming.AppModule{}.ConsensusVersion(), "claim": claim.AppModule{}.ConsensusVersion(), "marketmaker": marketmaker.AppModule{}.ConsensusVersion(), "farm": farm.AppModule{}.ConsensusVersion(), @@ -254,6 +256,7 @@ func TestInitGenesisOnMigration(t *testing.T) { "farming": farming.AppModule{}.ConsensusVersion(), "liquidity": liquidity.AppModule{}.ConsensusVersion(), "liquidstaking": liquidstaking.AppModule{}.ConsensusVersion(), + "liquidfarming": liquidfarming.AppModule{}.ConsensusVersion(), "claim": claim.AppModule{}.ConsensusVersion(), "marketmaker": marketmaker.AppModule{}.ConsensusVersion(), "farm": farm.AppModule{}.ConsensusVersion(), diff --git a/app/params/weights.go b/app/params/weights.go index 628bf0b2..e4dedbf9 100644 --- a/app/params/weights.go +++ b/app/params/weights.go @@ -36,6 +36,11 @@ const ( DefaultWeightMsgClaim int = 50 + DefaultWeightMsgLiquidFarm int = 50 + DefaultWeightMsgLiquidUnfarm int = 10 + DefaultWeightMsgPlaceBid int = 20 + DefaultWeightMsgRefundBid int = 5 + DefaultWeightMsgApplyMarketMaker int = 20 DefaultWeightMsgClaimIncentives int = 10 diff --git a/config-test.yml b/config-test.yml index 74bc5716..138f0b1d 100644 --- a/config-test.yml +++ b/config-test.yml @@ -86,6 +86,14 @@ genesis: whitelisted_validators: - validator_address: "cosmosvaloper1zaavvzxez0elundtn32qnk9lkm8kmcsz8ycjrl" target_weight: "100000000" + liquidfarming: + params: + rewards_auction_duration: "120s" + liquid_farms: + - pool_id: "1" + min_farm_amount: "1" + min_bid_amount: "1" + fee_rate: "0.000000000000000000" claim: airdrops: - id: "1" @@ -107,4 +115,3 @@ genesis: - amount: "3000000000000" denom: "airdrop" claimed_conditions: - liquidstaking: \ No newline at end of file diff --git a/docs/api/liquidfarming.md b/docs/api/liquidfarming.md new file mode 100644 index 00000000..26c7c84b --- /dev/null +++ b/docs/api/liquidfarming.md @@ -0,0 +1,191 @@ +--- +Title: Liquidfarming +Description: A high-level overview of what gRPC-gateway REST routes are supported in the liquidfarming module. +--- + +# Liquidfarming Module + +## Synopsis + +This document provides a high-level overview of what gRPC-gateway REST routes are supported in the `liquidfarming` module. + +## gRPC-gateway REST Routes + + + +++https://github.com/cosmosquad-labs/squad/blob/main/proto/squad/liquidfarming/v1beta1/query.proto + +- [Liquidfarming Module](#liquidfarming-module) + - [Synopsis](#synopsis) + - [gRPC-gateway REST Routes](#grpc-gateway-rest-routes) + - [Params](#params) + - [LiquidFarms](#liquidfarms) + - [LiquidFarm](#liquidfarm) + - [RewardsAuctions](#rewardsauctions) + - [RewardsAuction](#rewardsauction) + - [Bids](#bids) + +## Params + +Example Request + + + +```bash +http://localhost:1317/squad/liquidfarming/v1beta1/params +``` + +Example Response + +```json +{ + "params": { + "liquid_farms": [ + { + "pool_id": "1", + "min_farm_amount": "1", + "min_bid_amount": "1", + "fee_rate": "0.000000000000000000" + } + ], + "rewards_auction_duration": "120s" + } +} +``` + +## LiquidFarms + +Example Request + + + +```bash +http://localhost:1317/squad/liquidfarming/v1beta1/liquidfarms +``` + +Example Response + +```json +{ + "liquid_farms": [ + { + "pool_id": "1", + "liquid_farm_reserve_address": "cosmos1zyyf855slxure4c8dr06p00qjnkem95d2lgv8wgvry2rt437x6tsaf9tcf", + "lf_coin_denom": "lf1", + "min_farm_amount": "1", + "min_bid_amount": "1", + "total_farming_amount": "500000000000" + } + ] +} +``` + +## LiquidFarm + +Example Request + + + +```bash +http://localhost:1317/squad/liquidfarming/v1beta1/liquidfarms/1 +``` + +Example Response + +```json +{ + "liquid_farm": { + "pool_id": "1", + "liquid_farm_reserve_address": "cosmos1zyyf855slxure4c8dr06p00qjnkem95d2lgv8wgvry2rt437x6tsaf9tcf", + "lf_coin_denom": "lf1", + "minimum_farm_amount": "1", + "minimum_bid_amount": "1", + "total_farming_amount": "500000000000" + } +} +``` + +## RewardsAuctions + +Example Request + + + +```bash +http://localhost:1317/squad/liquidfarming/v1beta1/pools/1/rewards_auctions +``` + +Example Response + +```json +{ + "reward_auctions": [ + { + "id": "1", + "pool_id": "1", + "bidding_coin_denom": "pool1", + "paying_reserve_address": "cosmos1h72q3pkvsz537kj08hyv20tun3apampxhpgad97t3ls47nukgtxqeq6eu2", + "start_time": "2022-09-27T06:06:52.627872Z", + "end_time": "2022-09-27T06:08:52.627872Z", + "status": "AUCTION_STATUS_STARTED", + "winner": "", + "rewards": [] + } + ] +} +``` + +## RewardsAuction + +Example Request + + + +```bash +http://localhost:1317/squad/liquidfarming/v1beta1/pools/1/rewards_auctions/1 +``` + +Example Response + +```json +{ + "reward_auction": { + "id": "1", + "pool_id": "1", + "bidding_coin_denom": "pool1", + "paying_reserve_address": "cosmos1h72q3pkvsz537kj08hyv20tun3apampxhpgad97t3ls47nukgtxqeq6eu2", + "start_time": "2022-08-05T08:56:22.237454Z", + "end_time": "2022-08-06T08:56:22.237454Z", + "status": "AUCTION_STATUS_FINISHED", + "winner": "", + "rewards": [] + } +} +``` + +## Bids + +Example Request + + + +```bash +http://localhost:1317/squad/liquidfarming/v1beta1/pools/1/bids +``` + +Example Response + +```json +{ + "bids": [ + { + "pool_id": "1", + "bidder": "cosmos1zaavvzxez0elundtn32qnk9lkm8kmcszzsv80v", + "amount": { + "denom": "pool1", + "amount": "1000000000" + } + } + ] +} +``` diff --git a/docs/api/liquidity.md b/docs/api/liquidity.md index c1fd5cc0..890a8b38 100644 --- a/docs/api/liquidity.md +++ b/docs/api/liquidity.md @@ -14,21 +14,24 @@ This document provides a high-level overview of what gRPC-gateway REST routes ar ++https://github.com/cosmosquad-labs/squad/blob/main/proto/squad/liquidity/v1beta1/query.proto -- [Params](#Params) -- [Pairs](#Pairs) -- [Pair](#Pair) -- [Pools](#Pools) -- [Pool](#Pool) -- [PoolByReserveAddress](#PoolByReserveAddress) -- [PoolByPoolCoinDenom](#PoolByPoolCoinDenom) -- [DepositRequests](#DepositRequests) -- [DepositRequest](#DepositRequest) -- [WithdrawRequests](#WithdrawRequests) -- [WithdrawRequest](#WithdrawRequest) -- [Orders](#Orders) -- [Order](#Order) -- [OrdersByOrderer](#OrdersByOrderer) -- [OrderBooks](#OrderBooks) +- [Liquidity Module](#liquidity-module) + - [Synopsis](#synopsis) + - [gRPC-gateway REST Routes](#grpc-gateway-rest-routes) + - [Params](#params) + - [Pairs](#pairs) + - [Pair](#pair) + - [Pools](#pools) + - [Pool](#pool) + - [PoolByReserveAddress](#poolbyreserveaddress) + - [PoolByPoolCoinDenom](#poolbypoolcoindenom) + - [DepositRequests](#depositrequests) + - [DepositRequest](#depositrequest) + - [WithdrawRequests](#withdrawrequests) + - [WithdrawRequest](#withdrawrequest) + - [Orders](#orders) + - [Order](#order) + - [OrdersByOrderer](#ordersbyorderer) + - [OrderBooks](#orderbooks) ## Params diff --git a/docs/api/liquidstaking.md b/docs/api/liquidstaking.md index 820e7958..a81ee823 100644 --- a/docs/api/liquidstaking.md +++ b/docs/api/liquidstaking.md @@ -14,10 +14,13 @@ This document provides a high-level overview of what gRPC-gateway REST routes ar ++https://github.com/cosmosquad-labs/squad/blob/main/proto/squad/liquidstaking/v1beta1/query.proto -- [Params](#Params) -- [Validators](#Validators) -- [VotingPower](#VotingPower) -- [States](#States) +- [Liquidstaking Module](#liquidstaking-module) + - [Synopsis](#synopsis) + - [gRPC-gateway REST Routes](#grpc-gateway-rest-routes) + - [Params](#params) + - [Validators](#validators) + - [VotingPower](#votingpower) + - [States](#states) ## Params diff --git a/docs/cli/liquidfarming.md b/docs/cli/liquidfarming.md new file mode 100644 index 00000000..af45adb8 --- /dev/null +++ b/docs/cli/liquidfarming.md @@ -0,0 +1,277 @@ +--- +Title: LiquidFarming +Description: A high-level overview of how the command-line interfaces (CLI) works for the liquidfarming module. +--- + +# LiquidFarming Module + +## Synopsis + +This document provides a high-level overview of how the command line (CLI) interface works for the `liquidfarming` module. +To set up a local testing environment, it requires the latest [Ignite CLI](https://docs.ignite.com/). +If you don't have Ignite CLI set up in your local machine, see [this guide](https://docs.ignite.com/guide/install.html) to install it. +Run this command under the project root directory `$ ignite chain serve -c config-test.yml`. + +Note that [jq](https://stedolan.github.io/jq/) is recommended to be installed as it is used to process JSON throughout the document. + +- [LiquidFarming Module](#Liquidfarming-Module) + - [Synopsis](#Synopsis) +- [Transaction](#Transaction) + - [LiquidFarm](#LiquidFarm) + - [LiquidUnfarm](#LiquidUnfarm) + - [PlaceBid](#PlaceBid) + - [RefundBid](#RefundBid) +- [Query](#Query) + - [Params](#Params) + - [LiquidFarms](#LiquidFarms) + - [LiquidFarm](#LiquidFarm) + - [RewardsAuctions](#RewardsAuctions) + - [RewardsAuction](#RewardsAuction) + - [Bids](#bids) + +# Transaction + +## LiquidFarm + +Farm pool coin for liquid farming. The module mints the corresponding amount of `LFCoin` and sends it to the farmer when the execution is complete. + +Usage + +```bash +liquid-farm [pool-id] [amount] +``` + +| **Argument** | **Description** | +| :----------- | :--------------------------------- | +| pool-id | pool id for the liquid farm | +| amount | amount of pool coin to liquid farm | + +Example + +```bash +# Note that Alice must have some pool coin. +# Reference docs/cli/liquidity.md page to get to know how to +# create a pair, a pool, and deposit coins into the pool. +squad tx liquidfarming liquid-farm 1 500000000000pool1 \ +--chain-id localnet \ +--from alice \ +--keyring-backend test \ +--gas 1000000 \ +--broadcast-mode block \ +--yes \ +--output json | jq + +# +# Tips +# +# Query account balances +squad q bank balances cosmos1zaavvzxez0elundtn32qnk9lkm8kmcszzsv80v -o json | jq +``` + +## LiquidUnfarm + +Unfarm liquid farming coin to get the corresponding pool coin in return. + +Usage + +```bash +liquid-unfarm [pool-id] [amount] +``` + +| **Argument** | **Description** | +| :----------- | :-------------------------- | +| pool-id | pool id for the liquid farm | +| amount | amount of lf coin to unfarm | + +Example + +```bash +squad tx liquidfarming liquid-unfarm 1 300000000000lf1 \ +--chain-id localnet \ +--from alice \ +--keyring-backend test \ +--broadcast-mode block \ +--yes \ +--output json | jq + +# +# Tips +# +# Query account balances +squad q bank balances cosmos1zaavvzxez0elundtn32qnk9lkm8kmcszzsv80v -o json | jq +``` + +## PlaceBid + +Place a bid for a rewards auction. Bidders estimate how much rewards for the next epoch will be accumulated and place their bids accordingly with pool coin amount. + +Usage + +```bash +place-bid [auction-id] [pool-id] [amount] +``` + +| **Argument** | **Description** | +| :----------- | :------------------------------------------------- | +| auction-id | auction id for the liquid unfarm | +| pool-id | pool id for the liquid unfarm | +| amount | amount of pool coin to bid for the rewards auction | + +Example + +```bash +squad tx liquidfarming place-bid 1 1 1000000000pool1 \ +--chain-id localnet \ +--from alice \ +--keyring-backend test \ +--broadcast-mode block \ +--yes \ +--output json | jq + +# +# Tips +# +squad q liquidfarming bids 1 -o json | jq +``` + +## RefundBid + +Refund the placed bid for the rewards auction. Bidders use this transaction message to refund their bid; however, it is important to note that if the bid is currently winning bid, it can't be refunded. + +Usage + +```bash +refund-bid [auction-id] [pool-id] +``` + +| **Argument** | **Description** | +| :----------- | :----------------------------- | +| auction-id | auction id for the liquid farm | +| pool-id | pool id for the liquid farm | + +Example + +```bash +squad tx liquidfarming refund-bid 1 1 \ +--chain-id localnet \ +--from alice \ +--keyring-backend test \ +--broadcast-mode block \ +--yes \ +--output json | jq +``` + +# Query + +## Params + +Query the current liquidfarming parameters information. + +Usage + +```bash +params +``` + +Example + +```bash +squad query liquidfarming params -o json | jq +``` + +## LiquidFarms + +Query for all liquidfarms. + +Usage + +```bash +liquidfarms +``` + +Example + +```bash +squad query liquidfarming liquidfarms -o json | jq +``` + +## LiquidFarm + +Query the specific liquidfarm with pool id. + +Usage + +```bash +liquidfarm [pool-id] +``` + +| **Argument** | **Description** | +| :----------- | :------------------------ | +| pool-id | pool id of the liquidfarm | + +Example + +```bash +squad query liquidfarming liquidfarm 1 -o json | jq +``` + +## RewardsAuctions + +Query all rewards auctions for the liquidfarm. + +Usage + +```bash +rewards-auctions +``` + +Example + +```bash +# The "rewards_auction_duration" param is the duration that is used to create new rewards auction in begin blocker. +# You can adjust the value in config-test.yml file to make it faster or slower. +# By default, the value is set to 12 hours but for local testing purpose it is set to 120 seconds. +# If you wait 120 seconds (2 minutes) after starting a local network, the module automatically creates new rewards auction. +squad query liquidfarming rewards-auctions 1 -o json | jq +``` + +## RewardsAuction + +Query the specific reward auction + +Usage + +```bash +rewards-auction [pool-id] [auction-id] +``` + +| **Argument** | **Description** | +| :----------- | :-------------------------------------------- | +| pool-id | pool id of the liquidfarm | +| auction-id | auction id of the liquidfarm with the pool id | + +Example + +```bash +squad query liquidfarming rewards-auction 1 1 -o json | jq +``` + +## Bids + +Query all bids for the rewards auction + +Usage + +```bash +bids [pool-id] +``` + +| **Argument** | **Description** | +| :----------- | :------------------------ | +| pool-id | pool id of the liquidfarm | + +Example + +```bash +squad query liquidfarming bids 1 -o json | jq +``` diff --git a/go.mod b/go.mod index a12e2911..955eb750 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/golang/protobuf v1.5.2 github.com/gorilla/mux v1.8.0 github.com/grpc-ecosystem/grpc-gateway v1.16.0 - github.com/grpc-ecosystem/grpc-gateway/v2 v2.8.0 + github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.3 github.com/rakyll/statik v0.1.7 github.com/regen-network/cosmos-proto v0.3.1 github.com/spf13/cast v1.4.1 @@ -20,9 +20,9 @@ require ( github.com/tendermint/budget v1.2.0 github.com/tendermint/tendermint v0.34.19 github.com/tendermint/tm-db v0.6.7 - google.golang.org/genproto v0.0.0-20220302033224-9aa15565e42a - google.golang.org/grpc v1.45.0 - google.golang.org/protobuf v1.27.1 + google.golang.org/genproto v0.0.0-20220822174746-9e6da59bd2fc + google.golang.org/grpc v1.48.0 + google.golang.org/protobuf v1.28.1 gopkg.in/yaml.v2 v2.4.0 ) @@ -112,12 +112,12 @@ require ( github.com/zondax/hid v0.9.0 // indirect go.etcd.io/bbolt v1.3.6 // indirect golang.org/x/crypto v0.0.0-20210915214749-c084706c2272 // indirect - golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd // indirect - golang.org/x/sys v0.0.0-20220114195835-da31bd327af9 // indirect + golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e // indirect + golang.org/x/sys v0.0.0-20220610221304-9f5ed59c137d // indirect golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect golang.org/x/text v0.3.7 // indirect gopkg.in/ini.v1 v1.66.2 // indirect - gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect nhooyr.io/websocket v1.8.6 // indirect ) diff --git a/go.sum b/go.sum index defcfeb4..7489bd23 100644 --- a/go.sum +++ b/go.sum @@ -26,16 +26,25 @@ cloud.google.com/go v0.93.3/go.mod h1:8utlLll2EF5XMAV15woO4lSbWQlk8rer9aLOfLh7+Y cloud.google.com/go v0.94.1/go.mod h1:qAlAugsXlC+JWO+Bke5vCtc9ONxjQT3drlTTnAplMW4= cloud.google.com/go v0.97.0/go.mod h1:GF7l59pYBVlXQIBLx3a761cZ41F9bBH3JUlihCt2Udc= cloud.google.com/go v0.99.0/go.mod h1:w0Xx2nLzqWJPuozYQX+hFfCSI8WioryfRDzkoI/Y2ZA= +cloud.google.com/go v0.100.2/go.mod h1:4Xra9TjzAeYHrl5+oeLlzbM2k3mjVhZh4UqTZ//w99A= +cloud.google.com/go v0.102.0/go.mod h1:oWcCzKlqJ5zgHQt9YsaeTY9KzIvjyy0ArmiBUgpQ+nc= cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg= cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= +cloud.google.com/go/compute v0.1.0/go.mod h1:GAesmwr110a34z04OlxYkATPBEfVhkymfTBXtfbBFow= +cloud.google.com/go/compute v1.3.0/go.mod h1:cCZiE1NHEtai4wiufUhW8I8S1JKkAnhnQJWM7YD99wM= +cloud.google.com/go/compute v1.5.0/go.mod h1:9SMHyhJlzhlkJqrPAc839t2BZFTSk6Jdj6mkzQJeu0M= +cloud.google.com/go/compute v1.6.0/go.mod h1:T29tfhtVbq1wvAPo0E3+7vhgmkOYeXjhFvz/FMzPu0s= +cloud.google.com/go/compute v1.6.1/go.mod h1:g85FgpzFvNULZ+S8AYq87axRKuf2Kh7deLqV/jJ3thU= +cloud.google.com/go/compute v1.7.0/go.mod h1:435lt8av5oL9P3fv1OEzSbSUe+ybHXGMPQHHZWZxy9U= cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= cloud.google.com/go/firestore v1.1.0/go.mod h1:ulACoGHTpvq5r8rxGJ4ddJZBZqakUQqClKRT5SZwBmk= cloud.google.com/go/firestore v1.6.1/go.mod h1:asNXNOzBdyVQmEU+ggO8UPodTkEVFW5Qx+rwHnAz+EY= +cloud.google.com/go/iam v0.3.0/go.mod h1:XzJPvDayI+9zsASAFO68Hk07u3z+f+JrT2xXNdp4bnY= cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= @@ -45,6 +54,7 @@ cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0Zeo cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= +cloud.google.com/go/storage v1.22.1/go.mod h1:S8N1cAStu7BOeFfE8KAQzmyyLkK8p/vmRq6kuBTW58Y= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= filippo.io/edwards25519 v1.0.0-beta.2 h1:/BZRNzm8N4K4eWfK28dL4yescorxtO7YG1yun8fy+pI= filippo.io/edwards25519 v1.0.0-beta.2/go.mod h1:X+pm78QAUPtFLi1z9PYIlS/bdDnvbCOGKtZ+ACWEf7o= @@ -419,8 +429,9 @@ github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.7 h1:81/ik6ipDQS2aGcBfIN5dHDB36BwrStyeAQquSYCV4o= github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= +github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg= +github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.1.1-0.20200604201612-c04b05f3adfa h1:Q75Upo5UN4JbPFURXZ8nLKYUvF85dyFRop/vQ0Rv+64= @@ -449,10 +460,15 @@ github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm4 github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/googleapis/enterprise-certificate-proxy v0.0.0-20220520183353-fd19c99a87aa/go.mod h1:17drOmN3MwGY7t0e+Ei9b45FFGA3fBs3x36SsCg1hq8= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/googleapis/gax-go/v2 v2.1.0/go.mod h1:Q3nei7sK6ybPYH7twZdmQpAd1MKb7pfu6SK+H1/DsU0= github.com/googleapis/gax-go/v2 v2.1.1/go.mod h1:hddJymUZASv3XPyGkUpKj8pPO47Rmb0eJc8R6ouapiM= +github.com/googleapis/gax-go/v2 v2.2.0/go.mod h1:as02EH8zWkzwUoLbBaFeQ+arQaj/OthfcblKl4IGNaM= +github.com/googleapis/gax-go/v2 v2.3.0/go.mod h1:b8LNqSzNabLiUpXKkY7HAR5jr6bIT99EXz9pXxye9YM= +github.com/googleapis/gax-go/v2 v2.4.0/go.mod h1:XOTVJ59hdnfJLIP/dh8n5CGryZR2LxK9wbMD5+iXC6c= +github.com/googleapis/go-type-adapters v1.0.0/go.mod h1:zHW75FOG2aur7gAO2B+MLby+cLsWGBF62rFAi7WjWO4= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gordonklaus/ineffassign v0.0.0-20200309095847-7953dde2c7bf/go.mod h1:cuNKsD1zp2v6XfE/orVX2QE1LC+i254ceGcVeDT3pTU= github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= @@ -483,8 +499,8 @@ github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/grpc-ecosystem/grpc-gateway/v2 v2.6.0/go.mod h1:qrJPVzv9YlhsrxJc3P/Q85nr0w1lIRikTl4JlhdDH5w= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.8.0 h1:/57CcG6YAO31FWwTVUnNl+2RcDUAaT55HtI71KQAXVw= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.8.0/go.mod h1:/fckq3NE+vGiJsd4fDt4ge1XrK8cN+e5G5QWIzdg7Q8= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.3 h1:lLT7ZLSzGLI08vc9cpd+tYmNWjdKDqyr/2L+f6U12Fk= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.3/go.mod h1:o//XUCC/F+yRGJoPO/VU0GSB0f8Nhgmxx0VIRUvaC0w= github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c h1:6rhixN/i8ZofjG1Y75iExal34USq5p+wiN1tpie8IrU= github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c/go.mod h1:NMPJylDgVpX0MLRlPy15sqSwOFv/U1GZ2m21JhFfek0= github.com/gtank/merlin v0.1.1-0.20191105220539-8318aed1a79f/go.mod h1:T86dnYJhcGOh5BjZFCJWTDeTK7XW8uE+E21Cy/bIQ+s= @@ -1147,8 +1163,14 @@ golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d/go.mod h1:9nx3DQGgdP8bBQD5qx golang.org/x/net v0.0.0-20210903162142-ad29c8ab022f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210917221730-978cfadd31cf/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211208012354-db4efeb81f4b/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd h1:O7DYs+zxREGLKzKoMQrtrEacpb0ZVXA5rIwylE2Xchk= golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/net v0.0.0-20220325170049-de3da57026de/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/net v0.0.0-20220412020605-290c469a71a5/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/net v0.0.0-20220607020251-c690dde0001d/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e h1:TsQ7F31D3bUCLeqPT0u+yjp1guoArKaNKmCr22PYgTQ= +golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -1167,6 +1189,10 @@ golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f/go.mod h1:KelEdhl1UZF7XfJ golang.org/x/oauth2 v0.0.0-20211005180243-6b3c2da341f1/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= +golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= +golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= +golang.org/x/oauth2 v0.0.0-20220608161450-d0670ef3b1eb/go.mod h1:jaDAt6Dkxork7LmZnYtzbRWj0W47D86a3TGe0YHBvmE= +golang.org/x/oauth2 v0.0.0-20220822191816-0ebed06d0094/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -1178,6 +1204,7 @@ golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -1275,8 +1302,17 @@ golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20211205182925-97ca703d548d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211210111614-af8b64212486/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220114195835-da31bd327af9 h1:XfKQ4OlFl8okEOr5UvAqFRVj8pY/4yfcXrddB8qAbU0= golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220209214540-3681064d5158/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220328115105-d36c6a25d886/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220502124256-b6088ccd6cba/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220610221304-9f5ed59c137d h1:Zu/JngovGLVi6t2J3nmAf3AoTDwuzw85YZ3b9o4yU7s= +golang.org/x/sys v0.0.0-20220610221304-9f5ed59c137d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 h1:JGgROgKl9N8DuW20oFS5gxc+lE67/N3FcwmBPMe7ArY= @@ -1365,8 +1401,10 @@ golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= +golang.org/x/xerrors v0.0.0-20220609144429-65e65417b02f/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= gonum.org/v1/gonum v0.0.0-20180816165407-929014505bf4/go.mod h1:Y+Yx5eoAFn32cQvJDxZx5Dpnq+c3wtXuadVZAcxbbBo= gonum.org/v1/gonum v0.8.2/go.mod h1:oe/vMfY3deqTw+1EZJhuvEW2iwGF1bW9wwu7XCu0+v0= gonum.org/v1/netlib v0.0.0-20190313105609-8cb42192e0e0/go.mod h1:wa6Ws7BG/ESfp6dHfk7C6KdzKA7wR7u/rKwOGE66zvw= @@ -1404,6 +1442,14 @@ google.golang.org/api v0.57.0/go.mod h1:dVPlbZyBo2/OjBpmvNdpn2GRm6rPy75jyU7bmhdr google.golang.org/api v0.59.0/go.mod h1:sT2boj7M9YJxZzgeZqXogmhfmRWDtPzT31xkieUbuZU= google.golang.org/api v0.61.0/go.mod h1:xQRti5UdCmoCEqFxcz93fTl338AVqDgyaDRuOZ3hg9I= google.golang.org/api v0.63.0/go.mod h1:gs4ij2ffTRXwuzzgJl/56BdwJaA194ijkfn++9tDuPo= +google.golang.org/api v0.67.0/go.mod h1:ShHKP8E60yPsKNw/w8w+VYaj9H6buA5UqDp8dhbQZ6g= +google.golang.org/api v0.70.0/go.mod h1:Bs4ZM2HGifEvXwd50TtW70ovgJffJYw2oRCOFU/SkfA= +google.golang.org/api v0.71.0/go.mod h1:4PyU6e6JogV1f9eA4voyrTY2batOLdgZ5qZ5HOCc4j8= +google.golang.org/api v0.74.0/go.mod h1:ZpfMZOVRMywNyvJFeqL9HRWBgAuRfSjJFpe9QtRRyDs= +google.golang.org/api v0.75.0/go.mod h1:pU9QmyHLnzlpar1Mjt4IbapUCy8J+6HD6GeELN69ljA= +google.golang.org/api v0.78.0/go.mod h1:1Sg78yoMLOhlQTeF+ARBoytAcH1NNyyl390YMy6rKmw= +google.golang.org/api v0.80.0/go.mod h1:xY3nI94gbvBrE0J6NHXhxOmW97HG7Khjkku6AFB3Hyg= +google.golang.org/api v0.84.0/go.mod h1:NTsGnUFJMYROtiquksZHBWtHfeMC7iYthki7Eq3pa8o= google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= @@ -1456,6 +1502,7 @@ google.golang.org/genproto v0.0.0-20210222152913-aa3ee6e6a81c/go.mod h1:FWY/as6D google.golang.org/genproto v0.0.0-20210303154014-9728d6b83eeb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210310155132-4ce2db91004e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210319143718-93e7006c17a6/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20210329143202-679c6ae281ee/go.mod h1:9lPAdzaEmUacj36I+k7YKbEc5CXzPIeORRgDAUOu28A= google.golang.org/genproto v0.0.0-20210402141018-6c239bbf2bb1/go.mod h1:9lPAdzaEmUacj36I+k7YKbEc5CXzPIeORRgDAUOu28A= google.golang.org/genproto v0.0.0-20210513213006-bf773b8c8384/go.mod h1:P3QM42oQyzQSnHPnZ/vqoCdDmzH28fzWByN9asMeM8A= google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= @@ -1479,9 +1526,27 @@ google.golang.org/genproto v0.0.0-20211028162531-8db9c33dc351/go.mod h1:5CzLGKJ6 google.golang.org/genproto v0.0.0-20211118181313-81c1377c94b1/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/genproto v0.0.0-20211206160659-862468c7d6e0/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20211221195035-429b39de9b1c/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/genproto v0.0.0-20211223182754-3ac035c7e7cb/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20220302033224-9aa15565e42a h1:uqouglH745GoGeZ1YFZbPBiu961tgi/9Qm5jaorajjQ= -google.golang.org/genproto v0.0.0-20220302033224-9aa15565e42a/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= +google.golang.org/genproto v0.0.0-20220126215142-9970aeb2e350/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20220207164111-0872dc986b00/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20220218161850-94dd64e39d7c/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= +google.golang.org/genproto v0.0.0-20220222213610-43724f9ea8cf/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= +google.golang.org/genproto v0.0.0-20220304144024-325a89244dc8/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= +google.golang.org/genproto v0.0.0-20220310185008-1973136f34c6/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= +google.golang.org/genproto v0.0.0-20220324131243-acbaeb5b85eb/go.mod h1:hAL49I2IFola2sVEjAn7MEwsja0xp51I0tlGAf9hz4E= +google.golang.org/genproto v0.0.0-20220407144326-9054f6ed7bac/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= +google.golang.org/genproto v0.0.0-20220413183235-5e96e2839df9/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= +google.golang.org/genproto v0.0.0-20220414192740-2d67ff6cf2b4/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= +google.golang.org/genproto v0.0.0-20220421151946-72621c1f0bd3/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= +google.golang.org/genproto v0.0.0-20220429170224-98d788798c3e/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= +google.golang.org/genproto v0.0.0-20220505152158-f39f71e6c8f3/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4= +google.golang.org/genproto v0.0.0-20220518221133-4f43b3371335/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4= +google.golang.org/genproto v0.0.0-20220523171625-347a074981d8/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4= +google.golang.org/genproto v0.0.0-20220608133413-ed9918b62aac/go.mod h1:KEWEmljWE5zPzLBa/oHl6DaEt9LmfH6WtH1OHIvleBA= +google.golang.org/genproto v0.0.0-20220616135557-88e70c0c3a90/go.mod h1:KEWEmljWE5zPzLBa/oHl6DaEt9LmfH6WtH1OHIvleBA= +google.golang.org/genproto v0.0.0-20220822174746-9e6da59bd2fc h1:Nf+EdcTLHR8qDNN/KfkQL0u0ssxt9OhbaWCl5C0ucEI= +google.golang.org/genproto v0.0.0-20220822174746-9e6da59bd2fc/go.mod h1:dbqgFATTzChvnt+ujMdZwITVAJHFtfyN1qUhDqEiIlk= google.golang.org/grpc v1.33.2 h1:EQyQC3sa8M+p6Ulc8yy9SWSS2GVwyRc83gAbG8lrl4o= google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= @@ -1498,8 +1563,10 @@ google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlba google.golang.org/protobuf v1.25.1-0.20200805231151-a709e31e5d12/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ= google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= +google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= @@ -1532,8 +1599,9 @@ gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= @@ -1550,5 +1618,4 @@ rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc= -sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8= sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU= diff --git a/proto/squad/liquidfarming/v1beta1/genesis.proto b/proto/squad/liquidfarming/v1beta1/genesis.proto new file mode 100644 index 00000000..55aa872f --- /dev/null +++ b/proto/squad/liquidfarming/v1beta1/genesis.proto @@ -0,0 +1,47 @@ +syntax = "proto3"; +package squad.liquidfarming.v1beta1; + +import "gogoproto/gogo.proto"; +import "google/protobuf/timestamp.proto"; +import "squad/liquidfarming/v1beta1/liquidfarming.proto"; +import "squad/liquidfarming/v1beta1/params.proto"; + +option go_package = "github.com/cosmosquad-labs/squad/x/liquidfarming/types"; + +// GenesisState defines the liquidfarming module's genesis state. +message GenesisState { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + Params params = 1 [(gogoproto.nullable) = false]; + + repeated LastRewardsAuctionIdRecord last_rewards_auction_id_record = 2 [(gogoproto.nullable) = false]; + + repeated LiquidFarm liquid_farms = 3 [(gogoproto.nullable) = false]; + + repeated RewardsAuction rewards_auctions = 4 [(gogoproto.nullable) = false]; + + repeated Bid bids = 5 [(gogoproto.nullable) = false]; + + repeated WinningBidRecord winning_bid_records = 6 [(gogoproto.nullable) = false]; +} + +message LastRewardsAuctionIdRecord { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + uint64 pool_id = 1; + + uint64 auction_id = 2; +} + +// WinningBidRecord defines a custom winning bid record that is required to be recorded +// in genesis state. +message WinningBidRecord { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + uint64 auction_id = 1; + + Bid winning_bid = 2 [(gogoproto.nullable) = false]; +} \ No newline at end of file diff --git a/proto/squad/liquidfarming/v1beta1/liquidfarming.proto b/proto/squad/liquidfarming/v1beta1/liquidfarming.proto new file mode 100644 index 00000000..bd4a7f14 --- /dev/null +++ b/proto/squad/liquidfarming/v1beta1/liquidfarming.proto @@ -0,0 +1,101 @@ +syntax = "proto3"; +package squad.liquidfarming.v1beta1; + +import "gogoproto/gogo.proto"; +import "cosmos_proto/cosmos.proto"; +import "cosmos/base/v1beta1/coin.proto"; +import "google/protobuf/timestamp.proto"; + +option go_package = "github.com/cosmosquad-labs/squad/x/liquidfarming/types"; +option (gogoproto.goproto_getters_all) = false; + +// RewardsAuction defines rewards auction that is created by the module +// for every rewards_auction_duration in params. +message RewardsAuction { + // id specifies the unique auction id + uint64 id = 1; + + // pool_id specifies the liquidity pool id + uint64 pool_id = 2; + + // bidding_coin_denom specifies the bidding coin denomination + string bidding_coin_denom = 3; + + // paying_reserve_address specfies the account that reserves bidding amounts placed by bidders + string paying_reserve_address = 4; + + // start_time specifies the start time of an auction + google.protobuf.Timestamp start_time = 5 + [(gogoproto.stdtime) = true, (gogoproto.nullable) = false]; + + // end_time specifies the end time of an auction + google.protobuf.Timestamp end_time = 6 + [(gogoproto.stdtime) = true, (gogoproto.nullable) = false]; + + // status specifies the status of an auction + AuctionStatus status = 7; + + // winner specifies the bidder who won the auction + // the value is determined when an auction is finished + string winner = 8; + + // winning_amount specifies the winning amount for the uaction + cosmos.base.v1beta1.Coin winning_amount = 9 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coin" + ]; + + // rewards specifies the farming rewards for are accumulated in the farm module + // the value is determined when an auction is finished + repeated cosmos.base.v1beta1.Coin rewards = 10 [ + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", + (gogoproto.nullable) = false + ]; +} + +// CompoundingRewards records the amount of pool coin that is used for a bidder to place a bid +// for an auction. It is used internally to calculate unfarm amount. +message CompoundingRewards { + option (gogoproto.goproto_getters) = false; + + string amount = 1 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false]; +} + +// Bid defines standard bid for a rewards auction. +message Bid { + option (gogoproto.goproto_getters) = false; + + // pool_id specifies the pool id + uint64 pool_id = 1; + + // bidder specifies the bech32-encoded address that places a bid for the auction + string bidder = 2; + + // amount specifies the amount to place a bid + cosmos.base.v1beta1.Coin amount = 3 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coin" + ]; +} + +// AuctionStatus enumerates the valid status of an auction. +enum AuctionStatus { + option (gogoproto.goproto_enum_prefix) = false; + + // AUCTION_STATUS_UNSPECIFIED defines the default auction status + AUCTION_STATUS_UNSPECIFIED = 0 + [ (gogoproto.enumvalue_customname) = "AuctionStatusNil" ]; + + // AUCTION_STATUS_STARTED defines the started auction status + AUCTION_STATUS_STARTED = 1 + [ (gogoproto.enumvalue_customname) = "AuctionStatusStarted" ]; + + // AUCTION_STATUS_FINISHED defines the finished auction status + AUCTION_STATUS_FINISHED = 2 + [ (gogoproto.enumvalue_customname) = "AuctionStatusFinished" ]; + + // AUCTION_STATUS_SKIPPED defines the skipped auction status + AUCTION_STATUS_SKIPPED = 3 + [ (gogoproto.enumvalue_customname) = "AuctionStatusSkipped" ]; +} + diff --git a/proto/squad/liquidfarming/v1beta1/params.proto b/proto/squad/liquidfarming/v1beta1/params.proto new file mode 100644 index 00000000..1ad6ef2d --- /dev/null +++ b/proto/squad/liquidfarming/v1beta1/params.proto @@ -0,0 +1,37 @@ +syntax = "proto3"; +package squad.liquidfarming.v1beta1; + +import "google/protobuf/duration.proto"; +import "gogoproto/gogo.proto"; + +import "cosmos/base/v1beta1/coin.proto"; + +option go_package = "github.com/cosmosquad-labs/squad/x/liquidfarming/types"; + +// Params defines the parameters for the module. +message Params { + option (gogoproto.goproto_getters) = false; + + repeated LiquidFarm liquid_farms = 1 [(gogoproto.nullable) = false]; + + google.protobuf.Duration rewards_auction_duration = 2 [(gogoproto.nullable) = false, (gogoproto.stdduration) = true]; +} + +// LiquidFarm defines liquid farm object that provides auto compounding functionality +// for the liquidity pool and undergoes farming rewards auction process. +// See the technical spec for more detailed information. +message LiquidFarm { + option (gogoproto.goproto_getters) = false; + option (gogoproto.goproto_stringer) = false; + + uint64 pool_id = 1; + + string min_farm_amount = 2 + [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false]; + + string min_bid_amount = 3 + [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false]; + + string fee_rate = 4 + [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; +} diff --git a/proto/squad/liquidfarming/v1beta1/query.proto b/proto/squad/liquidfarming/v1beta1/query.proto new file mode 100644 index 00000000..00877507 --- /dev/null +++ b/proto/squad/liquidfarming/v1beta1/query.proto @@ -0,0 +1,162 @@ +syntax = "proto3"; +package squad.liquidfarming.v1beta1; + +import "cosmos/base/query/v1beta1/pagination.proto"; +import "cosmos/base/v1beta1/coin.proto"; +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; +import "squad/liquidfarming/v1beta1/liquidfarming.proto"; +import "squad/liquidfarming/v1beta1/params.proto"; + +option go_package = "github.com/cosmosquad-labs/squad/x/liquidfarming/types"; + +// Query defines the gRPC querier service. +service Query { + // Params returns parameters of the module + rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { + option (google.api.http).get = "/squad/liquidfarming/v1beta1/params"; + } + + // LiquidFarms returns all liquid farms registered in params + rpc LiquidFarms(QueryLiquidFarmsRequest) returns (QueryLiquidFarmsResponse) { + option (google.api.http).get = "/squad/liquidfarming/v1beta1/liquidfarms"; + } + + // LiquidFarm returns the specific liquid farm + rpc LiquidFarm(QueryLiquidFarmRequest) returns (QueryLiquidFarmResponse) { + option (google.api.http).get = "/squad/liquidfarming/v1beta1/liquidfarms/{pool_id}"; + } + + // RewardsAuctions returns all rewards auctions + rpc RewardsAuctions(QueryRewardsAuctionsRequest) returns (QueryRewardsAuctionsResponse) { + option (google.api.http).get = "/squad/liquidfarming/v1beta1/pools/{pool_id}/rewards_auctions"; + } + + // RewardsAuction returns the specific rewards auction + rpc RewardsAuction(QueryRewardsAuctionRequest) returns (QueryRewardsAuctionResponse) { + option (google.api.http).get = "/squad/liquidfarming/v1beta1/pools/{pool_id}/rewards_auctions/{auction_id}"; + } + + // Bids returns all bids for the liquid farm + rpc Bids(QueryBidsRequest) returns (QueryBidsResponse) { + option (google.api.http).get = "/squad/liquidfarming/v1beta1/pools/{pool_id}/bids"; + } + + // MintRate returns the current mint rate. + rpc MintRate(QueryMintRateRequest) returns (QueryMintRateResponse) { + option (google.api.http).get = "/squad/liquidfarming/v1beta1/pools/{pool_id}/mint_rate"; + } + + // BurnRate returns the current burn rate. + rpc BurnRate(QueryBurnRateRequest) returns (QueryBurnRateResponse) { + option (google.api.http).get = "/squad/liquidfarming/v1beta1/pools/{pool_id}/burn_rate"; + } +} + +// QueryLiquidFarmsRequest is the request type for the Query/LiquidFarms RPC method. +message QueryLiquidFarmsRequest { + cosmos.base.query.v1beta1.PageRequest pagination = 1; +} + +// QueryLiquidFarmsResponse is response type for the Query/LiquidFarms RPC method. +message QueryLiquidFarmsResponse { + repeated LiquidFarmResponse liquid_farms = 1 [ (gogoproto.nullable) = false ]; +} + +// QueryLiquidFarmRequest is the request type for the Query/LiquidFarm RPC method. +message QueryLiquidFarmRequest { + uint64 pool_id = 1; +} + +// QueryLiquidFarmResponse is response type for the Query/LiquidFarm RPC method. +message QueryLiquidFarmResponse { + LiquidFarmResponse liquid_farm = 1 [ (gogoproto.nullable) = false ]; +} + +// QueryParamsRequest is request type for the Query/Params RPC method. +message QueryParamsRequest {} + +// QueryParamsResponse is response type for the Query/Params RPC method. +message QueryParamsResponse { + Params params = 1 [(gogoproto.nullable) = false]; +} + +// QueryRewardsAuctionsRequest is request type for the Query/RewardsAuctions RPC method. +message QueryRewardsAuctionsRequest { + uint64 pool_id = 1; + cosmos.base.query.v1beta1.PageRequest pagination = 2; +} + +// QueryRewardsAuctionsResponse is response type for the Query/RewardsAuctions RPC method. +message QueryRewardsAuctionsResponse { + repeated RewardsAuction reward_auctions = 1 [ (gogoproto.nullable) = false ]; + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + + +// QueryRewardsAuctionRequest is request type for the Query/RewardsAuction RPC method. +message QueryRewardsAuctionRequest { + uint64 auction_id = 1; + uint64 pool_id = 2; +} + +// QueryRewardsAuctionResponse is response type for the Query/RewardsAuction RPC method. +message QueryRewardsAuctionResponse { + RewardsAuction reward_auction = 1 [ (gogoproto.nullable) = false ]; +} + +// QueryBidsRequest is request type for the Query/Bids RPC method. +message QueryBidsRequest { + uint64 pool_id = 1; + cosmos.base.query.v1beta1.PageRequest pagination = 2; +} + +// QueryBidsResponse is response type for the Query/Bids RPC method. +message QueryBidsResponse { + repeated Bid bids = 1 [ (gogoproto.nullable) = false ]; + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + +// QueryMintRateRequest is request type for the Query/MintRate RPC method. +message QueryMintRateRequest { + uint64 pool_id = 1; +} + +// QueryMintRateResponse is response type for the Query/MintRate RPC method. +message QueryMintRateResponse { + string mint_rate = 1 + [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; +} + +// QueryBurnRateRequest is request type for the Query/BurnRate RPC method. +message QueryBurnRateRequest { + uint64 pool_id = 1; +} + +// QueryBurnRateResponse is response type for the Query/BurnRate RPC method. +message QueryBurnRateResponse { + string burn_rate = 1 + [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; +} + +// +// Custom response messages +// + +// LiquidFarmResponse is response type for the Query/LiquidFarm RPC method. +message LiquidFarmResponse { + uint64 pool_id = 1; + + string liquid_farm_reserve_address = 2; + + string lf_coin_denom = 3 [(gogoproto.customname) = "LFCoinDenom"]; + + string min_farm_amount = 4 + [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false]; + + string min_bid_amount = 5 + [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false]; + + string total_farming_amount = 6 + [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false]; +} \ No newline at end of file diff --git a/proto/squad/liquidfarming/v1beta1/tx.proto b/proto/squad/liquidfarming/v1beta1/tx.proto new file mode 100644 index 00000000..6e71dabc --- /dev/null +++ b/proto/squad/liquidfarming/v1beta1/tx.proto @@ -0,0 +1,110 @@ +syntax = "proto3"; +package squad.liquidfarming.v1beta1; + +import "gogoproto/gogo.proto"; +import "cosmos/base/v1beta1/coin.proto"; +import "cosmos/base/query/v1beta1/pagination.proto"; + +option go_package = "github.com/cosmosquad-labs/squad/x/liquidfarming/types"; + +// Msg defines the Msg service. +service Msg { + // LiquidFarm defines a method for farming pool coin for a liquid farm + rpc LiquidFarm(MsgLiquidFarm) returns (MsgLiquidFarmResponse); + + // LiquidUnfarm defines a method for unfarming amount of LFCoin + rpc LiquidUnfarm(MsgLiquidUnfarm) returns (MsgLiquidUnfarmResponse); + + // LiquidUnfarmAndWithdraw defines a method for unfarming amount of LFCoin and withdraw pool coin from the pool + rpc LiquidUnfarmAndWithdraw(MsgLiquidUnfarmAndWithdraw) returns (MsgLiquidUnfarmAndWithdrawResponse); + + // PlaceBid defines a method for placing a bid for a rewards auction + rpc PlaceBid(MsgPlaceBid) returns (MsgPlaceBidResponse); + + // RefundBid defines a method for refunding the bid that is not winning for the auction + rpc RefundBid(MsgRefundBid) returns (MsgRefundBidResponse); +} + +// MsgLiquidFarm defines a SDK message for farming pool coin for a liquid farm. +message MsgLiquidFarm { + option (gogoproto.goproto_getters) = false; + + uint64 pool_id = 1; + + string farmer = 2; + + cosmos.base.v1beta1.Coin farming_coin = 3 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coin" + ]; +} + +// MsgLiquidFarmResponse defines the MsgLiquidFarmResponse response type. +message MsgLiquidFarmResponse {} + +// MsgLiquidUnfarm defines a SDK message for unfarming LFCoin. +message MsgLiquidUnfarm { + option (gogoproto.goproto_getters) = false; + + uint64 pool_id = 1; + + string farmer = 2; + + cosmos.base.v1beta1.Coin unfarming_coin = 3 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coin" + ]; +} + +// MsgLiquidUnfarmResponse defines the MsgLiquidUnfarmResponse response type. +message MsgLiquidUnfarmResponse {} + +// MsgLiquidUnfarmAndWithdraw defines a SDK message for unfarming LFCoin. +message MsgLiquidUnfarmAndWithdraw { + option (gogoproto.goproto_getters) = false; + + uint64 pool_id = 1; + + string farmer = 2; + + cosmos.base.v1beta1.Coin unfarming_coin = 3 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coin" + ]; +} + +// MsgLiquidUnfarmAndWithdrawResponse defines the MsgLiquidUnfarmAndWithdrawResponse response type. +message MsgLiquidUnfarmAndWithdrawResponse {} + +// MsgPlaceBid defines a SDK message for placing a bid for a rewards auction. +message MsgPlaceBid { + option (gogoproto.goproto_getters) = false; + + uint64 auction_id = 1; + + uint64 pool_id = 2; + + string bidder = 3; + + cosmos.base.v1beta1.Coin bidding_coin = 4 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coin" + ]; +} + +// MsgPlaceBidResponse defines the MsgPlaceBidResponse response type. +message MsgPlaceBidResponse {} + +// MsgRefundBid defines a SDK message for refunding the bid that is not winning for the auction. +message MsgRefundBid { + option (gogoproto.goproto_getters) = false; + + uint64 auction_id = 1; + + uint64 pool_id = 2; + + string bidder = 3; +} + +// MsgRefundBidResponse defines the MsgRefundBidResponse response type. +message MsgRefundBidResponse {} diff --git a/x/farming/keeper/epoch.go b/x/farming/keeper/epoch.go index 3356bc12..1f36c002 100644 --- a/x/farming/keeper/epoch.go +++ b/x/farming/keeper/epoch.go @@ -44,7 +44,7 @@ func (k Keeper) SetLastEpochTime(ctx sdk.Context, t time.Time) { // Use this only for simulation and testing purpose. func (k Keeper) AdvanceEpoch(ctx sdk.Context) error { currentEpochDays := k.GetCurrentEpochDays(ctx) - k.ProcessQueuedCoins(ctx, ctx.BlockTime().Add(time.Duration(currentEpochDays)*types.Day)) + k.ProcessQueuedCoins(ctx, ctx.BlockTime()) // Caller must adjust the ctx's BlockTime to simulate the advance. if err := k.TerminateEndedPlans(ctx); err != nil { return err } diff --git a/x/farming/keeper/msg_server.go b/x/farming/keeper/msg_server.go index 3460f51c..0797f3fd 100644 --- a/x/farming/keeper/msg_server.go +++ b/x/farming/keeper/msg_server.go @@ -8,6 +8,7 @@ package keeper import ( "context" "fmt" + "time" sdk "github.com/cosmos/cosmos-sdk/types" @@ -115,6 +116,8 @@ func (k msgServer) AdvanceEpoch(goCtx context.Context, msg *types.MsgAdvanceEpoc ctx := sdk.UnwrapSDKContext(goCtx) if EnableAdvanceEpoch { + currentEpochDays := k.GetCurrentEpochDays(ctx) + ctx = ctx.WithBlockTime(ctx.BlockTime().Add(time.Duration(currentEpochDays) * types.Day)) if err := k.Keeper.AdvanceEpoch(ctx); err != nil { return nil, err } diff --git a/x/farming/simulation/operations_test.go b/x/farming/simulation/operations_test.go index 858ef3a1..c86d864e 100644 --- a/x/farming/simulation/operations_test.go +++ b/x/farming/simulation/operations_test.go @@ -3,6 +3,7 @@ package simulation_test import ( "math/rand" "testing" + "time" "github.com/stretchr/testify/require" @@ -193,7 +194,8 @@ func TestSimulateMsgUnstake(t *testing.T) { // begin a new block and advance epoch app.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: app.LastBlockHeight() + 1, AppHash: app.LastCommitID().Hash}}) - err = app.FarmingKeeper.AdvanceEpoch(ctx) + currentEpochDays := app.FarmingKeeper.GetCurrentEpochDays(ctx) + err = app.FarmingKeeper.AdvanceEpoch(ctx.WithBlockTime(ctx.BlockTime().Add(time.Duration(currentEpochDays) * types.Day))) require.NoError(t, err) // execute operation @@ -265,7 +267,8 @@ func TestSimulateMsgHarvest(t *testing.T) { _, sf := app.FarmingKeeper.GetStaking(ctx, sdk.DefaultBondDenom, accounts[1].Address) require.True(t, sf) - err = app.FarmingKeeper.AdvanceEpoch(ctx) + currentEpochDays := app.FarmingKeeper.GetCurrentEpochDays(ctx) + err = app.FarmingKeeper.AdvanceEpoch(ctx.WithBlockTime(ctx.BlockTime().Add(time.Duration(currentEpochDays) * types.Day))) require.NoError(t, err) // execute operation diff --git a/x/farming/spec/09_hooks.md b/x/farming/spec/09_hooks.md new file mode 100644 index 00000000..dc6809c3 --- /dev/null +++ b/x/farming/spec/09_hooks.md @@ -0,0 +1,20 @@ + + +# Hooks + +Other modules may register operations to execute when a certain event has occurred within farming. +These events can be registered to execute right `Before` or `After` the farming event (as per the hook name). +The following hooks can be registered: + +```go +AfterAllocateRewards(ctx sdk.Context) +``` + +```go +AfterStaked( + ctx sdk.Context, + farmer sdk.AccAddress, + stakingCoinDenom string, + stakingAmt sdk.Int, +) +``` \ No newline at end of file diff --git a/x/farming/spec/README.md b/x/farming/spec/README.md index dbcd15df..88462c29 100644 --- a/x/farming/spec/README.md +++ b/x/farming/spec/README.md @@ -18,3 +18,4 @@ A primary use case of the farming module is to provide incentives for liquidity 6. **[Events](06_events.md)** 7. **[Parameters](07_params.md)** 8. **[Proposal](08_proposal.md)** +9. **[Hooks](09_hooks.md)** diff --git a/x/liquidfarming/abci.go b/x/liquidfarming/abci.go new file mode 100644 index 00000000..6c221f81 --- /dev/null +++ b/x/liquidfarming/abci.go @@ -0,0 +1,77 @@ +package liquidfarming + +import ( + "sort" + "time" + + "github.com/cosmos/cosmos-sdk/telemetry" + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/cosmosquad-labs/squad/v3/x/liquidfarming/keeper" + "github.com/cosmosquad-labs/squad/v3/x/liquidfarming/types" +) + +// BeginBlocker compares all LiquidFarms stored in KVstore with all LiquidFarms registered in params. +// Execute an appropriate operation when either new LiquidFarm is added or existing LiquidFarm is removed by +// going through governance proposal. +func BeginBlocker(ctx sdk.Context, k keeper.Keeper) { + defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyBeginBlocker) + + params := k.GetParams(ctx) + liquidFarmsInStore := k.GetAllLiquidFarms(ctx) + liquidFarmsInParams := params.LiquidFarms + + liquidFarmByPoolId := map[uint64]types.LiquidFarm{} // PoolId => LiquidFarm + for _, liquidFarm := range liquidFarmsInStore { + liquidFarmByPoolId[liquidFarm.PoolId] = liquidFarm + } + + // Compare all liquid farms stored in KVStore with the ones registered in params + // If new liquid farm is added through governance proposal, store it in KVStore. + // Otherwise, delete from the liquidFarmByPoolId + for _, liquidFarm := range liquidFarmsInParams { + if _, found := liquidFarmByPoolId[liquidFarm.PoolId]; !found { + k.SetLiquidFarm(ctx, liquidFarm) + continue + } + delete(liquidFarmByPoolId, liquidFarm.PoolId) + } + + // Sort map keys for deterministic execution + var poolIds []uint64 + for poolId := range liquidFarmByPoolId { + poolIds = append(poolIds, poolId) + } + sort.Slice(poolIds, func(i, j int) bool { + return poolIds[i] < poolIds[j] + }) + + // Handle a case when LiquidFarm is removed in params by governance proposal + for _, poolId := range poolIds { + k.HandleRemovedLiquidFarm(ctx, liquidFarmByPoolId[poolId]) + } + + endTime := k.GetLastRewardsAuctionEndTime(ctx) + if endTime.IsZero() { + k.SetLastRewardsAuctionEndTime(ctx, ctx.BlockTime().Add(params.RewardsAuctionDuration)) + return + } + + // Iterate all LiquidFarms in KVStore to create rewards auction if it is not found. + // If there is an ongoing rewards auction, finish it. + if !ctx.BlockTime().Before(endTime) { // AuctionEndTime <= Current BlockTime + for _, liquidFarm := range liquidFarmsInStore { + auctionId := k.GetLastRewardsAuctionId(ctx, liquidFarm.PoolId) + auction, found := k.GetRewardsAuction(ctx, auctionId, liquidFarm.PoolId) + if found { + // Note that order matters in this logic. + // The module needs to finish the auction and create new one + if err := k.FinishRewardsAuction(ctx, auction, liquidFarm.FeeRate); err != nil { + panic(err) + } + } + k.CreateRewardsAuction(ctx, liquidFarm.PoolId, params.RewardsAuctionDuration) + } + k.SetLastRewardsAuctionEndTime(ctx, ctx.BlockTime().Add(params.RewardsAuctionDuration)) + } +} diff --git a/x/liquidfarming/client/cli/query.go b/x/liquidfarming/client/cli/query.go new file mode 100644 index 00000000..6fe115ca --- /dev/null +++ b/x/liquidfarming/client/cli/query.go @@ -0,0 +1,391 @@ +package cli + +import ( + "fmt" + "strconv" + "strings" + + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/version" + + "github.com/cosmosquad-labs/squad/v3/x/liquidfarming/types" +) + +// GetQueryCmd returns the cli query commands for the module +func GetQueryCmd(queryRoute string) *cobra.Command { + cmd := &cobra.Command{ + Use: types.ModuleName, + Short: fmt.Sprintf("Querying commands for the %s module", types.ModuleName), + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + cmd.AddCommand( + NewQueryParamsCmd(), + NewQueryLiquidFarmsCmd(), + NewQueryLiquidFarmCmd(), + NewQueryRewardsAuctionsCmd(), + NewQueryRewardsAuctionCmd(), + NewQueryBidsCmd(), + NewQueryMintRateCmd(), + NewQueryBurnRateCmd(), + ) + + return cmd +} + +func NewQueryParamsCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "params", + Args: cobra.NoArgs, + Short: "Query the current liquidfarming parameters information", + Long: strings.TrimSpace( + fmt.Sprintf(`Query values set as liquidfarming parameters. +Example: +$ %s query %s params +`, + version.AppName, types.ModuleName, + ), + ), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + resp, err := queryClient.Params(cmd.Context(), &types.QueryParamsRequest{}) + if err != nil { + return err + } + + return clientCtx.PrintProto(&resp.Params) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +func NewQueryLiquidFarmsCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "liquidfarms", + Args: cobra.NoArgs, + Short: "Query for all liquidfarms", + Long: strings.TrimSpace( + fmt.Sprintf(`Query for all liquidfarms on a network. + +Example: +$ %s query %s liquidfarms +`, + version.AppName, types.ModuleName, + ), + ), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + pageReq, err := client.ReadPageRequest(cmd.Flags()) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + res, err := queryClient.LiquidFarms(cmd.Context(), &types.QueryLiquidFarmsRequest{ + Pagination: pageReq, + }) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +func NewQueryLiquidFarmCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "liquidfarm [pool-id]", + Args: cobra.ExactArgs(1), + Short: "Query the specific liquidfarm", + Long: strings.TrimSpace( + fmt.Sprintf(`Query the specific liquidfarm on a network. + +Example: +$ %s query %s liquidfarm 1 +`, + version.AppName, types.ModuleName, + ), + ), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + poolId, err := strconv.ParseUint(args[0], 10, 64) + if err != nil { + return fmt.Errorf("failed to parse pool id: %w", err) + } + + queryClient := types.NewQueryClient(clientCtx) + res, err := queryClient.LiquidFarm(cmd.Context(), &types.QueryLiquidFarmRequest{ + PoolId: poolId, + }) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +func NewQueryRewardsAuctionsCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "rewards-auctions [pool-id]", + Args: cobra.ExactArgs(1), + Short: "Query all rewards auctions for the liquidfarm", + Long: strings.TrimSpace( + fmt.Sprintf(`Query all rewards auctions for the liquidfarm on a network. + +Example: +$ %s query %s rewards-auctions 1 +`, + version.AppName, types.ModuleName, + ), + ), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + poolId, err := strconv.ParseUint(args[0], 10, 64) + if err != nil { + return fmt.Errorf("failed to parse pool id: %w", err) + } + + pageReq, err := client.ReadPageRequest(cmd.Flags()) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + res, err := queryClient.RewardsAuctions(cmd.Context(), &types.QueryRewardsAuctionsRequest{ + PoolId: poolId, + Pagination: pageReq, + }) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +func NewQueryRewardsAuctionCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "rewards-auction [pool-id] [auction-id]", + Args: cobra.ExactArgs(2), + Short: "Query the specific reward auction", + Long: strings.TrimSpace( + fmt.Sprintf(`Query the specific reward auction on a network. + +Example: +$ %s query %s rewards-auction 1 1 +`, + version.AppName, types.ModuleName, + ), + ), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + poolId, err := strconv.ParseUint(args[0], 10, 64) + if err != nil { + return fmt.Errorf("failed to parse pool id: %w", err) + } + + auctionId, err := strconv.ParseUint(args[1], 10, 64) + if err != nil { + return fmt.Errorf("failed to auction pool id: %w", err) + } + + queryClient := types.NewQueryClient(clientCtx) + + res, err := queryClient.RewardsAuction(cmd.Context(), &types.QueryRewardsAuctionRequest{ + PoolId: poolId, + AuctionId: auctionId, + }) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +func NewQueryBidsCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "bids [pool-id]", + Args: cobra.ExactArgs(1), + Short: "Query all bids for the rewards auction", + Long: strings.TrimSpace( + fmt.Sprintf(`Query all bids for the rewards auction on a network. + +Example: +$ %s query %s bids 1 +`, + version.AppName, types.ModuleName, + ), + ), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + poolId, err := strconv.ParseUint(args[0], 10, 64) + if err != nil { + return fmt.Errorf("failed to parse pool id: %w", err) + } + + pageReq, err := client.ReadPageRequest(cmd.Flags()) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + res, err := queryClient.Bids(cmd.Context(), &types.QueryBidsRequest{ + PoolId: poolId, + Pagination: pageReq, + }) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +func NewQueryMintRateCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "mint-rate [pool-id]", + Args: cobra.ExactArgs(1), + Short: "Query the current mint rate for liquid farm", + Long: strings.TrimSpace( + fmt.Sprintf(`Query the current mint rate for liquid farm. + +Example: +$ %s query %s mint-rate 1 +`, + version.AppName, types.ModuleName, + ), + ), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + poolId, err := strconv.ParseUint(args[0], 10, 64) + if err != nil { + return fmt.Errorf("failed to parse pool id: %w", err) + } + + queryClient := types.NewQueryClient(clientCtx) + + res, err := queryClient.MintRate(cmd.Context(), &types.QueryMintRateRequest{ + PoolId: poolId, + }) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +func NewQueryBurnRateCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "burn-rate [pool-id]", + Args: cobra.ExactArgs(1), + Short: "Query the current burn rate for liquid farm", + Long: strings.TrimSpace( + fmt.Sprintf(`Query the current burn rate for liquid farm. + +Example: +$ %s query %s burn-rate 1 +`, + version.AppName, types.ModuleName, + ), + ), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + poolId, err := strconv.ParseUint(args[0], 10, 64) + if err != nil { + return fmt.Errorf("failed to parse pool id: %w", err) + } + + queryClient := types.NewQueryClient(clientCtx) + + res, err := queryClient.BurnRate(cmd.Context(), &types.QueryBurnRateRequest{ + PoolId: poolId, + }) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/liquidfarming/client/cli/tx.go b/x/liquidfarming/client/cli/tx.go new file mode 100644 index 00000000..2a18eaea --- /dev/null +++ b/x/liquidfarming/client/cli/tx.go @@ -0,0 +1,277 @@ +package cli + +import ( + "fmt" + "strconv" + "strings" + + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/version" + + "github.com/cosmosquad-labs/squad/v3/x/liquidfarming/types" +) + +// GetTxCmd returns the cli transaction commands for the module. +func GetTxCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: types.ModuleName, + Short: fmt.Sprintf("Transaction commands for the %s module", types.ModuleName), + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + cmd.AddCommand( + NewLiquidFarmCmd(), + NewLiquidUnfarmCmd(), + NewLiquidUnfarmAndWithdrawCmd(), + NewPlaceBidCmd(), + NewRefundBidCmd(), + ) + + return cmd + +} + +// NewLiquidFarmCmd implements the liquid farm command handler. +func NewLiquidFarmCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "liquid-farm [pool-id] [amount]", + Args: cobra.ExactArgs(2), + Short: "Liquid farm pool coin for auto compounding rewards and receive LFCoin by mint rate", + Long: strings.TrimSpace( + fmt.Sprintf(`Liquid farm pool coin for auto compounding and receive LFCoin by mint rate. +The module farms your pool coin to the farm module for you and auto compounds rewards for every auction period. +LFCoin opens up other opportunities to make profits like providing liquidity for lending protocol. + +Example: +$ %s tx %s liquid-farm 1 100000000pool1 --from mykey +`, + version.AppName, types.ModuleName, + ), + ), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + poolId, err := strconv.ParseUint(args[0], 10, 64) + if err != nil { + return fmt.Errorf("failed to parse pool id: %w", err) + } + + farmingCoin, err := sdk.ParseCoinNormalized(args[1]) + if err != nil { + return fmt.Errorf("invalid coin: %w", err) + } + + msg := types.NewMsgLiquidFarm( + poolId, + clientCtx.GetFromAddress().String(), + farmingCoin, + ) + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + +// NewLiquidUnfarmCmd implements the liquid unfarm command handler. +func NewLiquidUnfarmCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "liquid-unfarm [pool-id] [amount]", + Args: cobra.ExactArgs(2), + Short: "Liquid unfarm liquid farming coin (LFCoin) ", + Long: strings.TrimSpace( + fmt.Sprintf(`Liquid unfarm liquid farming coin (LFCoin) to receive corresponding pool coin by burn rate. + +Example: +$ %s tx %s liquid-unfarm 1 100000lf1 --from mykey +`, + version.AppName, types.ModuleName, + ), + ), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + poolId, err := strconv.ParseUint(args[0], 10, 64) + if err != nil { + return fmt.Errorf("failed to parse pool id: %w", err) + } + + unfarmingCoin, err := sdk.ParseCoinNormalized(args[1]) + if err != nil { + return fmt.Errorf("invalid coin: %w", err) + } + + msg := types.NewMsgLiquidUnfarm( + poolId, + clientCtx.GetFromAddress().String(), + unfarmingCoin, + ) + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + +// NewLiquidUnfarmAndWithdrawCmd implements the liquid unfarm and withdraw command handler. +func NewLiquidUnfarmAndWithdrawCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "liquid-unfarm-and-withdraw [pool-id] [amount]", + Args: cobra.ExactArgs(2), + Short: "Liquid unfarm liquid farming coin (LFCoin) and withdraw from the liquidity module", + Long: strings.TrimSpace( + fmt.Sprintf(`Liquid unfarm liquid farming coin (LFCoin) to receive corresponding pool coin by burn rate and withdraw from the liquidity module. + +Example: +$ %s tx %s liquid-unfarm-and-withdraw 1 100000lf1 --from mykey +`, + version.AppName, types.ModuleName, + ), + ), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + poolId, err := strconv.ParseUint(args[0], 10, 64) + if err != nil { + return fmt.Errorf("failed to parse pool id: %w", err) + } + + unfarmingCoin, err := sdk.ParseCoinNormalized(args[1]) + if err != nil { + return fmt.Errorf("invalid coin: %w", err) + } + + msg := types.NewMsgLiquidUnfarmAndWithdraw( + poolId, + clientCtx.GetFromAddress().String(), + unfarmingCoin, + ) + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + +// NewPlaceBidCmd implements the place bid command handler. +func NewPlaceBidCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "place-bid [auction-id] [pool-id] [amount]", + Args: cobra.ExactArgs(3), + Short: "Place a bid for a rewards auction", + Long: strings.TrimSpace( + fmt.Sprintf(`Place a bid for a rewards auction. + +Example: +$ %s tx %s place-bid 1 1 10000000pool1 --from mykey +`, + version.AppName, types.ModuleName, + ), + ), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + auctionId, err := strconv.ParseUint(args[0], 10, 64) + if err != nil { + return fmt.Errorf("failed to parse auctionId id: %w", err) + } + + poolId, err := strconv.ParseUint(args[1], 10, 64) + if err != nil { + return fmt.Errorf("failed to parse pool id: %w", err) + } + + amount, err := sdk.ParseCoinNormalized(args[2]) + if err != nil { + return fmt.Errorf("invalid bidding amount: %w", err) + } + + msg := types.NewMsgPlaceBid( + auctionId, + poolId, + clientCtx.GetFromAddress().String(), + amount, + ) + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + +// NewRefundBidCmd implements the refund bid command handler. +func NewRefundBidCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "refund-bid [auction-id] [pool-id]", + Args: cobra.ExactArgs(2), + Short: "Refund a bid", + Long: strings.TrimSpace( + fmt.Sprintf(`Refund a bid. + +Example: +$ %s tx %s refund-bid 1 1 --from mykey +`, + version.AppName, types.ModuleName, + ), + ), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + auctionId, err := strconv.ParseUint(args[0], 10, 64) + if err != nil { + return fmt.Errorf("failed to parse auctionId id: %w", err) + } + + poolId, err := strconv.ParseUint(args[1], 10, 64) + if err != nil { + return fmt.Errorf("failed to parse pool id: %w", err) + } + + msg := types.NewMsgRefundBid( + auctionId, + poolId, + clientCtx.GetFromAddress().String(), + ) + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} diff --git a/x/liquidfarming/client/testutil/cli_test.go b/x/liquidfarming/client/testutil/cli_test.go new file mode 100644 index 00000000..2a46d303 --- /dev/null +++ b/x/liquidfarming/client/testutil/cli_test.go @@ -0,0 +1,14 @@ +//go:build norace +// +build norace + +package testutil + +import ( + "testing" + + "github.com/stretchr/testify/suite" +) + +func TestIntegrationTestSuite(t *testing.T) { + suite.Run(t, new(IntegrationTestSuite)) +} diff --git a/x/liquidfarming/client/testutil/helpers.go b/x/liquidfarming/client/testutil/helpers.go new file mode 100644 index 00000000..b4d7a74a --- /dev/null +++ b/x/liquidfarming/client/testutil/helpers.go @@ -0,0 +1,40 @@ +package testutil + +import ( + "fmt" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/testutil" + clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/cosmosquad-labs/squad/v3/x/liquidfarming/client/cli" +) + +var commonArgs = []string{ + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewInt64Coin(sdk.DefaultBondDenom, 10)).String()), +} + +func MsgLiquidFarmExec(clientCtx client.Context, from, poolId string, amount sdk.Coin, extraArgs ...string) (testutil.BufferWriter, error) { + args := append(append([]string{ + poolId, + amount.String(), + fmt.Sprintf("--%s=%s", flags.FlagFrom, from), + }, commonArgs...), extraArgs...) + + return clitestutil.ExecTestCLICmd(clientCtx, cli.NewLiquidFarmCmd(), args) +} + +func MsgPlaceBidExec(clientCtx client.Context, from, auctionId, poolId string, amount sdk.Coin, extraArgs ...string) (testutil.BufferWriter, error) { + args := append(append([]string{ + auctionId, + poolId, + amount.String(), + fmt.Sprintf("--%s=%s", flags.FlagFrom, from), + }, commonArgs...), extraArgs...) + + return clitestutil.ExecTestCLICmd(clientCtx, cli.NewPlaceBidCmd(), args) +} diff --git a/x/liquidfarming/client/testutil/suite.go b/x/liquidfarming/client/testutil/suite.go new file mode 100644 index 00000000..24e5d8e8 --- /dev/null +++ b/x/liquidfarming/client/testutil/suite.go @@ -0,0 +1,690 @@ +package testutil + +import ( + "fmt" + "strconv" + "testing" + "time" + + "github.com/gogo/protobuf/proto" + "github.com/stretchr/testify/suite" + + "github.com/cosmos/cosmos-sdk/baseapp" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + servertypes "github.com/cosmos/cosmos-sdk/server/types" + "github.com/cosmos/cosmos-sdk/simapp" + store "github.com/cosmos/cosmos-sdk/store/types" + utilcli "github.com/cosmos/cosmos-sdk/testutil/cli" + "github.com/cosmos/cosmos-sdk/testutil/network" + sdk "github.com/cosmos/cosmos-sdk/types" + tmcli "github.com/tendermint/tendermint/libs/cli" + dbm "github.com/tendermint/tm-db" + + chain "github.com/cosmosquad-labs/squad/v3/app" + "github.com/cosmosquad-labs/squad/v3/app/params" + utils "github.com/cosmosquad-labs/squad/v3/types" + "github.com/cosmosquad-labs/squad/v3/x/liquidfarming/client/cli" + "github.com/cosmosquad-labs/squad/v3/x/liquidfarming/types" + liquiditytestutil "github.com/cosmosquad-labs/squad/v3/x/liquidity/client/testutil" + liquiditytypes "github.com/cosmosquad-labs/squad/v3/x/liquidity/types" +) + +type IntegrationTestSuite struct { + suite.Suite + + cfg network.Config + network *network.Network + val *network.Validator + clientCtx client.Context + + denom1, denom2 string +} + +func NewAppConstructor(encodingCfg params.EncodingConfig) network.AppConstructor { + return func(val network.Validator) servertypes.Application { + return chain.NewApp( + val.Ctx.Logger, dbm.NewMemDB(), nil, true, make(map[int64]bool), val.Ctx.Config.RootDir, 0, + encodingCfg, + simapp.EmptyAppOptions{}, + baseapp.SetPruning(store.NewPruningOptionsFromString(val.AppConfig.Pruning)), + baseapp.SetMinGasPrices(val.AppConfig.MinGasPrices), + ) + } +} + +// SetupTest creates a new network for _each_ integration test. We create a new +// network for each test because there are some state modifications that are +// needed to be made in order to make useful queries. However, we don't want +// these state changes to be present in other tests. +func (s *IntegrationTestSuite) SetupTest() { + s.T().Log("setting up integration test suite") + + if testing.Short() { + s.T().Skip("skipping test in unit-tests mode.") + } + + encCfg := chain.MakeTestEncodingConfig() + + cfg := network.DefaultConfig() + cfg.AppConstructor = NewAppConstructor(encCfg) + cfg.GenesisState = chain.ModuleBasics.DefaultGenesis(cfg.Codec) + cfg.NumValidators = 1 + + var genesisState types.GenesisState + err := cfg.Codec.UnmarshalJSON(cfg.GenesisState[types.ModuleName], &genesisState) + s.Require().NoError(err) + + genesisState.Params = types.DefaultParams() + genesisState.Params.RewardsAuctionDuration = 1 * time.Hour + genesisState.Params.LiquidFarms = []types.LiquidFarm{ + { + PoolId: 1, + MinFarmAmount: sdk.NewInt(100_000), + MinBidAmount: sdk.NewInt(100_000), + }, + } + genesisState.LastRewardsAuctionIdRecord = []types.LastRewardsAuctionIdRecord{ + { + PoolId: 1, + AuctionId: 1, + }, + } + genesisState.RewardsAuctions = []types.RewardsAuction{ + { + Id: 1, + PoolId: 1, + BiddingCoinDenom: liquiditytypes.PoolCoinDenom(1), + PayingReserveAddress: types.PayingReserveAddress(1).String(), + StartTime: utils.ParseTime("0001-01-01T00:00:00Z"), + EndTime: utils.ParseTime("9999-12-31T23:59:59Z"), + Status: types.AuctionStatusStarted, + }, + } + cfg.GenesisState[types.ModuleName] = cfg.Codec.MustMarshalJSON(&genesisState) + + s.cfg = cfg + s.network = network.New(s.T(), cfg) + + s.val = s.network.Validators[0] + s.clientCtx = s.val.ClientCtx + + s.denom1, s.denom2 = fmt.Sprintf("%stoken", s.val.Moniker), s.cfg.BondDenom + + s.createPair(s.denom1, s.denom2) + s.createPool(1, sdk.NewCoins(sdk.NewInt64Coin(s.denom1, 10_000_000), sdk.NewInt64Coin(s.denom2, 10_000_000))) + + _, err = s.network.WaitForHeight(1) + s.Require().NoError(err) +} + +// TearDownTest cleans up the current test network after each test in the suite. +func (s *IntegrationTestSuite) TearDownTest() { + s.T().Log("tearing down integration test suite") + s.network.Cleanup() +} + +// +// Helper functions +// + +func (s *IntegrationTestSuite) createPair(baseCoinDenom, quoteCoinDenom string) { + _, err := liquiditytestutil.MsgCreatePair(s.clientCtx, s.val.Address.String(), baseCoinDenom, quoteCoinDenom) + s.Require().NoError(err) + + err = s.network.WaitForNextBlock() + s.Require().NoError(err) +} + +func (s *IntegrationTestSuite) createPool(pairId uint64, depositCoins sdk.Coins) { + _, err := liquiditytestutil.MsgCreatePool(s.clientCtx, s.val.Address.String(), pairId, depositCoins) + s.Require().NoError(err) + + err = s.network.WaitForNextBlock() + s.Require().NoError(err) +} + +// +// Query CLI Integration Tests +// + +func (s *IntegrationTestSuite) TestNewQueryParamsCmd() { + val := s.network.Validators[0] + clientCtx := val.ClientCtx + + testCases := []struct { + name string + args []string + expectErr bool + }{ + { + "happy case", + []string{fmt.Sprintf("--%s=json", tmcli.OutputFlag)}, + false, + }, + { + "with specific height", + []string{fmt.Sprintf("--%s=1", flags.FlagHeight), fmt.Sprintf("--%s=json", tmcli.OutputFlag)}, + false, + }, + } + + for _, tc := range testCases { + s.Run(tc.name, func() { + cmd := cli.NewQueryParamsCmd() + + out, err := utilcli.ExecTestCLICmd(clientCtx, cmd, tc.args) + if tc.expectErr { + s.Require().Error(err) + s.Require().NotEqual("internal", err.Error()) + } else { + s.Require().NoError(err) + + var params types.Params + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), ¶ms)) + s.Require().NotEmpty(params.LiquidFarms) + } + }) + } +} + +func (s *IntegrationTestSuite) TestNewQueryLiquidFarmsCmd() { + val := s.network.Validators[0] + clientCtx := val.ClientCtx + + testCases := []struct { + name string + args []string + expectErr bool + postRun func(*types.QueryLiquidFarmsResponse) + }{ + { + "happy case", + []string{ + fmt.Sprintf("--%s=json", tmcli.OutputFlag), + }, + false, + func(resp *types.QueryLiquidFarmsResponse) { + s.Require().Len(resp.LiquidFarms, 1) + s.Require().Equal(uint64(1), resp.LiquidFarms[0].PoolId) + s.Require().Equal(types.LiquidFarmCoinDenom(1), resp.LiquidFarms[0].LFCoinDenom) + s.Require().Equal(sdk.NewInt(100_000), resp.LiquidFarms[0].MinFarmAmount) + s.Require().Equal(sdk.NewInt(100_000), resp.LiquidFarms[0].MinBidAmount) + }, + }, + { + "with specific height", + []string{ + fmt.Sprintf("--%s=1", flags.FlagHeight), + fmt.Sprintf("--%s=json", tmcli.OutputFlag), + }, + false, + func(resp *types.QueryLiquidFarmsResponse) { + s.Require().Len(resp.LiquidFarms, 1) + s.Require().Equal(uint64(1), resp.LiquidFarms[0].PoolId) + s.Require().Equal(types.LiquidFarmCoinDenom(1), resp.LiquidFarms[0].LFCoinDenom) + s.Require().Equal(sdk.NewInt(100_000), resp.LiquidFarms[0].MinFarmAmount) + s.Require().Equal(sdk.NewInt(100_000), resp.LiquidFarms[0].MinBidAmount) + }, + }, + } + + for _, tc := range testCases { + s.Run(tc.name, func() { + cmd := cli.NewQueryLiquidFarmsCmd() + + out, err := utilcli.ExecTestCLICmd(clientCtx, cmd, tc.args) + if tc.expectErr { + s.Require().Error(err) + } else { + s.Require().NoError(err) + var resp types.QueryLiquidFarmsResponse + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &resp), out.String()) + tc.postRun(&resp) + } + }) + } +} + +func (s *IntegrationTestSuite) TestNewQueryLiquidFarmCmd() { + val := s.network.Validators[0] + clientCtx := val.ClientCtx + + testCases := []struct { + name string + args []string + expectErr bool + postRun func(*types.QueryLiquidFarmResponse) + }{ + { + "happy case", + []string{ + strconv.Itoa(1), + fmt.Sprintf("--%s=json", tmcli.OutputFlag), + }, + false, + func(resp *types.QueryLiquidFarmResponse) { + s.Require().Equal(uint64(1), resp.LiquidFarm.PoolId) + s.Require().Equal(sdk.NewInt(100_000), resp.LiquidFarm.MinFarmAmount) + s.Require().Equal(sdk.NewInt(100_000), resp.LiquidFarm.MinBidAmount) + }, + }, + { + "with specific height", + []string{ + strconv.Itoa(1), + fmt.Sprintf("--%s=1", flags.FlagHeight), + fmt.Sprintf("--%s=json", tmcli.OutputFlag), + }, + false, + func(resp *types.QueryLiquidFarmResponse) { + s.Require().Equal(uint64(1), resp.LiquidFarm.PoolId) + s.Require().Equal(sdk.NewInt(100_000), resp.LiquidFarm.MinFarmAmount) + s.Require().Equal(sdk.NewInt(100_000), resp.LiquidFarm.MinBidAmount) + }, + }, + { + "pool id not found", + []string{ + strconv.Itoa(10), + fmt.Sprintf("--%s=json", tmcli.OutputFlag), + }, + true, + nil, + }, + } + + for _, tc := range testCases { + s.Run(tc.name, func() { + cmd := cli.NewQueryLiquidFarmCmd() + + out, err := utilcli.ExecTestCLICmd(clientCtx, cmd, tc.args) + if tc.expectErr { + s.Require().Error(err) + } else { + s.Require().NoError(err) + var resp types.QueryLiquidFarmResponse + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &resp), out.String()) + tc.postRun(&resp) + } + }) + } +} + +func (s *IntegrationTestSuite) TestNewQueryRewardsAuctionsCmd() { + val := s.network.Validators[0] + clientCtx := val.ClientCtx + + testCases := []struct { + name string + args []string + expectErr bool + postRun func(*types.QueryRewardsAuctionsResponse) + }{ + { + "happy case", + []string{ + strconv.Itoa(1), + fmt.Sprintf("--%s=json", tmcli.OutputFlag), + }, + false, + func(resp *types.QueryRewardsAuctionsResponse) { + s.Require().Len(resp.RewardAuctions, 1) + s.Require().Equal(uint64(1), resp.RewardAuctions[0].Id) + s.Require().Equal(uint64(1), resp.RewardAuctions[0].PoolId) + s.Require().Equal(types.AuctionStatusStarted, resp.RewardAuctions[0].Status) + }, + }, + } + + for _, tc := range testCases { + s.Run(tc.name, func() { + cmd := cli.NewQueryRewardsAuctionsCmd() + + out, err := utilcli.ExecTestCLICmd(clientCtx, cmd, tc.args) + if tc.expectErr { + s.Require().Error(err) + } else { + s.Require().NoError(err) + var resp types.QueryRewardsAuctionsResponse + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &resp), out.String()) + tc.postRun(&resp) + } + }) + } +} + +func (s *IntegrationTestSuite) TestNewQueryRewardsAuctionCmd() { + val := s.network.Validators[0] + clientCtx := val.ClientCtx + + testCases := []struct { + name string + args []string + expectErr bool + postRun func(*types.QueryRewardsAuctionResponse) + }{ + { + "happy case", + []string{ + strconv.Itoa(1), + strconv.Itoa(1), + fmt.Sprintf("--%s=json", tmcli.OutputFlag), + }, + false, + func(resp *types.QueryRewardsAuctionResponse) { + s.Require().Equal(uint64(1), resp.RewardAuction.Id) + s.Require().Equal(uint64(1), resp.RewardAuction.PoolId) + s.Require().Equal(types.AuctionStatusStarted, resp.RewardAuction.Status) + }, + }, + } + + for _, tc := range testCases { + s.Run(tc.name, func() { + cmd := cli.NewQueryRewardsAuctionCmd() + + out, err := utilcli.ExecTestCLICmd(clientCtx, cmd, tc.args) + if tc.expectErr { + s.Require().Error(err) + } else { + s.Require().NoError(err) + var resp types.QueryRewardsAuctionResponse + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &resp), out.String()) + tc.postRun(&resp) + } + }) + } +} + +// +// Transaction CLI Integration Tests +// + +func (s *IntegrationTestSuite) TestNewLiquidFarmCmd() { + val := s.network.Validators[0] + + testCases := []struct { + name string + args []string + expectErr bool + respType proto.Message + expectedCode uint32 + }{ + { + "happy case", + []string{ + strconv.Itoa(1), + sdk.NewInt64Coin(liquiditytypes.PoolCoinDenom(1), 1_000_000).String(), + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewInt64Coin(s.cfg.BondDenom, 10)).String()), + }, + false, &sdk.TxResponse{}, 0, + }, + { + "invalid case: invalid denom", + []string{ + strconv.Itoa(1), + sdk.NewInt64Coin(s.denom1, 1_000_000).String(), + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewInt64Coin(s.cfg.BondDenom, 10)).String()), + }, + true, &sdk.TxResponse{}, 18, + }, + { + "invalid case: minimum farm amount", + []string{ + strconv.Itoa(1), + sdk.NewInt64Coin(liquiditytypes.PoolCoinDenom(1), 100).String(), + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewInt64Coin(s.cfg.BondDenom, 10)).String()), + }, + false, &sdk.TxResponse{}, 2, + }, + { + "invalid case: pool id not found", + []string{ + strconv.Itoa(10), + sdk.NewInt64Coin(liquiditytypes.PoolCoinDenom(10), 1_000_000).String(), + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewInt64Coin(s.cfg.BondDenom, 10)).String()), + }, + false, &sdk.TxResponse{}, 38, + }, + } + + for _, tc := range testCases { + tc := tc + + s.Run(tc.name, func() { + cmd := cli.NewLiquidFarmCmd() + clientCtx := val.ClientCtx + + out, err := utilcli.ExecTestCLICmd(clientCtx, cmd, tc.args) + + if tc.expectErr { + s.Require().Error(err) + } else { + s.Require().NoError(err, out.String()) + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + + txResp := tc.respType.(*sdk.TxResponse) + s.Require().Equal(tc.expectedCode, txResp.Code, out.String()) + } + }) + } +} + +func (s *IntegrationTestSuite) TestNewUnfarmCmd() { + val := s.network.Validators[0] + + _, err := MsgLiquidFarmExec( + val.ClientCtx, + val.Address.String(), + strconv.Itoa(1), + sdk.NewInt64Coin(liquiditytypes.PoolCoinDenom(1), 100_000_000), + ) + s.Require().NoError(err) + + testCases := []struct { + name string + args []string + expectErr bool + respType proto.Message + expectedCode uint32 + }{ + { + "happy case", + []string{ + strconv.Itoa(1), + sdk.NewInt64Coin(types.LiquidFarmCoinDenom(1), 1_000_000).String(), + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewInt64Coin(s.cfg.BondDenom, 10)).String()), + }, + false, &sdk.TxResponse{}, 0, + }, + { + "invalid case: invalid denom", + []string{ + strconv.Itoa(1), + sdk.NewInt64Coin(s.denom1, 1_000_000).String(), + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewInt64Coin(s.cfg.BondDenom, 10)).String()), + }, + true, &sdk.TxResponse{}, 0, + }, + { + "invalid case: pool id not found", + []string{ + strconv.Itoa(10), + sdk.NewInt64Coin(types.LiquidFarmCoinDenom(10), 1_000_000).String(), + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewInt64Coin(s.cfg.BondDenom, 10)).String()), + }, + false, &sdk.TxResponse{}, 38, + }, + } + + for _, tc := range testCases { + tc := tc + + s.Run(tc.name, func() { + cmd := cli.NewLiquidUnfarmCmd() + clientCtx := val.ClientCtx + + out, err := utilcli.ExecTestCLICmd(clientCtx, cmd, tc.args) + + if tc.expectErr { + s.Require().Error(err) + } else { + s.Require().NoError(err, out.String()) + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + + txResp := tc.respType.(*sdk.TxResponse) + s.Require().Equal(tc.expectedCode, txResp.Code, out.String()) + } + }) + } +} + +func (s *IntegrationTestSuite) TestNewPlaceBidCmd() { + val := s.network.Validators[0] + + testCases := []struct { + name string + args []string + expectErr bool + respType proto.Message + expectedCode uint32 + }{ + { + "happy case", + []string{ + strconv.Itoa(1), + strconv.Itoa(1), + sdk.NewInt64Coin(liquiditytypes.PoolCoinDenom(1), 1_000_000).String(), + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewInt64Coin(s.cfg.BondDenom, 10)).String()), + }, + false, &sdk.TxResponse{}, 0, + }, + { + "invalid case: minimum bid amount", + []string{ + strconv.Itoa(1), + strconv.Itoa(1), + sdk.NewInt64Coin(liquiditytypes.PoolCoinDenom(1), 100).String(), + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewInt64Coin(s.cfg.BondDenom, 10)).String()), + }, + false, &sdk.TxResponse{}, 2, + }, + { + "invalid case: invalid bidding coin denom", + []string{ + strconv.Itoa(1), + strconv.Itoa(1), + sdk.NewInt64Coin(s.denom1, 1_000_000).String(), + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewInt64Coin(s.cfg.BondDenom, 10)).String()), + }, + true, &sdk.TxResponse{}, 0, + }, + } + + for _, tc := range testCases { + tc := tc + + s.Run(tc.name, func() { + cmd := cli.NewPlaceBidCmd() + clientCtx := val.ClientCtx + + out, err := utilcli.ExecTestCLICmd(clientCtx, cmd, tc.args) + + if tc.expectErr { + s.Require().Error(err) + } else { + s.Require().NoError(err, out.String()) + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + + txResp := tc.respType.(*sdk.TxResponse) + s.Require().Equal(tc.expectedCode, txResp.Code, out.String()) + } + }) + } +} + +func (s *IntegrationTestSuite) TestNewRefundBidCmd() { + val := s.network.Validators[0] + + _, err := MsgPlaceBidExec( + val.ClientCtx, + val.Address.String(), + strconv.Itoa(1), + strconv.Itoa(1), + sdk.NewInt64Coin(liquiditytypes.PoolCoinDenom(1), 10_000_000), + ) + s.Require().NoError(err) + + testCases := []struct { + name string + args []string + expectErr bool + respType proto.Message + expectedCode uint32 + }{ + { + "invalid case", + []string{ + strconv.Itoa(1), + strconv.Itoa(1), + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewInt64Coin(s.cfg.BondDenom, 10)).String()), + }, + false, &sdk.TxResponse{}, 18, + }, + } + + for _, tc := range testCases { + tc := tc + + s.Run(tc.name, func() { + cmd := cli.NewRefundBidCmd() + clientCtx := val.ClientCtx + + out, err := utilcli.ExecTestCLICmd(clientCtx, cmd, tc.args) + + if tc.expectErr { + s.Require().Error(err) + } else { + s.Require().NoError(err, out.String()) + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + + txResp := tc.respType.(*sdk.TxResponse) + s.Require().Equal(tc.expectedCode, txResp.Code, out.String()) + } + }) + } +} diff --git a/x/liquidfarming/handler.go b/x/liquidfarming/handler.go new file mode 100644 index 00000000..9e81c014 --- /dev/null +++ b/x/liquidfarming/handler.go @@ -0,0 +1,45 @@ +package liquidfarming + +import ( + "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + + "github.com/cosmosquad-labs/squad/v3/x/liquidfarming/keeper" + "github.com/cosmosquad-labs/squad/v3/x/liquidfarming/types" +) + +// NewHandler returns a new msg handler. +func NewHandler(k keeper.Keeper) sdk.Handler { + msgServer := keeper.NewMsgServerImpl(k) + + return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { + ctx = ctx.WithEventManager(sdk.NewEventManager()) + + switch msg := msg.(type) { + case *types.MsgLiquidFarm: + res, err := msgServer.LiquidFarm(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + + case *types.MsgLiquidUnfarm: + res, err := msgServer.LiquidUnfarm(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + + case *types.MsgLiquidUnfarmAndWithdraw: + res, err := msgServer.LiquidUnfarmAndWithdraw(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + + case *types.MsgPlaceBid: + res, err := msgServer.PlaceBid(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + + case *types.MsgRefundBid: + res, err := msgServer.RefundBid(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + + default: + return nil, sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, fmt.Sprintf("unrecognized %s message type: %T", types.ModuleName, msg)) + } + } +} diff --git a/x/liquidfarming/keeper/auction.go b/x/liquidfarming/keeper/auction.go new file mode 100644 index 00000000..8861a0d2 --- /dev/null +++ b/x/liquidfarming/keeper/auction.go @@ -0,0 +1,220 @@ +package keeper + +import ( + "strconv" + "time" + + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + + "github.com/cosmosquad-labs/squad/v3/x/liquidfarming/types" + liquiditytypes "github.com/cosmosquad-labs/squad/v3/x/liquidity/types" +) + +// PlaceBid handles types.MsgPlaceBid and stores bid object. +func (k Keeper) PlaceBid(ctx sdk.Context, auctionId uint64, poolId uint64, bidder sdk.AccAddress, biddingCoin sdk.Coin) (types.Bid, error) { + liquidFarm, found := k.GetLiquidFarm(ctx, poolId) + if !found { + return types.Bid{}, sdkerrors.Wrapf(sdkerrors.ErrNotFound, "liquid farm by pool %d not found", poolId) + } + + auction, found := k.GetRewardsAuction(ctx, auctionId, poolId) + if !found { + return types.Bid{}, sdkerrors.Wrapf(sdkerrors.ErrNotFound, "auction by pool %d not found", poolId) + } + + if auction.BiddingCoinDenom != biddingCoin.Denom { + return types.Bid{}, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "expected denom %s, but got %s", auction.BiddingCoinDenom, biddingCoin.Denom) + } + + if biddingCoin.Amount.LT(liquidFarm.MinBidAmount) { + return types.Bid{}, sdkerrors.Wrapf(types.ErrSmallerThanMinimumAmount, "%s is smaller than %s", biddingCoin.Amount, liquidFarm.MinBidAmount) + } + + winningBid, found := k.GetWinningBid(ctx, auctionId, poolId) + if found { + if biddingCoin.Amount.LTE(winningBid.Amount.Amount) { + return types.Bid{}, sdkerrors.Wrapf(types.ErrNotBiggerThanWinningBidAmount, "%s is not bigger than %s", biddingCoin.Amount, winningBid.Amount.Amount) + } + } + + // Refund the previous bid if exists + previousBid, found := k.GetBid(ctx, auctionId, bidder) + if found { + if err := k.bankKeeper.SendCoins(ctx, auction.GetPayingReserveAddress(), previousBid.GetBidder(), sdk.NewCoins(previousBid.Amount)); err != nil { + return types.Bid{}, err + } + k.DeleteBid(ctx, previousBid) + } + + if err := k.bankKeeper.SendCoins(ctx, bidder, auction.GetPayingReserveAddress(), sdk.NewCoins(biddingCoin)); err != nil { + return types.Bid{}, err + } + + bid := types.NewBid( + poolId, + bidder.String(), + biddingCoin, + ) + k.SetBid(ctx, bid) + k.SetWinningBid(ctx, auction.Id, bid) + + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + types.EventTypePlaceBid, + sdk.NewAttribute(types.AttributeKeyPoolId, strconv.FormatUint(poolId, 10)), + sdk.NewAttribute(types.AttributeKeyAuctionId, strconv.FormatUint(auction.Id, 10)), + sdk.NewAttribute(types.AttributeKeyBidder, bidder.String()), + sdk.NewAttribute(types.AttributeKeyBiddingCoin, biddingCoin.String()), + ), + }) + + return bid, nil +} + +// RefundBid handles types.MsgRefundBid and refunds bid amount to the bidder and +// delete the bid object. +func (k Keeper) RefundBid(ctx sdk.Context, auctionId uint64, poolId uint64, bidder sdk.AccAddress) error { + auction, found := k.GetRewardsAuction(ctx, auctionId, poolId) + if !found { + return sdkerrors.Wrapf(sdkerrors.ErrNotFound, "auction by pool %d not found", poolId) + } + + winningBid, found := k.GetWinningBid(ctx, auctionId, poolId) + if found && winningBid.Bidder == bidder.String() { + return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "winning bid can't be refunded") + } + + bid, found := k.GetBid(ctx, poolId, bidder) + if !found { + return sdkerrors.Wrap(sdkerrors.ErrNotFound, "bid not found") + } + + if err := k.bankKeeper.SendCoins(ctx, auction.GetPayingReserveAddress(), bidder, sdk.NewCoins(bid.Amount)); err != nil { + return err + } + + k.DeleteBid(ctx, bid) + + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + types.EventTypeRefundBid, + sdk.NewAttribute(types.AttributeKeyPoolId, strconv.FormatUint(poolId, 10)), + sdk.NewAttribute(types.AttributeKeyBidder, bidder.String()), + sdk.NewAttribute(types.AttributeKeyRefundCoin, bid.Amount.String()), + ), + }) + + return nil +} + +// getNextAuctionIdWithUpdate increments rewards auction id by one and store it. +func (k Keeper) getNextAuctionIdWithUpdate(ctx sdk.Context, poolId uint64) uint64 { + id := k.GetLastRewardsAuctionId(ctx, poolId) + 1 + k.SetLastRewardsAuctionId(ctx, id, poolId) + return id +} + +// CreateRewardsAuction creates new rewards auction and store it. +func (k Keeper) CreateRewardsAuction(ctx sdk.Context, poolId uint64, duration time.Duration) { + nextAuctionId := k.getNextAuctionIdWithUpdate(ctx, poolId) + poolCoinDenom := liquiditytypes.PoolCoinDenom(poolId) + startTime := ctx.BlockTime() + endTime := startTime.Add(duration) + k.SetRewardsAuction(ctx, types.NewRewardsAuction( + nextAuctionId, + poolId, + poolCoinDenom, + startTime, + endTime, + )) +} + +// RefundAllBids refunds all bids at once as the rewards auction is finished and delete all bids. +func (k Keeper) RefundAllBids(ctx sdk.Context, auction types.RewardsAuction, includeWinningBid bool) error { + winningBid, found := k.GetWinningBid(ctx, auction.Id, auction.PoolId) + if !found { + winningBid = types.Bid{} + } + + inputs := []banktypes.Input{} + outputs := []banktypes.Output{} + for _, bid := range k.GetBidsByPoolId(ctx, auction.PoolId) { + if includeWinningBid || bid.Bidder != winningBid.Bidder { + inputs = append(inputs, banktypes.NewInput(auction.GetPayingReserveAddress(), sdk.NewCoins(bid.Amount))) + outputs = append(outputs, banktypes.NewOutput(bid.GetBidder(), sdk.NewCoins(bid.Amount))) + } + k.DeleteBid(ctx, bid) + } + if err := k.bankKeeper.InputOutputCoins(ctx, inputs, outputs); err != nil { + return err + } + + return nil +} + +// FinishRewardsAuction finishes the ongoing rewards auction. +func (k Keeper) FinishRewardsAuction(ctx sdk.Context, auction types.RewardsAuction, feeRate sdk.Dec) error { + liquidFarmReserveAddr := types.LiquidFarmReserveAddress(auction.PoolId) + auctionPayingReserveAddr := auction.GetPayingReserveAddress() + poolCoinDenom := liquiditytypes.PoolCoinDenom(auction.PoolId) + position, found := k.farmKeeper.GetPosition(ctx, liquidFarmReserveAddr, poolCoinDenom) + if !found { + position.FarmingAmount = sdk.ZeroInt() // TODO: develop simulation and debug + } + rewards := k.farmKeeper.Rewards(ctx, liquidFarmReserveAddr, poolCoinDenom) + truncatedRewards, _ := rewards.TruncateDecimal() + + var ( + compoundingRewards types.CompoundingRewards + status types.AuctionStatus + ) + + // Finishing rewards auction can have two different scenarios depending on winning bid existence + // When there is winning bid, harvest farming rewards first and send them to the winner and + // stake the winning bid amount in the farming module for farmers so that it acts as auto compounding functionality. + winningBid, found := k.GetWinningBid(ctx, auction.Id, auction.PoolId) + if found { + if _, err := k.farmKeeper.Harvest(ctx, liquidFarmReserveAddr, poolCoinDenom); err != nil { + return err + } + + deducted, err := types.DeductFees(auction.PoolId, truncatedRewards, feeRate) + if err != nil { + return err + } + + if err := k.bankKeeper.SendCoins(ctx, liquidFarmReserveAddr, winningBid.GetBidder(), deducted); err != nil { + return err + } + + if err := k.RefundAllBids(ctx, auction, false); err != nil { + return err + } + + if err := k.bankKeeper.SendCoins(ctx, auctionPayingReserveAddr, liquidFarmReserveAddr, sdk.NewCoins(winningBid.Amount)); err != nil { + return err + } + + if _, err := k.farmKeeper.Farm(ctx, liquidFarmReserveAddr, winningBid.Amount); err != nil { + return err + } + + k.DeleteWinningBid(ctx, auction.Id, auction.PoolId) + compoundingRewards.Amount = winningBid.Amount.Amount + status = types.AuctionStatusFinished + } else { + compoundingRewards.Amount = sdk.ZeroInt() + status = types.AuctionStatusSkipped + } + + auction.SetWinner(winningBid.Bidder) + auction.SetWinningAmount(winningBid.Amount) + auction.SetRewards(truncatedRewards) + auction.SetStatus(status) + k.SetCompoundingRewards(ctx, auction.PoolId, compoundingRewards) + k.SetRewardsAuction(ctx, auction) + + return nil +} diff --git a/x/liquidfarming/keeper/auction_test.go b/x/liquidfarming/keeper/auction_test.go new file mode 100644 index 00000000..76f60431 --- /dev/null +++ b/x/liquidfarming/keeper/auction_test.go @@ -0,0 +1,286 @@ +package keeper_test + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + utils "github.com/cosmosquad-labs/squad/v3/types" + farmtypes "github.com/cosmosquad-labs/squad/v3/x/farm/types" + "github.com/cosmosquad-labs/squad/v3/x/liquidfarming/types" + + _ "github.com/stretchr/testify/suite" +) + +func (s *KeeperTestSuite) TestPlaceBid_Validation() { + pair := s.createPair(s.addr(0), "denom1", "denom2") + pool := s.createPool(s.addr(0), pair.Id, utils.ParseCoins("100_000_000denom1, 100_000_000denom2")) + + s.createLiquidFarm(pool.Id, sdk.ZeroInt(), sdk.NewInt(1_000_000), sdk.ZeroDec()) + + s.liquidFarm(pool.Id, s.addr(0), utils.ParseCoin("10_000_000pool1"), true) + s.nextBlock() + + s.createRewardsAuction(pool.Id) + + auctionId := s.keeper.GetLastRewardsAuctionId(s.ctx, pool.Id) + auction, found := s.keeper.GetRewardsAuction(s.ctx, auctionId, pool.Id) + s.Require().True(found) + + s.placeBid(pool.Id, s.addr(1), utils.ParseCoin("10_000_000pool1"), true) + s.nextBlock() + + s.placeBid(pool.Id, s.addr(2), utils.ParseCoin("15_000_000pool1"), true) + s.nextBlock() + + s.Require().Len(s.keeper.GetBidsByPoolId(s.ctx, pool.Id), 2) + + s.fundAddr(s.addr(5), utils.ParseCoins("100pool1")) + + for _, tc := range []struct { + name string + msg *types.MsgPlaceBid + postRun func(ctx sdk.Context, bid types.Bid) + expectedErr string + }{ + { + "happy case", + types.NewMsgPlaceBid( + auction.Id, + auction.PoolId, + s.addr(0).String(), + sdk.NewInt64Coin(pool.PoolCoinDenom, 30_000_000), + ), + func(ctx sdk.Context, bid types.Bid) { + s.Require().Equal(pool.Id, bid.PoolId) + s.Require().Equal(s.addr(0), bid.GetBidder()) + s.Require().Equal(sdk.NewInt64Coin(pool.PoolCoinDenom, 30_000_000), bid.Amount) + }, + "", + }, + { + "insufficient funds", + types.NewMsgPlaceBid( + auction.Id, + auction.PoolId, + s.addr(5).String(), + sdk.NewInt64Coin(pool.PoolCoinDenom, 30_000_000), + ), + nil, + "100pool1 is smaller than 30000000pool1: insufficient funds", + }, + { + "minimum bid amount", + types.NewMsgPlaceBid( + auction.Id, + auction.PoolId, + s.addr(5).String(), + sdk.NewInt64Coin(pool.PoolCoinDenom, 100), + ), + nil, + "100 is smaller than 1000000: smaller than the minimum amount", + }, + } { + s.Run(tc.name, func() { + s.Require().NoError(tc.msg.ValidateBasic()) + cacheCtx, _ := s.ctx.CacheContext() + + bid, err := s.keeper.PlaceBid(cacheCtx, tc.msg.AuctionId, tc.msg.PoolId, tc.msg.GetBidder(), tc.msg.BiddingCoin) + if tc.expectedErr == "" { + s.Require().NoError(err) + bid, found := s.keeper.GetBid(cacheCtx, bid.PoolId, bid.GetBidder()) + s.Require().True(found) + tc.postRun(cacheCtx, bid) + } else { + s.Require().EqualError(err, tc.expectedErr) + } + }) + } +} + +func (s *KeeperTestSuite) TestPlaceBid() { + pair := s.createPair(s.addr(0), "denom1", "denom2") + pool := s.createPool(s.addr(0), pair.Id, utils.ParseCoins("100_000_000denom1, 100_000_000denom2")) + + _, err := s.keeper.PlaceBid(s.ctx, 1, pool.Id, s.addr(0), sdk.NewInt64Coin(pool.PoolCoinDenom, 100_000_000)) + s.Require().EqualError(err, "liquid farm by pool 1 not found: not found") + + s.createLiquidFarm(pool.Id, sdk.NewInt(10_000_000), sdk.NewInt(10_000_000), sdk.ZeroDec()) + + s.liquidFarm(pool.Id, s.addr(0), utils.ParseCoin("10_000_000pool1"), true) + s.nextBlock() + + _, err = s.keeper.PlaceBid(s.ctx, 1, pool.Id, s.addr(0), sdk.NewInt64Coin(pool.PoolCoinDenom, 100_000_000)) + s.Require().EqualError(err, "auction by pool 1 not found: not found") + + // Create the first auction + s.nextAuction() + + var ( + bidderAddr1 = s.addr(1) + bidderAddr2 = s.addr(2) + ) + + s.fundAddr(bidderAddr1, utils.ParseCoins("250_000_000pool1")) + s.fundAddr(bidderAddr2, utils.ParseCoins("100_000_000pool1")) + + auctionId := s.keeper.GetLastRewardsAuctionId(s.ctx, pool.Id) + + // Place a bid successfully + _, err = s.keeper.PlaceBid(s.ctx, auctionId, pool.Id, bidderAddr1, sdk.NewInt64Coin(pool.PoolCoinDenom, 100_000_000)) + s.Require().NoError(err) + + // Place with higher bidding amount + _, err = s.keeper.PlaceBid(s.ctx, auctionId, pool.Id, bidderAddr1, sdk.NewInt64Coin(pool.PoolCoinDenom, 150_000_000)) + s.Require().NoError(err) + + // Ensure the refunded amount + s.Require().Equal(sdk.NewInt(100_000_000), s.getBalance(bidderAddr1, pool.PoolCoinDenom).Amount) + + // Place a bid with less than the winning bid amount + _, err = s.keeper.PlaceBid(s.ctx, auctionId, pool.Id, bidderAddr2, sdk.NewInt64Coin(pool.PoolCoinDenom, 90_000_000)) + s.Require().EqualError(err, "90000000 is not bigger than 150000000: not bigger than the winning bid amount") +} + +func (s *KeeperTestSuite) TestRefundBid() { + pair := s.createPair(s.addr(0), "denom1", "denom2") + pool := s.createPool(s.addr(0), pair.Id, utils.ParseCoins("100_000_000denom1, 100_000_000denom2")) + + s.createLiquidFarm(pool.Id, sdk.NewInt(10_000_000), sdk.NewInt(10_000_000), sdk.ZeroDec()) + s.createRewardsAuction(pool.Id) + + auctionId := s.keeper.GetLastRewardsAuctionId(s.ctx, pool.Id) + + s.placeBid(pool.Id, s.addr(0), sdk.NewInt64Coin(pool.PoolCoinDenom, 500_000_000), true) + s.placeBid(pool.Id, s.addr(1), sdk.NewInt64Coin(pool.PoolCoinDenom, 600_000_000), true) + + for _, tc := range []struct { + name string + msg *types.MsgRefundBid + postRun func(ctx sdk.Context, bid types.Bid) + expectedErr string + }{ + { + "happy case", + types.NewMsgRefundBid( + auctionId, + pool.Id, + s.addr(0).String(), + ), + func(ctx sdk.Context, bid types.Bid) { + s.Require().Equal(pool.Id, bid.PoolId) + s.Require().Equal(s.addr(0), bid.GetBidder()) + }, + "", + }, + { + "auction not found", + types.NewMsgRefundBid( + auctionId, + 5, + s.addr(1).String(), + ), + nil, + "auction by pool 5 not found: not found", + }, + { + "refund winning bid", + types.NewMsgRefundBid( + auctionId, + pool.Id, + s.addr(1).String(), + ), + nil, + "winning bid can't be refunded: invalid request", + }, + } { + s.Run(tc.name, func() { + s.Require().NoError(tc.msg.ValidateBasic()) + cacheCtx, _ := s.ctx.CacheContext() + err := s.keeper.RefundBid(cacheCtx, tc.msg.AuctionId, tc.msg.PoolId, tc.msg.GetBidder()) + if tc.expectedErr == "" { + s.Require().NoError(err) + _, found := s.keeper.GetBid(cacheCtx, tc.msg.PoolId, s.addr(0)) + s.Require().False(found) + } else { + s.Require().EqualError(err, tc.expectedErr) + } + }) + } +} + +func (s *KeeperTestSuite) TestAfterAllocateRewards() { + pair := s.createPairWithLastPrice(s.addr(0), "denom1", "denom2", sdk.NewDec(1)) + pool := s.createPool(s.addr(0), pair.Id, utils.ParseCoins("100_000_000denom1, 100_000_000denom2")) + plan := s.createPrivatePlan(s.addr(0), []farmtypes.RewardAllocation{ + { + PairId: pool.PairId, + RewardsPerDay: utils.ParseCoins("100_000_000stake"), + }, + }) + s.fundAddr(plan.GetFarmingPoolAddress(), utils.ParseCoins("100_000_000stake")) + + s.createLiquidFarm(pool.Id, sdk.ZeroInt(), sdk.ZeroInt(), sdk.ZeroDec()) + + s.liquidFarm(pool.Id, s.addr(1), sdk.NewCoin(pool.PoolCoinDenom, sdk.NewInt(50_000_000)), true) + s.nextBlock() + + s.nextAuction() + + // Ensure that the rewards auction is created + auctionId := s.keeper.GetLastRewardsAuctionId(s.ctx, pool.Id) + auction, found := s.keeper.GetRewardsAuction(s.ctx, auctionId, pool.Id) + s.Require().True(found) + s.Require().Equal(types.AuctionStatusStarted, auction.Status) + + s.placeBid(auction.PoolId, s.addr(1), sdk.NewInt64Coin(pool.PoolCoinDenom, 10_000_000), true) + s.placeBid(auction.PoolId, s.addr(2), sdk.NewInt64Coin(pool.PoolCoinDenom, 20_000_000), true) + s.placeBid(auction.PoolId, s.addr(3), sdk.NewInt64Coin(pool.PoolCoinDenom, 30_000_000), true) + s.nextBlock() + + s.nextAuction() + + // Ensure the state of previous auction is updated + s.Require().Len(s.keeper.GetAllRewardsAuctions(s.ctx), 2) + + // Ensure that two bidders got their pool coin back to their balances + s.Require().Equal(sdk.NewInt(10_000_000), s.getBalance(s.addr(1), pool.PoolCoinDenom).Amount) + s.Require().Equal(sdk.NewInt(20_000_000), s.getBalance(s.addr(2), pool.PoolCoinDenom).Amount) + s.Require().Equal(sdk.ZeroInt(), s.getBalance(s.addr(3), pool.PoolCoinDenom).Amount) + + // Ensure winner's balance to see if they received farming rewards + s.Require().True(s.getBalance(s.addr(3), "stake").Amount.GT(sdk.NewInt(1))) + + // Ensure newly staked amount by the liquid farm reserve account + reserveAddr := types.LiquidFarmReserveAddress(pool.Id) + position, found := s.app.FarmKeeper.GetPosition(s.ctx, reserveAddr, pool.PoolCoinDenom) + s.Require().True(found) + s.Require().Equal(sdk.NewInt(80_000_000), position.FarmingAmount) +} + +func (s *KeeperTestSuite) TestAfterAllocateRewards_NoBid() { + pair := s.createPairWithLastPrice(s.addr(0), "denom1", "denom2", sdk.NewDec(1)) + pool := s.createPool(s.addr(0), pair.Id, utils.ParseCoins("100_000_000denom1, 100_000_000denom2")) + plan := s.createPrivatePlan(s.addr(0), []farmtypes.RewardAllocation{ + { + PairId: pool.PairId, + RewardsPerDay: utils.ParseCoins("100_000_000stake"), + }, + }) + s.fundAddr(plan.GetFarmingPoolAddress(), utils.ParseCoins("100_000_000stake")) + + s.createLiquidFarm(pool.Id, sdk.ZeroInt(), sdk.ZeroInt(), sdk.ZeroDec()) + s.liquidFarm(pool.Id, s.addr(1), sdk.NewCoin(pool.PoolCoinDenom, sdk.NewInt(50_000_000)), true) + s.nextBlock() + + s.nextAuction() + + auctionId := s.keeper.GetLastRewardsAuctionId(s.ctx, pool.Id) + auction, found := s.keeper.GetRewardsAuction(s.ctx, auctionId, pool.Id) + s.Require().True(found) + s.Require().Equal(types.AuctionStatusStarted, auction.Status) + + s.nextAuction() + + auction, found = s.keeper.GetRewardsAuction(s.ctx, auction.PoolId, auction.Id) + s.Require().True(found) + s.Require().Equal(types.AuctionStatusSkipped, auction.Status) +} diff --git a/x/liquidfarming/keeper/genesis.go b/x/liquidfarming/keeper/genesis.go new file mode 100644 index 00000000..e35748d3 --- /dev/null +++ b/x/liquidfarming/keeper/genesis.go @@ -0,0 +1,81 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/cosmosquad-labs/squad/v3/x/liquidfarming/types" +) + +// InitGenesis initializes the capability module's state from a provided genesis state. +func (k Keeper) InitGenesis(ctx sdk.Context, genState types.GenesisState) { + if err := genState.Validate(); err != nil { + panic(err) + } + + k.SetParams(ctx, genState.Params) + + for _, liquidFarm := range genState.LiquidFarms { + k.SetLiquidFarm(ctx, liquidFarm) + } + + for _, record := range genState.LastRewardsAuctionIdRecord { + k.SetLastRewardsAuctionId(ctx, record.AuctionId, record.PoolId) + } + + for _, auction := range genState.RewardsAuctions { + k.SetRewardsAuction(ctx, auction) + } + + for _, bid := range genState.Bids { + k.SetBid(ctx, bid) + } + + for _, record := range genState.WinningBidRecords { + k.SetWinningBid(ctx, record.AuctionId, record.WinningBid) + } +} + +// ExportGenesis returns the module's exported genesis. +func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { + params := k.GetParams(ctx) + + // Initialize objects to prevent from having nil slice + if params.LiquidFarms == nil { + params.LiquidFarms = []types.LiquidFarm{} + } + + poolIds := []uint64{} + for _, liquidFarm := range params.LiquidFarms { + poolIds = append(poolIds, liquidFarm.PoolId) + } + + lastRewardsAuctionIdRecords := []types.LastRewardsAuctionIdRecord{} + bids := []types.Bid{} + winningBidRecords := []types.WinningBidRecord{} + for _, poolId := range poolIds { + lastRewardsAuctionIdRecords = append(lastRewardsAuctionIdRecords, types.LastRewardsAuctionIdRecord{ + PoolId: poolId, + AuctionId: k.GetLastRewardsAuctionId(ctx, poolId), + }) + + bids = append(bids, k.GetBidsByPoolId(ctx, poolId)...) + + auctionId := k.GetLastRewardsAuctionId(ctx, poolId) + winningBid, found := k.GetWinningBid(ctx, auctionId, poolId) + if found { + winningBidRecords = append(winningBidRecords, types.WinningBidRecord{ + AuctionId: auctionId, + WinningBid: winningBid, + }) + } + } + + return &types.GenesisState{ + Params: params, + LastRewardsAuctionIdRecord: lastRewardsAuctionIdRecords, + LiquidFarms: k.GetAllLiquidFarms(ctx), + RewardsAuctions: k.GetAllRewardsAuctions(ctx), + Bids: bids, + WinningBidRecords: winningBidRecords, + } +} diff --git a/x/liquidfarming/keeper/genesis_test.go b/x/liquidfarming/keeper/genesis_test.go new file mode 100644 index 00000000..b686d152 --- /dev/null +++ b/x/liquidfarming/keeper/genesis_test.go @@ -0,0 +1,97 @@ +package keeper_test + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + utils "github.com/cosmosquad-labs/squad/v3/types" + "github.com/cosmosquad-labs/squad/v3/x/liquidfarming/types" + + _ "github.com/stretchr/testify/suite" +) + +func (s *KeeperTestSuite) TestDefaultGenesis() { + genState := *types.DefaultGenesis() + + s.keeper.InitGenesis(s.ctx, genState) + got := s.keeper.ExportGenesis(s.ctx) + s.Require().Equal(genState, *got) +} + +func (s *KeeperTestSuite) TestImportExportGenesis() { + pair := s.createPair(s.addr(0), "denom1", "denom2") + pool := s.createPool(s.addr(0), pair.Id, utils.ParseCoins("100_000_000denom1, 100_000_000denom2")) + + s.createLiquidFarm(pool.Id, sdk.ZeroInt(), sdk.ZeroInt(), sdk.ZeroDec()) + + s.deposit(s.addr(1), pool.Id, utils.ParseCoins("100_000_000denom1, 100_000_000denom2"), true) + s.deposit(s.addr(2), pool.Id, utils.ParseCoins("100_000_000denom1, 100_000_000denom2"), true) + s.deposit(s.addr(3), pool.Id, utils.ParseCoins("100_000_000denom1, 100_000_000denom2"), true) + s.nextBlock() + + s.liquidFarm(pool.Id, s.addr(1), utils.ParseCoin("100_000pool1"), false) + s.liquidFarm(pool.Id, s.addr(2), utils.ParseCoin("300_000pool1"), false) + s.liquidFarm(pool.Id, s.addr(3), utils.ParseCoin("500_000pool1"), false) + s.nextBlock() + + // Ensure that the position is created and the amount of farmed coin + position, found := s.app.FarmKeeper.GetPosition(s.ctx, types.LiquidFarmReserveAddress(pool.Id), pool.PoolCoinDenom) + s.Require().True(found) + s.Require().Equal(sdk.NewInt(900_000), position.FarmingAmount) // 100+300+500 + + // Move time to auctionTime so that rewards auction is created + s.nextAuction() + + auctionId := s.keeper.GetLastRewardsAuctionId(s.ctx, pool.Id) + auction, found := s.keeper.GetRewardsAuction(s.ctx, auctionId, pool.Id) + s.Require().True(found) + + s.placeBid(auction.PoolId, s.addr(4), utils.ParseCoin("100_000pool1"), true) + s.placeBid(auction.PoolId, s.addr(5), utils.ParseCoin("110_000pool1"), true) + s.placeBid(auction.PoolId, s.addr(6), utils.ParseCoin("150_000pool1"), true) + s.placeBid(auction.PoolId, s.addr(7), utils.ParseCoin("200_000pool1"), true) + + // Finish the first auction and create the second rewards auction + s.nextAuction() + + // Ensure that the amount of farmed coin is increased due to the auction + position, found = s.app.FarmKeeper.GetPosition(s.ctx, types.LiquidFarmReserveAddress(pool.Id), pool.PoolCoinDenom) + s.Require().True(found) + s.Require().Equal(sdk.NewInt(1_100_000), position.FarmingAmount) // 100+300+500+200 + + // Ensure that the second rewards auction is created + auctionId = s.keeper.GetLastRewardsAuctionId(s.ctx, pool.Id) + auction, found = s.keeper.GetRewardsAuction(s.ctx, auctionId, pool.Id) + s.Require().True(found) + + s.liquidFarm(auction.PoolId, s.addr(1), utils.ParseCoin("200_000pool1"), true) + s.liquidFarm(auction.PoolId, s.addr(2), utils.ParseCoin("200_000pool1"), true) + s.nextBlock() + + s.placeBid(auction.PoolId, s.addr(6), utils.ParseCoin("100_000pool1"), true) + s.placeBid(auction.PoolId, s.addr(7), utils.ParseCoin("110_000pool1"), true) + s.placeBid(auction.PoolId, s.addr(4), utils.ParseCoin("150_000pool1"), true) + s.placeBid(auction.PoolId, s.addr(5), utils.ParseCoin("300_000pool1"), true) + s.nextBlock() + + // Export genesis state and verify + var genState *types.GenesisState + s.Require().NotPanics(func() { + genState = s.keeper.ExportGenesis(s.ctx) + s.Require().Len(genState.RewardsAuctions, 2) + s.Require().Len(genState.Bids, 4) + s.Require().Len(genState.WinningBidRecords, 1) + }) + s.Require().NoError(genState.Validate()) + + var genState2 types.GenesisState + bz := s.app.AppCodec().MustMarshalJSON(genState) + s.app.AppCodec().MustUnmarshalJSON(bz, &genState2) + s.keeper.InitGenesis(s.ctx, genState2) + + var genState3 *types.GenesisState + s.Require().NotPanics(func() { + genState3 = s.keeper.ExportGenesis(s.ctx) + s.Require().Equal(*genState, *genState3) + }) + s.Require().NoError(genState3.Validate()) +} diff --git a/x/liquidfarming/keeper/grpc_query.go b/x/liquidfarming/keeper/grpc_query.go new file mode 100644 index 00000000..b2d26f8c --- /dev/null +++ b/x/liquidfarming/keeper/grpc_query.go @@ -0,0 +1,267 @@ +package keeper + +import ( + "context" + + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/query" + + "github.com/cosmosquad-labs/squad/v3/x/liquidfarming/types" + liquiditytypes "github.com/cosmosquad-labs/squad/v3/x/liquidity/types" +) + +// Querier is used as Keeper will have duplicate methods if used directly, and gRPC names take precedence over keeper. +type Querier struct { + Keeper +} + +var _ types.QueryServer = Querier{} + +// Params queries the parameters of the module. +func (k Querier) Params(c context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + ctx := sdk.UnwrapSDKContext(c) + params := k.GetParams(ctx) + return &types.QueryParamsResponse{Params: params}, nil +} + +// LiquidFarms queries all liquidfarms. +func (k Querier) LiquidFarms(c context.Context, req *types.QueryLiquidFarmsRequest) (*types.QueryLiquidFarmsResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + + ctx := sdk.UnwrapSDKContext(c) + + liquidFarmsRes := []types.LiquidFarmResponse{} + for _, liquidFarm := range k.GetAllLiquidFarms(ctx) { + reserveAddr := types.LiquidFarmReserveAddress(liquidFarm.PoolId) + poolCoinDenom := liquiditytypes.PoolCoinDenom(liquidFarm.PoolId) + lfCoinDenom := types.LiquidFarmCoinDenom(liquidFarm.PoolId) + farm, found := k.farmKeeper.GetFarm(ctx, poolCoinDenom) + if !found { + farm.TotalFarmingAmount = sdk.ZeroInt() + } + + liquidFarmsRes = append(liquidFarmsRes, types.LiquidFarmResponse{ + PoolId: liquidFarm.PoolId, + LiquidFarmReserveAddress: reserveAddr.String(), + LFCoinDenom: lfCoinDenom, + MinFarmAmount: liquidFarm.MinFarmAmount, + MinBidAmount: liquidFarm.MinBidAmount, + TotalFarmingAmount: farm.TotalFarmingAmount, + }) + } + + return &types.QueryLiquidFarmsResponse{LiquidFarms: liquidFarmsRes}, nil +} + +// LiquidFarm queries the specific liquidfarm. +func (k Querier) LiquidFarm(c context.Context, req *types.QueryLiquidFarmRequest) (*types.QueryLiquidFarmResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + + if req.PoolId == 0 { + return nil, status.Error(codes.InvalidArgument, "pool id cannot be 0") + } + + ctx := sdk.UnwrapSDKContext(c) + + liquidFarm, found := k.GetLiquidFarm(ctx, req.PoolId) + if !found { + return nil, status.Errorf(codes.NotFound, "liquid farm by pool id %d not found", req.PoolId) + } + + reserveAddr := types.LiquidFarmReserveAddress(liquidFarm.PoolId) + poolCoinDenom := liquiditytypes.PoolCoinDenom(liquidFarm.PoolId) + lfCoinDenom := types.LiquidFarmCoinDenom(liquidFarm.PoolId) + farm, found := k.farmKeeper.GetFarm(ctx, poolCoinDenom) + if !found { + farm.TotalFarmingAmount = sdk.ZeroInt() + } + + liquidFarmRes := types.LiquidFarmResponse{ + PoolId: liquidFarm.PoolId, + LiquidFarmReserveAddress: reserveAddr.String(), + LFCoinDenom: lfCoinDenom, + MinFarmAmount: liquidFarm.MinFarmAmount, + MinBidAmount: liquidFarm.MinBidAmount, + TotalFarmingAmount: farm.TotalFarmingAmount, + } + + return &types.QueryLiquidFarmResponse{LiquidFarm: liquidFarmRes}, nil +} + +// RewardsAuctions queries all rewards auctions. +func (k Querier) RewardsAuctions(c context.Context, req *types.QueryRewardsAuctionsRequest) (*types.QueryRewardsAuctionsResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + + if req.PoolId == 0 { + return nil, status.Error(codes.InvalidArgument, "pool id cannot be 0") + } + + ctx := sdk.UnwrapSDKContext(c) + store := ctx.KVStore(k.storeKey) + auctionStore := prefix.NewStore(store, types.RewardsAuctionKeyPrefix) + + // Filter auctions by descending order to show an ongoing auction first + req.Pagination = &query.PageRequest{ + Reverse: true, + } + + var auctions []types.RewardsAuction + pageRes, err := query.FilteredPaginate(auctionStore, req.Pagination, func(key []byte, value []byte, accumulate bool) (bool, error) { + auction, err := types.UnmarshalRewardsAuction(k.cdc, value) + if err != nil { + return false, err + } + + if auction.PoolId != req.PoolId { + return false, err + } + + if accumulate { + auctions = append(auctions, auction) + } + + return true, nil + }) + + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + + return &types.QueryRewardsAuctionsResponse{RewardAuctions: auctions, Pagination: pageRes}, nil +} + +// RewardsAuction queries rewards auction +func (k Querier) RewardsAuction(c context.Context, req *types.QueryRewardsAuctionRequest) (*types.QueryRewardsAuctionResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + + if req.AuctionId == 0 { + return nil, status.Error(codes.InvalidArgument, "auction id cannot be 0") + } + + if req.PoolId == 0 { + return nil, status.Error(codes.InvalidArgument, "pool id cannot be 0") + } + + ctx := sdk.UnwrapSDKContext(c) + + auction, found := k.GetRewardsAuction(ctx, req.AuctionId, req.PoolId) + if !found { + return nil, status.Errorf(codes.NotFound, "auction by pool %d and auction id %d not found", req.PoolId, req.AuctionId) + } + + return &types.QueryRewardsAuctionResponse{RewardAuction: auction}, nil +} + +// Bids queries all bids. +func (k Querier) Bids(c context.Context, req *types.QueryBidsRequest) (*types.QueryBidsResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + + if req.PoolId == 0 { + return nil, status.Error(codes.InvalidArgument, "pool id cannot be 0") + } + + ctx := sdk.UnwrapSDKContext(c) + store := ctx.KVStore(k.storeKey) + bidStore := prefix.NewStore(store, types.BidKeyPrefix) + + var bids []types.Bid + pageRes, err := query.FilteredPaginate(bidStore, req.Pagination, func(key []byte, value []byte, accumulate bool) (bool, error) { + bid, err := types.UnmarshalBid(k.cdc, value) + if err != nil { + return false, err + } + + if bid.PoolId != req.PoolId { + return false, nil + } + + if accumulate { + bids = append(bids, bid) + } + + return true, nil + }) + + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + + return &types.QueryBidsResponse{Bids: bids, Pagination: pageRes}, nil +} + +// MintRate queries the current mint rate. +func (k Querier) MintRate(c context.Context, req *types.QueryMintRateRequest) (*types.QueryMintRateResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + + if req.PoolId == 0 { + return nil, status.Error(codes.InvalidArgument, "pool id cannot be 0") + } + + ctx := sdk.UnwrapSDKContext(c) + + mintRate := sdk.ZeroDec() + lfCoinTotalSupplyAmt := k.bankKeeper.GetSupply(ctx, types.LiquidFarmCoinDenom(req.PoolId)).Amount + if !lfCoinTotalSupplyAmt.IsZero() { + farm, found := k.farmKeeper.GetFarm(ctx, liquiditytypes.PoolCoinDenom(req.PoolId)) + if !found { + farm.TotalFarmingAmount = sdk.ZeroInt() + } + + // MintRate = LFCoinTotalSupply / LPCoinTotalFarmingAmount + mintRate = lfCoinTotalSupplyAmt.ToDec().Quo(farm.TotalFarmingAmount.ToDec()) + } + + return &types.QueryMintRateResponse{MintRate: mintRate}, nil +} + +// BurnRate queries the current burn rate. +func (k Querier) BurnRate(c context.Context, req *types.QueryBurnRateRequest) (*types.QueryBurnRateResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + + if req.PoolId == 0 { + return nil, status.Error(codes.InvalidArgument, "pool id cannot be 0") + } + + ctx := sdk.UnwrapSDKContext(c) + + burnRate := sdk.ZeroDec() + lfCoinTotalSupplyAmt := k.bankKeeper.GetSupply(ctx, types.LiquidFarmCoinDenom(req.PoolId)).Amount + if !lfCoinTotalSupplyAmt.IsZero() { + farm, found := k.farmKeeper.GetFarm(ctx, liquiditytypes.PoolCoinDenom(req.PoolId)) + if !found { + farm.TotalFarmingAmount = sdk.ZeroInt() + } + + compoundingRewards, found := k.GetCompoundingRewards(ctx, req.PoolId) + if !found { + compoundingRewards.Amount = sdk.ZeroInt() + } + + // BurnRate = LPCoinTotalFarmingAmount - CompoundingRewards / LFCoinTotalSupply + lpCoinTotalFarmingAmt := farm.TotalFarmingAmount.Sub(compoundingRewards.Amount) + burnRate = lpCoinTotalFarmingAmt.ToDec().Quo(lfCoinTotalSupplyAmt.ToDec()) + } + + return &types.QueryBurnRateResponse{BurnRate: burnRate}, nil +} diff --git a/x/liquidfarming/keeper/grpc_query_test.go b/x/liquidfarming/keeper/grpc_query_test.go new file mode 100644 index 00000000..ed5f24a4 --- /dev/null +++ b/x/liquidfarming/keeper/grpc_query_test.go @@ -0,0 +1,557 @@ +package keeper_test + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + utils "github.com/cosmosquad-labs/squad/v3/types" + farmtypes "github.com/cosmosquad-labs/squad/v3/x/farm/types" + "github.com/cosmosquad-labs/squad/v3/x/liquidfarming/types" + liquiditytypes "github.com/cosmosquad-labs/squad/v3/x/liquidity/types" + + _ "github.com/stretchr/testify/suite" +) + +func (s *KeeperTestSuite) TestGRPCParams() { + resp, err := s.querier.Params(sdk.WrapSDKContext(s.ctx), &types.QueryParamsRequest{}) + s.Require().NoError(err) + s.Require().Equal(s.keeper.GetParams(s.ctx), resp.Params) +} + +func (s *KeeperTestSuite) TestGRPCLiquidFarms() { + pair1 := s.createPair(s.addr(0), "denom1", "denom2") + pool1 := s.createPool(s.addr(0), pair1.Id, utils.ParseCoins("100_000_000denom1, 100_000_000denom2")) + minFarmAmt1, minBidAmt1 := sdk.NewInt(10_000_000), sdk.NewInt(10_000_000) + s.createLiquidFarm(pool1.Id, minFarmAmt1, minBidAmt1, sdk.ZeroDec()) + + pair2 := s.createPair(s.addr(1), "denom3", "denom4") + pool2 := s.createPool(s.addr(1), pair2.Id, utils.ParseCoins("100_000_000denom3, 100_000_000denom4")) + minFarmAmt2, minBidAmt2 := sdk.NewInt(30_000_000), sdk.NewInt(30_000_000) + s.createLiquidFarm(pool2.Id, minFarmAmt2, minBidAmt2, sdk.ZeroDec()) + + for _, tc := range []struct { + name string + req *types.QueryLiquidFarmsRequest + expectErr bool + postRun func(*types.QueryLiquidFarmsResponse) + }{ + { + "nil request", + nil, + true, + nil, + }, + { + "happy case", + &types.QueryLiquidFarmsRequest{}, + false, + func(resp *types.QueryLiquidFarmsResponse) { + s.Require().Len(resp.LiquidFarms, 2) + + for _, liquidFarm := range resp.LiquidFarms { + switch liquidFarm.PoolId { + case 1: + s.Require().Equal(minFarmAmt1, liquidFarm.MinFarmAmount) + s.Require().Equal(minBidAmt1, liquidFarm.MinBidAmount) + case 2: + s.Require().Equal(minFarmAmt2, liquidFarm.MinFarmAmount) + s.Require().Equal(minBidAmt2, liquidFarm.MinBidAmount) + } + poolCoinDenom := liquiditytypes.PoolCoinDenom(liquidFarm.PoolId) + farm, found := s.app.FarmKeeper.GetFarm(s.ctx, poolCoinDenom) + if !found { + farm.TotalFarmingAmount = sdk.ZeroInt() + } + s.Require().Equal(farm.TotalFarmingAmount, liquidFarm.TotalFarmingAmount) + } + }, + }, + } { + s.Run(tc.name, func() { + resp, err := s.querier.LiquidFarms(sdk.WrapSDKContext(s.ctx), tc.req) + if tc.expectErr { + s.Require().Error(err) + } else { + s.Require().NoError(err) + tc.postRun(resp) + } + }) + } +} + +func (s *KeeperTestSuite) TestGRPCLiquidFarm() { + pair := s.createPair(s.addr(0), "denom1", "denom2") + pool := s.createPool(s.addr(0), pair.Id, utils.ParseCoins("100_000_000denom1, 100_000_000denom2")) + minFarmAmt, minBidAmt := sdk.NewInt(10_000_000), sdk.NewInt(10_000_000) + s.createLiquidFarm(pool.Id, minFarmAmt, minBidAmt, sdk.ZeroDec()) + + for _, tc := range []struct { + name string + req *types.QueryLiquidFarmRequest + expectErr bool + postRun func(*types.QueryLiquidFarmResponse) + }{ + { + "nil request", + nil, + true, + nil, + }, + { + "happy case", + &types.QueryLiquidFarmRequest{ + PoolId: pool.Id, + }, + false, + func(resp *types.QueryLiquidFarmResponse) { + poolCoinDenom := liquiditytypes.PoolCoinDenom(resp.LiquidFarm.PoolId) + farm, found := s.app.FarmKeeper.GetFarm(s.ctx, poolCoinDenom) + if !found { + farm.TotalFarmingAmount = sdk.ZeroInt() + } + s.Require().Equal(farm.TotalFarmingAmount, resp.LiquidFarm.TotalFarmingAmount) + s.Require().Equal(types.LiquidFarmCoinDenom(pool.Id), resp.LiquidFarm.LFCoinDenom) + s.Require().Equal(types.LiquidFarmReserveAddress(pool.Id).String(), resp.LiquidFarm.LiquidFarmReserveAddress) + s.Require().Equal(minFarmAmt, resp.LiquidFarm.MinFarmAmount) + s.Require().Equal(minBidAmt, resp.LiquidFarm.MinBidAmount) + }, + }, + { + "query by invalid pool id", + &types.QueryLiquidFarmRequest{ + PoolId: 5, + }, + true, + nil, + }, + } { + s.Run(tc.name, func() { + resp, err := s.querier.LiquidFarm(sdk.WrapSDKContext(s.ctx), tc.req) + if tc.expectErr { + s.Require().Error(err) + } else { + s.Require().NoError(err) + tc.postRun(resp) + } + }) + } +} + +func (s *KeeperTestSuite) TestGRPCRewardsAuctions() { + pair := s.createPair(s.addr(0), "denom1", "denom2") + pool := s.createPool(s.addr(0), pair.Id, utils.ParseCoins("100_000_000denom1, 100_000_000denom2")) + + s.createLiquidFarm(pool.Id, sdk.ZeroInt(), sdk.ZeroInt(), sdk.ZeroDec()) + + s.deposit(s.addr(1), pool.Id, utils.ParseCoins("100_000_000denom1, 100_000_000denom2"), true) + s.deposit(s.addr(2), pool.Id, utils.ParseCoins("100_000_000denom1, 100_000_000denom2"), true) + s.deposit(s.addr(3), pool.Id, utils.ParseCoins("100_000_000denom1, 100_000_000denom2"), true) + s.nextBlock() + + s.nextBlock() + + s.liquidFarm(pool.Id, s.addr(1), utils.ParseCoin("100_000pool1"), true) + s.liquidFarm(pool.Id, s.addr(2), utils.ParseCoin("300_000pool1"), true) + s.liquidFarm(pool.Id, s.addr(3), utils.ParseCoin("500_000pool1"), true) + s.nextBlock() + + s.nextAuction() + + s.placeBid(pool.Id, s.addr(5), utils.ParseCoin("100_000pool1"), true) + s.placeBid(pool.Id, s.addr(6), utils.ParseCoin("110_000pool1"), true) + s.placeBid(pool.Id, s.addr(7), utils.ParseCoin("150_000pool1"), true) + s.nextBlock() + + s.nextAuction() + + s.placeBid(pool.Id, s.addr(5), utils.ParseCoin("100_000pool1"), true) + s.placeBid(pool.Id, s.addr(6), utils.ParseCoin("110_000pool1"), true) + s.placeBid(pool.Id, s.addr(7), utils.ParseCoin("150_000pool1"), true) + s.nextBlock() + + s.nextAuction() + + for _, tc := range []struct { + name string + req *types.QueryRewardsAuctionsRequest + expectErr bool + postRun func(*types.QueryRewardsAuctionsResponse) + }{ + { + "nil request", + nil, + true, + nil, + }, + { + "query by invalid pool id", + &types.QueryRewardsAuctionsRequest{ + PoolId: 0, + }, + true, + func(resp *types.QueryRewardsAuctionsResponse) {}, + }, + { + "query by invalid pool id", + &types.QueryRewardsAuctionsRequest{ + PoolId: 10, + }, + false, + func(resp *types.QueryRewardsAuctionsResponse) { + s.Require().Len(resp.RewardAuctions, 0) + }, + }, + { + "query by pool id", + &types.QueryRewardsAuctionsRequest{ + PoolId: pool.Id, + }, + false, + func(resp *types.QueryRewardsAuctionsResponse) { + s.Require().Len(resp.RewardAuctions, 3) + }, + }, + } { + s.Run(tc.name, func() { + resp, err := s.querier.RewardsAuctions(sdk.WrapSDKContext(s.ctx), tc.req) + if tc.expectErr { + s.Require().Error(err) + } else { + s.Require().NoError(err) + tc.postRun(resp) + } + }) + } +} + +func (s *KeeperTestSuite) TestGRPCRewardsAuction() { + pair := s.createPair(s.addr(0), "denom1", "denom2") + pool := s.createPool(s.addr(0), pair.Id, utils.ParseCoins("100_000_000denom1, 100_000_000denom2")) + + s.createLiquidFarm(pool.Id, sdk.ZeroInt(), sdk.ZeroInt(), sdk.ZeroDec()) + + s.deposit(s.addr(1), pool.Id, utils.ParseCoins("100_000_000denom1, 100_000_000denom2"), true) + s.deposit(s.addr(2), pool.Id, utils.ParseCoins("100_000_000denom1, 100_000_000denom2"), true) + s.deposit(s.addr(3), pool.Id, utils.ParseCoins("100_000_000denom1, 100_000_000denom2"), true) + s.nextBlock() + + s.liquidFarm(pool.Id, s.addr(1), utils.ParseCoin("100_000pool1"), true) + s.liquidFarm(pool.Id, s.addr(2), utils.ParseCoin("300_000pool1"), true) + s.liquidFarm(pool.Id, s.addr(3), utils.ParseCoin("500_000pool1"), true) + s.nextBlock() + + s.nextAuction() + + s.placeBid(pool.Id, s.addr(5), utils.ParseCoin("100_000pool1"), true) + s.placeBid(pool.Id, s.addr(6), utils.ParseCoin("110_000pool1"), true) + s.placeBid(pool.Id, s.addr(7), utils.ParseCoin("150_000pool1"), true) + s.nextBlock() + + s.nextAuction() + + for _, tc := range []struct { + name string + req *types.QueryRewardsAuctionRequest + expectErr bool + postRun func(*types.QueryRewardsAuctionResponse) + }{ + { + "nil request", + nil, + true, + nil, + }, + { + "query by invalid pool id", + &types.QueryRewardsAuctionRequest{ + PoolId: 10, + AuctionId: 1, + }, + true, + func(resp *types.QueryRewardsAuctionResponse) {}, + }, + { + "query by invalid auction id", + &types.QueryRewardsAuctionRequest{ + PoolId: 1, + AuctionId: 10, + }, + true, + func(resp *types.QueryRewardsAuctionResponse) {}, + }, + { + "query finished auction", + &types.QueryRewardsAuctionRequest{ + PoolId: pool.Id, + AuctionId: 1, + }, + false, + func(resp *types.QueryRewardsAuctionResponse) { + s.Require().Equal(pool.PoolCoinDenom, resp.RewardAuction.BiddingCoinDenom) + s.Require().Equal(types.PayingReserveAddress(pool.Id), resp.RewardAuction.GetPayingReserveAddress()) + s.Require().Equal(types.AuctionStatusFinished, resp.RewardAuction.Status) + }, + }, + { + "query started auction", + &types.QueryRewardsAuctionRequest{ + PoolId: pool.Id, + AuctionId: 2, + }, + false, + func(resp *types.QueryRewardsAuctionResponse) { + s.Require().Equal(pool.PoolCoinDenom, resp.RewardAuction.BiddingCoinDenom) + s.Require().Equal(types.PayingReserveAddress(pool.Id), resp.RewardAuction.GetPayingReserveAddress()) + s.Require().Equal(types.AuctionStatusStarted, resp.RewardAuction.Status) + }, + }, + } { + s.Run(tc.name, func() { + resp, err := s.querier.RewardsAuction(sdk.WrapSDKContext(s.ctx), tc.req) + if tc.expectErr { + s.Require().Error(err) + } else { + s.Require().NoError(err) + tc.postRun(resp) + } + }) + } +} + +func (s *KeeperTestSuite) TestGRPCBids() { + pair := s.createPair(s.addr(0), "denom1", "denom2") + pool := s.createPool(s.addr(0), pair.Id, utils.ParseCoins("100_000_000denom1, 100_000_000denom2")) + s.createLiquidFarm(pool.Id, sdk.ZeroInt(), sdk.ZeroInt(), sdk.ZeroDec()) + + s.deposit(s.addr(1), pool.Id, utils.ParseCoins("100_000_000denom1, 100_000_000denom2"), true) + s.deposit(s.addr(2), pool.Id, utils.ParseCoins("100_000_000denom1, 100_000_000denom2"), true) + s.deposit(s.addr(3), pool.Id, utils.ParseCoins("100_000_000denom1, 100_000_000denom2"), true) + s.nextBlock() + + s.liquidFarm(pool.Id, s.addr(1), utils.ParseCoin("100_000pool1"), true) + s.liquidFarm(pool.Id, s.addr(2), utils.ParseCoin("300_000pool1"), true) + s.liquidFarm(pool.Id, s.addr(3), utils.ParseCoin("500_000pool1"), true) + s.nextBlock() + + s.nextAuction() + + s.placeBid(pool.Id, s.addr(5), utils.ParseCoin("100_000pool1"), true) + s.placeBid(pool.Id, s.addr(6), utils.ParseCoin("110_000pool1"), true) + s.placeBid(pool.Id, s.addr(7), utils.ParseCoin("150_000pool1"), true) + s.nextBlock() + + for _, tc := range []struct { + name string + req *types.QueryBidsRequest + expectErr bool + postRun func(*types.QueryBidsResponse) + }{ + { + "nil request", + nil, + true, + nil, + }, + { + "query by invalid pool id", + &types.QueryBidsRequest{ + PoolId: 0, + }, + true, + func(resp *types.QueryBidsResponse) {}, + }, + { + "query by pool id", + &types.QueryBidsRequest{ + PoolId: pool.Id, + }, + false, + func(resp *types.QueryBidsResponse) { + s.Require().Len(resp.Bids, 3) + }, + }, + } { + s.Run(tc.name, func() { + resp, err := s.querier.Bids(sdk.WrapSDKContext(s.ctx), tc.req) + if tc.expectErr { + s.Require().Error(err) + } else { + s.Require().NoError(err) + tc.postRun(resp) + } + }) + } +} + +func (s *KeeperTestSuite) TestGRPCMintRate() { + pair := s.createPairWithLastPrice(s.addr(0), "denom1", "denom2", sdk.NewDec(1)) + pool := s.createPool(s.addr(0), pair.Id, utils.ParseCoins("100_000_000denom1, 100_000_000denom2")) + plan := s.createPrivatePlan(s.addr(0), []farmtypes.RewardAllocation{ + { + PairId: pool.PairId, + RewardsPerDay: utils.ParseCoins("100_000_000denom3"), + }, + }) + s.fundAddr(plan.GetFarmingPoolAddress(), utils.ParseCoins("500_000_000denom3")) + + s.createLiquidFarm(pool.Id, sdk.ZeroInt(), sdk.ZeroInt(), sdk.ZeroDec()) + s.nextBlock() + + s.liquidFarm(pool.Id, s.addr(1), utils.ParseCoin("200_000pool1"), true) + s.liquidFarm(pool.Id, s.addr(2), utils.ParseCoin("300_000pool1"), true) + s.nextBlock() + + s.nextAuction() + + s.liquidFarm(pool.Id, s.addr(3), utils.ParseCoin("500_000pool1"), true) + s.nextBlock() + + s.nextAuction() + + s.placeBid(pool.Id, s.addr(10), utils.ParseCoin("100_000pool1"), true) + s.placeBid(pool.Id, s.addr(11), utils.ParseCoin("200_000pool1"), true) + s.nextBlock() + + s.nextAuction() + + s.liquidFarm(pool.Id, s.addr(4), utils.ParseCoin("500_000pool1"), true) // Mint rate is changed + s.nextBlock() + + for _, tc := range []struct { + name string + req *types.QueryMintRateRequest + expectErr bool + postRun func(*types.QueryMintRateResponse) + }{ + { + "nil request", + nil, + true, + nil, + }, + { + "query by invalid pool id", + &types.QueryMintRateRequest{ + PoolId: 0, + }, + true, + func(resp *types.QueryMintRateResponse) {}, + }, + { + "query by not found pool id", + &types.QueryMintRateRequest{ + PoolId: 10, + }, + false, + func(resp *types.QueryMintRateResponse) { + s.Require().True(resp.MintRate.IsZero()) + }, + }, + { + "query by valid pool id", + &types.QueryMintRateRequest{ + PoolId: 1, + }, + false, + func(resp *types.QueryMintRateResponse) { + s.Require().True(resp.MintRate.LT(sdk.OneDec())) + }, + }, + } { + s.Run(tc.name, func() { + resp, err := s.querier.MintRate(sdk.WrapSDKContext(s.ctx), tc.req) + if tc.expectErr { + s.Require().Error(err) + } else { + s.Require().NoError(err) + tc.postRun(resp) + } + }) + } +} + +func (s *KeeperTestSuite) TestGRPCBurnRate() { + pair := s.createPair(s.addr(0), "denom1", "denom2") + pool := s.createPool(s.addr(0), pair.Id, utils.ParseCoins("100_000_000denom1, 100_000_000denom2")) + plan := s.createPrivatePlan(s.addr(0), []farmtypes.RewardAllocation{ + { + PairId: pool.PairId, + RewardsPerDay: utils.ParseCoins("100_000_000denom3"), + }, + }) + s.fundAddr(plan.GetFarmingPoolAddress(), utils.ParseCoins("500_000_000denom3")) + + s.createLiquidFarm(pool.Id, sdk.ZeroInt(), sdk.ZeroInt(), sdk.ZeroDec()) + s.nextBlock() + + s.liquidFarm(pool.Id, s.addr(1), utils.ParseCoin("200_000pool1"), true) + s.nextBlock() + + s.nextAuction() + + s.placeBid(pool.Id, s.addr(10), utils.ParseCoin("100_000pool1"), true) + s.placeBid(pool.Id, s.addr(11), utils.ParseCoin("200_000pool1"), true) + s.nextBlock() + + s.nextAuction() + + s.liquidFarm(pool.Id, s.addr(2), utils.ParseCoin("200_000pool1"), true) + s.nextBlock() + + s.liquidUnfarm(pool.Id, s.addr(2), utils.ParseCoin("100_000lf1"), true) + s.nextBlock() + + s.liquidFarm(pool.Id, s.addr(3), utils.ParseCoin("200_000pool1"), true) // Burn rate is changed + s.nextBlock() + + for _, tc := range []struct { + name string + req *types.QueryBurnRateRequest + expectErr bool + postRun func(*types.QueryBurnRateResponse) + }{ + { + "nil request", + nil, + true, + nil, + }, + { + "query by invalid pool id", + &types.QueryBurnRateRequest{ + PoolId: 0, + }, + true, + func(resp *types.QueryBurnRateResponse) {}, + }, + { + "query by not found pool id", + &types.QueryBurnRateRequest{ + PoolId: 10, + }, + false, + func(resp *types.QueryBurnRateResponse) { + s.Require().True(resp.BurnRate.IsZero()) + }, + }, + { + "query by valid pool id", + &types.QueryBurnRateRequest{ + PoolId: 1, + }, + false, + func(resp *types.QueryBurnRateResponse) { + s.Require().True(resp.BurnRate.GT(sdk.OneDec())) + }, + }, + } { + s.Run(tc.name, func() { + resp, err := s.querier.BurnRate(sdk.WrapSDKContext(s.ctx), tc.req) + if tc.expectErr { + s.Require().Error(err) + } else { + s.Require().NoError(err) + tc.postRun(resp) + } + }) + } +} diff --git a/x/liquidfarming/keeper/keeper.go b/x/liquidfarming/keeper/keeper.go new file mode 100644 index 00000000..5e508938 --- /dev/null +++ b/x/liquidfarming/keeper/keeper.go @@ -0,0 +1,68 @@ +package keeper + +import ( + "fmt" + + "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" + "github.com/tendermint/tendermint/libs/log" + + "github.com/cosmosquad-labs/squad/v3/x/liquidfarming/types" +) + +type Keeper struct { + cdc codec.BinaryCodec + storeKey sdk.StoreKey + paramSpace paramtypes.Subspace + accountKeeper types.AccountKeeper + bankKeeper types.BankKeeper + farmKeeper types.FarmKeeper + liquidityKeeper types.LiquidityKeeper +} + +func NewKeeper( + cdc codec.BinaryCodec, + storeKey sdk.StoreKey, + paramSpace paramtypes.Subspace, + accountKeeper types.AccountKeeper, + bankKeeper types.BankKeeper, + farmKeeper types.FarmKeeper, + liquidityKeeper types.LiquidityKeeper, +) Keeper { + // Ensure the module account is set + if addr := accountKeeper.GetModuleAddress(types.ModuleName); addr == nil { + panic(fmt.Sprintf("%s module account has not been set", types.ModuleName)) + } + + // Set KeyTable if it has not already been set + if !paramSpace.HasKeyTable() { + paramSpace = paramSpace.WithKeyTable(types.ParamKeyTable()) + } + + return Keeper{ + cdc: cdc, + storeKey: storeKey, + paramSpace: paramSpace, + accountKeeper: accountKeeper, + bankKeeper: bankKeeper, + farmKeeper: farmKeeper, + liquidityKeeper: liquidityKeeper, + } +} + +// Logger returns a module-specific logger. +func (k Keeper) Logger(ctx sdk.Context) log.Logger { + return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) +} + +// GetParams returns the parameters for the module. +func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) { + k.paramSpace.GetParamSet(ctx, ¶ms) + return params +} + +// SetParams sets the parameters for the module. +func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { + k.paramSpace.SetParamSet(ctx, ¶ms) +} diff --git a/x/liquidfarming/keeper/keeper_test.go b/x/liquidfarming/keeper/keeper_test.go new file mode 100644 index 00000000..c8c633fc --- /dev/null +++ b/x/liquidfarming/keeper/keeper_test.go @@ -0,0 +1,190 @@ +package keeper_test + +import ( + "encoding/binary" + "testing" + "time" + + "github.com/stretchr/testify/suite" + + sdk "github.com/cosmos/cosmos-sdk/types" + abci "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + + chain "github.com/cosmosquad-labs/squad/v3/app" + utils "github.com/cosmosquad-labs/squad/v3/types" + farmtypes "github.com/cosmosquad-labs/squad/v3/x/farm/types" + "github.com/cosmosquad-labs/squad/v3/x/liquidfarming" + "github.com/cosmosquad-labs/squad/v3/x/liquidfarming/keeper" + "github.com/cosmosquad-labs/squad/v3/x/liquidfarming/types" + liquiditytypes "github.com/cosmosquad-labs/squad/v3/x/liquidity/types" +) + +var ( + sampleStartTime = utils.ParseTime("0001-01-01T00:00:00Z") + sampleEndTime = utils.ParseTime("9999-12-31T23:59:59Z") +) + +type KeeperTestSuite struct { + suite.Suite + + app *chain.App + ctx sdk.Context + keeper keeper.Keeper + querier keeper.Querier + msgServer types.MsgServer +} + +func TestKeeperTestSuite(t *testing.T) { + suite.Run(t, new(KeeperTestSuite)) +} + +func (s *KeeperTestSuite) SetupTest() { + s.app = chain.Setup(false) + s.ctx = s.app.BaseApp.NewContext(false, tmproto.Header{}) + s.keeper = s.app.LiquidFarmingKeeper + s.querier = keeper.Querier{Keeper: s.keeper} + s.msgServer = keeper.NewMsgServerImpl(s.keeper) + s.ctx = s.ctx.WithBlockTime(time.Now()) // set to current time +} + +// +// Below are just shortcuts to frequently-used functions. +// + +func (s *KeeperTestSuite) fundAddr(addr sdk.AccAddress, amt sdk.Coins) { + s.T().Helper() + err := s.app.BankKeeper.MintCoins(s.ctx, types.ModuleName, amt) + s.Require().NoError(err) + err = s.app.BankKeeper.SendCoinsFromModuleToAccount(s.ctx, types.ModuleName, addr, amt) + s.Require().NoError(err) +} + +func (s *KeeperTestSuite) createPrivatePlan(creator sdk.AccAddress, rewardAllocs []farmtypes.RewardAllocation) farmtypes.Plan { + s.T().Helper() + s.fundAddr(creator, s.app.FarmKeeper.GetPrivatePlanCreationFee(s.ctx)) + plan, err := s.app.FarmKeeper.CreatePrivatePlan(s.ctx, creator, "", rewardAllocs, sampleStartTime, sampleEndTime) + s.Require().NoError(err) + return plan +} + +func (s *KeeperTestSuite) createPair(creator sdk.AccAddress, baseCoinDenom, quoteCoinDenom string) liquiditytypes.Pair { + s.T().Helper() + s.fundAddr(creator, s.app.LiquidityKeeper.GetPairCreationFee(s.ctx)) + pair, err := s.app.LiquidityKeeper.CreatePair(s.ctx, liquiditytypes.NewMsgCreatePair(creator, baseCoinDenom, quoteCoinDenom)) + s.Require().NoError(err) + return pair +} + +// createPairWithLastPrice is a convenient method to create a pair with last price. +// it is needed as farming plan doesn't distribute farming rewards if the last price is not set. +func (s *KeeperTestSuite) createPairWithLastPrice(creator sdk.AccAddress, baseCoinDenom, quoteCoinDenom string, lastPrice sdk.Dec) liquiditytypes.Pair { + s.T().Helper() + pair := s.createPair(creator, baseCoinDenom, quoteCoinDenom) + pair.LastPrice = &lastPrice + s.app.LiquidityKeeper.SetPair(s.ctx, pair) + return pair +} + +func (s *KeeperTestSuite) createPool(creator sdk.AccAddress, pairId uint64, depositCoins sdk.Coins) liquiditytypes.Pool { + s.T().Helper() + s.fundAddr(creator, s.app.LiquidityKeeper.GetPoolCreationFee(s.ctx).Add(depositCoins...)) + pool, err := s.app.LiquidityKeeper.CreatePool(s.ctx, liquiditytypes.NewMsgCreatePool(creator, pairId, depositCoins)) + s.Require().NoError(err) + return pool +} + +func (s *KeeperTestSuite) deposit(depositor sdk.AccAddress, poolId uint64, depositCoins sdk.Coins, fund bool) liquiditytypes.DepositRequest { + s.T().Helper() + if fund { + s.fundAddr(depositor, depositCoins) + } + req, err := s.app.LiquidityKeeper.Deposit(s.ctx, liquiditytypes.NewMsgDeposit(depositor, poolId, depositCoins)) + s.Require().NoError(err) + return req +} + +func (s *KeeperTestSuite) createLiquidFarm(poolId uint64, minFarmAmt, minBidAmt sdk.Int, feeRate sdk.Dec) types.LiquidFarm { + s.T().Helper() + liquidFarm := types.NewLiquidFarm(poolId, minFarmAmt, minBidAmt, feeRate) + params := s.keeper.GetParams(s.ctx) + params.LiquidFarms = append(params.LiquidFarms, liquidFarm) + s.keeper.SetParams(s.ctx, params) + s.keeper.SetLiquidFarm(s.ctx, liquidFarm) + return liquidFarm +} + +func (s *KeeperTestSuite) createRewardsAuction(poolId uint64) { + s.T().Helper() + params := s.keeper.GetParams(s.ctx) + s.keeper.CreateRewardsAuction(s.ctx, poolId, params.RewardsAuctionDuration) +} + +func (s *KeeperTestSuite) liquidFarm(poolId uint64, farmer sdk.AccAddress, lpCoin sdk.Coin, fund bool) { + s.T().Helper() + if fund { + s.fundAddr(farmer, sdk.NewCoins(lpCoin)) + } + err := s.keeper.LiquidFarm(s.ctx, poolId, farmer, lpCoin) + s.Require().NoError(err) +} + +func (s *KeeperTestSuite) liquidUnfarm(poolId uint64, farmer sdk.AccAddress, lfCoin sdk.Coin, fund bool) { + s.T().Helper() + if fund { + s.fundAddr(farmer, sdk.NewCoins(lfCoin)) + } + _, err := s.keeper.LiquidUnfarm(s.ctx, poolId, farmer, lfCoin) + s.Require().NoError(err) +} + +func (s *KeeperTestSuite) placeBid(poolId uint64, bidder sdk.AccAddress, biddingCoin sdk.Coin, fund bool) types.Bid { + s.T().Helper() + if fund { + s.fundAddr(bidder, sdk.NewCoins(biddingCoin)) + } + + auctionId := s.keeper.GetLastRewardsAuctionId(s.ctx, poolId) + bid, err := s.keeper.PlaceBid(s.ctx, auctionId, poolId, bidder, biddingCoin) + s.Require().NoError(err) + + return bid +} + +// +// Below are helper functions to write test code easily +// + +func (s *KeeperTestSuite) addr(addrNum int) sdk.AccAddress { + addr := make(sdk.AccAddress, 20) + binary.PutVarint(addr, int64(addrNum)) + return addr +} + +func (s *KeeperTestSuite) getBalances(addr sdk.AccAddress) sdk.Coins { //nolint + return s.app.BankKeeper.GetAllBalances(s.ctx, addr) +} + +func (s *KeeperTestSuite) getBalance(addr sdk.AccAddress, denom string) sdk.Coin { + return s.app.BankKeeper.GetBalance(s.ctx, addr, denom) +} + +func (s *KeeperTestSuite) nextBlock() { + s.T().Helper() + s.app.EndBlock(abci.RequestEndBlock{}) + s.app.Commit() + hdr := tmproto.Header{ + Height: s.app.LastBlockHeight() + 1, + Time: s.ctx.BlockTime().Add(5 * time.Second), + } + s.app.BeginBlock(abci.RequestBeginBlock{Header: hdr}) + s.ctx = s.app.BaseApp.NewContext(false, hdr) + s.app.BeginBlocker(s.ctx, abci.RequestBeginBlock{Header: hdr}) +} + +func (s *KeeperTestSuite) nextAuction() { + s.T().Helper() + auctionDuration := s.keeper.GetParams(s.ctx).RewardsAuctionDuration + s.ctx = s.ctx.WithBlockTime(s.ctx.BlockTime().Add(auctionDuration)) + liquidfarming.BeginBlocker(s.ctx, s.keeper) +} diff --git a/x/liquidfarming/keeper/liquidfarm.go b/x/liquidfarming/keeper/liquidfarm.go new file mode 100644 index 00000000..d101a88c --- /dev/null +++ b/x/liquidfarming/keeper/liquidfarm.go @@ -0,0 +1,210 @@ +package keeper + +import ( + "strconv" + + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + + "github.com/cosmosquad-labs/squad/v3/x/liquidfarming/types" + liquiditytypes "github.com/cosmosquad-labs/squad/v3/x/liquidity/types" +) + +// LiquidFarm handles types.MsgLiquidFarm to liquid farm. +func (k Keeper) LiquidFarm(ctx sdk.Context, poolId uint64, farmer sdk.AccAddress, farmingCoin sdk.Coin) error { + pool, found := k.liquidityKeeper.GetPool(ctx, poolId) + if !found { + return sdkerrors.Wrapf(sdkerrors.ErrNotFound, "pool %d not found", poolId) + } + + liquidFarm, found := k.GetLiquidFarm(ctx, pool.Id) + if !found { + return sdkerrors.Wrapf(sdkerrors.ErrNotFound, "liquid farm by pool %d not found", pool.Id) + } + + if farmingCoin.Amount.LT(liquidFarm.MinFarmAmount) { + return sdkerrors.Wrapf(types.ErrSmallerThanMinimumAmount, "%s is smaller than %s", farmingCoin.Amount, liquidFarm.MinFarmAmount) + } + + reserveAddr := types.LiquidFarmReserveAddress(pool.Id) + if err := k.bankKeeper.SendCoins(ctx, farmer, reserveAddr, sdk.NewCoins(farmingCoin)); err != nil { + return err + } + + lfCoinDenom := types.LiquidFarmCoinDenom(pool.Id) + lfCoinTotalSupplyAmt := k.bankKeeper.GetSupply(ctx, lfCoinDenom).Amount + farm, found := k.farmKeeper.GetFarm(ctx, farmingCoin.Denom) + if !found { + farm.TotalFarmingAmount = sdk.ZeroInt() + } + + mintingAmt := types.CalculateLiquidFarmAmount( + lfCoinTotalSupplyAmt, + farm.TotalFarmingAmount, + farmingCoin.Amount, + ) + mintingCoin := sdk.NewCoin(lfCoinDenom, mintingAmt) + + if err := k.bankKeeper.MintCoins(ctx, types.ModuleName, sdk.NewCoins(mintingCoin)); err != nil { + return err + } + if err := k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, farmer, sdk.NewCoins(mintingCoin)); err != nil { + return err + } + + if _, err := k.farmKeeper.Farm(ctx, reserveAddr, farmingCoin); err != nil { + return err + } + + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + types.EventTypeLiquidFarm, + sdk.NewAttribute(types.AttributeKeyPoolId, strconv.FormatUint(poolId, 10)), + sdk.NewAttribute(types.AttributeKeyFarmer, farmer.String()), + sdk.NewAttribute(types.AttributeKeyFarmingCoin, farmingCoin.String()), + sdk.NewAttribute(types.AttributeKeyMintedCoin, mintingCoin.String()), + sdk.NewAttribute(types.AttributeKeyLiquidFarmReserveAddress, reserveAddr.String()), + ), + }) + + return nil +} + +// UnfarmInfo holds information about unfarm. +type UnfarmInfo struct { + Farmer sdk.AccAddress + UnfarmedCoin sdk.Coin +} + +// LiquidUnfarm handles types.MsgLiquidUnfarm to unfarm LFCoin. +// It doesn't validate if the liquid farm exists because farmers still need to be able to +// unfarm their LFCoin in case the liquid farm object is removed in params by governance proposal. +func (k Keeper) LiquidUnfarm(ctx sdk.Context, poolId uint64, farmer sdk.AccAddress, unfarmingCoin sdk.Coin) (UnfarmInfo, error) { + pool, found := k.liquidityKeeper.GetPool(ctx, poolId) + if !found { + return UnfarmInfo{}, sdkerrors.Wrapf(sdkerrors.ErrNotFound, "pool %d not found", poolId) + } + + reserveAddr := types.LiquidFarmReserveAddress(pool.Id) + poolCoinDenom := liquiditytypes.PoolCoinDenom(pool.Id) + lfCoinDenom := types.LiquidFarmCoinDenom(pool.Id) + lfCoinTotalSupplyAmt := k.bankKeeper.GetSupply(ctx, lfCoinDenom).Amount + lpCoinTotalFarmingAmt := sdk.ZeroInt() + farm, found := k.farmKeeper.GetFarm(ctx, poolCoinDenom) + if found { + lpCoinTotalFarmingAmt = farm.TotalFarmingAmount + } + compoundingRewardsAmt := sdk.ZeroInt() + compoundingRewards, found := k.GetCompoundingRewards(ctx, pool.Id) + if found { + compoundingRewardsAmt = compoundingRewards.Amount + } + + _, found = k.GetLiquidFarm(ctx, poolId) + if !found { + // Handle a case when the liquid farm is removed in params + // Since the reserve account must have unfarm all farmed coin from the farm module, + // the module must use the reserve account balance + lpCoinTotalFarmingAmt = k.bankKeeper.SpendableCoins(ctx, reserveAddr).AmountOf(poolCoinDenom) + } + + unfarmingAmt := types.CalculateLiquidUnfarmAmount( + lfCoinTotalSupplyAmt, + lpCoinTotalFarmingAmt, + unfarmingCoin.Amount, + compoundingRewardsAmt, + ) + unfarmedCoin := sdk.NewCoin(poolCoinDenom, unfarmingAmt) + + if found { + // Unfarm the farmed coin in the farm module and release it to the farmer + if _, err := k.farmKeeper.Unfarm(ctx, reserveAddr, unfarmedCoin); err != nil { + return UnfarmInfo{}, err + } + } + + if err := k.bankKeeper.SendCoins(ctx, reserveAddr, farmer, sdk.NewCoins(unfarmedCoin)); err != nil { + return UnfarmInfo{}, err + } + + if err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, farmer, types.ModuleName, sdk.NewCoins(unfarmingCoin)); err != nil { + return UnfarmInfo{}, err + } + if err := k.bankKeeper.BurnCoins(ctx, types.ModuleName, sdk.NewCoins(unfarmingCoin)); err != nil { + return UnfarmInfo{}, err + } + + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + types.EventTypeLiquidUnfarm, + sdk.NewAttribute(types.AttributeKeyPoolId, strconv.FormatUint(poolId, 10)), + sdk.NewAttribute(types.AttributeKeyFarmer, farmer.String()), + sdk.NewAttribute(types.AttributeKeyUnfarmingCoin, unfarmingCoin.String()), + sdk.NewAttribute(types.AttributeKeyUnfarmedCoin, unfarmedCoin.String()), + ), + }) + + return UnfarmInfo{Farmer: farmer, UnfarmedCoin: unfarmedCoin}, nil +} + +// LiquidUnfarmAndWithdraw handles types.MsgUnfarmAndWithdraw to unfarm LFCoin and withdraw pool coin from the pool. +func (k Keeper) LiquidUnfarmAndWithdraw(ctx sdk.Context, poolId uint64, farmer sdk.AccAddress, unfarmingCoin sdk.Coin) error { + unfarmInfo, err := k.LiquidUnfarm(ctx, poolId, farmer, unfarmingCoin) + if err != nil { + return err + } + + _, err = k.liquidityKeeper.Withdraw(ctx, &liquiditytypes.MsgWithdraw{ + PoolId: poolId, + Withdrawer: farmer.String(), + PoolCoin: unfarmInfo.UnfarmedCoin, + }) + if err != nil { + return err + } + + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + types.EventTypeLiquidUnfarmAndWithdraw, + sdk.NewAttribute(types.AttributeKeyPoolId, strconv.FormatUint(poolId, 10)), + sdk.NewAttribute(types.AttributeKeyFarmer, farmer.String()), + sdk.NewAttribute(types.AttributeKeyUnfarmingCoin, unfarmingCoin.String()), + sdk.NewAttribute(types.AttributeKeyUnfarmedCoin, unfarmInfo.UnfarmedCoin.String()), + ), + }) + + return nil +} + +// HandleRemovedLiquidFarm unfarms all farmed coin from the farm module to stop having +// farming rewards accumulated and handle an ongoing rewards auction. +// Then finally delete the LiquidFarm object in the store. +func (k Keeper) HandleRemovedLiquidFarm(ctx sdk.Context, liquidFarm types.LiquidFarm) { + reserveAddr := types.LiquidFarmReserveAddress(liquidFarm.PoolId) + poolCoinDenom := liquiditytypes.PoolCoinDenom(liquidFarm.PoolId) + + // Unstake all farmed coin to stop having rewards accumulated in the farm module + position, found := k.farmKeeper.GetPosition(ctx, reserveAddr, poolCoinDenom) + if found { + if _, err := k.farmKeeper.Unfarm(ctx, reserveAddr, sdk.NewCoin(poolCoinDenom, position.FarmingAmount)); err != nil { + panic(err) + } + // TODO: rewards remain in the reserve account. How do we deal with them? + } + + // Handle the ongoing rewards auction by refunding all bids and + // set status to AuctionStatusFinished + auctionId := k.GetLastRewardsAuctionId(ctx, liquidFarm.PoolId) + auction, found := k.GetRewardsAuction(ctx, auctionId, liquidFarm.PoolId) + if found { + if err := k.RefundAllBids(ctx, auction, true); err != nil { + panic(err) + } + k.DeleteWinningBid(ctx, auctionId, liquidFarm.PoolId) + auction.SetStatus(types.AuctionStatusFinished) + k.SetRewardsAuction(ctx, auction) + } + + k.SetCompoundingRewards(ctx, liquidFarm.PoolId, types.CompoundingRewards{Amount: sdk.ZeroInt()}) + k.DeleteLiquidFarm(ctx, liquidFarm) +} diff --git a/x/liquidfarming/keeper/liquidfarm_test.go b/x/liquidfarming/keeper/liquidfarm_test.go new file mode 100644 index 00000000..501947b6 --- /dev/null +++ b/x/liquidfarming/keeper/liquidfarm_test.go @@ -0,0 +1,645 @@ +package keeper_test + +import ( + _ "github.com/stretchr/testify/suite" + + sdk "github.com/cosmos/cosmos-sdk/types" + utils "github.com/cosmosquad-labs/squad/v3/types" + + farmtypes "github.com/cosmosquad-labs/squad/v3/x/farm/types" + "github.com/cosmosquad-labs/squad/v3/x/liquidfarming/keeper" + "github.com/cosmosquad-labs/squad/v3/x/liquidfarming/types" +) + +func (s *KeeperTestSuite) TestLiquidFarm_Validation() { + err := s.keeper.LiquidFarm(s.ctx, 1, s.addr(0), utils.ParseCoin("100_000_000pool1")) + s.Require().EqualError(err, "pool 1 not found: not found") + + pair := s.createPair(s.addr(0), "denom1", "denom2") + pool := s.createPool(s.addr(0), pair.Id, utils.ParseCoins("100_000_000denom1, 100_000_000denom2")) + s.createLiquidFarm(pool.Id, sdk.NewInt(100_000_000), sdk.NewInt(100_000_000), sdk.ZeroDec()) + + for _, tc := range []struct { + name string + msg *types.MsgLiquidFarm + postRun func(ctx sdk.Context, farmerAddr sdk.AccAddress) + expectedErr string + }{ + { + "happy case", + types.NewMsgLiquidFarm( + pool.Id, + s.addr(0).String(), + sdk.NewInt64Coin(pool.PoolCoinDenom, 1_000_000_000), + ), + func(ctx sdk.Context, farmerAddr sdk.AccAddress) { + reserveAddr := types.LiquidFarmReserveAddress(pool.Id) + position, found := s.app.FarmKeeper.GetPosition(ctx, reserveAddr, pool.PoolCoinDenom) + s.Require().True(found) + s.Require().Equal(sdk.NewInt(1_000_000_000), position.FarmingAmount) + }, + "", + }, + { + "minimum farm amount", + types.NewMsgLiquidFarm( + pool.Id, + s.addr(0).String(), + sdk.NewInt64Coin(pool.PoolCoinDenom, 100), + ), + nil, + "100 is smaller than 100000000: smaller than the minimum amount", + }, + { + "insufficient funds", + types.NewMsgLiquidFarm( + pool.Id, + s.addr(5).String(), + sdk.NewInt64Coin(pool.PoolCoinDenom, 500_000_000), + ), + nil, + "0pool1 is smaller than 500000000pool1: insufficient funds", + }, + } { + s.Run(tc.name, func() { + s.Require().NoError(tc.msg.ValidateBasic()) + cacheCtx, _ := s.ctx.CacheContext() + err := s.keeper.LiquidFarm(cacheCtx, tc.msg.PoolId, tc.msg.GetFarmer(), tc.msg.FarmingCoin) + if tc.expectedErr == "" { + s.Require().NoError(err) + tc.postRun(cacheCtx, tc.msg.GetFarmer()) + } else { + s.Require().EqualError(err, tc.expectedErr) + } + }) + } +} + +func (s *KeeperTestSuite) TestLiquidFarm() { + pair := s.createPair(s.addr(0), "denom1", "denom2") + pool := s.createPool(s.addr(0), pair.Id, utils.ParseCoins("100_000_000denom1, 100_000_000denom2")) + + err := s.keeper.LiquidFarm(s.ctx, pool.Id, s.addr(0), utils.ParseCoin("1_000_000pool1")) + s.Require().EqualError(err, "liquid farm by pool 1 not found: not found") + + s.createLiquidFarm(pool.Id, sdk.ZeroInt(), sdk.ZeroInt(), sdk.ZeroDec()) + s.Require().Len(s.keeper.GetParams(s.ctx).LiquidFarms, 1) + + var ( + amount1 = sdk.NewInt(100_000_000) + amount2 = sdk.NewInt(200_000_000) + amount3 = sdk.NewInt(300_000_000) + ) + + s.liquidFarm(pool.Id, s.addr(0), sdk.NewCoin(pool.PoolCoinDenom, amount1), true) + s.nextBlock() + + s.liquidFarm(pool.Id, s.addr(0), sdk.NewCoin(pool.PoolCoinDenom, amount2), true) + s.nextBlock() + + s.liquidFarm(pool.Id, s.addr(0), sdk.NewCoin(pool.PoolCoinDenom, amount3), true) + s.nextBlock() + + // Check if the reserve account farmed the coin in the farm module + reserveAddr := types.LiquidFarmReserveAddress(pool.Id) + position, found := s.app.FarmKeeper.GetPosition(s.ctx, reserveAddr, pool.PoolCoinDenom) + s.Require().True(found) + s.Require().Equal(amount1.Add(amount2).Add(amount3), position.FarmingAmount) +} + +func (s *KeeperTestSuite) TestLiquidUnfarm_Validation() { + _, err := s.keeper.LiquidUnfarm(s.ctx, 1, s.addr(0), utils.ParseCoin("100_000_000pool1")) + s.Require().EqualError(err, "pool 1 not found: not found") + + pair := s.createPair(s.addr(0), "denom1", "denom2") + pool := s.createPool(s.addr(0), pair.Id, utils.ParseCoins("100_000_000denom1, 100_000_000denom2")) + + s.createLiquidFarm(pool.Id, sdk.ZeroInt(), sdk.ZeroInt(), sdk.ZeroDec()) + s.liquidFarm(pool.Id, s.addr(0), sdk.NewInt64Coin(pool.PoolCoinDenom, 1_000_000_000), true) + + for _, tc := range []struct { + name string + msg *types.MsgLiquidUnfarm + postRun func(ctx sdk.Context, unfarmInfo keeper.UnfarmInfo) + expectedErr string + }{ + { + "happy case", + types.NewMsgLiquidUnfarm( + pool.Id, + s.addr(0).String(), + sdk.NewInt64Coin(types.LiquidFarmCoinDenom(pool.Id), 1_000_000_000), + ), + func(ctx sdk.Context, unfarmInfo keeper.UnfarmInfo) { + s.Require().Equal(s.addr(0), unfarmInfo.Farmer) + }, + "", + }, + { + "insufficient balance", + types.NewMsgLiquidUnfarm( + pool.Id, + s.addr(5).String(), + sdk.NewInt64Coin(types.LiquidFarmCoinDenom(pool.Id), 1_000_000_000), + ), + nil, + "0lf1 is smaller than 1000000000lf1: insufficient funds", + }, + } { + s.Run(tc.name, func() { + s.Require().NoError(tc.msg.ValidateBasic()) + cacheCtx, _ := s.ctx.CacheContext() + unfarmInfo, err := s.keeper.LiquidUnfarm(cacheCtx, tc.msg.PoolId, tc.msg.GetFarmer(), tc.msg.UnfarmingCoin) + if tc.expectedErr == "" { + s.Require().NoError(err) + tc.postRun(cacheCtx, unfarmInfo) + } else { + s.Require().EqualError(err, tc.expectedErr) + } + }) + } +} + +func (s *KeeperTestSuite) TestLiquidUnfarm_All() { + pair := s.createPair(s.addr(0), "denom1", "denom2") + pool := s.createPool(s.addr(0), pair.Id, utils.ParseCoins("100_000_000denom1, 100_000_000denom2")) + + s.createLiquidFarm(pool.Id, sdk.ZeroInt(), sdk.ZeroInt(), sdk.ZeroDec()) + s.Require().Len(s.keeper.GetParams(s.ctx).LiquidFarms, 1) + + var ( + farmerAddr = s.addr(1) + amount1 = sdk.NewInt(100_000_000) + ) + reserveAddr := types.LiquidFarmReserveAddress(pool.Id) + lfCoinDenom := types.LiquidFarmCoinDenom(pool.Id) + + s.liquidFarm(pool.Id, farmerAddr, sdk.NewCoin(pool.PoolCoinDenom, amount1), true) + s.nextBlock() + + // Farm amount must be 100 + position, found := s.app.FarmKeeper.GetPosition(s.ctx, reserveAddr, pool.PoolCoinDenom) + s.Require().True(found) + s.Require().Equal(amount1, position.FarmingAmount) + + // Ensure the amount of minted LFCoin + balance := s.getBalance(farmerAddr, lfCoinDenom) + s.Require().Equal(amount1, balance.Amount) + + // Unfarm all amounts + s.liquidUnfarm(pool.Id, farmerAddr, balance, false) + + // Ensure that the position is deleted from the store + position, found = s.app.FarmKeeper.GetPosition(s.ctx, reserveAddr, pool.PoolCoinDenom) + s.Require().False(found) + + // Ensure the total supply + supply := s.app.BankKeeper.GetSupply(s.ctx, lfCoinDenom) + s.Require().True(supply.IsZero()) +} + +func (s *KeeperTestSuite) TestLiquidUnfarm_Partial() { + pair := s.createPair(s.addr(0), "denom1", "denom2") + pool := s.createPool(s.addr(0), pair.Id, utils.ParseCoins("100_000_000denom1, 100_000_000denom2")) + + s.createLiquidFarm(pool.Id, sdk.ZeroInt(), sdk.ZeroInt(), sdk.ZeroDec()) + s.Require().Len(s.keeper.GetParams(s.ctx).LiquidFarms, 1) + + reserveAddr := types.LiquidFarmReserveAddress(pool.Id) + lfCoinDenom := types.LiquidFarmCoinDenom(pool.Id) + + var ( + farmerAddr1 = s.addr(1) + farmerAddr2 = s.addr(2) + + amount1 = sdk.NewInt(5_000_000_000) + amount2 = sdk.NewInt(1_000_000_000) + ) + + s.liquidFarm(pool.Id, farmerAddr1, sdk.NewCoin(pool.PoolCoinDenom, amount1), true) + s.nextBlock() + + s.liquidFarm(pool.Id, farmerAddr2, sdk.NewCoin(pool.PoolCoinDenom, amount2), true) + s.nextBlock() + + position, found := s.app.FarmKeeper.GetPosition(s.ctx, reserveAddr, pool.PoolCoinDenom) + s.Require().True(found) + s.Require().Equal(amount1.Add(amount2), position.FarmingAmount) + + // Ensure the amount of minted LFCoin + s.Require().Equal(amount1, s.getBalance(farmerAddr1, lfCoinDenom).Amount) + s.Require().Equal(amount2, s.getBalance(farmerAddr2, lfCoinDenom).Amount) + + // Unfarm farmer2's all LFCoin amount + s.liquidUnfarm(pool.Id, farmerAddr2, s.getBalance(farmerAddr2, lfCoinDenom), false) + + // Ensure the total supply + s.Require().Equal(amount1, s.app.BankKeeper.GetSupply(s.ctx, lfCoinDenom).Amount) + + var ( + farmerAddr3 = s.addr(3) + amount3 = sdk.NewInt(1_000_000_000) + ) + + s.liquidFarm(pool.Id, farmerAddr3, sdk.NewCoin(pool.PoolCoinDenom, amount3), true) + s.nextBlock() + + // Ensure the amount of minted LFCoin + s.Require().Equal(amount1, s.getBalance(farmerAddr1, lfCoinDenom).Amount) + s.Require().Equal(sdk.ZeroInt(), s.getBalance(farmerAddr2, lfCoinDenom).Amount) + s.Require().Equal(amount3, s.getBalance(farmerAddr3, lfCoinDenom).Amount) + + // Unfarm farmer3's all LFCoin amount + s.liquidUnfarm(pool.Id, farmerAddr3, s.getBalance(farmerAddr3, lfCoinDenom), false) + + // Ensure the farming amount + position, found = s.app.FarmKeeper.GetPosition(s.ctx, reserveAddr, pool.PoolCoinDenom) + s.Require().True(found) + s.Require().Equal(amount1, position.FarmingAmount) + + // Ensure the total supply + s.Require().Equal(amount1, s.app.BankKeeper.GetSupply(s.ctx, lfCoinDenom).Amount) +} + +func (s *KeeperTestSuite) TestLiquidUnfarm_RemoveLiquidFarm() { + pair := s.createPair(s.addr(0), "denom1", "denom2") + pool := s.createPool(s.addr(0), pair.Id, utils.ParseCoins("100_000_000denom1, 100_000_000denom2")) + + plan := s.createPrivatePlan(s.addr(0), []farmtypes.RewardAllocation{ + { + PairId: pool.PairId, + RewardsPerDay: utils.ParseCoins("100_000_000stake"), + }, + }) + s.fundAddr(plan.GetFarmingPoolAddress(), utils.ParseCoins("1_000_000_000stake")) + + s.nextBlock() +} + +func (s *KeeperTestSuite) TestLiquidUnfarm_Complex_WithRewards() { + pair := s.createPairWithLastPrice(s.addr(0), "denom1", "denom2", sdk.NewDec(1)) + pool := s.createPool(s.addr(0), pair.Id, utils.ParseCoins("100_000_000denom1, 100_000_000denom2")) + + plan := s.createPrivatePlan(s.addr(0), []farmtypes.RewardAllocation{ + { + PairId: pool.PairId, + RewardsPerDay: utils.ParseCoins("100_000_000stake"), + }, + }) + s.fundAddr(plan.GetFarmingPoolAddress(), utils.ParseCoins("500_000_000stake")) + + s.createLiquidFarm(pool.Id, sdk.ZeroInt(), sdk.ZeroInt(), sdk.ZeroDec()) + s.Require().Len(s.keeper.GetParams(s.ctx).LiquidFarms, 1) + + reserveAddr := types.LiquidFarmReserveAddress(pool.Id) + lfCoinDenom := types.LiquidFarmCoinDenom(pool.Id) + + var ( + farmerAddr1 = s.addr(1) + farmerAddr2 = s.addr(2) + + amount1 = sdk.NewInt(1_000_000_000) + amount2 = sdk.NewInt(1_000_000_000) + ) + + s.liquidFarm(pool.Id, farmerAddr1, sdk.NewCoin(pool.PoolCoinDenom, amount1), true) + s.nextBlock() + + s.liquidFarm(pool.Id, farmerAddr2, sdk.NewCoin(pool.PoolCoinDenom, amount2), true) + s.nextBlock() + + // Ensure that the farmers received the minted LFCoin + s.Require().Equal(amount1, s.getBalance(farmerAddr1, lfCoinDenom).Amount) + s.Require().Equal(amount2, s.getBalance(farmerAddr2, lfCoinDenom).Amount) + + // Ensure the amount of farmed coin farmed by the reserve account + position, found := s.app.FarmKeeper.GetPosition(s.ctx, reserveAddr, pool.PoolCoinDenom) + s.Require().True(found) + s.Require().Equal(amount1.Add(amount2), position.FarmingAmount) + + // Move time to auctionTime so that rewards auction is created + s.nextAuction() + + // Ensure rewards auction is created + auctionId := s.keeper.GetLastRewardsAuctionId(s.ctx, pool.Id) + auction, found := s.keeper.GetRewardsAuction(s.ctx, auctionId, pool.Id) + s.Require().True(found) + + var ( + bidderAddr1 = s.addr(3) + bidderAddr2 = s.addr(4) + + biddingAmt1 = sdk.NewInt(100_000_000) + biddingAmt2 = sdk.NewInt(200_000_000) + ) + + s.placeBid(auction.PoolId, bidderAddr1, sdk.NewCoin(pool.PoolCoinDenom, biddingAmt1), true) + s.placeBid(auction.PoolId, bidderAddr2, sdk.NewCoin(pool.PoolCoinDenom, biddingAmt2), true) + s.nextBlock() + + // Finish the first auction and create the next rewards auction + s.nextAuction() + + // Ensure compounding rewards are set in the store + rewards, found := s.keeper.GetCompoundingRewards(s.ctx, pool.Id) + s.Require().True(found) + s.Require().Equal(biddingAmt2, rewards.Amount) + + // Ensure bidderAddr2 has received farming rewards + s.Require().True(s.getBalance(bidderAddr2, "stake").Amount.GT(sdk.NewInt(1))) + + // Ensure the next rewards auction is created + s.Require().Len(s.keeper.GetAllRewardsAuctions(s.ctx), 2) + + var ( + bidderAddr3 = s.addr(5) + biddingAmt3 = sdk.NewInt(10_000_000) + + bidderAddr4 = s.addr(6) + biddingAmt4 = sdk.NewInt(30_000_000) + ) + + s.placeBid(auction.PoolId, bidderAddr3, sdk.NewCoin(pool.PoolCoinDenom, biddingAmt3), true) + s.placeBid(auction.PoolId, bidderAddr4, sdk.NewCoin(pool.PoolCoinDenom, biddingAmt4), true) + + s.nextAuction() + + // Ensure compounding rewards are updated with the new bidding amount in the store + rewards, found = s.keeper.GetCompoundingRewards(s.ctx, pool.Id) + s.Require().True(found) + s.Require().Equal(biddingAmt4, rewards.Amount) + + // Ensure bidderAddr24has received farming rewards + s.Require().True(s.getBalance(bidderAddr2, "stake").Amount.GT(sdk.NewInt(1))) + + // Unfarm all + s.liquidUnfarm(pool.Id, farmerAddr1, s.getBalance(farmerAddr1, lfCoinDenom), false) + s.liquidUnfarm(pool.Id, farmerAddr2, s.getBalance(farmerAddr2, lfCoinDenom), false) + + // Ensure the total supply + s.Require().Equal(sdk.ZeroInt(), s.app.BankKeeper.GetSupply(s.ctx, lfCoinDenom).Amount) +} + +func (s *KeeperTestSuite) TestLiquidUnfarmAndWithdraw() { + depositCoins := utils.ParseCoins("100_000_000denom1, 100_000_000denom2") + pair := s.createPair(s.addr(0), "denom1", "denom2") + pool := s.createPool(s.addr(0), pair.Id, depositCoins) + + s.createLiquidFarm(pool.Id, sdk.ZeroInt(), sdk.ZeroInt(), sdk.ZeroDec()) + s.Require().Len(s.keeper.GetParams(s.ctx).LiquidFarms, 1) + + poolAmt := sdk.NewInt(1_000_000_000_000) + s.liquidFarm(pool.Id, s.addr(0), sdk.NewCoin(pool.PoolCoinDenom, poolAmt), false) + s.nextBlock() + + s.nextAuction() + + // Ensure that reserve account farms the coin and its amount + farm, found := s.app.FarmKeeper.GetFarm(s.ctx, pool.PoolCoinDenom) + s.Require().True(found) + s.Require().Equal(poolAmt, farm.TotalFarmingAmount) + + // Ensure the minted LFCoin + lfCoinDenom := types.LiquidFarmCoinDenom(pool.Id) + lfCoinBalance := s.getBalance(s.addr(0), lfCoinDenom) + s.Require().Equal(poolAmt, lfCoinBalance.Amount) + + err := s.keeper.LiquidUnfarmAndWithdraw(s.ctx, pool.Id, s.addr(0), lfCoinBalance) + s.Require().NoError(err) + + // Call nextBlock as Withdraw is executed in batch + s.nextBlock() + + // Ensure that depositCoins are returned to the farmer's balance + s.Require().EqualValues(depositCoins, s.getBalances(s.addr(0))) + +} + +func (s *KeeperTestSuite) TestDeleteLiquidFarm_Case1() { + pair1 := s.createPair(s.addr(0), "denom1", "denom2") + pool1 := s.createPool(s.addr(0), pair1.Id, utils.ParseCoins("100_000_000denom1, 100_000_000denom2")) + pair2 := s.createPair(s.addr(0), "denom3", "denom4") + pool2 := s.createPool(s.addr(0), pair2.Id, utils.ParseCoins("100_000_000denom3, 100_000_000denom4")) + + liquidFarm1 := s.createLiquidFarm(pool1.Id, sdk.NewInt(100), sdk.NewInt(100), sdk.ZeroDec()) + s.nextBlock() + + s.createLiquidFarm(pool2.Id, sdk.NewInt(500), sdk.NewInt(500), sdk.ZeroDec()) + s.nextBlock() + + // Ensure that the param and KVStore has the same length of liquid farms + s.Require().Len(s.keeper.GetAllLiquidFarms(s.ctx), 2) + s.Require().Len(s.keeper.GetParams(s.ctx).LiquidFarms, 2) + + // Forcefully remove one liquid farm from the store + s.keeper.DeleteLiquidFarm(s.ctx, liquidFarm1) + + // Ensure that the liquid farm is deleted in KVStore + s.Require().Len(s.keeper.GetAllLiquidFarms(s.ctx), 1) + s.Require().Len(s.keeper.GetParams(s.ctx).LiquidFarms, 2) + + // Synchronize LiquidFarms in begin blocker + s.nextBlock() + + // Ensure the length of liquid farms in the param and KVstore is the same + s.Require().Len(s.keeper.GetAllLiquidFarms(s.ctx), 2) + s.Require().Len(s.keeper.GetParams(s.ctx).LiquidFarms, 2) +} + +func (s *KeeperTestSuite) TestDeleteLiquidFarm_Case2() { + pair := s.createPairWithLastPrice(s.addr(0), "denom1", "denom2", sdk.NewDec(1)) + pool := s.createPool(s.addr(0), pair.Id, utils.ParseCoins("100_000_000denom1, 100_000_000denom2")) + plan := s.createPrivatePlan(s.addr(0), []farmtypes.RewardAllocation{ + { + PairId: pool.PairId, + RewardsPerDay: utils.ParseCoins("100_000_000stake"), + }, + }) + s.fundAddr(plan.GetFarmingPoolAddress(), utils.ParseCoins("500_000_000stake")) + + liquidFarm := s.createLiquidFarm(pool.Id, sdk.ZeroInt(), sdk.ZeroInt(), sdk.ZeroDec()) + + poolCoinBalance := s.getBalance(s.addr(0), pool.PoolCoinDenom) + s.liquidFarm(pool.Id, s.addr(0), poolCoinBalance, false) + s.nextBlock() + + // Create the first rewards auction + s.nextAuction() + + s.placeBid(pool.Id, s.addr(5), utils.ParseCoin("100_000pool1"), true) + s.nextBlock() + + s.placeBid(pool.Id, s.addr(6), utils.ParseCoin("200_000pool1"), true) + s.nextBlock() + + // Ensure that the reserve account farmed the pool coin + farm, found := s.app.FarmKeeper.GetPosition(s.ctx, types.LiquidFarmReserveAddress(pool.Id), pool.PoolCoinDenom) + s.Require().True(found) + s.Require().Equal(poolCoinBalance.Amount, farm.FarmingAmount) + + s.nextAuction() + + // Ensure that the total farming amount is increased + farm, found = s.app.FarmKeeper.GetPosition(s.ctx, types.LiquidFarmReserveAddress(pool.Id), pool.PoolCoinDenom) + s.Require().True(found) + s.Require().True(farm.FarmingAmount.GT(poolCoinBalance.Amount)) + + s.placeBid(pool.Id, s.addr(7), utils.ParseCoin("300_000pool1"), true) + s.nextBlock() + + s.placeBid(pool.Id, s.addr(8), utils.ParseCoin("400_000pool1"), true) + s.nextBlock() + + // Remove the liquid farm object in params + params := s.keeper.GetParams(s.ctx) + params.LiquidFarms = []types.LiquidFarm{} + s.keeper.SetParams(s.ctx, params) + + // Synchronize and handle the removed liquid farm + s.nextBlock() + + // Unfarm all LFCoin + s.liquidUnfarm(liquidFarm.PoolId, s.addr(0), s.getBalance(s.addr(0), types.LiquidFarmCoinDenom(pool.Id)), false) + s.nextBlock() + + // Ensure that the returned pool coin is increased + s.Require().True(s.getBalance(s.addr(0), pool.PoolCoinDenom).Amount.GT(poolCoinBalance.Amount)) + + // Ensure the auction status + auction, found := s.keeper.GetRewardsAuction(s.ctx, 1, pool.Id) + s.Require().True(found) + s.Require().Equal(types.AuctionStatusFinished, auction.Status) + + // Ensure that bidders got their funds back + s.Require().Equal(utils.ParseCoin("300_000pool1"), s.getBalance(s.addr(7), pool.PoolCoinDenom)) + s.Require().Equal(utils.ParseCoin("400_000pool1"), s.getBalance(s.addr(8), pool.PoolCoinDenom)) +} + +func (s *KeeperTestSuite) TestMintRate() { + pair := s.createPairWithLastPrice(s.addr(0), "denom1", "denom2", sdk.NewDec(1)) + pool := s.createPool(s.addr(0), pair.Id, utils.ParseCoins("100_000_000denom1, 100_000_000denom2")) + plan := s.createPrivatePlan(s.addr(0), []farmtypes.RewardAllocation{ + { + PairId: pool.PairId, + RewardsPerDay: utils.ParseCoins("100_000_000stake"), + }, + }) + s.fundAddr(plan.GetFarmingPoolAddress(), utils.ParseCoins("500_000_000stake")) + + s.createLiquidFarm(pool.Id, sdk.ZeroInt(), sdk.ZeroInt(), sdk.ZeroDec()) + + var ( + farmerAddr1 = s.addr(1) + amount1 = sdk.NewInt(5_000_000_000) + ) + + s.liquidFarm(pool.Id, farmerAddr1, sdk.NewCoin(pool.PoolCoinDenom, amount1), true) + s.nextBlock() + + // Ensure the amount of minted LFCoin + s.Require().Equal(amount1, s.getBalance(farmerAddr1, types.LiquidFarmCoinDenom(pool.Id)).Amount) + + s.nextAuction() + + // Ensure rewards auction is created + auctionId := s.keeper.GetLastRewardsAuctionId(s.ctx, pool.Id) + auction, found := s.keeper.GetRewardsAuction(s.ctx, auctionId, pool.Id) + s.Require().True(found) + + var ( + bidderAddr = s.addr(10) + biddingAmt = sdk.NewInt(100_000_000) + ) + + s.placeBid(auction.PoolId, bidderAddr, sdk.NewCoin(pool.PoolCoinDenom, biddingAmt), true) + s.nextBlock() + + s.nextAuction() + + // Ensure that the farming amount is increased due to auto compounding rewards + reserveAddr := types.LiquidFarmReserveAddress(pool.Id) + position, found := s.app.FarmKeeper.GetPosition(s.ctx, reserveAddr, pool.PoolCoinDenom) + s.Require().True(found) + s.Require().Equal(amount1.Add(biddingAmt), position.FarmingAmount) + + // Ensure that the bidder received the farming rewards + s.Require().True(!s.getBalance(bidderAddr, "stake").IsZero()) + + var ( + farmerAddr2 = s.addr(2) + amount2 = sdk.NewInt(5_100_000_000) + ) + + // Now, let's liquid farm again to see the changed mint rate + s.liquidFarm(pool.Id, farmerAddr2, sdk.NewCoin(pool.PoolCoinDenom, amount2), true) + s.nextBlock() + + // Ensure the less amount of minted LFCoin + s.Require().True( + s.getBalance(farmerAddr1, types.LiquidFarmCoinDenom(pool.Id)).Amount.Equal( + s.getBalance(farmerAddr2, types.LiquidFarmCoinDenom(pool.Id)).Amount)) +} + +func (s *KeeperTestSuite) TestBurnRate() { + pair := s.createPair(s.addr(0), "denom1", "denom2") + pool := s.createPool(s.addr(0), pair.Id, utils.ParseCoins("100_000_000denom1, 100_000_000denom2")) + plan := s.createPrivatePlan(s.addr(0), []farmtypes.RewardAllocation{ + { + PairId: pool.PairId, + RewardsPerDay: utils.ParseCoins("100_000_000stake"), + }, + }) + s.fundAddr(plan.GetFarmingPoolAddress(), utils.ParseCoins("500_000_000stake")) + + s.createLiquidFarm(pool.Id, sdk.ZeroInt(), sdk.ZeroInt(), sdk.ZeroDec()) + s.nextBlock() + + var ( + farmerAddr1 = s.addr(1) + amount1 = sdk.NewInt(200_000) + ) + + s.liquidFarm(pool.Id, farmerAddr1, sdk.NewCoin(pool.PoolCoinDenom, amount1), true) + s.nextBlock() + + var ( + farmerAddr2 = s.addr(2) + amount2 = sdk.NewInt(200_000) + ) + + s.liquidFarm(pool.Id, farmerAddr2, sdk.NewCoin(pool.PoolCoinDenom, amount2), true) + s.nextBlock() + + // Ensure that the reserve account farmed the amount + reserveAddr := types.LiquidFarmReserveAddress(pool.Id) + position, found := s.app.FarmKeeper.GetPosition(s.ctx, reserveAddr, pool.PoolCoinDenom) + s.Require().True(found) + s.Require().Equal(amount1.Add(amount2), position.FarmingAmount) + + s.nextAuction() + + s.placeBid(pool.Id, s.addr(10), utils.ParseCoin("100_000pool1"), true) + s.nextBlock() + + s.placeBid(pool.Id, s.addr(11), utils.ParseCoin("200_000pool1"), true) + s.nextBlock() + + _, found = s.keeper.GetCompoundingRewards(s.ctx, pool.Id) + s.Require().False(found) + + s.nextAuction() + + _, found = s.keeper.GetCompoundingRewards(s.ctx, pool.Id) + s.Require().True(found) + + s.liquidUnfarm(pool.Id, farmerAddr1, utils.ParseCoin("200_000lf1"), false) + s.nextBlock() + + s.Require().Equal(amount1, s.getBalance(farmerAddr1, pool.PoolCoinDenom).Amount) + + s.liquidUnfarm(pool.Id, farmerAddr2, utils.ParseCoin("200_000lf1"), false) + s.nextBlock() + + // Farmed + WinningBid (last one to unfarm) + s.Require().Equal(amount1.Add(amount2), s.getBalance(farmerAddr2, pool.PoolCoinDenom).Amount) +} diff --git a/x/liquidfarming/keeper/msg_server.go b/x/liquidfarming/keeper/msg_server.go new file mode 100644 index 00000000..aa213886 --- /dev/null +++ b/x/liquidfarming/keeper/msg_server.go @@ -0,0 +1,78 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/cosmosquad-labs/squad/v3/x/liquidfarming/types" +) + +type msgServer struct { + Keeper +} + +// NewMsgServerImpl returns an implementation of the MsgServer interface +// for the provided Keeper. +func NewMsgServerImpl(keeper Keeper) types.MsgServer { + return &msgServer{Keeper: keeper} +} + +var _ types.MsgServer = msgServer{} + +// LiquidFarm defines a method for farming pool coin and mint LFCoin for the farmer. +func (m msgServer) LiquidFarm(goCtx context.Context, msg *types.MsgLiquidFarm) (*types.MsgLiquidFarmResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + if err := m.Keeper.LiquidFarm(ctx, msg.PoolId, msg.GetFarmer(), msg.FarmingCoin); err != nil { + return nil, err + } + + return &types.MsgLiquidFarmResponse{}, nil +} + +// LiquidUnfarm defines a method for unfarming LFCoin to return the corresponding amount of pool coin. +func (m msgServer) LiquidUnfarm(goCtx context.Context, msg *types.MsgLiquidUnfarm) (*types.MsgLiquidUnfarmResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + if _, err := m.Keeper.LiquidUnfarm(ctx, msg.PoolId, msg.GetFarmer(), msg.UnfarmingCoin); err != nil { + return nil, err + } + + return &types.MsgLiquidUnfarmResponse{}, nil +} + +// LiquidUnfarmAndWithdraw defines a method for unfarming LFCoin and withdraw the corresponding amount of pool coin +// from the pool in the liquidity module. +// This is a convenient transaction message for a bidder to use when they participate in rewards auction. +func (m msgServer) LiquidUnfarmAndWithdraw(goCtx context.Context, msg *types.MsgLiquidUnfarmAndWithdraw) (*types.MsgLiquidUnfarmAndWithdrawResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + if err := m.Keeper.LiquidUnfarmAndWithdraw(ctx, msg.PoolId, msg.GetFarmer(), msg.UnfarmingCoin); err != nil { + return nil, err + } + + return &types.MsgLiquidUnfarmAndWithdrawResponse{}, nil +} + +// PlaceBid defines a method for placing a bid for a rewards auction. +func (m msgServer) PlaceBid(goCtx context.Context, msg *types.MsgPlaceBid) (*types.MsgPlaceBidResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + if _, err := m.Keeper.PlaceBid(ctx, msg.AuctionId, msg.PoolId, msg.GetBidder(), msg.BiddingCoin); err != nil { + return nil, err + } + + return &types.MsgPlaceBidResponse{}, nil +} + +// RefundBid defines a method for refunding the bid for the auction. +func (m msgServer) RefundBid(goCtx context.Context, msg *types.MsgRefundBid) (*types.MsgRefundBidResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + if err := m.Keeper.RefundBid(ctx, msg.AuctionId, msg.PoolId, msg.GetBidder()); err != nil { + return nil, err + } + + return &types.MsgRefundBidResponse{}, nil +} diff --git a/x/liquidfarming/keeper/store.go b/x/liquidfarming/keeper/store.go new file mode 100644 index 00000000..3918592f --- /dev/null +++ b/x/liquidfarming/keeper/store.go @@ -0,0 +1,242 @@ +package keeper + +import ( + "time" + + gogotypes "github.com/gogo/protobuf/types" + + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/cosmosquad-labs/squad/v3/x/liquidfarming/types" +) + +// GetLiquidFarm returns liquid farm object by the given pool id. +func (k Keeper) GetLiquidFarm(ctx sdk.Context, poolId uint64) (liquidFarm types.LiquidFarm, found bool) { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.GetLiquidFarmKey(poolId)) + if bz == nil { + return + } + k.cdc.MustUnmarshal(bz, &liquidFarm) + found = true + return +} + +// GetAllLiquidFarms returns all liquid farm objects stored in the store. +func (k Keeper) GetAllLiquidFarms(ctx sdk.Context) (liquidFarms []types.LiquidFarm) { + liquidFarms = []types.LiquidFarm{} + k.IterateLiquidFarms(ctx, func(liquidFarm types.LiquidFarm) (stop bool) { + liquidFarms = append(liquidFarms, liquidFarm) + return false + }) + return liquidFarms +} + +// SetLiquidFarm stores liquid farm object with the given pool id. +func (k Keeper) SetLiquidFarm(ctx sdk.Context, liquidFarm types.LiquidFarm) { + store := ctx.KVStore(k.storeKey) + bz := k.cdc.MustMarshal(&liquidFarm) + store.Set(types.GetLiquidFarmKey(liquidFarm.PoolId), bz) +} + +// DeleteLiquidFarm deletes the liquid farm object from the store. +func (k Keeper) DeleteLiquidFarm(ctx sdk.Context, liquidFarm types.LiquidFarm) { + store := ctx.KVStore(k.storeKey) + store.Delete(types.GetLiquidFarmKey(liquidFarm.PoolId)) +} + +// GetLastRewardsAuctionId returns the last rewards auction id. +func (k Keeper) GetLastRewardsAuctionId(ctx sdk.Context, poolId uint64) uint64 { + var id uint64 + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.GetLastRewardsAuctionIdKey(poolId)) + if bz == nil { + id = 0 // initialize the auction id + } else { + val := gogotypes.UInt64Value{} + k.cdc.MustUnmarshal(bz, &val) + id = val.GetValue() + } + return id +} + +// SetLastRewardsAuctionId stores the last rewards auction id. +func (k Keeper) SetLastRewardsAuctionId(ctx sdk.Context, id uint64, poolId uint64) { + store := ctx.KVStore(k.storeKey) + bz := k.cdc.MustMarshal(&gogotypes.UInt64Value{Value: id}) + store.Set(types.GetLastRewardsAuctionIdKey(poolId), bz) +} + +// GetLastRewardsAuctionEndTime returns the last rewards auction end time. +func (k Keeper) GetLastRewardsAuctionEndTime(ctx sdk.Context) time.Time { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.RewardsAuctionTimeKey) + if bz == nil { + return time.Time{} + } + ts, err := sdk.ParseTimeBytes(bz) + if err != nil { + panic(err) + } + return ts +} + +// SetLastRewardsAuctionEndTime stores the last rewards auction end time. +func (k Keeper) SetLastRewardsAuctionEndTime(ctx sdk.Context, auctionTime time.Time) { + store := ctx.KVStore(k.storeKey) + bz := sdk.FormatTimeBytes(auctionTime) + store.Set(types.RewardsAuctionTimeKey, bz) +} + +// GetRewardsAuction returns the reward auction object by the given pool id and auction id. +func (k Keeper) GetRewardsAuction(ctx sdk.Context, auctionId uint64, poolId uint64) (auction types.RewardsAuction, found bool) { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.GetRewardsAuctionKey(auctionId, poolId)) + if bz == nil { + return auction, false + } + + auction = types.MustUnmarshalRewardsAuction(k.cdc, bz) + + return auction, true +} + +// GetAllRewardsAuctions returns all rewards auctions in the store. +func (k Keeper) GetAllRewardsAuctions(ctx sdk.Context) (auctions []types.RewardsAuction) { + auctions = []types.RewardsAuction{} + k.IterateRewardsAuctions(ctx, func(auction types.RewardsAuction) (stop bool) { + auctions = append(auctions, auction) + return false + }) + return auctions +} + +// SetRewardsAuction stores rewards auction. +func (k Keeper) SetRewardsAuction(ctx sdk.Context, auction types.RewardsAuction) { + store := ctx.KVStore(k.storeKey) + bz := types.MustMarshalRewardsAuction(k.cdc, auction) + store.Set(types.GetRewardsAuctionKey(auction.Id, auction.PoolId), bz) +} + +// GetCompoundingRewards returns the last farming rewards by the given pool id. +func (k Keeper) GetCompoundingRewards(ctx sdk.Context, poolId uint64) (rewards types.CompoundingRewards, found bool) { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.GetCompoundingRewardsKey(poolId)) + if bz == nil { + return + } + k.cdc.MustUnmarshal(bz, &rewards) + found = true + return +} + +// SetCompoundingRewards stores compounding rewards with the given pool id. +func (k Keeper) SetCompoundingRewards(ctx sdk.Context, poolId uint64, rewards types.CompoundingRewards) { + store := ctx.KVStore(k.storeKey) + bz := k.cdc.MustMarshal(&rewards) + store.Set(types.GetCompoundingRewardsKey(poolId), bz) +} + +// GetBid returns the bid object by the given pool id and bidder address. +func (k Keeper) GetBid(ctx sdk.Context, poolId uint64, bidder sdk.AccAddress) (bid types.Bid, found bool) { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.GetBidKey(poolId, bidder)) + if bz == nil { + return bid, false + } + k.cdc.MustUnmarshal(bz, &bid) + return bid, true +} + +// SetBid stores a bid object. +func (k Keeper) SetBid(ctx sdk.Context, bid types.Bid) { + store := ctx.KVStore(k.storeKey) + bz := k.cdc.MustMarshal(&bid) + store.Set(types.GetBidKey(bid.PoolId, bid.GetBidder()), bz) +} + +// DeleteBid deletes the bid object. +func (k Keeper) DeleteBid(ctx sdk.Context, bid types.Bid) { + store := ctx.KVStore(k.storeKey) + store.Delete(types.GetBidKey(bid.PoolId, bid.GetBidder())) +} + +// GetBidsByPoolId returns all bid objects by the pool id. +func (k Keeper) GetBidsByPoolId(ctx sdk.Context, poolId uint64) []types.Bid { + bids := []types.Bid{} + k.IterateBidsByPoolId(ctx, poolId, func(bid types.Bid) (stop bool) { + bids = append(bids, bid) + return false + }) + return bids +} + +// GetWinningBid returns the winning bid object by the given pool id and auction id. +func (k Keeper) GetWinningBid(ctx sdk.Context, auctionId uint64, poolId uint64) (bid types.Bid, found bool) { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.GetWinningBidKey(auctionId, poolId)) + if bz == nil { + return bid, false + } + k.cdc.MustUnmarshal(bz, &bid) + return bid, true +} + +// SetWinningBid stores the winning bid with the auction id. +func (k Keeper) SetWinningBid(ctx sdk.Context, auctionId uint64, bid types.Bid) { + store := ctx.KVStore(k.storeKey) + bz := k.cdc.MustMarshal(&bid) + store.Set(types.GetWinningBidKey(auctionId, bid.PoolId), bz) +} + +// DeleteWinningBid deletes the winning bid from the store. +func (k Keeper) DeleteWinningBid(ctx sdk.Context, auctionId, poolId uint64) { + store := ctx.KVStore(k.storeKey) + store.Delete(types.GetWinningBidKey(auctionId, poolId)) +} + +// IterateLiquidFarms iterates through all liquid farm objects +// stored in the store and invokes callback function for each item. +// Stops the iteration when the callback function for each time. +func (k Keeper) IterateLiquidFarms(ctx sdk.Context, cb func(liquidFarm types.LiquidFarm) (stop bool)) { + store := ctx.KVStore(k.storeKey) + iter := sdk.KVStorePrefixIterator(store, types.LiquidFarmKeyPrefix) + defer iter.Close() + for ; iter.Valid(); iter.Next() { + var liquidFarm types.LiquidFarm + k.cdc.MustUnmarshal(iter.Value(), &liquidFarm) + if cb(liquidFarm) { + break + } + } +} + +// IterateRewardsAuctions iterates over all the stored auctions and performs a callback function. +// Stops iteration when callback returns true. +func (k Keeper) IterateRewardsAuctions(ctx sdk.Context, cb func(auction types.RewardsAuction) (stop bool)) { + store := ctx.KVStore(k.storeKey) + iterator := sdk.KVStorePrefixIterator(store, types.RewardsAuctionKeyPrefix) + defer iterator.Close() + for ; iterator.Valid(); iterator.Next() { + auction := types.MustUnmarshalRewardsAuction(k.cdc, iterator.Value()) + if cb(auction) { + break + } + } +} + +// IterateBidsBy PoolId iterates through all bids by pool id stored in the store and +// invokes callback function for each item. +// Stops the iteration when the callback function returns true. +func (k Keeper) IterateBidsByPoolId(ctx sdk.Context, poolId uint64, cb func(bid types.Bid) (stop bool)) { + store := ctx.KVStore(k.storeKey) + iter := sdk.KVStorePrefixIterator(store, types.GetBidByPoolIdPrefix(poolId)) + defer iter.Close() + for ; iter.Valid(); iter.Next() { + var bid types.Bid + k.cdc.MustUnmarshal(iter.Value(), &bid) + if cb(bid) { + break + } + } +} diff --git a/x/liquidfarming/module.go b/x/liquidfarming/module.go new file mode 100644 index 00000000..ef1a2c5f --- /dev/null +++ b/x/liquidfarming/module.go @@ -0,0 +1,208 @@ +package liquidfarming + +import ( + "context" + "encoding/json" + "fmt" + "math/rand" + + "github.com/gorilla/mux" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + abci "github.com/tendermint/tendermint/abci/types" + + "github.com/cosmosquad-labs/squad/v3/x/liquidfarming/client/cli" + "github.com/cosmosquad-labs/squad/v3/x/liquidfarming/keeper" + "github.com/cosmosquad-labs/squad/v3/x/liquidfarming/simulation" + "github.com/cosmosquad-labs/squad/v3/x/liquidfarming/types" +) + +var ( + _ module.AppModule = AppModule{} + _ module.AppModuleBasic = AppModuleBasic{} +) + +// ---------------------------------------------------------------------------- +// AppModuleBasic +// ---------------------------------------------------------------------------- + +// AppModuleBasic implements the AppModuleBasic interface for the module. +type AppModuleBasic struct { + cdc codec.Codec +} + +func NewAppModuleBasic(cdc codec.Codec) AppModuleBasic { + return AppModuleBasic{cdc: cdc} +} + +// Name returns the module's name. +func (AppModuleBasic) Name() string { + return types.ModuleName +} + +// RegisterLegacyAminoCodec registers the module's types for the legacy amino codec. +func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + types.RegisterLegacyAminoCodec(cdc) +} + +// RegisterInterfaces registers the module's interface types +func (a AppModuleBasic) RegisterInterfaces(reg cdctypes.InterfaceRegistry) { + types.RegisterInterfaces(reg) +} + +// DefaultGenesis returns the module's default genesis state. +func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { + return cdc.MustMarshalJSON(types.DefaultGenesis()) +} + +// ValidateGenesis performs genesis state validation for the module. +func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error { + var genState types.GenesisState + if err := cdc.UnmarshalJSON(bz, &genState); err != nil { + return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err) + } + return genState.Validate() +} + +// RegisterRESTRoutes registers the module's REST service handlers. +func (AppModuleBasic) RegisterRESTRoutes(_ client.Context, _ *mux.Router) {} + +// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module. +func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { + if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil { + panic(err) + } +} + +// GetTxCmd returns the module's root tx command. +func (a AppModuleBasic) GetTxCmd() *cobra.Command { + return cli.GetTxCmd() +} + +// GetQueryCmd returns the module's root query command. +func (AppModuleBasic) GetQueryCmd() *cobra.Command { + return cli.GetQueryCmd(types.StoreKey) +} + +// ---------------------------------------------------------------------------- +// AppModule +// ---------------------------------------------------------------------------- + +// AppModule implements the AppModule interface for the module. +type AppModule struct { + AppModuleBasic + + keeper keeper.Keeper + accountKeeper types.AccountKeeper + bankKeeper types.BankKeeper +} + +// NewAppModule creates a new AppModule object. +func NewAppModule( + cdc codec.Codec, + keeper keeper.Keeper, + accountKeeper types.AccountKeeper, + bankKeeper types.BankKeeper, +) AppModule { + return AppModule{ + AppModuleBasic: NewAppModuleBasic(cdc), + keeper: keeper, + accountKeeper: accountKeeper, + bankKeeper: bankKeeper, + } +} + +// Name returns the module's name. +func (am AppModule) Name() string { + return am.AppModuleBasic.Name() +} + +// Route returns the module's message routing key. +func (am AppModule) Route() sdk.Route { + return sdk.NewRoute(types.RouterKey, NewHandler(am.keeper)) +} + +// QuerierRoute returns the module's query routing key. +func (AppModule) QuerierRoute() string { return types.QuerierRoute } + +// LegacyQuerierHandler returns the module's Querier. +func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sdk.Querier { + return nil +} + +// RegisterServices registers a GRPC query service to respond to the +// module-specific GRPC queries. +func (am AppModule) RegisterServices(cfg module.Configurator) { + types.RegisterQueryServer(cfg.QueryServer(), keeper.Querier{Keeper: am.keeper}) +} + +// RegisterInvariants registers the module's invariants. +func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} + +// InitGenesis performs the module's genesis initialization It returns +// no validator updates. +func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, gs json.RawMessage) []abci.ValidatorUpdate { + var genState types.GenesisState + cdc.MustUnmarshalJSON(gs, &genState) + am.keeper.InitGenesis(ctx, genState) + return []abci.ValidatorUpdate{} +} + +// ExportGenesis returns the module's exported genesis state as raw JSON bytes. +func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { + genState := am.keeper.ExportGenesis(ctx) + return cdc.MustMarshalJSON(genState) +} + +// ConsensusVersion implements ConsensusVersion. +func (AppModule) ConsensusVersion() uint64 { return 1 } + +// BeginBlock executes all ABCI BeginBlock logic respective to the module. +func (am AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) { + BeginBlocker(ctx, am.keeper) +} + +// EndBlock executes all ABCI EndBlock logic respective to the module. It +// returns no validator updates. +func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { + return []abci.ValidatorUpdate{} +} + +// ---------------------------------------------------------------------------- +// AppModuleSimulation +// ---------------------------------------------------------------------------- + +// GenerateGenesisState creates a randomized GenState of the liquidfarming module. +func (AppModule) GenerateGenesisState(simState *module.SimulationState) { + simulation.RandomizedGenState(simState) +} + +// ProposalContents returns all the liquidfarming content functions used to +// simulate governance proposals. +func (am AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedProposalContent { + return nil +} + +// RandomizedParams creates randomized liquidfarming param changes for the simulator. +func (am AppModule) RandomizedParams(r *rand.Rand) []simtypes.ParamChange { + return simulation.ParamChanges(r) +} + +// RegisterStoreDecoder registers a decoder for liquidfarming module's types +func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) { + sdr[types.StoreKey] = simulation.NewDecodeStore(am.cdc) +} + +// WeightedOperations returns the all the liquidfarming module operations with their respective weights. +func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation { + return simulation.WeightedOperations( + simState.AppParams, simState.Cdc, am.accountKeeper, am.bankKeeper, am.keeper, + ) +} diff --git a/x/liquidfarming/simulation/decoder.go b/x/liquidfarming/simulation/decoder.go new file mode 100644 index 00000000..1227dac2 --- /dev/null +++ b/x/liquidfarming/simulation/decoder.go @@ -0,0 +1,46 @@ +package simulation + +import ( + "bytes" + "fmt" + + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/types/kv" + + "github.com/cosmosquad-labs/squad/v3/x/liquidfarming/types" +) + +// NewDecodeStore returns a decoder function closure that unmarshals the KVPair's +// Value to the corresponding liquidfarming type. +func NewDecodeStore(cdc codec.Codec) func(kvA, kvB kv.Pair) string { + return func(kvA, kvB kv.Pair) string { + switch { + case bytes.Equal(kvA.Key[:1], types.LiquidFarmKeyPrefix): + var lA, lB types.LiquidFarm + cdc.MustUnmarshal(kvA.Value, &lA) + cdc.MustUnmarshal(kvB.Value, &lB) + return fmt.Sprintf("%v\n%v", lA, lB) + + case bytes.Equal(kvA.Key[:1], types.CompoundingRewardsKeyPrefix): + var cA, cB types.CompoundingRewards + cdc.MustUnmarshal(kvA.Value, &cA) + cdc.MustUnmarshal(kvB.Value, &cB) + return fmt.Sprintf("%v\n%v", cA, cB) + + case bytes.Equal(kvA.Key[:1], types.RewardsAuctionKeyPrefix): + var rA, rB types.RewardsAuction + cdc.MustUnmarshal(kvA.Value, &rA) + cdc.MustUnmarshal(kvB.Value, &rB) + return fmt.Sprintf("%v\n%v", rA, rB) + + case bytes.Equal(kvA.Key[:1], types.BidKeyPrefix): + var bA, bB types.Bid + cdc.MustUnmarshal(kvA.Value, &bA) + cdc.MustUnmarshal(kvB.Value, &bB) + return fmt.Sprintf("%v\n%v", bA, bB) + + default: + panic(fmt.Sprintf("invalid liquid farm key prefix %X", kvA.Key[:1])) + } + } +} diff --git a/x/liquidfarming/simulation/decoder_test.go b/x/liquidfarming/simulation/decoder_test.go new file mode 100644 index 00000000..3f886004 --- /dev/null +++ b/x/liquidfarming/simulation/decoder_test.go @@ -0,0 +1,56 @@ +package simulation_test + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/cosmos/cosmos-sdk/simapp" + "github.com/cosmos/cosmos-sdk/types/kv" + + "github.com/cosmosquad-labs/squad/v3/x/liquidfarming/simulation" + "github.com/cosmosquad-labs/squad/v3/x/liquidfarming/types" +) + +func TestDecodeFarmingStore(t *testing.T) { + cdc := simapp.MakeTestEncodingConfig().Marshaler + dec := simulation.NewDecodeStore(cdc) + + liquidFarm := types.LiquidFarm{} + compoundingRewards := types.CompoundingRewards{} + rewardsAuction := types.RewardsAuction{} + bid := types.Bid{} + + kvPairs := kv.Pairs{ + Pairs: []kv.Pair{ + {Key: types.LiquidFarmKeyPrefix, Value: cdc.MustMarshal(&liquidFarm)}, + {Key: types.CompoundingRewardsKeyPrefix, Value: cdc.MustMarshal(&compoundingRewards)}, + {Key: types.RewardsAuctionKeyPrefix, Value: cdc.MustMarshal(&rewardsAuction)}, + {Key: types.BidKeyPrefix, Value: cdc.MustMarshal(&bid)}, + {Key: []byte{0x99}, Value: []byte{0x99}}, + }, + } + + tests := []struct { + name string + expectedLog string + }{ + {"LiquidFarm", fmt.Sprintf("%v\n%v", liquidFarm, liquidFarm)}, + {"CompoundingRewards", fmt.Sprintf("%v\n%v", compoundingRewards, compoundingRewards)}, + {"RewardsAuction", fmt.Sprintf("%v\n%v", rewardsAuction, rewardsAuction)}, + {"Bid", fmt.Sprintf("%v\n%v", bid, bid)}, + {"other", ""}, + } + for i, tt := range tests { + i, tt := i, tt + t.Run(tt.name, func(t *testing.T) { + switch i { + case len(tests) - 1: + require.Panics(t, func() { dec(kvPairs.Pairs[i], kvPairs.Pairs[i]) }, tt.name) + default: + require.Equal(t, tt.expectedLog, dec(kvPairs.Pairs[i], kvPairs.Pairs[i]), tt.name) + } + }) + } +} diff --git a/x/liquidfarming/simulation/genesis.go b/x/liquidfarming/simulation/genesis.go new file mode 100644 index 00000000..6af257a7 --- /dev/null +++ b/x/liquidfarming/simulation/genesis.go @@ -0,0 +1,65 @@ +package simulation + +// DONTCOVER + +import ( + "math/rand" + "time" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + "github.com/cosmos/cosmos-sdk/types/simulation" + + utils "github.com/cosmosquad-labs/squad/v3/types" + "github.com/cosmosquad-labs/squad/v3/x/liquidfarming/types" +) + +// Simulation parameter constants. +const ( + RewardsAuctionDuration = "rewards_auction_duration" + LiquidFarms = "liquid_farms" +) + +// GenRewardsAuctionDuration returns randomized rewards auction duration. +func GenRewardsAuctionDuration(r *rand.Rand) time.Duration { + return time.Duration(simulation.RandIntBetween(r, 1, 24)) * time.Hour +} + +// GenLiquidFarms returns randomized liquid farm list. +func GenLiquidFarms(r *rand.Rand) []types.LiquidFarm { + numLiquidFarms := r.Intn(5) + liquidFarms := []types.LiquidFarm{} + for i := 0; i < numLiquidFarms; i++ { + liquidFarm := types.LiquidFarm{ + PoolId: uint64(i + 1), + MinFarmAmount: utils.RandomInt(r, sdk.ZeroInt(), sdk.NewInt(1_000_000)), + MinBidAmount: utils.RandomInt(r, sdk.ZeroInt(), sdk.NewInt(1_000_000)), + FeeRate: simulation.RandomDecAmount(r, sdk.NewDecWithPrec(1, 2)), + } + liquidFarms = append(liquidFarms, liquidFarm) + } + return liquidFarms +} + +// RandomizedGenState generates a random GenesisState. +func RandomizedGenState(simState *module.SimulationState) { + var rewardsAuctionDuration time.Duration + simState.AppParams.GetOrGenerate( + simState.Cdc, RewardsAuctionDuration, &rewardsAuctionDuration, simState.Rand, + func(r *rand.Rand) { rewardsAuctionDuration = GenRewardsAuctionDuration(r) }, + ) + + var liquidFarms []types.LiquidFarm + simState.AppParams.GetOrGenerate( + simState.Cdc, LiquidFarms, &liquidFarms, simState.Rand, + func(r *rand.Rand) { liquidFarms = GenLiquidFarms(r) }, + ) + + genState := types.GenesisState{ + Params: types.Params{ + RewardsAuctionDuration: rewardsAuctionDuration, + LiquidFarms: liquidFarms, + }, + } + simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(&genState) +} diff --git a/x/liquidfarming/simulation/genesis_test.go b/x/liquidfarming/simulation/genesis_test.go new file mode 100644 index 00000000..8828965f --- /dev/null +++ b/x/liquidfarming/simulation/genesis_test.go @@ -0,0 +1,82 @@ +package simulation_test + +import ( + "encoding/json" + "math/rand" + "testing" + "time" + + "github.com/stretchr/testify/require" + + "github.com/cosmos/cosmos-sdk/codec" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + + "github.com/cosmosquad-labs/squad/v3/x/liquidfarming/simulation" + "github.com/cosmosquad-labs/squad/v3/x/liquidfarming/types" +) + +// TestRandomizedGenState tests the normal scenario of applying RandomizedGenState. +// Abnormal scenarios are not tested here. +func TestRandomizedGenState(t *testing.T) { + interfaceRegistry := codectypes.NewInterfaceRegistry() + cdc := codec.NewProtoCodec(interfaceRegistry) + s := rand.NewSource(2) + r := rand.New(s) + + simState := module.SimulationState{ + AppParams: make(simtypes.AppParams), + Cdc: cdc, + Rand: r, + NumBonded: 3, + Accounts: simtypes.RandomAccounts(r, 3), + InitialStake: 1000, + GenState: make(map[string]json.RawMessage), + } + + simulation.RandomizedGenState(&simState) + + var genState types.GenesisState + simState.Cdc.MustUnmarshalJSON(simState.GenState[types.ModuleName], &genState) + + expLiquidFarms := []types.LiquidFarm{ + { + PoolId: 1, + MinFarmAmount: sdk.NewInt(807408), + MinBidAmount: sdk.NewInt(713862), + FeeRate: sdk.MustNewDecFromStr("0.004768816528183848"), + }, + } + require.Equal(t, 18*time.Hour, genState.Params.RewardsAuctionDuration) + require.Equal(t, expLiquidFarms, genState.Params.LiquidFarms) +} + +// TestRandomizedGenState tests abnormal scenarios of applying RandomizedGenState. +func TestRandomizedGenState1(t *testing.T) { + interfaceRegistry := codectypes.NewInterfaceRegistry() + cdc := codec.NewProtoCodec(interfaceRegistry) + + s := rand.NewSource(1) + r := rand.New(s) + + // all these tests will panic + tests := []struct { + simState module.SimulationState + panicMsg string + }{ + { // panic => reason: incomplete initialization of the simState + module.SimulationState{}, "invalid memory address or nil pointer dereference"}, + { // panic => reason: incomplete initialization of the simState + module.SimulationState{ + AppParams: make(simtypes.AppParams), + Cdc: cdc, + Rand: r, + }, "assignment to entry in nil map"}, + } + + for _, tt := range tests { + require.Panicsf(t, func() { simulation.RandomizedGenState(&tt.simState) }, tt.panicMsg) + } +} diff --git a/x/liquidfarming/simulation/operations.go b/x/liquidfarming/simulation/operations.go new file mode 100644 index 00000000..d7285741 --- /dev/null +++ b/x/liquidfarming/simulation/operations.go @@ -0,0 +1,146 @@ +package simulation + +import ( + "math/rand" + + "github.com/cosmos/cosmos-sdk/baseapp" + "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + "github.com/cosmos/cosmos-sdk/x/simulation" + + appparams "github.com/cosmosquad-labs/squad/v3/app/params" + "github.com/cosmosquad-labs/squad/v3/x/liquidfarming/keeper" + "github.com/cosmosquad-labs/squad/v3/x/liquidfarming/types" +) + +// Simulation operation weights constants. +const ( + OpWeightMsgLiquidFarm = "op_weight_msg_liquid_farm" + OpWeightMsgLiquidUnfarm = "op_weight_msg_liquid_unfarm" + OpWeightMsgPlaceBid = "op_weight_msg_place_bid" + OpWeightMsgRefundBid = "op_weight_msg_refund_bid" +) + +var ( + Gas = uint64(20000000) + Fees = sdk.Coins{ + { + Denom: "stake", + Amount: sdk.NewInt(0), + }, + } +) + +// WeightedOperations returns all the operations from the module with their respective weights. +func WeightedOperations( + appParams simtypes.AppParams, + cdc codec.JSONCodec, + ak types.AccountKeeper, + bk types.BankKeeper, + k keeper.Keeper, +) simulation.WeightedOperations { + + var weightMsgLiquidFarm int + appParams.GetOrGenerate(cdc, OpWeightMsgLiquidFarm, &weightMsgLiquidFarm, nil, + func(_ *rand.Rand) { + weightMsgLiquidFarm = appparams.DefaultWeightMsgLiquidFarm + }, + ) + + var weightMsgLiquidUnfarm int + appParams.GetOrGenerate(cdc, OpWeightMsgLiquidUnfarm, &weightMsgLiquidUnfarm, nil, + func(_ *rand.Rand) { + weightMsgLiquidUnfarm = appparams.DefaultWeightMsgLiquidUnfarm + }, + ) + + var weightMsgPlaceBid int + appParams.GetOrGenerate(cdc, OpWeightMsgPlaceBid, &weightMsgPlaceBid, nil, + func(_ *rand.Rand) { + weightMsgPlaceBid = appparams.DefaultWeightMsgPlaceBid + }, + ) + + var weightMsgRefundBid int + appParams.GetOrGenerate(cdc, OpWeightMsgRefundBid, &weightMsgRefundBid, nil, + func(_ *rand.Rand) { + weightMsgRefundBid = appparams.DefaultWeightMsgRefundBid + }, + ) + + return simulation.WeightedOperations{ + simulation.NewWeightedOperation( + weightMsgLiquidFarm, + SimulateMsgLiquidFarm(ak, bk, k), + ), + simulation.NewWeightedOperation( + weightMsgLiquidUnfarm, + SimulateMsgLiquidUnfarm(ak, bk, k), + ), + simulation.NewWeightedOperation( + weightMsgPlaceBid, + SimulateMsgPlaceBid(ak, bk, k), + ), + simulation.NewWeightedOperation( + weightMsgRefundBid, + SimulateMsgRefundBid(ak, bk, k), + ), + } +} + +// SimulateMsgLiquidFarm generates a MsgLiquidFarm with random values +// nolint: interfacer +func SimulateMsgLiquidFarm(ak types.AccountKeeper, bk types.BankKeeper, k keeper.Keeper) simtypes.Operation { + return func( + r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + + // TODO: not implemented yet + + return simtypes.OperationMsg{}, nil, nil + // return simtypes.NewOperationMsg(msg, true, "", nil), nil, nil + } +} + +// SimulateMsgLiquidUnfarm generates a MsgLiquidUnfarm with random values +// nolint: interfacer +func SimulateMsgLiquidUnfarm(ak types.AccountKeeper, bk types.BankKeeper, k keeper.Keeper) simtypes.Operation { + return func( + r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + + // TODO: not implemented yet + + return simtypes.OperationMsg{}, nil, nil + // return simtypes.NewOperationMsg(msg, true, "", nil), nil, nil + } +} + +// SimulateMsgPlaceBid generates a MsgPlaceBid with random values +// nolint: interfacer +func SimulateMsgPlaceBid(ak types.AccountKeeper, bk types.BankKeeper, k keeper.Keeper) simtypes.Operation { + return func( + r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + + // TODO: not implemented yet + + return simtypes.OperationMsg{}, nil, nil + // return simtypes.NewOperationMsg(msg, true, "", nil), nil, nil + } +} + +// SimulateMsgRefundBid generates a MsgRefundBid with random values +// nolint: interfacer +func SimulateMsgRefundBid(ak types.AccountKeeper, bk types.BankKeeper, k keeper.Keeper) simtypes.Operation { + return func( + r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + + // TODO: not implemented yet + + return simtypes.OperationMsg{}, nil, nil + // return simtypes.NewOperationMsg(msg, true, "", nil), nil, nil + } +} diff --git a/x/liquidfarming/simulation/params.go b/x/liquidfarming/simulation/params.go new file mode 100644 index 00000000..f95b0749 --- /dev/null +++ b/x/liquidfarming/simulation/params.go @@ -0,0 +1,25 @@ +package simulation + +// DONTCOVER + +import ( + "fmt" + "math/rand" + + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + "github.com/cosmos/cosmos-sdk/x/simulation" + + "github.com/cosmosquad-labs/squad/v3/x/liquidfarming/types" +) + +// ParamChanges defines the parameters that can be modified by param change proposals +// on the simulation. +func ParamChanges(r *rand.Rand) []simtypes.ParamChange { + return []simtypes.ParamChange{ + simulation.NewSimParamChange(types.ModuleName, string(types.KeyRewardsAuctionDuration), + func(r *rand.Rand) string { + return fmt.Sprintf("\"%d\"", GenRewardsAuctionDuration(r)) + }, + ), + } +} diff --git a/x/liquidfarming/simulation/params_test.go b/x/liquidfarming/simulation/params_test.go new file mode 100644 index 00000000..cacd7dcf --- /dev/null +++ b/x/liquidfarming/simulation/params_test.go @@ -0,0 +1,34 @@ +package simulation_test + +import ( + "math/rand" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/cosmosquad-labs/squad/v3/x/liquidfarming/simulation" +) + +func TestParamChanges(t *testing.T) { + r := rand.New(rand.NewSource(0)) + + paramChanges := simulation.ParamChanges(r) + require.Len(t, paramChanges, 1) + + expected := []struct { + composedKey string + key string + simValue string + subspace string + }{ + {"liquidfarming/RewardsAuctionDuration", "RewardsAuctionDuration", "\"43200000000000\"", "liquidfarming"}, + // {"liquidfarming/LiquidFarms", "LiquidFarms", "[]", "liquidfarming"}, + } + + for i, p := range paramChanges { + require.Equal(t, expected[i].composedKey, p.ComposedKey()) + require.Equal(t, expected[i].key, p.Key()) + require.Equal(t, expected[i].simValue, p.SimValue()(r)) + require.Equal(t, expected[i].subspace, p.Subspace()) + } +} diff --git a/x/liquidfarming/spec/01_concepts.md b/x/liquidfarming/spec/01_concepts.md new file mode 100644 index 00000000..aba4f635 --- /dev/null +++ b/x/liquidfarming/spec/01_concepts.md @@ -0,0 +1,68 @@ + +# Concepts + +This is the concept for `Liquidfarming` module in Crescent Network. + +## LiquidFarming Module + +The `liquidfarming` module provides a functionality for farmers to have another option to use with their liquidity pool coins in Crescent Network. + +The module allows farmers to farm their pool coin and mint a synthetic version of the pool coin called LFCoin. +Farmers can use the LFCoin to take a full advantage of Crescent functionality, such as Boost. +On behalf of farmers, the module stakes their pool coin to the `farming` module and receives farming rewards for every epoch. +The module provides auto-compounding of the rewards by going through an auction process, which results in the exchange of the farming rewards coin(s) into the pool coin. + +## Liquid Farm + +A `liquidFarm` corresponds to one unique pool id. A `liquidFarm` stakes and unstakes the pool coins as users’ requests. When the rewards are allocated by staking the pool coins, the `liquidFarm` creates and manages an auction in order to exchange the rewards to pool coins to be staked additionally. + +A `liquidFarm` can be registered to the parameter `liquidFarms` by governance for activating the liquid farming of a pool. +When the `liquidFarm` is registered to the parameter, users can request to farm their pool coins. + +A `liquidFarm` can be removed in the parameter `liquidFarms` by governance for deactivating the liquid farming of a pool. +When the `liquidFarm` is removed, the module unstakes all pool coins in the module, users cannot request to farm their pool coins, but users can still request to unfarm LF coins. +In this case, the ongoing rewards auction becomes finished, all bids are refunded, and a new auction is not started. + +## Liquid Farm + +Once a user farms their pool coin, the user receives LFCoin instantly minted. +The following formula is used for an exchange rate of `LFCoinMint` (which is also called `mintedCoin`) when a user farms with `LPCoinFarm` (which is also called `farmingCoin`). + +$$LFCoinMint = \frac{LFCoinTotalSupply}{LPCoinTotalStaked+LPCoinTotalQueued} \times LPCoinFarm,$$ + +where `LFCoinTotalSupply` is not zero. +`LPCoinTotalQueued` is the amount of pool coins in `FarmQueued` by the `liquidfarming` module. +If `LFCoinTotalSupply` is zero, then the following formula is applied: + +$$LFCoinMint = LPCoinFarm.$$ + +## Liquid Unfarm + +When a user unfarms their LFCoin, the module burns the LFCoin and releases the corresponding amount of pool coin. +The following formula is used for an exchange rate of `LFCoinBurn` (which is also called `burningCoin`) to receive `LPCoinUnfarm` (which is also called `unfarmedCoin`): + +$$LPCoinUnfarm = \frac{LPCoinTotalStaked+LPCoinTotalQueued-CompoundingRewards}{LFCoinTotalSupply} \times LFCoinBurn,$$ + +if $$LFCoinBurn < LFCoinTotalSupply$$, where `CompoundingRewards` is the amount of pool coins obtained from the last rewards auction, which is in `FarmQueued`. +If $$LFCoinBurn = LFCoinTotalSupply$$, the following formula is used: + +$$LPCoinUnfarm = \frac{LPCoinTotalStaked+LPCoinTotalQueued}{LFCoinTotalSupply} \times LFCoinBurn.$$ + +If the `liquidfarm` is not registered in the parameter, the following formula is used an exchange rate of `LFCoinBurn`: + +$$LPCoinUnfarm = \frac{LPCoinTotalQueued}{LFCoinTotalSupply} \times LFCoinBurn.$$ + +## Farming Rewards and Auction + +On behalf of users, the module stakes their pool coins and claims farming rewards. +In order to exchange the rewards coin(s) into the pool coin to be additionally staked for farming, the module creates an auction to sell the rewards that will be received at the end of the epoch. +Note that the exact amount of the rewards being auctioned is not determined when the auction is created, but will be determined when the auction ends. +The amount of the rewards depends on the total amount of staked pool coins and the `liquidfarming` module’s staked pool coin, which can be varied during the epoch. +Therefore, a bidder to place a bid for the auction should be aware of this uncertainty of the rewards amount. + +## Bidding for Auction and Winning Bid + +A bidder can place a bid with the pool coin, which is the paying coin of the auction. +A bidder only can place a single bid per auction of a liquid farm. +The bid amount of the pool coin must be higher than the current winning bid amount that is the highest bid amount of the auction at the moment. +The bidder placing the bid with the highest amount of the pool coin becomes the winner of the auction and will takes all the accumulated rewards amount at the end of the auction. \ No newline at end of file diff --git a/x/liquidfarming/spec/02_state.md b/x/liquidfarming/spec/02_state.md new file mode 100644 index 00000000..c07d3c5d --- /dev/null +++ b/x/liquidfarming/spec/02_state.md @@ -0,0 +1,87 @@ + + +# State + +The `liquidfarming` module keeps track of the states of pool coins and LFCoins. + +## LiquidFarm + +```go +// LiquidFarms tracks the list of the activated LiquidFarms +type LiquidFarms struct { + liquidfarms []LiquidFarm +} + +// LiquidFarm defines liquid farm. +type LiquidFarm struct { + PoolId uint64 // the pool id + MinDepositAmount sdk.Int // the minimum deposit amount; it allows zero value + MinBidAmount sdk.Int // the minimum bid amount; it allows zero value + AuctionPeriod time.Duration // default value is 12 hours +} +``` + +## RewardsAuction + +```go +// AuctionStatus enumerates the valid status of an auction. +type AuctionStatus int32 + +const ( + AuctionStatusNil AuctionStatus = 0 + AuctionStatusStarted AuctionStatus = 1 + AuctionStatusFinished AuctionStatus = 2 + AuctionStatusSkipped AuctionStatus = 3 +) + +// RewardsAuction defines rewards auction information. +type RewardsAuction struct { + Id uint64 // rewards auction id + PoolId uint64 // corresponding pool id of the target liquid farm + BiddingCoinDenom string // corresponding pool coin denom + PayingReserveAddress string // the paying reserve address that collects bidding coin placed by bidders + StartTime time.Time // the auction start time + EndTime time.Time // the auction end time + Status AuctionStatus // the auction status + Winner string // the bidder who won the auction + WinningAmount sdk.Coin // the winning amount placed by the winner + Rewards sdk.Coins // the farming rewards for are accumulated every block +} +``` + +## CompoundingRewards + +```go +// CompoundingRewards records the amount of farming rewards +type CompoundingRewards struct { + Amount sdk.Int +} +``` + +## Bid + +```go +// Bid defines a standard bid for an auction. +type Bid struct { + PoolId uint64 + Bidder string + BiddingCoin sdk.Coin +} +``` + +## Parameter + +- ModuleName: `liquidfarming` +- RouterKey: `liquidfarming` +- StoreKey: `liquidfarming` +- QuerierRoute: `liquidfarming` + +## Store + +- LastRewardsAuctionIdKey: `[]byte{0xe1} | PoolId -> Uint64Value(uint64)` +- RewardsAuctionTimeKey: `[]byte{0xe2} -> Uint64Value(uint64)` +- LiquidFarmKey: `[]byte{0xe4} | PoolId -> ProtocolBuffer(LiquidFarm)` +- CompoundingRewardsKey: `[]byte{0xe7} | PoolId -> ProtocolBuffer(CompoundingRewards)` +- RewardsAuctionKey: `[]byte{0xe8} | AuctionId | PoolId -> ProtocolBuffer(RewardsAuction)` +- BidKey: `[]byte{0xea} | PoolId | BidderAddressLen (1 byte) | BidderAddress -> ProtocolBuffer(Bid)` +- WinningBidKey: `[]byte{0xeb} | AuctionId | PoolId -> ProtocolBuffer(WinningBid)` diff --git a/x/liquidfarming/spec/03_state_transitions.md b/x/liquidfarming/spec/03_state_transitions.md new file mode 100644 index 00000000..04f1cb60 --- /dev/null +++ b/x/liquidfarming/spec/03_state_transitions.md @@ -0,0 +1,48 @@ + + +# State Transitions + +This document describes the state transaction operations in the `liquidfarming` module. + +## Parameter Change for Activated Liquid Farms + +### Activation of a Liquid Farm + +When a new `liquidFarm` with a given pool id is registered to the parameter `LiquidFarms` by governance, the `liquidFarm` with the pool id becomes activated and added to the state `LiquidFarms`. + +### Deactivation of a Liquid Farm + +When a `liquidFarm` with a given pool id in the parameter `LiquidFarms` is removed by governance, the `liquidFarm` becomes deactivated and deleted in the state `LiquidFarms`. +When the `liquidFarm` becomes deactivated, the module unstakes all pool coins for the `liquidFarm`. + +## Coin Escrow for Liquidfarming Module Messages + +The following messages cause state transition on the `bank`, `liquidty`, and `farming` modules. + +### MsgLiquidFarm + +- A farmer farms in the `liquidfarming` module with their farming coin (pool coin) +- The module sends that farming coin to dynamically generated reserve account +- The reserve account farms their farming coin to the `farm` module and start generating farming rewards +- The `LFCoin` is minted and sends it to the farmer. + +### MsgLiquidUnfarm + +- A farmer unfarms in the `liquidfarming` module with their liquid farming coin (LFCoin) +- The module calculates the corresponding pool coin by the burn rate and releases the pool coin back to the farmer +- The module burns the `LFCoin` + +### MsgLiquidUnfarmWithdraw + +- A farmer unfarms in the `liquidfarming` module with their liquid farming coin (LFCoin) +- The module calculates the corresponding pool coin by the burn rate and calls to withdraw the pool coin in the `liquidity` module +- The corresponding two coins are back to the farmer +- The module burns the `LFCoin` + +### MsgPlaceBid + +- Bidding coins are sent to the `PayingReserveAddress` of an auction. + +### MsgRefundBid + +- Bidding coins are sent to a bidder account from the `PayingReserveAddress` of an auction. diff --git a/x/liquidfarming/spec/04_messages.md b/x/liquidfarming/spec/04_messages.md new file mode 100644 index 00000000..d75cb0e8 --- /dev/null +++ b/x/liquidfarming/spec/04_messages.md @@ -0,0 +1,106 @@ + + +# Messages + +Messages (Msg) are objects that trigger state transitions. Msgs are wrapped in transactions (Txs) that clients submit to the network. +The Cosmos SDK wraps and unwraps `liquidfarming` module messages from transactions. + +## MsgLiquidFarm + +Farm coin to liquid farm. Farming coins are the pool coin that starts with pool prefix, which is a pool coin of a corresponding pool. +It is important to note that a farmer is not receiving a synthetic version of the farming coins right away. +It are expected to receive the synthetic version of the farming coins after one epoch at the current mint rate. +A synthetic version of the farming coin is called as LFCoin in the module and the terminology is used throughout the documentation and codebase. + +```go +type MsgLiquidFarm struct { + PoolId uint64 // target pool id + Farmer string // the bech32-encoded address that farms coin + FarmingCoin sdk.Coin // farming amount of pool coin +} +``` + +Validity checks are performed for `MsgLiquidFarm` message. The transaction that is triggered with the `MsgLiquidFarm` message fails if: + +- The target liquid farm with the pool id does not exist +- The amount of farming coin is not positive +- The amount of farming coin is less than `MinimumFarmAmount` +- The farming coin denom is not the same as the pool coin denom of the pool with `PoolId` +- The farmer has insufficient spendable balances for the farming coin amount + +## MsgLiquidUnfarm + +Unfarm LFCoin to liquid unfarm. +The module burns LFCoin amounts and releases the corresponding amount of pool coins to a farmer at the current burn rate. + +```go +type MsgLiquidUnfarm struct { + PoolId uint64 // target deposit request id + Farmer string // the bech32-encoded address that unfarms liquid farm coin + UnfarmingCoin sdk.Coin // withdrawing amount of LF coin +} +``` + +Validity checks are performed for `MsgLiquidUnfarm` message. The transaction that is triggered with the `MsgLiquidUnfarm` message fails if: + +- The target liquid farm with the pool id does not exist +- The amount of LF coins is not positive +- The unfarming coin denom is not the same as the pool coin denom of the pool with `PoolId` +- The farmer has insufficient spendable balances for the unfarming amount + +## MsgLiquidUnfarmAndWithdraw + +Unfarm LFCoin to liquid unfarm and withdraw the pool coin from the pool. +The module burns LFCoin amounts at the current burn rate, withdraw the corresponding amount of pool coins from the pool, and then releases the withdrawn coins to a farmer. + +```go +type MsgLiquidUnfarmAndWithdraw struct { + PoolId uint64 // target pool id + Farmer string // the bech32-encoded address that unfarms liquid farm coin and withdraws + UnfarmingCoin sdk.Coin // withdrawing amount of LF coin +} +``` + +Validity checks are performed for `MsgLiquidUnfarmAndWithdraw` message. The transaction that is triggered with the `MsgLiquidUnfarmAndWithdraw` message fails if: + +- The target liquid farm with the pool id does not exist +- The amount of LF coins is not positive +- The unfarming coin denom is not the same as the pool coin denom of the pool with `PoolId` +- The farmer has insufficient spendable balances for the unfarming amount + +## MsgPlaceBid + +Place a bid for a rewards auction. +Anyone can place a bid for an auction where the bidder placing with the highest bid amount takes all the rewards. + +```go +type MsgPlaceBid struct { + AuctionId uint64 // auction id + PoolId uint64 // target pool id + Bidder string // the bech32-encoded address that places a bid + BiddingCoin sdk.Coin // bidding amount of pool coin +} +``` + +Validity checks are performed for `MsgPlaceBid` message. The transaction that is triggered with the `MsgPlaceBid` message fails if: + +- The target liquid farm with the pool id does not exist +- The target auction status is in invalid status + +## MsgRefundBid + +Refund the bid that is not winning for the auction. + +```go +type MsgRefundBid struct { + AuctionId uint64 // auction id + PoolId uint64 // target pool id + Bidder string // the bech32-encoded address that refunds a bid +} +``` + +Validity checks are performed for `MsgRefundBid` message. The transaction that is triggered with the `MsgRefundBid` message fails if: + +- The target liquid farm with the pool id does not exist +- The target auction status is in invalid status +- The bid by the bidder in the auction of the liquid farm with the pool id does not exist diff --git a/x/liquidfarming/spec/05_begin_block.md b/x/liquidfarming/spec/05_begin_block.md new file mode 100644 index 00000000..0340dc30 --- /dev/null +++ b/x/liquidfarming/spec/05_begin_block.md @@ -0,0 +1,9 @@ + + +# Begin-Block + +At each BeginBlock, the following operations occur in the `liquidfarming` module: + +- Synchronizes `LiquidFarms` registered in params with the ones stored in KVStore. When a new `LiquidFarm` is added by governance proposal, the `LiquidFarm` is going to be stored in KVStore. When an existing `LiquidFarm` is removed by the governance proposal, it first calls `Unfarm` function in the `farm` module with the reserve module account to unfarm all farming coin to prevent from having farming rewards accumulated and handle the ongoing `RewardsAuction`. It refunds all placed bids and change the auction status to `AuctionStatusFinished`. Lastly, it deletes the `LiquidFarm` in the store. + +- Iterates all existing `LiquidFarms` in KVStore and create `RewardsAuction` for every `LiquidFarm` if it is not created before. It there is an ongoing `RewardsAuction` for the `LiquidFarm`, then it finishes by selecting the winning bid to give them the accumulated farming rewards and calls `Farm` function in the `farm` module to farm the coin of the winning bid. This action is regarded as auto compounding rewards functionality for farmers. diff --git a/x/liquidfarming/spec/06_events.md b/x/liquidfarming/spec/06_events.md new file mode 100644 index 00000000..4e805073 --- /dev/null +++ b/x/liquidfarming/spec/06_events.md @@ -0,0 +1,65 @@ + + +# Events + +The `liquidfarming` module emits the following events: + +## Handlers + +### MsgLiquidFarm + +| Type | Attribute Key | Attribute Value | +| ----------- | ------------- | --------------- | +| liquid_farm | pool_id | {poolId} | +| liquid_farm | farmer | {farmer} | +| liquid_farm | farming_coin | {farmingCoin} | +| liquid_farm | minted_coin | {mintingCoin} | +| message | module | liquidfarming | +| message | action | farm | +| message | farmer | {farmerAddress} | + +### MsgLiquidUnfarm + +| Type | Attribute Key | Attribute Value | +| ------------- | -------------- | --------------- | +| liquid_unfarm | pool_id | {poolId} | +| liquid_unfarm | farmer | {farmer} | +| liquid_unfarm | unfarming_coin | {unfarmingCoin} | +| liquid_unfarm | unfarmed_coin | {unfarmedCoin} | +| message | module | liquidfarming | +| message | action | unfarm | +| message | farmer | {farmerAddress} | + +### MsgLiquidUnfarmAndWithdraw + +| Type | Attribute Key | Attribute Value | +| -------------------------- | -------------- | ----------------- | +| liquid_unfarm_and_withdraw | pool_id | {poolId} | +| liquid_unfarm_and_withdraw | farmer | {farmer} | +| liquid_unfarm_and_withdraw | unfarming_coin | {unfarmingCoin} | +| liquid_unfarm_and_withdraw | unfarmed_coin | {unfarmedCoin} | +| message | module | liquidfarming | +| message | action | unfarmandwithdraw | +| message | farmer | {farmerAddress} | + +### MsgPlaceBid + +| Type | Attribute Key | Attribute Value | +| --------- | ------------- | --------------- | +| place_bid | auction_id | {auctionId} | +| place_bid | bidder | {bidder} | +| place_bid | bidding_coin | {biddingCoin} | +| message | module | liquidfarming | +| message | action | deposit | +| message | bidder | {bidderAddress} | + +### MsgRefundBid + +| Type | Attribute Key | Attribute Value | +| ---------- | ------------- | --------------- | +| refund_bid | auction_id | {auctionId} | +| refund_bid | bidder | {bidder} | +| refund_bid | refund_coin | {bidAmount} | +| message | module | liquidfarming | +| message | action | deposit | +| message | bidder | {bidderAddress} | diff --git a/x/liquidfarming/spec/07_params.md b/x/liquidfarming/spec/07_params.md new file mode 100644 index 00000000..23b1101e --- /dev/null +++ b/x/liquidfarming/spec/07_params.md @@ -0,0 +1,29 @@ + + +# Parameters + +The `liquidfarming` module contains the following parameters: + +| Key | Type | Example | +| ---------------------- | ---------------- | ------------------------- | +| LiquidFarms | []LiquidFarm | []LiquidFarm{} | +| RewardsAuctionDuration | string (time ns) | 43200000000000 (12 hours) | + +## LiquidFarms + +`LiquidFarms` is a list of `LiquidFarm`, where a `LiquidFarm` is corresponding to a specific pool with `PoolId`. +A single `LiquidFarm` can exist for a given pool. + +```go +type LiquidFarm struct { + PoolId uint64 // the pool id + MinDepositAmount sdk.Int // the minimum deposit amount; it allows zero value + MinBidAmount sdk.Int // the minimum bid amount; it allows zero value + AuctionPeriod time.Duration // default value is 12 hours +} +``` + +## RewardsAuctionDuration + +`RewardsAuctionDuration` is the duration that triggers the module to create new `RewardsAuction`. +If there is an ongoing `RewardsAuction`, then it finishes it and it creates next one. diff --git a/x/liquidfarming/spec/README.md b/x/liquidfarming/spec/README.md new file mode 100644 index 00000000..0c336286 --- /dev/null +++ b/x/liquidfarming/spec/README.md @@ -0,0 +1,17 @@ + + +# `liquidfarming` + +## Abstract + +This document specifies the `liquidfarming` module that provides a functionality for farmers to have another option to use with their liquidity pool coins in Crescent Network. + +## Contents + +1. **[Concepts](01_concepts.md)** +2. **[State](02_state.md)** +3. **[State Transitions](03_state_transitions.md)** +4. **[Messages](04_messages.md)** +5. **[BeginBlock](05_begin_block.md)** +6. **[Events](06_events.md)** +7. **[Parameters](07_params.md)** diff --git a/x/liquidfarming/types/auction.go b/x/liquidfarming/types/auction.go new file mode 100644 index 00000000..101fdd9b --- /dev/null +++ b/x/liquidfarming/types/auction.go @@ -0,0 +1,168 @@ +package types + +import ( + fmt "fmt" + "strconv" + "strings" + time "time" + + "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + + farmingtypes "github.com/cosmosquad-labs/squad/v3/x/farming/types" +) + +const ( + PayingReserveAddressPrefix string = "PayingReserveAddress" + ModuleAddressNameSplitter string = "|" + + // The module uses the address type of 32 bytes length, but it can always be changed depending on Cosmos SDK's direction. + ReserveAddressType = farmingtypes.AddressType32Bytes +) + +// NewRewardsAuction creates a new RewardsAuction. +func NewRewardsAuction( + id uint64, + poolId uint64, + biddingCoinDenom string, + startTime time.Time, + endTime time.Time, +) RewardsAuction { + return RewardsAuction{ + Id: id, + PoolId: poolId, + BiddingCoinDenom: biddingCoinDenom, + PayingReserveAddress: PayingReserveAddress(poolId).String(), + StartTime: startTime, + EndTime: endTime, + Status: AuctionStatusStarted, + Winner: "", // the value is determined when the auction is finished + WinningAmount: sdk.Coin{}, // the value is determined when the auction is finished + Rewards: sdk.Coins{}, // the value is determined when the auction is finished + } +} + +// Validate validates RewardsAuction. +func (a *RewardsAuction) Validate() error { + if a.PoolId == 0 { + return fmt.Errorf("pool id must not be 0") + } + if a.BiddingCoinDenom == "" { + return fmt.Errorf("denom must not be empty") + } + if err := sdk.ValidateDenom(a.BiddingCoinDenom); err != nil { + return fmt.Errorf("invalid coin denom") + } + if _, err := sdk.AccAddressFromBech32(a.PayingReserveAddress); err != nil { + return fmt.Errorf("invalid paying reserve address %w", err) + } + if !a.EndTime.After(a.StartTime) { + return fmt.Errorf("end time must be set after the start time") + } + if a.Status != AuctionStatusStarted && a.Status != AuctionStatusFinished { + return fmt.Errorf("invalid auction status") + } + return nil +} + +// SetStatus sets rewards auction status. +func (a *RewardsAuction) SetStatus(status AuctionStatus) { + a.Status = status +} + +// SetWinner sets winner address. +func (a *RewardsAuction) SetWinner(winner string) { + a.Winner = winner +} + +// SetWinningAmount sets the winning amount. +func (a *RewardsAuction) SetWinningAmount(winningAmount sdk.Coin) { + a.WinningAmount = winningAmount +} + +// SetRewards sets auction rewards. +func (a *RewardsAuction) SetRewards(rewards sdk.Coins) { + a.Rewards = rewards +} + +// GetPayingReserveAddress returns the paying reserve address in the form of sdk.AccAddress. +func (a RewardsAuction) GetPayingReserveAddress() sdk.AccAddress { + addr, err := sdk.AccAddressFromBech32(a.PayingReserveAddress) + if err != nil { + panic(err) + } + return addr +} + +// NewBid creates a new Bid. +func NewBid(poolId uint64, bidder string, amount sdk.Coin) Bid { + return Bid{ + PoolId: poolId, + Bidder: bidder, + Amount: amount, + } +} + +// GetBidder returns the bidder address in the form of sdk.AccAddress. +func (b Bid) GetBidder() sdk.AccAddress { + addr, err := sdk.AccAddressFromBech32(b.Bidder) + if err != nil { + panic(err) + } + return addr +} + +// Validate validates Bid. +func (b Bid) Validate() error { + if b.PoolId == 0 { + return fmt.Errorf("pool id must not be 0") + } + if _, err := sdk.AccAddressFromBech32(b.Bidder); err != nil { + return fmt.Errorf("invalid bidder address %w", err) + } + if !b.Amount.IsPositive() { + return fmt.Errorf("amount must be positive value") + } + if err := b.Amount.Validate(); err != nil { + return fmt.Errorf("invalid bid amount %w", err) + } + return nil +} + +// MustMarshalRewardsAuction marshals RewardsAuction and +// it panics upon failure. +func MustMarshalRewardsAuction(cdc codec.BinaryCodec, auction RewardsAuction) []byte { + return cdc.MustMarshal(&auction) +} + +// MustUnmarshalRewardsAuction unmarshals RewardsAuction and +// it panics upon failure. +func MustUnmarshalRewardsAuction(cdc codec.BinaryCodec, value []byte) RewardsAuction { + pair, err := UnmarshalRewardsAuction(cdc, value) + if err != nil { + panic(err) + } + return pair +} + +// UnmarshalRewardsAuction unmarshals RewardsAuction. +func UnmarshalRewardsAuction(cdc codec.BinaryCodec, value []byte) (auction RewardsAuction, err error) { + err = cdc.Unmarshal(value, &auction) + return auction, err +} + +// UnmarshalBid unmarshals bid from a store value. +func UnmarshalBid(cdc codec.BinaryCodec, value []byte) (bid Bid, err error) { + err = cdc.Unmarshal(value, &bid) + return bid, err +} + +// PayingReserveAddress creates the paying reserve address in the form of sdk.AccAddress +// with the given pool id. +func PayingReserveAddress(poolId uint64) sdk.AccAddress { + return farmingtypes.DeriveAddress( + ReserveAddressType, + ModuleName, + strings.Join([]string{PayingReserveAddressPrefix, strconv.FormatUint(poolId, 10)}, ModuleAddressNameSplitter), + ) +} diff --git a/x/liquidfarming/types/auction_test.go b/x/liquidfarming/types/auction_test.go new file mode 100644 index 00000000..16bd538c --- /dev/null +++ b/x/liquidfarming/types/auction_test.go @@ -0,0 +1,164 @@ +package types_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + + "github.com/cosmos/cosmos-sdk/codec" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/address" + "github.com/tendermint/tendermint/crypto" + + utils "github.com/cosmosquad-labs/squad/v3/types" + "github.com/cosmosquad-labs/squad/v3/x/liquidfarming/types" +) + +func TestRewardsAuctionValidate(t *testing.T) { + for _, tc := range []struct { + name string + malleate func(*types.RewardsAuction) + expectedErr string + }{ + { + "happy case", + func(auction *types.RewardsAuction) { + registry := codectypes.NewInterfaceRegistry() + types.RegisterInterfaces(registry) + cdc := codec.NewProtoCodec(registry) + bz := types.MustMarshalRewardsAuction(cdc, *auction) + newAuction := types.MustUnmarshalRewardsAuction(cdc, bz) + require.EqualValues(t, auction, &newAuction) + }, + "", + }, + { + "invalid pool id", + func(auction *types.RewardsAuction) { + auction.PoolId = 0 + }, + "pool id must not be 0", + }, + { + "invalid bidding coin denom", + func(auction *types.RewardsAuction) { + auction.BiddingCoinDenom = "" + }, + "denom must not be empty", + }, + { + "invalid bidding coin denom", + func(auction *types.RewardsAuction) { + auction.BiddingCoinDenom = "123!@#$%" + }, + "invalid coin denom", + }, + { + "invalid paying reserve address", + func(auction *types.RewardsAuction) { + auction.PayingReserveAddress = "invalidaddr" + }, + "invalid paying reserve address decoding bech32 failed: invalid separator index -1", + }, + { + "invalid start and end time", + func(auction *types.RewardsAuction) { + auction.StartTime = utils.ParseTime("9999-12-31T00:00:00Z") + auction.EndTime = utils.ParseTime("0001-01-01T00:00:00Z") + }, + "end time must be set after the start time", + }, + { + "invalid auction status", + func(auction *types.RewardsAuction) { + auction.Status = types.AuctionStatusNil + }, + "invalid auction status", + }, + } { + t.Run(tc.name, func(t *testing.T) { + auction := types.NewRewardsAuction( + 1, + 1, + "stake", + utils.ParseTime("0001-01-01T00:00:00Z"), + utils.ParseTime("9999-12-31T00:00:00Z"), + ) + auction.SetRewards(utils.ParseCoins("100000denom1")) + auction.SetStatus(types.AuctionStatusStarted) + auction.SetWinner("") + auction.SetWinningAmount(utils.ParseCoin("100000pool1")) + tc.malleate(&auction) + err := auction.Validate() + if tc.expectedErr == "" { + require.NoError(t, err) + } else { + require.EqualError(t, err, tc.expectedErr) + } + }) + } +} + +func TestBidValidate(t *testing.T) { + for _, tc := range []struct { + name string + malleate func(*types.Bid) + expectedErr string + }{ + { + "happy case", + func(b *types.Bid) {}, + "", + }, + { + "invalid pool id", + func(b *types.Bid) { + b.PoolId = 0 + }, + "pool id must not be 0", + }, + { + "invalid bidder", + func(b *types.Bid) { + b.Bidder = "invalidaddr" + }, + "invalid bidder address decoding bech32 failed: invalid separator index -1", + }, + { + "invalid bidding amount", + func(b *types.Bid) { + b.Amount = utils.ParseCoin("0pool1") + }, + "amount must be positive value", + }, + } { + t.Run(tc.name, func(t *testing.T) { + bid := types.NewBid( + 1, + sdk.AccAddress(crypto.AddressHash([]byte("address1"))).String(), + utils.ParseCoin("100000000pool1"), + ) + tc.malleate(&bid) + err := bid.Validate() + if tc.expectedErr == "" { + require.NoError(t, err) + } else { + require.EqualError(t, err, tc.expectedErr) + } + }) + } +} + +func TestPayingReserveAddress(t *testing.T) { + config := sdk.GetConfig() + addrPrefix := config.GetBech32AccountAddrPrefix() + + testAcc1 := types.PayingReserveAddress(1) + require.Equal(t, testAcc1, sdk.AccAddress(address.Module(types.ModuleName, []byte("PayingReserveAddress|1")))) + require.Equal(t, addrPrefix+"1h72q3pkvsz537kj08hyv20tun3apampxhpgad97t3ls47nukgtxqeq6eu2", testAcc1.String()) + + testAcc2 := types.PayingReserveAddress(22) + require.Equal(t, testAcc2, sdk.AccAddress(address.Module(types.ModuleName, []byte("PayingReserveAddress|22")))) + require.Equal(t, addrPrefix+"1tepnmaep852l483ldnfxttgsua9j9ynpmelqmn3ywvwynr7s5acqr6sz4k", testAcc2.String()) +} diff --git a/x/liquidfarming/types/codec.go b/x/liquidfarming/types/codec.go new file mode 100644 index 00000000..a898876e --- /dev/null +++ b/x/liquidfarming/types/codec.go @@ -0,0 +1,37 @@ +package types + +import ( + "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/msgservice" +) + +// RegisterLegacyAminoCodec registers the necessary x/liquidfarming interfaces and concrete types +// on the provided LegacyAmino codec. These types are used for Amino JSON serialization. +func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + cdc.RegisterConcrete(&MsgLiquidFarm{}, "liquidfarming/MsgLiquidFarm", nil) + cdc.RegisterConcrete(&MsgLiquidUnfarm{}, "liquidfarming/MsgLiquidUnfarm", nil) + cdc.RegisterConcrete(&MsgLiquidUnfarmAndWithdraw{}, "liquidfarming/MsgLiquidUnfarmAndWithdraw", nil) + cdc.RegisterConcrete(&MsgPlaceBid{}, "liquidfarming/MsgPlaceBid", nil) + cdc.RegisterConcrete(&MsgRefundBid{}, "liquidfarming/MsgRefundBid", nil) +} + +// RegisterInterfaces registers the x/liquidfarming interfaces types with the interface registry +func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { + registry.RegisterImplementations( + (*sdk.Msg)(nil), + &MsgLiquidFarm{}, + &MsgLiquidUnfarm{}, + &MsgLiquidUnfarmAndWithdraw{}, + &MsgPlaceBid{}, + &MsgRefundBid{}, + ) + + msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) +} + +var ( + Amino = codec.NewLegacyAmino() + ModuleCdc = codec.NewProtoCodec(cdctypes.NewInterfaceRegistry()) +) diff --git a/x/liquidfarming/types/errors.go b/x/liquidfarming/types/errors.go new file mode 100644 index 00000000..39477f99 --- /dev/null +++ b/x/liquidfarming/types/errors.go @@ -0,0 +1,13 @@ +package types + +// DONTCOVER + +import ( + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +// x/liquidfarming module sentinel errors +var ( + ErrSmallerThanMinimumAmount = sdkerrors.Register(ModuleName, 2, "smaller than the minimum amount") + ErrNotBiggerThanWinningBidAmount = sdkerrors.Register(ModuleName, 3, "not bigger than the winning bid amount") +) diff --git a/x/liquidfarming/types/events.go b/x/liquidfarming/types/events.go new file mode 100644 index 00000000..8ee0e364 --- /dev/null +++ b/x/liquidfarming/types/events.go @@ -0,0 +1,23 @@ +package types + +// Event types for the module. +const ( + EventTypeLiquidFarm = "liquid_farm" + EventTypeLiquidUnfarm = "liquid_unfarm" + EventTypeLiquidUnfarmAndWithdraw = "liquid_unfarm_and_withdraw" + EventTypePlaceBid = "place_bid" + EventTypeRefundBid = "refund_bid" + + AttributeKeyPoolId = "pool_id" + AttributeKeyAuctionId = "auction_id" + AttributeKeyBidId = "bid_id" + AttributeKeyFarmer = "farmer" + AttributeKeyLiquidFarmReserveAddress = "liquid_farm_reserve_address" + AttributeKeyBidder = "bidder" + AttributeKeyFarmingCoin = "farming_coin" + AttributeKeyMintedCoin = "minted_coin" + AttributeKeyBiddingCoin = "bidding_coin" + AttributeKeyUnfarmingCoin = "unfarming_coin" + AttributeKeyUnfarmedCoin = "unfarmed_coin" + AttributeKeyRefundCoin = "refund_coin" +) diff --git a/x/liquidfarming/types/expected_keepers.go b/x/liquidfarming/types/expected_keepers.go new file mode 100644 index 00000000..b6ae08c7 --- /dev/null +++ b/x/liquidfarming/types/expected_keepers.go @@ -0,0 +1,44 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + + farmtypes "github.com/cosmosquad-labs/squad/v3/x/farm/types" + liquiditytypes "github.com/cosmosquad-labs/squad/v3/x/liquidity/types" +) + +// AccountKeeper defines the expected interface needed for the module. +type AccountKeeper interface { + GetModuleAddress(name string) sdk.AccAddress +} + +// BankKeeper defines the expected interface needed for the module. +type BankKeeper interface { + GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin + GetAllBalances(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins + GetSupply(ctx sdk.Context, denom string) sdk.Coin + SpendableCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins + SendCoins(ctx sdk.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amt sdk.Coins) error + InputOutputCoins(ctx sdk.Context, inputs []banktypes.Input, outputs []banktypes.Output) error + MintCoins(ctx sdk.Context, name string, amt sdk.Coins) error + BurnCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) error + SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error + SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error +} + +// FarmKeeper defines the expected interface needed for the module. +type FarmKeeper interface { + Farm(ctx sdk.Context, farmerAddr sdk.AccAddress, coin sdk.Coin) (withdrawnRewards sdk.Coins, err error) + Unfarm(ctx sdk.Context, farmerAddr sdk.AccAddress, coin sdk.Coin) (withdrawnRewards sdk.Coins, err error) + Harvest(ctx sdk.Context, farmerAddr sdk.AccAddress, denom string) (withdrawnRewards sdk.Coins, err error) + Rewards(ctx sdk.Context, farmerAddr sdk.AccAddress, denom string) sdk.DecCoins + GetFarm(ctx sdk.Context, denom string) (farm farmtypes.Farm, found bool) + GetPosition(ctx sdk.Context, farmerAddr sdk.AccAddress, denom string) (position farmtypes.Position, found bool) +} + +// LiquidityKeeper defines the expected interface needed for the module. +type LiquidityKeeper interface { + GetPool(ctx sdk.Context, id uint64) (pool liquiditytypes.Pool, found bool) + Withdraw(ctx sdk.Context, msg *liquiditytypes.MsgWithdraw) (liquiditytypes.WithdrawRequest, error) +} diff --git a/x/liquidfarming/types/genesis.go b/x/liquidfarming/types/genesis.go new file mode 100644 index 00000000..787a2275 --- /dev/null +++ b/x/liquidfarming/types/genesis.go @@ -0,0 +1,60 @@ +package types + +import ( + fmt "fmt" +) + +// DefaultGenesis returns the default genesis state. +func DefaultGenesis() *GenesisState { + return &GenesisState{ + Params: DefaultParams(), + LastRewardsAuctionIdRecord: []LastRewardsAuctionIdRecord{}, + LiquidFarms: []LiquidFarm{}, + RewardsAuctions: []RewardsAuction{}, + Bids: []Bid{}, + WinningBidRecords: []WinningBidRecord{}, + } +} + +// Validate performs basic genesis state validation returning an error upon any failure. +func (gs GenesisState) Validate() error { + if err := gs.Params.Validate(); err != nil { + return fmt.Errorf("invalid params: %w", err) + } + + for _, liquidFarm := range gs.LiquidFarms { + if err := liquidFarm.Validate(); err != nil { + return fmt.Errorf("invalid liquid farm %w", err) + } + } + + for _, auction := range gs.RewardsAuctions { + if err := auction.Validate(); err != nil { + return err + } + } + + for _, bid := range gs.Bids { + if err := bid.Validate(); err != nil { + return err + } + } + + winningBidMap := map[uint64]Bid{} // AuctionId => Bid + for _, record := range gs.WinningBidRecords { + if record.AuctionId == 0 { + return fmt.Errorf("auction id must not be 0") + } + + if err := record.WinningBid.Validate(); err != nil { + return fmt.Errorf("invalid winning bid: %w", err) + } + + if _, ok := winningBidMap[record.AuctionId]; ok { + return fmt.Errorf("multiple winning bids at auction %d", record.AuctionId) + } + winningBidMap[record.AuctionId] = record.WinningBid + } + + return nil +} diff --git a/x/liquidfarming/types/genesis.pb.go b/x/liquidfarming/types/genesis.pb.go new file mode 100644 index 00000000..5ab57c54 --- /dev/null +++ b/x/liquidfarming/types/genesis.pb.go @@ -0,0 +1,980 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: squad/liquidfarming/v1beta1/genesis.proto + +package types + +import ( + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + _ "google.golang.org/protobuf/types/known/timestamppb" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// GenesisState defines the liquidfarming module's genesis state. +type GenesisState struct { + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` + LastRewardsAuctionIdRecord []LastRewardsAuctionIdRecord `protobuf:"bytes,2,rep,name=last_rewards_auction_id_record,json=lastRewardsAuctionIdRecord,proto3" json:"last_rewards_auction_id_record"` + LiquidFarms []LiquidFarm `protobuf:"bytes,3,rep,name=liquid_farms,json=liquidFarms,proto3" json:"liquid_farms"` + RewardsAuctions []RewardsAuction `protobuf:"bytes,4,rep,name=rewards_auctions,json=rewardsAuctions,proto3" json:"rewards_auctions"` + Bids []Bid `protobuf:"bytes,5,rep,name=bids,proto3" json:"bids"` + WinningBidRecords []WinningBidRecord `protobuf:"bytes,6,rep,name=winning_bid_records,json=winningBidRecords,proto3" json:"winning_bid_records"` +} + +func (m *GenesisState) Reset() { *m = GenesisState{} } +func (m *GenesisState) String() string { return proto.CompactTextString(m) } +func (*GenesisState) ProtoMessage() {} +func (*GenesisState) Descriptor() ([]byte, []int) { + return fileDescriptor_90f9cf71ffd184b0, []int{0} +} +func (m *GenesisState) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GenesisState.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 *GenesisState) XXX_Merge(src proto.Message) { + xxx_messageInfo_GenesisState.Merge(m, src) +} +func (m *GenesisState) XXX_Size() int { + return m.Size() +} +func (m *GenesisState) XXX_DiscardUnknown() { + xxx_messageInfo_GenesisState.DiscardUnknown(m) +} + +var xxx_messageInfo_GenesisState proto.InternalMessageInfo + +type LastRewardsAuctionIdRecord struct { + PoolId uint64 `protobuf:"varint,1,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty"` + AuctionId uint64 `protobuf:"varint,2,opt,name=auction_id,json=auctionId,proto3" json:"auction_id,omitempty"` +} + +func (m *LastRewardsAuctionIdRecord) Reset() { *m = LastRewardsAuctionIdRecord{} } +func (m *LastRewardsAuctionIdRecord) String() string { return proto.CompactTextString(m) } +func (*LastRewardsAuctionIdRecord) ProtoMessage() {} +func (*LastRewardsAuctionIdRecord) Descriptor() ([]byte, []int) { + return fileDescriptor_90f9cf71ffd184b0, []int{1} +} +func (m *LastRewardsAuctionIdRecord) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *LastRewardsAuctionIdRecord) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_LastRewardsAuctionIdRecord.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 *LastRewardsAuctionIdRecord) XXX_Merge(src proto.Message) { + xxx_messageInfo_LastRewardsAuctionIdRecord.Merge(m, src) +} +func (m *LastRewardsAuctionIdRecord) XXX_Size() int { + return m.Size() +} +func (m *LastRewardsAuctionIdRecord) XXX_DiscardUnknown() { + xxx_messageInfo_LastRewardsAuctionIdRecord.DiscardUnknown(m) +} + +var xxx_messageInfo_LastRewardsAuctionIdRecord proto.InternalMessageInfo + +// WinningBidRecord defines a custom winning bid record that is required to be recorded +// in genesis state. +type WinningBidRecord struct { + AuctionId uint64 `protobuf:"varint,1,opt,name=auction_id,json=auctionId,proto3" json:"auction_id,omitempty"` + WinningBid Bid `protobuf:"bytes,2,opt,name=winning_bid,json=winningBid,proto3" json:"winning_bid"` +} + +func (m *WinningBidRecord) Reset() { *m = WinningBidRecord{} } +func (m *WinningBidRecord) String() string { return proto.CompactTextString(m) } +func (*WinningBidRecord) ProtoMessage() {} +func (*WinningBidRecord) Descriptor() ([]byte, []int) { + return fileDescriptor_90f9cf71ffd184b0, []int{2} +} +func (m *WinningBidRecord) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *WinningBidRecord) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_WinningBidRecord.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 *WinningBidRecord) XXX_Merge(src proto.Message) { + xxx_messageInfo_WinningBidRecord.Merge(m, src) +} +func (m *WinningBidRecord) XXX_Size() int { + return m.Size() +} +func (m *WinningBidRecord) XXX_DiscardUnknown() { + xxx_messageInfo_WinningBidRecord.DiscardUnknown(m) +} + +var xxx_messageInfo_WinningBidRecord proto.InternalMessageInfo + +func init() { + proto.RegisterType((*GenesisState)(nil), "squad.liquidfarming.v1beta1.GenesisState") + proto.RegisterType((*LastRewardsAuctionIdRecord)(nil), "squad.liquidfarming.v1beta1.LastRewardsAuctionIdRecord") + proto.RegisterType((*WinningBidRecord)(nil), "squad.liquidfarming.v1beta1.WinningBidRecord") +} + +func init() { + proto.RegisterFile("squad/liquidfarming/v1beta1/genesis.proto", fileDescriptor_90f9cf71ffd184b0) +} + +var fileDescriptor_90f9cf71ffd184b0 = []byte{ + // 493 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x93, 0x41, 0x6b, 0xd4, 0x40, + 0x14, 0xc7, 0x93, 0x36, 0xae, 0x3a, 0x5b, 0xb0, 0x8e, 0x82, 0x61, 0xc5, 0xec, 0x52, 0x0f, 0xae, + 0x48, 0x13, 0x5a, 0x41, 0xa1, 0xb7, 0xee, 0xc1, 0x52, 0xf0, 0xb0, 0xc4, 0x83, 0x20, 0x62, 0x98, + 0x64, 0xa6, 0x71, 0x20, 0xc9, 0xa4, 0xf3, 0x26, 0xae, 0x1e, 0x05, 0x0f, 0x1e, 0xfd, 0x08, 0xfd, + 0x08, 0x7e, 0x8c, 0x1e, 0x7b, 0xf4, 0x24, 0xb2, 0x7b, 0xf1, 0x63, 0xc8, 0x4e, 0xd2, 0x6e, 0x13, + 0xd8, 0xc1, 0xdb, 0xce, 0xdb, 0xff, 0xff, 0xf7, 0x7f, 0xef, 0x65, 0x06, 0x3d, 0x85, 0xd3, 0x8a, + 0xd0, 0x20, 0xe3, 0xa7, 0x15, 0xa7, 0x27, 0x44, 0xe6, 0xbc, 0x48, 0x83, 0x4f, 0x7b, 0x31, 0x53, + 0x64, 0x2f, 0x48, 0x59, 0xc1, 0x80, 0x83, 0x5f, 0x4a, 0xa1, 0x04, 0x7e, 0xa8, 0xa5, 0x7e, 0x4b, + 0xea, 0x37, 0xd2, 0xc1, 0xfd, 0x54, 0xa4, 0x42, 0xeb, 0x82, 0xe5, 0xaf, 0xda, 0x32, 0x18, 0xa6, + 0x42, 0xa4, 0x19, 0x0b, 0xf4, 0x29, 0xae, 0x4e, 0x02, 0xc5, 0x73, 0x06, 0x8a, 0xe4, 0x65, 0x23, + 0x08, 0x4c, 0xf1, 0xed, 0xa4, 0xda, 0x30, 0x36, 0x19, 0x4a, 0x22, 0x49, 0xde, 0xb4, 0xbb, 0xf3, + 0xd3, 0x41, 0x5b, 0x47, 0xf5, 0x00, 0x6f, 0x14, 0x51, 0x0c, 0x1f, 0xa2, 0x5e, 0x2d, 0x70, 0xed, + 0x91, 0x3d, 0xee, 0xef, 0x3f, 0xf6, 0x0d, 0x03, 0xf9, 0x53, 0x2d, 0x9d, 0x38, 0xe7, 0xbf, 0x87, + 0x56, 0xd8, 0x18, 0xf1, 0x57, 0x1b, 0x79, 0x19, 0x01, 0x15, 0x49, 0x36, 0x23, 0x92, 0x42, 0x44, + 0xaa, 0x44, 0x71, 0x51, 0x44, 0x9c, 0x46, 0x92, 0x25, 0x42, 0x52, 0x77, 0x63, 0xb4, 0x39, 0xee, + 0xef, 0xbf, 0x34, 0xb2, 0x5f, 0x13, 0x50, 0x61, 0x4d, 0x38, 0xac, 0x01, 0xc7, 0x34, 0xd4, 0xf6, + 0x26, 0x6f, 0x90, 0xad, 0x55, 0xe0, 0x29, 0xda, 0xaa, 0xa9, 0xd1, 0x12, 0x0b, 0xee, 0xa6, 0x0e, + 0x7c, 0x62, 0x0e, 0xd4, 0xd5, 0x57, 0x44, 0xe6, 0x4d, 0x40, 0x3f, 0xbb, 0xaa, 0x00, 0x7e, 0x8f, + 0xb6, 0x3b, 0xf3, 0x80, 0xeb, 0x68, 0xea, 0x33, 0x23, 0xb5, 0xdd, 0x60, 0x43, 0xbe, 0x23, 0x5b, + 0x55, 0xc0, 0x07, 0xc8, 0x89, 0x39, 0x05, 0xf7, 0x86, 0x26, 0x8e, 0x8c, 0xc4, 0x09, 0xbf, 0xdc, + 0x80, 0xf6, 0xe0, 0x04, 0xdd, 0x9b, 0xf1, 0xa2, 0xe0, 0x45, 0x1a, 0xc5, 0x57, 0x2b, 0x06, 0xb7, + 0xa7, 0x51, 0xbb, 0x46, 0xd4, 0xdb, 0xda, 0x37, 0xe1, 0xed, 0xcd, 0xde, 0x9d, 0x75, 0xea, 0x70, + 0x70, 0xeb, 0xfb, 0xd9, 0xd0, 0xfa, 0x7b, 0x36, 0xb4, 0x76, 0x3e, 0xa0, 0xc1, 0xfa, 0x4f, 0x83, + 0x1f, 0xa0, 0x9b, 0xa5, 0x10, 0x59, 0xc4, 0xa9, 0xbe, 0x40, 0x4e, 0xd8, 0x5b, 0x1e, 0x8f, 0x29, + 0x7e, 0x84, 0xd0, 0xea, 0x1e, 0xb8, 0x1b, 0xfa, 0xbf, 0xdb, 0xe4, 0xd2, 0x7d, 0x8d, 0xff, 0xcd, + 0x46, 0xdb, 0xdd, 0xbe, 0x3a, 0x6e, 0xbb, 0xe3, 0xc6, 0x47, 0xa8, 0x7f, 0x6d, 0x05, 0x9a, 0xfe, + 0xff, 0x5b, 0x44, 0xab, 0x69, 0x57, 0x6d, 0x4c, 0xa6, 0xe7, 0x73, 0xcf, 0xbe, 0x98, 0x7b, 0xf6, + 0x9f, 0xb9, 0x67, 0xff, 0x58, 0x78, 0xd6, 0xc5, 0xc2, 0xb3, 0x7e, 0x2d, 0x3c, 0xeb, 0xdd, 0x8b, + 0x94, 0xab, 0x8f, 0x55, 0xec, 0x27, 0x22, 0x0f, 0x12, 0x01, 0xb9, 0xd0, 0x31, 0xbb, 0x19, 0x89, + 0xa1, 0x79, 0xa9, 0x9f, 0x3b, 0x4f, 0x4f, 0x7d, 0x29, 0x19, 0xc4, 0x3d, 0xfd, 0xe4, 0x9e, 0xff, + 0x0b, 0x00, 0x00, 0xff, 0xff, 0x6b, 0x43, 0x58, 0x79, 0x4e, 0x04, 0x00, 0x00, +} + +func (m *GenesisState) 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 *GenesisState) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.WinningBidRecords) > 0 { + for iNdEx := len(m.WinningBidRecords) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.WinningBidRecords[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + } + } + if len(m.Bids) > 0 { + for iNdEx := len(m.Bids) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Bids[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + } + } + if len(m.RewardsAuctions) > 0 { + for iNdEx := len(m.RewardsAuctions) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.RewardsAuctions[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + } + if len(m.LiquidFarms) > 0 { + for iNdEx := len(m.LiquidFarms) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.LiquidFarms[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if len(m.LastRewardsAuctionIdRecord) > 0 { + for iNdEx := len(m.LastRewardsAuctionIdRecord) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.LastRewardsAuctionIdRecord[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *LastRewardsAuctionIdRecord) 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 *LastRewardsAuctionIdRecord) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *LastRewardsAuctionIdRecord) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.AuctionId != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.AuctionId)) + i-- + dAtA[i] = 0x10 + } + if m.PoolId != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.PoolId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *WinningBidRecord) 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 *WinningBidRecord) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *WinningBidRecord) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.WinningBid.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if m.AuctionId != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.AuctionId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { + offset -= sovGenesis(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *GenesisState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovGenesis(uint64(l)) + if len(m.LastRewardsAuctionIdRecord) > 0 { + for _, e := range m.LastRewardsAuctionIdRecord { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.LiquidFarms) > 0 { + for _, e := range m.LiquidFarms { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.RewardsAuctions) > 0 { + for _, e := range m.RewardsAuctions { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.Bids) > 0 { + for _, e := range m.Bids { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.WinningBidRecords) > 0 { + for _, e := range m.WinningBidRecords { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + return n +} + +func (m *LastRewardsAuctionIdRecord) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PoolId != 0 { + n += 1 + sovGenesis(uint64(m.PoolId)) + } + if m.AuctionId != 0 { + n += 1 + sovGenesis(uint64(m.AuctionId)) + } + return n +} + +func (m *WinningBidRecord) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.AuctionId != 0 { + n += 1 + sovGenesis(uint64(m.AuctionId)) + } + l = m.WinningBid.Size() + n += 1 + l + sovGenesis(uint64(l)) + return n +} + +func sovGenesis(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozGenesis(x uint64) (n int) { + return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *GenesisState) 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 ErrIntOverflowGenesis + } + 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: GenesisState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field LastRewardsAuctionIdRecord", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.LastRewardsAuctionIdRecord = append(m.LastRewardsAuctionIdRecord, LastRewardsAuctionIdRecord{}) + if err := m.LastRewardsAuctionIdRecord[len(m.LastRewardsAuctionIdRecord)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field LiquidFarms", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.LiquidFarms = append(m.LiquidFarms, LiquidFarm{}) + if err := m.LiquidFarms[len(m.LiquidFarms)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RewardsAuctions", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RewardsAuctions = append(m.RewardsAuctions, RewardsAuction{}) + if err := m.RewardsAuctions[len(m.RewardsAuctions)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Bids", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Bids = append(m.Bids, Bid{}) + if err := m.Bids[len(m.Bids)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field WinningBidRecords", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.WinningBidRecords = append(m.WinningBidRecords, WinningBidRecord{}) + if err := m.WinningBidRecords[len(m.WinningBidRecords)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *LastRewardsAuctionIdRecord) 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 ErrIntOverflowGenesis + } + 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: LastRewardsAuctionIdRecord: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: LastRewardsAuctionIdRecord: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PoolId", wireType) + } + m.PoolId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PoolId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field AuctionId", wireType) + } + m.AuctionId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.AuctionId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *WinningBidRecord) 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 ErrIntOverflowGenesis + } + 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: WinningBidRecord: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: WinningBidRecord: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field AuctionId", wireType) + } + m.AuctionId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.AuctionId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field WinningBid", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.WinningBid.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipGenesis(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthGenesis + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupGenesis + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthGenesis + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthGenesis = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowGenesis = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/liquidfarming/types/genesis_test.go b/x/liquidfarming/types/genesis_test.go new file mode 100644 index 00000000..5055cfa1 --- /dev/null +++ b/x/liquidfarming/types/genesis_test.go @@ -0,0 +1,218 @@ +package types_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/tendermint/tendermint/crypto" + + utils "github.com/cosmosquad-labs/squad/v3/types" + "github.com/cosmosquad-labs/squad/v3/x/liquidfarming/types" +) + +func TestGenesisState_Validate(t *testing.T) { + validPayingReserveAddr := sdk.AccAddress(crypto.AddressHash([]byte("validPayingReserveAddr"))) + validBidder := sdk.AccAddress(crypto.AddressHash([]byte("validBidder"))) + validDenom := "denom1" + validPoolId := uint64(1) + validAuctionId := uint64(1) + + for _, tc := range []struct { + name string + malleate func(genState *types.GenesisState) + expectedErr string + }{ + { + "default is valid", + func(genState *types.GenesisState) {}, + "", + }, + { + "valid liquid farm", + func(genState *types.GenesisState) { + genState.LiquidFarms = []types.LiquidFarm{ + { + PoolId: 1, + MinFarmAmount: sdk.ZeroInt(), + MinBidAmount: sdk.ZeroInt(), + FeeRate: sdk.ZeroDec(), + }, + } + }, + "", + }, + { + "invalid liquid farm: pool id", + func(genState *types.GenesisState) { + genState.LiquidFarms = []types.LiquidFarm{ + { + PoolId: 0, + }, + } + }, + "invalid liquid farm pool id must not be 0", + }, + { + "invalid rewards auction: pool id", + func(genState *types.GenesisState) { + genState.RewardsAuctions = []types.RewardsAuction{ + { + PoolId: 0, + BiddingCoinDenom: validDenom, + PayingReserveAddress: validPayingReserveAddr.String(), + StartTime: utils.ParseTime("2022-08-01T00:00:00Z"), + EndTime: utils.ParseTime("2022-08-02T00:00:00Z"), + Status: types.AuctionStatusStarted, + }, + } + }, + "pool id must not be 0", + }, + { + "invalid rewards auction: bidding coin denom", + func(genState *types.GenesisState) { + genState.RewardsAuctions = []types.RewardsAuction{ + { + PoolId: validPoolId, + BiddingCoinDenom: "123!@#$%", + PayingReserveAddress: validPayingReserveAddr.String(), + StartTime: utils.ParseTime("2022-08-01T00:00:00Z"), + EndTime: utils.ParseTime("2022-08-02T00:00:00Z"), + Status: types.AuctionStatusStarted, + }, + } + }, + "invalid coin denom", + }, + { + "invalid rewards auction: auction status", + func(genState *types.GenesisState) { + genState.RewardsAuctions = []types.RewardsAuction{ + { + PoolId: validPoolId, + BiddingCoinDenom: validDenom, + PayingReserveAddress: validPayingReserveAddr.String(), + StartTime: utils.ParseTime("2022-08-01T00:00:00Z"), + EndTime: utils.ParseTime("2022-08-02T00:00:00Z"), + Status: types.AuctionStatusNil, + }, + } + }, + "invalid auction status", + }, + { + "invalid bids: pool id", + func(genState *types.GenesisState) { + genState.Bids = []types.Bid{ + { + PoolId: 0, + Bidder: validBidder.String(), + Amount: utils.ParseCoin("1000000pool1"), + }, + } + }, + "pool id must not be 0", + }, + { + "invalid bids: bid amount", + func(genState *types.GenesisState) { + genState.Bids = []types.Bid{ + { + PoolId: validPoolId, + Bidder: validBidder.String(), + Amount: utils.ParseCoin("0pool1"), + }, + } + }, + "amount must be positive value", + }, + { + "invalid winning bid records: auction id", + func(genState *types.GenesisState) { + genState.WinningBidRecords = []types.WinningBidRecord{ + { + AuctionId: 0, + WinningBid: types.Bid{ + PoolId: validPoolId, + Bidder: validBidder.String(), + Amount: utils.ParseCoin("1000000pool1"), + }, + }, + } + }, + "auction id must not be 0", + }, + { + "invalid winning bid records: pool id", + func(genState *types.GenesisState) { + genState.WinningBidRecords = []types.WinningBidRecord{ + { + AuctionId: validAuctionId, + WinningBid: types.Bid{ + PoolId: 0, + Bidder: validBidder.String(), + Amount: utils.ParseCoin("1000000pool1"), + }, + }, + } + }, + "invalid winning bid: pool id must not be 0", + }, + { + "invalid winning bid records: pool id", + func(genState *types.GenesisState) { + genState.WinningBidRecords = []types.WinningBidRecord{ + { + AuctionId: validAuctionId, + WinningBid: types.Bid{ + PoolId: validPoolId, + Bidder: validBidder.String(), + Amount: utils.ParseCoin("0pool1"), + }, + }, + } + }, + "invalid winning bid: amount must be positive value", + }, + { + "invalid winning bid records: duplicate winning bid", + func(genState *types.GenesisState) { + genState.WinningBidRecords = []types.WinningBidRecord{ + { + AuctionId: validAuctionId, + WinningBid: types.Bid{ + PoolId: validPoolId, + Bidder: validBidder.String(), + Amount: utils.ParseCoin("1000000pool1"), + }, + }, + { + AuctionId: validAuctionId, + WinningBid: types.Bid{ + PoolId: validPoolId, + Bidder: validBidder.String(), + Amount: utils.ParseCoin("1000000pool1"), + }, + }, + } + }, + "multiple winning bids at auction 1", + }, + } { + t.Run(tc.name, func(t *testing.T) { + genState := types.DefaultGenesis() + genState.RewardsAuctions = []types.RewardsAuction{} + genState.Bids = []types.Bid{} + genState.WinningBidRecords = []types.WinningBidRecord{} + tc.malleate(genState) + err := genState.Validate() + if tc.expectedErr == "" { + require.NoError(t, err) + } else { + require.EqualError(t, err, tc.expectedErr) + } + }) + } +} diff --git a/x/liquidfarming/types/keys.go b/x/liquidfarming/types/keys.go new file mode 100644 index 00000000..a2993269 --- /dev/null +++ b/x/liquidfarming/types/keys.go @@ -0,0 +1,85 @@ +package types + +import ( + time "time" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/address" +) + +const ( + // ModuleName defines the module name + ModuleName = "liquidfarming" + + // StoreKey defines the primary module store key + StoreKey = ModuleName + + // RouterKey is the message route key + RouterKey = ModuleName + + // QuerierRoute defines the module's query routing key + QuerierRoute = ModuleName +) + +// keys for the store prefixes +var ( + LastRewardsAuctionIdKey = []byte{0xe1} // key to retrieve the last rewards auction id + RewardsAuctionTimeKey = []byte{0xe2} // key to retrieve the last rewards auction end time + + LiquidFarmKeyPrefix = []byte{0xe4} + + CompoundingRewardsKeyPrefix = []byte{0xe7} + RewardsAuctionKeyPrefix = []byte{0xe8} + + BidKeyPrefix = []byte{0xea} + WinningBidKeyPrefix = []byte{0xeb} +) + +// GetLastRewardsAuctionIdKey returns the store key to retrieve the last rewards auction +// by the given pool id. +func GetLastRewardsAuctionIdKey(poolId uint64) []byte { + return append(LastRewardsAuctionIdKey, sdk.Uint64ToBigEndian(poolId)...) +} + +// GetLiquidFarmKey returns the store key to retrieve the liquid farm object +// by the given pool id. +func GetLiquidFarmKey(poolId uint64) []byte { + return append(LiquidFarmKeyPrefix, sdk.Uint64ToBigEndian(poolId)...) +} + +// GetCompoundingRewardsKey returns the store key to retrieve the compounding rewards object +// by the given pool id. +func GetCompoundingRewardsKey(poolId uint64) []byte { + return append(CompoundingRewardsKeyPrefix, sdk.Uint64ToBigEndian(poolId)...) +} + +// GetRewardsAuctionKey returns the store key to retrieve the rewards auction object +// by the given pool id and auction id. +func GetRewardsAuctionKey(auctionId, poolId uint64) []byte { + return append(append(RewardsAuctionKeyPrefix, sdk.Uint64ToBigEndian(auctionId)...), sdk.Uint64ToBigEndian(poolId)...) +} + +// GetBidKey returns the store key to retrieve the bid object +// by the given pool id and bidder address. +func GetBidKey(poolId uint64, bidder sdk.AccAddress) []byte { + return append(append(BidKeyPrefix, sdk.Uint64ToBigEndian(poolId)...), address.MustLengthPrefix(bidder)...) +} + +// GetBidByPoolIdPrefix returns the prefix to iterate all bids +// by the given pool id. +func GetBidByPoolIdPrefix(poolId uint64) []byte { + return append(BidKeyPrefix, sdk.Uint64ToBigEndian(poolId)...) +} + +// GetWinningBidKey returns the store key to retrieve the winning bid +// by the given pool id and the auction id. +func GetWinningBidKey(auctionId uint64, poolId uint64) []byte { + return append(append(WinningBidKeyPrefix, sdk.Uint64ToBigEndian(auctionId)...), sdk.Uint64ToBigEndian(poolId)...) +} + +// LengthPrefixTimeBytes returns length-prefixed bytes representation +// of time.Time. +func LengthPrefixTimeBytes(t time.Time) []byte { + bz := sdk.FormatTimeBytes(t) + return append([]byte{byte(len(bz))}, bz...) +} diff --git a/x/liquidfarming/types/keys_test.go b/x/liquidfarming/types/keys_test.go new file mode 100644 index 00000000..25b0bd26 --- /dev/null +++ b/x/liquidfarming/types/keys_test.go @@ -0,0 +1,184 @@ +package types_test + +import ( + fmt "fmt" + "testing" + time "time" + + "github.com/stretchr/testify/suite" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/tendermint/tendermint/crypto" + + utils "github.com/cosmosquad-labs/squad/v3/types" + "github.com/cosmosquad-labs/squad/v3/x/liquidfarming/types" +) + +type keysTestSuite struct { + suite.Suite +} + +func TestKeysTestSuite(t *testing.T) { + suite.Run(t, new(keysTestSuite)) +} + +func (s *keysTestSuite) TestGetLastRewardsAuctionIdKey() { + s.Require().Equal([]byte{0xe1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, types.GetLastRewardsAuctionIdKey(0)) + s.Require().Equal([]byte{0xe1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x9}, types.GetLastRewardsAuctionIdKey(9)) + s.Require().Equal([]byte{0xe1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xa}, types.GetLastRewardsAuctionIdKey(10)) +} + +func (s *keysTestSuite) TestGetLiquidFarmKey() { + s.Require().Equal([]byte{0xe4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, types.GetLiquidFarmKey(0)) + s.Require().Equal([]byte{0xe4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x9}, types.GetLiquidFarmKey(9)) + s.Require().Equal([]byte{0xe4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xa}, types.GetLiquidFarmKey(10)) +} + +func (s *keysTestSuite) TestGetCompundingRewardsKey() { + s.Require().Equal([]byte{0xe7, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, types.GetCompoundingRewardsKey(0)) + s.Require().Equal([]byte{0xe7, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x9}, types.GetCompoundingRewardsKey(9)) + s.Require().Equal([]byte{0xe7, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xa}, types.GetCompoundingRewardsKey(10)) +} + +func (s *keysTestSuite) TestGetRewardsAuctionKey() { + testCases := []struct { + poolId uint64 + auctionId uint64 + expected []byte + }{ + { + 1, + 1, + []byte{0xe8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1}, + }, + { + 1, + 5, + []byte{0xe8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x5, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1}, + }, + { + 5, + 5, + []byte{0xe8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x5, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x5}, + }, + } + + for i, tc := range testCases { + s.Run(fmt.Sprint(i), func() { + key := types.GetRewardsAuctionKey(tc.auctionId, tc.poolId) + s.Require().Equal(tc.expected, key) + }) + } +} + +func (s *keysTestSuite) TestGetBidKey() { + testCases := []struct { + poolId uint64 + bidder sdk.AccAddress + expected []byte + }{ + { + 1, + sdk.AccAddress(crypto.AddressHash([]byte("bidder1"))), + []byte{0xea, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x14, + 0x20, 0x5c, 0xa, 0x82, 0xa, 0xf1, 0xed, 0x98, 0x39, 0x6a, + 0x35, 0xfe, 0xe3, 0x5d, 0x5, 0x2c, 0xd7, 0x96, 0x5a, 0x37}, + }, + { + 1, + sdk.AccAddress(crypto.AddressHash([]byte("bidder3"))), + []byte{0xea, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x14, + 0xe, 0x99, 0x7b, 0x9b, 0x5c, 0xef, 0x81, 0x2f, 0xc6, 0x3f, + 0xb6, 0x8b, 0x27, 0x42, 0x8a, 0xab, 0x7a, 0x58, 0xbc, 0x5e}, + }, + { + 5, + sdk.AccAddress(crypto.AddressHash([]byte("bidder22"))), + []byte{0xea, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x5, 0x14, + 0x4c, 0xf1, 0xbd, 0x90, 0x1, 0x70, 0x78, 0xfb, 0xfc, 0x87, + 0x51, 0x9d, 0x40, 0x4, 0x39, 0x9f, 0x4d, 0xe3, 0xc9, 0x43}, + }, + } + + for i, tc := range testCases { + s.Run(fmt.Sprint(i), func() { + key := types.GetBidKey(tc.poolId, tc.bidder) + s.Require().Equal(tc.expected, key) + }) + } +} + +func (s *keysTestSuite) TestGetBidByPoolIdPrefix() { + s.Require().Equal([]byte{0xea, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, types.GetBidByPoolIdPrefix(0)) + s.Require().Equal([]byte{0xea, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x9}, types.GetBidByPoolIdPrefix(9)) + s.Require().Equal([]byte{0xea, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xa}, types.GetBidByPoolIdPrefix(10)) +} + +func (s *keysTestSuite) TestGetWinningBidKey() { + testCases := []struct { + poolId uint64 + auctionId uint64 + expected []byte + }{ + { + 1, + 1, + []byte{0xeb, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1}, + }, + { + 1, + 5, + []byte{0xeb, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x5}, + }, + { + 5, + 5, + []byte{0xeb, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x5, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x5}, + }, + } + + for i, tc := range testCases { + s.Run(fmt.Sprint(i), func() { + key := types.GetWinningBidKey(tc.poolId, tc.auctionId) + s.Require().Equal(tc.expected, key) + }) + } +} + +func (s *keysTestSuite) TestLengthPrefixTimeBytes() { + sampleTime1 := utils.ParseTime("2022-07-01T00:00:00Z") + sampleTime2 := utils.ParseTime("2022-08-01T00:00:00Z") + + testCases := []struct { + sampleTime time.Time + length int + expected []byte + }{ + { + sampleTime1, + len(sdk.FormatTimeBytes(sampleTime1)), + []byte{0x1d, 0x32, 0x30, 0x32, 0x32, 0x2d, 0x30, 0x37, 0x2d, 0x30, + 0x31, 0x54, 0x30, 0x30, 0x3a, 0x30, 0x30, 0x3a, 0x30, 0x30, + 0x2e, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30}, + }, + { + sampleTime2, + len(sdk.FormatTimeBytes(sampleTime2)), + []byte{0x1d, 0x32, 0x30, 0x32, 0x32, 0x2d, 0x30, 0x38, 0x2d, 0x30, + 0x31, 0x54, 0x30, 0x30, 0x3a, 0x30, 0x30, 0x3a, 0x30, 0x30, + 0x2e, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30}, + }, + } + + for _, tc := range testCases { + bz := types.LengthPrefixTimeBytes(tc.sampleTime) + s.Require().Equal(tc.length, int(bz[0])) + s.Require().Equal(tc.expected, bz) + } +} diff --git a/x/liquidfarming/types/liquidfarm.go b/x/liquidfarming/types/liquidfarm.go new file mode 100644 index 00000000..b2637eed --- /dev/null +++ b/x/liquidfarming/types/liquidfarm.go @@ -0,0 +1,133 @@ +package types + +import ( + fmt "fmt" + "regexp" + "strconv" + "strings" + + "github.com/cosmos/cosmos-sdk/codec" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + + farmingtypes "github.com/cosmosquad-labs/squad/v3/x/farming/types" + "github.com/cosmosquad-labs/squad/v3/x/liquidstaking/types" +) + +const ( + LiquidFarmReserveAccPrefix string = "LiquidFarmReserveAcc" + LiquidFarmFeeCollectorAccName string = "LiquidFarmFeeCollectorAcc" +) + +var ( + liquidFarmCoinDenomRegexp = regexp.MustCompile(`^lf([1-9]\d*)$`) + + // LiquidFarmFeeCollectorAcc is the fee collector address for liquid farms that collects all fees generated from the module. + LiquidFarmFeeCollectorAcc = farmingtypes.DeriveAddress(farmingtypes.ReserveAddressType, types.ModuleName, LiquidFarmFeeCollectorAccName) +) + +// NewLiquidFarm returns a new LiquidFarm. +func NewLiquidFarm(poolId uint64, minFarmAmt, minBidAmount sdk.Int, feeRate sdk.Dec) LiquidFarm { + return LiquidFarm{ + PoolId: poolId, + MinFarmAmount: minFarmAmt, + MinBidAmount: minBidAmount, + FeeRate: feeRate, + } +} + +// Validate validates LiquidFarm. +func (l LiquidFarm) Validate() error { + if l.PoolId == 0 { + return fmt.Errorf("pool id must not be 0") + } + if l.MinBidAmount.IsNegative() { + return fmt.Errorf("minimum bid amount must be 0 or positive value: %s", l.MinBidAmount) + } + if l.MinFarmAmount.IsNegative() { + return fmt.Errorf("minimum farm amount must be 0 or positive value: %s", l.MinFarmAmount) + } + if l.FeeRate.IsNegative() { + return fmt.Errorf("fee rate must be 0 or positive value: %s", l.FeeRate) + } + return nil +} + +// String returns a human-readable string representation of the LiquidFarm. +func (l LiquidFarm) String() string { + out, _ := l.MarshalYAML() + return out.(string) +} + +// MarshalYAML returns the YAML representation of a LiquidFarm. +func (l LiquidFarm) MarshalYAML() (interface{}, error) { + bz, err := codec.MarshalYAML(codec.NewProtoCodec(codectypes.NewInterfaceRegistry()), &l) + if err != nil { + return nil, err + } + return string(bz), err +} + +// LiquidFarmCoinDenom returns a unique liquid farming coin denom for a LiquidFarm. +func LiquidFarmCoinDenom(poolId uint64) string { + return fmt.Sprintf("lf%d", poolId) +} + +// ParseLiquidFarmCoinDenom parses a LF coin denom and returns its pool id. +func ParseLiquidFarmCoinDenom(denom string) (poolId uint64, err error) { + chunks := liquidFarmCoinDenomRegexp.FindStringSubmatch(denom) + if len(chunks) == 0 { + return 0, fmt.Errorf("%s is not a liquid farm coin denom", denom) + } + poolId, err = strconv.ParseUint(chunks[1], 10, 64) + if err != nil { + return 0, fmt.Errorf("parse pool id: %w", err) + } + return poolId, nil +} + +// LiquidFarmReserveAddress returns the reserve address for a liquid farm with the given pool id. +func LiquidFarmReserveAddress(poolId uint64) sdk.AccAddress { + return farmingtypes.DeriveAddress( + ReserveAddressType, + ModuleName, + strings.Join([]string{LiquidFarmReserveAccPrefix, strconv.FormatUint(poolId, 10)}, ModuleAddressNameSplitter), + ) +} + +// CalculateLiquidFarmAmount calculates minting liquid farm amount. +// MintingAmt = LFCoinTotalSupply / LPCoinTotalAmount * LPCoinFarmingAmount +func CalculateLiquidFarmAmount( + lfCoinTotalSupplyAmt sdk.Int, + lpCoinTotalFarmingAmt sdk.Int, + newFarmingAmt sdk.Int, +) sdk.Int { + if lfCoinTotalSupplyAmt.IsZero() { // initial minting + return newFarmingAmt + } + return lfCoinTotalSupplyAmt.Mul(newFarmingAmt).Quo(lpCoinTotalFarmingAmt) +} + +// CalculateLiquidUnfarmAmount calculates unfarming amount. +// UnfarmingAmount = LPCoinTotalAmount - CompoundingRewards / LFCoinTotalSupply * LFCoinUnfarmingAmount +func CalculateLiquidUnfarmAmount( + lfCoinTotalSupplyAmt sdk.Int, + lpCoinTotalFarmingAmt sdk.Int, + unfarmingAmt sdk.Int, + compoundingRewards sdk.Int, +) sdk.Int { + if lfCoinTotalSupplyAmt.Equal(unfarmingAmt) { // last one to unfarm + return lpCoinTotalFarmingAmt + } + totalFarmingAmt := lpCoinTotalFarmingAmt.Sub(compoundingRewards) + return totalFarmingAmt.Mul(unfarmingAmt).Quo(lfCoinTotalSupplyAmt) +} + +// DeductFees deducts fee rates from the farming rewards. +func DeductFees(poolId uint64, rewards sdk.Coins, feeRate sdk.Dec) (sdk.Coins, error) { + for i, reward := range rewards { + multiplier := sdk.OneDec().Sub(feeRate) // 1 - feeRate + rewards[i] = sdk.NewCoin(reward.Denom, reward.Amount.ToDec().Mul(multiplier).TruncateInt()) // reward * multiplier + } + return rewards, nil +} diff --git a/x/liquidfarming/types/liquidfarm_test.go b/x/liquidfarming/types/liquidfarm_test.go new file mode 100644 index 00000000..fefe663f --- /dev/null +++ b/x/liquidfarming/types/liquidfarm_test.go @@ -0,0 +1,208 @@ +package types_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + + sdk "github.com/cosmos/cosmos-sdk/types" + + utils "github.com/cosmosquad-labs/squad/v3/types" + "github.com/cosmosquad-labs/squad/v3/x/liquidfarming/types" +) + +func TestLiquidFarm(t *testing.T) { + liquidFarm := types.LiquidFarm{ + PoolId: 1, + MinFarmAmount: sdk.ZeroInt(), + MinBidAmount: sdk.ZeroInt(), + FeeRate: sdk.ZeroDec(), + } + require.Equal(t, `fee_rate: "0.000000000000000000" +min_bid_amount: "0" +min_farm_amount: "0" +pool_id: "1" +`, liquidFarm.String()) +} + +func TestLiquidFarmCoinDenom(t *testing.T) { + for _, tc := range []struct { + denom string + expectsErr bool + }{ + {"lf1", false}, + {"lf10", false}, + {"lf18446744073709551615", false}, + {"lf18446744073709551616", true}, + {"lfabc", true}, + {"lf01", true}, + {"lf-10", true}, + {"lf+10", true}, + {"ucre", true}, + {"denom1", true}, + } { + t.Run("", func(t *testing.T) { + poolId, err := types.ParseLiquidFarmCoinDenom(tc.denom) + if tc.expectsErr { + require.Error(t, err) + } else { + require.NoError(t, err) + require.Equal(t, tc.denom, types.LiquidFarmCoinDenom(poolId)) + } + }) + } +} + +func TestLiquidFarmReserveAddress(t *testing.T) { + config := sdk.GetConfig() + addrPrefix := config.GetBech32AccountAddrPrefix() + + for _, tc := range []struct { + poolId uint64 + expected string + }{ + {1, addrPrefix + "1zyyf855slxure4c8dr06p00qjnkem95d2lgv8wgvry2rt437x6tsaf9tcf"}, + {2, addrPrefix + "1d2csu4ynxpuxll8wk72n9z98ytm649u78paj9efskjwrlc2wyhpq8h886j"}, + } { + t.Run("", func(t *testing.T) { + require.Equal(t, tc.expected, types.LiquidFarmReserveAddress(tc.poolId).String()) + }) + } +} + +func TestCalculateLiquidFarmAmount(t *testing.T) { + for _, tc := range []struct { + name string + lfTotalSupplyAmt sdk.Int + lpTotalFarmingAmt sdk.Int + newFarmingAmt sdk.Int + expectedAmt sdk.Int + }{ + { + name: "initial minting", + lfTotalSupplyAmt: sdk.ZeroInt(), + lpTotalFarmingAmt: sdk.ZeroInt(), + newFarmingAmt: sdk.NewInt(1_000_00_000), + expectedAmt: sdk.NewInt(1_000_00_000), + }, + { + name: "normal", + lfTotalSupplyAmt: sdk.NewInt(1_000_000_000), + lpTotalFarmingAmt: sdk.NewInt(1_000_000_000), + newFarmingAmt: sdk.NewInt(250_000_000), + expectedAmt: sdk.NewInt(250_000_000), + }, + { + name: "rewards are auto compounded", + lfTotalSupplyAmt: sdk.NewInt(1_000_000_000), + lpTotalFarmingAmt: sdk.NewInt(1_100_000_000), + newFarmingAmt: sdk.NewInt(100_000_000), + expectedAmt: sdk.NewInt(90_909_090), + }, + } { + t.Run(tc.name, func(t *testing.T) { + mintingAmt := types.CalculateLiquidFarmAmount( + tc.lfTotalSupplyAmt, + tc.lpTotalFarmingAmt, + tc.newFarmingAmt, + ) + require.Equal(t, tc.expectedAmt, mintingAmt) + }) + } +} + +func TestCalculateLiquidUnfarmAmount(t *testing.T) { + for _, tc := range []struct { + name string + lfTotalSupplyAmt sdk.Int + lpTotalFarmingAmt sdk.Int + unfarmingAmt sdk.Int + compoundingRewards sdk.Int + expectedAmt sdk.Int + }{ + { + name: "unfarm all", + lfTotalSupplyAmt: sdk.NewInt(100_000_000), + lpTotalFarmingAmt: sdk.NewInt(100_000_000), + unfarmingAmt: sdk.NewInt(100_000_000), + compoundingRewards: sdk.ZeroInt(), + expectedAmt: sdk.NewInt(100_000_000), + }, + { + name: "unfarming small amount #1: no compounding rewards", + lfTotalSupplyAmt: sdk.NewInt(100_000_000), + lpTotalFarmingAmt: sdk.NewInt(100_000_000), + unfarmingAmt: sdk.NewInt(1), + compoundingRewards: sdk.ZeroInt(), + expectedAmt: sdk.NewInt(1), + }, + { + name: "unfarming small amount #2: with compounding rewards", + lfTotalSupplyAmt: sdk.NewInt(100_000_000), + lpTotalFarmingAmt: sdk.NewInt(100_000_100), + unfarmingAmt: sdk.NewInt(1), + compoundingRewards: sdk.NewInt(100), + expectedAmt: sdk.NewInt(1), + }, + { + name: "rewards are auto compounded #1: no compouding rewards", + lfTotalSupplyAmt: sdk.NewInt(1_000_000_000), + lpTotalFarmingAmt: sdk.NewInt(1_100_000_000), + unfarmingAmt: sdk.NewInt(100_000_000), + compoundingRewards: sdk.ZeroInt(), + expectedAmt: sdk.NewInt(110_000_000), + }, + { + name: "rewards are auto compounded #1: with compouding rewards", + lfTotalSupplyAmt: sdk.NewInt(1_000_000_000), + lpTotalFarmingAmt: sdk.NewInt(1_100_000_000), + unfarmingAmt: sdk.NewInt(100_000_000), + compoundingRewards: sdk.NewInt(100_000), + expectedAmt: sdk.NewInt(109_990_000), + }, + } { + t.Run(tc.name, func(t *testing.T) { + unfarmingAmt := types.CalculateLiquidUnfarmAmount( + tc.lfTotalSupplyAmt, + tc.lpTotalFarmingAmt, + tc.unfarmingAmt, + tc.compoundingRewards, + ) + require.Equal(t, tc.expectedAmt, unfarmingAmt) + }) + } +} + +func TestDeductFees(t *testing.T) { + for _, tc := range []struct { + name string + feeRate sdk.Dec + rewards sdk.Coins + deducted sdk.Coins + }{ + { + name: "zero fee rate", + feeRate: sdk.ZeroDec(), + rewards: utils.ParseCoins("100denom1"), + deducted: utils.ParseCoins("100denom1"), + }, + { + name: "fee rate - 10%", + feeRate: sdk.MustNewDecFromStr("0.1"), + rewards: utils.ParseCoins("100denom1"), + deducted: utils.ParseCoins("90denom1"), + }, + { + name: "fee rate - 6.666666666666%", + feeRate: sdk.MustNewDecFromStr("0.066666666666666"), + rewards: utils.ParseCoins("100000denom1"), + deducted: utils.ParseCoins("93333denom1"), + }, + } { + t.Run(tc.name, func(t *testing.T) { + deducted, err := types.DeductFees(1, tc.rewards, tc.feeRate) + require.NoError(t, err) + require.Equal(t, tc.deducted, deducted) + }) + } +} diff --git a/x/liquidfarming/types/liquidfarming.pb.go b/x/liquidfarming/types/liquidfarming.pb.go new file mode 100644 index 00000000..6c551396 --- /dev/null +++ b/x/liquidfarming/types/liquidfarming.pb.go @@ -0,0 +1,1173 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: squad/liquidfarming/v1beta1/liquidfarming.proto + +package types + +import ( + fmt "fmt" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + github_com_gogo_protobuf_types "github.com/gogo/protobuf/types" + _ "github.com/regen-network/cosmos-proto" + _ "google.golang.org/protobuf/types/known/timestamppb" + io "io" + math "math" + math_bits "math/bits" + time "time" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf +var _ = time.Kitchen + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// AuctionStatus enumerates the valid status of an auction. +type AuctionStatus int32 + +const ( + // AUCTION_STATUS_UNSPECIFIED defines the default auction status + AuctionStatusNil AuctionStatus = 0 + // AUCTION_STATUS_STARTED defines the started auction status + AuctionStatusStarted AuctionStatus = 1 + // AUCTION_STATUS_FINISHED defines the finished auction status + AuctionStatusFinished AuctionStatus = 2 + // AUCTION_STATUS_SKIPPED defines the skipped auction status + AuctionStatusSkipped AuctionStatus = 3 +) + +var AuctionStatus_name = map[int32]string{ + 0: "AUCTION_STATUS_UNSPECIFIED", + 1: "AUCTION_STATUS_STARTED", + 2: "AUCTION_STATUS_FINISHED", + 3: "AUCTION_STATUS_SKIPPED", +} + +var AuctionStatus_value = map[string]int32{ + "AUCTION_STATUS_UNSPECIFIED": 0, + "AUCTION_STATUS_STARTED": 1, + "AUCTION_STATUS_FINISHED": 2, + "AUCTION_STATUS_SKIPPED": 3, +} + +func (x AuctionStatus) String() string { + return proto.EnumName(AuctionStatus_name, int32(x)) +} + +func (AuctionStatus) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_b3445e3599d3c045, []int{0} +} + +// RewardsAuction defines rewards auction that is created by the module +// for every rewards_auction_duration in params. +type RewardsAuction struct { + // id specifies the unique auction id + Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + // pool_id specifies the liquidity pool id + PoolId uint64 `protobuf:"varint,2,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty"` + // bidding_coin_denom specifies the bidding coin denomination + BiddingCoinDenom string `protobuf:"bytes,3,opt,name=bidding_coin_denom,json=biddingCoinDenom,proto3" json:"bidding_coin_denom,omitempty"` + // paying_reserve_address specfies the account that reserves bidding amounts placed by bidders + PayingReserveAddress string `protobuf:"bytes,4,opt,name=paying_reserve_address,json=payingReserveAddress,proto3" json:"paying_reserve_address,omitempty"` + // start_time specifies the start time of an auction + StartTime time.Time `protobuf:"bytes,5,opt,name=start_time,json=startTime,proto3,stdtime" json:"start_time"` + // end_time specifies the end time of an auction + EndTime time.Time `protobuf:"bytes,6,opt,name=end_time,json=endTime,proto3,stdtime" json:"end_time"` + // status specifies the status of an auction + Status AuctionStatus `protobuf:"varint,7,opt,name=status,proto3,enum=squad.liquidfarming.v1beta1.AuctionStatus" json:"status,omitempty"` + // winner specifies the bidder who won the auction + // the value is determined when an auction is finished + Winner string `protobuf:"bytes,8,opt,name=winner,proto3" json:"winner,omitempty"` + // winning_amount specifies the winning amount for the uaction + WinningAmount types.Coin `protobuf:"bytes,9,opt,name=winning_amount,json=winningAmount,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coin" json:"winning_amount"` + // rewards specifies the farming rewards for are accumulated in the farm module + // the value is determined when an auction is finished + Rewards github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,10,rep,name=rewards,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"rewards"` +} + +func (m *RewardsAuction) Reset() { *m = RewardsAuction{} } +func (m *RewardsAuction) String() string { return proto.CompactTextString(m) } +func (*RewardsAuction) ProtoMessage() {} +func (*RewardsAuction) Descriptor() ([]byte, []int) { + return fileDescriptor_b3445e3599d3c045, []int{0} +} +func (m *RewardsAuction) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *RewardsAuction) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_RewardsAuction.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 *RewardsAuction) XXX_Merge(src proto.Message) { + xxx_messageInfo_RewardsAuction.Merge(m, src) +} +func (m *RewardsAuction) XXX_Size() int { + return m.Size() +} +func (m *RewardsAuction) XXX_DiscardUnknown() { + xxx_messageInfo_RewardsAuction.DiscardUnknown(m) +} + +var xxx_messageInfo_RewardsAuction proto.InternalMessageInfo + +// CompoundingRewards records the amount of pool coin that is used for a bidder to place a bid +// for an auction. It is used internally to calculate unfarm amount. +type CompoundingRewards struct { + Amount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=amount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"amount"` +} + +func (m *CompoundingRewards) Reset() { *m = CompoundingRewards{} } +func (m *CompoundingRewards) String() string { return proto.CompactTextString(m) } +func (*CompoundingRewards) ProtoMessage() {} +func (*CompoundingRewards) Descriptor() ([]byte, []int) { + return fileDescriptor_b3445e3599d3c045, []int{1} +} +func (m *CompoundingRewards) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *CompoundingRewards) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_CompoundingRewards.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 *CompoundingRewards) XXX_Merge(src proto.Message) { + xxx_messageInfo_CompoundingRewards.Merge(m, src) +} +func (m *CompoundingRewards) XXX_Size() int { + return m.Size() +} +func (m *CompoundingRewards) XXX_DiscardUnknown() { + xxx_messageInfo_CompoundingRewards.DiscardUnknown(m) +} + +var xxx_messageInfo_CompoundingRewards proto.InternalMessageInfo + +// Bid defines standard bid for a rewards auction. +type Bid struct { + // pool_id specifies the pool id + PoolId uint64 `protobuf:"varint,1,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty"` + // bidder specifies the bech32-encoded address that places a bid for the auction + Bidder string `protobuf:"bytes,2,opt,name=bidder,proto3" json:"bidder,omitempty"` + // amount specifies the amount to place a bid + Amount types.Coin `protobuf:"bytes,3,opt,name=amount,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coin" json:"amount"` +} + +func (m *Bid) Reset() { *m = Bid{} } +func (m *Bid) String() string { return proto.CompactTextString(m) } +func (*Bid) ProtoMessage() {} +func (*Bid) Descriptor() ([]byte, []int) { + return fileDescriptor_b3445e3599d3c045, []int{2} +} +func (m *Bid) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Bid) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Bid.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 *Bid) XXX_Merge(src proto.Message) { + xxx_messageInfo_Bid.Merge(m, src) +} +func (m *Bid) XXX_Size() int { + return m.Size() +} +func (m *Bid) XXX_DiscardUnknown() { + xxx_messageInfo_Bid.DiscardUnknown(m) +} + +var xxx_messageInfo_Bid proto.InternalMessageInfo + +func init() { + proto.RegisterEnum("squad.liquidfarming.v1beta1.AuctionStatus", AuctionStatus_name, AuctionStatus_value) + proto.RegisterType((*RewardsAuction)(nil), "squad.liquidfarming.v1beta1.RewardsAuction") + proto.RegisterType((*CompoundingRewards)(nil), "squad.liquidfarming.v1beta1.CompoundingRewards") + proto.RegisterType((*Bid)(nil), "squad.liquidfarming.v1beta1.Bid") +} + +func init() { + proto.RegisterFile("squad/liquidfarming/v1beta1/liquidfarming.proto", fileDescriptor_b3445e3599d3c045) +} + +var fileDescriptor_b3445e3599d3c045 = []byte{ + // 706 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0xcd, 0x4e, 0xeb, 0x46, + 0x14, 0xb6, 0x93, 0x34, 0x21, 0x53, 0x11, 0x45, 0xa3, 0x14, 0x8c, 0x2b, 0x39, 0x16, 0x8b, 0x36, + 0x42, 0xc5, 0x2e, 0x14, 0xb1, 0xe8, 0xa6, 0xca, 0xaf, 0x6a, 0x55, 0x4a, 0x91, 0x13, 0x36, 0xdd, + 0x58, 0x76, 0x66, 0x08, 0x23, 0x62, 0x8f, 0xf1, 0xd8, 0x50, 0xde, 0x00, 0xb1, 0xe2, 0x05, 0x90, + 0x90, 0xba, 0xeb, 0x93, 0xb0, 0x64, 0xd9, 0x76, 0x01, 0x2d, 0x3c, 0x40, 0x5f, 0xe1, 0x6a, 0xc6, + 0x03, 0x92, 0xb9, 0x08, 0x71, 0xa5, 0xbb, 0xb2, 0xcf, 0xf9, 0xe6, 0x3b, 0xdf, 0xf9, 0x9b, 0x01, + 0x36, 0x3b, 0xce, 0x7c, 0x64, 0x2f, 0xc8, 0x71, 0x46, 0xd0, 0x81, 0x9f, 0x84, 0x24, 0x9a, 0xdb, + 0x27, 0x5b, 0x01, 0x4e, 0xfd, 0xad, 0xa2, 0xd7, 0x8a, 0x13, 0x9a, 0x52, 0xf8, 0xb5, 0x20, 0x58, + 0x45, 0x48, 0x12, 0xf4, 0xd6, 0x9c, 0xce, 0xa9, 0x38, 0x67, 0xf3, 0xbf, 0x9c, 0xa2, 0xaf, 0xcd, + 0x28, 0x0b, 0x29, 0xf3, 0x72, 0x20, 0x37, 0x24, 0x64, 0xe4, 0x96, 0x1d, 0xf8, 0x0c, 0x3f, 0xcb, + 0xce, 0x28, 0x89, 0x24, 0xde, 0x9e, 0x53, 0x3a, 0x5f, 0x60, 0x5b, 0x58, 0x41, 0x76, 0x60, 0xa7, + 0x24, 0xc4, 0x2c, 0xf5, 0xc3, 0x38, 0x3f, 0xb0, 0xfe, 0x77, 0x05, 0x34, 0x5c, 0x7c, 0xea, 0x27, + 0x88, 0x75, 0xb3, 0x59, 0x4a, 0x68, 0x04, 0x1b, 0xa0, 0x44, 0x90, 0xa6, 0x9a, 0x6a, 0xa7, 0xe2, + 0x96, 0x08, 0x82, 0xab, 0xa0, 0x16, 0x53, 0xba, 0xf0, 0x08, 0xd2, 0x4a, 0xc2, 0x59, 0xe5, 0xa6, + 0x83, 0xe0, 0x77, 0x00, 0x06, 0x04, 0x21, 0x12, 0xcd, 0x3d, 0x2e, 0xe9, 0x21, 0x1c, 0xd1, 0x50, + 0x2b, 0x9b, 0x6a, 0xa7, 0xee, 0x36, 0x25, 0xd2, 0xa7, 0x24, 0x1a, 0x70, 0x3f, 0xdc, 0x01, 0x2b, + 0xb1, 0x7f, 0xc6, 0x0f, 0x27, 0x98, 0xe1, 0xe4, 0x04, 0x7b, 0x3e, 0x42, 0x09, 0x66, 0x4c, 0xab, + 0x08, 0x46, 0x2b, 0x47, 0xdd, 0x1c, 0xec, 0xe6, 0x18, 0xec, 0x03, 0xc0, 0x52, 0x3f, 0x49, 0x3d, + 0x9e, 0xb8, 0xf6, 0x85, 0xa9, 0x76, 0xbe, 0xdc, 0xd6, 0xad, 0xbc, 0x2a, 0xeb, 0xa9, 0x2a, 0x6b, + 0xfa, 0x54, 0x55, 0x6f, 0xe9, 0xe6, 0xae, 0xad, 0x5c, 0xde, 0xb7, 0x55, 0xb7, 0x2e, 0x78, 0x1c, + 0x81, 0x3f, 0x81, 0x25, 0x1c, 0xa1, 0x3c, 0x44, 0xf5, 0x13, 0x42, 0xd4, 0x70, 0x84, 0x44, 0x80, + 0x1e, 0xa8, 0xb2, 0xd4, 0x4f, 0x33, 0xa6, 0xd5, 0x4c, 0xb5, 0xd3, 0xd8, 0xde, 0xb0, 0xde, 0x98, + 0xa2, 0x25, 0x1b, 0x39, 0x11, 0x0c, 0x57, 0x32, 0xe1, 0x0a, 0xa8, 0x9e, 0x92, 0x28, 0xc2, 0x89, + 0xb6, 0x24, 0xea, 0x95, 0x16, 0x3c, 0x06, 0x0d, 0xfe, 0xc7, 0x1b, 0xe3, 0x87, 0x34, 0x8b, 0x52, + 0xad, 0x2e, 0x52, 0x5c, 0xb3, 0xe4, 0xa4, 0xf9, 0x6c, 0x9f, 0x63, 0xf3, 0x7e, 0xf6, 0x6c, 0x9e, + 0xe1, 0x9f, 0xf7, 0xed, 0x6f, 0xe7, 0x24, 0x3d, 0xcc, 0x02, 0x6b, 0x46, 0x43, 0xb9, 0x16, 0xf2, + 0xb3, 0xc9, 0xd0, 0x91, 0x9d, 0x9e, 0xc5, 0x98, 0x09, 0x82, 0xbb, 0x2c, 0x15, 0xba, 0x42, 0x00, + 0x62, 0x50, 0x4b, 0xf2, 0x99, 0x6b, 0xc0, 0x2c, 0xbf, 0xad, 0xf5, 0xbd, 0xd4, 0xea, 0xbc, 0x53, + 0x8b, 0xb9, 0x4f, 0xb1, 0xd7, 0x03, 0x00, 0xfb, 0x34, 0x8c, 0x69, 0x16, 0x21, 0x31, 0x58, 0xe1, + 0x85, 0x23, 0x50, 0x95, 0x75, 0xf2, 0x15, 0xab, 0xf7, 0x2c, 0x2e, 0xf0, 0xcf, 0x5d, 0xfb, 0x9b, + 0x77, 0x08, 0x38, 0x51, 0xea, 0x4a, 0xf6, 0x8f, 0x95, 0xf3, 0xeb, 0xb6, 0xb2, 0x7e, 0xad, 0x82, + 0x72, 0xaf, 0xb8, 0xa4, 0x6a, 0x61, 0x49, 0x57, 0x40, 0x95, 0xaf, 0x22, 0x4e, 0xc4, 0xf2, 0xd6, + 0x5d, 0x69, 0xc1, 0xe0, 0x39, 0x8d, 0xf2, 0x67, 0x6f, 0x77, 0x21, 0xc5, 0x8d, 0xff, 0x55, 0xb0, + 0x5c, 0x58, 0x09, 0xb8, 0x03, 0xf4, 0xee, 0x7e, 0x7f, 0xea, 0xfc, 0x3a, 0xf6, 0x26, 0xd3, 0xee, + 0x74, 0x7f, 0xe2, 0xed, 0x8f, 0x27, 0x7b, 0xc3, 0xbe, 0x33, 0x72, 0x86, 0x83, 0xa6, 0xa2, 0xb7, + 0x2e, 0xae, 0xcc, 0x66, 0x81, 0x32, 0x26, 0x0b, 0x7e, 0x81, 0x5e, 0xb0, 0x26, 0xd3, 0xae, 0x3b, + 0x1d, 0x0e, 0x9a, 0xaa, 0xae, 0x5d, 0x5c, 0x99, 0xad, 0x02, 0x63, 0xc2, 0xb7, 0x1f, 0x23, 0xb8, + 0x0b, 0x56, 0x5f, 0xb0, 0x46, 0xce, 0xd8, 0x99, 0xfc, 0x3c, 0x1c, 0x34, 0x4b, 0xfa, 0xda, 0xc5, + 0x95, 0xf9, 0x55, 0x81, 0x36, 0x22, 0x11, 0x61, 0x87, 0x18, 0xbd, 0xa6, 0xf6, 0x8b, 0xb3, 0xb7, + 0x37, 0x1c, 0x34, 0xcb, 0xaf, 0xa9, 0x1d, 0x91, 0x38, 0xc6, 0x48, 0xaf, 0x9c, 0xff, 0x61, 0x28, + 0xbd, 0xe9, 0xcd, 0x7f, 0x86, 0x72, 0xf3, 0x60, 0xa8, 0xb7, 0x0f, 0x86, 0xfa, 0xef, 0x83, 0xa1, + 0x5e, 0x3e, 0x1a, 0xca, 0xed, 0xa3, 0xa1, 0xfc, 0xf5, 0x68, 0x28, 0xbf, 0xed, 0x7e, 0xd4, 0x46, + 0x7e, 0x97, 0x36, 0x17, 0x7e, 0xc0, 0xe4, 0x6b, 0xfa, 0xfb, 0x8b, 0xf7, 0x54, 0xb4, 0x36, 0xa8, + 0x8a, 0xbb, 0xfa, 0xc3, 0x87, 0x00, 0x00, 0x00, 0xff, 0xff, 0xa2, 0xab, 0x3b, 0xe1, 0x73, 0x05, + 0x00, 0x00, +} + +func (m *RewardsAuction) 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 *RewardsAuction) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *RewardsAuction) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Rewards) > 0 { + for iNdEx := len(m.Rewards) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Rewards[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintLiquidfarming(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x52 + } + } + { + size, err := m.WinningAmount.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintLiquidfarming(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x4a + if len(m.Winner) > 0 { + i -= len(m.Winner) + copy(dAtA[i:], m.Winner) + i = encodeVarintLiquidfarming(dAtA, i, uint64(len(m.Winner))) + i-- + dAtA[i] = 0x42 + } + if m.Status != 0 { + i = encodeVarintLiquidfarming(dAtA, i, uint64(m.Status)) + i-- + dAtA[i] = 0x38 + } + n2, err2 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.EndTime, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.EndTime):]) + if err2 != nil { + return 0, err2 + } + i -= n2 + i = encodeVarintLiquidfarming(dAtA, i, uint64(n2)) + i-- + dAtA[i] = 0x32 + n3, err3 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.StartTime, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.StartTime):]) + if err3 != nil { + return 0, err3 + } + i -= n3 + i = encodeVarintLiquidfarming(dAtA, i, uint64(n3)) + i-- + dAtA[i] = 0x2a + if len(m.PayingReserveAddress) > 0 { + i -= len(m.PayingReserveAddress) + copy(dAtA[i:], m.PayingReserveAddress) + i = encodeVarintLiquidfarming(dAtA, i, uint64(len(m.PayingReserveAddress))) + i-- + dAtA[i] = 0x22 + } + if len(m.BiddingCoinDenom) > 0 { + i -= len(m.BiddingCoinDenom) + copy(dAtA[i:], m.BiddingCoinDenom) + i = encodeVarintLiquidfarming(dAtA, i, uint64(len(m.BiddingCoinDenom))) + i-- + dAtA[i] = 0x1a + } + if m.PoolId != 0 { + i = encodeVarintLiquidfarming(dAtA, i, uint64(m.PoolId)) + i-- + dAtA[i] = 0x10 + } + if m.Id != 0 { + i = encodeVarintLiquidfarming(dAtA, i, uint64(m.Id)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *CompoundingRewards) 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 *CompoundingRewards) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *CompoundingRewards) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.Amount.Size() + i -= size + if _, err := m.Amount.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintLiquidfarming(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *Bid) 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 *Bid) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Bid) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Amount.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintLiquidfarming(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if len(m.Bidder) > 0 { + i -= len(m.Bidder) + copy(dAtA[i:], m.Bidder) + i = encodeVarintLiquidfarming(dAtA, i, uint64(len(m.Bidder))) + i-- + dAtA[i] = 0x12 + } + if m.PoolId != 0 { + i = encodeVarintLiquidfarming(dAtA, i, uint64(m.PoolId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintLiquidfarming(dAtA []byte, offset int, v uint64) int { + offset -= sovLiquidfarming(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *RewardsAuction) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Id != 0 { + n += 1 + sovLiquidfarming(uint64(m.Id)) + } + if m.PoolId != 0 { + n += 1 + sovLiquidfarming(uint64(m.PoolId)) + } + l = len(m.BiddingCoinDenom) + if l > 0 { + n += 1 + l + sovLiquidfarming(uint64(l)) + } + l = len(m.PayingReserveAddress) + if l > 0 { + n += 1 + l + sovLiquidfarming(uint64(l)) + } + l = github_com_gogo_protobuf_types.SizeOfStdTime(m.StartTime) + n += 1 + l + sovLiquidfarming(uint64(l)) + l = github_com_gogo_protobuf_types.SizeOfStdTime(m.EndTime) + n += 1 + l + sovLiquidfarming(uint64(l)) + if m.Status != 0 { + n += 1 + sovLiquidfarming(uint64(m.Status)) + } + l = len(m.Winner) + if l > 0 { + n += 1 + l + sovLiquidfarming(uint64(l)) + } + l = m.WinningAmount.Size() + n += 1 + l + sovLiquidfarming(uint64(l)) + if len(m.Rewards) > 0 { + for _, e := range m.Rewards { + l = e.Size() + n += 1 + l + sovLiquidfarming(uint64(l)) + } + } + return n +} + +func (m *CompoundingRewards) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Amount.Size() + n += 1 + l + sovLiquidfarming(uint64(l)) + return n +} + +func (m *Bid) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PoolId != 0 { + n += 1 + sovLiquidfarming(uint64(m.PoolId)) + } + l = len(m.Bidder) + if l > 0 { + n += 1 + l + sovLiquidfarming(uint64(l)) + } + l = m.Amount.Size() + n += 1 + l + sovLiquidfarming(uint64(l)) + return n +} + +func sovLiquidfarming(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozLiquidfarming(x uint64) (n int) { + return sovLiquidfarming(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *RewardsAuction) 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 ErrIntOverflowLiquidfarming + } + 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: RewardsAuction: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: RewardsAuction: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) + } + m.Id = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLiquidfarming + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Id |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PoolId", wireType) + } + m.PoolId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLiquidfarming + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PoolId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BiddingCoinDenom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLiquidfarming + } + 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 ErrInvalidLengthLiquidfarming + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLiquidfarming + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.BiddingCoinDenom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PayingReserveAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLiquidfarming + } + 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 ErrInvalidLengthLiquidfarming + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLiquidfarming + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PayingReserveAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StartTime", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLiquidfarming + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthLiquidfarming + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthLiquidfarming + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(&m.StartTime, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EndTime", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLiquidfarming + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthLiquidfarming + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthLiquidfarming + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(&m.EndTime, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 7: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) + } + m.Status = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLiquidfarming + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Status |= AuctionStatus(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Winner", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLiquidfarming + } + 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 ErrInvalidLengthLiquidfarming + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLiquidfarming + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Winner = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 9: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field WinningAmount", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLiquidfarming + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthLiquidfarming + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthLiquidfarming + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.WinningAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 10: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Rewards", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLiquidfarming + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthLiquidfarming + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthLiquidfarming + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Rewards = append(m.Rewards, types.Coin{}) + if err := m.Rewards[len(m.Rewards)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipLiquidfarming(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthLiquidfarming + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *CompoundingRewards) 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 ErrIntOverflowLiquidfarming + } + 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: CompoundingRewards: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: CompoundingRewards: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLiquidfarming + } + 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 ErrInvalidLengthLiquidfarming + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLiquidfarming + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Amount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipLiquidfarming(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthLiquidfarming + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Bid) 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 ErrIntOverflowLiquidfarming + } + 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: Bid: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Bid: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PoolId", wireType) + } + m.PoolId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLiquidfarming + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PoolId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Bidder", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLiquidfarming + } + 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 ErrInvalidLengthLiquidfarming + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLiquidfarming + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Bidder = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLiquidfarming + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthLiquidfarming + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthLiquidfarming + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Amount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipLiquidfarming(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthLiquidfarming + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipLiquidfarming(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowLiquidfarming + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowLiquidfarming + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowLiquidfarming + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthLiquidfarming + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupLiquidfarming + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthLiquidfarming + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthLiquidfarming = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowLiquidfarming = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupLiquidfarming = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/liquidfarming/types/msgs.go b/x/liquidfarming/types/msgs.go new file mode 100644 index 00000000..03c5ad99 --- /dev/null +++ b/x/liquidfarming/types/msgs.go @@ -0,0 +1,287 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + + liquiditytypes "github.com/cosmosquad-labs/squad/v3/x/liquidity/types" +) + +var ( + _ sdk.Msg = (*MsgLiquidFarm)(nil) + _ sdk.Msg = (*MsgLiquidUnfarm)(nil) + _ sdk.Msg = (*MsgLiquidUnfarmAndWithdraw)(nil) + _ sdk.Msg = (*MsgPlaceBid)(nil) + _ sdk.Msg = (*MsgRefundBid)(nil) +) + +// Message types for the module +const ( + TypeMsgLiquidFarm = "liquid_farm" + TypeMsgLiquidUnfarm = "liquid_unfarm" + TypeMsgLiquidUnfarmAndWithdraw = "liquid_unfarm_and_withdraw" + TypeMsgPlaceBid = "place_bid" + TypeMsgRefundBid = "refund_bid" +) + +// NewMsgLiquidFarm creates a new MsgLiquidFarm +func NewMsgLiquidFarm(poolId uint64, farmer string, farmingCoin sdk.Coin) *MsgLiquidFarm { + return &MsgLiquidFarm{ + PoolId: poolId, + Farmer: farmer, + FarmingCoin: farmingCoin, + } +} + +func (msg MsgLiquidFarm) Route() string { return RouterKey } + +func (msg MsgLiquidFarm) Type() string { return TypeMsgLiquidFarm } + +func (msg MsgLiquidFarm) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(msg.Farmer); err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid farmer address: %v", err) + } + if msg.PoolId == 0 { + return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "invalid pool id") + } + if err := msg.FarmingCoin.Validate(); err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid farming coin: %v", err) + } + if !msg.FarmingCoin.IsPositive() { + return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "farming coin must be positive") + } + poolCoinDenom := liquiditytypes.PoolCoinDenom(msg.PoolId) + if poolCoinDenom != msg.FarmingCoin.Denom { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "expected denom %s, but got %s", poolCoinDenom, msg.FarmingCoin.Denom) + } + return nil +} + +func (msg MsgLiquidFarm) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) +} + +func (msg MsgLiquidFarm) GetSigners() []sdk.AccAddress { + addr, err := sdk.AccAddressFromBech32(msg.Farmer) + if err != nil { + panic(err) + } + return []sdk.AccAddress{addr} +} + +func (msg MsgLiquidFarm) GetFarmer() sdk.AccAddress { + addr, err := sdk.AccAddressFromBech32(msg.Farmer) + if err != nil { + panic(err) + } + return addr +} + +// NewMsgLiquidUnfarm creates a new MsgLiquidUnfarm +func NewMsgLiquidUnfarm(poolId uint64, farmer string, unfarmingCoin sdk.Coin) *MsgLiquidUnfarm { + return &MsgLiquidUnfarm{ + PoolId: poolId, + Farmer: farmer, + UnfarmingCoin: unfarmingCoin, + } +} + +func (msg MsgLiquidUnfarm) Route() string { return RouterKey } + +func (msg MsgLiquidUnfarm) Type() string { return TypeMsgLiquidUnfarm } + +func (msg MsgLiquidUnfarm) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(msg.Farmer); err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid farmer address: %v", err) + } + if msg.PoolId == 0 { + return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "invalid pool id") + } + if err := msg.UnfarmingCoin.Validate(); err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid unfarming coin: %v", err) + } + if !msg.UnfarmingCoin.IsPositive() { + return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "unfarming coin must be positive") + } + expCoinDenom := LiquidFarmCoinDenom(msg.PoolId) + if msg.UnfarmingCoin.Denom != expCoinDenom { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "expected denom %s, but got %s", expCoinDenom, msg.UnfarmingCoin.Denom) + } + return nil +} + +func (msg MsgLiquidUnfarm) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) +} + +func (msg MsgLiquidUnfarm) GetSigners() []sdk.AccAddress { + addr, err := sdk.AccAddressFromBech32(msg.Farmer) + if err != nil { + panic(err) + } + return []sdk.AccAddress{addr} +} + +func (msg MsgLiquidUnfarm) GetFarmer() sdk.AccAddress { + addr, err := sdk.AccAddressFromBech32(msg.Farmer) + if err != nil { + panic(err) + } + return addr +} + +// NewMsgLiquidUnfarmAndWithdraw creates a new MsgLiquidUnfarmAndWithdraw +func NewMsgLiquidUnfarmAndWithdraw(poolId uint64, farmer string, unfarmingCoin sdk.Coin) *MsgLiquidUnfarmAndWithdraw { + return &MsgLiquidUnfarmAndWithdraw{ + PoolId: poolId, + Farmer: farmer, + UnfarmingCoin: unfarmingCoin, + } +} + +func (msg MsgLiquidUnfarmAndWithdraw) Route() string { return RouterKey } + +func (msg MsgLiquidUnfarmAndWithdraw) Type() string { return TypeMsgLiquidUnfarmAndWithdraw } + +func (msg MsgLiquidUnfarmAndWithdraw) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(msg.Farmer); err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid farmer address: %v", err) + } + if msg.PoolId == 0 { + return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "invalid pool id") + } + if err := msg.UnfarmingCoin.Validate(); err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid unfarming coin: %v", err) + } + if !msg.UnfarmingCoin.IsPositive() { + return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "unfarming coin must be positive") + } + expCoinDenom := LiquidFarmCoinDenom(msg.PoolId) + if msg.UnfarmingCoin.Denom != expCoinDenom { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "expected denom %s, but got %s", expCoinDenom, msg.UnfarmingCoin.Denom) + } + return nil +} + +func (msg MsgLiquidUnfarmAndWithdraw) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) +} + +func (msg MsgLiquidUnfarmAndWithdraw) GetSigners() []sdk.AccAddress { + addr, err := sdk.AccAddressFromBech32(msg.Farmer) + if err != nil { + panic(err) + } + return []sdk.AccAddress{addr} +} + +func (msg MsgLiquidUnfarmAndWithdraw) GetFarmer() sdk.AccAddress { + addr, err := sdk.AccAddressFromBech32(msg.Farmer) + if err != nil { + panic(err) + } + return addr +} + +// NewMsgPlaceBid creates a new MsgPlaceBid +func NewMsgPlaceBid(auctionId uint64, poolId uint64, bidder string, biddingCoin sdk.Coin) *MsgPlaceBid { + return &MsgPlaceBid{ + AuctionId: auctionId, + PoolId: poolId, + Bidder: bidder, + BiddingCoin: biddingCoin, + } +} + +func (msg MsgPlaceBid) Route() string { return RouterKey } + +func (msg MsgPlaceBid) Type() string { return TypeMsgPlaceBid } + +func (msg MsgPlaceBid) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(msg.Bidder); err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid bidder address: %v", err) + } + if msg.AuctionId == 0 { + return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "invalid auction id") + } + if msg.PoolId == 0 { + return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "invalid pool id") + } + if err := msg.BiddingCoin.Validate(); err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid bidding coin: %v", err) + } + if !msg.BiddingCoin.IsPositive() { + return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "bidding amount must be positive") + } + poolCoinDenom := liquiditytypes.PoolCoinDenom(msg.PoolId) + if poolCoinDenom != msg.BiddingCoin.Denom { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "expected denom %s, but got %s", poolCoinDenom, msg.BiddingCoin.Denom) + } + return nil +} + +func (msg MsgPlaceBid) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) +} + +func (msg MsgPlaceBid) GetSigners() []sdk.AccAddress { + addr, err := sdk.AccAddressFromBech32(msg.Bidder) + if err != nil { + panic(err) + } + return []sdk.AccAddress{addr} +} + +func (msg MsgPlaceBid) GetBidder() sdk.AccAddress { + addr, err := sdk.AccAddressFromBech32(msg.Bidder) + if err != nil { + panic(err) + } + return addr +} + +// NewMsgRefundBid creates a new MsgRefundBid +func NewMsgRefundBid(auctionId uint64, poolId uint64, bidder string) *MsgRefundBid { + return &MsgRefundBid{ + AuctionId: auctionId, + PoolId: poolId, + Bidder: bidder, + } +} + +func (msg MsgRefundBid) Route() string { return RouterKey } + +func (msg MsgRefundBid) Type() string { return TypeMsgRefundBid } + +func (msg MsgRefundBid) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(msg.Bidder); err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid bidder address: %v", err) + } + if msg.AuctionId == 0 { + return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "invalid auction id") + } + if msg.PoolId == 0 { + return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "invalid pool id") + } + return nil +} + +func (msg MsgRefundBid) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) +} + +func (msg MsgRefundBid) GetSigners() []sdk.AccAddress { + addr, err := sdk.AccAddressFromBech32(msg.Bidder) + if err != nil { + panic(err) + } + return []sdk.AccAddress{addr} +} + +func (msg MsgRefundBid) GetBidder() sdk.AccAddress { + addr, err := sdk.AccAddressFromBech32(msg.Bidder) + if err != nil { + panic(err) + } + return addr +} diff --git a/x/liquidfarming/types/msgs_test.go b/x/liquidfarming/types/msgs_test.go new file mode 100644 index 00000000..7a6dfbe6 --- /dev/null +++ b/x/liquidfarming/types/msgs_test.go @@ -0,0 +1,312 @@ +package types_test + +import ( + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + "github.com/tendermint/tendermint/crypto" + + utils "github.com/cosmosquad-labs/squad/v3/types" + "github.com/cosmosquad-labs/squad/v3/x/liquidfarming/types" +) + +var testAddr = sdk.AccAddress(crypto.AddressHash([]byte("test"))) + +func TestMsgLiquidFarm(t *testing.T) { + for _, tc := range []struct { + name string + malleate func(msg *types.MsgLiquidFarm) + expectedErr string + }{ + { + "happy case", + func(msg *types.MsgLiquidFarm) {}, + "", + }, + { + "invalid pool id", + func(msg *types.MsgLiquidFarm) { + msg.PoolId = 0 + }, + "invalid pool id: invalid request", + }, + { + "invalid farmer", + func(msg *types.MsgLiquidFarm) { + msg.Farmer = "invalidaddr" + }, + "invalid farmer address: decoding bech32 failed: invalid separator index -1: invalid address", + }, + { + "invalid farming coin", + func(msg *types.MsgLiquidFarm) { + msg.PoolId = 1 + msg.FarmingCoin = sdk.NewInt64Coin("pool1", 0) + }, + "farming coin must be positive: invalid request", + }, + { + "invalid farming coin denom", + func(msg *types.MsgLiquidFarm) { + msg.PoolId = 1 + msg.FarmingCoin = sdk.NewInt64Coin("denom1", 100_000) + }, + "expected denom pool1, but got denom1: invalid request", + }, + } { + t.Run(tc.name, func(t *testing.T) { + msg := types.NewMsgLiquidFarm(1, testAddr.String(), utils.ParseCoin("1000000pool1")) + tc.malleate(msg) + require.Equal(t, types.TypeMsgLiquidFarm, msg.Type()) + require.Equal(t, types.RouterKey, msg.Route()) + require.Equal(t, sdk.MustSortJSON(types.ModuleCdc.MustMarshalJSON(msg)), msg.GetSignBytes()) + err := msg.ValidateBasic() + if tc.expectedErr == "" { + require.NoError(t, err) + signers := msg.GetSigners() + require.Len(t, signers, 1) + require.Equal(t, msg.GetFarmer(), signers[0]) + } else { + require.EqualError(t, err, tc.expectedErr) + } + }) + } +} + +func TestMsgLiquidUnfarm(t *testing.T) { + for _, tc := range []struct { + name string + malleate func(msg *types.MsgLiquidUnfarm) + expectedErr string + }{ + { + "happy case", + func(msg *types.MsgLiquidUnfarm) {}, + "", + }, + { + "invalid pool id", + func(msg *types.MsgLiquidUnfarm) { + msg.PoolId = 0 + }, + "invalid pool id: invalid request", + }, + { + "invalid farmer", + func(msg *types.MsgLiquidUnfarm) { + msg.Farmer = "invalidaddr" + }, + "invalid farmer address: decoding bech32 failed: invalid separator index -1: invalid address", + }, + { + "invalid lf coin", + func(msg *types.MsgLiquidUnfarm) { + msg.UnfarmingCoin = sdk.NewInt64Coin("lf1", 0) + }, + "unfarming coin must be positive: invalid request", + }, + { + "invalid lf coin denom", + func(msg *types.MsgLiquidUnfarm) { + msg.UnfarmingCoin = sdk.NewInt64Coin("pool1", 100_000) + }, + "expected denom lf1, but got pool1: invalid request", + }, + } { + t.Run(tc.name, func(t *testing.T) { + msg := types.NewMsgLiquidUnfarm(1, testAddr.String(), utils.ParseCoin("1000000lf1")) + tc.malleate(msg) + require.Equal(t, types.TypeMsgLiquidUnfarm, msg.Type()) + require.Equal(t, types.RouterKey, msg.Route()) + require.Equal(t, sdk.MustSortJSON(types.ModuleCdc.MustMarshalJSON(msg)), msg.GetSignBytes()) + err := msg.ValidateBasic() + if tc.expectedErr == "" { + require.NoError(t, err) + signers := msg.GetSigners() + require.Len(t, signers, 1) + require.Equal(t, msg.GetFarmer(), signers[0]) + } else { + require.EqualError(t, err, tc.expectedErr) + } + }) + } +} + +func TestMsgLiquidUnfarmAndWithdraw(t *testing.T) { + for _, tc := range []struct { + name string + malleate func(msg *types.MsgLiquidUnfarmAndWithdraw) + expectedErr string + }{ + { + "happy case", + func(msg *types.MsgLiquidUnfarmAndWithdraw) {}, + "", + }, + { + "invalid pool id", + func(msg *types.MsgLiquidUnfarmAndWithdraw) { + msg.PoolId = 0 + }, + "invalid pool id: invalid request", + }, + { + "invalid farmer", + func(msg *types.MsgLiquidUnfarmAndWithdraw) { + msg.Farmer = "invalidaddr" + }, + "invalid farmer address: decoding bech32 failed: invalid separator index -1: invalid address", + }, + { + "invalid lf coin", + func(msg *types.MsgLiquidUnfarmAndWithdraw) { + msg.UnfarmingCoin = sdk.NewInt64Coin("lf1", 0) + }, + "unfarming coin must be positive: invalid request", + }, + { + "invalid lf coin denom", + func(msg *types.MsgLiquidUnfarmAndWithdraw) { + msg.UnfarmingCoin = sdk.NewInt64Coin("pool1", 100_000) + }, + "expected denom lf1, but got pool1: invalid request", + }, + } { + t.Run(tc.name, func(t *testing.T) { + msg := types.NewMsgLiquidUnfarmAndWithdraw(1, testAddr.String(), utils.ParseCoin("1000000lf1")) + tc.malleate(msg) + require.Equal(t, types.TypeMsgLiquidUnfarmAndWithdraw, msg.Type()) + require.Equal(t, types.RouterKey, msg.Route()) + require.Equal(t, sdk.MustSortJSON(types.ModuleCdc.MustMarshalJSON(msg)), msg.GetSignBytes()) + err := msg.ValidateBasic() + if tc.expectedErr == "" { + require.NoError(t, err) + signers := msg.GetSigners() + require.Len(t, signers, 1) + require.Equal(t, msg.GetFarmer(), signers[0]) + } else { + require.EqualError(t, err, tc.expectedErr) + } + }) + } +} + +func TestMsgPlaceBid(t *testing.T) { + for _, tc := range []struct { + name string + malleate func(msg *types.MsgPlaceBid) + expectedErr string + }{ + { + "happy case", + func(msg *types.MsgPlaceBid) {}, + "", + }, + { + "invalid auction id", + func(msg *types.MsgPlaceBid) { + msg.AuctionId = 0 + }, + "invalid auction id: invalid request", + }, + { + "invalid pool id", + func(msg *types.MsgPlaceBid) { + msg.PoolId = 0 + }, + "invalid pool id: invalid request", + }, + { + "invalid bidder", + func(msg *types.MsgPlaceBid) { + msg.Bidder = "invalidaddr" + }, + "invalid bidder address: decoding bech32 failed: invalid separator index -1: invalid address", + }, + { + "invalid bidding coin", + func(msg *types.MsgPlaceBid) { + msg.BiddingCoin = sdk.NewInt64Coin("pool1", 0) + }, + "bidding amount must be positive: invalid request", + }, + { + "invalid bidding coin denom", + func(msg *types.MsgPlaceBid) { + msg.PoolId = 1 + msg.BiddingCoin = sdk.NewInt64Coin("denom1", 100_000) + }, + "expected denom pool1, but got denom1: invalid request", + }, + } { + t.Run(tc.name, func(t *testing.T) { + msg := types.NewMsgPlaceBid(1, 1, testAddr.String(), utils.ParseCoin("1000000pool1")) + tc.malleate(msg) + require.Equal(t, types.TypeMsgPlaceBid, msg.Type()) + require.Equal(t, types.RouterKey, msg.Route()) + require.Equal(t, sdk.MustSortJSON(types.ModuleCdc.MustMarshalJSON(msg)), msg.GetSignBytes()) + err := msg.ValidateBasic() + if tc.expectedErr == "" { + require.NoError(t, err) + signers := msg.GetSigners() + require.Len(t, signers, 1) + require.Equal(t, msg.GetBidder(), signers[0]) + } else { + require.EqualError(t, err, tc.expectedErr) + } + }) + } +} + +func TestMsgRefundBid(t *testing.T) { + for _, tc := range []struct { + name string + malleate func(msg *types.MsgRefundBid) + expectedErr string + }{ + { + "happy case", + func(msg *types.MsgRefundBid) {}, + "", + }, + { + "invalid auction id", + func(msg *types.MsgRefundBid) { + msg.AuctionId = 0 + }, + "invalid auction id: invalid request", + }, + { + "invalid pool id", + func(msg *types.MsgRefundBid) { + msg.PoolId = 0 + }, + "invalid pool id: invalid request", + }, + { + "invalid bidder", + func(msg *types.MsgRefundBid) { + msg.Bidder = "invalidaddr" + }, + "invalid bidder address: decoding bech32 failed: invalid separator index -1: invalid address", + }, + } { + t.Run(tc.name, func(t *testing.T) { + msg := types.NewMsgRefundBid(1, 1, testAddr.String()) + tc.malleate(msg) + require.Equal(t, types.TypeMsgRefundBid, msg.Type()) + require.Equal(t, types.RouterKey, msg.Route()) + require.Equal(t, sdk.MustSortJSON(types.ModuleCdc.MustMarshalJSON(msg)), msg.GetSignBytes()) + err := msg.ValidateBasic() + if tc.expectedErr == "" { + require.NoError(t, err) + signers := msg.GetSigners() + require.Len(t, signers, 1) + require.Equal(t, msg.GetBidder(), signers[0]) + } else { + require.EqualError(t, err, tc.expectedErr) + } + }) + } +} diff --git a/x/liquidfarming/types/params.go b/x/liquidfarming/types/params.go new file mode 100644 index 00000000..38d37d3f --- /dev/null +++ b/x/liquidfarming/types/params.go @@ -0,0 +1,83 @@ +package types + +import ( + "fmt" + time "time" + + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" +) + +// Parameter store keys +var ( + KeyLiquidFarms = []byte("LiquidFarms") + KeyRewardsAuctionDuration = []byte("RewardsAuctionDuration") + + DefaultLiquidFarms = []LiquidFarm{} + DefaultRewardsAuctionDuration time.Duration = time.Hour * 12 +) + +var _ paramtypes.ParamSet = (*Params)(nil) + +// ParamKeyTable the param key table for launch module +func ParamKeyTable() paramtypes.KeyTable { + return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) +} + +// DefaultParams returns a default set of parameters +func DefaultParams() Params { + return Params{ + LiquidFarms: DefaultLiquidFarms, + RewardsAuctionDuration: DefaultRewardsAuctionDuration, + } +} + +// ParamSetPairs get the params.ParamSet +func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { + return paramtypes.ParamSetPairs{ + paramtypes.NewParamSetPair(KeyLiquidFarms, &p.LiquidFarms, validateLiquidFarms), + paramtypes.NewParamSetPair(KeyRewardsAuctionDuration, &p.RewardsAuctionDuration, validateRewardsAuctionDuration), + } +} + +// Validate validates the set of parameters +func (p Params) Validate() error { + for _, v := range []struct { + value interface{} + validator func(interface{}) error + }{ + {p.LiquidFarms, validateLiquidFarms}, + {p.RewardsAuctionDuration, validateRewardsAuctionDuration}, + } { + if err := v.validator(v.value); err != nil { + return err + } + } + return nil +} + +func validateLiquidFarms(i interface{}) error { + liquidFarms, ok := i.([]LiquidFarm) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + for _, liquidFarm := range liquidFarms { + if err := liquidFarm.Validate(); err != nil { + return err + } + } + + return nil +} + +func validateRewardsAuctionDuration(i interface{}) error { + v, ok := i.(time.Duration) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + if v <= 0 { + return fmt.Errorf("auction period hours must be positive: %d", v) + } + return nil +} diff --git a/x/liquidfarming/types/params.pb.go b/x/liquidfarming/types/params.pb.go new file mode 100644 index 00000000..26acf452 --- /dev/null +++ b/x/liquidfarming/types/params.pb.go @@ -0,0 +1,680 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: squad/liquidfarming/v1beta1/params.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + github_com_gogo_protobuf_types "github.com/gogo/protobuf/types" + _ "google.golang.org/protobuf/types/known/durationpb" + io "io" + math "math" + math_bits "math/bits" + time "time" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf +var _ = time.Kitchen + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// Params defines the parameters for the module. +type Params struct { + LiquidFarms []LiquidFarm `protobuf:"bytes,1,rep,name=liquid_farms,json=liquidFarms,proto3" json:"liquid_farms"` + RewardsAuctionDuration time.Duration `protobuf:"bytes,2,opt,name=rewards_auction_duration,json=rewardsAuctionDuration,proto3,stdduration" json:"rewards_auction_duration"` +} + +func (m *Params) Reset() { *m = Params{} } +func (m *Params) String() string { return proto.CompactTextString(m) } +func (*Params) ProtoMessage() {} +func (*Params) Descriptor() ([]byte, []int) { + return fileDescriptor_6012e16b27fcc811, []int{0} +} +func (m *Params) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Params.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 *Params) XXX_Merge(src proto.Message) { + xxx_messageInfo_Params.Merge(m, src) +} +func (m *Params) XXX_Size() int { + return m.Size() +} +func (m *Params) XXX_DiscardUnknown() { + xxx_messageInfo_Params.DiscardUnknown(m) +} + +var xxx_messageInfo_Params proto.InternalMessageInfo + +// LiquidFarm defines liquid farm object that provides auto compounding functionality +// for the liquidity pool and undergoes farming rewards auction process. +// See the technical spec for more detailed information. +type LiquidFarm struct { + PoolId uint64 `protobuf:"varint,1,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty"` + MinFarmAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=min_farm_amount,json=minFarmAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"min_farm_amount"` + MinBidAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=min_bid_amount,json=minBidAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"min_bid_amount"` + FeeRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,4,opt,name=fee_rate,json=feeRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"fee_rate"` +} + +func (m *LiquidFarm) Reset() { *m = LiquidFarm{} } +func (*LiquidFarm) ProtoMessage() {} +func (*LiquidFarm) Descriptor() ([]byte, []int) { + return fileDescriptor_6012e16b27fcc811, []int{1} +} +func (m *LiquidFarm) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *LiquidFarm) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_LiquidFarm.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 *LiquidFarm) XXX_Merge(src proto.Message) { + xxx_messageInfo_LiquidFarm.Merge(m, src) +} +func (m *LiquidFarm) XXX_Size() int { + return m.Size() +} +func (m *LiquidFarm) XXX_DiscardUnknown() { + xxx_messageInfo_LiquidFarm.DiscardUnknown(m) +} + +var xxx_messageInfo_LiquidFarm proto.InternalMessageInfo + +func init() { + proto.RegisterType((*Params)(nil), "squad.liquidfarming.v1beta1.Params") + proto.RegisterType((*LiquidFarm)(nil), "squad.liquidfarming.v1beta1.LiquidFarm") +} + +func init() { + proto.RegisterFile("squad/liquidfarming/v1beta1/params.proto", fileDescriptor_6012e16b27fcc811) +} + +var fileDescriptor_6012e16b27fcc811 = []byte{ + // 445 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x92, 0x4f, 0x6b, 0x14, 0x31, + 0x18, 0xc6, 0x27, 0xed, 0xb2, 0x5d, 0xb3, 0x55, 0x61, 0x10, 0x1d, 0x2b, 0x64, 0x96, 0x1e, 0x74, + 0x2f, 0x4d, 0x68, 0x05, 0x0f, 0xbd, 0x75, 0x28, 0xc2, 0x82, 0x87, 0x65, 0x10, 0x0f, 0x82, 0x0c, + 0x99, 0x49, 0x76, 0x0c, 0x4e, 0x26, 0xdb, 0x24, 0xe3, 0x9f, 0x6f, 0xe0, 0xd1, 0x63, 0x8f, 0x3d, + 0xfa, 0x2d, 0xbc, 0xf6, 0xd8, 0xa3, 0x78, 0xa8, 0xb2, 0xfb, 0x45, 0x24, 0x99, 0x99, 0x8a, 0x0a, + 0x82, 0x3d, 0x4d, 0xe6, 0xe5, 0xc9, 0xef, 0x79, 0xde, 0xbc, 0x2f, 0x9c, 0x9a, 0x93, 0x86, 0x32, + 0x52, 0x89, 0x93, 0x46, 0xb0, 0x05, 0xd5, 0x52, 0xd4, 0x25, 0x79, 0xbb, 0x9f, 0x73, 0x4b, 0xf7, + 0xc9, 0x92, 0x6a, 0x2a, 0x0d, 0x5e, 0x6a, 0x65, 0x55, 0xf8, 0xc0, 0x2b, 0xf1, 0x6f, 0x4a, 0xdc, + 0x29, 0x77, 0x50, 0xa9, 0x54, 0x59, 0x71, 0xe2, 0xa5, 0x79, 0xb3, 0x20, 0xac, 0xd1, 0xd4, 0x0a, + 0x55, 0xb7, 0x97, 0x77, 0xee, 0x94, 0xaa, 0x54, 0xfe, 0x48, 0xdc, 0xa9, 0xab, 0xa2, 0x42, 0x19, + 0xa9, 0x0c, 0xc9, 0xa9, 0xe1, 0x57, 0xa6, 0x85, 0x12, 0xdd, 0xad, 0xdd, 0x2f, 0x00, 0x0e, 0xe7, + 0x3e, 0x43, 0x38, 0x87, 0xdb, 0xad, 0x73, 0xe6, 0xac, 0x4d, 0x04, 0x26, 0x9b, 0xd3, 0xf1, 0xc1, + 0x23, 0xfc, 0x8f, 0x50, 0xf8, 0x99, 0xaf, 0x3e, 0xa5, 0x5a, 0x26, 0x83, 0xf3, 0xcb, 0x38, 0x48, + 0xc7, 0xd5, 0x55, 0xc5, 0x84, 0xaf, 0x60, 0xa4, 0xf9, 0x3b, 0xaa, 0x99, 0xc9, 0x68, 0x53, 0xb8, + 0xac, 0x59, 0x1f, 0x3a, 0xda, 0x98, 0x80, 0xe9, 0xf8, 0xe0, 0x3e, 0x6e, 0xbb, 0xc2, 0x7d, 0x57, + 0xf8, 0xb8, 0x13, 0x24, 0x23, 0xc7, 0x3b, 0xfd, 0x1e, 0x83, 0xf4, 0x6e, 0x07, 0x39, 0x6a, 0x19, + 0xbd, 0xe2, 0x70, 0xf0, 0xf1, 0x2c, 0x0e, 0x76, 0x3f, 0x6f, 0x40, 0xf8, 0x2b, 0x46, 0x78, 0x0f, + 0x6e, 0x2d, 0x95, 0xaa, 0x32, 0xc1, 0x22, 0x30, 0x01, 0xd3, 0x41, 0x3a, 0x74, 0xbf, 0x33, 0x16, + 0xbe, 0x80, 0xb7, 0xa5, 0xa8, 0x7d, 0x6f, 0x19, 0x95, 0xaa, 0xa9, 0xad, 0xcf, 0x70, 0x23, 0xc1, + 0xce, 0xe8, 0xdb, 0x65, 0xfc, 0xb0, 0x14, 0xf6, 0x75, 0x93, 0xe3, 0x42, 0x49, 0xd2, 0xbd, 0x5a, + 0xfb, 0xd9, 0x33, 0xec, 0x0d, 0xb1, 0x1f, 0x96, 0xdc, 0xe0, 0x59, 0x6d, 0xd3, 0x9b, 0x52, 0xd4, + 0xce, 0xea, 0xc8, 0x43, 0xc2, 0xe7, 0xf0, 0x96, 0xe3, 0xe6, 0x82, 0xf5, 0xd8, 0xcd, 0x6b, 0x61, + 0xb7, 0xa5, 0xa8, 0x13, 0xc1, 0x3a, 0xea, 0x0c, 0x8e, 0x16, 0x9c, 0x67, 0x9a, 0x5a, 0x1e, 0x0d, + 0xfe, 0x9b, 0x77, 0xcc, 0x8b, 0x74, 0x6b, 0xc1, 0x79, 0x4a, 0x2d, 0x3f, 0x1c, 0xb9, 0x67, 0x3a, + 0x3d, 0x8b, 0x83, 0x64, 0x7e, 0xbe, 0x42, 0xe0, 0x62, 0x85, 0xc0, 0x8f, 0x15, 0x02, 0x9f, 0xd6, + 0x28, 0xb8, 0x58, 0xa3, 0xe0, 0xeb, 0x1a, 0x05, 0x2f, 0x9f, 0xfc, 0x05, 0x75, 0x43, 0xdf, 0xab, + 0x68, 0x6e, 0x48, 0xbb, 0xbe, 0xef, 0xff, 0x58, 0x60, 0x6f, 0x94, 0x0f, 0xfd, 0xdc, 0x1e, 0xff, + 0x0c, 0x00, 0x00, 0xff, 0xff, 0xeb, 0xc9, 0x01, 0xaf, 0xe4, 0x02, 0x00, 0x00, +} + +func (m *Params) 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 *Params) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + n1, err1 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.RewardsAuctionDuration, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.RewardsAuctionDuration):]) + if err1 != nil { + return 0, err1 + } + i -= n1 + i = encodeVarintParams(dAtA, i, uint64(n1)) + i-- + dAtA[i] = 0x12 + if len(m.LiquidFarms) > 0 { + for iNdEx := len(m.LiquidFarms) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.LiquidFarms[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *LiquidFarm) 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 *LiquidFarm) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *LiquidFarm) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.FeeRate.Size() + i -= size + if _, err := m.FeeRate.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + { + size := m.MinBidAmount.Size() + i -= size + if _, err := m.MinBidAmount.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + { + size := m.MinFarmAmount.Size() + i -= size + if _, err := m.MinFarmAmount.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if m.PoolId != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.PoolId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintParams(dAtA []byte, offset int, v uint64) int { + offset -= sovParams(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Params) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.LiquidFarms) > 0 { + for _, e := range m.LiquidFarms { + l = e.Size() + n += 1 + l + sovParams(uint64(l)) + } + } + l = github_com_gogo_protobuf_types.SizeOfStdDuration(m.RewardsAuctionDuration) + n += 1 + l + sovParams(uint64(l)) + return n +} + +func (m *LiquidFarm) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PoolId != 0 { + n += 1 + sovParams(uint64(m.PoolId)) + } + l = m.MinFarmAmount.Size() + n += 1 + l + sovParams(uint64(l)) + l = m.MinBidAmount.Size() + n += 1 + l + sovParams(uint64(l)) + l = m.FeeRate.Size() + n += 1 + l + sovParams(uint64(l)) + return n +} + +func sovParams(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozParams(x uint64) (n int) { + return sovParams(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Params) 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: Params: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field LiquidFarms", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.LiquidFarms = append(m.LiquidFarms, LiquidFarm{}) + if err := m.LiquidFarms[len(m.LiquidFarms)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RewardsAuctionDuration", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_gogo_protobuf_types.StdDurationUnmarshal(&m.RewardsAuctionDuration, 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 (m *LiquidFarm) 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: LiquidFarm: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: LiquidFarm: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PoolId", wireType) + } + m.PoolId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PoolId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MinFarmAmount", 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.MinFarmAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MinBidAmount", 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.MinBidAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FeeRate", 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.FeeRate.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 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowParams + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowParams + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowParams + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthParams + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupParams + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthParams + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthParams = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowParams = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupParams = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/liquidfarming/types/params_test.go b/x/liquidfarming/types/params_test.go new file mode 100644 index 00000000..3ca916ae --- /dev/null +++ b/x/liquidfarming/types/params_test.go @@ -0,0 +1,38 @@ +package types_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + + paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" + + "github.com/cosmosquad-labs/squad/v3/x/liquidfarming/types" +) + +func TestParams_Validate(t *testing.T) { + require.IsType(t, paramstypes.KeyTable{}, types.ParamKeyTable()) + + for _, tc := range []struct { + name string + malleate func(*types.Params) + errStr string + }{ + { + "default params", + func(params *types.Params) {}, + "", + }, + } { + t.Run(tc.name, func(t *testing.T) { + params := types.DefaultParams() + tc.malleate(¶ms) + err := params.Validate() + if tc.errStr == "" { + require.NoError(t, err) + } else { + require.EqualError(t, err, tc.errStr) + } + }) + } +} diff --git a/x/liquidfarming/types/query.pb.go b/x/liquidfarming/types/query.pb.go new file mode 100644 index 00000000..5fd73212 --- /dev/null +++ b/x/liquidfarming/types/query.pb.go @@ -0,0 +1,3862 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: squad/liquidfarming/v1beta1/query.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + query "github.com/cosmos/cosmos-sdk/types/query" + _ "github.com/gogo/protobuf/gogoproto" + grpc1 "github.com/gogo/protobuf/grpc" + proto "github.com/gogo/protobuf/proto" + _ "google.golang.org/genproto/googleapis/api/annotations" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// QueryLiquidFarmsRequest is the request type for the Query/LiquidFarms RPC method. +type QueryLiquidFarmsRequest struct { + Pagination *query.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryLiquidFarmsRequest) Reset() { *m = QueryLiquidFarmsRequest{} } +func (m *QueryLiquidFarmsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryLiquidFarmsRequest) ProtoMessage() {} +func (*QueryLiquidFarmsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_9d6573e06fd69a92, []int{0} +} +func (m *QueryLiquidFarmsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryLiquidFarmsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryLiquidFarmsRequest.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 *QueryLiquidFarmsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryLiquidFarmsRequest.Merge(m, src) +} +func (m *QueryLiquidFarmsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryLiquidFarmsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryLiquidFarmsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryLiquidFarmsRequest proto.InternalMessageInfo + +func (m *QueryLiquidFarmsRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination + } + return nil +} + +// QueryLiquidFarmsResponse is response type for the Query/LiquidFarms RPC method. +type QueryLiquidFarmsResponse struct { + LiquidFarms []LiquidFarmResponse `protobuf:"bytes,1,rep,name=liquid_farms,json=liquidFarms,proto3" json:"liquid_farms"` +} + +func (m *QueryLiquidFarmsResponse) Reset() { *m = QueryLiquidFarmsResponse{} } +func (m *QueryLiquidFarmsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryLiquidFarmsResponse) ProtoMessage() {} +func (*QueryLiquidFarmsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_9d6573e06fd69a92, []int{1} +} +func (m *QueryLiquidFarmsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryLiquidFarmsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryLiquidFarmsResponse.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 *QueryLiquidFarmsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryLiquidFarmsResponse.Merge(m, src) +} +func (m *QueryLiquidFarmsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryLiquidFarmsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryLiquidFarmsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryLiquidFarmsResponse proto.InternalMessageInfo + +func (m *QueryLiquidFarmsResponse) GetLiquidFarms() []LiquidFarmResponse { + if m != nil { + return m.LiquidFarms + } + return nil +} + +// QueryLiquidFarmRequest is the request type for the Query/LiquidFarm RPC method. +type QueryLiquidFarmRequest struct { + PoolId uint64 `protobuf:"varint,1,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty"` +} + +func (m *QueryLiquidFarmRequest) Reset() { *m = QueryLiquidFarmRequest{} } +func (m *QueryLiquidFarmRequest) String() string { return proto.CompactTextString(m) } +func (*QueryLiquidFarmRequest) ProtoMessage() {} +func (*QueryLiquidFarmRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_9d6573e06fd69a92, []int{2} +} +func (m *QueryLiquidFarmRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryLiquidFarmRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryLiquidFarmRequest.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 *QueryLiquidFarmRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryLiquidFarmRequest.Merge(m, src) +} +func (m *QueryLiquidFarmRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryLiquidFarmRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryLiquidFarmRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryLiquidFarmRequest proto.InternalMessageInfo + +func (m *QueryLiquidFarmRequest) GetPoolId() uint64 { + if m != nil { + return m.PoolId + } + return 0 +} + +// QueryLiquidFarmResponse is response type for the Query/LiquidFarm RPC method. +type QueryLiquidFarmResponse struct { + LiquidFarm LiquidFarmResponse `protobuf:"bytes,1,opt,name=liquid_farm,json=liquidFarm,proto3" json:"liquid_farm"` +} + +func (m *QueryLiquidFarmResponse) Reset() { *m = QueryLiquidFarmResponse{} } +func (m *QueryLiquidFarmResponse) String() string { return proto.CompactTextString(m) } +func (*QueryLiquidFarmResponse) ProtoMessage() {} +func (*QueryLiquidFarmResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_9d6573e06fd69a92, []int{3} +} +func (m *QueryLiquidFarmResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryLiquidFarmResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryLiquidFarmResponse.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 *QueryLiquidFarmResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryLiquidFarmResponse.Merge(m, src) +} +func (m *QueryLiquidFarmResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryLiquidFarmResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryLiquidFarmResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryLiquidFarmResponse proto.InternalMessageInfo + +func (m *QueryLiquidFarmResponse) GetLiquidFarm() LiquidFarmResponse { + if m != nil { + return m.LiquidFarm + } + return LiquidFarmResponse{} +} + +// QueryParamsRequest is request type for the Query/Params RPC method. +type QueryParamsRequest struct { +} + +func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} } +func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryParamsRequest) ProtoMessage() {} +func (*QueryParamsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_9d6573e06fd69a92, []int{4} +} +func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsRequest.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 *QueryParamsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsRequest.Merge(m, src) +} +func (m *QueryParamsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsRequest proto.InternalMessageInfo + +// QueryParamsResponse is response type for the Query/Params RPC method. +type QueryParamsResponse struct { + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` +} + +func (m *QueryParamsResponse) Reset() { *m = QueryParamsResponse{} } +func (m *QueryParamsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryParamsResponse) ProtoMessage() {} +func (*QueryParamsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_9d6573e06fd69a92, []int{5} +} +func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsResponse.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 *QueryParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsResponse.Merge(m, src) +} +func (m *QueryParamsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsResponse proto.InternalMessageInfo + +func (m *QueryParamsResponse) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +// QueryRewardsAuctionsRequest is request type for the Query/RewardsAuctions RPC method. +type QueryRewardsAuctionsRequest struct { + PoolId uint64 `protobuf:"varint,1,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty"` + Pagination *query.PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryRewardsAuctionsRequest) Reset() { *m = QueryRewardsAuctionsRequest{} } +func (m *QueryRewardsAuctionsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryRewardsAuctionsRequest) ProtoMessage() {} +func (*QueryRewardsAuctionsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_9d6573e06fd69a92, []int{6} +} +func (m *QueryRewardsAuctionsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryRewardsAuctionsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryRewardsAuctionsRequest.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 *QueryRewardsAuctionsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryRewardsAuctionsRequest.Merge(m, src) +} +func (m *QueryRewardsAuctionsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryRewardsAuctionsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryRewardsAuctionsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryRewardsAuctionsRequest proto.InternalMessageInfo + +func (m *QueryRewardsAuctionsRequest) GetPoolId() uint64 { + if m != nil { + return m.PoolId + } + return 0 +} + +func (m *QueryRewardsAuctionsRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination + } + return nil +} + +// QueryRewardsAuctionsResponse is response type for the Query/RewardsAuctions RPC method. +type QueryRewardsAuctionsResponse struct { + RewardAuctions []RewardsAuction `protobuf:"bytes,1,rep,name=reward_auctions,json=rewardAuctions,proto3" json:"reward_auctions"` + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryRewardsAuctionsResponse) Reset() { *m = QueryRewardsAuctionsResponse{} } +func (m *QueryRewardsAuctionsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryRewardsAuctionsResponse) ProtoMessage() {} +func (*QueryRewardsAuctionsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_9d6573e06fd69a92, []int{7} +} +func (m *QueryRewardsAuctionsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryRewardsAuctionsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryRewardsAuctionsResponse.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 *QueryRewardsAuctionsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryRewardsAuctionsResponse.Merge(m, src) +} +func (m *QueryRewardsAuctionsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryRewardsAuctionsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryRewardsAuctionsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryRewardsAuctionsResponse proto.InternalMessageInfo + +func (m *QueryRewardsAuctionsResponse) GetRewardAuctions() []RewardsAuction { + if m != nil { + return m.RewardAuctions + } + return nil +} + +func (m *QueryRewardsAuctionsResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination + } + return nil +} + +// QueryRewardsAuctionRequest is request type for the Query/RewardsAuction RPC method. +type QueryRewardsAuctionRequest struct { + AuctionId uint64 `protobuf:"varint,1,opt,name=auction_id,json=auctionId,proto3" json:"auction_id,omitempty"` + PoolId uint64 `protobuf:"varint,2,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty"` +} + +func (m *QueryRewardsAuctionRequest) Reset() { *m = QueryRewardsAuctionRequest{} } +func (m *QueryRewardsAuctionRequest) String() string { return proto.CompactTextString(m) } +func (*QueryRewardsAuctionRequest) ProtoMessage() {} +func (*QueryRewardsAuctionRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_9d6573e06fd69a92, []int{8} +} +func (m *QueryRewardsAuctionRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryRewardsAuctionRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryRewardsAuctionRequest.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 *QueryRewardsAuctionRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryRewardsAuctionRequest.Merge(m, src) +} +func (m *QueryRewardsAuctionRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryRewardsAuctionRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryRewardsAuctionRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryRewardsAuctionRequest proto.InternalMessageInfo + +func (m *QueryRewardsAuctionRequest) GetAuctionId() uint64 { + if m != nil { + return m.AuctionId + } + return 0 +} + +func (m *QueryRewardsAuctionRequest) GetPoolId() uint64 { + if m != nil { + return m.PoolId + } + return 0 +} + +// QueryRewardsAuctionResponse is response type for the Query/RewardsAuction RPC method. +type QueryRewardsAuctionResponse struct { + RewardAuction RewardsAuction `protobuf:"bytes,1,opt,name=reward_auction,json=rewardAuction,proto3" json:"reward_auction"` +} + +func (m *QueryRewardsAuctionResponse) Reset() { *m = QueryRewardsAuctionResponse{} } +func (m *QueryRewardsAuctionResponse) String() string { return proto.CompactTextString(m) } +func (*QueryRewardsAuctionResponse) ProtoMessage() {} +func (*QueryRewardsAuctionResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_9d6573e06fd69a92, []int{9} +} +func (m *QueryRewardsAuctionResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryRewardsAuctionResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryRewardsAuctionResponse.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 *QueryRewardsAuctionResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryRewardsAuctionResponse.Merge(m, src) +} +func (m *QueryRewardsAuctionResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryRewardsAuctionResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryRewardsAuctionResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryRewardsAuctionResponse proto.InternalMessageInfo + +func (m *QueryRewardsAuctionResponse) GetRewardAuction() RewardsAuction { + if m != nil { + return m.RewardAuction + } + return RewardsAuction{} +} + +// QueryBidsRequest is request type for the Query/Bids RPC method. +type QueryBidsRequest struct { + PoolId uint64 `protobuf:"varint,1,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty"` + Pagination *query.PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryBidsRequest) Reset() { *m = QueryBidsRequest{} } +func (m *QueryBidsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryBidsRequest) ProtoMessage() {} +func (*QueryBidsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_9d6573e06fd69a92, []int{10} +} +func (m *QueryBidsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryBidsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryBidsRequest.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 *QueryBidsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryBidsRequest.Merge(m, src) +} +func (m *QueryBidsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryBidsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryBidsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryBidsRequest proto.InternalMessageInfo + +func (m *QueryBidsRequest) GetPoolId() uint64 { + if m != nil { + return m.PoolId + } + return 0 +} + +func (m *QueryBidsRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination + } + return nil +} + +// QueryBidsResponse is response type for the Query/Bids RPC method. +type QueryBidsResponse struct { + Bids []Bid `protobuf:"bytes,1,rep,name=bids,proto3" json:"bids"` + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryBidsResponse) Reset() { *m = QueryBidsResponse{} } +func (m *QueryBidsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryBidsResponse) ProtoMessage() {} +func (*QueryBidsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_9d6573e06fd69a92, []int{11} +} +func (m *QueryBidsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryBidsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryBidsResponse.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 *QueryBidsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryBidsResponse.Merge(m, src) +} +func (m *QueryBidsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryBidsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryBidsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryBidsResponse proto.InternalMessageInfo + +func (m *QueryBidsResponse) GetBids() []Bid { + if m != nil { + return m.Bids + } + return nil +} + +func (m *QueryBidsResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination + } + return nil +} + +// QueryMintRateRequest is request type for the Query/MintRate RPC method. +type QueryMintRateRequest struct { + PoolId uint64 `protobuf:"varint,1,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty"` +} + +func (m *QueryMintRateRequest) Reset() { *m = QueryMintRateRequest{} } +func (m *QueryMintRateRequest) String() string { return proto.CompactTextString(m) } +func (*QueryMintRateRequest) ProtoMessage() {} +func (*QueryMintRateRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_9d6573e06fd69a92, []int{12} +} +func (m *QueryMintRateRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryMintRateRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryMintRateRequest.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 *QueryMintRateRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryMintRateRequest.Merge(m, src) +} +func (m *QueryMintRateRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryMintRateRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryMintRateRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryMintRateRequest proto.InternalMessageInfo + +func (m *QueryMintRateRequest) GetPoolId() uint64 { + if m != nil { + return m.PoolId + } + return 0 +} + +// QueryMintRateResponse is response type for the Query/MintRate RPC method. +type QueryMintRateResponse struct { + MintRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,1,opt,name=mint_rate,json=mintRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"mint_rate"` +} + +func (m *QueryMintRateResponse) Reset() { *m = QueryMintRateResponse{} } +func (m *QueryMintRateResponse) String() string { return proto.CompactTextString(m) } +func (*QueryMintRateResponse) ProtoMessage() {} +func (*QueryMintRateResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_9d6573e06fd69a92, []int{13} +} +func (m *QueryMintRateResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryMintRateResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryMintRateResponse.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 *QueryMintRateResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryMintRateResponse.Merge(m, src) +} +func (m *QueryMintRateResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryMintRateResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryMintRateResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryMintRateResponse proto.InternalMessageInfo + +// QueryBurnRateRequest is request type for the Query/BurnRate RPC method. +type QueryBurnRateRequest struct { + PoolId uint64 `protobuf:"varint,1,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty"` +} + +func (m *QueryBurnRateRequest) Reset() { *m = QueryBurnRateRequest{} } +func (m *QueryBurnRateRequest) String() string { return proto.CompactTextString(m) } +func (*QueryBurnRateRequest) ProtoMessage() {} +func (*QueryBurnRateRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_9d6573e06fd69a92, []int{14} +} +func (m *QueryBurnRateRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryBurnRateRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryBurnRateRequest.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 *QueryBurnRateRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryBurnRateRequest.Merge(m, src) +} +func (m *QueryBurnRateRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryBurnRateRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryBurnRateRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryBurnRateRequest proto.InternalMessageInfo + +func (m *QueryBurnRateRequest) GetPoolId() uint64 { + if m != nil { + return m.PoolId + } + return 0 +} + +// QueryBurnRateResponse is response type for the Query/BurnRate RPC method. +type QueryBurnRateResponse struct { + BurnRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,1,opt,name=burn_rate,json=burnRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"burn_rate"` +} + +func (m *QueryBurnRateResponse) Reset() { *m = QueryBurnRateResponse{} } +func (m *QueryBurnRateResponse) String() string { return proto.CompactTextString(m) } +func (*QueryBurnRateResponse) ProtoMessage() {} +func (*QueryBurnRateResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_9d6573e06fd69a92, []int{15} +} +func (m *QueryBurnRateResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryBurnRateResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryBurnRateResponse.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 *QueryBurnRateResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryBurnRateResponse.Merge(m, src) +} +func (m *QueryBurnRateResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryBurnRateResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryBurnRateResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryBurnRateResponse proto.InternalMessageInfo + +// LiquidFarmResponse is response type for the Query/LiquidFarm RPC method. +type LiquidFarmResponse struct { + PoolId uint64 `protobuf:"varint,1,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty"` + LiquidFarmReserveAddress string `protobuf:"bytes,2,opt,name=liquid_farm_reserve_address,json=liquidFarmReserveAddress,proto3" json:"liquid_farm_reserve_address,omitempty"` + LFCoinDenom string `protobuf:"bytes,3,opt,name=lf_coin_denom,json=lfCoinDenom,proto3" json:"lf_coin_denom,omitempty"` + MinFarmAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,4,opt,name=min_farm_amount,json=minFarmAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"min_farm_amount"` + MinBidAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,5,opt,name=min_bid_amount,json=minBidAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"min_bid_amount"` + TotalFarmingAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,6,opt,name=total_farming_amount,json=totalFarmingAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"total_farming_amount"` +} + +func (m *LiquidFarmResponse) Reset() { *m = LiquidFarmResponse{} } +func (m *LiquidFarmResponse) String() string { return proto.CompactTextString(m) } +func (*LiquidFarmResponse) ProtoMessage() {} +func (*LiquidFarmResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_9d6573e06fd69a92, []int{16} +} +func (m *LiquidFarmResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *LiquidFarmResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_LiquidFarmResponse.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 *LiquidFarmResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_LiquidFarmResponse.Merge(m, src) +} +func (m *LiquidFarmResponse) XXX_Size() int { + return m.Size() +} +func (m *LiquidFarmResponse) XXX_DiscardUnknown() { + xxx_messageInfo_LiquidFarmResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_LiquidFarmResponse proto.InternalMessageInfo + +func (m *LiquidFarmResponse) GetPoolId() uint64 { + if m != nil { + return m.PoolId + } + return 0 +} + +func (m *LiquidFarmResponse) GetLiquidFarmReserveAddress() string { + if m != nil { + return m.LiquidFarmReserveAddress + } + return "" +} + +func (m *LiquidFarmResponse) GetLFCoinDenom() string { + if m != nil { + return m.LFCoinDenom + } + return "" +} + +func init() { + proto.RegisterType((*QueryLiquidFarmsRequest)(nil), "squad.liquidfarming.v1beta1.QueryLiquidFarmsRequest") + proto.RegisterType((*QueryLiquidFarmsResponse)(nil), "squad.liquidfarming.v1beta1.QueryLiquidFarmsResponse") + proto.RegisterType((*QueryLiquidFarmRequest)(nil), "squad.liquidfarming.v1beta1.QueryLiquidFarmRequest") + proto.RegisterType((*QueryLiquidFarmResponse)(nil), "squad.liquidfarming.v1beta1.QueryLiquidFarmResponse") + proto.RegisterType((*QueryParamsRequest)(nil), "squad.liquidfarming.v1beta1.QueryParamsRequest") + proto.RegisterType((*QueryParamsResponse)(nil), "squad.liquidfarming.v1beta1.QueryParamsResponse") + proto.RegisterType((*QueryRewardsAuctionsRequest)(nil), "squad.liquidfarming.v1beta1.QueryRewardsAuctionsRequest") + proto.RegisterType((*QueryRewardsAuctionsResponse)(nil), "squad.liquidfarming.v1beta1.QueryRewardsAuctionsResponse") + proto.RegisterType((*QueryRewardsAuctionRequest)(nil), "squad.liquidfarming.v1beta1.QueryRewardsAuctionRequest") + proto.RegisterType((*QueryRewardsAuctionResponse)(nil), "squad.liquidfarming.v1beta1.QueryRewardsAuctionResponse") + proto.RegisterType((*QueryBidsRequest)(nil), "squad.liquidfarming.v1beta1.QueryBidsRequest") + proto.RegisterType((*QueryBidsResponse)(nil), "squad.liquidfarming.v1beta1.QueryBidsResponse") + proto.RegisterType((*QueryMintRateRequest)(nil), "squad.liquidfarming.v1beta1.QueryMintRateRequest") + proto.RegisterType((*QueryMintRateResponse)(nil), "squad.liquidfarming.v1beta1.QueryMintRateResponse") + proto.RegisterType((*QueryBurnRateRequest)(nil), "squad.liquidfarming.v1beta1.QueryBurnRateRequest") + proto.RegisterType((*QueryBurnRateResponse)(nil), "squad.liquidfarming.v1beta1.QueryBurnRateResponse") + proto.RegisterType((*LiquidFarmResponse)(nil), "squad.liquidfarming.v1beta1.LiquidFarmResponse") +} + +func init() { + proto.RegisterFile("squad/liquidfarming/v1beta1/query.proto", fileDescriptor_9d6573e06fd69a92) +} + +var fileDescriptor_9d6573e06fd69a92 = []byte{ + // 1055 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x97, 0x41, 0x6f, 0x1b, 0x45, + 0x14, 0xc7, 0xb3, 0x49, 0x6a, 0x9a, 0xe7, 0x26, 0x81, 0x21, 0x50, 0xcb, 0x29, 0x4e, 0xb4, 0x15, + 0x6d, 0xd4, 0x2a, 0xbb, 0xb5, 0x13, 0x4a, 0x5a, 0xa9, 0xa0, 0x98, 0x12, 0x14, 0x08, 0x52, 0x58, + 0x55, 0x55, 0xd5, 0x8b, 0x19, 0x7b, 0x27, 0x66, 0xc4, 0xee, 0x8e, 0xbd, 0xb3, 0xdb, 0x52, 0x55, + 0xe5, 0xc0, 0x27, 0x40, 0xe2, 0xd2, 0x23, 0x1f, 0x80, 0x4b, 0xc5, 0x95, 0x1b, 0x97, 0x5e, 0x90, + 0x2a, 0x71, 0x00, 0x71, 0x88, 0x50, 0xc2, 0x07, 0x41, 0x3b, 0x33, 0xeb, 0xdd, 0xb5, 0x8d, 0xed, + 0x75, 0x51, 0x4f, 0xb1, 0x77, 0xe6, 0xfd, 0xdf, 0xef, 0xff, 0xe6, 0x79, 0xdf, 0x04, 0x2e, 0xf3, + 0x6e, 0x88, 0x6d, 0xd3, 0xa1, 0xdd, 0x90, 0xda, 0x47, 0xd8, 0x77, 0xa9, 0xd7, 0x36, 0x1f, 0x54, + 0x9b, 0x24, 0xc0, 0x55, 0xb3, 0x1b, 0x12, 0xff, 0x91, 0xd1, 0xf1, 0x59, 0xc0, 0xd0, 0xaa, 0xd8, + 0x68, 0x64, 0x36, 0x1a, 0x6a, 0x63, 0xf9, 0x4a, 0x8b, 0x71, 0x97, 0x71, 0xb3, 0x89, 0x39, 0x91, + 0x51, 0x3d, 0x8d, 0x0e, 0x6e, 0x53, 0x0f, 0x07, 0x94, 0x79, 0x52, 0xa8, 0x5c, 0x49, 0xef, 0x8d, + 0x77, 0xb5, 0x18, 0x8d, 0xd7, 0x57, 0xda, 0xac, 0xcd, 0xc4, 0x47, 0x33, 0xfa, 0xa4, 0x9e, 0x5e, + 0x68, 0x33, 0xd6, 0x76, 0x88, 0x89, 0x3b, 0xd4, 0xc4, 0x9e, 0xc7, 0x02, 0x21, 0xc9, 0xd5, 0xaa, + 0x39, 0xca, 0x45, 0x16, 0x59, 0x06, 0x6c, 0x8c, 0x0a, 0xe8, 0x60, 0x1f, 0xbb, 0x4a, 0x5a, 0xc7, + 0x70, 0xfe, 0x8b, 0xc8, 0xd0, 0x81, 0xd8, 0xba, 0x87, 0x7d, 0x97, 0x5b, 0xa4, 0x1b, 0x12, 0x1e, + 0xa0, 0x3d, 0x80, 0xc4, 0x5d, 0x49, 0x5b, 0xd7, 0x36, 0x8a, 0xb5, 0x4b, 0x86, 0xb4, 0x67, 0x44, + 0xf6, 0x0c, 0x59, 0x40, 0xa5, 0x6b, 0x1c, 0xe2, 0x36, 0x51, 0xb1, 0x56, 0x2a, 0x52, 0x0f, 0xa0, + 0x34, 0x98, 0x82, 0x77, 0x98, 0xc7, 0x09, 0xba, 0x07, 0xe7, 0x24, 0x64, 0x23, 0xa2, 0xe4, 0x25, + 0x6d, 0x7d, 0x6e, 0xa3, 0x58, 0x33, 0x8d, 0x11, 0xa7, 0x61, 0x24, 0x3a, 0xb1, 0x4c, 0x7d, 0xfe, + 0xf9, 0xf1, 0xda, 0x8c, 0x55, 0x74, 0x92, 0x0c, 0x7a, 0x15, 0xde, 0xee, 0xcb, 0x1a, 0xfb, 0x3a, + 0x0f, 0xaf, 0x75, 0x18, 0x73, 0x1a, 0xd4, 0x16, 0xa6, 0xe6, 0xad, 0x42, 0xf4, 0x75, 0xdf, 0xd6, + 0xbb, 0x03, 0xb5, 0xe8, 0x71, 0xde, 0x85, 0x62, 0x8a, 0x53, 0x15, 0x63, 0x4a, 0x4c, 0x48, 0x30, + 0xf5, 0x15, 0x40, 0x22, 0xe5, 0xa1, 0x38, 0x13, 0x45, 0xa8, 0xdf, 0x83, 0x37, 0x33, 0x4f, 0x15, + 0xc4, 0x2e, 0x14, 0xe4, 0xd9, 0xa9, 0xfc, 0x17, 0x47, 0xe6, 0x97, 0xc1, 0x2a, 0xa7, 0x0a, 0xd4, + 0xbf, 0x85, 0x55, 0xa1, 0x6c, 0x91, 0x87, 0xd8, 0xb7, 0xf9, 0x6e, 0xd8, 0x12, 0x7d, 0x36, 0xae, + 0x34, 0x7d, 0xbd, 0x30, 0x3b, 0x75, 0x2f, 0xfc, 0xaa, 0xc1, 0x85, 0xe1, 0x00, 0xca, 0xe3, 0x7d, + 0x58, 0xf6, 0xc5, 0x52, 0x03, 0xab, 0x25, 0xd5, 0x13, 0x57, 0x47, 0x9a, 0xcd, 0xca, 0x29, 0xd3, + 0x4b, 0x52, 0x29, 0xce, 0x81, 0x3e, 0x19, 0x62, 0xe2, 0xf2, 0x58, 0x13, 0x12, 0x2c, 0xe3, 0xe2, + 0x0e, 0x94, 0x87, 0x98, 0x88, 0x8b, 0xf8, 0x0e, 0x80, 0x62, 0x4f, 0xea, 0xb8, 0xa0, 0x9e, 0xec, + 0xdb, 0xe9, 0x1a, 0xcf, 0x66, 0xda, 0xef, 0xe1, 0xd0, 0xb3, 0x49, 0xfd, 0x54, 0x96, 0xb2, 0x95, + 0x51, 0x5d, 0x30, 0x45, 0x61, 0x16, 0x33, 0x85, 0xd1, 0x39, 0xbc, 0x2e, 0x12, 0xd7, 0xa9, 0xfd, + 0xea, 0x3a, 0xe1, 0xa9, 0x06, 0x6f, 0xa4, 0xb2, 0x2a, 0x93, 0x37, 0x61, 0xbe, 0x49, 0xed, 0xf8, + 0xcc, 0xd7, 0x47, 0x5a, 0xab, 0x53, 0x5b, 0xf9, 0x11, 0x31, 0xff, 0xdf, 0xf1, 0x9a, 0xb0, 0x22, + 0xc8, 0x3e, 0xa7, 0x5e, 0x60, 0xe1, 0x80, 0x8c, 0x7d, 0x71, 0xd8, 0xf0, 0x56, 0x5f, 0x80, 0xb2, + 0xf3, 0x19, 0x2c, 0xb8, 0xd4, 0x0b, 0x1a, 0x3e, 0x0e, 0x88, 0x88, 0x59, 0xa8, 0x1b, 0x11, 0xf1, + 0x5f, 0xc7, 0x6b, 0x97, 0xda, 0x34, 0xf8, 0x2a, 0x6c, 0x1a, 0x2d, 0xe6, 0x9a, 0x6a, 0x64, 0xc8, + 0x3f, 0x9b, 0xdc, 0xfe, 0xda, 0x0c, 0x1e, 0x75, 0x08, 0x37, 0x6e, 0x93, 0x96, 0x75, 0xd6, 0x55, + 0xa2, 0x3d, 0xac, 0x7a, 0xe8, 0x7b, 0xb9, 0xb0, 0x92, 0x80, 0x04, 0xab, 0x19, 0xfa, 0xde, 0x4b, + 0x61, 0x35, 0x95, 0xa8, 0xfe, 0x6c, 0x0e, 0xd0, 0x90, 0x37, 0xe6, 0x7f, 0x36, 0xd0, 0x2d, 0x58, + 0x4d, 0xbd, 0x4a, 0x1b, 0x3e, 0xe1, 0xc4, 0x7f, 0x40, 0x1a, 0xd8, 0xb6, 0x7d, 0xc2, 0xb9, 0x38, + 0xb7, 0x05, 0xab, 0xe4, 0xa4, 0x15, 0xa3, 0x0d, 0xbb, 0x72, 0x1d, 0x6d, 0xc1, 0xa2, 0x73, 0xd4, + 0x88, 0x06, 0x6a, 0xc3, 0x26, 0x1e, 0x73, 0x4b, 0x73, 0x82, 0x7f, 0xf9, 0xe4, 0x78, 0xad, 0x78, + 0xb0, 0xf7, 0x11, 0xa3, 0xde, 0xed, 0xe8, 0xb1, 0x55, 0x74, 0x8e, 0x7a, 0x5f, 0xd0, 0x5d, 0x58, + 0x76, 0xa9, 0x27, 0x13, 0x62, 0x97, 0x85, 0x5e, 0x50, 0x9a, 0xcf, 0x6d, 0x7b, 0xdf, 0x0b, 0xac, + 0x45, 0x97, 0x7a, 0x11, 0xd4, 0xae, 0x10, 0x41, 0x77, 0x60, 0x29, 0xd2, 0x6d, 0x52, 0x3b, 0x96, + 0x3d, 0x33, 0x95, 0xec, 0x39, 0x97, 0x7a, 0x75, 0x6a, 0x2b, 0xd5, 0x2f, 0x61, 0x25, 0x60, 0x01, + 0x76, 0x1a, 0xaa, 0xe3, 0x63, 0xed, 0xc2, 0x54, 0xda, 0x48, 0x68, 0xed, 0x49, 0x29, 0x99, 0xa1, + 0xf6, 0x4b, 0x11, 0xce, 0x88, 0xd6, 0x40, 0x4f, 0x35, 0x28, 0xc8, 0x49, 0x81, 0x46, 0x8f, 0xb3, + 0xc1, 0x31, 0x55, 0xbe, 0x36, 0x79, 0x80, 0x6c, 0x0a, 0xfd, 0xea, 0x77, 0xbf, 0xff, 0xf3, 0xc3, + 0xec, 0xbb, 0xe8, 0xa2, 0x39, 0xfe, 0x82, 0x82, 0x7e, 0xd2, 0xa0, 0x98, 0xba, 0x33, 0xa0, 0xed, + 0xf1, 0xe9, 0x06, 0x6f, 0x31, 0xe5, 0xf7, 0x72, 0x46, 0x29, 0xd2, 0x6b, 0x82, 0xf4, 0x0a, 0xda, + 0x98, 0xf0, 0xee, 0xc5, 0xd1, 0xcf, 0x1a, 0x40, 0xa2, 0x84, 0xb6, 0xf2, 0xe4, 0x8d, 0x61, 0xb7, + 0xf3, 0x05, 0x29, 0xd6, 0x9b, 0x82, 0x75, 0x1b, 0xd5, 0x26, 0x65, 0x35, 0x1f, 0xab, 0x9f, 0xe6, + 0x13, 0xf4, 0x9b, 0x06, 0xcb, 0x7d, 0xb3, 0x18, 0xed, 0x8c, 0xa7, 0x18, 0x7e, 0x7f, 0x28, 0xdf, + 0x98, 0x22, 0x52, 0x99, 0xf8, 0x58, 0x98, 0xf8, 0x10, 0xdd, 0x1a, 0xdd, 0x1a, 0x8c, 0x39, 0x29, + 0x7c, 0x53, 0x0e, 0x32, 0xde, 0xbb, 0x2c, 0xa0, 0x3f, 0x34, 0x58, 0xca, 0xa6, 0x40, 0xef, 0xe7, + 0x85, 0x8a, 0xdd, 0xec, 0xe4, 0x0f, 0x54, 0x66, 0x2c, 0x61, 0xe6, 0x00, 0x7d, 0xfa, 0x52, 0x66, + 0xcc, 0xc7, 0xc9, 0x3d, 0xe2, 0x09, 0xfa, 0x51, 0x83, 0xf9, 0x68, 0x56, 0xa2, 0xcd, 0xf1, 0x58, + 0xa9, 0x49, 0x5e, 0x36, 0x26, 0xdd, 0xae, 0xd8, 0x6f, 0x08, 0xf6, 0x2d, 0x54, 0xcd, 0xc5, 0x2e, + 0x26, 0xf0, 0x33, 0x0d, 0xce, 0xc6, 0x33, 0x10, 0x55, 0xc7, 0xe7, 0xed, 0x1b, 0xb0, 0xe5, 0x5a, + 0x9e, 0x10, 0x85, 0xfb, 0x81, 0xc0, 0xdd, 0x41, 0xd7, 0x73, 0xe1, 0xf6, 0xa6, 0xb2, 0x60, 0x8e, + 0x07, 0xe4, 0x24, 0xcc, 0x7d, 0xd3, 0x77, 0x12, 0xe6, 0xfe, 0xf9, 0x3b, 0x25, 0x73, 0x6f, 0x64, + 0xd7, 0x0f, 0x9f, 0x9f, 0x54, 0xb4, 0x17, 0x27, 0x15, 0xed, 0xef, 0x93, 0x8a, 0xf6, 0xfd, 0x69, + 0x65, 0xe6, 0xc5, 0x69, 0x65, 0xe6, 0xcf, 0xd3, 0xca, 0xcc, 0xfd, 0xeb, 0x03, 0x43, 0x21, 0x4a, + 0xb0, 0xe9, 0xe0, 0x26, 0x57, 0xb9, 0xbe, 0xe9, 0xcb, 0x26, 0x06, 0x45, 0xb3, 0x20, 0xfe, 0x1b, + 0xdc, 0xfa, 0x37, 0x00, 0x00, 0xff, 0xff, 0xc2, 0x20, 0x1a, 0xaa, 0x30, 0x0f, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// QueryClient is the client API for Query service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type QueryClient interface { + // Params returns parameters of the module + Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) + // LiquidFarms returns all liquid farms registered in params + LiquidFarms(ctx context.Context, in *QueryLiquidFarmsRequest, opts ...grpc.CallOption) (*QueryLiquidFarmsResponse, error) + // LiquidFarm returns the specific liquid farm + LiquidFarm(ctx context.Context, in *QueryLiquidFarmRequest, opts ...grpc.CallOption) (*QueryLiquidFarmResponse, error) + // RewardsAuctions returns all rewards auctions + RewardsAuctions(ctx context.Context, in *QueryRewardsAuctionsRequest, opts ...grpc.CallOption) (*QueryRewardsAuctionsResponse, error) + // RewardsAuction returns the specific rewards auction + RewardsAuction(ctx context.Context, in *QueryRewardsAuctionRequest, opts ...grpc.CallOption) (*QueryRewardsAuctionResponse, error) + // Bids returns all bids for the liquid farm + Bids(ctx context.Context, in *QueryBidsRequest, opts ...grpc.CallOption) (*QueryBidsResponse, error) + // MintRate returns the current mint rate. + MintRate(ctx context.Context, in *QueryMintRateRequest, opts ...grpc.CallOption) (*QueryMintRateResponse, error) + // BurnRate returns the current burn rate. + BurnRate(ctx context.Context, in *QueryBurnRateRequest, opts ...grpc.CallOption) (*QueryBurnRateResponse, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { + out := new(QueryParamsResponse) + err := c.cc.Invoke(ctx, "/squad.liquidfarming.v1beta1.Query/Params", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) LiquidFarms(ctx context.Context, in *QueryLiquidFarmsRequest, opts ...grpc.CallOption) (*QueryLiquidFarmsResponse, error) { + out := new(QueryLiquidFarmsResponse) + err := c.cc.Invoke(ctx, "/squad.liquidfarming.v1beta1.Query/LiquidFarms", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) LiquidFarm(ctx context.Context, in *QueryLiquidFarmRequest, opts ...grpc.CallOption) (*QueryLiquidFarmResponse, error) { + out := new(QueryLiquidFarmResponse) + err := c.cc.Invoke(ctx, "/squad.liquidfarming.v1beta1.Query/LiquidFarm", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) RewardsAuctions(ctx context.Context, in *QueryRewardsAuctionsRequest, opts ...grpc.CallOption) (*QueryRewardsAuctionsResponse, error) { + out := new(QueryRewardsAuctionsResponse) + err := c.cc.Invoke(ctx, "/squad.liquidfarming.v1beta1.Query/RewardsAuctions", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) RewardsAuction(ctx context.Context, in *QueryRewardsAuctionRequest, opts ...grpc.CallOption) (*QueryRewardsAuctionResponse, error) { + out := new(QueryRewardsAuctionResponse) + err := c.cc.Invoke(ctx, "/squad.liquidfarming.v1beta1.Query/RewardsAuction", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) Bids(ctx context.Context, in *QueryBidsRequest, opts ...grpc.CallOption) (*QueryBidsResponse, error) { + out := new(QueryBidsResponse) + err := c.cc.Invoke(ctx, "/squad.liquidfarming.v1beta1.Query/Bids", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) MintRate(ctx context.Context, in *QueryMintRateRequest, opts ...grpc.CallOption) (*QueryMintRateResponse, error) { + out := new(QueryMintRateResponse) + err := c.cc.Invoke(ctx, "/squad.liquidfarming.v1beta1.Query/MintRate", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) BurnRate(ctx context.Context, in *QueryBurnRateRequest, opts ...grpc.CallOption) (*QueryBurnRateResponse, error) { + out := new(QueryBurnRateResponse) + err := c.cc.Invoke(ctx, "/squad.liquidfarming.v1beta1.Query/BurnRate", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + // Params returns parameters of the module + Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) + // LiquidFarms returns all liquid farms registered in params + LiquidFarms(context.Context, *QueryLiquidFarmsRequest) (*QueryLiquidFarmsResponse, error) + // LiquidFarm returns the specific liquid farm + LiquidFarm(context.Context, *QueryLiquidFarmRequest) (*QueryLiquidFarmResponse, error) + // RewardsAuctions returns all rewards auctions + RewardsAuctions(context.Context, *QueryRewardsAuctionsRequest) (*QueryRewardsAuctionsResponse, error) + // RewardsAuction returns the specific rewards auction + RewardsAuction(context.Context, *QueryRewardsAuctionRequest) (*QueryRewardsAuctionResponse, error) + // Bids returns all bids for the liquid farm + Bids(context.Context, *QueryBidsRequest) (*QueryBidsResponse, error) + // MintRate returns the current mint rate. + MintRate(context.Context, *QueryMintRateRequest) (*QueryMintRateResponse, error) + // BurnRate returns the current burn rate. + BurnRate(context.Context, *QueryBurnRateRequest) (*QueryBurnRateResponse, error) +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") +} +func (*UnimplementedQueryServer) LiquidFarms(ctx context.Context, req *QueryLiquidFarmsRequest) (*QueryLiquidFarmsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method LiquidFarms not implemented") +} +func (*UnimplementedQueryServer) LiquidFarm(ctx context.Context, req *QueryLiquidFarmRequest) (*QueryLiquidFarmResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method LiquidFarm not implemented") +} +func (*UnimplementedQueryServer) RewardsAuctions(ctx context.Context, req *QueryRewardsAuctionsRequest) (*QueryRewardsAuctionsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RewardsAuctions not implemented") +} +func (*UnimplementedQueryServer) RewardsAuction(ctx context.Context, req *QueryRewardsAuctionRequest) (*QueryRewardsAuctionResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RewardsAuction not implemented") +} +func (*UnimplementedQueryServer) Bids(ctx context.Context, req *QueryBidsRequest) (*QueryBidsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Bids not implemented") +} +func (*UnimplementedQueryServer) MintRate(ctx context.Context, req *QueryMintRateRequest) (*QueryMintRateResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method MintRate not implemented") +} +func (*UnimplementedQueryServer) BurnRate(ctx context.Context, req *QueryBurnRateRequest) (*QueryBurnRateResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method BurnRate not implemented") +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryParamsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Params(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/squad.liquidfarming.v1beta1.Query/Params", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_LiquidFarms_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryLiquidFarmsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).LiquidFarms(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/squad.liquidfarming.v1beta1.Query/LiquidFarms", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).LiquidFarms(ctx, req.(*QueryLiquidFarmsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_LiquidFarm_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryLiquidFarmRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).LiquidFarm(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/squad.liquidfarming.v1beta1.Query/LiquidFarm", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).LiquidFarm(ctx, req.(*QueryLiquidFarmRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_RewardsAuctions_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryRewardsAuctionsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).RewardsAuctions(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/squad.liquidfarming.v1beta1.Query/RewardsAuctions", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).RewardsAuctions(ctx, req.(*QueryRewardsAuctionsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_RewardsAuction_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryRewardsAuctionRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).RewardsAuction(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/squad.liquidfarming.v1beta1.Query/RewardsAuction", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).RewardsAuction(ctx, req.(*QueryRewardsAuctionRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_Bids_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryBidsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Bids(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/squad.liquidfarming.v1beta1.Query/Bids", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Bids(ctx, req.(*QueryBidsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_MintRate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryMintRateRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).MintRate(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/squad.liquidfarming.v1beta1.Query/MintRate", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).MintRate(ctx, req.(*QueryMintRateRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_BurnRate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryBurnRateRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).BurnRate(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/squad.liquidfarming.v1beta1.Query/BurnRate", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).BurnRate(ctx, req.(*QueryBurnRateRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "squad.liquidfarming.v1beta1.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Params", + Handler: _Query_Params_Handler, + }, + { + MethodName: "LiquidFarms", + Handler: _Query_LiquidFarms_Handler, + }, + { + MethodName: "LiquidFarm", + Handler: _Query_LiquidFarm_Handler, + }, + { + MethodName: "RewardsAuctions", + Handler: _Query_RewardsAuctions_Handler, + }, + { + MethodName: "RewardsAuction", + Handler: _Query_RewardsAuction_Handler, + }, + { + MethodName: "Bids", + Handler: _Query_Bids_Handler, + }, + { + MethodName: "MintRate", + Handler: _Query_MintRate_Handler, + }, + { + MethodName: "BurnRate", + Handler: _Query_BurnRate_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "squad/liquidfarming/v1beta1/query.proto", +} + +func (m *QueryLiquidFarmsRequest) 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 *QueryLiquidFarmsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryLiquidFarmsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryLiquidFarmsResponse) 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 *QueryLiquidFarmsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryLiquidFarmsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.LiquidFarms) > 0 { + for iNdEx := len(m.LiquidFarms) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.LiquidFarms[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *QueryLiquidFarmRequest) 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 *QueryLiquidFarmRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryLiquidFarmRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.PoolId != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.PoolId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *QueryLiquidFarmResponse) 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 *QueryLiquidFarmResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryLiquidFarmResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.LiquidFarm.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *QueryParamsRequest) 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 *QueryParamsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryParamsResponse) 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 *QueryParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *QueryRewardsAuctionsRequest) 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 *QueryRewardsAuctionsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryRewardsAuctionsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if m.PoolId != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.PoolId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *QueryRewardsAuctionsResponse) 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 *QueryRewardsAuctionsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryRewardsAuctionsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.RewardAuctions) > 0 { + for iNdEx := len(m.RewardAuctions) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.RewardAuctions[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *QueryRewardsAuctionRequest) 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 *QueryRewardsAuctionRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryRewardsAuctionRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.PoolId != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.PoolId)) + i-- + dAtA[i] = 0x10 + } + if m.AuctionId != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.AuctionId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *QueryRewardsAuctionResponse) 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 *QueryRewardsAuctionResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryRewardsAuctionResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.RewardAuction.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *QueryBidsRequest) 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 *QueryBidsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryBidsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if m.PoolId != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.PoolId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *QueryBidsResponse) 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 *QueryBidsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryBidsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Bids) > 0 { + for iNdEx := len(m.Bids) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Bids[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *QueryMintRateRequest) 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 *QueryMintRateRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryMintRateRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.PoolId != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.PoolId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *QueryMintRateResponse) 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 *QueryMintRateResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryMintRateResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.MintRate.Size() + i -= size + if _, err := m.MintRate.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *QueryBurnRateRequest) 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 *QueryBurnRateRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryBurnRateRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.PoolId != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.PoolId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *QueryBurnRateResponse) 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 *QueryBurnRateResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryBurnRateResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.BurnRate.Size() + i -= size + if _, err := m.BurnRate.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *LiquidFarmResponse) 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 *LiquidFarmResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *LiquidFarmResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.TotalFarmingAmount.Size() + i -= size + if _, err := m.TotalFarmingAmount.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + { + size := m.MinBidAmount.Size() + i -= size + if _, err := m.MinBidAmount.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + { + size := m.MinFarmAmount.Size() + i -= size + if _, err := m.MinFarmAmount.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + if len(m.LFCoinDenom) > 0 { + i -= len(m.LFCoinDenom) + copy(dAtA[i:], m.LFCoinDenom) + i = encodeVarintQuery(dAtA, i, uint64(len(m.LFCoinDenom))) + i-- + dAtA[i] = 0x1a + } + if len(m.LiquidFarmReserveAddress) > 0 { + i -= len(m.LiquidFarmReserveAddress) + copy(dAtA[i:], m.LiquidFarmReserveAddress) + i = encodeVarintQuery(dAtA, i, uint64(len(m.LiquidFarmReserveAddress))) + i-- + dAtA[i] = 0x12 + } + if m.PoolId != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.PoolId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QueryLiquidFarmsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryLiquidFarmsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.LiquidFarms) > 0 { + for _, e := range m.LiquidFarms { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + +func (m *QueryLiquidFarmRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PoolId != 0 { + n += 1 + sovQuery(uint64(m.PoolId)) + } + return n +} + +func (m *QueryLiquidFarmResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.LiquidFarm.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryParamsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryRewardsAuctionsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PoolId != 0 { + n += 1 + sovQuery(uint64(m.PoolId)) + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryRewardsAuctionsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.RewardAuctions) > 0 { + for _, e := range m.RewardAuctions { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryRewardsAuctionRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.AuctionId != 0 { + n += 1 + sovQuery(uint64(m.AuctionId)) + } + if m.PoolId != 0 { + n += 1 + sovQuery(uint64(m.PoolId)) + } + return n +} + +func (m *QueryRewardsAuctionResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.RewardAuction.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryBidsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PoolId != 0 { + n += 1 + sovQuery(uint64(m.PoolId)) + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryBidsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Bids) > 0 { + for _, e := range m.Bids { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryMintRateRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PoolId != 0 { + n += 1 + sovQuery(uint64(m.PoolId)) + } + return n +} + +func (m *QueryMintRateResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.MintRate.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryBurnRateRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PoolId != 0 { + n += 1 + sovQuery(uint64(m.PoolId)) + } + return n +} + +func (m *QueryBurnRateResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.BurnRate.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *LiquidFarmResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PoolId != 0 { + n += 1 + sovQuery(uint64(m.PoolId)) + } + l = len(m.LiquidFarmReserveAddress) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.LFCoinDenom) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = m.MinFarmAmount.Size() + n += 1 + l + sovQuery(uint64(l)) + l = m.MinBidAmount.Size() + n += 1 + l + sovQuery(uint64(l)) + l = m.TotalFarmingAmount.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QueryLiquidFarmsRequest) 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 ErrIntOverflowQuery + } + 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: QueryLiquidFarmsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryLiquidFarmsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryLiquidFarmsResponse) 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 ErrIntOverflowQuery + } + 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: QueryLiquidFarmsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryLiquidFarmsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field LiquidFarms", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.LiquidFarms = append(m.LiquidFarms, LiquidFarmResponse{}) + if err := m.LiquidFarms[len(m.LiquidFarms)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryLiquidFarmRequest) 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 ErrIntOverflowQuery + } + 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: QueryLiquidFarmRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryLiquidFarmRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PoolId", wireType) + } + m.PoolId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PoolId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryLiquidFarmResponse) 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 ErrIntOverflowQuery + } + 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: QueryLiquidFarmResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryLiquidFarmResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field LiquidFarm", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.LiquidFarm.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryParamsRequest) 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 ErrIntOverflowQuery + } + 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: QueryParamsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryParamsResponse) 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 ErrIntOverflowQuery + } + 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: QueryParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryRewardsAuctionsRequest) 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 ErrIntOverflowQuery + } + 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: QueryRewardsAuctionsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryRewardsAuctionsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PoolId", wireType) + } + m.PoolId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PoolId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryRewardsAuctionsResponse) 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 ErrIntOverflowQuery + } + 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: QueryRewardsAuctionsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryRewardsAuctionsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RewardAuctions", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RewardAuctions = append(m.RewardAuctions, RewardsAuction{}) + if err := m.RewardAuctions[len(m.RewardAuctions)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryRewardsAuctionRequest) 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 ErrIntOverflowQuery + } + 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: QueryRewardsAuctionRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryRewardsAuctionRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field AuctionId", wireType) + } + m.AuctionId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.AuctionId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PoolId", wireType) + } + m.PoolId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PoolId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryRewardsAuctionResponse) 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 ErrIntOverflowQuery + } + 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: QueryRewardsAuctionResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryRewardsAuctionResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RewardAuction", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.RewardAuction.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryBidsRequest) 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 ErrIntOverflowQuery + } + 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: QueryBidsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryBidsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PoolId", wireType) + } + m.PoolId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PoolId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryBidsResponse) 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 ErrIntOverflowQuery + } + 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: QueryBidsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryBidsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Bids", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Bids = append(m.Bids, Bid{}) + if err := m.Bids[len(m.Bids)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryMintRateRequest) 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 ErrIntOverflowQuery + } + 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: QueryMintRateRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryMintRateRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PoolId", wireType) + } + m.PoolId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PoolId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryMintRateResponse) 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 ErrIntOverflowQuery + } + 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: QueryMintRateResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryMintRateResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MintRate", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.MintRate.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryBurnRateRequest) 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 ErrIntOverflowQuery + } + 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: QueryBurnRateRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryBurnRateRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PoolId", wireType) + } + m.PoolId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PoolId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryBurnRateResponse) 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 ErrIntOverflowQuery + } + 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: QueryBurnRateResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryBurnRateResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BurnRate", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.BurnRate.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *LiquidFarmResponse) 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 ErrIntOverflowQuery + } + 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: LiquidFarmResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: LiquidFarmResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PoolId", wireType) + } + m.PoolId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PoolId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field LiquidFarmReserveAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.LiquidFarmReserveAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field LFCoinDenom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.LFCoinDenom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MinFarmAmount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.MinFarmAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MinBidAmount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.MinBidAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TotalFarmingAmount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.TotalFarmingAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipQuery(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthQuery + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQuery + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQuery + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/liquidfarming/types/query.pb.gw.go b/x/liquidfarming/types/query.pb.gw.go new file mode 100644 index 00000000..5cb0f5b0 --- /dev/null +++ b/x/liquidfarming/types/query.pb.gw.go @@ -0,0 +1,874 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: squad/liquidfarming/v1beta1/query.proto + +/* +Package types is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package types + +import ( + "context" + "io" + "net/http" + + "github.com/golang/protobuf/descriptor" + "github.com/golang/protobuf/proto" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/grpc-ecosystem/grpc-gateway/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/status" +) + +// Suppress "imported and not used" errors +var _ codes.Code +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray +var _ = descriptor.ForMessage + +func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest + var metadata runtime.ServerMetadata + + msg, err := client.Params(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest + var metadata runtime.ServerMetadata + + msg, err := server.Params(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_LiquidFarms_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Query_LiquidFarms_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryLiquidFarmsRequest + 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_LiquidFarms_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.LiquidFarms(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_LiquidFarms_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryLiquidFarmsRequest + 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_LiquidFarms_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.LiquidFarms(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_LiquidFarm_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryLiquidFarmRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["pool_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "pool_id") + } + + protoReq.PoolId, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "pool_id", err) + } + + msg, err := client.LiquidFarm(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_LiquidFarm_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryLiquidFarmRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["pool_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "pool_id") + } + + protoReq.PoolId, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "pool_id", err) + } + + msg, err := server.LiquidFarm(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_RewardsAuctions_0 = &utilities.DoubleArray{Encoding: map[string]int{"pool_id": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} +) + +func request_Query_RewardsAuctions_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryRewardsAuctionsRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["pool_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "pool_id") + } + + protoReq.PoolId, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "pool_id", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_RewardsAuctions_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.RewardsAuctions(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_RewardsAuctions_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryRewardsAuctionsRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["pool_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "pool_id") + } + + protoReq.PoolId, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "pool_id", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_RewardsAuctions_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.RewardsAuctions(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_RewardsAuction_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryRewardsAuctionRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["pool_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "pool_id") + } + + protoReq.PoolId, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "pool_id", err) + } + + val, ok = pathParams["auction_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "auction_id") + } + + protoReq.AuctionId, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "auction_id", err) + } + + msg, err := client.RewardsAuction(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_RewardsAuction_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryRewardsAuctionRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["pool_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "pool_id") + } + + protoReq.PoolId, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "pool_id", err) + } + + val, ok = pathParams["auction_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "auction_id") + } + + protoReq.AuctionId, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "auction_id", err) + } + + msg, err := server.RewardsAuction(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_Bids_0 = &utilities.DoubleArray{Encoding: map[string]int{"pool_id": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} +) + +func request_Query_Bids_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryBidsRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["pool_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "pool_id") + } + + protoReq.PoolId, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "pool_id", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Bids_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.Bids(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Bids_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryBidsRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["pool_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "pool_id") + } + + protoReq.PoolId, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "pool_id", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Bids_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.Bids(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_MintRate_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryMintRateRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["pool_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "pool_id") + } + + protoReq.PoolId, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "pool_id", err) + } + + msg, err := client.MintRate(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_MintRate_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryMintRateRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["pool_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "pool_id") + } + + protoReq.PoolId, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "pool_id", err) + } + + msg, err := server.MintRate(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_BurnRate_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryBurnRateRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["pool_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "pool_id") + } + + protoReq.PoolId, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "pool_id", err) + } + + msg, err := client.BurnRate(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_BurnRate_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryBurnRateRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["pool_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "pool_id") + } + + protoReq.PoolId, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "pool_id", err) + } + + msg, err := server.BurnRate(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. +// Note that using this registration option will cause many gRPC library features (such as grpc.SendHeader, etc) to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { + + mux.Handle("GET", pattern_Query_Params_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_Params_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_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_LiquidFarms_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_LiquidFarms_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_LiquidFarms_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_LiquidFarm_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_LiquidFarm_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_LiquidFarm_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_RewardsAuctions_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_RewardsAuctions_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_RewardsAuctions_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_RewardsAuction_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_RewardsAuction_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_RewardsAuction_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_Bids_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_Bids_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_Bids_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_MintRate_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_MintRate_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_MintRate_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_BurnRate_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_BurnRate_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_BurnRate_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.Dial(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterQueryHandler(ctx, mux, conn) +} + +// RegisterQueryHandler registers the http handlers for service Query to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn)) +} + +// RegisterQueryHandlerClient registers the http handlers for service Query +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "QueryClient" to call the correct interceptors. +func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { + + mux.Handle("GET", pattern_Query_Params_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_Params_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_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_LiquidFarms_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_LiquidFarms_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_LiquidFarms_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_LiquidFarm_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_LiquidFarm_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_LiquidFarm_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_RewardsAuctions_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_RewardsAuctions_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_RewardsAuctions_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_RewardsAuction_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_RewardsAuction_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_RewardsAuction_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_Bids_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_Bids_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_Bids_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_MintRate_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_MintRate_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_MintRate_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_BurnRate_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_BurnRate_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_BurnRate_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"squad", "liquidfarming", "v1beta1", "params"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_LiquidFarms_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"squad", "liquidfarming", "v1beta1", "liquidfarms"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_LiquidFarm_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"squad", "liquidfarming", "v1beta1", "liquidfarms", "pool_id"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_RewardsAuctions_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5}, []string{"squad", "liquidfarming", "v1beta1", "pools", "pool_id", "rewards_auctions"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_RewardsAuction_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5, 1, 0, 4, 1, 5, 6}, []string{"squad", "liquidfarming", "v1beta1", "pools", "pool_id", "rewards_auctions", "auction_id"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_Bids_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5}, []string{"squad", "liquidfarming", "v1beta1", "pools", "pool_id", "bids"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_MintRate_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5}, []string{"squad", "liquidfarming", "v1beta1", "pools", "pool_id", "mint_rate"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_BurnRate_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5}, []string{"squad", "liquidfarming", "v1beta1", "pools", "pool_id", "burn_rate"}, "", runtime.AssumeColonVerbOpt(false))) +) + +var ( + forward_Query_Params_0 = runtime.ForwardResponseMessage + + forward_Query_LiquidFarms_0 = runtime.ForwardResponseMessage + + forward_Query_LiquidFarm_0 = runtime.ForwardResponseMessage + + forward_Query_RewardsAuctions_0 = runtime.ForwardResponseMessage + + forward_Query_RewardsAuction_0 = runtime.ForwardResponseMessage + + forward_Query_Bids_0 = runtime.ForwardResponseMessage + + forward_Query_MintRate_0 = runtime.ForwardResponseMessage + + forward_Query_BurnRate_0 = runtime.ForwardResponseMessage +) diff --git a/x/liquidfarming/types/tx.pb.go b/x/liquidfarming/types/tx.pb.go new file mode 100644 index 00000000..72bd2fa0 --- /dev/null +++ b/x/liquidfarming/types/tx.pb.go @@ -0,0 +1,2215 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: squad/liquidfarming/v1beta1/tx.proto + +package types + +import ( + context "context" + fmt "fmt" + types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/cosmos/cosmos-sdk/types/query" + _ "github.com/gogo/protobuf/gogoproto" + grpc1 "github.com/gogo/protobuf/grpc" + proto "github.com/gogo/protobuf/proto" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// MsgLiquidFarm defines a SDK message for farming pool coin for a liquid farm. +type MsgLiquidFarm struct { + PoolId uint64 `protobuf:"varint,1,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty"` + Farmer string `protobuf:"bytes,2,opt,name=farmer,proto3" json:"farmer,omitempty"` + FarmingCoin types.Coin `protobuf:"bytes,3,opt,name=farming_coin,json=farmingCoin,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coin" json:"farming_coin"` +} + +func (m *MsgLiquidFarm) Reset() { *m = MsgLiquidFarm{} } +func (m *MsgLiquidFarm) String() string { return proto.CompactTextString(m) } +func (*MsgLiquidFarm) ProtoMessage() {} +func (*MsgLiquidFarm) Descriptor() ([]byte, []int) { + return fileDescriptor_db3f4cd082b3b711, []int{0} +} +func (m *MsgLiquidFarm) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgLiquidFarm) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgLiquidFarm.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 *MsgLiquidFarm) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgLiquidFarm.Merge(m, src) +} +func (m *MsgLiquidFarm) XXX_Size() int { + return m.Size() +} +func (m *MsgLiquidFarm) XXX_DiscardUnknown() { + xxx_messageInfo_MsgLiquidFarm.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgLiquidFarm proto.InternalMessageInfo + +// MsgLiquidFarmResponse defines the MsgLiquidFarmResponse response type. +type MsgLiquidFarmResponse struct { +} + +func (m *MsgLiquidFarmResponse) Reset() { *m = MsgLiquidFarmResponse{} } +func (m *MsgLiquidFarmResponse) String() string { return proto.CompactTextString(m) } +func (*MsgLiquidFarmResponse) ProtoMessage() {} +func (*MsgLiquidFarmResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_db3f4cd082b3b711, []int{1} +} +func (m *MsgLiquidFarmResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgLiquidFarmResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgLiquidFarmResponse.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 *MsgLiquidFarmResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgLiquidFarmResponse.Merge(m, src) +} +func (m *MsgLiquidFarmResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgLiquidFarmResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgLiquidFarmResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgLiquidFarmResponse proto.InternalMessageInfo + +// MsgLiquidUnfarm defines a SDK message for unfarming LFCoin. +type MsgLiquidUnfarm struct { + PoolId uint64 `protobuf:"varint,1,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty"` + Farmer string `protobuf:"bytes,2,opt,name=farmer,proto3" json:"farmer,omitempty"` + UnfarmingCoin types.Coin `protobuf:"bytes,3,opt,name=unfarming_coin,json=unfarmingCoin,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coin" json:"unfarming_coin"` +} + +func (m *MsgLiquidUnfarm) Reset() { *m = MsgLiquidUnfarm{} } +func (m *MsgLiquidUnfarm) String() string { return proto.CompactTextString(m) } +func (*MsgLiquidUnfarm) ProtoMessage() {} +func (*MsgLiquidUnfarm) Descriptor() ([]byte, []int) { + return fileDescriptor_db3f4cd082b3b711, []int{2} +} +func (m *MsgLiquidUnfarm) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgLiquidUnfarm) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgLiquidUnfarm.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 *MsgLiquidUnfarm) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgLiquidUnfarm.Merge(m, src) +} +func (m *MsgLiquidUnfarm) XXX_Size() int { + return m.Size() +} +func (m *MsgLiquidUnfarm) XXX_DiscardUnknown() { + xxx_messageInfo_MsgLiquidUnfarm.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgLiquidUnfarm proto.InternalMessageInfo + +// MsgLiquidUnfarmResponse defines the MsgLiquidUnfarmResponse response type. +type MsgLiquidUnfarmResponse struct { +} + +func (m *MsgLiquidUnfarmResponse) Reset() { *m = MsgLiquidUnfarmResponse{} } +func (m *MsgLiquidUnfarmResponse) String() string { return proto.CompactTextString(m) } +func (*MsgLiquidUnfarmResponse) ProtoMessage() {} +func (*MsgLiquidUnfarmResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_db3f4cd082b3b711, []int{3} +} +func (m *MsgLiquidUnfarmResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgLiquidUnfarmResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgLiquidUnfarmResponse.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 *MsgLiquidUnfarmResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgLiquidUnfarmResponse.Merge(m, src) +} +func (m *MsgLiquidUnfarmResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgLiquidUnfarmResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgLiquidUnfarmResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgLiquidUnfarmResponse proto.InternalMessageInfo + +// MsgLiquidUnfarmAndWithdraw defines a SDK message for unfarming LFCoin. +type MsgLiquidUnfarmAndWithdraw struct { + PoolId uint64 `protobuf:"varint,1,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty"` + Farmer string `protobuf:"bytes,2,opt,name=farmer,proto3" json:"farmer,omitempty"` + UnfarmingCoin types.Coin `protobuf:"bytes,3,opt,name=unfarming_coin,json=unfarmingCoin,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coin" json:"unfarming_coin"` +} + +func (m *MsgLiquidUnfarmAndWithdraw) Reset() { *m = MsgLiquidUnfarmAndWithdraw{} } +func (m *MsgLiquidUnfarmAndWithdraw) String() string { return proto.CompactTextString(m) } +func (*MsgLiquidUnfarmAndWithdraw) ProtoMessage() {} +func (*MsgLiquidUnfarmAndWithdraw) Descriptor() ([]byte, []int) { + return fileDescriptor_db3f4cd082b3b711, []int{4} +} +func (m *MsgLiquidUnfarmAndWithdraw) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgLiquidUnfarmAndWithdraw) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgLiquidUnfarmAndWithdraw.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 *MsgLiquidUnfarmAndWithdraw) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgLiquidUnfarmAndWithdraw.Merge(m, src) +} +func (m *MsgLiquidUnfarmAndWithdraw) XXX_Size() int { + return m.Size() +} +func (m *MsgLiquidUnfarmAndWithdraw) XXX_DiscardUnknown() { + xxx_messageInfo_MsgLiquidUnfarmAndWithdraw.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgLiquidUnfarmAndWithdraw proto.InternalMessageInfo + +// MsgLiquidUnfarmAndWithdrawResponse defines the MsgLiquidUnfarmAndWithdrawResponse response type. +type MsgLiquidUnfarmAndWithdrawResponse struct { +} + +func (m *MsgLiquidUnfarmAndWithdrawResponse) Reset() { *m = MsgLiquidUnfarmAndWithdrawResponse{} } +func (m *MsgLiquidUnfarmAndWithdrawResponse) String() string { return proto.CompactTextString(m) } +func (*MsgLiquidUnfarmAndWithdrawResponse) ProtoMessage() {} +func (*MsgLiquidUnfarmAndWithdrawResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_db3f4cd082b3b711, []int{5} +} +func (m *MsgLiquidUnfarmAndWithdrawResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgLiquidUnfarmAndWithdrawResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgLiquidUnfarmAndWithdrawResponse.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 *MsgLiquidUnfarmAndWithdrawResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgLiquidUnfarmAndWithdrawResponse.Merge(m, src) +} +func (m *MsgLiquidUnfarmAndWithdrawResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgLiquidUnfarmAndWithdrawResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgLiquidUnfarmAndWithdrawResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgLiquidUnfarmAndWithdrawResponse proto.InternalMessageInfo + +// MsgPlaceBid defines a SDK message for placing a bid for a rewards auction. +type MsgPlaceBid struct { + AuctionId uint64 `protobuf:"varint,1,opt,name=auction_id,json=auctionId,proto3" json:"auction_id,omitempty"` + PoolId uint64 `protobuf:"varint,2,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty"` + Bidder string `protobuf:"bytes,3,opt,name=bidder,proto3" json:"bidder,omitempty"` + BiddingCoin types.Coin `protobuf:"bytes,4,opt,name=bidding_coin,json=biddingCoin,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coin" json:"bidding_coin"` +} + +func (m *MsgPlaceBid) Reset() { *m = MsgPlaceBid{} } +func (m *MsgPlaceBid) String() string { return proto.CompactTextString(m) } +func (*MsgPlaceBid) ProtoMessage() {} +func (*MsgPlaceBid) Descriptor() ([]byte, []int) { + return fileDescriptor_db3f4cd082b3b711, []int{6} +} +func (m *MsgPlaceBid) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgPlaceBid) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgPlaceBid.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 *MsgPlaceBid) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgPlaceBid.Merge(m, src) +} +func (m *MsgPlaceBid) XXX_Size() int { + return m.Size() +} +func (m *MsgPlaceBid) XXX_DiscardUnknown() { + xxx_messageInfo_MsgPlaceBid.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgPlaceBid proto.InternalMessageInfo + +// MsgPlaceBidResponse defines the MsgPlaceBidResponse response type. +type MsgPlaceBidResponse struct { +} + +func (m *MsgPlaceBidResponse) Reset() { *m = MsgPlaceBidResponse{} } +func (m *MsgPlaceBidResponse) String() string { return proto.CompactTextString(m) } +func (*MsgPlaceBidResponse) ProtoMessage() {} +func (*MsgPlaceBidResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_db3f4cd082b3b711, []int{7} +} +func (m *MsgPlaceBidResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgPlaceBidResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgPlaceBidResponse.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 *MsgPlaceBidResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgPlaceBidResponse.Merge(m, src) +} +func (m *MsgPlaceBidResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgPlaceBidResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgPlaceBidResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgPlaceBidResponse proto.InternalMessageInfo + +// MsgRefundBid defines a SDK message for refunding the bid that is not winning for the auction. +type MsgRefundBid struct { + AuctionId uint64 `protobuf:"varint,1,opt,name=auction_id,json=auctionId,proto3" json:"auction_id,omitempty"` + PoolId uint64 `protobuf:"varint,2,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty"` + Bidder string `protobuf:"bytes,3,opt,name=bidder,proto3" json:"bidder,omitempty"` +} + +func (m *MsgRefundBid) Reset() { *m = MsgRefundBid{} } +func (m *MsgRefundBid) String() string { return proto.CompactTextString(m) } +func (*MsgRefundBid) ProtoMessage() {} +func (*MsgRefundBid) Descriptor() ([]byte, []int) { + return fileDescriptor_db3f4cd082b3b711, []int{8} +} +func (m *MsgRefundBid) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRefundBid) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRefundBid.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 *MsgRefundBid) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRefundBid.Merge(m, src) +} +func (m *MsgRefundBid) XXX_Size() int { + return m.Size() +} +func (m *MsgRefundBid) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRefundBid.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRefundBid proto.InternalMessageInfo + +// MsgRefundBidResponse defines the MsgRefundBidResponse response type. +type MsgRefundBidResponse struct { +} + +func (m *MsgRefundBidResponse) Reset() { *m = MsgRefundBidResponse{} } +func (m *MsgRefundBidResponse) String() string { return proto.CompactTextString(m) } +func (*MsgRefundBidResponse) ProtoMessage() {} +func (*MsgRefundBidResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_db3f4cd082b3b711, []int{9} +} +func (m *MsgRefundBidResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRefundBidResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRefundBidResponse.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 *MsgRefundBidResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRefundBidResponse.Merge(m, src) +} +func (m *MsgRefundBidResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgRefundBidResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRefundBidResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRefundBidResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*MsgLiquidFarm)(nil), "squad.liquidfarming.v1beta1.MsgLiquidFarm") + proto.RegisterType((*MsgLiquidFarmResponse)(nil), "squad.liquidfarming.v1beta1.MsgLiquidFarmResponse") + proto.RegisterType((*MsgLiquidUnfarm)(nil), "squad.liquidfarming.v1beta1.MsgLiquidUnfarm") + proto.RegisterType((*MsgLiquidUnfarmResponse)(nil), "squad.liquidfarming.v1beta1.MsgLiquidUnfarmResponse") + proto.RegisterType((*MsgLiquidUnfarmAndWithdraw)(nil), "squad.liquidfarming.v1beta1.MsgLiquidUnfarmAndWithdraw") + proto.RegisterType((*MsgLiquidUnfarmAndWithdrawResponse)(nil), "squad.liquidfarming.v1beta1.MsgLiquidUnfarmAndWithdrawResponse") + proto.RegisterType((*MsgPlaceBid)(nil), "squad.liquidfarming.v1beta1.MsgPlaceBid") + proto.RegisterType((*MsgPlaceBidResponse)(nil), "squad.liquidfarming.v1beta1.MsgPlaceBidResponse") + proto.RegisterType((*MsgRefundBid)(nil), "squad.liquidfarming.v1beta1.MsgRefundBid") + proto.RegisterType((*MsgRefundBidResponse)(nil), "squad.liquidfarming.v1beta1.MsgRefundBidResponse") +} + +func init() { + proto.RegisterFile("squad/liquidfarming/v1beta1/tx.proto", fileDescriptor_db3f4cd082b3b711) +} + +var fileDescriptor_db3f4cd082b3b711 = []byte{ + // 579 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x95, 0x41, 0x6b, 0x13, 0x41, + 0x14, 0xc7, 0x33, 0x6d, 0x88, 0xe6, 0x25, 0x55, 0x58, 0xdb, 0x26, 0x5d, 0x71, 0x13, 0x42, 0xc1, + 0x58, 0xec, 0xae, 0x89, 0xa2, 0xe0, 0x45, 0x8c, 0x20, 0x14, 0x0c, 0x94, 0x05, 0x11, 0xbc, 0x94, + 0xd9, 0xcc, 0x66, 0x3b, 0x98, 0xec, 0x24, 0x3b, 0xbb, 0xda, 0x7e, 0x03, 0x8f, 0x82, 0x5f, 0xc0, + 0xb3, 0x77, 0x4f, 0xde, 0xa5, 0xc7, 0xe0, 0xc9, 0x93, 0x4a, 0xf2, 0x45, 0x64, 0x36, 0xb3, 0xd3, + 0x4d, 0xa4, 0x36, 0x2d, 0xf6, 0xd0, 0x53, 0x76, 0x32, 0xff, 0xf7, 0xfe, 0xff, 0x1f, 0xbc, 0xb7, + 0x0b, 0x9b, 0x7c, 0x18, 0x61, 0x62, 0xf5, 0xe8, 0x30, 0xa2, 0xa4, 0x8b, 0x83, 0x3e, 0xf5, 0x3d, + 0xeb, 0x6d, 0xc3, 0x71, 0x43, 0xdc, 0xb0, 0xc2, 0x03, 0x73, 0x10, 0xb0, 0x90, 0x69, 0x37, 0x63, + 0x95, 0x39, 0xa3, 0x32, 0xa5, 0x4a, 0x5f, 0xf5, 0x98, 0xc7, 0x62, 0x9d, 0x25, 0x9e, 0xa6, 0x25, + 0xba, 0xd1, 0x61, 0xbc, 0xcf, 0xb8, 0xe5, 0x60, 0xee, 0xaa, 0x86, 0x1d, 0x46, 0x7d, 0x79, 0xbf, + 0x95, 0xbe, 0x1f, 0x46, 0x6e, 0x70, 0xa8, 0x54, 0x03, 0xec, 0x51, 0x1f, 0x87, 0x94, 0x49, 0x6d, + 0xed, 0x0b, 0x82, 0x95, 0x36, 0xf7, 0x5e, 0xc4, 0xf6, 0xcf, 0x71, 0xd0, 0xd7, 0x4a, 0x70, 0x65, + 0xc0, 0x58, 0x6f, 0x8f, 0x92, 0x32, 0xaa, 0xa2, 0x7a, 0xd6, 0xce, 0x89, 0xe3, 0x0e, 0xd1, 0xd6, + 0x21, 0x27, 0xf2, 0xb9, 0x41, 0x79, 0xa9, 0x8a, 0xea, 0x79, 0x5b, 0x9e, 0xb4, 0x3e, 0x14, 0x65, + 0xee, 0x3d, 0x11, 0xa2, 0xbc, 0x5c, 0x45, 0xf5, 0x42, 0x73, 0xc3, 0x9c, 0xa6, 0x30, 0x45, 0x8a, + 0x04, 0xc8, 0x7c, 0xc6, 0xa8, 0xdf, 0xb2, 0x8e, 0x7e, 0x56, 0x32, 0x9f, 0x7f, 0x55, 0x6e, 0x7b, + 0x34, 0xdc, 0x8f, 0x1c, 0xb3, 0xc3, 0xfa, 0x96, 0x8c, 0x3c, 0xfd, 0xd9, 0xe6, 0xe4, 0x8d, 0x15, + 0x1e, 0x0e, 0x5c, 0x1e, 0x17, 0xd8, 0x05, 0xd9, 0x5f, 0x1c, 0x1e, 0x67, 0xdf, 0x7f, 0xaa, 0x64, + 0x6a, 0x25, 0x58, 0x9b, 0x89, 0x6d, 0xbb, 0x7c, 0xc0, 0x7c, 0xee, 0xd6, 0xbe, 0x22, 0xb8, 0xae, + 0x6e, 0x5e, 0xfa, 0xdd, 0x73, 0x21, 0x0d, 0xe1, 0x5a, 0xe4, 0x5f, 0x30, 0xd4, 0x8a, 0x72, 0x48, + 0x61, 0x6d, 0x40, 0x69, 0x2e, 0xbc, 0x02, 0xfb, 0x86, 0x40, 0x9f, 0xbb, 0x7b, 0xea, 0x93, 0x57, + 0x34, 0xdc, 0x27, 0x01, 0x7e, 0x77, 0x89, 0x18, 0x37, 0xa1, 0x76, 0x32, 0x87, 0xc2, 0xfd, 0x8e, + 0xa0, 0xd0, 0xe6, 0xde, 0x6e, 0x0f, 0x77, 0xdc, 0x16, 0x25, 0xda, 0x2d, 0x00, 0x1c, 0x75, 0xc4, + 0xe4, 0x1e, 0x23, 0xe6, 0xe5, 0x3f, 0x3b, 0x24, 0x8d, 0xbf, 0x34, 0x8f, 0xef, 0x50, 0x42, 0xdc, + 0x20, 0xc6, 0xcb, 0xdb, 0xf2, 0x24, 0xa6, 0x56, 0x3c, 0x29, 0xf8, 0xec, 0xff, 0x9f, 0x5a, 0xd9, + 0x3f, 0x85, 0xbe, 0x06, 0x37, 0x52, 0x4c, 0x8a, 0x95, 0x40, 0xb1, 0xcd, 0x3d, 0xdb, 0xed, 0x46, + 0x3e, 0xb9, 0x00, 0x56, 0x69, 0xbe, 0x0e, 0xab, 0x69, 0x97, 0xc4, 0xbd, 0x39, 0xca, 0xc2, 0x72, + 0x9b, 0x7b, 0x5a, 0x0f, 0x20, 0xf5, 0x1a, 0xd8, 0x32, 0xff, 0xf1, 0x62, 0x32, 0x67, 0x76, 0x4f, + 0x6f, 0x2e, 0xae, 0x4d, 0x5c, 0xb5, 0x00, 0x8a, 0x33, 0x3b, 0x7a, 0x77, 0xb1, 0x1e, 0x53, 0xb5, + 0xfe, 0xe0, 0x2c, 0x6a, 0xe5, 0xf9, 0x11, 0x41, 0xe9, 0xa4, 0xfd, 0x79, 0x74, 0x96, 0x8e, 0xa9, + 0x42, 0xfd, 0xc9, 0x39, 0x0b, 0x55, 0xaa, 0x2e, 0x5c, 0x55, 0x53, 0x5e, 0x3f, 0xad, 0x59, 0xa2, + 0xd4, 0xef, 0x2d, 0xaa, 0x54, 0x3e, 0x14, 0xf2, 0xc7, 0x23, 0x76, 0xe7, 0xb4, 0x72, 0x25, 0xd5, + 0x1b, 0x0b, 0x4b, 0x13, 0xab, 0xd6, 0xee, 0xd1, 0xd8, 0x40, 0xa3, 0xb1, 0x81, 0x7e, 0x8f, 0x0d, + 0xf4, 0x61, 0x62, 0x64, 0x46, 0x13, 0x23, 0xf3, 0x63, 0x62, 0x64, 0x5e, 0x3f, 0xfc, 0x6b, 0x7b, + 0x44, 0xef, 0xed, 0x1e, 0x76, 0xb8, 0x35, 0xfd, 0x5e, 0x1e, 0xcc, 0x7d, 0x31, 0xe3, 0x8d, 0x72, + 0x72, 0xf1, 0xe7, 0xea, 0xfe, 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x5c, 0xa3, 0xf2, 0x37, 0x55, + 0x07, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// MsgClient is the client API for Msg service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type MsgClient interface { + // LiquidFarm defines a method for farming pool coin for a liquid farm + LiquidFarm(ctx context.Context, in *MsgLiquidFarm, opts ...grpc.CallOption) (*MsgLiquidFarmResponse, error) + // LiquidUnfarm defines a method for unfarming amount of LFCoin + LiquidUnfarm(ctx context.Context, in *MsgLiquidUnfarm, opts ...grpc.CallOption) (*MsgLiquidUnfarmResponse, error) + // LiquidUnfarmAndWithdraw defines a method for unfarming amount of LFCoin and withdraw pool coin from the pool + LiquidUnfarmAndWithdraw(ctx context.Context, in *MsgLiquidUnfarmAndWithdraw, opts ...grpc.CallOption) (*MsgLiquidUnfarmAndWithdrawResponse, error) + // PlaceBid defines a method for placing a bid for a rewards auction + PlaceBid(ctx context.Context, in *MsgPlaceBid, opts ...grpc.CallOption) (*MsgPlaceBidResponse, error) + // RefundBid defines a method for refunding the bid that is not winning for the auction + RefundBid(ctx context.Context, in *MsgRefundBid, opts ...grpc.CallOption) (*MsgRefundBidResponse, error) +} + +type msgClient struct { + cc grpc1.ClientConn +} + +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} +} + +func (c *msgClient) LiquidFarm(ctx context.Context, in *MsgLiquidFarm, opts ...grpc.CallOption) (*MsgLiquidFarmResponse, error) { + out := new(MsgLiquidFarmResponse) + err := c.cc.Invoke(ctx, "/squad.liquidfarming.v1beta1.Msg/LiquidFarm", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) LiquidUnfarm(ctx context.Context, in *MsgLiquidUnfarm, opts ...grpc.CallOption) (*MsgLiquidUnfarmResponse, error) { + out := new(MsgLiquidUnfarmResponse) + err := c.cc.Invoke(ctx, "/squad.liquidfarming.v1beta1.Msg/LiquidUnfarm", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) LiquidUnfarmAndWithdraw(ctx context.Context, in *MsgLiquidUnfarmAndWithdraw, opts ...grpc.CallOption) (*MsgLiquidUnfarmAndWithdrawResponse, error) { + out := new(MsgLiquidUnfarmAndWithdrawResponse) + err := c.cc.Invoke(ctx, "/squad.liquidfarming.v1beta1.Msg/LiquidUnfarmAndWithdraw", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) PlaceBid(ctx context.Context, in *MsgPlaceBid, opts ...grpc.CallOption) (*MsgPlaceBidResponse, error) { + out := new(MsgPlaceBidResponse) + err := c.cc.Invoke(ctx, "/squad.liquidfarming.v1beta1.Msg/PlaceBid", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) RefundBid(ctx context.Context, in *MsgRefundBid, opts ...grpc.CallOption) (*MsgRefundBidResponse, error) { + out := new(MsgRefundBidResponse) + err := c.cc.Invoke(ctx, "/squad.liquidfarming.v1beta1.Msg/RefundBid", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MsgServer is the server API for Msg service. +type MsgServer interface { + // LiquidFarm defines a method for farming pool coin for a liquid farm + LiquidFarm(context.Context, *MsgLiquidFarm) (*MsgLiquidFarmResponse, error) + // LiquidUnfarm defines a method for unfarming amount of LFCoin + LiquidUnfarm(context.Context, *MsgLiquidUnfarm) (*MsgLiquidUnfarmResponse, error) + // LiquidUnfarmAndWithdraw defines a method for unfarming amount of LFCoin and withdraw pool coin from the pool + LiquidUnfarmAndWithdraw(context.Context, *MsgLiquidUnfarmAndWithdraw) (*MsgLiquidUnfarmAndWithdrawResponse, error) + // PlaceBid defines a method for placing a bid for a rewards auction + PlaceBid(context.Context, *MsgPlaceBid) (*MsgPlaceBidResponse, error) + // RefundBid defines a method for refunding the bid that is not winning for the auction + RefundBid(context.Context, *MsgRefundBid) (*MsgRefundBidResponse, error) +} + +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { +} + +func (*UnimplementedMsgServer) LiquidFarm(ctx context.Context, req *MsgLiquidFarm) (*MsgLiquidFarmResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method LiquidFarm not implemented") +} +func (*UnimplementedMsgServer) LiquidUnfarm(ctx context.Context, req *MsgLiquidUnfarm) (*MsgLiquidUnfarmResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method LiquidUnfarm not implemented") +} +func (*UnimplementedMsgServer) LiquidUnfarmAndWithdraw(ctx context.Context, req *MsgLiquidUnfarmAndWithdraw) (*MsgLiquidUnfarmAndWithdrawResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method LiquidUnfarmAndWithdraw not implemented") +} +func (*UnimplementedMsgServer) PlaceBid(ctx context.Context, req *MsgPlaceBid) (*MsgPlaceBidResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method PlaceBid not implemented") +} +func (*UnimplementedMsgServer) RefundBid(ctx context.Context, req *MsgRefundBid) (*MsgRefundBidResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RefundBid not implemented") +} + +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { + s.RegisterService(&_Msg_serviceDesc, srv) +} + +func _Msg_LiquidFarm_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgLiquidFarm) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).LiquidFarm(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/squad.liquidfarming.v1beta1.Msg/LiquidFarm", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).LiquidFarm(ctx, req.(*MsgLiquidFarm)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_LiquidUnfarm_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgLiquidUnfarm) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).LiquidUnfarm(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/squad.liquidfarming.v1beta1.Msg/LiquidUnfarm", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).LiquidUnfarm(ctx, req.(*MsgLiquidUnfarm)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_LiquidUnfarmAndWithdraw_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgLiquidUnfarmAndWithdraw) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).LiquidUnfarmAndWithdraw(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/squad.liquidfarming.v1beta1.Msg/LiquidUnfarmAndWithdraw", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).LiquidUnfarmAndWithdraw(ctx, req.(*MsgLiquidUnfarmAndWithdraw)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_PlaceBid_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgPlaceBid) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).PlaceBid(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/squad.liquidfarming.v1beta1.Msg/PlaceBid", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).PlaceBid(ctx, req.(*MsgPlaceBid)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_RefundBid_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgRefundBid) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).RefundBid(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/squad.liquidfarming.v1beta1.Msg/RefundBid", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).RefundBid(ctx, req.(*MsgRefundBid)) + } + return interceptor(ctx, in, info, handler) +} + +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "squad.liquidfarming.v1beta1.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "LiquidFarm", + Handler: _Msg_LiquidFarm_Handler, + }, + { + MethodName: "LiquidUnfarm", + Handler: _Msg_LiquidUnfarm_Handler, + }, + { + MethodName: "LiquidUnfarmAndWithdraw", + Handler: _Msg_LiquidUnfarmAndWithdraw_Handler, + }, + { + MethodName: "PlaceBid", + Handler: _Msg_PlaceBid_Handler, + }, + { + MethodName: "RefundBid", + Handler: _Msg_RefundBid_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "squad/liquidfarming/v1beta1/tx.proto", +} + +func (m *MsgLiquidFarm) 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 *MsgLiquidFarm) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgLiquidFarm) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.FarmingCoin.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if len(m.Farmer) > 0 { + i -= len(m.Farmer) + copy(dAtA[i:], m.Farmer) + i = encodeVarintTx(dAtA, i, uint64(len(m.Farmer))) + i-- + dAtA[i] = 0x12 + } + if m.PoolId != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.PoolId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *MsgLiquidFarmResponse) 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 *MsgLiquidFarmResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgLiquidFarmResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgLiquidUnfarm) 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 *MsgLiquidUnfarm) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgLiquidUnfarm) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.UnfarmingCoin.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if len(m.Farmer) > 0 { + i -= len(m.Farmer) + copy(dAtA[i:], m.Farmer) + i = encodeVarintTx(dAtA, i, uint64(len(m.Farmer))) + i-- + dAtA[i] = 0x12 + } + if m.PoolId != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.PoolId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *MsgLiquidUnfarmResponse) 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 *MsgLiquidUnfarmResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgLiquidUnfarmResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgLiquidUnfarmAndWithdraw) 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 *MsgLiquidUnfarmAndWithdraw) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgLiquidUnfarmAndWithdraw) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.UnfarmingCoin.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if len(m.Farmer) > 0 { + i -= len(m.Farmer) + copy(dAtA[i:], m.Farmer) + i = encodeVarintTx(dAtA, i, uint64(len(m.Farmer))) + i-- + dAtA[i] = 0x12 + } + if m.PoolId != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.PoolId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *MsgLiquidUnfarmAndWithdrawResponse) 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 *MsgLiquidUnfarmAndWithdrawResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgLiquidUnfarmAndWithdrawResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgPlaceBid) 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 *MsgPlaceBid) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgPlaceBid) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.BiddingCoin.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + if len(m.Bidder) > 0 { + i -= len(m.Bidder) + copy(dAtA[i:], m.Bidder) + i = encodeVarintTx(dAtA, i, uint64(len(m.Bidder))) + i-- + dAtA[i] = 0x1a + } + if m.PoolId != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.PoolId)) + i-- + dAtA[i] = 0x10 + } + if m.AuctionId != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.AuctionId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *MsgPlaceBidResponse) 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 *MsgPlaceBidResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgPlaceBidResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgRefundBid) 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 *MsgRefundBid) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRefundBid) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Bidder) > 0 { + i -= len(m.Bidder) + copy(dAtA[i:], m.Bidder) + i = encodeVarintTx(dAtA, i, uint64(len(m.Bidder))) + i-- + dAtA[i] = 0x1a + } + if m.PoolId != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.PoolId)) + i-- + dAtA[i] = 0x10 + } + if m.AuctionId != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.AuctionId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *MsgRefundBidResponse) 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 *MsgRefundBidResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRefundBidResponse) 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 + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MsgLiquidFarm) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PoolId != 0 { + n += 1 + sovTx(uint64(m.PoolId)) + } + l = len(m.Farmer) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.FarmingCoin.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *MsgLiquidFarmResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgLiquidUnfarm) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PoolId != 0 { + n += 1 + sovTx(uint64(m.PoolId)) + } + l = len(m.Farmer) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.UnfarmingCoin.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *MsgLiquidUnfarmResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgLiquidUnfarmAndWithdraw) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PoolId != 0 { + n += 1 + sovTx(uint64(m.PoolId)) + } + l = len(m.Farmer) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.UnfarmingCoin.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *MsgLiquidUnfarmAndWithdrawResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgPlaceBid) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.AuctionId != 0 { + n += 1 + sovTx(uint64(m.AuctionId)) + } + if m.PoolId != 0 { + n += 1 + sovTx(uint64(m.PoolId)) + } + l = len(m.Bidder) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.BiddingCoin.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *MsgPlaceBidResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgRefundBid) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.AuctionId != 0 { + n += 1 + sovTx(uint64(m.AuctionId)) + } + if m.PoolId != 0 { + n += 1 + sovTx(uint64(m.PoolId)) + } + l = len(m.Bidder) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgRefundBidResponse) 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 +} +func sozTx(x uint64) (n int) { + return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MsgLiquidFarm) 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: MsgLiquidFarm: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgLiquidFarm: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PoolId", wireType) + } + m.PoolId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PoolId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Farmer", 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.Farmer = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FarmingCoin", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.FarmingCoin.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 *MsgLiquidFarmResponse) 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: MsgLiquidFarmResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgLiquidFarmResponse: 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 (m *MsgLiquidUnfarm) 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: MsgLiquidUnfarm: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgLiquidUnfarm: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PoolId", wireType) + } + m.PoolId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PoolId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Farmer", 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.Farmer = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UnfarmingCoin", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.UnfarmingCoin.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 *MsgLiquidUnfarmResponse) 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: MsgLiquidUnfarmResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgLiquidUnfarmResponse: 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 (m *MsgLiquidUnfarmAndWithdraw) 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: MsgLiquidUnfarmAndWithdraw: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgLiquidUnfarmAndWithdraw: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PoolId", wireType) + } + m.PoolId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PoolId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Farmer", 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.Farmer = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UnfarmingCoin", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.UnfarmingCoin.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 *MsgLiquidUnfarmAndWithdrawResponse) 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: MsgLiquidUnfarmAndWithdrawResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgLiquidUnfarmAndWithdrawResponse: 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 (m *MsgPlaceBid) 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: MsgPlaceBid: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgPlaceBid: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field AuctionId", wireType) + } + m.AuctionId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.AuctionId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PoolId", wireType) + } + m.PoolId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PoolId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Bidder", 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.Bidder = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BiddingCoin", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.BiddingCoin.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 *MsgPlaceBidResponse) 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: MsgPlaceBidResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgPlaceBidResponse: 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 (m *MsgRefundBid) 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: MsgRefundBid: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRefundBid: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field AuctionId", wireType) + } + m.AuctionId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.AuctionId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PoolId", wireType) + } + m.PoolId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PoolId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Bidder", 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.Bidder = string(dAtA[iNdEx:postIndex]) + 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 *MsgRefundBidResponse) 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: MsgRefundBidResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRefundBidResponse: 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 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthTx + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupTx + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthTx + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthTx = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowTx = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group") +)