From a4aecf0aa7659861ddc780971348348eff417a8e Mon Sep 17 00:00:00 2001 From: jelysn <129082781+jelysn@users.noreply.github.com> Date: Fri, 26 Apr 2024 21:30:03 +0800 Subject: [PATCH] masterchef + e-staking module implementation (#435) * scaffold masterchef module * scaffold estaking module * bootstrap required proto/msgs/queries * hook functions for masterchef * ClaimRewards, token transfer on AddExternalIncentive, PendingRewards query * masterchef reward distribution update * external reward distribution * Integrate distribution module on app.go and add TODOs for estaking * Add whitelist feature for external incentive tokens & minimum amount configuration per external incentive & Add more query functions for frontend (e.g. queries on incentives - APR) * update on commitment hook management for Eden and EdenB * add update on wasmbinding and cli commands * add GetTokenPrice * update reward claim process for eden and edenB * add unit test for user reward info and abci todo * Resolve chain start issue on estaking module * cleanup eden validator pubkey variables * add update on external incentive APR, unit tests * update on masterchef unit test * implement estaking msgserver, queries, disable reward distribution in incentive module * implement missing hooks for estaking * add further test and fixes on masterchef * reward distribution logic on estaking * add TODO unit tesT * Refactor queries to fit into new estaking + masterchef data structure * fix issues after testing through cli command * removal of duplications in incentive and masterchef * add update for edenB rewards * Resolve single node start issue * update for EdenBoostApr field * Implement query for AllProgramRewards on incentive module & disable invariant * update on estaking+masterchef+commitment * add missing wasmbinding on estaking * add basic upgrade handler for commitment, incentive, masterchef, distribution * resolve issues in single node start * Resolve stablestake reward claim issue on masterchef * add incentive refactoring upgrade test script * add missing wasmbindings for estaking+masterchef * add unit test for estaking msgServer * update unit test for UpdateStakersRewards * Add unit test for estaking QueryRewards * prevent panics on hooks * Add unit test for Estaking ExtendedFunctions * Add unit test for masterchef abci * Move elys staked snapshot related codebase from incentive to estaking & resolve tests * fix hooks execution on incentive v11 migration * fix issue in v11 migration script * add query command for all rewards for a delegator * resolve unit tests * ci: software upgrade test fix * ci: fix upgrade-assure * ci: increase timeout to 10min * test: improve test scripts * ci: add flags to avoid port conflicts between nodes * fix cli command example text * remove max_eden_per_allocation on masterchef incentive info --------- Co-authored-by: Cosmic Vagabond <121588426+cosmic-vagabond@users.noreply.github.com> --- .github/workflows/software-upgrade-test.yml | 9 +- .github/workflows/test.yml | 11 +- Makefile | 7 +- app/ante.go | 6 +- app/app.go | 189 +- app/setup_handlers.go | 5 +- app/test_setup.go | 7 +- config.yml | 130 +- docs/static/openapi.yml | 3411 ++++++++++---- proto/elys/commitment/commitments.proto | 75 +- proto/elys/commitment/types_cw.proto | 6 - proto/elys/estaking/dex_rewards_tracker.proto | 23 + proto/elys/estaking/elys_staked.proto | 17 + proto/elys/estaking/genesis.proto | 14 + proto/elys/estaking/incentive.proto | 22 + proto/elys/estaking/params.proto | 28 + proto/elys/estaking/query.proto | 53 + proto/elys/estaking/tx.proto | 57 + proto/elys/incentive/dex_rewards_traker.proto | 37 +- proto/elys/incentive/distribution.proto | 16 - proto/elys/incentive/genesis.proto | 6 - proto/elys/incentive/incentive.proto | 56 +- proto/elys/incentive/params.proto | 20 +- proto/elys/incentive/pool.proto | 68 +- proto/elys/incentive/query.proto | 67 +- proto/elys/incentive/tx.proto | 69 - .../elys/masterchef/dex_rewards_traker.proto | 21 + .../elys/masterchef/external_incentive.proto | 17 + proto/elys/masterchef/genesis.proto | 18 + proto/elys/masterchef/incentive.proto | 22 + proto/elys/masterchef/params.proto | 49 + proto/elys/masterchef/pool.proto | 75 + proto/elys/masterchef/query.proto | 150 + proto/elys/masterchef/tx.proto | 71 + scripts/examples/estaking/estaking.sh | 28 + scripts/examples/incentive/upgrade.sh | 64 + scripts/examples/masterchef/masterchef.sh | 37 + scripts/upgrade-assure/get-flags.go | 28 + .../query-and-calc-upgrade-block-height.go | 2 +- scripts/upgrade-assure/start.go | 4 +- scripts/upgrade-assure/types.go | 5 +- scripts/upgrade-assure/update-genesis.go | 14 +- scripts/upgrade-assure/upgrade-assure.go | 24 +- testutil/keeper/estaking.go | 50 + testutil/keeper/incentive.go | 2 +- testutil/keeper/masterchef.go | 62 + .../client/register_custom_plugins.go | 22 +- .../types/custom_message_decorator.go | 6 + wasmbindings/types/new_query_plugin.go | 6 + wasmbindings/types/types.go | 65 +- x/amm/client/wasm/querier.go | 7 +- .../client/wasm/query_earn_mining_pool_all.go | 31 +- x/amm/keeper/estimate_price.go | 20 + x/amm/types/utils.go | 10 + x/commitment/client/wasm/querier.go | 4 - .../client/wasm/query_reward_balance.go | 35 - .../wasm/query_reward_sub_bucket_balance.go | 47 - x/commitment/keeper/claim_reward.go | 94 - x/commitment/keeper/claim_reward_test.go | 95 - x/commitment/keeper/commitments.go | 111 +- .../keeper/deposit_liquid_tokens_test.go | 3 +- x/commitment/keeper/hooks.go | 70 +- x/commitment/keeper/keeper.go | 144 +- x/commitment/keeper/msg_server_cancel_vest.go | 3 - .../msg_server_commit_claimed_rewards.go | 36 +- .../msg_server_commit_claimed_rewards_test.go | 8 +- .../keeper/msg_server_commit_liquid_tokens.go | 5 +- .../keeper/msg_server_uncommit_tokens.go | 37 +- .../keeper/msg_server_uncommit_tokens_test.go | 11 +- x/commitment/keeper/msg_server_vest.go | 3 - .../keeper/msg_server_vest_liquid_test.go | 1 - x/commitment/keeper/msg_server_vest_now.go | 3 - .../keeper/msg_server_vest_now_test.go | 4 +- x/commitment/keeper/msg_server_vest_test.go | 2 - x/commitment/keeper/params.go | 12 - x/commitment/migrations/v3_migration.go | 55 - x/commitment/types/commitments.go | 194 - x/commitment/types/commitments.pb.go | 1987 +-------- x/commitment/types/commitments_test.go | 14 +- x/commitment/types/expected_keepers.go | 9 +- x/commitment/types/interfaces.go | 12 +- x/commitment/types/params.go | 73 - x/commitment/types/types_cw.pb.go | 418 +- x/estaking/client/cli/query.go | 34 + x/estaking/client/cli/query_params.go | 64 + x/estaking/client/cli/tx.go | 26 + x/estaking/client/wasm/messenger.go | 36 + .../wasm/msg_withdraw_elys_staking_rewards.go | 69 + x/estaking/client/wasm/msg_withdraw_reward.go | 70 + x/estaking/client/wasm/querier.go | 60 + x/estaking/keeper/abci.go | 202 + x/estaking/keeper/abci_test.go | 80 + x/estaking/keeper/elys_stake_change.go | 36 + x/estaking/keeper/elys_staked.go | 51 + x/estaking/keeper/genesis.go | 58 + x/estaking/keeper/genesis_test.go | 27 + x/estaking/keeper/hooks.go | 134 + .../keeper/hooks_staking.go | 2 +- x/estaking/keeper/keeper.go | 305 ++ .../keeper/keeper_burn_edenB.go | 39 +- .../keeper/keeper_burn_edenB_test.go | 62 +- .../keeper/keeper_shares.go | 48 +- x/estaking/keeper/keeper_shares_test.go | 26 + x/estaking/keeper/keeper_test.go | 85 + x/estaking/keeper/msg_server.go | 70 + x/estaking/keeper/msg_server_test.go | 248 ++ x/estaking/keeper/params.go | 26 + x/estaking/keeper/params_test.go | 18 + x/estaking/keeper/query.go | 52 + x/estaking/keeper/query_params.go | 19 + .../keeper/query_params_test.go} | 4 +- x/estaking/keeper/query_test.go | 77 + x/estaking/module.go | 150 + x/estaking/module_simulation.go | 64 + x/estaking/modules/distribution/module.go | 113 + x/estaking/modules/staking/module.go | 63 + x/estaking/simulation/helpers.go | 15 + x/estaking/types/codec.go | 33 + x/estaking/types/dex_rewards_tracker.pb.go | 399 ++ x/estaking/types/elys_staked.pb.go | 396 ++ x/estaking/types/errors.go | 12 + x/estaking/types/expected_keepers.go | 76 + x/estaking/types/genesis.go | 24 + x/estaking/types/genesis.pb.go | 386 ++ x/estaking/types/genesis_test.go | 41 + x/estaking/types/incentive.pb.go | 470 ++ x/estaking/types/keys.go | 36 + x/estaking/types/msgs.go | 109 + x/estaking/types/params.go | 32 + x/estaking/types/params.pb.go | 592 +++ x/estaking/types/query.pb.go | 1237 +++++ x/estaking/types/query.pb.gw.go | 246 + x/estaking/types/tx.pb.go | 1433 ++++++ x/estaking/types/types.go | 1 + x/incentive/client/cli/queries.go | 92 - x/incentive/client/cli/query.go | 3 - x/incentive/client/cli/tx.go | 96 +- .../client/cli/tx_update_incentive_params.go | 120 - .../cli/tx_update_incentive_params_test.go | 46 - x/incentive/client/wasm/messenger.go | 4 - .../client/wasm/msg_withdraw_rewards.go | 67 - .../wasm/msg_withdraw_validator_commission.go | 72 - x/incentive/client/wasm/querier.go | 8 +- .../client/wasm/query_all_program_rewards.go | 22 + .../client/wasm/query_community_pool.go | 22 - x/incentive/client/wasm/query_params.go | 22 - x/incentive/client/wasm/query_pool_aprs.go | 22 - x/incentive/keeper/abci.go | 220 - x/incentive/keeper/abci_test.go | 126 - x/incentive/keeper/alias_functions.go | 10 - x/incentive/keeper/apr.go | 80 +- x/incentive/keeper/estimate_price.go | 45 - x/incentive/keeper/fee_pool.go | 30 - x/incentive/keeper/genesis.go | 7 +- x/incentive/keeper/hooks_commitment.go | 39 - x/incentive/keeper/keeper.go | 568 +-- .../keeper/keeper_apr_per_pool_test.go | 116 - x/incentive/keeper/keeper_fees.go | 147 - x/incentive/keeper/keeper_lps.go | 140 - x/incentive/keeper/keeper_lps_test.go | 186 - x/incentive/keeper/keeper_shares_test.go | 100 - x/incentive/keeper/keeper_stable_stake_lps.go | 125 - x/incentive/keeper/keeper_stakers.go | 77 - x/incentive/keeper/keeper_stakers_test.go | 103 - x/incentive/keeper/keeper_test.go | 59 +- x/incentive/keeper/keeper_withdraw.go | 257 -- x/incentive/keeper/keeper_withdraw_test.go | 164 - x/incentive/keeper/msg_server.go | 80 - .../msg_server_update_incentive_params.go | 29 - .../msg_server_update_pool_multipliers.go | 22 - x/incentive/keeper/params.go | 196 - x/incentive/keeper/params_test.go | 132 - x/incentive/keeper/queries.go | 85 +- x/incentive/keeper/store.go | 24 - x/incentive/migrations/new_migrator.go | 28 +- x/incentive/migrations/v10_migration.go | 12 - x/incentive/migrations/v11_migration.go | 154 + x/incentive/migrations/v2_migration.go | 11 - x/incentive/migrations/v3_migration.go | 11 - x/incentive/migrations/v4_migration.go | 11 - x/incentive/migrations/v5_migration.go | 11 - x/incentive/migrations/v6_migration.go | 11 - x/incentive/migrations/v7_migration.go | 11 - x/incentive/migrations/v8_migration.go | 11 - x/incentive/migrations/v9_migration.go | 42 - x/incentive/module.go | 28 +- x/incentive/module_simulation.go | 5 - .../simulation/update_incentive_params.go | 29 - x/incentive/spec/02_state.md | 47 - x/incentive/types/codec.go | 7 +- x/incentive/types/dex_rewards_traker.pb.go | 9 +- x/incentive/types/distribution.pb.go | 365 -- x/incentive/types/expected_keepers.go | 17 +- x/incentive/types/feel_pool.go | 23 - x/incentive/types/genesis.go | 18 +- x/incentive/types/genesis.pb.go | 138 +- x/incentive/types/incentive.pb.go | 2 +- .../types/message_update_incentive_params.go | 75 - .../message_update_incentive_params_test.go | 53 - x/incentive/types/msg.go | 78 - x/incentive/types/params.go | 251 +- x/incentive/types/params.pb.go | 6 +- x/incentive/types/params_test.go | 35 - x/incentive/types/query.pb.go | 1583 ++----- x/incentive/types/query.pb.gw.go | 192 +- x/incentive/types/tx.pb.go | 2090 +-------- x/incentive/types/types.go | 28 - x/masterchef/client/cli/query.go | 33 + x/masterchef/client/cli/query_cmds.go | 253 ++ x/masterchef/client/cli/tx.go | 47 + x/masterchef/client/cli/tx_cmds.go | 308 ++ x/masterchef/client/wasm/messenger.go | 44 + x/masterchef/client/wasm/msg_claim_rewards.go | 70 + x/masterchef/client/wasm/querier.go | 153 + x/masterchef/genesis.go | 43 + x/masterchef/genesis_test.go | 29 + x/masterchef/keeper/abci.go | 632 +++ .../keeper/abci_test.go} | 129 +- .../keeper/apr_pool.go} | 18 +- .../keeper/apr_pool_test.go} | 22 +- x/masterchef/keeper/apr_stable_stake.go | 80 + x/masterchef/keeper/external_incentive.go | 67 + .../keeper/external_incentive_test.go | 60 + .../keeper/hooks_amm.go | 25 +- x/masterchef/keeper/hooks_masterchef.go | 124 + x/masterchef/keeper/hooks_masterchef_test.go | 311 ++ x/masterchef/keeper/hooks_stablestake.go | 29 + x/masterchef/keeper/hooks_user_actions.go | 85 + x/masterchef/keeper/keeper.go | 74 + x/masterchef/keeper/msg_server.go | 188 + x/masterchef/keeper/msg_server_test.go | 23 + x/masterchef/keeper/params.go | 26 + x/masterchef/keeper/params_test.go | 18 + x/masterchef/keeper/pool.go | 63 + x/masterchef/keeper/pool_reward_info.go | 46 + x/masterchef/keeper/pool_reward_info_test.go | 52 + x/masterchef/keeper/pool_test.go | 162 + x/masterchef/keeper/query.go | 125 + x/masterchef/keeper/query_params.go | 19 + x/masterchef/keeper/query_params_test.go | 21 + x/masterchef/keeper/user_reward_info.go | 46 + x/masterchef/keeper/user_reward_info_test.go | 58 + x/masterchef/module.go | 151 + x/masterchef/module_simulation.go | 64 + x/masterchef/simulation/helpers.go | 15 + x/masterchef/types/codec.go | 37 + x/masterchef/types/dex_rewards_traker.pb.go | 397 ++ x/masterchef/types/errors.go | 12 + x/masterchef/types/expected_keepers.go | 136 + x/masterchef/types/external_incentive.pb.go | 516 +++ x/masterchef/types/genesis.go | 24 + x/masterchef/types/genesis.pb.go | 577 +++ x/masterchef/types/genesis_test.go | 33 + x/masterchef/types/incentive.pb.go | 470 ++ x/masterchef/types/keys.go | 92 + .../types/message_add_external_incentive.go | 41 + .../message_add_external_reward_denom.go | 41 + x/masterchef/types/message_claim_rewards.go | 41 + .../types/message_update_incentive_params.go | 41 + .../types/message_update_pool_multipliers.go | 17 +- x/masterchef/types/params.go | 122 + x/masterchef/types/params.pb.go | 875 ++++ x/masterchef/types/pool.pb.go | 1409 ++++++ x/masterchef/types/query.pb.go | 3964 +++++++++++++++++ x/masterchef/types/query.pb.gw.go | 726 +++ x/masterchef/types/tx.pb.go | 2619 +++++++++++ x/masterchef/types/types.go | 20 + x/stablestake/keeper/hooks.go | 38 + x/stablestake/keeper/keeper.go | 12 + x/stablestake/keeper/msg_server_bond.go | 11 +- x/stablestake/keeper/msg_server_unbond.go | 7 + x/stablestake/types/interfaces.go | 12 + 272 files changed, 29313 insertions(+), 12610 deletions(-) create mode 100644 proto/elys/estaking/dex_rewards_tracker.proto create mode 100644 proto/elys/estaking/elys_staked.proto create mode 100644 proto/elys/estaking/genesis.proto create mode 100644 proto/elys/estaking/incentive.proto create mode 100644 proto/elys/estaking/params.proto create mode 100644 proto/elys/estaking/query.proto create mode 100644 proto/elys/estaking/tx.proto delete mode 100644 proto/elys/incentive/distribution.proto create mode 100644 proto/elys/masterchef/dex_rewards_traker.proto create mode 100644 proto/elys/masterchef/external_incentive.proto create mode 100644 proto/elys/masterchef/genesis.proto create mode 100644 proto/elys/masterchef/incentive.proto create mode 100644 proto/elys/masterchef/params.proto create mode 100644 proto/elys/masterchef/pool.proto create mode 100644 proto/elys/masterchef/query.proto create mode 100644 proto/elys/masterchef/tx.proto create mode 100644 scripts/examples/estaking/estaking.sh create mode 100644 scripts/examples/incentive/upgrade.sh create mode 100644 scripts/examples/masterchef/masterchef.sh create mode 100644 testutil/keeper/estaking.go create mode 100644 testutil/keeper/masterchef.go delete mode 100644 x/commitment/client/wasm/query_reward_balance.go delete mode 100644 x/commitment/client/wasm/query_reward_sub_bucket_balance.go delete mode 100644 x/commitment/keeper/claim_reward.go delete mode 100644 x/commitment/keeper/claim_reward_test.go create mode 100644 x/estaking/client/cli/query.go create mode 100644 x/estaking/client/cli/query_params.go create mode 100644 x/estaking/client/cli/tx.go create mode 100644 x/estaking/client/wasm/messenger.go create mode 100644 x/estaking/client/wasm/msg_withdraw_elys_staking_rewards.go create mode 100644 x/estaking/client/wasm/msg_withdraw_reward.go create mode 100644 x/estaking/client/wasm/querier.go create mode 100644 x/estaking/keeper/abci.go create mode 100644 x/estaking/keeper/abci_test.go create mode 100644 x/estaking/keeper/elys_stake_change.go create mode 100644 x/estaking/keeper/elys_staked.go create mode 100644 x/estaking/keeper/genesis.go create mode 100644 x/estaking/keeper/genesis_test.go create mode 100644 x/estaking/keeper/hooks.go rename x/{incentive => estaking}/keeper/hooks_staking.go (97%) create mode 100644 x/estaking/keeper/keeper.go rename x/{incentive => estaking}/keeper/keeper_burn_edenB.go (73%) rename x/{incentive => estaking}/keeper/keeper_burn_edenB_test.go (64%) rename x/{incentive => estaking}/keeper/keeper_shares.go (51%) create mode 100644 x/estaking/keeper/keeper_shares_test.go create mode 100644 x/estaking/keeper/keeper_test.go create mode 100644 x/estaking/keeper/msg_server.go create mode 100644 x/estaking/keeper/msg_server_test.go create mode 100644 x/estaking/keeper/params.go create mode 100644 x/estaking/keeper/params_test.go create mode 100644 x/estaking/keeper/query.go create mode 100644 x/estaking/keeper/query_params.go rename x/{incentive/keeper/queries_test.go => estaking/keeper/query_params_test.go} (83%) create mode 100644 x/estaking/keeper/query_test.go create mode 100644 x/estaking/module.go create mode 100644 x/estaking/module_simulation.go create mode 100644 x/estaking/modules/distribution/module.go create mode 100644 x/estaking/modules/staking/module.go create mode 100644 x/estaking/simulation/helpers.go create mode 100644 x/estaking/types/codec.go create mode 100644 x/estaking/types/dex_rewards_tracker.pb.go create mode 100644 x/estaking/types/elys_staked.pb.go create mode 100644 x/estaking/types/errors.go create mode 100644 x/estaking/types/expected_keepers.go create mode 100644 x/estaking/types/genesis.go create mode 100644 x/estaking/types/genesis.pb.go create mode 100644 x/estaking/types/genesis_test.go create mode 100644 x/estaking/types/incentive.pb.go create mode 100644 x/estaking/types/keys.go create mode 100644 x/estaking/types/msgs.go create mode 100644 x/estaking/types/params.go create mode 100644 x/estaking/types/params.pb.go create mode 100644 x/estaking/types/query.pb.go create mode 100644 x/estaking/types/query.pb.gw.go create mode 100644 x/estaking/types/tx.pb.go create mode 100644 x/estaking/types/types.go delete mode 100644 x/incentive/client/cli/tx_update_incentive_params.go delete mode 100644 x/incentive/client/cli/tx_update_incentive_params_test.go delete mode 100644 x/incentive/client/wasm/msg_withdraw_rewards.go delete mode 100644 x/incentive/client/wasm/msg_withdraw_validator_commission.go create mode 100644 x/incentive/client/wasm/query_all_program_rewards.go delete mode 100644 x/incentive/client/wasm/query_community_pool.go delete mode 100644 x/incentive/client/wasm/query_params.go delete mode 100644 x/incentive/client/wasm/query_pool_aprs.go delete mode 100644 x/incentive/keeper/abci_test.go delete mode 100644 x/incentive/keeper/alias_functions.go delete mode 100644 x/incentive/keeper/estimate_price.go delete mode 100644 x/incentive/keeper/fee_pool.go delete mode 100644 x/incentive/keeper/hooks_commitment.go delete mode 100644 x/incentive/keeper/keeper_apr_per_pool_test.go delete mode 100644 x/incentive/keeper/keeper_fees.go delete mode 100644 x/incentive/keeper/keeper_lps.go delete mode 100644 x/incentive/keeper/keeper_lps_test.go delete mode 100644 x/incentive/keeper/keeper_shares_test.go delete mode 100644 x/incentive/keeper/keeper_stable_stake_lps.go delete mode 100644 x/incentive/keeper/keeper_stakers.go delete mode 100644 x/incentive/keeper/keeper_stakers_test.go delete mode 100644 x/incentive/keeper/keeper_withdraw.go delete mode 100644 x/incentive/keeper/keeper_withdraw_test.go delete mode 100644 x/incentive/keeper/msg_server_update_incentive_params.go delete mode 100644 x/incentive/keeper/msg_server_update_pool_multipliers.go delete mode 100644 x/incentive/keeper/params_test.go delete mode 100644 x/incentive/keeper/store.go delete mode 100644 x/incentive/migrations/v10_migration.go create mode 100644 x/incentive/migrations/v11_migration.go delete mode 100644 x/incentive/migrations/v2_migration.go delete mode 100644 x/incentive/migrations/v3_migration.go delete mode 100644 x/incentive/migrations/v4_migration.go delete mode 100644 x/incentive/migrations/v5_migration.go delete mode 100644 x/incentive/migrations/v6_migration.go delete mode 100644 x/incentive/migrations/v7_migration.go delete mode 100644 x/incentive/migrations/v8_migration.go delete mode 100644 x/incentive/migrations/v9_migration.go delete mode 100644 x/incentive/simulation/update_incentive_params.go delete mode 100644 x/incentive/types/distribution.pb.go delete mode 100644 x/incentive/types/feel_pool.go delete mode 100644 x/incentive/types/message_update_incentive_params.go delete mode 100644 x/incentive/types/message_update_incentive_params_test.go delete mode 100644 x/incentive/types/params_test.go create mode 100644 x/masterchef/client/cli/query.go create mode 100644 x/masterchef/client/cli/query_cmds.go create mode 100644 x/masterchef/client/cli/tx.go create mode 100644 x/masterchef/client/cli/tx_cmds.go create mode 100644 x/masterchef/client/wasm/messenger.go create mode 100644 x/masterchef/client/wasm/msg_claim_rewards.go create mode 100644 x/masterchef/client/wasm/querier.go create mode 100644 x/masterchef/genesis.go create mode 100644 x/masterchef/genesis_test.go create mode 100644 x/masterchef/keeper/abci.go rename x/{incentive/keeper/keeper_fees_test.go => masterchef/keeper/abci_test.go} (59%) rename x/{incentive/keeper/pool_apr.go => masterchef/keeper/apr_pool.go} (54%) rename x/{incentive/keeper/pool_apr_test.go => masterchef/keeper/apr_pool_test.go} (80%) create mode 100644 x/masterchef/keeper/apr_stable_stake.go create mode 100644 x/masterchef/keeper/external_incentive.go create mode 100644 x/masterchef/keeper/external_incentive_test.go rename x/{incentive => masterchef}/keeper/hooks_amm.go (75%) create mode 100644 x/masterchef/keeper/hooks_masterchef.go create mode 100644 x/masterchef/keeper/hooks_masterchef_test.go create mode 100644 x/masterchef/keeper/hooks_stablestake.go create mode 100644 x/masterchef/keeper/hooks_user_actions.go create mode 100644 x/masterchef/keeper/keeper.go create mode 100644 x/masterchef/keeper/msg_server.go create mode 100644 x/masterchef/keeper/msg_server_test.go create mode 100644 x/masterchef/keeper/params.go create mode 100644 x/masterchef/keeper/params_test.go create mode 100644 x/masterchef/keeper/pool.go create mode 100644 x/masterchef/keeper/pool_reward_info.go create mode 100644 x/masterchef/keeper/pool_reward_info_test.go create mode 100644 x/masterchef/keeper/pool_test.go create mode 100644 x/masterchef/keeper/query.go create mode 100644 x/masterchef/keeper/query_params.go create mode 100644 x/masterchef/keeper/query_params_test.go create mode 100644 x/masterchef/keeper/user_reward_info.go create mode 100644 x/masterchef/keeper/user_reward_info_test.go create mode 100644 x/masterchef/module.go create mode 100644 x/masterchef/module_simulation.go create mode 100644 x/masterchef/simulation/helpers.go create mode 100644 x/masterchef/types/codec.go create mode 100644 x/masterchef/types/dex_rewards_traker.pb.go create mode 100644 x/masterchef/types/errors.go create mode 100644 x/masterchef/types/expected_keepers.go create mode 100644 x/masterchef/types/external_incentive.pb.go create mode 100644 x/masterchef/types/genesis.go create mode 100644 x/masterchef/types/genesis.pb.go create mode 100644 x/masterchef/types/genesis_test.go create mode 100644 x/masterchef/types/incentive.pb.go create mode 100644 x/masterchef/types/keys.go create mode 100644 x/masterchef/types/message_add_external_incentive.go create mode 100644 x/masterchef/types/message_add_external_reward_denom.go create mode 100644 x/masterchef/types/message_claim_rewards.go create mode 100644 x/masterchef/types/message_update_incentive_params.go rename x/{incentive => masterchef}/types/message_update_pool_multipliers.go (59%) create mode 100644 x/masterchef/types/params.go create mode 100644 x/masterchef/types/params.pb.go create mode 100644 x/masterchef/types/pool.pb.go create mode 100644 x/masterchef/types/query.pb.go create mode 100644 x/masterchef/types/query.pb.gw.go create mode 100644 x/masterchef/types/tx.pb.go create mode 100644 x/masterchef/types/types.go create mode 100644 x/stablestake/keeper/hooks.go create mode 100644 x/stablestake/types/interfaces.go diff --git a/.github/workflows/software-upgrade-test.yml b/.github/workflows/software-upgrade-test.yml index 06134c7e2..b6a3f3968 100644 --- a/.github/workflows/software-upgrade-test.yml +++ b/.github/workflows/software-upgrade-test.yml @@ -6,6 +6,7 @@ on: jobs: software-upgrade-test: runs-on: ubuntu-latest + timeout-minutes: 60 steps: - name: Checkout repository @@ -52,14 +53,12 @@ jobs: - name: Chain initialization run: | - # disabled this line temporarily as v0.29.31 types.go commitment vesting info structure is different - # TODO: restore this line before v0.29.32 is released - # cp -a scripts/upgrade-assure/types.go scripts/upgrade-assure-skip/types.go - go run ./scripts/upgrade-assure-skip/... $SNAPSHOT_PATH $OLD_BINARY_PATH $NEW_BINARY_PATH --skip-node-start + cp -a scripts/upgrade-assure/types.go scripts/upgrade-assure-skip/types.go + GOMEMLIMIT=16GiB go run ./scripts/upgrade-assure-skip/... $SNAPSHOT_PATH $OLD_BINARY_PATH $NEW_BINARY_PATH --skip-node-start - name: Check out new branch run: git checkout ${{ github.head_ref }} - name: Software upgrade run: | - go run ./scripts/upgrade-assure/... $SNAPSHOT_PATH $OLD_BINARY_PATH $NEW_BINARY_PATH --skip-snapshot --skip-chain-init + GOMEMLIMIT=16GiB go run ./scripts/upgrade-assure/... $SNAPSHOT_PATH $OLD_BINARY_PATH $NEW_BINARY_PATH --skip-snapshot --skip-chain-init diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8aed086ff..05a7f2600 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,12 +1,3 @@ -# This workflow file defines a job named test that runs on Ubuntu and is triggered -# on push and pull request events. -# -# The job checks out the repository code, sets up Go with version 1.20, installs -# the project dependencies, and runs the unit tests using `go test`. -# -# The purpose of this workflow file is to automate the process of running unit tests -# for the Elys codebase whenever code changes are pushed or a pull request is opened. - name: Run unit tests on: push @@ -29,4 +20,4 @@ jobs: - name: Run unit tests run: | - go test ./... + make ci-test-unit diff --git a/Makefile b/Makefile index 12f91b651..693ea63fc 100644 --- a/Makefile +++ b/Makefile @@ -95,13 +95,18 @@ test-unit: @echo Running unit tests... @GOFLAGS=$(GOFLAGS) go test -race -failfast -v ./... +## ci-test-unit: Run unit tests +ci-test-unit: + @echo Running unit tests via CI... + @GOFLAGS=$(GOFLAGS) GOMEMLIMIT=16GiB go test -race -cpu=4 -failfast -v ./... + ## clean: Clean build files. Runs `go clean` internally. clean: @echo Cleaning build cache... @rm -rf $(BUILD_FOLDER) 2> /dev/null @go clean ./... -.PHONY: mocks test-unit clean +.PHONY: mocks test-unit ci-test-unit clean ## go-mod-cache: Retrieve the go modules and store them in the local cache go-mod-cache: go.sum diff --git a/app/ante.go b/app/ante.go index 2f0eb4a88..2bed114c6 100644 --- a/app/ante.go +++ b/app/ante.go @@ -139,7 +139,7 @@ func (min MinCommissionDecorator) AnteHandle( return errorsmod.Wrap(sdkerrors.ErrUnauthorized, "commission can't be lower than 5%") } projectedVotingPower := min.CalculateValidatorProjectedVotingPower(ctx, sdk.NewDecFromInt(msg.Value.Amount)) - if projectedVotingPower.GTE(maxVotingPower) { + if projectedVotingPower.GT(maxVotingPower) { return errorsmod.Wrapf( sdkerrors.ErrInvalidRequest, "This validator has a voting power of %s%%. Delegations not allowed to a validator whose post-delegation voting power is more than %s%%. Please delegate to a validator with less bonded tokens", projectedVotingPower.Mul(sdk.NewDec(100)), maxVotingPower.Mul(sdk.NewDec(100))) @@ -160,7 +160,7 @@ func (min MinCommissionDecorator) AnteHandle( } projectedVotingPower := min.CalculateDelegateProjectedVotingPower(ctx, val, sdk.NewDecFromInt(msg.Amount.Amount)) - if projectedVotingPower.GTE(maxVotingPower) { + if projectedVotingPower.GT(maxVotingPower) { return errorsmod.Wrapf( sdkerrors.ErrInvalidRequest, "This validator has a voting power of %s%%. Delegations not allowed to a validator whose post-delegation voting power is more than %s%%. Please delegate to a validator with less bonded tokens", projectedVotingPower.Mul(sdk.NewDec(100)), maxVotingPower.Mul(sdk.NewDec(100))) @@ -181,7 +181,7 @@ func (min MinCommissionDecorator) AnteHandle( } projectedVotingPower := min.CalculateRedelegateProjectedVotingPower(ctx, dstVal, delegateAmount) - if projectedVotingPower.GTE(maxVotingPower) { + if projectedVotingPower.GT(maxVotingPower) { return errorsmod.Wrapf( sdkerrors.ErrInvalidRequest, "This validator has a voting power of %s%%. Delegations not allowed to a validator whose post-delegation voting power is more than %s%%. Please redelegate to a validator with less bonded tokens", projectedVotingPower.Mul(sdk.NewDec(100)), maxVotingPower.Mul(sdk.NewDec(100))) diff --git a/app/app.go b/app/app.go index 2090fabf4..0c244bd7a 100644 --- a/app/app.go +++ b/app/app.go @@ -57,6 +57,9 @@ import ( "github.com/cosmos/cosmos-sdk/x/crisis" crisiskeeper "github.com/cosmos/cosmos-sdk/x/crisis/keeper" crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types" + distr "github.com/cosmos/cosmos-sdk/x/distribution" + distrkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper" + distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" "github.com/cosmos/cosmos-sdk/x/evidence" evidencekeeper "github.com/cosmos/cosmos-sdk/x/evidence/keeper" evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types" @@ -113,7 +116,6 @@ import ( ibcclientclient "github.com/cosmos/ibc-go/v7/modules/core/02-client/client" ibcclienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" ibcporttypes "github.com/cosmos/ibc-go/v7/modules/core/05-port/types" - porttypes "github.com/cosmos/ibc-go/v7/modules/core/05-port/types" ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported" ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper" solomachine "github.com/cosmos/ibc-go/v7/modules/light-clients/06-solomachine" @@ -129,6 +131,8 @@ import ( epochsmodule "github.com/elys-network/elys/x/epochs" epochsmodulekeeper "github.com/elys-network/elys/x/epochs/keeper" epochsmoduletypes "github.com/elys-network/elys/x/epochs/types" + exdistr "github.com/elys-network/elys/x/estaking/modules/distribution" + exstaking "github.com/elys-network/elys/x/estaking/modules/staking" oraclemodule "github.com/elys-network/elys/x/oracle" oraclekeeper "github.com/elys-network/elys/x/oracle/keeper" oracletypes "github.com/elys-network/elys/x/oracle/types" @@ -182,6 +186,13 @@ import ( leveragelpmodulekeeper "github.com/elys-network/elys/x/leveragelp/keeper" leveragelpmoduletypes "github.com/elys-network/elys/x/leveragelp/types" + estakingmodule "github.com/elys-network/elys/x/estaking" + estakingmodulekeeper "github.com/elys-network/elys/x/estaking/keeper" + estakingmoduletypes "github.com/elys-network/elys/x/estaking/types" + masterchefmodule "github.com/elys-network/elys/x/masterchef" + masterchefmodulekeeper "github.com/elys-network/elys/x/masterchef/keeper" + masterchefmoduletypes "github.com/elys-network/elys/x/masterchef/types" + // this line is used by starport scaffolding # stargate/app/moduleImport "github.com/elys-network/elys/docs" @@ -191,9 +202,6 @@ const ( AccountAddressPrefix = "elys" Name = "elys" - // Dex revenue consolidating wallet - DexRevenueCollectorName = "dexRevenueCollector" - // If EnabledSpecificProposals is "", and this is "true", then enable all x/wasm proposals. // If EnabledSpecificProposals is "", and this is not "true", then disable all x/wasm proposals. ProposalsEnabled = "false" @@ -253,6 +261,7 @@ var ( capability.AppModuleBasic{}, staking.AppModuleBasic{}, mint.AppModuleBasic{}, + distr.AppModuleBasic{}, gov.NewAppModuleBasic(getGovProposalHandlers()), params.AppModuleBasic{}, crisis.AppModuleBasic{}, @@ -285,13 +294,15 @@ var ( clockmodule.AppModuleBasic{}, stablestake.AppModuleBasic{}, leveragelpmodule.AppModuleBasic{}, + masterchefmodule.AppModuleBasic{}, + estakingmodule.AppModuleBasic{}, // this line is used by starport scaffolding # stargate/app/moduleBasic ) // module account permissions maccPerms = map[string][]string{ authtypes.FeeCollectorName: nil, - DexRevenueCollectorName: nil, + distrtypes.ModuleName: nil, icatypes.ModuleName: nil, ibcfeetypes.ModuleName: nil, minttypes.ModuleName: {authtypes.Minter}, @@ -305,6 +316,7 @@ var ( ammmoduletypes.ModuleName: {authtypes.Minter, authtypes.Burner, authtypes.Staking}, wasmmoduletypes.ModuleName: {authtypes.Burner}, stablestaketypes.ModuleName: {authtypes.Minter, authtypes.Burner}, + masterchefmoduletypes.ModuleName: {}, // this line is used by starport scaffolding # stargate/app/maccPerms } ) @@ -347,6 +359,7 @@ type ElysApp struct { StakingKeeper *stakingkeeper.Keeper SlashingKeeper slashingkeeper.Keeper MintKeeper mintkeeper.Keeper + DistrKeeper distrkeeper.Keeper GovKeeper govkeeper.Keeper CrisisKeeper *crisiskeeper.Keeper UpgradeKeeper *upgradekeeper.Keeper @@ -389,6 +402,10 @@ type ElysApp struct { StablestakeKeeper stablestakekeeper.Keeper LeveragelpKeeper leveragelpmodulekeeper.Keeper + + MasterchefKeeper masterchefmodulekeeper.Keeper + + EstakingKeeper estakingmodulekeeper.Keeper // this line is used by starport scaffolding # stargate/app/keeperDeclaration // mm is the module manager @@ -452,6 +469,7 @@ func NewElysApp( ibctransfertypes.StoreKey, icahosttypes.StoreKey, capabilitytypes.StoreKey, group.StoreKey, ibcfeetypes.StoreKey, icacontrollertypes.StoreKey, + distrtypes.StoreKey, wasmmodule.StoreKey, consensusparamtypes.StoreKey, epochsmoduletypes.StoreKey, @@ -469,6 +487,8 @@ func NewElysApp( clockmoduletypes.StoreKey, stablestaketypes.StoreKey, leveragelpmoduletypes.StoreKey, + masterchefmoduletypes.StoreKey, + estakingmoduletypes.StoreKey, // this line is used by starport scaffolding # stargate/app/storeKey ) tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey, ammmoduletypes.TStoreKey) @@ -552,6 +572,16 @@ func NewElysApp( authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) + app.AssetprofileKeeper = *assetprofilemodulekeeper.NewKeeper( + appCodec, + keys[assetprofilemoduletypes.StoreKey], + keys[assetprofilemoduletypes.MemStoreKey], + app.GetSubspace(assetprofilemoduletypes.ModuleName), + &app.TransferKeeper, + authtypes.NewModuleAddress(govtypes.ModuleName).String(), + ) + assetprofileModule := assetprofilemodule.NewAppModule(appCodec, app.AssetprofileKeeper, app.AccountKeeper, app.BankKeeper) + app.StakingKeeper = stakingkeeper.NewKeeper( appCodec, keys[stakingtypes.StoreKey], @@ -560,6 +590,42 @@ func NewElysApp( authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) + commitmentKeeper := *commitmentmodulekeeper.NewKeeper( + appCodec, + keys[commitmentmoduletypes.StoreKey], + keys[commitmentmoduletypes.MemStoreKey], + app.GetSubspace(commitmentmoduletypes.ModuleName), + + app.BankKeeper, + app.StakingKeeper, + app.AssetprofileKeeper, + authtypes.NewModuleAddress(govtypes.ModuleName).String(), + ) + + app.TokenomicsKeeper = *tokenomicsmodulekeeper.NewKeeper( + appCodec, + keys[tokenomicsmoduletypes.StoreKey], + keys[tokenomicsmoduletypes.MemStoreKey], + app.GetSubspace(tokenomicsmoduletypes.ModuleName), + &app.CommitmentKeeper, + authtypes.NewModuleAddress(govtypes.ModuleName).String(), + ) + tokenomicsModule := tokenomicsmodule.NewAppModule(appCodec, app.TokenomicsKeeper, app.AccountKeeper, app.BankKeeper) + + app.EstakingKeeper = *estakingmodulekeeper.NewKeeper( + appCodec, + keys[estakingmoduletypes.StoreKey], + keys[estakingmoduletypes.MemStoreKey], + app.StakingKeeper, + &app.CommitmentKeeper, + &app.DistrKeeper, + app.AssetprofileKeeper, + app.TokenomicsKeeper, + authtypes.NewModuleAddress(govtypes.ModuleName).String(), + ) + + estakingModule := estakingmodule.NewAppModule(appCodec, app.EstakingKeeper, app.AccountKeeper, app.BankKeeper) + app.MintKeeper = mintkeeper.NewKeeper( appCodec, keys[minttypes.StoreKey], @@ -574,7 +640,7 @@ func NewElysApp( appCodec, cdc, keys[slashingtypes.StoreKey], - app.StakingKeeper, + app.EstakingKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) @@ -706,33 +772,11 @@ func NewElysApp( oracleIBCModule := oraclemodule.NewIBCModule(app.OracleKeeper) - app.AssetprofileKeeper = *assetprofilemodulekeeper.NewKeeper( - appCodec, - keys[assetprofilemoduletypes.StoreKey], - keys[assetprofilemoduletypes.MemStoreKey], - app.GetSubspace(assetprofilemoduletypes.ModuleName), - &app.TransferKeeper, - authtypes.NewModuleAddress(govtypes.ModuleName).String(), - ) - assetprofileModule := assetprofilemodule.NewAppModule(appCodec, app.AssetprofileKeeper, app.AccountKeeper, app.BankKeeper) - app.EpochsKeeper = *epochsmodulekeeper.NewKeeper( appCodec, keys[epochsmoduletypes.StoreKey], ) - commitmentKeeper := *commitmentmodulekeeper.NewKeeper( - appCodec, - keys[commitmentmoduletypes.StoreKey], - keys[commitmentmoduletypes.MemStoreKey], - app.GetSubspace(commitmentmoduletypes.ModuleName), - - app.BankKeeper, - app.StakingKeeper, - app.AssetprofileKeeper, - authtypes.NewModuleAddress(govtypes.ModuleName).String(), - ) - app.AccountedPoolKeeper = *accountedpoolmodulekeeper.NewKeeper( appCodec, keys[accountedpoolmoduletypes.StoreKey], @@ -764,17 +808,45 @@ func NewElysApp( &app.CommitmentKeeper, app.AssetprofileKeeper, ) - stablestake := stablestake.NewAppModule(appCodec, app.StablestakeKeeper, app.AccountKeeper, app.BankKeeper) + app.CommitmentKeeper = *commitmentKeeper.SetHooks( + commitmentmodulekeeper.NewMultiCommitmentHooks( + app.EstakingKeeper.CommitmentHooks(), + ), + ) + commitmentModule := commitmentmodule.NewAppModule(appCodec, app.CommitmentKeeper, app.AccountKeeper, app.BankKeeper) - app.TokenomicsKeeper = *tokenomicsmodulekeeper.NewKeeper( + app.DistrKeeper = distrkeeper.NewKeeper( appCodec, - keys[tokenomicsmoduletypes.StoreKey], - keys[tokenomicsmoduletypes.MemStoreKey], - app.GetSubspace(tokenomicsmoduletypes.ModuleName), - &app.CommitmentKeeper, + keys[distrtypes.StoreKey], + app.AccountKeeper, + app.CommitmentKeeper, + app.EstakingKeeper, + authtypes.FeeCollectorName, authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) - tokenomicsModule := tokenomicsmodule.NewAppModule(appCodec, app.TokenomicsKeeper, app.AccountKeeper, app.BankKeeper) + + app.MasterchefKeeper = *masterchefmodulekeeper.NewKeeper( + appCodec, + keys[masterchefmoduletypes.StoreKey], + keys[masterchefmoduletypes.MemStoreKey], + app.GetSubspace(masterchefmoduletypes.ModuleName), + app.CommitmentKeeper, + app.AmmKeeper, + app.OracleKeeper, + app.AssetprofileKeeper, + app.AccountedPoolKeeper, + app.StablestakeKeeper, + app.TokenomicsKeeper, + app.AccountKeeper, + app.BankKeeper, + authtypes.NewModuleAddress(govtypes.ModuleName).String(), + ) + masterchefModule := masterchefmodule.NewAppModule(appCodec, app.MasterchefKeeper, app.AccountKeeper, app.BankKeeper) + + app.StablestakeKeeper = *app.StablestakeKeeper.SetHooks(stablestakekeeper.NewMultiStableStakeHooks( + app.MasterchefKeeper.StableStakeHooks(), + )) + stablestakeModule := stablestake.NewAppModule(appCodec, app.StablestakeKeeper, app.AccountKeeper, app.BankKeeper) app.IncentiveKeeper = *incentivemodulekeeper.NewKeeper( appCodec, @@ -788,22 +860,14 @@ func NewElysApp( app.OracleKeeper, app.AssetprofileKeeper, app.AccountedPoolKeeper, - app.EpochsKeeper, app.StablestakeKeeper, app.TokenomicsKeeper, + &app.MasterchefKeeper, + &app.EstakingKeeper, authtypes.FeeCollectorName, - DexRevenueCollectorName, authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) - incentiveModule := incentivemodule.NewAppModule(appCodec, app.IncentiveKeeper) - - app.CommitmentKeeper = *commitmentKeeper.SetHooks( - commitmentmodulekeeper.NewMultiEpochHooks( - app.IncentiveKeeper.CommitmentHooks(), - ), - ) - - commitmentModule := commitmentmodule.NewAppModule(appCodec, app.CommitmentKeeper, app.AccountKeeper, app.BankKeeper) + incentiveModule := incentivemodule.NewAppModule(appCodec, app.IncentiveKeeper, app.EstakingKeeper, app.MasterchefKeeper, app.DistrKeeper, app.CommitmentKeeper) app.BurnerKeeper = *burnermodulekeeper.NewKeeper( appCodec, @@ -848,6 +912,8 @@ func NewElysApp( app.StakingKeeper, &app.TokenomicsKeeper, &app.TransferhookKeeper, + &app.MasterchefKeeper, + &app.EstakingKeeper, ), wasmOpts..., ) @@ -858,7 +924,7 @@ func NewElysApp( app.AccountKeeper, app.BankKeeper, app.StakingKeeper, - nil, + distrkeeper.NewQuerier(app.DistrKeeper), app.IBCFeeKeeper, // ISC4 Wrapper: fee IBC middleware app.IBCKeeper.ChannelKeeper, &app.IBCKeeper.PortKeeper, @@ -968,7 +1034,7 @@ func NewElysApp( wasmStack = wasmmodule.NewIBCHandler(app.WasmKeeper, app.IBCKeeper.ChannelKeeper, app.IBCFeeKeeper) wasmStack = ibcfee.NewIBCMiddleware(wasmStack, app.IBCFeeKeeper) - var transferStack porttypes.IBCModule = transferIBCModule + var transferStack ibcporttypes.IBCModule = transferIBCModule transferStack = transferhook.NewIBCModule(app.TransferhookKeeper, transferStack) // Create static IBC router, add transfer route, then set and seal it @@ -984,11 +1050,12 @@ func NewElysApp( // register hooks after all modules have been initialized - app.StakingKeeper.SetHooks( + app.EstakingKeeper.SetHooks( stakingtypes.NewMultiStakingHooks( // insert staking hooks receivers here app.SlashingKeeper.Hooks(), - app.IncentiveKeeper.StakingHooks(), + app.DistrKeeper.Hooks(), + app.EstakingKeeper.StakingHooks(), ), ) @@ -1001,9 +1068,9 @@ func NewElysApp( app.AmmKeeper = *app.AmmKeeper.SetHooks( ammmoduletypes.NewMultiAmmHooks( // insert amm hooks receivers here - app.IncentiveKeeper.AmmHooks(), app.PerpetualKeeper.AmmHooks(), app.LeveragelpKeeper.AmmHooks(), + app.MasterchefKeeper.AmmHooks(), ), ) ammModule := ammmodule.NewAppModule(appCodec, app.AmmKeeper, app.AccountKeeper, app.BankKeeper) @@ -1052,7 +1119,8 @@ func NewElysApp( gov.NewAppModule(appCodec, &app.GovKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(govtypes.ModuleName)), mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper, nil, app.GetSubspace(minttypes.ModuleName)), slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.GetSubspace(slashingtypes.ModuleName)), - staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(stakingtypes.ModuleName)), + exdistr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.CommitmentKeeper, &app.EstakingKeeper, authtypes.FeeCollectorName, app.GetSubspace(distrtypes.ModuleName)), + exstaking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(stakingtypes.ModuleName)), upgrade.NewAppModule(app.UpgradeKeeper), evidence.NewAppModule(app.EvidenceKeeper), consensus.NewAppModule(appCodec, app.ConsensusParamsKeeper), @@ -1074,8 +1142,10 @@ func NewElysApp( accountedPoolModule, transferhookModule, clockModule, - stablestake, + stablestakeModule, leveragelpModule, + masterchefModule, + estakingModule, // this line is used by starport scaffolding # stargate/app/appModule ) @@ -1090,6 +1160,7 @@ func NewElysApp( // Note: epochs' begin should be "real" start of epochs, we keep epochs beginblock at the beginning epochsmoduletypes.ModuleName, minttypes.ModuleName, + distrtypes.ModuleName, stablestaketypes.ModuleName, incentivemoduletypes.ModuleName, slashingtypes.ModuleName, @@ -1122,6 +1193,8 @@ func NewElysApp( transferhooktypes.ModuleName, clockmoduletypes.ModuleName, leveragelpmoduletypes.ModuleName, + masterchefmoduletypes.ModuleName, + estakingmoduletypes.ModuleName, // this line is used by starport scaffolding # stargate/app/beginBlockers ) @@ -1138,6 +1211,7 @@ func NewElysApp( capabilitytypes.ModuleName, authtypes.ModuleName, banktypes.ModuleName, + distrtypes.ModuleName, stablestaketypes.ModuleName, incentivemoduletypes.ModuleName, slashingtypes.ModuleName, @@ -1163,6 +1237,8 @@ func NewElysApp( accountedpoolmoduletypes.ModuleName, transferhooktypes.ModuleName, leveragelpmoduletypes.ModuleName, + masterchefmoduletypes.ModuleName, + estakingmoduletypes.ModuleName, // this line is used by starport scaffolding # stargate/app/endBlockers ) @@ -1176,6 +1252,8 @@ func NewElysApp( capabilitytypes.ModuleName, authtypes.ModuleName, banktypes.ModuleName, + commitmentmoduletypes.ModuleName, + distrtypes.ModuleName, epochsmoduletypes.ModuleName, stablestaketypes.ModuleName, incentivemoduletypes.ModuleName, @@ -1198,7 +1276,6 @@ func NewElysApp( consensusparamtypes.ModuleName, assetprofilemoduletypes.ModuleName, oracletypes.ModuleName, - commitmentmoduletypes.ModuleName, tokenomicsmoduletypes.ModuleName, burnermoduletypes.ModuleName, ammmoduletypes.ModuleName, @@ -1208,6 +1285,8 @@ func NewElysApp( transferhooktypes.ModuleName, clockmoduletypes.ModuleName, leveragelpmoduletypes.ModuleName, + masterchefmoduletypes.ModuleName, + estakingmoduletypes.ModuleName, // this line is used by starport scaffolding # stargate/app/initGenesis } app.mm.SetOrderInitGenesis(genesisModuleOrder...) @@ -1486,6 +1565,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino paramsKeeper.Subspace(banktypes.ModuleName) paramsKeeper.Subspace(stakingtypes.ModuleName) paramsKeeper.Subspace(minttypes.ModuleName) + paramsKeeper.Subspace(distrtypes.ModuleName) paramsKeeper.Subspace(slashingtypes.ModuleName) paramsKeeper.Subspace(govtypes.ModuleName).WithKeyTable(govv1.ParamKeyTable()) paramsKeeper.Subspace(crisistypes.ModuleName) @@ -1503,6 +1583,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino paramsKeeper.Subspace(clockmoduletypes.ModuleName) paramsKeeper.Subspace(stablestaketypes.ModuleName) paramsKeeper.Subspace(leveragelpmoduletypes.ModuleName) + paramsKeeper.Subspace(masterchefmoduletypes.ModuleName) // this line is used by starport scaffolding # stargate/app/paramSubspace return paramsKeeper diff --git a/app/setup_handlers.go b/app/setup_handlers.go index 372de33e9..78e4559a9 100644 --- a/app/setup_handlers.go +++ b/app/setup_handlers.go @@ -5,9 +5,12 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" m "github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/cosmos-sdk/version" + distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" + estakingtypes "github.com/elys-network/elys/x/estaking/types" + mastercheftypes "github.com/elys-network/elys/x/masterchef/types" ) func SetupHandlers(app *ElysApp) { @@ -103,7 +106,7 @@ func loadUpgradeStore(app *ElysApp) { if shouldLoadUpgradeStore(app, upgradeInfo) { storeUpgrades := storetypes.StoreUpgrades{ - // Added: []string{}, + Added: []string{distrtypes.StoreKey, mastercheftypes.StoreKey, estakingtypes.StoreKey}, } // Use upgrade store loader for the initial loading of all stores when app starts, // it checks if version == upgradeHeight and applies store upgrades before loading the stores, diff --git a/app/test_setup.go b/app/test_setup.go index 67213a5b5..79f5c9970 100644 --- a/app/test_setup.go +++ b/app/test_setup.go @@ -246,14 +246,9 @@ func initAccountWithCoins(app *ElysApp, ctx sdk.Context, addr sdk.AccAddress, co } // Add testing commitments -func AddTestCommitment(app *ElysApp, ctx sdk.Context, address sdk.AccAddress, committed sdk.Coins, rewardsUnclaimed sdk.Coins) { +func AddTestCommitment(app *ElysApp, ctx sdk.Context, address sdk.AccAddress, committed sdk.Coins) { commitment := app.CommitmentKeeper.GetCommitments(ctx, address.String()) - // Loop unclaimed rewards - for _, uc := range rewardsUnclaimed { - commitment.AddRewardsUnclaimed(uc) - } - for _, c := range committed { commitment.AddCommittedTokens(c.Denom, c.Amount, uint64(ctx.BlockTime().Unix())) } diff --git a/config.yml b/config.yml index 81947b24d..56005f37c 100644 --- a/config.yml +++ b/config.yml @@ -3,6 +3,7 @@ accounts: - name: treasury coins: - 1000000000000uatom + - 1000000000000uinc - 1000000000000uusdc - 1000000000000uusdt - 9000000000000000uelys @@ -81,6 +82,12 @@ genesis: params: bond_denom: uelys unbonding_time: 1209600s + estaking: + params: + eden_commit_val: "" + edenb_commit_val: "" + max_eden_reward_apr_stakers: "0.3" + eden_boost_apr: "1.0" bank: denom_metadata: - base: uelys @@ -273,89 +280,33 @@ genesis: denom: ueden - amount: "10000" denom: uedenb - rewards_unclaimed: - - amount: "1000000" - denom: ueden - - amount: "1000000" - denom: uedenb - - amount: "1000000" - denom: uusdc vesting_tokens: [] - rewards_by_usdc_unclaimed: - - denom: ueden - amount: "200000" - - denom: uedenb - amount: "200000" - - denom: uusdc - amount: "200000" - rewards_by_elys_unclaimed: - - denom: ueden - amount: "300000" - - denom: uedenb - amount: "200000" - - denom: uusdc - amount: "300000" - rewards_by_eden_unclaimed: - - denom: ueden - amount: "300000" - - denom: uedenb - amount: "200000" - - denom: uusdc - amount: "300000" - rewards_by_edenb_unclaimed: - - denom: ueden - amount: "200000" - - denom: uedenb - amount: "200000" - - denom: uusdc - amount: "200000" - incentive: - params: - lp_incentives: null - stake_incentives: null - reward_portion_for_lps: "0.65" - pool_infos: [] - elys_stake_snap_interval: "10" - dex_rewards_stakers: - num_blocks: "0" - amount: "0" - amount_collected_by_other_tracker: "0" - dex_rewards_lps: - num_blocks: "0" - amount: "0" - amount_collected_by_other_tracker: "0" - max_eden_reward_apr_stakers: "0.30" - max_eden_reward_apr_lps: "0.30" - fee_pool: - community_pool: - - amount: "0" - denom: uelys tokenomics: airdropList: - intent: AtomStakers - amount: 9999999 + amount: 9999999000000 authority: elys10d07y265gmmuvt4z0w9aw880jnsr700j6z2zm3 - intent: RowanStakersLP - amount: 9999999 + amount: 9999999000000 authority: elys10d07y265gmmuvt4z0w9aw880jnsr700j6z2zm3 - intent: Juno - amount: 9999999 + amount: 9999999000000 authority: elys10d07y265gmmuvt4z0w9aw880jnsr700j6z2zm3 - intent: Osmo - amount: 9999999 + amount: 9999999000000 authority: elys10d07y265gmmuvt4z0w9aw880jnsr700j6z2zm3 - intent: Evmos - amount: 9999999 + amount: 9999999000000 authority: elys10d07y265gmmuvt4z0w9aw880jnsr700j6z2zm3 genesisInflation: inflation: - lmRewards: 9999999 - icsStakingRewards: 9999999 - communityFund: 9999999 - strategicReserve: 9999999 - teamTokensVested: 9999999 - seedVesting: 9999999 - strategicSalesVesting: 9999999 + lmRewards: 9999999000000 + icsStakingRewards: 9999999000000 + communityFund: 9999999000000 + strategicReserve: 9999999000000 + teamTokensVested: 9999999000000 + seedVesting: 9999999000000 + strategicSalesVesting: 9999999000000 authority: elys10d07y265gmmuvt4z0w9aw880jnsr700j6z2zm3 timeBasedInflationList: - startBlockHeight: 1 @@ -363,31 +314,31 @@ genesis: description: 1st Year Inflation authority: elys10d07y265gmmuvt4z0w9aw880jnsr700j6z2zm3 inflation: - lmRewards: 9999999 - icsStakingRewards: 9999999 - communityFund: 9999999 - strategicReserve: 9999999 - teamTokensVested: 9999999 + lmRewards: 9999999000000 + icsStakingRewards: 9999999000000 + communityFund: 9999999000000 + strategicReserve: 9999999000000 + teamTokensVested: 9999999000000 - startBlockHeight: 6307201 endBlockHeight: 12614401 description: 2nd Year Inflation authority: elys10d07y265gmmuvt4z0w9aw880jnsr700j6z2zm3 inflation: - lmRewards: 9999999 - icsStakingRewards: 9999999 - communityFund: 9999999 - strategicReserve: 9999999 - teamTokensVested: 9999999 + lmRewards: 9999999000000 + icsStakingRewards: 9999999000000 + communityFund: 9999999000000 + strategicReserve: 9999999000000 + teamTokensVested: 9999999000000 - startBlockHeight: 12614402 endBlockHeight: 18921602 description: 3rd Year Inflation authority: elys10d07y265gmmuvt4z0w9aw880jnsr700j6z2zm3 inflation: - lmRewards: 9999999 - icsStakingRewards: 9999999 - communityFund: 9999999 - strategicReserve: 9999999 - teamTokensVested: 9999999 + lmRewards: 9999999000000 + icsStakingRewards: 9999999000000 + communityFund: 9999999000000 + strategicReserve: 9999999000000 + teamTokensVested: 9999999000000 oracle: assetInfos: - denom: "satoshi" @@ -465,7 +416,7 @@ genesis: parameter: params: min_commission_rate: "0.05" - max_voting_power: "0.66" + max_voting_power: "1.00" min_self_delegation: "1" broker_address: "elys1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqnrec2l" perpetual: @@ -497,4 +448,15 @@ genesis: params: deposit_denom: "uusdc" redemption_rate: "1.000000000000000000" + masterchef: + params: + supported_reward_denoms: + - denom: "uinc" + min_amount: "1000000" + reward_portion_for_lps: "0.6" + dex_rewards_lps: + num_blocks: "1" + amount: "0" + max_eden_reward_apr_lps: "0.5" + protocol_revenue_address: "elys10d07y265gmmuvt4z0w9aw880jnsr700j6z2zm3" chain_id: elystestnet-1 diff --git a/docs/static/openapi.yml b/docs/static/openapi.yml index 30e07c430..71ce6da73 100644 --- a/docs/static/openapi.yml +++ b/docs/static/openapi.yml @@ -10390,6 +10390,717 @@ paths: additionalProperties: {} tags: - Query + /cosmos/distribution/v1beta1/community_pool: + get: + summary: CommunityPool queries the community pool coins. + operationId: CosmosDistributionV1Beta1CommunityPool + responses: + '200': + description: A successful response. + schema: + type: object + properties: + pool: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + DecCoin defines a token with a denomination and a decimal + amount. + + + NOTE: The amount field is an Dec which implements the custom + method + + signatures required by gogoproto. + description: pool defines community pool's coins. + description: >- + QueryCommunityPoolResponse is the response type for the + Query/CommunityPool + + RPC method. + default: + description: An unexpected error response. + schema: + type: object + properties: + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + '@type': + type: string + additionalProperties: {} + tags: + - Query + /cosmos/distribution/v1beta1/delegators/{delegator_address}/rewards: + get: + summary: |- + DelegationTotalRewards queries the total rewards accrued by a each + validator. + operationId: CosmosDistributionV1Beta1DelegationTotalRewards + responses: + '200': + description: A successful response. + schema: + type: object + properties: + rewards: + type: array + items: + type: object + properties: + validator_address: + type: string + reward: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + DecCoin defines a token with a denomination and a + decimal amount. + + + NOTE: The amount field is an Dec which implements the + custom method + + signatures required by gogoproto. + description: |- + DelegationDelegatorReward represents the properties + of a delegator's delegation reward. + description: rewards defines all the rewards accrued by a delegator. + total: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + DecCoin defines a token with a denomination and a decimal + amount. + + + NOTE: The amount field is an Dec which implements the custom + method + + signatures required by gogoproto. + description: total defines the sum of all the rewards. + description: |- + QueryDelegationTotalRewardsResponse is the response type for the + Query/DelegationTotalRewards RPC method. + default: + description: An unexpected error response. + schema: + type: object + properties: + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + '@type': + type: string + additionalProperties: {} + parameters: + - name: delegator_address + description: delegator_address defines the delegator address to query for. + in: path + required: true + type: string + tags: + - Query + /cosmos/distribution/v1beta1/delegators/{delegator_address}/rewards/{validator_address}: + get: + summary: DelegationRewards queries the total rewards accrued by a delegation. + operationId: CosmosDistributionV1Beta1DelegationRewards + responses: + '200': + description: A successful response. + schema: + type: object + properties: + rewards: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + DecCoin defines a token with a denomination and a decimal + amount. + + + NOTE: The amount field is an Dec which implements the custom + method + + signatures required by gogoproto. + description: rewards defines the rewards accrued by a delegation. + description: |- + QueryDelegationRewardsResponse is the response type for the + Query/DelegationRewards RPC method. + default: + description: An unexpected error response. + schema: + type: object + properties: + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + '@type': + type: string + additionalProperties: {} + parameters: + - name: delegator_address + description: delegator_address defines the delegator address to query for. + in: path + required: true + type: string + - name: validator_address + description: validator_address defines the validator address to query for. + in: path + required: true + type: string + tags: + - Query + /cosmos/distribution/v1beta1/delegators/{delegator_address}/validators: + get: + summary: DelegatorValidators queries the validators of a delegator. + operationId: CosmosDistributionV1Beta1DelegatorValidators + responses: + '200': + description: A successful response. + schema: + type: object + properties: + validators: + type: array + items: + type: string + description: >- + validators defines the validators a delegator is delegating + for. + description: |- + QueryDelegatorValidatorsResponse is the response type for the + Query/DelegatorValidators RPC method. + default: + description: An unexpected error response. + schema: + type: object + properties: + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + '@type': + type: string + additionalProperties: {} + parameters: + - name: delegator_address + description: delegator_address defines the delegator address to query for. + in: path + required: true + type: string + tags: + - Query + /cosmos/distribution/v1beta1/delegators/{delegator_address}/withdraw_address: + get: + summary: DelegatorWithdrawAddress queries withdraw address of a delegator. + operationId: CosmosDistributionV1Beta1DelegatorWithdrawAddress + responses: + '200': + description: A successful response. + schema: + type: object + properties: + withdraw_address: + type: string + description: withdraw_address defines the delegator address to query for. + description: |- + QueryDelegatorWithdrawAddressResponse is the response type for the + Query/DelegatorWithdrawAddress RPC method. + default: + description: An unexpected error response. + schema: + type: object + properties: + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + '@type': + type: string + additionalProperties: {} + parameters: + - name: delegator_address + description: delegator_address defines the delegator address to query for. + in: path + required: true + type: string + tags: + - Query + /cosmos/distribution/v1beta1/params: + get: + summary: Params queries params of the distribution module. + operationId: CosmosDistributionV1Beta1Params + responses: + '200': + description: A successful response. + schema: + type: object + properties: + params: + description: params defines the parameters of the module. + type: object + properties: + community_tax: + type: string + base_proposer_reward: + type: string + description: >- + Deprecated: The base_proposer_reward field is deprecated + and is no longer used + + in the x/distribution module's reward mechanism. + bonus_proposer_reward: + type: string + description: >- + Deprecated: The bonus_proposer_reward field is deprecated + and is no longer used + + in the x/distribution module's reward mechanism. + withdraw_addr_enabled: + type: boolean + description: >- + QueryParamsResponse is the response type for the Query/Params RPC + method. + default: + description: An unexpected error response. + schema: + type: object + properties: + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + '@type': + type: string + additionalProperties: {} + tags: + - Query + /cosmos/distribution/v1beta1/validators/{validator_address}: + get: + summary: >- + ValidatorDistributionInfo queries validator commission and + self-delegation rewards for validator + operationId: CosmosDistributionV1Beta1ValidatorDistributionInfo + responses: + '200': + description: A successful response. + schema: + type: object + properties: + operator_address: + type: string + description: operator_address defines the validator operator address. + self_bond_rewards: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + DecCoin defines a token with a denomination and a decimal + amount. + + + NOTE: The amount field is an Dec which implements the custom + method + + signatures required by gogoproto. + description: self_bond_rewards defines the self delegations rewards. + commission: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + DecCoin defines a token with a denomination and a decimal + amount. + + + NOTE: The amount field is an Dec which implements the custom + method + + signatures required by gogoproto. + description: commission defines the commission the validator received. + description: >- + QueryValidatorDistributionInfoResponse is the response type for + the Query/ValidatorDistributionInfo RPC method. + default: + description: An unexpected error response. + schema: + type: object + properties: + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + '@type': + type: string + additionalProperties: {} + parameters: + - name: validator_address + description: validator_address defines the validator address to query for. + in: path + required: true + type: string + tags: + - Query + /cosmos/distribution/v1beta1/validators/{validator_address}/commission: + get: + summary: ValidatorCommission queries accumulated commission for a validator. + operationId: CosmosDistributionV1Beta1ValidatorCommission + responses: + '200': + description: A successful response. + schema: + type: object + properties: + commission: + description: commission defines the commission the validator received. + type: object + properties: + commission: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + DecCoin defines a token with a denomination and a + decimal amount. + + + NOTE: The amount field is an Dec which implements the + custom method + + signatures required by gogoproto. + title: |- + QueryValidatorCommissionResponse is the response type for the + Query/ValidatorCommission RPC method + default: + description: An unexpected error response. + schema: + type: object + properties: + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + '@type': + type: string + additionalProperties: {} + parameters: + - name: validator_address + description: validator_address defines the validator address to query for. + in: path + required: true + type: string + tags: + - Query + /cosmos/distribution/v1beta1/validators/{validator_address}/outstanding_rewards: + get: + summary: ValidatorOutstandingRewards queries rewards of a validator address. + operationId: CosmosDistributionV1Beta1ValidatorOutstandingRewards + responses: + '200': + description: A successful response. + schema: + type: object + properties: + rewards: + type: object + properties: + rewards: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + DecCoin defines a token with a denomination and a + decimal amount. + + + NOTE: The amount field is an Dec which implements the + custom method + + signatures required by gogoproto. + description: >- + ValidatorOutstandingRewards represents outstanding + (un-withdrawn) rewards + + for a validator inexpensive to track, allows simple sanity + checks. + description: >- + QueryValidatorOutstandingRewardsResponse is the response type for + the + + Query/ValidatorOutstandingRewards RPC method. + default: + description: An unexpected error response. + schema: + type: object + properties: + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + '@type': + type: string + additionalProperties: {} + parameters: + - name: validator_address + description: validator_address defines the validator address to query for. + in: path + required: true + type: string + tags: + - Query + /cosmos/distribution/v1beta1/validators/{validator_address}/slashes: + get: + summary: ValidatorSlashes queries slash events of a validator. + operationId: CosmosDistributionV1Beta1ValidatorSlashes + responses: + '200': + description: A successful response. + schema: + type: object + properties: + slashes: + type: array + items: + type: object + properties: + validator_period: + type: string + format: uint64 + fraction: + type: string + description: >- + ValidatorSlashEvent represents a validator slash event. + + Height is implicit within the store key. + + This is needed to calculate appropriate amount of staking + tokens + + for delegations which are withdrawn after a slash has + occurred. + description: slashes defines the slashes the validator received. + pagination: + description: pagination defines the pagination in the response. + type: object + properties: + next_key: + type: string + format: byte + description: |- + next_key is the key to be passed to PageRequest.key to + query the next page most efficiently. It will be empty if + there are no more results. + total: + type: string + format: uint64 + title: >- + total is total number of results available if + PageRequest.count_total + + was set, its value is undefined otherwise + description: |- + QueryValidatorSlashesResponse is the response type for the + Query/ValidatorSlashes RPC method. + default: + description: An unexpected error response. + schema: + type: object + properties: + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + '@type': + type: string + additionalProperties: {} + parameters: + - name: validator_address + description: validator_address defines the validator address to query for. + in: path + required: true + type: string + - name: starting_height + description: >- + starting_height defines the optional starting height to query the + slashes. + in: query + required: false + type: string + format: uint64 + - name: ending_height + description: >- + starting_height defines the optional ending height to query the + slashes. + in: query + required: false + type: string + format: uint64 + - name: pagination.key + description: |- + key is a value returned in PageResponse.next_key to begin + querying the next page most efficiently. Only one of offset or key + should be set. + in: query + required: false + type: string + format: byte + - name: pagination.offset + description: >- + offset is a numeric offset that can be used when key is unavailable. + + It is less efficient than using key. Only one of offset or key + should + + be set. + in: query + required: false + type: string + format: uint64 + - name: pagination.limit + description: >- + limit is the total number of results to be returned in the result + page. + + If left empty it will default to a value to be set by each app. + in: query + required: false + type: string + format: uint64 + - name: pagination.count_total + description: >- + count_total is set to true to indicate that the result set should + include + + a count of the total number of items available for pagination in + UIs. + + count_total is only respected when offset is used. It is ignored + when key + + is set. + in: query + required: false + type: boolean + - name: pagination.reverse + description: >- + reverse is set to true if results are to be returned in the + descending order. + + + Since: cosmos-sdk 0.43 + in: query + required: false + type: boolean + tags: + - Query /cosmos/evidence/v1beta1/evidence: get: summary: AllEvidence queries all evidence. @@ -39357,23 +40068,6 @@ paths: unlock_timestamp: type: string format: uint64 - rewards_unclaimed: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an amount. - - - NOTE: The amount field is an Int which implements the - custom method - - signatures required by gogoproto. claimed: type: array items: @@ -39411,74 +40105,6 @@ paths: vest_started_timestamp: type: string format: int64 - rewards_by_elys_unclaimed: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an amount. - - - NOTE: The amount field is an Int which implements the - custom method - - signatures required by gogoproto. - rewards_by_eden_unclaimed: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an amount. - - - NOTE: The amount field is an Int which implements the - custom method - - signatures required by gogoproto. - rewards_by_edenb_unclaimed: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an amount. - - - NOTE: The amount field is an Int which implements the - custom method - - signatures required by gogoproto. - rewards_by_usdc_unclaimed: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an amount. - - - NOTE: The amount field is an Int which implements the - custom method - - signatures required by gogoproto. description: GenesisState defines the commitment module's genesis state. default: description: An unexpected error response. @@ -39701,18 +40327,64 @@ paths: type: boolean tags: - Query - /elys-network/elys/incentive/apr/{withdraw_type}/{denom}: + /elys-network/elys/estaking/params: get: - summary: Calculate APR - operationId: ElysIncentiveApr + summary: Parameters queries the parameters of the module. + operationId: ElysEstakingParams responses: '200': description: A successful response. schema: type: object properties: - apr: - type: string + params: + description: params holds all the parameters of this module. + type: object + properties: + stake_incentives: + type: object + properties: + eden_amount_per_year: + type: string + title: reward amount in eden for 1 year + distribution_start_block: + type: string + title: starting block height of the distribution + total_blocks_per_year: + type: string + title: distribution duration - block number per year + blocks_distributed: + type: string + title: blocks distributed + title: Incentive Info + eden_commit_val: + type: string + edenb_commit_val: + type: string + max_eden_reward_apr_stakers: + type: string + title: Maximum eden reward apr for stakers - [0 - 0.3] + eden_boost_apr: + type: string + dex_rewards_stakers: + title: Tracking dex rewards given to stakers + type: object + properties: + num_blocks: + type: string + title: >- + Number of blocks since start of epoch (distribution + epoch) + amount: + type: string + title: >- + Accumulated amount at distribution epoch - + recalculated at every + + distribution epoch + description: >- + QueryParamsResponse is response type for the Query/Params RPC + method. default: description: An unexpected error response. schema: @@ -39731,54 +40403,63 @@ paths: '@type': type: string additionalProperties: {} - parameters: - - name: withdraw_type - in: path - required: true - type: string - enum: - - ALL_PROGRAM - - USDC_PROGRAM - - ELYS_PROGRAM - - EDEN_PROGRAM - - EDENB_PROGRAM - - LP_MINING_PROGRAM - - name: denom - in: path - required: true - type: string tags: - Query - /elys-network/elys/incentive/aprs: + /elys-network/elys/estaking/rewards/{address}: get: - summary: Calculate APRs - operationId: ElysIncentiveAprs + summary: Rewards queries the total rewards accrued by a delegation + operationId: ElysEstakingRewards responses: '200': description: A successful response. schema: type: object properties: - usdc_apr_usdc: - type: string - eden_apr_usdc: - type: string - usdc_apr_edenb: - type: string - eden_apr_edenb: - type: string - usdc_apr_eden: - type: string - eden_apr_eden: - type: string - edenb_apr_eden: - type: string - usdc_apr_elys: - type: string - eden_apr_elys: - type: string - edenb_apr_elys: - type: string + rewards: + type: array + items: + type: object + properties: + validator_address: + type: string + reward: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + DecCoin defines a token with a denomination and a + decimal amount. + + + NOTE: The amount field is an Dec which implements the + custom method + + signatures required by gogoproto. + description: rewards defines all the rewards accrued by a delegator. + total: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + DecCoin defines a token with a denomination and a decimal + amount. + + + NOTE: The amount field is an Dec which implements the custom + method + + signatures required by gogoproto. + description: total defines the sum of all the rewards. default: description: An unexpected error response. schema: @@ -39797,19 +40478,78 @@ paths: '@type': type: string additionalProperties: {} + parameters: + - name: address + in: path + required: true + type: string tags: - Query - /elys-network/elys/incentive/community_pool: + /elys-network/elys/incentive/all_program_rewards: get: - summary: Queries a list of CommunityPool items. - operationId: ElysIncentiveCommunityPool + summary: Queries all program rewards + operationId: ElysIncentiveAllProgramRewards responses: '200': description: A successful response. schema: type: object properties: - pool: + usdc_staking_rewards: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + DecCoin defines a token with a denomination and a decimal + amount. + + + NOTE: The amount field is an Dec which implements the custom + method + + signatures required by gogoproto. + elys_staking_rewards: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + DecCoin defines a token with a denomination and a decimal + amount. + + + NOTE: The amount field is an Dec which implements the custom + method + + signatures required by gogoproto. + eden_staking_rewards: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + DecCoin defines a token with a denomination and a decimal + amount. + + + NOTE: The amount field is an Dec which implements the custom + method + + signatures required by gogoproto. + edenb_staking_rewards: type: array items: type: object @@ -39827,7 +40567,6 @@ paths: method signatures required by gogoproto. - description: pool defines community pool's coins. default: description: An unexpected error response. schema: @@ -39846,181 +40585,25 @@ paths: '@type': type: string additionalProperties: {} + parameters: + - name: address + in: query + required: false + type: string tags: - Query - /elys-network/elys/incentive/params: + /elys-network/elys/incentive/apr/{withdraw_type}/{denom}: get: - summary: Parameters queries the parameters of the module. - operationId: ElysIncentiveParams + summary: Calculate APR + operationId: ElysIncentiveApr responses: '200': description: A successful response. schema: type: object properties: - params: - description: params holds all the parameters of this module. - type: object - properties: - lp_incentives: - type: object - properties: - eden_amount_per_year: - type: string - title: reward amount in eden for 1 year - distribution_start_block: - type: string - title: starting block height of the distribution - total_blocks_per_year: - type: string - title: distribution duration - block number per year - epoch_num_blocks: - type: string - title: unused - max_eden_per_allocation: - type: string - title: >- - maximum eden allocation per day that won't exceed 30% - apr - distribution_epoch_in_blocks: - type: string - title: unused - current_epoch_in_blocks: - type: string - title: current epoch in block number - title: Incentive Info - stake_incentives: - type: object - properties: - eden_amount_per_year: - type: string - title: reward amount in eden for 1 year - distribution_start_block: - type: string - title: starting block height of the distribution - total_blocks_per_year: - type: string - title: distribution duration - block number per year - epoch_num_blocks: - type: string - title: unused - max_eden_per_allocation: - type: string - title: >- - maximum eden allocation per day that won't exceed 30% - apr - distribution_epoch_in_blocks: - type: string - title: unused - current_epoch_in_blocks: - type: string - title: current epoch in block number - title: Incentive Info - reward_portion_for_lps: - type: string - description: >- - Dex revenue percent for lps, `100 - reward_portion_for_lps - - reward_portion_for_stakers = revenue percent for - protocol`. - reward_portion_for_stakers: - type: string - description: >- - Dex revenue percent for lps, `100 - reward_portion_for_lps - - reward_portion_for_stakers = revenue percent for - protocol`. - pool_infos: - type: array - items: - type: object - properties: - pool_id: - type: string - format: uint64 - title: reward amount - reward_wallet: - type: string - title: reward wallet address - multiplier: - type: string - title: multiplier for lp rewards - num_blocks: - type: string - title: Block number since the creation of PoolInfo - dex_reward_amount_given: - type: string - title: Total dex rewards given - eden_reward_amount_given: - type: string - title: Total eden rewards given - eden_apr: - type: string - title: Eden APR, updated at every distribution - dex_apr: - type: string - title: Dex APR, updated at every distribution - title: Pool Info - title: |- - Pool information - poolId, reward wallet, **multiplier**, dex rewards given - elys_stake_snap_interval: - type: string - format: int64 - title: >- - Number of blocks to update elys staked amount for - delegators - dex_rewards_stakers: - title: Tracking dex rewards given to stakers - type: object - properties: - num_blocks: - type: string - title: >- - Number of blocks since start of epoch (distribution - epoch) - amount: - type: string - title: >- - Accumulated amount at distribution epoch - - recalculated at every distribution epoch - amount_collected_by_other_tracker: - type: string - title: >- - Accumulated rewards tracked by other (when it's for - staking, from lp, if it's for lp, from staking) - dex_rewards_lps: - title: Tracking dex rewards given to LPs - type: object - properties: - num_blocks: - type: string - title: >- - Number of blocks since start of epoch (distribution - epoch) - amount: - type: string - title: >- - Accumulated amount at distribution epoch - - recalculated at every distribution epoch - amount_collected_by_other_tracker: - type: string - title: >- - Accumulated rewards tracked by other (when it's for - staking, from lp, if it's for lp, from staking) - max_eden_reward_apr_stakers: - type: string - title: Maximum eden reward apr for stakers - [0 - 0.3] - max_eden_reward_apr_lps: - type: string - title: Maximum eden reward apr for lps - [0 - 0.3] - distribution_interval: - type: string - format: int64 - title: >- - Distribution interval in blocks - number of blocks on - distribution epoch - description: >- - QueryParamsResponse is response type for the Query/Params RPC - method. + apr: + type: string default: description: An unexpected error response. schema: @@ -40039,28 +40622,54 @@ paths: '@type': type: string additionalProperties: {} + parameters: + - name: withdraw_type + in: path + required: true + type: string + enum: + - ALL_PROGRAM + - USDC_PROGRAM + - ELYS_PROGRAM + - EDEN_PROGRAM + - EDENB_PROGRAM + - LP_MINING_PROGRAM + - name: denom + in: path + required: true + type: string tags: - Query - /elys-network/elys/incentive/pool_aprs: + /elys-network/elys/incentive/aprs: get: - summary: Calculate liquidity mining pool APRs - operationId: ElysIncentivePoolAprs + summary: Calculate APRs + operationId: ElysIncentiveAprs responses: '200': description: A successful response. schema: type: object properties: - data: - type: array - items: - type: object - properties: - pool_id: - type: string - format: uint64 - apr: - type: string + usdc_apr_usdc: + type: string + eden_apr_usdc: + type: string + usdc_apr_edenb: + type: string + eden_apr_edenb: + type: string + usdc_apr_eden: + type: string + eden_apr_eden: + type: string + edenb_apr_eden: + type: string + usdc_apr_elys: + type: string + eden_apr_elys: + type: string + edenb_apr_elys: + type: string default: description: An unexpected error response. schema: @@ -40079,15 +40688,6 @@ paths: '@type': type: string additionalProperties: {} - parameters: - - name: pool_ids - in: query - required: false - type: array - items: - type: string - format: uint64 - collectionFormat: multi tags: - Query /elys-network/elys/incentive/pool_rewards: @@ -41204,6 +41804,500 @@ paths: type: boolean tags: - Query + /elys-network/elys/masterchef/external_incentive: + get: + operationId: ElysMasterchefExternalIncentive + responses: + '200': + description: A successful response. + schema: + type: object + properties: + external_incentive: + type: object + properties: + id: + type: string + format: uint64 + reward_denom: + type: string + pool_id: + type: string + format: uint64 + from_block: + type: string + format: uint64 + to_block: + type: string + format: uint64 + amount_per_block: + type: string + description: ExternalIncentive defines the external incentives. + default: + description: An unexpected error response. + schema: + type: object + properties: + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + '@type': + type: string + additionalProperties: {} + parameters: + - name: id + in: query + required: false + type: string + format: uint64 + tags: + - Query + /elys-network/elys/masterchef/params: + get: + summary: Parameters queries the parameters of the module. + operationId: ElysMasterchefParams + responses: + '200': + description: A successful response. + schema: + type: object + properties: + params: + description: params holds all the parameters of this module. + type: object + properties: + lp_incentives: + type: object + properties: + eden_amount_per_year: + type: string + title: reward amount in eden for 1 year + distribution_start_block: + type: string + title: starting block height of the distribution + total_blocks_per_year: + type: string + title: distribution duration - block number per year + blocks_distributed: + type: string + title: blocks distributed + title: Incentive Info + reward_portion_for_lps: + type: string + description: >- + gas fees and swap fees portion for lps, `100 - + reward_portion_for_lps - reward_portion_for_stakers = + revenue percent for protocol`. + reward_portion_for_stakers: + type: string + description: >- + gas fees and swap fees portion for stakers, `100 - + reward_portion_for_lps - reward_portion_for_stakers = + revenue percent for protocol`. + dex_rewards_lps: + title: Tracking dex rewards given to LPs + type: object + properties: + num_blocks: + type: string + title: >- + Number of blocks since start of epoch (distribution + epoch) + amount: + type: string + title: >- + Accumulated amount at distribution epoch - + recalculated at every distribution epoch + max_eden_reward_apr_lps: + type: string + title: Maximum eden reward apr for lps - [0 - 0.3] + supported_reward_denoms: + type: array + items: + type: object + properties: + denom: + type: string + min_amount: + type: string + protocol_revenue_address: + type: string + description: >- + QueryParamsResponse is response type for the Query/Params RPC + method. + default: + description: An unexpected error response. + schema: + type: object + properties: + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + '@type': + type: string + additionalProperties: {} + tags: + - Query + /elys-network/elys/masterchef/pending_reward: + get: + operationId: ElysMasterchefUserPendingReward + responses: + '200': + description: A successful response. + schema: + type: object + properties: + rewards: + type: array + items: + type: object + properties: + pool_id: + type: string + format: uint64 + reward: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an + amount. + + + NOTE: The amount field is an Int which implements the + custom method + + signatures required by gogoproto. + total_rewards: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an amount. + + + NOTE: The amount field is an Int which implements the custom + method + + signatures required by gogoproto. + default: + description: An unexpected error response. + schema: + type: object + properties: + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + '@type': + type: string + additionalProperties: {} + parameters: + - name: user + in: query + required: false + type: string + tags: + - Query + /elys-network/elys/masterchef/pool_aprs: + get: + operationId: ElysMasterchefPoolAprs + responses: + '200': + description: A successful response. + schema: + type: object + properties: + data: + type: array + items: + type: object + properties: + pool_id: + type: string + format: uint64 + eden_apr: + type: string + usdc_apr: + type: string + total_apr: + type: string + default: + description: An unexpected error response. + schema: + type: object + properties: + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + '@type': + type: string + additionalProperties: {} + parameters: + - name: pool_ids + in: query + required: false + type: array + items: + type: string + format: uint64 + collectionFormat: multi + tags: + - Query + /elys-network/elys/masterchef/pool_info: + get: + operationId: ElysMasterchefPoolInfo + responses: + '200': + description: A successful response. + schema: + type: object + properties: + pool_info: + type: object + properties: + pool_id: + type: string + format: uint64 + title: reward amount + reward_wallet: + type: string + title: reward wallet address + multiplier: + type: string + title: multiplier for lp rewards + num_blocks: + type: string + title: Block number since the creation of PoolInfo + dex_reward_amount_given: + type: string + title: Total dex rewards given + eden_reward_amount_given: + type: string + title: Total eden rewards given + eden_apr: + type: string + title: Eden APR, updated at every distribution + dex_apr: + type: string + title: Dex APR, updated at every distribution + external_incentive_apr: + type: string + title: External Incentive APR, updated at every distribution + external_reward_denoms: + type: array + items: + type: string + title: external reward denoms on the pool + title: Pool Info + default: + description: An unexpected error response. + schema: + type: object + properties: + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + '@type': + type: string + additionalProperties: {} + parameters: + - name: pool_id + in: query + required: false + type: string + format: uint64 + tags: + - Query + /elys-network/elys/masterchef/pool_reward_info: + get: + operationId: ElysMasterchefPoolRewardInfo + responses: + '200': + description: A successful response. + schema: + type: object + properties: + pool_reward_info: + type: object + properties: + pool_id: + type: string + format: uint64 + reward_denom: + type: string + pool_acc_reward_per_share: + type: string + last_updated_block: + type: string + format: uint64 + default: + description: An unexpected error response. + schema: + type: object + properties: + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + '@type': + type: string + additionalProperties: {} + parameters: + - name: pool_id + in: query + required: false + type: string + format: uint64 + - name: reward_denom + in: query + required: false + type: string + tags: + - Query + /elys-network/elys/masterchef/stable_stake_apr/{denom}: + get: + operationId: ElysMasterchefStableStakeApr + responses: + '200': + description: A successful response. + schema: + type: object + properties: + apr: + type: string + default: + description: An unexpected error response. + schema: + type: object + properties: + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + '@type': + type: string + additionalProperties: {} + parameters: + - name: denom + in: path + required: true + type: string + tags: + - Query + /elys-network/elys/masterchef/user_reward_info: + get: + operationId: ElysMasterchefUserRewardInfo + responses: + '200': + description: A successful response. + schema: + type: object + properties: + user_reward_info: + type: object + properties: + user: + type: string + pool_id: + type: string + format: uint64 + reward_denom: + type: string + reward_debt: + type: string + reward_pending: + type: string + default: + description: An unexpected error response. + schema: + type: object + properties: + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + '@type': + type: string + additionalProperties: {} + parameters: + - name: user + in: query + required: false + type: string + - name: pool_id + in: query + required: false + type: string + format: uint64 + - name: reward_denom + in: query + required: false + type: string + tags: + - Query /elys-network/elys/oracle/asset_info: get: summary: Queries a list of AssetInfo items. @@ -67905,6 +68999,461 @@ definitions: cosmos.crisis.v1beta1.MsgVerifyInvariantResponse: type: object description: MsgVerifyInvariantResponse defines the Msg/VerifyInvariant response type. + cosmos.base.v1beta1.DecCoin: + type: object + properties: + denom: + type: string + amount: + type: string + description: |- + DecCoin defines a token with a denomination and a decimal amount. + + NOTE: The amount field is an Dec which implements the custom method + signatures required by gogoproto. + cosmos.distribution.v1beta1.DelegationDelegatorReward: + type: object + properties: + validator_address: + type: string + reward: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: |- + DecCoin defines a token with a denomination and a decimal amount. + + NOTE: The amount field is an Dec which implements the custom method + signatures required by gogoproto. + description: |- + DelegationDelegatorReward represents the properties + of a delegator's delegation reward. + cosmos.distribution.v1beta1.MsgCommunityPoolSpendResponse: + type: object + description: |- + MsgCommunityPoolSpendResponse defines the response to executing a + MsgCommunityPoolSpend message. + + Since: cosmos-sdk 0.47 + cosmos.distribution.v1beta1.MsgFundCommunityPoolResponse: + type: object + description: >- + MsgFundCommunityPoolResponse defines the Msg/FundCommunityPool response + type. + cosmos.distribution.v1beta1.MsgSetWithdrawAddressResponse: + type: object + description: |- + MsgSetWithdrawAddressResponse defines the Msg/SetWithdrawAddress response + type. + cosmos.distribution.v1beta1.MsgUpdateParamsResponse: + type: object + description: |- + MsgUpdateParamsResponse defines the response structure for executing a + MsgUpdateParams message. + + Since: cosmos-sdk 0.47 + cosmos.distribution.v1beta1.MsgWithdrawDelegatorRewardResponse: + type: object + properties: + amount: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: |- + Coin defines a token with a denomination and an amount. + + NOTE: The amount field is an Int which implements the custom method + signatures required by gogoproto. + title: 'Since: cosmos-sdk 0.46' + description: |- + MsgWithdrawDelegatorRewardResponse defines the Msg/WithdrawDelegatorReward + response type. + cosmos.distribution.v1beta1.MsgWithdrawValidatorCommissionResponse: + type: object + properties: + amount: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: |- + Coin defines a token with a denomination and an amount. + + NOTE: The amount field is an Int which implements the custom method + signatures required by gogoproto. + title: 'Since: cosmos-sdk 0.46' + description: |- + MsgWithdrawValidatorCommissionResponse defines the + Msg/WithdrawValidatorCommission response type. + cosmos.distribution.v1beta1.Params: + type: object + properties: + community_tax: + type: string + base_proposer_reward: + type: string + description: >- + Deprecated: The base_proposer_reward field is deprecated and is no + longer used + + in the x/distribution module's reward mechanism. + bonus_proposer_reward: + type: string + description: >- + Deprecated: The bonus_proposer_reward field is deprecated and is no + longer used + + in the x/distribution module's reward mechanism. + withdraw_addr_enabled: + type: boolean + description: Params defines the set of params for the distribution module. + cosmos.distribution.v1beta1.QueryCommunityPoolResponse: + type: object + properties: + pool: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: |- + DecCoin defines a token with a denomination and a decimal amount. + + NOTE: The amount field is an Dec which implements the custom method + signatures required by gogoproto. + description: pool defines community pool's coins. + description: >- + QueryCommunityPoolResponse is the response type for the + Query/CommunityPool + + RPC method. + cosmos.distribution.v1beta1.QueryDelegationRewardsResponse: + type: object + properties: + rewards: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: |- + DecCoin defines a token with a denomination and a decimal amount. + + NOTE: The amount field is an Dec which implements the custom method + signatures required by gogoproto. + description: rewards defines the rewards accrued by a delegation. + description: |- + QueryDelegationRewardsResponse is the response type for the + Query/DelegationRewards RPC method. + cosmos.distribution.v1beta1.QueryDelegationTotalRewardsResponse: + type: object + properties: + rewards: + type: array + items: + type: object + properties: + validator_address: + type: string + reward: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + DecCoin defines a token with a denomination and a decimal + amount. + + + NOTE: The amount field is an Dec which implements the custom + method + + signatures required by gogoproto. + description: |- + DelegationDelegatorReward represents the properties + of a delegator's delegation reward. + description: rewards defines all the rewards accrued by a delegator. + total: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: |- + DecCoin defines a token with a denomination and a decimal amount. + + NOTE: The amount field is an Dec which implements the custom method + signatures required by gogoproto. + description: total defines the sum of all the rewards. + description: |- + QueryDelegationTotalRewardsResponse is the response type for the + Query/DelegationTotalRewards RPC method. + cosmos.distribution.v1beta1.QueryDelegatorValidatorsResponse: + type: object + properties: + validators: + type: array + items: + type: string + description: validators defines the validators a delegator is delegating for. + description: |- + QueryDelegatorValidatorsResponse is the response type for the + Query/DelegatorValidators RPC method. + cosmos.distribution.v1beta1.QueryDelegatorWithdrawAddressResponse: + type: object + properties: + withdraw_address: + type: string + description: withdraw_address defines the delegator address to query for. + description: |- + QueryDelegatorWithdrawAddressResponse is the response type for the + Query/DelegatorWithdrawAddress RPC method. + cosmos.distribution.v1beta1.QueryParamsResponse: + type: object + properties: + params: + description: params defines the parameters of the module. + type: object + properties: + community_tax: + type: string + base_proposer_reward: + type: string + description: >- + Deprecated: The base_proposer_reward field is deprecated and is no + longer used + + in the x/distribution module's reward mechanism. + bonus_proposer_reward: + type: string + description: >- + Deprecated: The bonus_proposer_reward field is deprecated and is + no longer used + + in the x/distribution module's reward mechanism. + withdraw_addr_enabled: + type: boolean + description: QueryParamsResponse is the response type for the Query/Params RPC method. + cosmos.distribution.v1beta1.QueryValidatorCommissionResponse: + type: object + properties: + commission: + description: commission defines the commission the validator received. + type: object + properties: + commission: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + DecCoin defines a token with a denomination and a decimal + amount. + + + NOTE: The amount field is an Dec which implements the custom + method + + signatures required by gogoproto. + title: |- + QueryValidatorCommissionResponse is the response type for the + Query/ValidatorCommission RPC method + cosmos.distribution.v1beta1.QueryValidatorDistributionInfoResponse: + type: object + properties: + operator_address: + type: string + description: operator_address defines the validator operator address. + self_bond_rewards: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: |- + DecCoin defines a token with a denomination and a decimal amount. + + NOTE: The amount field is an Dec which implements the custom method + signatures required by gogoproto. + description: self_bond_rewards defines the self delegations rewards. + commission: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: |- + DecCoin defines a token with a denomination and a decimal amount. + + NOTE: The amount field is an Dec which implements the custom method + signatures required by gogoproto. + description: commission defines the commission the validator received. + description: >- + QueryValidatorDistributionInfoResponse is the response type for the + Query/ValidatorDistributionInfo RPC method. + cosmos.distribution.v1beta1.QueryValidatorOutstandingRewardsResponse: + type: object + properties: + rewards: + type: object + properties: + rewards: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + DecCoin defines a token with a denomination and a decimal + amount. + + + NOTE: The amount field is an Dec which implements the custom + method + + signatures required by gogoproto. + description: >- + ValidatorOutstandingRewards represents outstanding (un-withdrawn) + rewards + + for a validator inexpensive to track, allows simple sanity checks. + description: |- + QueryValidatorOutstandingRewardsResponse is the response type for the + Query/ValidatorOutstandingRewards RPC method. + cosmos.distribution.v1beta1.QueryValidatorSlashesResponse: + type: object + properties: + slashes: + type: array + items: + type: object + properties: + validator_period: + type: string + format: uint64 + fraction: + type: string + description: |- + ValidatorSlashEvent represents a validator slash event. + Height is implicit within the store key. + This is needed to calculate appropriate amount of staking tokens + for delegations which are withdrawn after a slash has occurred. + description: slashes defines the slashes the validator received. + pagination: + description: pagination defines the pagination in the response. + type: object + properties: + next_key: + type: string + format: byte + description: |- + next_key is the key to be passed to PageRequest.key to + query the next page most efficiently. It will be empty if + there are no more results. + total: + type: string + format: uint64 + title: >- + total is total number of results available if + PageRequest.count_total + + was set, its value is undefined otherwise + description: |- + QueryValidatorSlashesResponse is the response type for the + Query/ValidatorSlashes RPC method. + cosmos.distribution.v1beta1.ValidatorAccumulatedCommission: + type: object + properties: + commission: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: |- + DecCoin defines a token with a denomination and a decimal amount. + + NOTE: The amount field is an Dec which implements the custom method + signatures required by gogoproto. + description: |- + ValidatorAccumulatedCommission represents accumulated commission + for a validator kept as a running counter, can be withdrawn at any time. + cosmos.distribution.v1beta1.ValidatorOutstandingRewards: + type: object + properties: + rewards: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: |- + DecCoin defines a token with a denomination and a decimal amount. + + NOTE: The amount field is an Dec which implements the custom method + signatures required by gogoproto. + description: |- + ValidatorOutstandingRewards represents outstanding (un-withdrawn) rewards + for a validator inexpensive to track, allows simple sanity checks. + cosmos.distribution.v1beta1.ValidatorSlashEvent: + type: object + properties: + validator_period: + type: string + format: uint64 + fraction: + type: string + description: |- + ValidatorSlashEvent represents a validator slash event. + Height is implicit within the store key. + This is needed to calculate appropriate amount of staking tokens + for delegations which are withdrawn after a slash has occurred. cosmos.evidence.v1beta1.MsgSubmitEvidenceResponse: type: object properties: @@ -84041,20 +85590,6 @@ definitions: unlock_timestamp: type: string format: uint64 - rewards_unclaimed: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: |- - Coin defines a token with a denomination and an amount. - - NOTE: The amount field is an Int which implements the custom method - signatures required by gogoproto. claimed: type: array items: @@ -84089,62 +85624,6 @@ definitions: vest_started_timestamp: type: string format: int64 - rewards_by_elys_unclaimed: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: |- - Coin defines a token with a denomination and an amount. - - NOTE: The amount field is an Int which implements the custom method - signatures required by gogoproto. - rewards_by_eden_unclaimed: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: |- - Coin defines a token with a denomination and an amount. - - NOTE: The amount field is an Int which implements the custom method - signatures required by gogoproto. - rewards_by_edenb_unclaimed: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: |- - Coin defines a token with a denomination and an amount. - - NOTE: The amount field is an Int which implements the custom method - signatures required by gogoproto. - rewards_by_usdc_unclaimed: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: |- - Coin defines a token with a denomination and an amount. - - NOTE: The amount field is an Int which implements the custom method - signatures required by gogoproto. description: GenesisState defines the commitment module's genesis state. elys.commitment.CommittedTokens: type: object @@ -84309,23 +85788,6 @@ definitions: unlock_timestamp: type: string format: uint64 - rewards_unclaimed: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an amount. - - - NOTE: The amount field is an Int which implements the custom - method - - signatures required by gogoproto. claimed: type: array items: @@ -84363,74 +85825,6 @@ definitions: vest_started_timestamp: type: string format: int64 - rewards_by_elys_unclaimed: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an amount. - - - NOTE: The amount field is an Int which implements the custom - method - - signatures required by gogoproto. - rewards_by_eden_unclaimed: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an amount. - - - NOTE: The amount field is an Int which implements the custom - method - - signatures required by gogoproto. - rewards_by_edenb_unclaimed: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an amount. - - - NOTE: The amount field is an Int which implements the custom - method - - signatures required by gogoproto. - rewards_by_usdc_unclaimed: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an amount. - - - NOTE: The amount field is an Int which implements the custom - method - - signatures required by gogoproto. description: GenesisState defines the commitment module's genesis state. elys.commitment.VestingInfo: type: object @@ -84579,29 +85973,26 @@ definitions: description: |- QueryEpochsInfoResponse is the response type for the Query/EpochInfos RPC method. - cosmos.base.v1beta1.DecCoin: + elys.estaking.DelegationDelegatorReward: type: object properties: - denom: - type: string - amount: + validator_address: type: string - description: |- - DecCoin defines a token with a denomination and a decimal amount. + reward: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: |- + DecCoin defines a token with a denomination and a decimal amount. - NOTE: The amount field is an Dec which implements the custom method - signatures required by gogoproto. - elys.commitment.EarnType: - type: string - enum: - - ALL_PROGRAM - - USDC_PROGRAM - - ELYS_PROGRAM - - EDEN_PROGRAM - - EDENB_PROGRAM - - LP_MINING_PROGRAM - default: ALL_PROGRAM - elys.incentive.DexRewardsTracker: + NOTE: The amount field is an Dec which implements the custom method + signatures required by gogoproto. + elys.estaking.DexRewardsTracker: type: object properties: num_blocks: @@ -84609,18 +86000,13 @@ definitions: title: Number of blocks since start of epoch (distribution epoch) amount: type: string - title: >- + title: |- Accumulated amount at distribution epoch - recalculated at every distribution epoch - amount_collected_by_other_tracker: - type: string - title: >- - Accumulated rewards tracked by other (when it's for staking, from lp, - if it's for lp, from staking) - title: >- + title: |- DexRewardsTracker is used for tracking rewards for stakers and LPs, all amount here is in USDC - elys.incentive.IncentiveInfo: + elys.estaking.IncentiveInfo: type: object properties: eden_amount_per_year: @@ -84632,61 +86018,58 @@ definitions: total_blocks_per_year: type: string title: distribution duration - block number per year - epoch_num_blocks: + blocks_distributed: type: string - title: unused - max_eden_per_allocation: - type: string - title: maximum eden allocation per day that won't exceed 30% apr - distribution_epoch_in_blocks: - type: string - title: unused - current_epoch_in_blocks: - type: string - title: current epoch in block number + title: blocks distributed title: Incentive Info - elys.incentive.MsgUpdateIncentiveParamsResponse: + elys.estaking.MsgUpdateParamsResponse: type: object - elys.incentive.MsgUpdatePoolMultipliersResponse: - type: object - elys.incentive.MsgWithdrawRewardsResponse: + description: >- + MsgUpdateParamsResponse defines the response structure for executing a + MsgUpdateParams message. + elys.estaking.MsgWithdrawElysStakingRewardsResponse: type: object + properties: + amount: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: |- + Coin defines a token with a denomination and an amount. + + NOTE: The amount field is an Int which implements the custom method + signatures required by gogoproto. description: >- - MsgWithdrawDelegatorRewardResponse defines the Msg/WithdrawDelegatorReward + MsgWithdrawElysStakingRewards defines the Msg/WithdrawElysStakingRewards response type. - elys.incentive.MsgWithdrawValidatorCommissionResponse: + elys.estaking.MsgWithdrawRewardResponse: type: object + properties: + amount: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: |- + Coin defines a token with a denomination and an amount. + + NOTE: The amount field is an Int which implements the custom method + signatures required by gogoproto. description: >- - MsgWithdrawValidatorCommissionResponse defines the - Msg/WithdrawValidatorCommission response type. - elys.incentive.Params: + MsgWithdrawRewardResponse defines the Msg/WithdrawDelegatorReward response + type. + elys.estaking.Params: type: object properties: - lp_incentives: - type: object - properties: - eden_amount_per_year: - type: string - title: reward amount in eden for 1 year - distribution_start_block: - type: string - title: starting block height of the distribution - total_blocks_per_year: - type: string - title: distribution duration - block number per year - epoch_num_blocks: - type: string - title: unused - max_eden_per_allocation: - type: string - title: maximum eden allocation per day that won't exceed 30% apr - distribution_epoch_in_blocks: - type: string - title: unused - current_epoch_in_blocks: - type: string - title: current epoch in block number - title: Incentive Info stake_incentives: type: object properties: @@ -84699,67 +86082,19 @@ definitions: total_blocks_per_year: type: string title: distribution duration - block number per year - epoch_num_blocks: - type: string - title: unused - max_eden_per_allocation: + blocks_distributed: type: string - title: maximum eden allocation per day that won't exceed 30% apr - distribution_epoch_in_blocks: - type: string - title: unused - current_epoch_in_blocks: - type: string - title: current epoch in block number + title: blocks distributed title: Incentive Info - reward_portion_for_lps: + eden_commit_val: type: string - description: >- - Dex revenue percent for lps, `100 - reward_portion_for_lps - - reward_portion_for_stakers = revenue percent for protocol`. - reward_portion_for_stakers: + edenb_commit_val: type: string - description: >- - Dex revenue percent for lps, `100 - reward_portion_for_lps - - reward_portion_for_stakers = revenue percent for protocol`. - pool_infos: - type: array - items: - type: object - properties: - pool_id: - type: string - format: uint64 - title: reward amount - reward_wallet: - type: string - title: reward wallet address - multiplier: - type: string - title: multiplier for lp rewards - num_blocks: - type: string - title: Block number since the creation of PoolInfo - dex_reward_amount_given: - type: string - title: Total dex rewards given - eden_reward_amount_given: - type: string - title: Total eden rewards given - eden_apr: - type: string - title: Eden APR, updated at every distribution - dex_apr: - type: string - title: Dex APR, updated at every distribution - title: Pool Info - title: |- - Pool information - poolId, reward wallet, **multiplier**, dex rewards given - elys_stake_snap_interval: + max_eden_reward_apr_stakers: + type: string + title: Maximum eden reward apr for stakers - [0 - 0.3] + eden_boost_apr: type: string - format: int64 - title: Number of blocks to update elys staked amount for delegators dex_rewards_stakers: title: Tracking dex rewards given to stakers type: object @@ -84769,89 +86104,111 @@ definitions: title: Number of blocks since start of epoch (distribution epoch) amount: type: string - title: >- + title: |- Accumulated amount at distribution epoch - recalculated at every distribution epoch - amount_collected_by_other_tracker: - type: string - title: >- - Accumulated rewards tracked by other (when it's for staking, from - lp, if it's for lp, from staking) - dex_rewards_lps: - title: Tracking dex rewards given to LPs + description: Params defines the parameters for the module. + elys.estaking.QueryParamsResponse: + type: object + properties: + params: + description: params holds all the parameters of this module. type: object properties: - num_blocks: + stake_incentives: + type: object + properties: + eden_amount_per_year: + type: string + title: reward amount in eden for 1 year + distribution_start_block: + type: string + title: starting block height of the distribution + total_blocks_per_year: + type: string + title: distribution duration - block number per year + blocks_distributed: + type: string + title: blocks distributed + title: Incentive Info + eden_commit_val: type: string - title: Number of blocks since start of epoch (distribution epoch) - amount: + edenb_commit_val: type: string - title: >- - Accumulated amount at distribution epoch - recalculated at every - distribution epoch - amount_collected_by_other_tracker: + max_eden_reward_apr_stakers: type: string - title: >- - Accumulated rewards tracked by other (when it's for staking, from - lp, if it's for lp, from staking) - max_eden_reward_apr_stakers: - type: string - title: Maximum eden reward apr for stakers - [0 - 0.3] - max_eden_reward_apr_lps: - type: string - title: Maximum eden reward apr for lps - [0 - 0.3] - distribution_interval: - type: string - format: int64 - title: >- - Distribution interval in blocks - number of blocks on distribution - epoch - description: Params defines the parameters for the module. - elys.incentive.PoolApr: - type: object - properties: - pool_id: - type: string - format: uint64 - apr: - type: string - elys.incentive.PoolInfo: - type: object - properties: - pool_id: - type: string - format: uint64 - title: reward amount - reward_wallet: - type: string - title: reward wallet address - multiplier: - type: string - title: multiplier for lp rewards - num_blocks: - type: string - title: Block number since the creation of PoolInfo - dex_reward_amount_given: - type: string - title: Total dex rewards given - eden_reward_amount_given: - type: string - title: Total eden rewards given - eden_apr: - type: string - title: Eden APR, updated at every distribution - dex_apr: - type: string - title: Dex APR, updated at every distribution - title: Pool Info - elys.incentive.PoolMultiplier: + title: Maximum eden reward apr for stakers - [0 - 0.3] + eden_boost_apr: + type: string + dex_rewards_stakers: + title: Tracking dex rewards given to stakers + type: object + properties: + num_blocks: + type: string + title: Number of blocks since start of epoch (distribution epoch) + amount: + type: string + title: >- + Accumulated amount at distribution epoch - recalculated at + every + + distribution epoch + description: QueryParamsResponse is response type for the Query/Params RPC method. + elys.estaking.QueryRewardsResponse: type: object properties: - pool_id: - type: string - format: uint64 - multiplier: - type: string + rewards: + type: array + items: + type: object + properties: + validator_address: + type: string + reward: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + DecCoin defines a token with a denomination and a decimal + amount. + + + NOTE: The amount field is an Dec which implements the custom + method + + signatures required by gogoproto. + description: rewards defines all the rewards accrued by a delegator. + total: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: |- + DecCoin defines a token with a denomination and a decimal amount. + + NOTE: The amount field is an Dec which implements the custom method + signatures required by gogoproto. + description: total defines the sum of all the rewards. + elys.commitment.EarnType: + type: string + enum: + - ALL_PROGRAM + - USDC_PROGRAM + - ELYS_PROGRAM + - EDEN_PROGRAM + - EDENB_PROGRAM + - LP_MINING_PROGRAM + default: ALL_PROGRAM elys.incentive.PoolRewards: type: object properties: @@ -84870,9 +86227,68 @@ definitions: amount: type: string description: |- - Coin defines a token with a denomination and an amount. + Coin defines a token with a denomination and an amount. + + NOTE: The amount field is an Int which implements the custom method + signatures required by gogoproto. + elys.incentive.QueryAllProgramRewardsResponse: + type: object + properties: + usdc_staking_rewards: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: |- + DecCoin defines a token with a denomination and a decimal amount. + + NOTE: The amount field is an Dec which implements the custom method + signatures required by gogoproto. + elys_staking_rewards: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: |- + DecCoin defines a token with a denomination and a decimal amount. - NOTE: The amount field is an Int which implements the custom method + NOTE: The amount field is an Dec which implements the custom method + signatures required by gogoproto. + eden_staking_rewards: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: |- + DecCoin defines a token with a denomination and a decimal amount. + + NOTE: The amount field is an Dec which implements the custom method + signatures required by gogoproto. + edenb_staking_rewards: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: |- + DecCoin defines a token with a denomination and a decimal amount. + + NOTE: The amount field is an Dec which implements the custom method signatures required by gogoproto. elys.incentive.QueryAprResponse: type: object @@ -84902,189 +86318,6 @@ definitions: type: string edenb_apr_elys: type: string - elys.incentive.QueryCommunityPoolResponse: - type: object - properties: - pool: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: |- - DecCoin defines a token with a denomination and a decimal amount. - - NOTE: The amount field is an Dec which implements the custom method - signatures required by gogoproto. - description: pool defines community pool's coins. - elys.incentive.QueryParamsResponse: - type: object - properties: - params: - description: params holds all the parameters of this module. - type: object - properties: - lp_incentives: - type: object - properties: - eden_amount_per_year: - type: string - title: reward amount in eden for 1 year - distribution_start_block: - type: string - title: starting block height of the distribution - total_blocks_per_year: - type: string - title: distribution duration - block number per year - epoch_num_blocks: - type: string - title: unused - max_eden_per_allocation: - type: string - title: maximum eden allocation per day that won't exceed 30% apr - distribution_epoch_in_blocks: - type: string - title: unused - current_epoch_in_blocks: - type: string - title: current epoch in block number - title: Incentive Info - stake_incentives: - type: object - properties: - eden_amount_per_year: - type: string - title: reward amount in eden for 1 year - distribution_start_block: - type: string - title: starting block height of the distribution - total_blocks_per_year: - type: string - title: distribution duration - block number per year - epoch_num_blocks: - type: string - title: unused - max_eden_per_allocation: - type: string - title: maximum eden allocation per day that won't exceed 30% apr - distribution_epoch_in_blocks: - type: string - title: unused - current_epoch_in_blocks: - type: string - title: current epoch in block number - title: Incentive Info - reward_portion_for_lps: - type: string - description: >- - Dex revenue percent for lps, `100 - reward_portion_for_lps - - reward_portion_for_stakers = revenue percent for protocol`. - reward_portion_for_stakers: - type: string - description: >- - Dex revenue percent for lps, `100 - reward_portion_for_lps - - reward_portion_for_stakers = revenue percent for protocol`. - pool_infos: - type: array - items: - type: object - properties: - pool_id: - type: string - format: uint64 - title: reward amount - reward_wallet: - type: string - title: reward wallet address - multiplier: - type: string - title: multiplier for lp rewards - num_blocks: - type: string - title: Block number since the creation of PoolInfo - dex_reward_amount_given: - type: string - title: Total dex rewards given - eden_reward_amount_given: - type: string - title: Total eden rewards given - eden_apr: - type: string - title: Eden APR, updated at every distribution - dex_apr: - type: string - title: Dex APR, updated at every distribution - title: Pool Info - title: |- - Pool information - poolId, reward wallet, **multiplier**, dex rewards given - elys_stake_snap_interval: - type: string - format: int64 - title: Number of blocks to update elys staked amount for delegators - dex_rewards_stakers: - title: Tracking dex rewards given to stakers - type: object - properties: - num_blocks: - type: string - title: Number of blocks since start of epoch (distribution epoch) - amount: - type: string - title: >- - Accumulated amount at distribution epoch - recalculated at - every distribution epoch - amount_collected_by_other_tracker: - type: string - title: >- - Accumulated rewards tracked by other (when it's for staking, - from lp, if it's for lp, from staking) - dex_rewards_lps: - title: Tracking dex rewards given to LPs - type: object - properties: - num_blocks: - type: string - title: Number of blocks since start of epoch (distribution epoch) - amount: - type: string - title: >- - Accumulated amount at distribution epoch - recalculated at - every distribution epoch - amount_collected_by_other_tracker: - type: string - title: >- - Accumulated rewards tracked by other (when it's for staking, - from lp, if it's for lp, from staking) - max_eden_reward_apr_stakers: - type: string - title: Maximum eden reward apr for stakers - [0 - 0.3] - max_eden_reward_apr_lps: - type: string - title: Maximum eden reward apr for lps - [0 - 0.3] - distribution_interval: - type: string - format: int64 - title: >- - Distribution interval in blocks - number of blocks on distribution - epoch - description: QueryParamsResponse is response type for the Query/Params RPC method. - elys.incentive.QueryPoolAprsResponse: - type: object - properties: - data: - type: array - items: - type: object - properties: - pool_id: - type: string - format: uint64 - apr: - type: string elys.incentive.QueryPoolRewardsResponse: type: object properties: @@ -85596,6 +86829,456 @@ definitions: repeated Bar results = 1; PageResponse page = 2; } + elys.masterchef.DexRewardsTracker: + type: object + properties: + num_blocks: + type: string + title: Number of blocks since start of epoch (distribution epoch) + amount: + type: string + title: >- + Accumulated amount at distribution epoch - recalculated at every + distribution epoch + title: >- + DexRewardsTracker is used for tracking rewards for LPs, all amount here is + in USDC + elys.masterchef.ExternalIncentive: + type: object + properties: + id: + type: string + format: uint64 + reward_denom: + type: string + pool_id: + type: string + format: uint64 + from_block: + type: string + format: uint64 + to_block: + type: string + format: uint64 + amount_per_block: + type: string + description: ExternalIncentive defines the external incentives. + elys.masterchef.IncentiveInfo: + type: object + properties: + eden_amount_per_year: + type: string + title: reward amount in eden for 1 year + distribution_start_block: + type: string + title: starting block height of the distribution + total_blocks_per_year: + type: string + title: distribution duration - block number per year + blocks_distributed: + type: string + title: blocks distributed + title: Incentive Info + elys.masterchef.MsgAddExternalIncentiveResponse: + type: object + elys.masterchef.MsgAddExternalRewardDenomResponse: + type: object + elys.masterchef.MsgClaimRewardsResponse: + type: object + elys.masterchef.MsgUpdateParamsResponse: + type: object + elys.masterchef.MsgUpdatePoolMultipliersResponse: + type: object + elys.masterchef.Params: + type: object + properties: + lp_incentives: + type: object + properties: + eden_amount_per_year: + type: string + title: reward amount in eden for 1 year + distribution_start_block: + type: string + title: starting block height of the distribution + total_blocks_per_year: + type: string + title: distribution duration - block number per year + blocks_distributed: + type: string + title: blocks distributed + title: Incentive Info + reward_portion_for_lps: + type: string + description: >- + gas fees and swap fees portion for lps, `100 - reward_portion_for_lps + - reward_portion_for_stakers = revenue percent for protocol`. + reward_portion_for_stakers: + type: string + description: >- + gas fees and swap fees portion for stakers, `100 - + reward_portion_for_lps - reward_portion_for_stakers = revenue percent + for protocol`. + dex_rewards_lps: + title: Tracking dex rewards given to LPs + type: object + properties: + num_blocks: + type: string + title: Number of blocks since start of epoch (distribution epoch) + amount: + type: string + title: >- + Accumulated amount at distribution epoch - recalculated at every + distribution epoch + max_eden_reward_apr_lps: + type: string + title: Maximum eden reward apr for lps - [0 - 0.3] + supported_reward_denoms: + type: array + items: + type: object + properties: + denom: + type: string + min_amount: + type: string + protocol_revenue_address: + type: string + description: Params defines the parameters for the module. + elys.masterchef.PoolApr: + type: object + properties: + pool_id: + type: string + format: uint64 + eden_apr: + type: string + usdc_apr: + type: string + total_apr: + type: string + elys.masterchef.PoolInfo: + type: object + properties: + pool_id: + type: string + format: uint64 + title: reward amount + reward_wallet: + type: string + title: reward wallet address + multiplier: + type: string + title: multiplier for lp rewards + num_blocks: + type: string + title: Block number since the creation of PoolInfo + dex_reward_amount_given: + type: string + title: Total dex rewards given + eden_reward_amount_given: + type: string + title: Total eden rewards given + eden_apr: + type: string + title: Eden APR, updated at every distribution + dex_apr: + type: string + title: Dex APR, updated at every distribution + external_incentive_apr: + type: string + title: External Incentive APR, updated at every distribution + external_reward_denoms: + type: array + items: + type: string + title: external reward denoms on the pool + title: Pool Info + elys.masterchef.PoolMultiplier: + type: object + properties: + pool_id: + type: string + format: uint64 + multiplier: + type: string + elys.masterchef.PoolRewardInfo: + type: object + properties: + pool_id: + type: string + format: uint64 + reward_denom: + type: string + pool_acc_reward_per_share: + type: string + last_updated_block: + type: string + format: uint64 + elys.masterchef.QueryExternalIncentiveResponse: + type: object + properties: + external_incentive: + type: object + properties: + id: + type: string + format: uint64 + reward_denom: + type: string + pool_id: + type: string + format: uint64 + from_block: + type: string + format: uint64 + to_block: + type: string + format: uint64 + amount_per_block: + type: string + description: ExternalIncentive defines the external incentives. + elys.masterchef.QueryParamsResponse: + type: object + properties: + params: + description: params holds all the parameters of this module. + type: object + properties: + lp_incentives: + type: object + properties: + eden_amount_per_year: + type: string + title: reward amount in eden for 1 year + distribution_start_block: + type: string + title: starting block height of the distribution + total_blocks_per_year: + type: string + title: distribution duration - block number per year + blocks_distributed: + type: string + title: blocks distributed + title: Incentive Info + reward_portion_for_lps: + type: string + description: >- + gas fees and swap fees portion for lps, `100 - + reward_portion_for_lps - reward_portion_for_stakers = revenue + percent for protocol`. + reward_portion_for_stakers: + type: string + description: >- + gas fees and swap fees portion for stakers, `100 - + reward_portion_for_lps - reward_portion_for_stakers = revenue + percent for protocol`. + dex_rewards_lps: + title: Tracking dex rewards given to LPs + type: object + properties: + num_blocks: + type: string + title: Number of blocks since start of epoch (distribution epoch) + amount: + type: string + title: >- + Accumulated amount at distribution epoch - recalculated at + every distribution epoch + max_eden_reward_apr_lps: + type: string + title: Maximum eden reward apr for lps - [0 - 0.3] + supported_reward_denoms: + type: array + items: + type: object + properties: + denom: + type: string + min_amount: + type: string + protocol_revenue_address: + type: string + description: QueryParamsResponse is response type for the Query/Params RPC method. + elys.masterchef.QueryPoolAprsResponse: + type: object + properties: + data: + type: array + items: + type: object + properties: + pool_id: + type: string + format: uint64 + eden_apr: + type: string + usdc_apr: + type: string + total_apr: + type: string + elys.masterchef.QueryPoolInfoResponse: + type: object + properties: + pool_info: + type: object + properties: + pool_id: + type: string + format: uint64 + title: reward amount + reward_wallet: + type: string + title: reward wallet address + multiplier: + type: string + title: multiplier for lp rewards + num_blocks: + type: string + title: Block number since the creation of PoolInfo + dex_reward_amount_given: + type: string + title: Total dex rewards given + eden_reward_amount_given: + type: string + title: Total eden rewards given + eden_apr: + type: string + title: Eden APR, updated at every distribution + dex_apr: + type: string + title: Dex APR, updated at every distribution + external_incentive_apr: + type: string + title: External Incentive APR, updated at every distribution + external_reward_denoms: + type: array + items: + type: string + title: external reward denoms on the pool + title: Pool Info + elys.masterchef.QueryPoolRewardInfoResponse: + type: object + properties: + pool_reward_info: + type: object + properties: + pool_id: + type: string + format: uint64 + reward_denom: + type: string + pool_acc_reward_per_share: + type: string + last_updated_block: + type: string + format: uint64 + elys.masterchef.QueryStableStakeAprResponse: + type: object + properties: + apr: + type: string + elys.masterchef.QueryUserPendingRewardResponse: + type: object + properties: + rewards: + type: array + items: + type: object + properties: + pool_id: + type: string + format: uint64 + reward: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an amount. + + + NOTE: The amount field is an Int which implements the custom + method + + signatures required by gogoproto. + total_rewards: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: |- + Coin defines a token with a denomination and an amount. + + NOTE: The amount field is an Int which implements the custom method + signatures required by gogoproto. + elys.masterchef.QueryUserRewardInfoResponse: + type: object + properties: + user_reward_info: + type: object + properties: + user: + type: string + pool_id: + type: string + format: uint64 + reward_denom: + type: string + reward_debt: + type: string + reward_pending: + type: string + elys.masterchef.RewardInfo: + type: object + properties: + pool_id: + type: string + format: uint64 + reward: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: |- + Coin defines a token with a denomination and an amount. + + NOTE: The amount field is an Int which implements the custom method + signatures required by gogoproto. + elys.masterchef.SupportedRewardDenom: + type: object + properties: + denom: + type: string + min_amount: + type: string + elys.masterchef.UserRewardInfo: + type: object + properties: + user: + type: string + pool_id: + type: string + format: uint64 + reward_denom: + type: string + reward_debt: + type: string + reward_pending: + type: string elys.oracle.AssetInfo: type: object properties: diff --git a/proto/elys/commitment/commitments.proto b/proto/elys/commitment/commitments.proto index 53b97e803..3bb7024b7 100644 --- a/proto/elys/commitment/commitments.proto +++ b/proto/elys/commitment/commitments.proto @@ -15,35 +15,11 @@ option go_package = "github.com/elys-network/elys/x/commitment/types"; message Commitments { string creator = 1; repeated CommittedTokens committed_tokens = 2; - repeated cosmos.base.v1beta1.Coin rewards_unclaimed = 3 [ - (gogoproto.nullable) = false, - (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" - ]; - repeated cosmos.base.v1beta1.Coin claimed = 4 [ - (gogoproto.nullable) = false, - (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" - ]; - repeated VestingTokens vesting_tokens = 5; - - repeated cosmos.base.v1beta1.Coin rewards_by_elys_unclaimed = 6 [ - (gogoproto.nullable) = false, - (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" - ]; - - repeated cosmos.base.v1beta1.Coin rewards_by_eden_unclaimed = 7 [ - (gogoproto.nullable) = false, - (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" - ]; - - repeated cosmos.base.v1beta1.Coin rewards_by_edenb_unclaimed = 8 [ - (gogoproto.nullable) = false, - (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" - ]; - - repeated cosmos.base.v1beta1.Coin rewards_by_usdc_unclaimed = 9 [ + repeated cosmos.base.v1beta1.Coin claimed = 3 [ (gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" ]; + repeated VestingTokens vesting_tokens = 4; } message Lockup { @@ -63,14 +39,6 @@ message CommittedTokens { repeated Lockup lockups = 3 [ (gogoproto.nullable) = false ]; } -message RewardsUnclaimed { - string denom = 1; - string amount = 2 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", - (gogoproto.nullable) = false - ]; -} - message VestingTokens { string denom = 1; string total_amount = 2 [ @@ -86,8 +54,6 @@ message VestingTokens { int64 vest_started_timestamp = 7; } - -// GenesisState defines the commitment module's genesis state. message LegacyCommitments { string creator = 1; repeated CommittedTokens committed_tokens = 2; @@ -99,7 +65,7 @@ message LegacyCommitments { (gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" ]; - repeated LegacyVestingTokens vesting_tokens = 5; + repeated VestingTokens vesting_tokens = 5; repeated cosmos.base.v1beta1.Coin rewards_by_elys_unclaimed = 6 [ (gogoproto.nullable) = false, @@ -121,38 +87,3 @@ message LegacyCommitments { (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" ]; } - -message LegacyVestingTokens { - string denom = 1; - string total_amount = 2 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", - (gogoproto.nullable) = false - ]; - string unvested_amount = 3 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", - (gogoproto.nullable) = false - ]; - string epoch_identifier = 4; - int64 num_epochs = 5; - int64 current_epoch = 6; - int64 vest_started_timestamp = 7; -} - -message LegacyVestingInfo { - string base_denom = 1; - string vesting_denom = 2; - string epoch_identifier = 3; - int64 num_epochs = 4; - string vest_now_factor = 5 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", - (gogoproto.nullable) = false - ]; - int64 num_max_vestings = 6; -} - -// Params defines the parameters for the module. -message LegacyParams { - option (gogoproto.goproto_stringer) = false; - - repeated LegacyVestingInfo vesting_infos = 1; -} \ No newline at end of file diff --git a/proto/elys/commitment/types_cw.proto b/proto/elys/commitment/types_cw.proto index 5d06c725d..8b8136e89 100644 --- a/proto/elys/commitment/types_cw.proto +++ b/proto/elys/commitment/types_cw.proto @@ -208,12 +208,6 @@ message QueryUnstakedPositionResponse { repeated UnstakedPosition unstaked_position = 1 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; } -message QuerySubBucketBalanceRequest { - string address = 1; - string denom = 2; - elys.commitment.EarnType program = 3; -} - message QueryVestingInfoRequest { string address = 1; } diff --git a/proto/elys/estaking/dex_rewards_tracker.proto b/proto/elys/estaking/dex_rewards_tracker.proto new file mode 100644 index 000000000..591683a78 --- /dev/null +++ b/proto/elys/estaking/dex_rewards_tracker.proto @@ -0,0 +1,23 @@ +syntax = "proto3"; +package elys.estaking; + +option go_package = "github.com/elys-network/elys/x/estaking/types"; +option (gogoproto.equal_all) = true; + +import "gogoproto/gogo.proto"; + +// DexRewardsTracker is used for tracking rewards for stakers and LPs, all +// amount here is in USDC +message DexRewardsTracker { + // Number of blocks since start of epoch (distribution epoch) + string num_blocks = 1 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; + // Accumulated amount at distribution epoch - recalculated at every + // distribution epoch + string amount = 2 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; +} diff --git a/proto/elys/estaking/elys_staked.proto b/proto/elys/estaking/elys_staked.proto new file mode 100644 index 000000000..e31cc8d56 --- /dev/null +++ b/proto/elys/estaking/elys_staked.proto @@ -0,0 +1,17 @@ +syntax = "proto3"; +package elys.estaking; + +option go_package = "github.com/elys-network/elys/x/estaking/types"; +option (gogoproto.equal_all) = true; + +import "gogoproto/gogo.proto"; + +// Elys staked amount is tracked because EdenBoost has to be burnt when unstake ELYS event happens, +// and there's no way to track staked amount change from staking hook and this struct is added. +message ElysStaked { + string address = 1; + string amount = 2 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; +} diff --git a/proto/elys/estaking/genesis.proto b/proto/elys/estaking/genesis.proto new file mode 100644 index 000000000..a22e59123 --- /dev/null +++ b/proto/elys/estaking/genesis.proto @@ -0,0 +1,14 @@ +syntax = "proto3"; +package elys.estaking; + +import "gogoproto/gogo.proto"; +import "elys/estaking/params.proto"; +import "elys/estaking/elys_staked.proto"; + +option go_package = "github.com/elys-network/elys/x/estaking/types"; + +// GenesisState defines the estaking module's genesis state. +message GenesisState { + Params params = 1 [(gogoproto.nullable) = false]; + repeated ElysStaked staking_snapshots = 2 [ (gogoproto.nullable) = false ]; +} diff --git a/proto/elys/estaking/incentive.proto b/proto/elys/estaking/incentive.proto new file mode 100644 index 000000000..157bd8e47 --- /dev/null +++ b/proto/elys/estaking/incentive.proto @@ -0,0 +1,22 @@ +syntax = "proto3"; +package elys.estaking; +import "gogoproto/gogo.proto"; +import "google/protobuf/timestamp.proto"; + +option go_package = "github.com/elys-network/elys/x/estaking/types"; + +// Incentive Info +message IncentiveInfo { + // reward amount in eden for 1 year + string eden_amount_per_year = 1 + [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false]; + // starting block height of the distribution + string distribution_start_block = 2 + [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false]; + // distribution duration - block number per year + string total_blocks_per_year = 3 + [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false]; + // blocks distributed + string blocks_distributed = 4 + [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false]; +} \ No newline at end of file diff --git a/proto/elys/estaking/params.proto b/proto/elys/estaking/params.proto new file mode 100644 index 000000000..c0994d81e --- /dev/null +++ b/proto/elys/estaking/params.proto @@ -0,0 +1,28 @@ +syntax = "proto3"; +package elys.estaking; + +import "gogoproto/gogo.proto"; +import "elys/estaking/incentive.proto"; +import "elys/estaking/dex_rewards_tracker.proto"; + +option go_package = "github.com/elys-network/elys/x/estaking/types"; + +// Params defines the parameters for the module. +message Params { + option (gogoproto.goproto_stringer) = false; + + IncentiveInfo stake_incentives = 1; + string eden_commit_val = 2; + string edenb_commit_val = 3; + // Maximum eden reward apr for stakers - [0 - 0.3] + string max_eden_reward_apr_stakers = 5 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + string eden_boost_apr = 6 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + // Tracking dex rewards given to stakers + DexRewardsTracker dex_rewards_stakers = 7 [ (gogoproto.nullable) = false ]; +} diff --git a/proto/elys/estaking/query.proto b/proto/elys/estaking/query.proto new file mode 100644 index 000000000..0f6c394a4 --- /dev/null +++ b/proto/elys/estaking/query.proto @@ -0,0 +1,53 @@ +syntax = "proto3"; +package elys.estaking; + +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; +import "cosmos/base/v1beta1/coin.proto"; +import "cosmos/base/query/v1beta1/pagination.proto"; +import "elys/estaking/params.proto"; + +option go_package = "github.com/elys-network/elys/x/estaking/types"; + +// Query defines the gRPC querier service. +service Query { + // Parameters queries the parameters of the module. + rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { + option (google.api.http).get = "/elys-network/elys/estaking/params"; + } + // Rewards queries the total rewards accrued by a delegation + rpc Rewards(QueryRewardsRequest) returns (QueryRewardsResponse) { + option (google.api.http).get = "/elys-network/elys/estaking/rewards/{address}"; + } +} + +// 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 holds all the parameters of this module. + Params params = 1 [(gogoproto.nullable) = false]; +} + +message QueryRewardsRequest { + string address = 1; +} + +message DelegationDelegatorReward { + string validator_address = 1; + repeated cosmos.base.v1beta1.DecCoin reward = 2 [ + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins", + (gogoproto.nullable) = false + ]; +} + +message QueryRewardsResponse { + // rewards defines all the rewards accrued by a delegator. + repeated DelegationDelegatorReward rewards = 1 [(gogoproto.nullable) = false]; + // total defines the sum of all the rewards. + repeated cosmos.base.v1beta1.DecCoin total = 2 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins" + ]; +} \ No newline at end of file diff --git a/proto/elys/estaking/tx.proto b/proto/elys/estaking/tx.proto new file mode 100644 index 000000000..886a4f56c --- /dev/null +++ b/proto/elys/estaking/tx.proto @@ -0,0 +1,57 @@ +syntax = "proto3"; +package elys.estaking; + +import "gogoproto/gogo.proto"; +import "cosmos/base/v1beta1/coin.proto"; +import "elys/estaking/params.proto"; + +option go_package = "github.com/elys-network/elys/x/estaking/types"; + +// Msg defines the Msg service. +service Msg { + // UpdateParams defines a governance operation for updating the x/distribution + // module parameters. The authority is defined in the keeper. + rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse); + + // WithdrawReward defines a method to withdraw rewards of delegator from a single validator. + rpc WithdrawReward(MsgWithdrawReward) returns (MsgWithdrawRewardResponse); + + // WithdrawElysStakingRewards defines a method to withdraw rewards of delegator from all the validators. + rpc WithdrawElysStakingRewards(MsgWithdrawElysStakingRewards) returns (MsgWithdrawElysStakingRewardsResponse); +} + +// MsgUpdateParams is the Msg/UpdateParams request type. +message MsgUpdateParams { + string authority = 1; + Params params = 2 [ (gogoproto.nullable) = false ]; +} + +// MsgUpdateParamsResponse defines the response structure for executing a MsgUpdateParams message. +message MsgUpdateParamsResponse {} + +// MsgWithdrawReward represents delegation withdrawal to a delegator from a single validator. +message MsgWithdrawReward { + string delegator_address = 1; + string validator_address = 2; +} + +// MsgWithdrawRewardResponse defines the Msg/WithdrawDelegatorReward response type. +message MsgWithdrawRewardResponse { + repeated cosmos.base.v1beta1.Coin amount = 1 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" + ]; +} + +// MsgWithdrawElysStakingRewards represents delegation withdrawal to a delegator from all the validators. +message MsgWithdrawElysStakingRewards { + string delegator_address = 1; +} + +// MsgWithdrawElysStakingRewards defines the Msg/WithdrawElysStakingRewards response type. +message MsgWithdrawElysStakingRewardsResponse { + repeated cosmos.base.v1beta1.Coin amount = 1 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" + ]; +} \ No newline at end of file diff --git a/proto/elys/incentive/dex_rewards_traker.proto b/proto/elys/incentive/dex_rewards_traker.proto index 0b2fee4e3..99949591b 100644 --- a/proto/elys/incentive/dex_rewards_traker.proto +++ b/proto/elys/incentive/dex_rewards_traker.proto @@ -1,26 +1,29 @@ syntax = "proto3"; package elys.incentive; -option go_package = "github.com/elys-network/elys/x/incentive/types"; +option go_package = "github.com/elys-network/elys/x/incentive/types"; option (gogoproto.equal_all) = true; import "gogoproto/gogo.proto"; -// DexRewardsTracker is used for tracking rewards for stakers and LPs, all amount here is in USDC +// DexRewardsTracker is used for tracking rewards for stakers and LPs, all +// amount here is in USDC message DexRewardsTracker { - // Number of blocks since start of epoch (distribution epoch) - string num_blocks = 1 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", - (gogoproto.nullable) = false - ]; - // Accumulated amount at distribution epoch - recalculated at every distribution epoch - string amount = 2 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false - ]; - // Accumulated rewards tracked by other (when it's for staking, from lp, if it's for lp, from staking) - string amount_collected_by_other_tracker = 3 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false - ]; + // Number of blocks since start of epoch (distribution epoch) + string num_blocks = 1 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; + // Accumulated amount at distribution epoch - recalculated at every + // distribution epoch + string amount = 2 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + // Accumulated rewards tracked by other (when it's for staking, from lp, if + // it's for lp, from staking) + string amount_collected_by_other_tracker = 3 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; } diff --git a/proto/elys/incentive/distribution.proto b/proto/elys/incentive/distribution.proto deleted file mode 100644 index 53a86c838..000000000 --- a/proto/elys/incentive/distribution.proto +++ /dev/null @@ -1,16 +0,0 @@ -syntax = "proto3"; -package elys.incentive; - -option go_package = "github.com/elys-network/elys/x/incentive/types"; -option (gogoproto.equal_all) = true; - -import "gogoproto/gogo.proto"; -import "cosmos/base/v1beta1/coin.proto"; - -// FeePool is the global fee pool for distribution. -message FeePool { - repeated cosmos.base.v1beta1.DecCoin community_pool = 1 [ - (gogoproto.nullable) = false, - (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins" - ]; -} diff --git a/proto/elys/incentive/genesis.proto b/proto/elys/incentive/genesis.proto index e03177057..7421b44af 100644 --- a/proto/elys/incentive/genesis.proto +++ b/proto/elys/incentive/genesis.proto @@ -3,8 +3,6 @@ syntax = "proto3"; package elys.incentive; import "gogoproto/gogo.proto"; -import "elys/incentive/params.proto"; -import "elys/incentive/distribution.proto"; import "cosmos/base/v1beta1/coin.proto"; option go_package = "github.com/elys-network/elys/x/incentive/types"; @@ -12,8 +10,4 @@ option go_package = "github.com/elys-network/elys/x/incentive/types"; // GenesisState defines the incentive module's genesis state. message GenesisState { - Params params = 1 [(gogoproto.nullable) = false]; - - // fee_pool defines the fee pool at genesis. - FeePool fee_pool = 2 [(gogoproto.nullable) = false]; } diff --git a/proto/elys/incentive/incentive.proto b/proto/elys/incentive/incentive.proto index 7b63431b6..3a2784c48 100644 --- a/proto/elys/incentive/incentive.proto +++ b/proto/elys/incentive/incentive.proto @@ -7,25 +7,39 @@ option go_package = "github.com/elys-network/elys/x/incentive/types"; // Incentive Info message IncentiveInfo { - // reward amount in eden for 1 year - string eden_amount_per_year = 1 - [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false]; - // starting block height of the distribution - string distribution_start_block = 2 - [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false]; - // distribution duration - block number per year - string total_blocks_per_year = 3 - [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false]; - // unused - string epoch_num_blocks = 4 - [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false]; - // unused - string max_eden_per_allocation = 5 - [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false]; - // unused - string distribution_epoch_in_blocks = 6 - [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false]; - // current epoch in block number - string current_epoch_in_blocks = 7 - [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false]; + // reward amount in eden for 1 year + string eden_amount_per_year = 1 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; + // starting block height of the distribution + string distribution_start_block = 2 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; + // distribution duration - block number per year + string total_blocks_per_year = 3 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; + // unused + string epoch_num_blocks = 4 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; + // unused + string max_eden_per_allocation = 5 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; + // unused + string distribution_epoch_in_blocks = 6 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; + // current epoch in block number + string current_epoch_in_blocks = 7 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; } \ No newline at end of file diff --git a/proto/elys/incentive/params.proto b/proto/elys/incentive/params.proto index 6ff5d7303..462ac9246 100644 --- a/proto/elys/incentive/params.proto +++ b/proto/elys/incentive/params.proto @@ -11,16 +11,18 @@ option go_package = "github.com/elys-network/elys/x/incentive/types"; // Params defines the parameters for the module. message Params { option (gogoproto.goproto_stringer) = false; - IncentiveInfo lp_incentives = 1; - IncentiveInfo stake_incentives = 2; + IncentiveInfo lp_incentives = 1; + IncentiveInfo stake_incentives = 2; - // Dex revenue percent for lps, `100 - reward_portion_for_lps - reward_portion_for_stakers = revenue percent for protocol`. + // Dex revenue percent for lps, `100 - reward_portion_for_lps - + // reward_portion_for_stakers = revenue percent for protocol`. string reward_portion_for_lps = 3 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false ]; - // Dex revenue percent for lps, `100 - reward_portion_for_lps - reward_portion_for_stakers = revenue percent for protocol`. + // Dex revenue percent for lps, `100 - reward_portion_for_lps - + // reward_portion_for_stakers = revenue percent for protocol`. string reward_portion_for_stakers = 4 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false @@ -28,16 +30,16 @@ message Params { // Pool information // poolId, reward wallet, **multiplier**, dex rewards given - repeated PoolInfo pool_infos = 5 [(gogoproto.nullable) = false]; + repeated PoolInfo pool_infos = 5 [ (gogoproto.nullable) = false ]; // Number of blocks to update elys staked amount for delegators - int64 elys_stake_snap_interval = 6; + int64 elys_stake_snap_interval = 6; // Tracking dex rewards given to stakers - DexRewardsTracker dex_rewards_stakers = 7 [(gogoproto.nullable) = false]; - + DexRewardsTracker dex_rewards_stakers = 7 [ (gogoproto.nullable) = false ]; + // Tracking dex rewards given to LPs - DexRewardsTracker dex_rewards_lps = 8 [(gogoproto.nullable) = false]; + DexRewardsTracker dex_rewards_lps = 8 [ (gogoproto.nullable) = false ]; // Maximum eden reward apr for stakers - [0 - 0.3] string max_eden_reward_apr_stakers = 9 [ diff --git a/proto/elys/incentive/pool.proto b/proto/elys/incentive/pool.proto index 31a1dd8ca..1dd2f4080 100644 --- a/proto/elys/incentive/pool.proto +++ b/proto/elys/incentive/pool.proto @@ -8,38 +8,38 @@ import "cosmos_proto/cosmos.proto"; // Pool Info message PoolInfo { - // reward amount - uint64 pool_id = 1; - // reward wallet address - string reward_wallet = 2; - // multiplier for lp rewards - string multiplier = 3 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false - ]; - // Block number since the creation of PoolInfo - string num_blocks = 4 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", - (gogoproto.nullable) = false - ]; - // Total dex rewards given - string dex_reward_amount_given = 5 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false - ]; - // Total eden rewards given - string eden_reward_amount_given = 6 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", - (gogoproto.nullable) = false - ]; - // Eden APR, updated at every distribution - string eden_apr = 7 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false - ]; - // Dex APR, updated at every distribution - string dex_apr = 8 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false - ]; + // reward amount + uint64 pool_id = 1; + // reward wallet address + string reward_wallet = 2; + // multiplier for lp rewards + string multiplier = 3 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + // Block number since the creation of PoolInfo + string num_blocks = 4 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; + // Total dex rewards given + string dex_reward_amount_given = 5 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + // Total eden rewards given + string eden_reward_amount_given = 6 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; + // Eden APR, updated at every distribution + string eden_apr = 7 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + // Dex APR, updated at every distribution + string dex_apr = 8 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; } \ No newline at end of file diff --git a/proto/elys/incentive/query.proto b/proto/elys/incentive/query.proto index 77bfd04a4..30154228d 100644 --- a/proto/elys/incentive/query.proto +++ b/proto/elys/incentive/query.proto @@ -2,8 +2,7 @@ syntax = "proto3"; package elys.incentive; -import "elys/incentive/params.proto"; -import "elys/incentive/distribution.proto"; +import "cosmos_proto/cosmos.proto"; import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; import "cosmos/base/v1beta1/coin.proto"; @@ -14,16 +13,6 @@ option go_package = "github.com/elys-network/elys/x/incentive/types"; // Query defines the gRPC querier service. service Query { - // Parameters queries the parameters of the module. - rpc Params (QueryParamsRequest) returns (QueryParamsResponse) { - option (google.api.http).get = "/elys-network/elys/incentive/params"; - } - - // Queries a list of CommunityPool items. - rpc CommunityPool (QueryCommunityPoolRequest) returns (QueryCommunityPoolResponse) { - option (google.api.http).get = "/elys-network/elys/incentive/community_pool"; - } - // Calculate APR rpc Apr (QueryAprRequest) returns (QueryAprResponse) { option (google.api.http).get = "/elys-network/elys/incentive/apr/{withdraw_type}/{denom}"; @@ -34,30 +23,15 @@ service Query { option (google.api.http).get = "/elys-network/elys/incentive/aprs"; } - // Calculate liquidity mining pool APRs - rpc PoolAprs (QueryPoolAprsRequest) returns (QueryPoolAprsResponse) { - option (google.api.http).get = "/elys-network/elys/incentive/pool_aprs"; - } - // Queries PoolReward items rpc PoolRewards(QueryPoolRewardsRequest) returns (QueryPoolRewardsResponse) { option (google.api.http).get = "/elys-network/elys/incentive/pool_rewards"; } -} -// 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 holds all the parameters of this module. - Params params = 1 [(gogoproto.nullable) = false]; -} - -message QueryCommunityPoolRequest {} - -message QueryCommunityPoolResponse { - // pool defines community pool's coins. - repeated cosmos.base.v1beta1.DecCoin pool = 1 [(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins", (gogoproto.nullable) = false]; + // Queries all program rewards + rpc AllProgramRewards(QueryAllProgramRewardsRequest) returns (QueryAllProgramRewardsResponse) { + option (google.api.http).get = "/elys-network/elys/incentive/all_program_rewards"; + } } message QueryAprRequest { @@ -118,24 +92,29 @@ message QueryAprsResponse { ]; } -message QueryPoolAprsRequest { - repeated uint64 pool_ids = 1; +message QueryAllProgramRewardsRequest { + string address = 1; } -message QueryPoolAprsResponse { - repeated PoolApr data = 1 [ - (gogoproto.nullable) = false +message QueryAllProgramRewardsResponse { + repeated cosmos.base.v1beta1.DecCoin usdc_staking_rewards = 1 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins" ]; -} - -message PoolApr { - uint64 pool_id = 1; - string apr = 2 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false + repeated cosmos.base.v1beta1.DecCoin elys_staking_rewards = 2 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins" + ]; + repeated cosmos.base.v1beta1.DecCoin eden_staking_rewards = 3 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins" + ]; + repeated cosmos.base.v1beta1.DecCoin edenb_staking_rewards = 4 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins" ]; } - + message QueryPoolRewardsRequest { repeated uint64 pool_ids = 1; cosmos.base.query.v1beta1.PageRequest pagination = 2; diff --git a/proto/elys/incentive/tx.proto b/proto/elys/incentive/tx.proto index 72e998d2d..e64906841 100644 --- a/proto/elys/incentive/tx.proto +++ b/proto/elys/incentive/tx.proto @@ -11,64 +11,8 @@ option go_package = "github.com/elys-network/elys/x/incentive/types"; // Msg defines the Msg service. service Msg { - // WithdrawDelegatorReward defines a method to withdraw rewards of delegator - // from a single validator. - rpc WithdrawRewards (MsgWithdrawRewards) returns (MsgWithdrawRewardsResponse); - - // WithdrawValidatorCommission defines a method to withdraw the - // full commission to the validator address. - rpc WithdrawValidatorCommission(MsgWithdrawValidatorCommission) returns (MsgWithdrawValidatorCommissionResponse); - rpc UpdateIncentiveParams(MsgUpdateIncentiveParams) returns (MsgUpdateIncentiveParamsResponse); - rpc UpdatePoolMultipliers(MsgUpdatePoolMultipliers) returns (MsgUpdatePoolMultipliersResponse); -} -// MsgWithdrawDelegatorReward represents delegation withdrawal to a delegator -// from a single validator. -message MsgWithdrawRewards { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - string delegator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; - elys.commitment.EarnType withdraw_type = 2; -} - -// MsgWithdrawDelegatorRewardResponse defines the Msg/WithdrawDelegatorReward response type. -message MsgWithdrawRewardsResponse {} - -// MsgWithdrawValidatorCommission withdraws the full commission to the validator -// address. -message MsgWithdrawValidatorCommission { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - string delegator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; - string validator_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; } -// MsgWithdrawValidatorCommissionResponse defines the Msg/WithdrawValidatorCommission response type. -message MsgWithdrawValidatorCommissionResponse {} - -message MsgUpdateIncentiveParams { - string authority = 1; - string reward_portion_for_lps = 2 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false - ]; - string reward_portion_for_stakers = 3 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false - ]; - int64 elys_stake_snap_interval = 4; - string max_eden_reward_apr_stakers = 5 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false - ]; - string max_eden_reward_apr_lps = 6 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false - ]; - int64 distribution_interval = 7; -} - -message MsgUpdateIncentiveParamsResponse {} - message MsgBeginRedelegate { option (gogoproto.equal) = false; option (gogoproto.goproto_getters) = false; @@ -91,16 +35,3 @@ message MsgCancelUnbondingDelegation{ int64 creation_height = 4; } -message PoolMultiplier { - uint64 pool_id = 1; - string multiplier = 2 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false - ]; -} - -message MsgUpdatePoolMultipliers { - string authority = 1; - repeated PoolMultiplier pool_multipliers = 2 [ (gogoproto.nullable) = false ]; -} -message MsgUpdatePoolMultipliersResponse {} diff --git a/proto/elys/masterchef/dex_rewards_traker.proto b/proto/elys/masterchef/dex_rewards_traker.proto new file mode 100644 index 000000000..d67804812 --- /dev/null +++ b/proto/elys/masterchef/dex_rewards_traker.proto @@ -0,0 +1,21 @@ +syntax = "proto3"; +package elys.masterchef; + +option go_package = "github.com/elys-network/elys/x/masterchef/types"; +option (gogoproto.equal_all) = true; + +import "gogoproto/gogo.proto"; + +// DexRewardsTracker is used for tracking rewards for LPs, all amount here is in USDC +message DexRewardsTracker { + // Number of blocks since start of epoch (distribution epoch) + string num_blocks = 1 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; + // Accumulated amount at distribution epoch - recalculated at every distribution epoch + string amount = 2 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; +} diff --git a/proto/elys/masterchef/external_incentive.proto b/proto/elys/masterchef/external_incentive.proto new file mode 100644 index 000000000..7f3f7a4ca --- /dev/null +++ b/proto/elys/masterchef/external_incentive.proto @@ -0,0 +1,17 @@ +syntax = "proto3"; +package elys.masterchef; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/elys-network/elys/x/masterchef/types"; + +// ExternalIncentive defines the external incentives. +message ExternalIncentive { + uint64 id = 1; + string reward_denom = 2; + uint64 pool_id = 3; + uint64 from_block = 4; + uint64 to_block = 5; + string amount_per_block = 6 + [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false]; +} diff --git a/proto/elys/masterchef/genesis.proto b/proto/elys/masterchef/genesis.proto new file mode 100644 index 000000000..e8b5bc53c --- /dev/null +++ b/proto/elys/masterchef/genesis.proto @@ -0,0 +1,18 @@ +syntax = "proto3"; +package elys.masterchef; + +import "gogoproto/gogo.proto"; +import "elys/masterchef/params.proto"; +import "elys/masterchef/external_incentive.proto"; +import "elys/masterchef/pool.proto"; + +option go_package = "github.com/elys-network/elys/x/masterchef/types"; + +// GenesisState defines the masterchef module's genesis state. +message GenesisState { + Params params = 1 [(gogoproto.nullable) = false]; + repeated ExternalIncentive external_incentives = 2 [(gogoproto.nullable) = false]; + repeated PoolInfo pool_infos = 3 [(gogoproto.nullable) = false]; + repeated PoolRewardInfo pool_reward_infos = 4 [(gogoproto.nullable) = false]; + repeated UserRewardInfo user_reward_infos = 5 [(gogoproto.nullable) = false]; +} diff --git a/proto/elys/masterchef/incentive.proto b/proto/elys/masterchef/incentive.proto new file mode 100644 index 000000000..7db58ca24 --- /dev/null +++ b/proto/elys/masterchef/incentive.proto @@ -0,0 +1,22 @@ +syntax = "proto3"; +package elys.masterchef; +import "gogoproto/gogo.proto"; +import "google/protobuf/timestamp.proto"; + +option go_package = "github.com/elys-network/elys/x/masterchef/types"; + +// Incentive Info +message IncentiveInfo { + // reward amount in eden for 1 year + string eden_amount_per_year = 1 + [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false]; + // starting block height of the distribution + string distribution_start_block = 2 + [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false]; + // distribution duration - block number per year + string total_blocks_per_year = 3 + [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false]; + // blocks distributed + string blocks_distributed = 4 + [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false]; +} \ No newline at end of file diff --git a/proto/elys/masterchef/params.proto b/proto/elys/masterchef/params.proto new file mode 100644 index 000000000..2d49e89a5 --- /dev/null +++ b/proto/elys/masterchef/params.proto @@ -0,0 +1,49 @@ +syntax = "proto3"; +package elys.masterchef; + +import "gogoproto/gogo.proto"; +import "elys/masterchef/incentive.proto"; +import "elys/masterchef/pool.proto"; +import "elys/masterchef/dex_rewards_traker.proto"; + +option go_package = "github.com/elys-network/elys/x/masterchef/types"; + +// Params defines the parameters for the module. +message Params { + option (gogoproto.goproto_stringer) = false; + IncentiveInfo lp_incentives = 1; + + // gas fees and swap fees portion for lps, `100 - reward_portion_for_lps - reward_portion_for_stakers = revenue percent for protocol`. + string reward_portion_for_lps = 2 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + + // gas fees and swap fees portion for stakers, `100 - reward_portion_for_lps - reward_portion_for_stakers = revenue percent for protocol`. + string reward_portion_for_stakers = 3 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + + // Tracking dex rewards given to LPs + DexRewardsTracker dex_rewards_lps = 4 [(gogoproto.nullable) = false]; + + // Maximum eden reward apr for lps - [0 - 0.3] + string max_eden_reward_apr_lps = 5 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + + repeated SupportedRewardDenom supported_reward_denoms = 6; + + string protocol_revenue_address = 7; +} + + +message SupportedRewardDenom { + string denom = 1; + string min_amount = 2 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; +} \ No newline at end of file diff --git a/proto/elys/masterchef/pool.proto b/proto/elys/masterchef/pool.proto new file mode 100644 index 000000000..1bf108d2f --- /dev/null +++ b/proto/elys/masterchef/pool.proto @@ -0,0 +1,75 @@ +syntax = "proto3"; +package elys.masterchef; + +option go_package = "github.com/elys-network/elys/x/masterchef/types"; + +import "gogoproto/gogo.proto"; + +// Pool Info +message PoolInfo { + // reward amount + uint64 pool_id = 1; + // reward wallet address + string reward_wallet = 2; + // multiplier for lp rewards + string multiplier = 3 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + // Block number since the creation of PoolInfo + string num_blocks = 4 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; + // Total dex rewards given + string dex_reward_amount_given = 5 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + // Total eden rewards given + string eden_reward_amount_given = 6 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; + // Eden APR, updated at every distribution + string eden_apr = 7 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + // Dex APR, updated at every distribution + string dex_apr = 8 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + // External Incentive APR, updated at every distribution + string external_incentive_apr = 9 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + // external reward denoms on the pool + repeated string external_reward_denoms = 10; +} + +message PoolRewardInfo { + uint64 pool_id = 1; + string reward_denom = 2; + string pool_acc_reward_per_share = 3 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + uint64 last_updated_block = 4; +} + +message UserRewardInfo { + string user = 1; + uint64 pool_id = 2; + string reward_denom = 3; + string reward_debt = 4 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + string reward_pending = 5 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; +} \ No newline at end of file diff --git a/proto/elys/masterchef/query.proto b/proto/elys/masterchef/query.proto new file mode 100644 index 000000000..b3458b2d6 --- /dev/null +++ b/proto/elys/masterchef/query.proto @@ -0,0 +1,150 @@ +syntax = "proto3"; +package elys.masterchef; + +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; +import "cosmos/base/query/v1beta1/pagination.proto"; +import "cosmos/base/v1beta1/coin.proto"; +import "elys/masterchef/params.proto"; +import "elys/masterchef/external_incentive.proto"; +import "elys/masterchef/pool.proto"; + +option go_package = "github.com/elys-network/elys/x/masterchef/types"; + +// Query defines the gRPC querier service. +service Query { + // Parameters queries the parameters of the module. + rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { + option (google.api.http).get = "/elys-network/elys/masterchef/params"; + } + + rpc ExternalIncentive(QueryExternalIncentiveRequest) returns (QueryExternalIncentiveResponse) { + option (google.api.http).get = "/elys-network/elys/masterchef/external_incentive"; + } + + rpc PoolInfo(QueryPoolInfoRequest) returns (QueryPoolInfoResponse) { + option (google.api.http).get = "/elys-network/elys/masterchef/pool_info"; + } + + rpc PoolRewardInfo(QueryPoolRewardInfoRequest) returns (QueryPoolRewardInfoResponse) { + option (google.api.http).get = "/elys-network/elys/masterchef/pool_reward_info"; + } + + rpc UserRewardInfo(QueryUserRewardInfoRequest) returns (QueryUserRewardInfoResponse) { + option (google.api.http).get = "/elys-network/elys/masterchef/user_reward_info"; + } + + rpc UserPendingReward(QueryUserPendingRewardRequest) returns (QueryUserPendingRewardResponse) { + option (google.api.http).get = "/elys-network/elys/masterchef/pending_reward"; + } + + rpc StableStakeApr (QueryStableStakeAprRequest) returns (QueryStableStakeAprResponse) { + option (google.api.http).get = "/elys-network/elys/masterchef/stable_stake_apr/{denom}"; + } + + rpc PoolAprs (QueryPoolAprsRequest) returns (QueryPoolAprsResponse) { + option (google.api.http).get = "/elys-network/elys/masterchef/pool_aprs"; + } +} + +// 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 holds all the parameters of this module. + Params params = 1 [(gogoproto.nullable) = false]; +} + +message QueryExternalIncentiveRequest { + uint64 id = 1; +} + +message QueryExternalIncentiveResponse { + ExternalIncentive external_incentive = 1 [(gogoproto.nullable) = false]; +} + +message QueryPoolInfoRequest { + uint64 pool_id = 1; +} + +message QueryPoolInfoResponse { + PoolInfo pool_info = 1 [(gogoproto.nullable) = false]; +} + +message QueryPoolRewardInfoRequest { + uint64 pool_id = 1; + string reward_denom = 2; +} + +message QueryPoolRewardInfoResponse { + PoolRewardInfo pool_reward_info = 1 [(gogoproto.nullable) = false]; +} + +message QueryUserRewardInfoRequest { + string user = 1; + uint64 pool_id = 2; + string reward_denom = 3; +} + +message QueryUserRewardInfoResponse { + UserRewardInfo user_reward_info = 1 [(gogoproto.nullable) = false]; +} + +message QueryUserPendingRewardRequest { + string user = 1; +} + +message RewardInfo { + uint64 pool_id = 1; + repeated cosmos.base.v1beta1.Coin reward = 2 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" + ]; +} + +message QueryUserPendingRewardResponse { + repeated RewardInfo rewards = 1; + + repeated cosmos.base.v1beta1.Coin total_rewards = 2 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" + ]; +} + +message QueryStableStakeAprRequest { + string denom = 1; +} + +message QueryStableStakeAprResponse { + string apr = 1 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; +} + +message QueryPoolAprsRequest { + repeated uint64 pool_ids = 1; +} + +message QueryPoolAprsResponse { + repeated PoolApr data = 1 [ + (gogoproto.nullable) = false + ]; +} + +message PoolApr { + uint64 pool_id = 1; + string eden_apr = 2 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + string usdc_apr = 3 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + string total_apr = 4 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; +} \ No newline at end of file diff --git a/proto/elys/masterchef/tx.proto b/proto/elys/masterchef/tx.proto new file mode 100644 index 000000000..9846c4f6e --- /dev/null +++ b/proto/elys/masterchef/tx.proto @@ -0,0 +1,71 @@ +syntax = "proto3"; +package elys.masterchef; + +import "gogoproto/gogo.proto"; +import "elys/masterchef/params.proto"; + +option go_package = "github.com/elys-network/elys/x/masterchef/types"; + +// Msg defines the Msg service. +service Msg { + rpc AddExternalRewardDenom (MsgAddExternalRewardDenom) returns (MsgAddExternalRewardDenomResponse); + rpc AddExternalIncentive (MsgAddExternalIncentive) returns (MsgAddExternalIncentiveResponse); + rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse); + rpc UpdatePoolMultipliers(MsgUpdatePoolMultipliers) returns (MsgUpdatePoolMultipliersResponse); + rpc ClaimRewards (MsgClaimRewards) returns (MsgClaimRewardsResponse); +} + +message MsgAddExternalRewardDenom { + string authority = 1; + string reward_denom = 2; + string min_amount = 3 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; + bool supported = 4; +} + +message MsgAddExternalRewardDenomResponse { +} + +message MsgAddExternalIncentive { + string sender = 1; + string reward_denom = 2; + uint64 pool_id = 3; + uint64 from_block = 4; + uint64 to_block = 5; + string amount_per_block = 6 + [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false]; +} + +message MsgAddExternalIncentiveResponse { +} + +message MsgUpdateParams { + string authority = 1; + Params params = 2 [(gogoproto.nullable) = false]; +} + +message MsgUpdateParamsResponse {} + +message PoolMultiplier { + uint64 pool_id = 1; + string multiplier = 2 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; +} + +message MsgUpdatePoolMultipliers { + string authority = 1; + repeated PoolMultiplier pool_multipliers = 2 [ (gogoproto.nullable) = false ]; +} +message MsgUpdatePoolMultipliersResponse {} + +message MsgClaimRewards { + string sender = 1; + repeated uint64 pool_ids = 2; +} + +message MsgClaimRewardsResponse { +} \ No newline at end of file diff --git a/scripts/examples/estaking/estaking.sh b/scripts/examples/estaking/estaking.sh new file mode 100644 index 000000000..bbb0f4b38 --- /dev/null +++ b/scripts/examples/estaking/estaking.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +TREASURY=$(elysd keys show -a treasury --keyring-backend=test) + +elysd query commitment show-commitments $TREASURY +elysd query bank balances $TREASURY + +elysd query estaking params + +elysd query staking validators +VALIDATOR=elysvaloper12tzylat4udvjj56uuhu3vj2n4vgp7cf9pwcqcs +EDEN_VAL=elysvaloper1gnmpr8vvslp3shcq6e922xr0uq4aa2w5gdzht0 +EDENB_VAL=elysvaloper1wajd6ekh9u37hyghyw4mme59qmjllzuyaceanm + +elysd tx staking delegate $VALIDATOR 1000000000000uelys --from=treasury --keyring-backend=test --chain-id=elystestnet-1 --yes --gas=1000000 +elysd query distribution rewards $TREASURY $VALIDATOR +elysd query distribution rewards $TREASURY $EDEN_VAL +elysd query distribution rewards $TREASURY $EDENB_VAL + +elysd tx distribution withdraw-rewards $VALIDATOR --from=treasury --keyring-backend=test --chain-id=elystestnet-1 --yes --gas=1000000 +elysd tx distribution withdraw-rewards $EDEN_VAL --from=treasury --keyring-backend=test --chain-id=elystestnet-1 --yes --gas=1000000 +elysd tx distribution withdraw-rewards $EDENB_VAL --from=treasury --keyring-backend=test --chain-id=elystestnet-1 --yes --gas=1000000 + +elysd tx commitment commit-claimed-rewards 503544 ueden --from=treasury --keyring-backend=test --chain-id=elystestnet-1 --yes --gas=1000000 +elysd tx commitment commit-claimed-rewards 1678547 uedenb --from=treasury --keyring-backend=test --chain-id=elystestnet-1 --yes --gas=1000000 + +# Pay 10000 uusdc as gas fees +elysd tx staking delegate $VALIDATOR 1000uelys --fees=10000uusdc --from=treasury --keyring-backend=test --chain-id=elystestnet-1 --yes --gas=1000000 diff --git a/scripts/examples/incentive/upgrade.sh b/scripts/examples/incentive/upgrade.sh new file mode 100644 index 000000000..3e890ff83 --- /dev/null +++ b/scripts/examples/incentive/upgrade.sh @@ -0,0 +1,64 @@ +#!/usr/bin/env bash + +# start old chain +cd //elys +ignite chain serve --verbose --reset-once + +# stake Elys token +elysd query staking validators +elysd keys add user1 --keyring-backend=test --recover +# beef model palm pepper claim taste climb primary category gallery lava mimic future festival sign milk present toss basket reflect dignity frame scan hat +elysd tx bank send treasury elys1r8nfpk0t4g6r7542g99s8ymxwzpsg57alx7gue 1000000000000uelys --from=treasury --keyring-backend=test --chain-id=elystestnet-1 --yes +elysd tx staking delegate elysvaloper12tzylat4udvjj56uuhu3vj2n4vgp7cf9pwcqcs 100000000000uelys --from=user1 --keyring-backend=test --chain-id=elystestnet-1 --yes --gas=1000000 + +# claim Eden reward and commit +elysd keys show -a treasury --keyring-backend=test +elysd query commitment show-commitments elys1r8nfpk0t4g6r7542g99s8ymxwzpsg57alx7gue +elysd tx incentive withdraw-rewards --from=user1 --keyring-backend=test --chain-id=elystestnet-1 --yes +elysd tx commitment commit-claimed-rewards 342464 ueden --from=user1 --keyring-backend=test --chain-id=elystestnet-1 --yes --gas=1000000 + +# create vesting from Eden to Elys +elysd tx commitment vest 1284240 ueden --from=user1 --keyring-backend=test --chain-id=elystestnet-1 --yes --gas=1000000 +elysd query commitment show-commitments elys1r8nfpk0t4g6r7542g99s8ymxwzpsg57alx7gue + +# create liquidity pool +elysd tx amm create-pool 10uatom,10uusdc 100000000000uatom,10000000000uusdc --swap-fee=0.00 --exit-fee=0.00 --use-oracle=false --from=treasury --keyring-backend=test --chain-id=elystestnet-1 --yes --gas=1000000 +elysd tx stablestake bond 19800000000 --from=treasury --keyring-backend=test --chain-id=elystestnet-1 --yes --gas=1000000 +elysd query commitment show-commitments elys12tzylat4udvjj56uuhu3vj2n4vgp7cf9fwna9w + +# Migration proposal to "masterchef" version +elysd tx gov submit-legacy-proposal software-upgrade "masterchef" --upgrade-height=150 --deposit=10000000uelys --title="XXX" --description="XXX" --no-validate --from=treasury --fees=100000uelys --gas=200000 -y +elysd tx gov vote 1 yes --from=treasury --fees=100000uelys --gas=200000 -y +elysd tx gov vote 1 yes --from=user1 --fees=100000uelys --gas=200000 -y +elysd query gov tally 1 +elysd query gov proposals + +# Migrate and check if distribution module and Eden/EdenB commit work as expected +cd //elys +go install ./cmd/elysd/ +elysd start + +# Test functionalities after upgrade +VALIDATOR=elysvaloper12tzylat4udvjj56uuhu3vj2n4vgp7cf9pwcqcs +EDEN_VAL=elysvaloper1gnmpr8vvslp3shcq6e922xr0uq4aa2w5gdzht0 +EDENB_VAL=elysvaloper1wajd6ekh9u37hyghyw4mme59qmjllzuyaceanm + +# estaking functionalities +elysd tx commitment commit-claimed-rewards 173430717 ueden --from=treasury --keyring-backend=test --chain-id=elystestnet-1 --yes --gas=1000000 +elysd query distribution rewards $TREASURY $EDEN_VAL +elysd query commitment show-commitments $TREASURY +elysd query staking delegations $TREASURY + +elysd tx distribution withdraw-rewards $VALIDATOR --from=treasury --keyring-backend=test --chain-id=elystestnet-1 --yes --gas=1000000 +elysd tx distribution withdraw-rewards $EDEN_VAL --from=treasury --keyring-backend=test --chain-id=elystestnet-1 --yes --gas=1000000 +elysd tx distribution withdraw-rewards $EDENB_VAL --from=treasury --keyring-backend=test --chain-id=elystestnet-1 --yes --gas=1000000 + +elysd tx staking delegate elysvaloper12tzylat4udvjj56uuhu3vj2n4vgp7cf9pwcqcs 100000000000uelys --from=treasury --keyring-backend=test --chain-id=elystestnet-1 --yes --gas=1000000 +elysd query distribution rewards elys1r8nfpk0t4g6r7542g99s8ymxwzpsg57alx7gue $EDEN_VAL +elysd query estaking params + +# masterchef functionalities +elysd query masterchef user-pending-reward elys1r8nfpk0t4g6r7542g99s8ymxwzpsg57alx7gue +elysd tx masterchef claim-rewards --pool-ids=1 --from=treasury --keyring-backend=test --chain-id=elystestnet-1 --yes --gas=1000000 +elysd tx masterchef claim-rewards --pool-ids=32767 --from=treasury --keyring-backend=test --chain-id=elystestnet-1 --yes --gas=1000000 + diff --git a/scripts/examples/masterchef/masterchef.sh b/scripts/examples/masterchef/masterchef.sh new file mode 100644 index 000000000..8ab9952b9 --- /dev/null +++ b/scripts/examples/masterchef/masterchef.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash + +TREASURY=$(elysd keys show -a treasury --keyring-backend=test) + +elysd tx amm create-pool 10uatom,10uusdc 20000000000uatom,20000000000uusdc --swap-fee=0.01 --exit-fee=0.00 --use-oracle=false --from=treasury --keyring-backend=test --chain-id=elystestnet-1 --yes --gas=1000000 + +# single asset add-liquidity +elysd tx amm join-pool 1 2000uatom 90000000000000000 --from=treasury --keyring-backend=test --chain-id=elystestnet-1 --yes --gas=1000000 +# multiple asset add-liquidity +elysd tx amm join-pool 1 20000000000uatom,20000000000uusdt 1000000000000000000 --from=treasury --keyring-backend=test --chain-id=elystestnet-1 --yes --gas=1000000 + +# swap +elysd tx amm swap-exact-amount-in 10000000uatom 1 1 uusdc --from=treasury --keyring-backend=test --chain-id=elystestnet-1 --yes --gas=1000000 + +elysd query commitment show-commitments $TREASURY +elysd query bank balances $TREASURY + +elysd query masterchef pool-info 1 +elysd query masterchef params + +# Add external incentive +elysd tx masterchef add-external-incentive uinc 1 80 1080 1000000 --from=treasury --keyring-backend=test --chain-id=elystestnet-1 --yes --gas=1000000 +elysd query masterchef external-incentive 0 + +# Query pending rewards +elysd query masterchef user-pending-reward $TREASURY + +# Claim rewards +elysd tx masterchef claim-rewards --pool-ids=1 --from=treasury --keyring-backend=test --chain-id=elystestnet-1 --yes --gas=1000000 + +# Test flow +# - oracle setup without lifetime +# - amm pools creation +# - create external incentive on materchef (2) +# - try querying rewards +# - try claiming rewards and check state change after that +# - try swap operation and check if swap fee's correctly distributed \ No newline at end of file diff --git a/scripts/upgrade-assure/get-flags.go b/scripts/upgrade-assure/get-flags.go index e4a7f2c56..f0208ed34 100644 --- a/scripts/upgrade-assure/get-flags.go +++ b/scripts/upgrade-assure/get-flags.go @@ -33,6 +33,8 @@ const ( flagValidatorMnemonic = "validator-mnemonic" flagRpc = "rpc" flagP2p = "p2p" + flagPprof = "pprof" + flagApi = "api" // node 2 flagHome2 = "home-2" @@ -43,6 +45,8 @@ const ( flagValidatorMnemonic2 = "validator-mnemonic-2" flagRpc2 = "rpc-2" flagP2p2 = "p2p-2" + flagPprof2 = "pprof-2" + flagApi2 = "api-2" ) func getFlags(cmd *cobra.Command) ( @@ -71,6 +75,8 @@ func getFlags(cmd *cobra.Command) ( validatorMnemonic string, rpc string, p2p string, + pprof string, + api string, // node 2 homePath2 string, @@ -81,6 +87,8 @@ func getFlags(cmd *cobra.Command) ( validatorMnemonic2 string, rpc2 string, p2p2 string, + pprof2 string, + api2 string, ) { // global skipSnapshot, _ = cmd.Flags().GetBool(flagSkipSnapshot) @@ -194,6 +202,16 @@ func getFlags(cmd *cobra.Command) ( log.Fatalf(ColorRed + "p2p is required") } + pprof, _ = cmd.Flags().GetString(flagPprof) + if pprof == "" { + log.Fatalf(ColorRed + "pprof is required") + } + + api, _ = cmd.Flags().GetString(flagApi) + if api == "" { + log.Fatalf(ColorRed + "api is required") + } + // node 2 homePath2, _ = cmd.Flags().GetString(flagHome2) if homePath2 == "" { @@ -235,5 +253,15 @@ func getFlags(cmd *cobra.Command) ( log.Fatalf(ColorRed + "p2p 2 is required") } + pprof2, _ = cmd.Flags().GetString(flagPprof2) + if pprof2 == "" { + log.Fatalf(ColorRed + "pprof 2 is required") + } + + api2, _ = cmd.Flags().GetString(flagApi2) + if api2 == "" { + log.Fatalf(ColorRed + "api 2 is required") + } + return } diff --git a/scripts/upgrade-assure/query-and-calc-upgrade-block-height.go b/scripts/upgrade-assure/query-and-calc-upgrade-block-height.go index 04b962c80..fd5c1db30 100644 --- a/scripts/upgrade-assure/query-and-calc-upgrade-block-height.go +++ b/scripts/upgrade-assure/query-and-calc-upgrade-block-height.go @@ -19,7 +19,7 @@ func queryAndCalcUpgradeBlockHeight(cmdPath, node string) string { } // set upgrade block height - upgradeBlockHeight := blockHeightInt + 10 + upgradeBlockHeight := blockHeightInt + 20 // return upgrade block height as a string return strconv.Itoa(upgradeBlockHeight) diff --git a/scripts/upgrade-assure/start.go b/scripts/upgrade-assure/start.go index 88d1f8849..18c6fcadf 100644 --- a/scripts/upgrade-assure/start.go +++ b/scripts/upgrade-assure/start.go @@ -25,9 +25,9 @@ func (cw PromptWriter) Write(data []byte) (int, error) { return len(data), err } -func start(cmdPath, homePath, rpc, p2p, moniker, successColor, errorColor string) *exec.Cmd { +func start(cmdPath, homePath, rpc, p2p, pprof, api, moniker, successColor, errorColor string) *exec.Cmd { // Command and arguments - args := []string{"start", "--home", homePath, "--rpc.laddr", rpc, "--p2p.laddr", p2p} + args := []string{"start", "--home", homePath, "--rpc.laddr", rpc, "--p2p.laddr", p2p, "--rpc.pprof_laddr", pprof, "--api.address", api} // Set up the command cmd := exec.Command(cmdPath, args...) diff --git a/scripts/upgrade-assure/types.go b/scripts/upgrade-assure/types.go index 74e66bc99..7c30455c6 100644 --- a/scripts/upgrade-assure/types.go +++ b/scripts/upgrade-assure/types.go @@ -158,9 +158,8 @@ type Incentive struct { type IncentiveParams struct { incentivetypes.Params - PoolInfos []interface{} `json:"pool_infos"` - ElysStakeSnapInterval json.Number `json:"elys_stake_snap_interval"` - DistributionInterval json.Number `json:"distribution_interval"` + PoolInfos []interface{} `json:"pool_infos"` + DistributionInterval json.Number `json:"distribution_interval"` } type Epochs struct { diff --git a/scripts/upgrade-assure/update-genesis.go b/scripts/upgrade-assure/update-genesis.go index 4dde004cf..5d50636e8 100644 --- a/scripts/upgrade-assure/update-genesis.go +++ b/scripts/upgrade-assure/update-genesis.go @@ -76,13 +76,15 @@ func updateGenesis(validatorBalance, homePath, genesisFilePath string) { genesis.AppState.Gov = genesisInit.AppState.Gov // update voting period - genesis.AppState.Gov.Params.VotingPeriod = "20s" - genesis.AppState.Gov.Params.MaxDepositPeriod = "20s" - genesis.AppState.Gov.Params.MinDeposit = sdk.Coins{sdk.NewInt64Coin("uelys", 10000000)} + votingPeriod := "30s" + minDeposit := sdk.Coins{sdk.NewInt64Coin("uelys", 10000000)} + genesis.AppState.Gov.Params.VotingPeriod = votingPeriod + genesis.AppState.Gov.Params.MaxDepositPeriod = votingPeriod + genesis.AppState.Gov.Params.MinDeposit = minDeposit // set deprecated settings - genesis.AppState.Gov.VotingParams.VotingPeriod = "20s" - genesis.AppState.Gov.DepositParams.MaxDepositPeriod = "20s" - genesis.AppState.Gov.DepositParams.MinDeposit = sdk.Coins{sdk.NewInt64Coin("uelys", 10000000)} + genesis.AppState.Gov.VotingParams.VotingPeriod = votingPeriod + genesis.AppState.Gov.DepositParams.MaxDepositPeriod = votingPeriod + genesis.AppState.Gov.DepositParams.MinDeposit = minDeposit // update wasm params // genesis.AppState.Wasm.Params = wasmtypes.DefaultParams() diff --git a/scripts/upgrade-assure/upgrade-assure.go b/scripts/upgrade-assure/upgrade-assure.go index d76b46729..63fb7b1b8 100644 --- a/scripts/upgrade-assure/upgrade-assure.go +++ b/scripts/upgrade-assure/upgrade-assure.go @@ -19,14 +19,12 @@ func main() { snapshotUrl, oldBinaryUrl, newBinaryUrl := getArgs(args) // global flags skipSnapshot, skipChainInit, skipNodeStart, skipProposal, skipBinary, chainId, keyringBackend, genesisFilePath, broadcastMode, dbEngine, - - //timeouts + // timeouts timeOutToWaitForService, timeOutToWaitForNextBlock, - // node 1 flags - homePath, moniker, validatorKeyName, validatorBalance, validatorSelfDelegation, validatorMnemonic, rpc, p2p, + homePath, moniker, validatorKeyName, validatorBalance, validatorSelfDelegation, validatorMnemonic, rpc, p2p, pprof, api, // node 2 flags - homePath2, moniker2, validatorKeyName2, validatorBalance2, validatorSelfDelegation2, validatorMnemonic2, rpc2, p2p2 := getFlags(cmd) + homePath2, moniker2, validatorKeyName2, validatorBalance2, validatorSelfDelegation2, validatorMnemonic2, rpc2, p2p2, pprof2, api2 := getFlags(cmd) timeOutForNextBlock := time.Duration(timeOutToWaitForNextBlock) * time.Minute // set address prefix @@ -113,7 +111,7 @@ func main() { if !skipNodeStart { // start node 1 - oldBinaryCmd := start(oldBinaryPath, homePath, rpc, p2p, moniker, ColorGreen, ColorRed) + oldBinaryCmd := start(oldBinaryPath, homePath, rpc, p2p, pprof, api, moniker, ColorGreen, ColorRed) // wait for rpc to start waitForServiceToStart(rpc, moniker, timeOutToWaitForService) @@ -146,8 +144,8 @@ func main() { generatePrivValidatorState(homePath2) // start node 1 and 2 - oldBinaryCmd = start(oldBinaryPath, homePath, rpc, p2p, moniker, ColorGreen, ColorRed) - oldBinaryCmd2 := start(oldBinaryPath, homePath2, rpc2, p2p2, moniker2, ColorGreen, ColorRed) + oldBinaryCmd = start(oldBinaryPath, homePath, rpc, p2p, pprof, api, moniker, ColorGreen, ColorRed) + oldBinaryCmd2 := start(oldBinaryPath, homePath2, rpc2, p2p2, pprof2, api2, moniker2, ColorGreen, ColorRed) // wait for rpc 1 and 2 to start waitForServiceToStart(rpc, moniker, timeOutToWaitForService) @@ -187,8 +185,8 @@ func main() { time.Sleep(5 * time.Second) // start new binary - newBinaryCmd := start(newBinaryPath, homePath, rpc, p2p, moniker, "\033[32m", "\033[31m") - newBinaryCmd2 := start(newBinaryPath, homePath2, rpc2, p2p2, moniker2, "\033[32m", "\033[31m") + newBinaryCmd := start(newBinaryPath, homePath, rpc, p2p, pprof, api, moniker, "\033[32m", "\033[31m") + newBinaryCmd2 := start(newBinaryPath, homePath2, rpc2, p2p2, pprof2, api2, moniker2, "\033[32m", "\033[31m") // wait for node to start waitForServiceToStart(rpc, moniker, timeOutToWaitForService) @@ -223,7 +221,7 @@ func main() { rootCmd.PersistentFlags().String(flagBroadcastMode, "sync", "broadcast mode") rootCmd.PersistentFlags().String(flagDbEngine, "pebbledb", "database engine to use") - rootCmd.PersistentFlags().Int(flagTimeOutToWaitForService, 240, "set the maximum timeout in (seconds) to wait for the node starting") + rootCmd.PersistentFlags().Int(flagTimeOutToWaitForService, 600, "set the maximum timeout in (seconds) to wait for the node starting") rootCmd.PersistentFlags().Int(flagTimeOutNextBlock, 5, "set the maximum timeout in (minutes) to wait for the next block") // node 1 flags rootCmd.PersistentFlags().String(flagHome, homeEnv+"/.elys", "home directory") @@ -234,6 +232,8 @@ func main() { rootCmd.PersistentFlags().String(flagValidatorMnemonic, "bargain toss help way dash forget bar casual boat drill execute ordinary human lecture leopard enroll joy rural shed express kite sample brick void", "validator mnemonic") rootCmd.PersistentFlags().String(flagRpc, "tcp://0.0.0.0:26657", "rpc") rootCmd.PersistentFlags().String(flagP2p, "tcp://0.0.0.0:26656", "p2p") + rootCmd.PersistentFlags().String(flagPprof, "localhost:6060", "pprof") + rootCmd.PersistentFlags().String(flagApi, "tcp://localhost:1317", "api") // node 2 flags rootCmd.PersistentFlags().String(flagHome2, homeEnv+"/.elys2", "home directory 2") @@ -244,6 +244,8 @@ func main() { rootCmd.PersistentFlags().String(flagValidatorMnemonic2, "kidney seat stay demand panel garlic uncle flock plunge logic link owner laugh sponsor desk scare pipe derive trick smart coffee goat arrange cause", "validator mnemonic 2") rootCmd.PersistentFlags().String(flagRpc2, "tcp://0.0.0.0:26667", "rpc") rootCmd.PersistentFlags().String(flagP2p2, "tcp://0.0.0.0:26666", "p2p") + rootCmd.PersistentFlags().String(flagPprof2, "localhost:6061", "pprof") + rootCmd.PersistentFlags().String(flagApi2, "tcp://localhost:1318", "api") if err := rootCmd.Execute(); err != nil { log.Fatalf(ColorRed+"Error executing command: %v", err) diff --git a/testutil/keeper/estaking.go b/testutil/keeper/estaking.go new file mode 100644 index 000000000..61739969a --- /dev/null +++ b/testutil/keeper/estaking.go @@ -0,0 +1,50 @@ +package keeper + +import ( + "testing" + + tmdb "github.com/cometbft/cometbft-db" + "github.com/cometbft/cometbft/libs/log" + tmproto "github.com/cometbft/cometbft/proto/tendermint/types" + "github.com/cosmos/cosmos-sdk/codec" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/store" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/elys-network/elys/x/estaking/keeper" + "github.com/elys-network/elys/x/estaking/types" + "github.com/stretchr/testify/require" +) + +func EstakingKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) { + storeKey := sdk.NewKVStoreKey(types.StoreKey) + memStoreKey := storetypes.NewMemoryStoreKey(types.MemStoreKey) + + db := tmdb.NewMemDB() + stateStore := store.NewCommitMultiStore(db) + stateStore.MountStoreWithDB(storeKey, storetypes.StoreTypeIAVL, db) + stateStore.MountStoreWithDB(memStoreKey, storetypes.StoreTypeMemory, nil) + require.NoError(t, stateStore.LoadLatestVersion()) + + registry := codectypes.NewInterfaceRegistry() + cdc := codec.NewProtoCodec(registry) + + k := keeper.NewKeeper( + cdc, + storeKey, + memStoreKey, + nil, + nil, + nil, + nil, + nil, + "", + ) + + ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, log.NewNopLogger()) + + // Initialize params + k.SetParams(ctx, types.DefaultParams()) + + return k, ctx +} diff --git a/testutil/keeper/incentive.go b/testutil/keeper/incentive.go index e22d9c4cf..79421d89b 100644 --- a/testutil/keeper/incentive.go +++ b/testutil/keeper/incentive.go @@ -46,7 +46,7 @@ func IncentiveKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) { nil, nil, nil, - "", + nil, "", govAddress.String(), ) diff --git a/testutil/keeper/masterchef.go b/testutil/keeper/masterchef.go new file mode 100644 index 000000000..4235b5796 --- /dev/null +++ b/testutil/keeper/masterchef.go @@ -0,0 +1,62 @@ +package keeper + +import ( + "testing" + + tmdb "github.com/cometbft/cometbft-db" + "github.com/cometbft/cometbft/libs/log" + tmproto "github.com/cometbft/cometbft/proto/tendermint/types" + "github.com/cosmos/cosmos-sdk/codec" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/store" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + typesparams "github.com/cosmos/cosmos-sdk/x/params/types" + "github.com/elys-network/elys/x/masterchef/keeper" + "github.com/elys-network/elys/x/masterchef/types" + "github.com/stretchr/testify/require" +) + +func MasterchefKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) { + storeKey := sdk.NewKVStoreKey(types.StoreKey) + memStoreKey := storetypes.NewMemoryStoreKey(types.MemStoreKey) + + db := tmdb.NewMemDB() + stateStore := store.NewCommitMultiStore(db) + stateStore.MountStoreWithDB(storeKey, storetypes.StoreTypeIAVL, db) + stateStore.MountStoreWithDB(memStoreKey, storetypes.StoreTypeMemory, nil) + require.NoError(t, stateStore.LoadLatestVersion()) + + registry := codectypes.NewInterfaceRegistry() + cdc := codec.NewProtoCodec(registry) + + paramsSubspace := typesparams.NewSubspace(cdc, + types.Amino, + storeKey, + memStoreKey, + "MasterchefParams", + ) + k := keeper.NewKeeper( + cdc, + storeKey, + memStoreKey, + paramsSubspace, + nil, + nil, + nil, + nil, + nil, + nil, + nil, + nil, + nil, + "", + ) + + ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, log.NewNopLogger()) + + // Initialize params + k.SetParams(ctx, types.DefaultParams()) + + return k, ctx +} diff --git a/wasmbindings/client/register_custom_plugins.go b/wasmbindings/client/register_custom_plugins.go index f22a216e8..d7434b07b 100644 --- a/wasmbindings/client/register_custom_plugins.go +++ b/wasmbindings/client/register_custom_plugins.go @@ -22,10 +22,14 @@ import ( commitmentkeeper "github.com/elys-network/elys/x/commitment/keeper" epochsclientwasm "github.com/elys-network/elys/x/epochs/client/wasm" epochskeeper "github.com/elys-network/elys/x/epochs/keeper" + estakingclientwasm "github.com/elys-network/elys/x/estaking/client/wasm" + estakingkeeper "github.com/elys-network/elys/x/estaking/keeper" incentiveclientwasm "github.com/elys-network/elys/x/incentive/client/wasm" incentivekeeper "github.com/elys-network/elys/x/incentive/keeper" leveragelpclientwasm "github.com/elys-network/elys/x/leveragelp/client/wasm" leveragelpkeeper "github.com/elys-network/elys/x/leveragelp/keeper" + masterchefclientwasm "github.com/elys-network/elys/x/masterchef/client/wasm" + masterchefkeeper "github.com/elys-network/elys/x/masterchef/keeper" oracleclientwasm "github.com/elys-network/elys/x/oracle/client/wasm" oraclekeeper "github.com/elys-network/elys/x/oracle/keeper" parameterclientwasm "github.com/elys-network/elys/x/parameter/client/wasm" @@ -59,11 +63,13 @@ func RegisterCustomPlugins( staking *stakingkeeper.Keeper, tokenomics *tokenomicskeeper.Keeper, transferhook *transferhookkeeper.Keeper, + masterchef *masterchefkeeper.Keeper, + estaking *estakingkeeper.Keeper, ) []wasmkeeper.Option { accountedpoolQuerier := accountedpoolclientwasm.NewQuerier(accountedpool) accountedpoolMessenger := accountedpoolclientwasm.NewMessenger(accountedpool) - ammQuerier := ammclientwasm.NewQuerier(amm, bank, commitment, assetprofile, perpetual, incentive, oracle, leveragelp, accountedpool, stablestake) + ammQuerier := ammclientwasm.NewQuerier(amm, bank, commitment, assetprofile, perpetual, incentive, oracle, leveragelp, accountedpool, stablestake, masterchef) ammMessenger := ammclientwasm.NewMessenger(amm, parameter) assetprofileQuerier := assetprofileclientwasm.NewQuerier(assetprofile) @@ -108,6 +114,12 @@ func RegisterCustomPlugins( transferhookQuerier := transferhookclientwasm.NewQuerier(transferhook) transferhookMessenger := transferhookclientwasm.NewMessenger(transferhook) + masterchefQuerier := masterchefclientwasm.NewQuerier(masterchef, staking) + masterchefMessenger := masterchefclientwasm.NewMessenger(masterchef, staking, commitment, parameter) + + estakingQuerier := estakingclientwasm.NewQuerier(estaking) + estakingMessenger := estakingclientwasm.NewMessenger(estaking, parameter) + moduleQueriers := []types.ModuleQuerier{ accountedpoolQuerier, ammQuerier, @@ -125,6 +137,8 @@ func RegisterCustomPlugins( stablestakeQuerier, tokenomicsQuerier, transferhookQuerier, + masterchefQuerier, + estakingQuerier, } wasmQueryPlugin := types.NewQueryPlugin( @@ -147,6 +161,8 @@ func RegisterCustomPlugins( staking, tokenomics, transferhook, + masterchef, + estaking, ) queryPluginOpt := wasmkeeper.WithQueryPlugins(&wasmkeeper.QueryPlugins{ @@ -170,6 +186,8 @@ func RegisterCustomPlugins( stablestakeMessenger, tokenomicsMessenger, transferhookMessenger, + masterchefMessenger, + estakingMessenger, } messengerDecoratorOpt := wasmkeeper.WithMessageHandlerDecorator( @@ -193,6 +211,8 @@ func RegisterCustomPlugins( staking, tokenomics, transferhook, + masterchef, + estaking, ), ) return []wasm.Option{ diff --git a/wasmbindings/types/custom_message_decorator.go b/wasmbindings/types/custom_message_decorator.go index a448ad8f8..1d8c0f6e7 100644 --- a/wasmbindings/types/custom_message_decorator.go +++ b/wasmbindings/types/custom_message_decorator.go @@ -12,8 +12,10 @@ import ( clockkeeper "github.com/elys-network/elys/x/clock/keeper" commitmentkeeper "github.com/elys-network/elys/x/commitment/keeper" epochskeeper "github.com/elys-network/elys/x/epochs/keeper" + estakingkeeper "github.com/elys-network/elys/x/estaking/keeper" incentivekeeper "github.com/elys-network/elys/x/incentive/keeper" leveragelpkeeper "github.com/elys-network/elys/x/leveragelp/keeper" + masterchefkeeper "github.com/elys-network/elys/x/masterchef/keeper" oraclekeeper "github.com/elys-network/elys/x/oracle/keeper" parameterkeeper "github.com/elys-network/elys/x/parameter/keeper" perpetualkeeper "github.com/elys-network/elys/x/perpetual/keeper" @@ -42,6 +44,8 @@ func CustomMessageDecorator( staking *stakingkeeper.Keeper, tokenomics *tokenomicskeeper.Keeper, transferhook *transferhookkeeper.Keeper, + masterchef *masterchefkeeper.Keeper, + estaking *estakingkeeper.Keeper, ) func(wasmkeeper.Messenger) wasmkeeper.Messenger { return func(old wasmkeeper.Messenger) wasmkeeper.Messenger { return &CustomMessenger{ @@ -65,6 +69,8 @@ func CustomMessageDecorator( staking: staking, tokenomics: tokenomics, transferhook: transferhook, + masterchef: masterchef, + estaking: estaking, } } } diff --git a/wasmbindings/types/new_query_plugin.go b/wasmbindings/types/new_query_plugin.go index ec90c297c..be2233ebf 100644 --- a/wasmbindings/types/new_query_plugin.go +++ b/wasmbindings/types/new_query_plugin.go @@ -11,8 +11,10 @@ import ( clockkeeper "github.com/elys-network/elys/x/clock/keeper" commitmentkeeper "github.com/elys-network/elys/x/commitment/keeper" epochskeeper "github.com/elys-network/elys/x/epochs/keeper" + estakingkeeper "github.com/elys-network/elys/x/estaking/keeper" incentivekeeper "github.com/elys-network/elys/x/incentive/keeper" leveragelpkeeper "github.com/elys-network/elys/x/leveragelp/keeper" + masterchefkeeper "github.com/elys-network/elys/x/masterchef/keeper" oraclekeeper "github.com/elys-network/elys/x/oracle/keeper" parameterkeeper "github.com/elys-network/elys/x/parameter/keeper" perpetualkeeper "github.com/elys-network/elys/x/perpetual/keeper" @@ -42,6 +44,8 @@ func NewQueryPlugin( staking *stakingkeeper.Keeper, tokenomics *tokenomicskeeper.Keeper, transferhook *transferhookkeeper.Keeper, + masterchef *masterchefkeeper.Keeper, + estaking *estakingkeeper.Keeper, ) *QueryPlugin { return &QueryPlugin{ moduleQueriers: moduleQueriers, @@ -63,5 +67,7 @@ func NewQueryPlugin( stablestakeKeeper: stablestake, tokenomicsKeeper: tokenomics, transferhookKeeper: transferhook, + masterchefKeeper: masterchef, + estakingKeeper: estaking, } } diff --git a/wasmbindings/types/types.go b/wasmbindings/types/types.go index b949701ff..f5ee12c60 100644 --- a/wasmbindings/types/types.go +++ b/wasmbindings/types/types.go @@ -24,10 +24,14 @@ import ( commitmenttypes "github.com/elys-network/elys/x/commitment/types" epochskeeper "github.com/elys-network/elys/x/epochs/keeper" epochstypes "github.com/elys-network/elys/x/epochs/types" + estakingkeeper "github.com/elys-network/elys/x/estaking/keeper" + estakingtypes "github.com/elys-network/elys/x/estaking/types" incentivekeeper "github.com/elys-network/elys/x/incentive/keeper" incentivetypes "github.com/elys-network/elys/x/incentive/types" leveragelpkeeper "github.com/elys-network/elys/x/leveragelp/keeper" leveragelptypes "github.com/elys-network/elys/x/leveragelp/types" + masterchefkeeper "github.com/elys-network/elys/x/masterchef/keeper" + mastercheftypes "github.com/elys-network/elys/x/masterchef/types" oraclekeeper "github.com/elys-network/elys/x/oracle/keeper" oracletypes "github.com/elys-network/elys/x/oracle/types" parameterkeeper "github.com/elys-network/elys/x/parameter/keeper" @@ -72,6 +76,7 @@ type QueryPlugin struct { commitmentKeeper *commitmentkeeper.Keeper epochsKeeper *epochskeeper.Keeper incentiveKeeper *incentivekeeper.Keeper + masterchefKeeper *masterchefkeeper.Keeper leveragelpKeeper *leveragelpkeeper.Keeper perpetualKeeper *perpetualkeeper.Keeper oracleKeeper *oraclekeeper.Keeper @@ -80,6 +85,7 @@ type QueryPlugin struct { stakingKeeper *stakingkeeper.Keeper tokenomicsKeeper *tokenomicskeeper.Keeper transferhookKeeper *transferhookkeeper.Keeper + estakingKeeper *estakingkeeper.Keeper } // AllCapabilities returns all capabilities available with the current wasmvm @@ -136,29 +142,39 @@ type ElysQuery struct { ClockParams *clocktypes.QueryParamsRequest `json:"clock_params,omitempty"` // commitment queriers - CommitmentParams *commitmenttypes.QueryParamsRequest `json:"commitment_params,omitempty"` - CommitmentShowCommitments *commitmenttypes.QueryShowCommitmentsRequest `json:"commitment_show_commitments,omitempty"` - CommitmentDelegations *commitmenttypes.QueryDelegatorDelegationsRequest `json:"commitment_delegations,omitempty"` - CommitmentUnbondingDelegations *commitmenttypes.QueryDelegatorUnbondingDelegationsRequest `json:"commitment_unbonding_delegations,omitempty"` - CommitmentStakedBalanceOfDenom *ammtypes.QueryBalanceRequest `json:"commitment_staked_balance_of_denom,omitempty"` - CommitmentRewardsBalanceOfDenom *ammtypes.QueryBalanceRequest `json:"commitment_rewards_balance_of_denom,omitempty"` - CommitmentAllValidators *commitmenttypes.QueryValidatorsRequest `json:"commitment_all_validators,omitempty"` - CommitmentDelegatorValidators *commitmenttypes.QueryValidatorsRequest `json:"commitment_delegator_validators,omitempty"` - CommitmentStakedPositions *commitmenttypes.QueryValidatorsRequest `json:"commitment_staked_positions,omitempty"` - CommitmentUnStakedPositions *commitmenttypes.QueryValidatorsRequest `json:"commitment_un_staked_positions,omitempty"` - CommitmentRewardsSubBucketBalanceOfDenom *commitmenttypes.QuerySubBucketBalanceRequest `json:"commitment_rewards_sub_bucket_balance_of_denom,omitempty"` - CommitmentVestingInfo *commitmenttypes.QueryVestingInfoRequest `json:"commitment_vesting_info,omitempty"` + CommitmentParams *commitmenttypes.QueryParamsRequest `json:"commitment_params,omitempty"` + CommitmentShowCommitments *commitmenttypes.QueryShowCommitmentsRequest `json:"commitment_show_commitments,omitempty"` + CommitmentDelegations *commitmenttypes.QueryDelegatorDelegationsRequest `json:"commitment_delegations,omitempty"` + CommitmentUnbondingDelegations *commitmenttypes.QueryDelegatorUnbondingDelegationsRequest `json:"commitment_unbonding_delegations,omitempty"` + CommitmentStakedBalanceOfDenom *ammtypes.QueryBalanceRequest `json:"commitment_staked_balance_of_denom,omitempty"` + CommitmentAllValidators *commitmenttypes.QueryValidatorsRequest `json:"commitment_all_validators,omitempty"` + CommitmentDelegatorValidators *commitmenttypes.QueryValidatorsRequest `json:"commitment_delegator_validators,omitempty"` + CommitmentStakedPositions *commitmenttypes.QueryValidatorsRequest `json:"commitment_staked_positions,omitempty"` + CommitmentUnStakedPositions *commitmenttypes.QueryValidatorsRequest `json:"commitment_un_staked_positions,omitempty"` + CommitmentVestingInfo *commitmenttypes.QueryVestingInfoRequest `json:"commitment_vesting_info,omitempty"` // epochs queriers EpochsEpochInfos *epochstypes.QueryEpochsInfoRequest `json:"epochs_epoch_infos,omitempty"` EpochsCurrentEpoch *epochstypes.QueryCurrentEpochRequest `json:"epochs_current_epoch,omitempty"` // incentive queriers - IncentiveParams *incentivetypes.QueryParamsRequest `json:"incentive_params,omitempty"` - IncentiveCommunityPool *incentivetypes.QueryCommunityPoolRequest `json:"incentive_community_pool,omitempty"` - IncentiveApr *incentivetypes.QueryAprRequest `json:"incentive_apr"` - IncentiveAprs *incentivetypes.QueryAprsRequest `json:"incentive_aprs"` - IncentivePoolAprs *incentivetypes.QueryPoolAprsRequest `json:"incentive_pool_aprs"` + IncentiveApr *incentivetypes.QueryAprRequest `json:"incentive_apr,omitempty"` + IncentiveAprs *incentivetypes.QueryAprsRequest `json:"incentive_aprs,omitempty"` + IncentiveAllProgramRewards *incentivetypes.QueryAllProgramRewardsRequest `json:"incentive_all_program_rewards,omitempty"` + + // masterchef queriers + MasterchefParams *mastercheftypes.QueryParamsRequest `json:"masterchef_params,omitempty"` + MasterchefExternalIncentive *mastercheftypes.QueryExternalIncentiveRequest `json:"masterchef_external_incentive,omitempty"` + MasterchefPoolInfo *mastercheftypes.QueryPoolInfoRequest `json:"masterchef_pool_info,omitempty"` + MasterchefPoolRewardInfo *mastercheftypes.QueryPoolRewardInfoRequest `json:"masterchef_pool_reward_info,omitempty"` + MasterchefUserRewardInfo *mastercheftypes.QueryUserRewardInfoRequest `json:"masterchef_user_reward_info,omitempty"` + MasterchefUserPendingReward *mastercheftypes.QueryUserPendingRewardRequest `json:"masterchef_user_pending_reward,omitempty"` + MasterchefStableStakeApr *mastercheftypes.QueryStableStakeAprRequest `json:"masterchef_stable_stake_apr,omitempty"` + MasterchefPoolAprs *mastercheftypes.QueryPoolAprsRequest `json:"masterchef_pool_aprs,omitempty"` + + // estaking queriers + EstakingParams *estakingtypes.QueryParamsRequest `json:"estaking_params,omitempty"` + EstakingRewards *estakingtypes.QueryRewardsRequest `json:"estaking_rewards,omitempty"` // leveragelp queriers LeveragelpParams *leveragelptypes.ParamsRequest `json:"leveragelp_params,omitempty"` @@ -228,6 +244,8 @@ type CustomMessenger struct { commitment *commitmentkeeper.Keeper epochs *epochskeeper.Keeper incentive *incentivekeeper.Keeper + masterchef *masterchefkeeper.Keeper + estaking *estakingkeeper.Keeper leveragelp *leveragelpkeeper.Keeper perpetual *perpetualkeeper.Keeper oracle *oraclekeeper.Keeper @@ -270,10 +288,15 @@ type ElysMsg struct { // epochs messages // incentive messages - IncentiveBeginRedelegate *incentivetypes.MsgBeginRedelegate `json:"incentive_begin_redelegate,omitempty"` - IncentiveCancelUnbondingDelegation *incentivetypes.MsgCancelUnbondingDelegation `json:"incentive_cancel_unbonding_delegation"` - IncentiveWithdrawRewards *incentivetypes.MsgWithdrawRewards `json:"incentive_withdraw_rewards"` - IncentiveWithdrawValidatorCommission *incentivetypes.MsgWithdrawValidatorCommission `json:"incentive_withdraw_validator_commission"` + IncentiveBeginRedelegate *incentivetypes.MsgBeginRedelegate `json:"incentive_begin_redelegate,omitempty"` + IncentiveCancelUnbondingDelegation *incentivetypes.MsgCancelUnbondingDelegation `json:"incentive_cancel_unbonding_delegation"` + + // masterchef messages + MasterchefClaimRewards *mastercheftypes.MsgClaimRewards `json:"masterchef_claim_rewards,omitempty"` + + // estaking messages + EstakingWithdrawReward *estakingtypes.MsgWithdrawReward `json:"estaking_withdraw_reward,omitempty"` + EstakingWithdrawElysStakingRewards *estakingtypes.MsgWithdrawElysStakingRewards `json:"estaking_withdraw_elys_staking_rewards,omitempty"` // leveragelp messages LeveragelpOpen *leveragelptypes.MsgOpen `json:"leveragelp_open,omitempty"` diff --git a/x/amm/client/wasm/querier.go b/x/amm/client/wasm/querier.go index 92b10bc5d..0488ddadb 100644 --- a/x/amm/client/wasm/querier.go +++ b/x/amm/client/wasm/querier.go @@ -10,6 +10,7 @@ import ( commitmentkeeper "github.com/elys-network/elys/x/commitment/keeper" incentivekeeper "github.com/elys-network/elys/x/incentive/keeper" leveragelpkeeper "github.com/elys-network/elys/x/leveragelp/keeper" + masterchefkeeper "github.com/elys-network/elys/x/masterchef/keeper" oraclekeeper "github.com/elys-network/elys/x/oracle/keeper" perpetualkeeper "github.com/elys-network/elys/x/perpetual/keeper" stablestakekeeper "github.com/elys-network/elys/x/stablestake/keeper" @@ -27,6 +28,7 @@ type Querier struct { leveragelpKeeper *leveragelpkeeper.Keeper accountedpoolKeeper *accountedpoolkeeper.Keeper stablestakeKeeper *stablestakekeeper.Keeper + masterchefKeeper *masterchefkeeper.Keeper } func NewQuerier( @@ -39,7 +41,9 @@ func NewQuerier( oraclekeeper *oraclekeeper.Keeper, leveragelpKeeper *leveragelpkeeper.Keeper, accountedpoolKeeper *accountedpoolkeeper.Keeper, - stablestakeKeeper *stablestakekeeper.Keeper) *Querier { + stablestakeKeeper *stablestakekeeper.Keeper, + masterchefKeeper *masterchefkeeper.Keeper, +) *Querier { return &Querier{ keeper: keeper, bankKeeper: bankKeeper, @@ -51,6 +55,7 @@ func NewQuerier( leveragelpKeeper: leveragelpKeeper, accountedpoolKeeper: accountedpoolKeeper, stablestakeKeeper: stablestakeKeeper, + masterchefKeeper: masterchefKeeper, } } diff --git a/x/amm/client/wasm/query_earn_mining_pool_all.go b/x/amm/client/wasm/query_earn_mining_pool_all.go index d50b566c0..3c461248c 100644 --- a/x/amm/client/wasm/query_earn_mining_pool_all.go +++ b/x/amm/client/wasm/query_earn_mining_pool_all.go @@ -2,6 +2,7 @@ package wasm import ( "encoding/json" + "fmt" errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" @@ -28,6 +29,32 @@ func (oq *Querier) checkFilterType(ctx sdk.Context, ammPool *types.Pool, filterT return false } +// Calculate the amm pool ratio +func CalculatePoolRatio(ctx sdk.Context, pool *types.Pool) string { + weightString := "" + totalWeight := sdk.ZeroInt() + for _, asset := range pool.PoolAssets { + totalWeight = totalWeight.Add(asset.Weight) + } + + if totalWeight.IsZero() { + return weightString + } + + for _, asset := range pool.PoolAssets { + weight := sdk.NewDecFromInt(asset.Weight).QuoInt(totalWeight).MulInt(sdk.NewInt(100)).TruncateInt64() + weightString = fmt.Sprintf("%s : %d", weightString, weight) + } + + // remove prefix " : " 3 characters + if len(weightString) > 1 { + weightString = weightString[3:] + } + + // returns pool weight string + return weightString +} + // Generate earn pool struct func (oq *Querier) generateEarnPool(ctx sdk.Context, ammPool *types.Pool, filterType types.FilterType) types.EarnPool { rewardsApr := sdk.ZeroDec() @@ -35,7 +62,7 @@ func (oq *Querier) generateEarnPool(ctx sdk.Context, ammPool *types.Pool, filter leverageLpPercent := sdk.ZeroDec() perpetualPercent := sdk.ZeroDec() - poolInfo, found := oq.incentiveKeeper.GetPoolInfo(ctx, ammPool.PoolId) + poolInfo, found := oq.masterchefKeeper.GetPool(ctx, ammPool.PoolId) if found { rewardsApr = poolInfo.DexApr.Add(poolInfo.EdenApr) } @@ -51,7 +78,7 @@ func (oq *Querier) generateEarnPool(ctx sdk.Context, ammPool *types.Pool, filter rewardsUsd, rewardCoins := oq.incentiveKeeper.GetDailyRewardsAmountForPool(ctx, ammPool.PoolId) // Get pool ratio - poolRatio := oq.incentiveKeeper.CalculatePoolRatio(ctx, ammPool) + poolRatio := CalculatePoolRatio(ctx, ammPool) leverageLpPool, found := oq.leveragelpKeeper.GetPool(ctx, ammPool.PoolId) if found { diff --git a/x/amm/keeper/estimate_price.go b/x/amm/keeper/estimate_price.go index 2aa757227..11e95344d 100644 --- a/x/amm/keeper/estimate_price.go +++ b/x/amm/keeper/estimate_price.go @@ -43,3 +43,23 @@ func (k Keeper) GetEdenDenomPrice(ctx sdk.Context, baseCurrency string) math.Leg } return edenUsdcRate.Mul(usdcDenomPrice) } + +func (k Keeper) GetTokenPrice(ctx sdk.Context, tokenInDenom, baseCurrency string) math.LegacyDec { + oraclePrice := k.oracleKeeper.GetAssetPriceFromDenom(ctx, tokenInDenom) + if !oraclePrice.IsZero() { + return oraclePrice + } + + // Calc tokenIn / uusdc rate + tokenUsdcRate := k.EstimatePrice(ctx, tokenInDenom, baseCurrency) + usdcDenomPrice := k.oracleKeeper.GetAssetPriceFromDenom(ctx, baseCurrency) + if usdcDenomPrice.IsZero() { + usdcDecimal := int64(6) + usdcEntry, found := k.assetProfileKeeper.GetEntry(ctx, ptypes.BaseCurrency) + if found { + usdcDecimal = int64(usdcEntry.Decimals) + } + usdcDenomPrice = sdk.NewDecWithPrec(1, usdcDecimal) + } + return tokenUsdcRate.Mul(usdcDenomPrice) +} diff --git a/x/amm/types/utils.go b/x/amm/types/utils.go index ef6b32988..51258dc01 100644 --- a/x/amm/types/utils.go +++ b/x/amm/types/utils.go @@ -2,6 +2,8 @@ package types import ( fmt "fmt" + "strconv" + "strings" errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" @@ -11,6 +13,14 @@ func GetPoolShareDenom(poolId uint64) string { return fmt.Sprintf("amm/pool/%d", poolId) } +func GetPoolIdFromShareDenom(shareDenom string) (uint64, error) { + poolId, err := strconv.Atoi(strings.TrimPrefix(shareDenom, "amm/pool/")) + if err != nil { + return 0, err + } + return uint64(poolId), nil +} + // poolAssetsCoins returns all the coins corresponding to a slice of pool assets. func poolAssetsCoins(assets []PoolAsset) sdk.Coins { coins := sdk.Coins{} diff --git a/x/commitment/client/wasm/querier.go b/x/commitment/client/wasm/querier.go index 1d726d4d3..2ba245a1e 100644 --- a/x/commitment/client/wasm/querier.go +++ b/x/commitment/client/wasm/querier.go @@ -55,8 +55,6 @@ func (oq *Querier) HandleQuery(ctx sdk.Context, query wasmbindingstypes.ElysQuer return oq.queryUnbondingDelegations(ctx, query.CommitmentUnbondingDelegations) case query.CommitmentStakedBalanceOfDenom != nil: return oq.queryStakedBalanceOfDenom(ctx, query.CommitmentStakedBalanceOfDenom) - case query.CommitmentRewardsBalanceOfDenom != nil: - return oq.queryRewardBalanceOfDenom(ctx, query.CommitmentRewardsBalanceOfDenom) case query.CommitmentAllValidators != nil: return oq.queryAllValidators(ctx, query.CommitmentAllValidators) case query.CommitmentDelegatorValidators != nil: @@ -65,8 +63,6 @@ func (oq *Querier) HandleQuery(ctx sdk.Context, query wasmbindingstypes.ElysQuer return oq.queryStakedPositions(ctx, query.CommitmentStakedPositions) case query.CommitmentUnStakedPositions != nil: return oq.queryUnStakedPositions(ctx, query.CommitmentUnStakedPositions) - case query.CommitmentRewardsSubBucketBalanceOfDenom != nil: - return oq.queryRewardSubBucketBalanceOfDenom(ctx, query.CommitmentRewardsSubBucketBalanceOfDenom) case query.CommitmentVestingInfo != nil: return oq.queryVestingInfo(ctx, query.CommitmentVestingInfo) default: diff --git a/x/commitment/client/wasm/query_reward_balance.go b/x/commitment/client/wasm/query_reward_balance.go deleted file mode 100644 index 277190ddc..000000000 --- a/x/commitment/client/wasm/query_reward_balance.go +++ /dev/null @@ -1,35 +0,0 @@ -package wasm - -import ( - "encoding/json" - - errorsmod "cosmossdk.io/errors" - sdk "github.com/cosmos/cosmos-sdk/types" - ammtypes "github.com/elys-network/elys/x/amm/types" - commitmenttypes "github.com/elys-network/elys/x/commitment/types" - paramtypes "github.com/elys-network/elys/x/parameter/types" -) - -func (oq *Querier) queryRewardBalanceOfDenom(ctx sdk.Context, query *ammtypes.QueryBalanceRequest) ([]byte, error) { - denom := query.Denom - addr := query.Address - if denom == paramtypes.Elys { - return nil, errorsmod.Wrap(nil, "invalid denom") - } - - var balance sdk.Coin - commitment := oq.keeper.GetCommitments(ctx, addr) - uncommittedToken := commitment.GetRewardUnclaimedForDenom(denom) - balance = sdk.NewCoin(denom, uncommittedToken) - - res := commitmenttypes.BalanceAvailable{ - Amount: balance.Amount, - UsdAmount: sdk.NewDecFromInt(balance.Amount), - } - - responseBytes, err := json.Marshal(res) - if err != nil { - return nil, errorsmod.Wrap(err, "failed to get reward balance response") - } - return responseBytes, nil -} diff --git a/x/commitment/client/wasm/query_reward_sub_bucket_balance.go b/x/commitment/client/wasm/query_reward_sub_bucket_balance.go deleted file mode 100644 index 7b4ecf3b7..000000000 --- a/x/commitment/client/wasm/query_reward_sub_bucket_balance.go +++ /dev/null @@ -1,47 +0,0 @@ -package wasm - -import ( - "encoding/json" - - errorsmod "cosmossdk.io/errors" - sdk "github.com/cosmos/cosmos-sdk/types" - commitmenttypes "github.com/elys-network/elys/x/commitment/types" - paramtypes "github.com/elys-network/elys/x/parameter/types" -) - -func (oq *Querier) queryRewardSubBucketBalanceOfDenom(ctx sdk.Context, query *commitmenttypes.QuerySubBucketBalanceRequest) ([]byte, error) { - denom := query.Denom - addr := query.Address - if denom == paramtypes.Elys { - return nil, errorsmod.Wrap(nil, "invalid denom") - } - - var balance sdk.Coin - commitment := oq.keeper.GetCommitments(ctx, addr) - uncommittedToken := commitment.GetRewardUnclaimedForDenom(denom) - switch query.Program { - case commitmenttypes.EarnType_USDC_PROGRAM: - uncommittedToken = commitment.GetUsdcSubBucketRewardUnclaimedForDenom(denom) - case commitmenttypes.EarnType_ELYS_PROGRAM: - uncommittedToken = commitment.GetElysSubBucketRewardUnclaimedForDenom(denom) - case commitmenttypes.EarnType_EDEN_PROGRAM: - uncommittedToken = commitment.GetEdenSubBucketRewardUnclaimedForDenom(denom) - case commitmenttypes.EarnType_EDENB_PROGRAM: - uncommittedToken = commitment.GetEdenBSubBucketRewardUnclaimedForDenom(denom) - case commitmenttypes.EarnType_LP_MINING_PROGRAM: - uncommittedToken = commitment.GetLPMiningSubBucketRewardUnclaimedForDenom(denom) - } - - balance = sdk.NewCoin(denom, uncommittedToken) - - res := commitmenttypes.BalanceAvailable{ - Amount: balance.Amount, - UsdAmount: sdk.NewDecFromInt(balance.Amount), - } - - responseBytes, err := json.Marshal(res) - if err != nil { - return nil, errorsmod.Wrap(err, "failed to get reward balance response") - } - return responseBytes, nil -} diff --git a/x/commitment/keeper/claim_reward.go b/x/commitment/keeper/claim_reward.go deleted file mode 100644 index 73b589fe8..000000000 --- a/x/commitment/keeper/claim_reward.go +++ /dev/null @@ -1,94 +0,0 @@ -package keeper - -import ( - errorsmod "cosmossdk.io/errors" - "cosmossdk.io/math" - sdk "github.com/cosmos/cosmos-sdk/types" - aptypes "github.com/elys-network/elys/x/assetprofile/types" - "github.com/elys-network/elys/x/commitment/types" -) - -// Update commitments for claim reward operation -func (k Keeper) RecordClaimReward(ctx sdk.Context, creator string, denom string, amount math.Int, withdrawMode types.EarnType) error { - assetProfile, found := k.assetProfileKeeper.GetEntry(ctx, denom) - if !found { - return errorsmod.Wrapf(aptypes.ErrAssetProfileNotFound, "denom: %s", denom) - } - - if !assetProfile.WithdrawEnabled { - return errorsmod.Wrapf(types.ErrWithdrawDisabled, "denom: %s", denom) - } - - // uses asset profile denom - denom = assetProfile.Denom - - // Get the Commitments for the creator - commitments := k.GetCommitments(ctx, creator) - if !found { - return errorsmod.Wrapf(types.ErrCommitmentsNotFound, "creator: %s", creator) - } - - // Withdraw reward not depending on program type - switch withdrawMode { - case types.EarnType_ALL_PROGRAM: - // Subtract the withdrawn amount from the unclaimed balance - err := commitments.SubRewardsUnclaimed(sdk.NewCoin(denom, amount)) - if err != nil { - return err - } - case types.EarnType_USDC_PROGRAM: - // Subtract the withdrawn amount from the unclaimed balance - err := commitments.SubRewardsUnclaimedForUSDCDeposit(sdk.NewCoin(denom, amount)) - if err != nil { - return err - } - case types.EarnType_ELYS_PROGRAM: - // Subtract the withdrawn amount from the unclaimed balance - err := commitments.SubRewardsUnclaimedForElysStaking(sdk.NewCoin(denom, amount)) - if err != nil { - return err - } - case types.EarnType_EDEN_PROGRAM: - // Subtract the withdrawn amount from the unclaimed balance - err := commitments.SubRewardsUnclaimedForEdenCommitted(sdk.NewCoin(denom, amount)) - if err != nil { - return err - } - case types.EarnType_EDENB_PROGRAM: - // Subtract the withdrawn amount from the unclaimed balance - err := commitments.SubRewardsUnclaimedForEdenBCommitted(sdk.NewCoin(denom, amount)) - if err != nil { - return err - } - case types.EarnType_LP_MINING_PROGRAM: - // Subtract the withdrawn amount from lp mining - err := commitments.SubRewardsUnclaimed(sdk.NewCoin(denom, amount)) - if err != nil { - return err - } - default: - return errorsmod.Wrapf(types.ErrUnsupportedWithdrawMode, "creator: %s", creator) - } - - // Update the commitments - k.SetCommitments(ctx, commitments) - - withdrawCoins := sdk.NewCoins(sdk.NewCoin(denom, amount)) - - err := k.HandleWithdrawFromCommitment(ctx, &commitments, withdrawCoins, false, sdk.AccAddress{}) - if err != nil { - return err - } - - // Emit blockchain event - ctx.EventManager().EmitEvent( - sdk.NewEvent( - types.EventTypeCommitmentChanged, - sdk.NewAttribute(types.AttributeCreator, creator), - sdk.NewAttribute(types.AttributeAmount, amount.String()), - sdk.NewAttribute(types.AttributeDenom, denom), - ), - ) - - return nil -} diff --git a/x/commitment/keeper/claim_reward_test.go b/x/commitment/keeper/claim_reward_test.go deleted file mode 100644 index caa6c7338..000000000 --- a/x/commitment/keeper/claim_reward_test.go +++ /dev/null @@ -1,95 +0,0 @@ -package keeper_test - -import ( - "testing" - - tmproto "github.com/cometbft/cometbft/proto/tendermint/types" - - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/elys-network/elys/app" - - aptypes "github.com/elys-network/elys/x/assetprofile/types" - "github.com/elys-network/elys/x/commitment/types" - ptypes "github.com/elys-network/elys/x/parameter/types" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" -) - -func TestClaimReward(t *testing.T) { - app := app.InitElysTestApp(true) - - ctx := app.BaseApp.NewContext(false, tmproto.Header{}) - // Create a test context and keeper - keeper := app.CommitmentKeeper - - creatorAddr, _ := sdk.AccAddressFromBech32("cosmos1xv9tklw7d82sezh9haa573wufgy59vmwe6xxe5") - - // Define the test data - creator := creatorAddr.String() - denom := ptypes.Eden - initialUnclaimed := sdk.NewInt(50) - rewardsByElysUnclaimed := sdk.NewInt(1) - rewardsByEdenUnclaimed := sdk.NewInt(1) - rewardsByEdenbUnclaimed := sdk.NewInt(1) - rewardsByUsdcUnclaimed := sdk.NewInt(1) - - initialCommitted := sdk.NewInt(100) - - // Set up initial commitments object with sufficient unclaimed & committed tokens - committedTokens := types.CommittedTokens{ - Denom: denom, - Amount: initialCommitted, - } - - initialCommitments := types.Commitments{ - Creator: creator, - RewardsUnclaimed: sdk.Coins{sdk.Coin{ - Denom: denom, - Amount: initialUnclaimed, - }}, - RewardsByElysUnclaimed: sdk.Coins{sdk.Coin{ - Denom: denom, - Amount: rewardsByElysUnclaimed, - }}, - RewardsByEdenUnclaimed: sdk.Coins{sdk.Coin{ - Denom: denom, - Amount: rewardsByEdenUnclaimed, - }}, - RewardsByEdenbUnclaimed: sdk.Coins{sdk.Coin{ - Denom: denom, - Amount: rewardsByEdenbUnclaimed, - }}, - RewardsByUsdcUnclaimed: sdk.Coins{sdk.Coin{ - Denom: denom, - Amount: rewardsByUsdcUnclaimed, - }}, - CommittedTokens: []*types.CommittedTokens{&committedTokens}, - } - - keeper.SetCommitments(ctx, initialCommitments) - - // Set assetprofile entry for denom - app.AssetprofileKeeper.SetEntry(ctx, aptypes.Entry{Denom: denom, BaseDenom: denom, WithdrawEnabled: true}) - - // Test scenario 1: Withdraw LP mining rewards - err := app.CommitmentKeeper.RecordClaimReward(ctx, creator, denom, sdk.NewInt(46), types.EarnType_ALL_PROGRAM) - require.NoError(t, err) - - updatedCommitments := keeper.GetCommitments(ctx, creator) - unclaimedBalance := updatedCommitments.GetLPMiningSubBucketRewardUnclaimedForDenom(denom) - assert.Equal(t, sdk.NewInt(4), unclaimedBalance) - require.Equal(t, "46ueden", updatedCommitments.Claimed.String(), "tokens were not claimed correctly") - - // Test scenario 2: Withdraw within unclaimed balance - err = app.CommitmentKeeper.RecordClaimReward(ctx, creator, denom, sdk.NewInt(2), types.EarnType_ALL_PROGRAM) - require.NoError(t, err) - - updatedCommitments = keeper.GetCommitments(ctx, creator) - unclaimedBalance = updatedCommitments.GetRewardUnclaimedForDenom(denom) - assert.Equal(t, sdk.NewInt(2), unclaimedBalance) - require.Equal(t, "48ueden", updatedCommitments.Claimed.String(), "tokens were not claimed correctly") - - // Test scenario 3: Withdraw more than unclaimed reward - err = app.CommitmentKeeper.RecordClaimReward(ctx, creator, denom, sdk.NewInt(70), types.EarnType_ALL_PROGRAM) - require.Error(t, err) -} diff --git a/x/commitment/keeper/commitments.go b/x/commitment/keeper/commitments.go index d3b95bf5d..4e07c6308 100644 --- a/x/commitment/keeper/commitments.go +++ b/x/commitment/keeper/commitments.go @@ -6,7 +6,6 @@ import ( "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - aptypes "github.com/elys-network/elys/x/assetprofile/types" "github.com/elys-network/elys/x/commitment/types" ptypes "github.com/elys-network/elys/x/parameter/types" ) @@ -57,15 +56,10 @@ func (k Keeper) GetCommitments(ctx sdk.Context, creator string) types.Commitment b := store.Get(types.CommitmentsKey(creator)) if b == nil { return types.Commitments{ - Creator: creator, - CommittedTokens: []*types.CommittedTokens{}, - RewardsUnclaimed: sdk.Coins{}, - Claimed: sdk.Coins{}, - VestingTokens: []*types.VestingTokens{}, - RewardsByElysUnclaimed: sdk.Coins{}, - RewardsByEdenUnclaimed: sdk.Coins{}, - RewardsByEdenbUnclaimed: sdk.Coins{}, - RewardsByUsdcUnclaimed: sdk.Coins{}, + Creator: creator, + CommittedTokens: []*types.CommittedTokens{}, + Claimed: sdk.Coins{}, + VestingTokens: []*types.VestingTokens{}, } } @@ -110,44 +104,17 @@ func (k Keeper) DeductClaimed(ctx sdk.Context, creator string, denom string, amo return commitments, nil } -func (k Keeper) DeductUnclaimed(ctx sdk.Context, creator string, denom string, amount math.Int) (types.Commitments, error) { - // Get the Commitments for the creator - commitments := k.GetCommitments(ctx, creator) - - // if deduction amount is zero - if amount.Equal(sdk.ZeroInt()) { - return commitments, nil - } - - // Subtract the withdrawn amount from the unclaimed balance - err := commitments.SubRewardsUnclaimed(sdk.NewCoin(denom, amount)) - if err != nil { - return types.Commitments{}, err - } - return commitments, nil -} - func (k Keeper) BurnEdenBoost(ctx sdk.Context, creator string, denom string, amount math.Int) (types.Commitments, error) { // Get the Commitments for the creator commitments := k.GetCommitments(ctx, creator) - // if deduction amount is zero - if amount.Equal(sdk.ZeroInt()) { - return commitments, nil - } - - // Subtract the amount from the unclaimed balance - unclaimedRemovalAmount := amount - rewardUnclaimed := commitments.GetRewardUnclaimedForDenom(denom) - if rewardUnclaimed.LT(unclaimedRemovalAmount) { - unclaimedRemovalAmount = rewardUnclaimed - } - err := commitments.SubRewardsUnclaimed(sdk.NewCoin(denom, unclaimedRemovalAmount)) + addr := sdk.MustAccAddressFromBech32(creator) + err := k.hooks.BeforeEdenBCommitChange(ctx, addr) if err != nil { - return types.Commitments{}, err + return commitments, err } - amount = amount.Sub(unclaimedRemovalAmount) + // if deduction amount is zero if amount.Equal(sdk.ZeroInt()) { return commitments, nil } @@ -173,10 +140,16 @@ func (k Keeper) BurnEdenBoost(ctx sdk.Context, creator string, denom string, amo amount = committedAmount } + // Subtract the amount from the committed balance err = commitments.DeductFromCommitted(denom, amount, uint64(ctx.BlockTime().Unix())) if err != nil { return types.Commitments{}, err } + + err = k.hooks.CommitmentChanged(ctx, creator, sdk.Coins{sdk.NewCoin(denom, amount)}) + if err != nil { + return types.Commitments{}, err + } return commitments, nil } @@ -188,7 +161,10 @@ func (k Keeper) HandleWithdrawFromCommitment(ctx sdk.Context, commitments *types k.SetCommitments(ctx, *commitments) // Emit Hook commitment changed - k.AfterCommitmentChange(ctx, commitments.Creator, amount) + err := k.CommitmentChanged(ctx, commitments.Creator, amount) + if err != nil { + return err + } withdrawCoins := amount. Sub(sdk.NewCoin(ptypes.Eden, edenAmount)). @@ -200,52 +176,6 @@ func (k Keeper) HandleWithdrawFromCommitment(ctx sdk.Context, commitments *types return nil } -// Update commitments for validator's commission withdrawal to self delegator -func (k Keeper) RecordWithdrawValidatorCommission(ctx sdk.Context, delegator string, creator string, denom string, amount math.Int) error { - assetProfile, found := k.assetProfileKeeper.GetEntry(ctx, denom) - if !found { - return errorsmod.Wrapf(aptypes.ErrAssetProfileNotFound, "denom: %s", denom) - } - - if !assetProfile.WithdrawEnabled { - return errorsmod.Wrapf(types.ErrWithdrawDisabled, "denom: %s", denom) - } - - commitments, err := k.DeductUnclaimed(ctx, creator, denom, amount) - if err != nil { - return err - } - - // Update the commitments - k.SetCommitments(ctx, commitments) - - withdrawCoins := sdk.NewCoins(sdk.NewCoin(denom, amount)) - - // Withdraw to the delegated wallet - addr, err := sdk.AccAddressFromBech32(delegator) - if err != nil { - return errorsmod.Wrap(sdkerrors.ErrInvalidAddress, "unable to convert address from bech32") - } - - commitments = k.GetCommitments(ctx, delegator) - err = k.HandleWithdrawFromCommitment(ctx, &commitments, withdrawCoins, false, addr) - if err != nil { - return err - } - - // Emit blockchain event - ctx.EventManager().EmitEvent( - sdk.NewEvent( - types.EventTypeCommitmentChanged, - sdk.NewAttribute(types.AttributeCreator, creator), - sdk.NewAttribute(types.AttributeAmount, amount.String()), - sdk.NewAttribute(types.AttributeDenom, denom), - ), - ) - - return nil -} - // Process delegation hook - create commitment entities for delegator and validator func (k Keeper) BeforeDelegationCreated(ctx sdk.Context, delegator string, validator string) error { _, err := sdk.AccAddressFromBech32(delegator) @@ -267,7 +197,10 @@ func (k Keeper) BeforeDelegationCreated(ctx sdk.Context, delegator string, valid k.SetCommitments(ctx, commitments) // Emit Hook commitment changed - k.AfterCommitmentChange(ctx, delegator, sdk.Coins{}) + err := k.CommitmentChanged(ctx, delegator, sdk.Coins{}) + if err != nil { + return err + } // Emit blockchain event ctx.EventManager().EmitEvent( diff --git a/x/commitment/keeper/deposit_liquid_tokens_test.go b/x/commitment/keeper/deposit_liquid_tokens_test.go index 71267bc10..e83fb9cdd 100644 --- a/x/commitment/keeper/deposit_liquid_tokens_test.go +++ b/x/commitment/keeper/deposit_liquid_tokens_test.go @@ -44,8 +44,7 @@ func TestDepositLiquidTokens(t *testing.T) { Amount: sdk.NewInt(50), }, }, - RewardsUnclaimed: sdk.Coins{}, - Claimed: sdk.Coins{sdk.NewCoin(ptypes.Eden, sdk.NewInt(150))}, + Claimed: sdk.Coins{sdk.NewCoin(ptypes.Eden, sdk.NewInt(150))}, } keeper.SetCommitments(ctx, commitments) diff --git a/x/commitment/keeper/hooks.go b/x/commitment/keeper/hooks.go index f5fcd9814..28850c1bb 100644 --- a/x/commitment/keeper/hooks.go +++ b/x/commitment/keeper/hooks.go @@ -10,36 +10,84 @@ var _ types.CommitmentHooks = MultiCommitmentHooks{} // combine multiple commitment hooks, all hook functions are run in array sequence type MultiCommitmentHooks []types.CommitmentHooks -func NewMultiEpochHooks(hooks ...types.CommitmentHooks) MultiCommitmentHooks { +func NewMultiCommitmentHooks(hooks ...types.CommitmentHooks) MultiCommitmentHooks { return hooks } // Committed is called when staker committed his token -func (mh MultiCommitmentHooks) CommitmentChanged(ctx sdk.Context, creator string, amount sdk.Coins) { +func (mh MultiCommitmentHooks) CommitmentChanged(ctx sdk.Context, creator string, amount sdk.Coins) error { for i := range mh { - mh[i].CommitmentChanged(ctx, creator, amount) + err := mh[i].CommitmentChanged(ctx, creator, amount) + if err != nil { + return err + } } + return nil } // Committed is called when staker committed his token -func (mh MultiCommitmentHooks) EdenUncommitted(ctx sdk.Context, creator string, amount sdk.Coin) { +func (mh MultiCommitmentHooks) EdenUncommitted(ctx sdk.Context, creator string, amount sdk.Coin) error { for i := range mh { - mh[i].EdenUncommitted(ctx, creator, amount) + err := mh[i].EdenUncommitted(ctx, creator, amount) + if err != nil { + return err + } } + return nil +} + +func (mh MultiCommitmentHooks) BeforeEdenInitialCommit(ctx sdk.Context, addr sdk.AccAddress) error { + for i := range mh { + err := mh[i].BeforeEdenInitialCommit(ctx, addr) + if err != nil { + return err + } + } + return nil +} + +func (mh MultiCommitmentHooks) BeforeEdenBInitialCommit(ctx sdk.Context, addr sdk.AccAddress) error { + for i := range mh { + err := mh[i].BeforeEdenBInitialCommit(ctx, addr) + if err != nil { + return err + } + } + return nil +} + +func (mh MultiCommitmentHooks) BeforeEdenCommitChange(ctx sdk.Context, addr sdk.AccAddress) error { + for i := range mh { + err := mh[i].BeforeEdenCommitChange(ctx, addr) + if err != nil { + return err + } + } + return nil +} + +func (mh MultiCommitmentHooks) BeforeEdenBCommitChange(ctx sdk.Context, addr sdk.AccAddress) error { + for i := range mh { + err := mh[i].BeforeEdenBCommitChange(ctx, addr) + if err != nil { + return err + } + } + return nil } // Committed executes the indicated for committed hook -func (k Keeper) AfterCommitmentChange(ctx sdk.Context, creator string, amount sdk.Coins) { +func (k Keeper) CommitmentChanged(ctx sdk.Context, creator string, amount sdk.Coins) error { if k.hooks == nil { - return + return nil } - k.hooks.CommitmentChanged(ctx, creator, amount) + return k.hooks.CommitmentChanged(ctx, creator, amount) } // Committed executes the indicated for committed hook -func (k Keeper) EdenUncommitted(ctx sdk.Context, creator string, amount sdk.Coin) { +func (k Keeper) EdenUncommitted(ctx sdk.Context, creator string, amount sdk.Coin) error { if k.hooks == nil { - return + return nil } - k.hooks.EdenUncommitted(ctx, creator, amount) + return k.hooks.EdenUncommitted(ctx, creator, amount) } diff --git a/x/commitment/keeper/keeper.go b/x/commitment/keeper/keeper.go index 91cfae440..66521cf6b 100644 --- a/x/commitment/keeper/keeper.go +++ b/x/commitment/keeper/keeper.go @@ -3,14 +3,15 @@ package keeper import ( "fmt" - "cosmossdk.io/math" "github.com/cometbft/cometbft/libs/log" "github.com/cosmos/cosmos-sdk/codec" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/elys-network/elys/x/commitment/types" + ptypes "github.com/elys-network/elys/x/parameter/types" ) // Interface declearation @@ -23,12 +24,6 @@ type CommitmentKeeperI interface { // Get commitment GetCommitments(sdk.Context, string) types.Commitments - - // Update commitments for claim reward operation - RecordClaimReward(sdk.Context, string, string, math.Int, types.EarnType) error - - // Update commitments for validator's commission withdrawal to self delegator - RecordWithdrawValidatorCommission(sdk.Context, string, string, string, math.Int) error } var _ CommitmentKeeperI = Keeper{} @@ -59,11 +54,6 @@ func NewKeeper( assetProfileKeeper types.AssetProfileKeeper, authority string, ) *Keeper { - // set KeyTable if it has not already been set - if !ps.HasKeyTable() { - ps = ps.WithKeyTable(types.ParamKeyTable()) - } - return &Keeper{ cdc: cdc, storeKey: storeKey, @@ -95,3 +85,133 @@ func (k *Keeper) SetHooks(eh types.CommitmentHooks) *Keeper { return k } + +func (k Keeper) GetAllBalances(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins { + commitments := k.GetCommitments(ctx, addr.String()) + edenEdenBAmounts := sdk.Coins{} + edenEdenBAmounts = edenEdenBAmounts.Add(sdk.NewCoin(ptypes.Eden, commitments.Claimed.AmountOf(ptypes.Eden))) + edenEdenBAmounts = edenEdenBAmounts.Add(sdk.NewCoin(ptypes.EdenB, commitments.Claimed.AmountOf(ptypes.EdenB))) + + balances := k.bankKeeper.GetAllBalances(ctx, addr) + return balances.Add(edenEdenBAmounts...) +} + +func (k Keeper) SpendableCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins { + return k.bankKeeper.SpendableCoins(ctx, addr) +} + +func (k Keeper) BlockedAddr(addr sdk.AccAddress) bool { + return k.bankKeeper.BlockedAddr(addr) +} + +func (k Keeper) AddEdenEdenBOnAccount(ctx sdk.Context, addr sdk.AccAddress, amt sdk.Coins) sdk.Coins { + commitments := k.GetCommitments(ctx, addr.String()) + if amt.AmountOf(ptypes.Eden).IsPositive() { + coin := sdk.NewCoin(ptypes.Eden, amt.AmountOf(ptypes.Eden)) + amt = amt.Sub(coin) + commitments.AddClaimed(coin) + } + if amt.AmountOf(ptypes.EdenB).IsPositive() { + coin := sdk.NewCoin(ptypes.EdenB, amt.AmountOf(ptypes.EdenB)) + amt = amt.Sub(coin) + commitments.AddClaimed(coin) + } + + // Save the updated Commitments + k.SetCommitments(ctx, commitments) + return amt +} + +func (k Keeper) AddEdenEdenBOnModule(ctx sdk.Context, moduleName string, amt sdk.Coins) sdk.Coins { + addr := authtypes.NewModuleAddress(moduleName) + commitments := k.GetCommitments(ctx, addr.String()) + if amt.AmountOf(ptypes.Eden).IsPositive() { + coin := sdk.NewCoin(ptypes.Eden, amt.AmountOf(ptypes.Eden)) + amt = amt.Sub(coin) + commitments.AddClaimed(coin) + } + if amt.AmountOf(ptypes.EdenB).IsPositive() { + coin := sdk.NewCoin(ptypes.EdenB, amt.AmountOf(ptypes.EdenB)) + amt = amt.Sub(coin) + commitments.AddClaimed(coin) + } + + // Save the updated Commitments + k.SetCommitments(ctx, commitments) + return amt +} + +func (k Keeper) SubEdenEdenBOnModule(ctx sdk.Context, moduleName string, amt sdk.Coins) (sdk.Coins, error) { + addr := authtypes.NewModuleAddress(moduleName) + commitments := k.GetCommitments(ctx, addr.String()) + if amt.AmountOf(ptypes.Eden).IsPositive() { + coin := sdk.NewCoin(ptypes.Eden, amt.AmountOf(ptypes.Eden)) + amt = amt.Sub(coin) + err := commitments.SubClaimed(coin) + if err != nil { + return amt, err + } + } + if amt.AmountOf(ptypes.EdenB).IsPositive() { + coin := sdk.NewCoin(ptypes.EdenB, amt.AmountOf(ptypes.EdenB)) + amt = amt.Sub(coin) + err := commitments.SubClaimed(coin) + if err != nil { + return amt, err + } + } + + // Save the updated Commitments + k.SetCommitments(ctx, commitments) + return amt, nil +} + +func (k Keeper) MintCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) error { + amt = k.AddEdenEdenBOnModule(ctx, moduleName, amt) + if amt.Empty() { + return nil + } + return k.bankKeeper.MintCoins(ctx, moduleName, amt) +} + +func (k Keeper) BurnCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) error { + amt, err := k.SubEdenEdenBOnModule(ctx, moduleName, amt) + if err != nil { + return err + } + if amt.Empty() { + return nil + } + + return k.bankKeeper.BurnCoins(ctx, moduleName, amt) +} + +func (k Keeper) SendCoinsFromModuleToModule(ctx sdk.Context, senderModule string, recipientModule string, amt sdk.Coins) error { + _, err := k.SubEdenEdenBOnModule(ctx, senderModule, amt) + if err != nil { + return err + } + amt = k.AddEdenEdenBOnModule(ctx, recipientModule, amt) + if amt.Empty() { + return nil + } + return k.bankKeeper.SendCoinsFromModuleToModule(ctx, senderModule, recipientModule, amt) +} + +func (k Keeper) SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error { + _, err := k.SubEdenEdenBOnModule(ctx, senderModule, amt) + if err != nil { + return err + } + + amt = k.AddEdenEdenBOnAccount(ctx, recipientAddr, amt) + if amt.Empty() { + return nil + } + + return k.bankKeeper.SendCoinsFromModuleToAccount(ctx, senderModule, recipientAddr, amt) +} + +func (k Keeper) SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error { + return k.bankKeeper.SendCoinsFromAccountToModule(ctx, senderAddr, recipientModule, amt) +} diff --git a/x/commitment/keeper/msg_server_cancel_vest.go b/x/commitment/keeper/msg_server_cancel_vest.go index 5ff28ce4b..2836ca516 100644 --- a/x/commitment/keeper/msg_server_cancel_vest.go +++ b/x/commitment/keeper/msg_server_cancel_vest.go @@ -59,9 +59,6 @@ func (k msgServer) CancelVest(goCtx context.Context, msg *types.MsgCancelVest) ( commitments.AddClaimed(sdk.NewCoin(ptypes.Eden, msg.Amount)) k.SetCommitments(ctx, commitments) - // Emit Hook commitment changed - k.AfterCommitmentChange(ctx, msg.Creator, sdk.Coins{sdk.NewCoin(ptypes.Eden, msg.Amount)}) - // Emit blockchain event ctx.EventManager().EmitEvent( sdk.NewEvent( diff --git a/x/commitment/keeper/msg_server_commit_claimed_rewards.go b/x/commitment/keeper/msg_server_commit_claimed_rewards.go index 09fe5fa6c..652cf96aa 100644 --- a/x/commitment/keeper/msg_server_commit_claimed_rewards.go +++ b/x/commitment/keeper/msg_server_commit_claimed_rewards.go @@ -7,12 +7,13 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" aptypes "github.com/elys-network/elys/x/assetprofile/types" "github.com/elys-network/elys/x/commitment/types" + ptypes "github.com/elys-network/elys/x/parameter/types" ) // CommitClaimedRewards commit the tokens on unclaimed store to committed func (k msgServer) CommitClaimedRewards(goCtx context.Context, msg *types.MsgCommitClaimedRewards) (*types.MsgCommitClaimedRewardsResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - + sender := sdk.MustAccAddressFromBech32(msg.Creator) assetProfile, found := k.assetProfileKeeper.GetEntry(ctx, msg.Denom) if !found { return nil, errorsmod.Wrapf(aptypes.ErrAssetProfileNotFound, "denom: %s", msg.Denom) @@ -29,6 +30,34 @@ func (k msgServer) CommitClaimedRewards(goCtx context.Context, msg *types.MsgCom // Get the Commitments for the creator commitments := k.GetCommitments(ctx, msg.Creator) + if msg.Denom == ptypes.Eden { + if commitments.GetCommittedAmountForDenom(ptypes.Eden).IsPositive() { + err := k.hooks.BeforeEdenCommitChange(ctx, sender) + if err != nil { + return nil, err + } + } else { + err := k.hooks.BeforeEdenInitialCommit(ctx, sender) + if err != nil { + return nil, err + } + } + } + + if msg.Denom == ptypes.EdenB { + if commitments.GetCommittedAmountForDenom(ptypes.EdenB).IsPositive() { + err := k.hooks.BeforeEdenBCommitChange(ctx, sender) + if err != nil { + return nil, err + } + } else { + err := k.hooks.BeforeEdenBInitialCommit(ctx, sender) + if err != nil { + return nil, err + } + } + } + // Decrease unclaimed tokens amount err := commitments.SubClaimed(sdk.NewCoin(msg.Denom, msg.Amount)) if err != nil { @@ -42,7 +71,10 @@ func (k msgServer) CommitClaimedRewards(goCtx context.Context, msg *types.MsgCom k.SetCommitments(ctx, commitments) // Emit Hook commitment changed - k.AfterCommitmentChange(ctx, msg.Creator, sdk.Coins{sdk.NewCoin(msg.Denom, msg.Amount)}) + err = k.CommitmentChanged(ctx, msg.Creator, sdk.Coins{sdk.NewCoin(msg.Denom, msg.Amount)}) + if err != nil { + return nil, err + } // Emit blockchain event ctx.EventManager().EmitEvent( diff --git a/x/commitment/keeper/msg_server_commit_claimed_rewards_test.go b/x/commitment/keeper/msg_server_commit_claimed_rewards_test.go index 89a08eb0d..37fce0340 100644 --- a/x/commitment/keeper/msg_server_commit_claimed_rewards_test.go +++ b/x/commitment/keeper/msg_server_commit_claimed_rewards_test.go @@ -3,6 +3,7 @@ package keeper_test import ( "testing" + "github.com/cometbft/cometbft/crypto/ed25519" tmproto "github.com/cometbft/cometbft/proto/tendermint/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -24,7 +25,7 @@ func TestCommitClaimedRewards(t *testing.T) { msgServer := commitmentkeeper.NewMsgServerImpl(keeper) // Define the test data - creator := "test_creator" + creator := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address()).String() denom := "test_denom" initialUnclaimed := sdk.NewInt(500) commitAmount := sdk.NewInt(100) @@ -32,9 +33,8 @@ func TestCommitClaimedRewards(t *testing.T) { // Set up initial commitments object with sufficient unclaimed tokens rewardsClaimed := sdk.NewCoin(denom, initialUnclaimed) initialCommitments := types.Commitments{ - Creator: creator, - RewardsUnclaimed: sdk.Coins{}, - Claimed: sdk.Coins{rewardsClaimed}, + Creator: creator, + Claimed: sdk.Coins{rewardsClaimed}, } keeper.SetCommitments(ctx, initialCommitments) diff --git a/x/commitment/keeper/msg_server_commit_liquid_tokens.go b/x/commitment/keeper/msg_server_commit_liquid_tokens.go index 3dc74cc44..662538d33 100644 --- a/x/commitment/keeper/msg_server_commit_liquid_tokens.go +++ b/x/commitment/keeper/msg_server_commit_liquid_tokens.go @@ -50,7 +50,10 @@ func (k msgServer) CommitLiquidTokens(goCtx context.Context, msg *types.MsgCommi k.SetCommitments(ctx, commitments) // Emit Hook commitment changed - k.AfterCommitmentChange(ctx, msg.Creator, sdk.Coins{sdk.NewCoin(msg.Denom, msg.Amount)}) + err = k.CommitmentChanged(ctx, msg.Creator, sdk.Coins{sdk.NewCoin(msg.Denom, msg.Amount)}) + if err != nil { + return nil, err + } // Emit blockchain event ctx.EventManager().EmitEvent( diff --git a/x/commitment/keeper/msg_server_uncommit_tokens.go b/x/commitment/keeper/msg_server_uncommit_tokens.go index 0aec62eec..ec5cb9f80 100644 --- a/x/commitment/keeper/msg_server_uncommit_tokens.go +++ b/x/commitment/keeper/msg_server_uncommit_tokens.go @@ -15,6 +15,11 @@ import ( func (k msgServer) UncommitTokens(goCtx context.Context, msg *types.MsgUncommitTokens) (*types.MsgUncommitTokensResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) + addr, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + return nil, errorsmod.Wrap(sdkerrors.ErrInvalidAddress, "unable to convert address from bech32") + } + assetProfile, found := k.assetProfileKeeper.GetEntry(ctx, msg.Denom) if !found { return nil, errorsmod.Wrapf(aptypes.ErrAssetProfileNotFound, "denom: %s", msg.Denom) @@ -27,8 +32,22 @@ func (k msgServer) UncommitTokens(goCtx context.Context, msg *types.MsgUncommitT // Get the Commitments for the creator commitments := k.GetCommitments(ctx, msg.Creator) + if msg.Denom == ptypes.Eden { + err := k.hooks.BeforeEdenCommitChange(ctx, addr) + if err != nil { + return nil, err + } + } + + if msg.Denom == ptypes.EdenB { + err := k.hooks.BeforeEdenBCommitChange(ctx, addr) + if err != nil { + return nil, err + } + } + // Deduct from committed tokens - err := commitments.DeductFromCommitted(msg.Denom, msg.Amount, uint64(ctx.BlockTime().Unix())) + err = commitments.DeductFromCommitted(msg.Denom, msg.Amount, uint64(ctx.BlockTime().Unix())) if err != nil { return nil, err } @@ -36,11 +55,6 @@ func (k msgServer) UncommitTokens(goCtx context.Context, msg *types.MsgUncommitT liquidCoins := sdk.NewCoins(sdk.NewCoin(msg.Denom, msg.Amount)) - addr, err := sdk.AccAddressFromBech32(commitments.Creator) - if err != nil { - return nil, errorsmod.Wrap(sdkerrors.ErrInvalidAddress, "unable to convert address from bech32") - } - err = k.HandleWithdrawFromCommitment(ctx, &commitments, liquidCoins, true, addr) if err != nil { return nil, err @@ -48,7 +62,16 @@ func (k msgServer) UncommitTokens(goCtx context.Context, msg *types.MsgUncommitT // Emit Hook if Eden is uncommitted if msg.Denom == ptypes.Eden { - k.EdenUncommitted(ctx, msg.Creator, sdk.NewCoin(msg.Denom, msg.Amount)) + err = k.EdenUncommitted(ctx, msg.Creator, sdk.NewCoin(msg.Denom, msg.Amount)) + if err != nil { + return nil, err + } + } + + // Emit Hook commitment changed + err = k.CommitmentChanged(ctx, msg.Creator, sdk.Coins{sdk.NewCoin(msg.Denom, msg.Amount)}) + if err != nil { + return nil, err } // Update total commitment diff --git a/x/commitment/keeper/msg_server_uncommit_tokens_test.go b/x/commitment/keeper/msg_server_uncommit_tokens_test.go index d044105cb..626a73f8e 100644 --- a/x/commitment/keeper/msg_server_uncommit_tokens_test.go +++ b/x/commitment/keeper/msg_server_uncommit_tokens_test.go @@ -29,25 +29,18 @@ func TestUncommitTokens(t *testing.T) { // Define the test data creator := addr[0].String() denom := "test_denom" - initialUnclaimed := sdk.NewInt(400) initialCommitted := sdk.NewInt(100) uncommitAmount := sdk.NewInt(100) // Set up initial commitments object with sufficient unclaimed & committed tokens - rewardsUnclaimed := sdk.Coin{ - Denom: denom, - Amount: initialUnclaimed, - } - committedTokens := types.CommittedTokens{ Denom: denom, Amount: initialCommitted, } initialCommitments := types.Commitments{ - Creator: creator, - RewardsUnclaimed: sdk.Coins{rewardsUnclaimed}, - CommittedTokens: []*types.CommittedTokens{&committedTokens}, + Creator: creator, + CommittedTokens: []*types.CommittedTokens{&committedTokens}, } keeper.SetCommitments(ctx, initialCommitments) diff --git a/x/commitment/keeper/msg_server_vest.go b/x/commitment/keeper/msg_server_vest.go index 48c4764e8..3ff64cbe5 100644 --- a/x/commitment/keeper/msg_server_vest.go +++ b/x/commitment/keeper/msg_server_vest.go @@ -58,9 +58,6 @@ func (k Keeper) ProcessTokenVesting(ctx sdk.Context, denom string, amount math.I // Update the commitments k.SetCommitments(ctx, commitments) - // Emit Hook commitment changed - k.AfterCommitmentChange(ctx, creator, sdk.Coins{sdk.NewCoin(denom, amount)}) - // Emit blockchain event ctx.EventManager().EmitEvent( sdk.NewEvent( diff --git a/x/commitment/keeper/msg_server_vest_liquid_test.go b/x/commitment/keeper/msg_server_vest_liquid_test.go index f734e2ea6..70f22f42d 100644 --- a/x/commitment/keeper/msg_server_vest_liquid_test.go +++ b/x/commitment/keeper/msg_server_vest_liquid_test.go @@ -68,7 +68,6 @@ func TestLiquidVestWithExceed(t *testing.T) { Amount: sdk.NewInt(50), }, }, - RewardsUnclaimed: sdk.Coins{}, Claimed: sdk.Coins{ { Denom: ptypes.Eden, diff --git a/x/commitment/keeper/msg_server_vest_now.go b/x/commitment/keeper/msg_server_vest_now.go index 39254b869..4cc7d0ffe 100644 --- a/x/commitment/keeper/msg_server_vest_now.go +++ b/x/commitment/keeper/msg_server_vest_now.go @@ -63,9 +63,6 @@ func (k msgServer) VestNow(goCtx context.Context, msg *types.MsgVestNow) (*types // Update the commitments k.SetCommitments(ctx, commitments) - // Emit Hook commitment changed - k.AfterCommitmentChange(ctx, msg.Creator, sdk.Coins{sdk.NewCoin(msg.Denom, msg.Amount)}) - // Emit blockchain event ctx.EventManager().EmitEvent( sdk.NewEvent( diff --git a/x/commitment/keeper/msg_server_vest_now_test.go b/x/commitment/keeper/msg_server_vest_now_test.go index 5a914ecad..f8892b038 100644 --- a/x/commitment/keeper/msg_server_vest_now_test.go +++ b/x/commitment/keeper/msg_server_vest_now_test.go @@ -51,15 +51,13 @@ func TestVestNow(t *testing.T) { keeper.SetParams(ctx, params) // Set up initial commitments object with sufficient claimed & committed tokens - committedTokens := types.CommittedTokens{ Denom: denom, Amount: initialCommitted, } initialCommitments := types.Commitments{ - Creator: creator, - RewardsUnclaimed: sdk.Coins{}, + Creator: creator, Claimed: sdk.Coins{ { Denom: denom, diff --git a/x/commitment/keeper/msg_server_vest_test.go b/x/commitment/keeper/msg_server_vest_test.go index 73c3bfd20..92c4011de 100644 --- a/x/commitment/keeper/msg_server_vest_test.go +++ b/x/commitment/keeper/msg_server_vest_test.go @@ -63,7 +63,6 @@ func TestVest(t *testing.T) { Amount: sdk.NewInt(50), }, }, - RewardsUnclaimed: sdk.Coins{}, Claimed: sdk.Coins{ { Denom: ptypes.Eden, @@ -142,7 +141,6 @@ func TestExceedVesting(t *testing.T) { Amount: sdk.NewInt(50), }, }, - RewardsUnclaimed: sdk.Coins{}, Claimed: sdk.Coins{ { Denom: ptypes.Eden, diff --git a/x/commitment/keeper/params.go b/x/commitment/keeper/params.go index 346292cfe..f91dca460 100644 --- a/x/commitment/keeper/params.go +++ b/x/commitment/keeper/params.go @@ -5,18 +5,6 @@ import ( "github.com/elys-network/elys/x/commitment/types" ) -// GetParams returns the current parameters of the Commitment module -func (k Keeper) GetLegacyParams(ctx sdk.Context) types.LegacyParams { - var params types.LegacyParams - k.paramstore.GetParamSet(ctx, ¶ms) - return params -} - -// SetParams set the params -func (k Keeper) SetLegacyParams(ctx sdk.Context, params types.LegacyParams) { - k.paramstore.SetParamSet(ctx, ¶ms) -} - // GetParams get all parameters as types.Params func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) { store := ctx.KVStore(k.storeKey) diff --git a/x/commitment/migrations/v3_migration.go b/x/commitment/migrations/v3_migration.go index f35600645..ffd4806d4 100644 --- a/x/commitment/migrations/v3_migration.go +++ b/x/commitment/migrations/v3_migration.go @@ -1,65 +1,10 @@ package migrations import ( - "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/elys-network/elys/x/commitment/types" ) func (m Migrator) V3Migration(ctx sdk.Context) error { - legacyParams := m.keeper.GetLegacyParams(ctx) - totalCommitted := sdk.Coins{} - legacyCommitments := m.keeper.GetAllLegacyCommitments(ctx) - for _, legacy := range legacyCommitments { - - vestingTokens := []*types.VestingTokens{} - for _, vt := range legacy.VestingTokens { - blockMultiplier := int64(17280) // "day" - if vt.EpochIdentifier == "tenseconds" { - blockMultiplier = int64(2) - } else { - blockMultiplier = int64(720) // "hour" - } - vestingTokens = append(vestingTokens, &types.VestingTokens{ - Denom: vt.Denom, - TotalAmount: vt.UnvestedAmount, - ClaimedAmount: math.ZeroInt(), - NumBlocks: vt.NumEpochs * blockMultiplier, - StartBlock: ctx.BlockHeight(), - VestStartedTimestamp: vt.VestStartedTimestamp, - }) - } - m.keeper.SetCommitments(ctx, types.Commitments{ - Creator: legacy.Creator, - CommittedTokens: legacy.CommittedTokens, - RewardsUnclaimed: legacy.RewardsUnclaimed, - Claimed: legacy.Claimed, - VestingTokens: vestingTokens, - RewardsByElysUnclaimed: legacy.RewardsByElysUnclaimed, - RewardsByEdenUnclaimed: legacy.RewardsByEdenUnclaimed, - RewardsByEdenbUnclaimed: legacy.RewardsByEdenbUnclaimed, - RewardsByUsdcUnclaimed: legacy.RewardsByUsdcUnclaimed, - }) - for _, token := range legacy.CommittedTokens { - totalCommitted = totalCommitted.Add(sdk.NewCoin(token.Denom, token.Amount)) - } - } - - vestingInfos := []*types.VestingInfo{} - for _, legacy := range legacyParams.VestingInfos { - vestingInfos = append(vestingInfos, &types.VestingInfo{ - BaseDenom: legacy.BaseDenom, - VestingDenom: legacy.VestingDenom, - NumBlocks: legacy.NumEpochs * 17280, - VestNowFactor: legacy.VestNowFactor, - NumMaxVestings: legacy.NumMaxVestings, - }) - } - - m.keeper.SetParams(ctx, types.Params{ - VestingInfos: vestingInfos, - TotalCommitted: totalCommitted, - }) return nil } diff --git a/x/commitment/types/commitments.go b/x/commitment/types/commitments.go index 0bb0031f7..960c620f8 100644 --- a/x/commitment/types/commitments.go +++ b/x/commitment/types/commitments.go @@ -9,9 +9,6 @@ func (c Commitments) IsEmpty() bool { if len(c.CommittedTokens) > 0 { return false } - if len(c.RewardsUnclaimed) > 0 { - return false - } if len(c.Claimed) > 0 { return false } @@ -117,197 +114,6 @@ func (c *Commitments) DeductFromCommitted(denom string, amount math.Int, currTim return ErrInsufficientCommittedTokens } -func (c *Commitments) GetRewardUnclaimedForDenom(denom string) math.Int { - return c.RewardsUnclaimed.AmountOf(denom) -} - -// Sub bucket rewards query - Elys -func (c *Commitments) GetElysSubBucketRewardUnclaimedForDenom(denom string) math.Int { - return c.RewardsByElysUnclaimed.AmountOf(denom) -} - -// Sub bucket rewards query - Eden -func (c *Commitments) GetEdenSubBucketRewardUnclaimedForDenom(denom string) math.Int { - return c.RewardsByEdenUnclaimed.AmountOf(denom) -} - -// Sub bucket rewards query - EdenB -func (c *Commitments) GetEdenBSubBucketRewardUnclaimedForDenom(denom string) math.Int { - return c.RewardsByEdenbUnclaimed.AmountOf(denom) -} - -// Sub bucket rewards query - Usdc -func (c *Commitments) GetUsdcSubBucketRewardUnclaimedForDenom(denom string) math.Int { - return c.RewardsByUsdcUnclaimed.AmountOf(denom) -} - -func (c *Commitments) GetLPMiningSubBucketRewardUnclaimedForDenom(denom string) math.Int { - lpMiningRewards := c.RewardsUnclaimed. - Sub(c.RewardsByElysUnclaimed...). - Sub(c.RewardsByEdenUnclaimed...). - Sub(c.RewardsByEdenbUnclaimed...). - Sub(c.RewardsByUsdcUnclaimed...) - return lpMiningRewards.AmountOf(denom) -} - -func (c *Commitments) AddRewardsUnclaimed(amount sdk.Coin) { - c.RewardsUnclaimed = c.RewardsUnclaimed.Add(amount) -} - -func (c *Commitments) AddSubBucketRewardsByElysUnclaimed(amount sdk.Coins) { - c.RewardsByElysUnclaimed = c.RewardsByElysUnclaimed.Add(amount...) -} - -func (c *Commitments) AddSubBucketRewardsByEdenUnclaimed(amount sdk.Coins) { - c.RewardsByEdenUnclaimed = c.RewardsByEdenUnclaimed.Add(amount...) -} - -func (c *Commitments) AddSubBucketRewardsByEdenBUnclaimed(amount sdk.Coins) { - c.RewardsByEdenbUnclaimed = c.RewardsByEdenbUnclaimed.Add(amount...) -} - -func (c *Commitments) AddSubBucketRewardsByUsdcUnclaimed(amount sdk.Coins) { - c.RewardsByUsdcUnclaimed = c.RewardsByUsdcUnclaimed.Add(amount...) -} - -func (c *Commitments) SubRewardsUnclaimed(amount sdk.Coin) error { - if c.RewardsUnclaimed.AmountOf(amount.Denom).LT(amount.Amount) { - return ErrInsufficientRewardsUnclaimed - } - c.RewardsUnclaimed = c.RewardsUnclaimed.Sub(amount) - - // First deduct from elys staking bucket - allDeducted, remainedAmount := c.DeductSubBucketRewardsByElysUnclaimed(amount) - if allDeducted { - return nil - } - - // If there is still remaining amount, deduct from eden commited bucket - allDeducted, remainedAmount = c.DeductSubBucketRewardsByEdenUnclaimed(remainedAmount) - if allDeducted { - return nil - } - - // If there is still remaining amount, deduct from edenb commited bucket - allDeducted, remainedAmount = c.DeductSubBucketRewardsByEdenBUnclaimed(remainedAmount) - if allDeducted { - return nil - } - - // If there is still remaining amount, deduct from usdc deposit bucket - c.DeductSubBucketRewardsByUsdcUnclaimed(remainedAmount) - - return nil -} - -// This is the function used when we withdraw the reward by program -func (c *Commitments) SubRewardsUnclaimedForElysStaking(amount sdk.Coin) error { - if c.RewardsUnclaimed.AmountOf(amount.Denom).LT(amount.Amount) { - return ErrInsufficientRewardsUnclaimed - } - c.RewardsUnclaimed = c.RewardsUnclaimed.Sub(amount) - - c.DeductSubBucketRewardsByElysUnclaimed(amount) - return nil -} - -// This is the function used when we withdraw the reward by program -func (c *Commitments) SubRewardsUnclaimedForEdenCommitted(amount sdk.Coin) error { - if c.RewardsUnclaimed.AmountOf(amount.Denom).LT(amount.Amount) { - return ErrInsufficientRewardsUnclaimed - } - c.RewardsUnclaimed = c.RewardsUnclaimed.Sub(amount) - - c.DeductSubBucketRewardsByEdenUnclaimed(amount) - return nil -} - -// This is the function used when we withdraw the reward by program -func (c *Commitments) SubRewardsUnclaimedForEdenBCommitted(amount sdk.Coin) error { - if c.RewardsUnclaimed.AmountOf(amount.Denom).LT(amount.Amount) { - return ErrInsufficientRewardsUnclaimed - } - c.RewardsUnclaimed = c.RewardsUnclaimed.Sub(amount) - - c.DeductSubBucketRewardsByEdenBUnclaimed(amount) - return nil -} - -// This is the function used when we withdraw the reward by program -func (c *Commitments) SubRewardsUnclaimedForUSDCDeposit(amount sdk.Coin) error { - if c.RewardsUnclaimed.AmountOf(amount.Denom).LT(amount.Amount) { - return ErrInsufficientRewardsUnclaimed - } - c.RewardsUnclaimed = c.RewardsUnclaimed.Sub(amount) - - c.DeductSubBucketRewardsByUsdcUnclaimed(amount) - return nil -} - -func (c *Commitments) DeductSubBucketRewardsByElysUnclaimed(amount sdk.Coin) (bool, sdk.Coin) { - amountToDeduct := amount - availableToDeduct := c.RewardsByElysUnclaimed.AmountOf(amount.Denom) - if availableToDeduct.LT(amountToDeduct.Amount) { - amountToDeduct = sdk.NewCoin(amount.Denom, availableToDeduct) - } - - c.RewardsByElysUnclaimed = c.RewardsByElysUnclaimed.Sub(amountToDeduct) - remainedAmount := amount.Sub(amountToDeduct) - if remainedAmount.Amount.LTE(sdk.ZeroInt()) { - return true, remainedAmount - } - - return false, remainedAmount -} - -func (c *Commitments) DeductSubBucketRewardsByEdenUnclaimed(amount sdk.Coin) (bool, sdk.Coin) { - amountToDeduct := amount - availableToDeduct := c.RewardsByEdenUnclaimed.AmountOf(amount.Denom) - if availableToDeduct.LT(amountToDeduct.Amount) { - amountToDeduct = sdk.NewCoin(amount.Denom, availableToDeduct) - } - - c.RewardsByEdenUnclaimed = c.RewardsByEdenUnclaimed.Sub(amountToDeduct) - remainedAmount := amount.Sub(amountToDeduct) - if remainedAmount.Amount.LTE(sdk.ZeroInt()) { - return true, remainedAmount - } - - return false, remainedAmount -} - -func (c *Commitments) DeductSubBucketRewardsByEdenBUnclaimed(amount sdk.Coin) (bool, sdk.Coin) { - amountToDeduct := amount - availableToDeduct := c.RewardsByEdenbUnclaimed.AmountOf(amount.Denom) - if availableToDeduct.LT(amountToDeduct.Amount) { - amountToDeduct = sdk.NewCoin(amount.Denom, availableToDeduct) - } - - c.RewardsByEdenbUnclaimed = c.RewardsByEdenbUnclaimed.Sub(amountToDeduct) - remainedAmount := amount.Sub(amountToDeduct) - if remainedAmount.Amount.LTE(sdk.ZeroInt()) { - return true, remainedAmount - } - - return false, remainedAmount -} - -func (c *Commitments) DeductSubBucketRewardsByUsdcUnclaimed(amount sdk.Coin) (bool, sdk.Coin) { - amountToDeduct := amount - availableToDeduct := c.RewardsByUsdcUnclaimed.AmountOf(amount.Denom) - if availableToDeduct.LT(amountToDeduct.Amount) { - amountToDeduct = sdk.NewCoin(amount.Denom, availableToDeduct) - } - - c.RewardsByUsdcUnclaimed = c.RewardsByUsdcUnclaimed.Sub(amountToDeduct) - remainedAmount := amount.Sub(amountToDeduct) - if remainedAmount.Amount.LTE(sdk.ZeroInt()) { - return true, remainedAmount - } - - return false, remainedAmount -} - func (c *Commitments) GetClaimedForDenom(denom string) math.Int { for _, token := range c.Claimed { if token.Denom == denom { diff --git a/x/commitment/types/commitments.pb.go b/x/commitment/types/commitments.pb.go index bfc300c86..5ddb3c28e 100644 --- a/x/commitment/types/commitments.pb.go +++ b/x/commitment/types/commitments.pb.go @@ -31,15 +31,10 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // GenesisState defines the commitment module's genesis state. type Commitments struct { - Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` - CommittedTokens []*CommittedTokens `protobuf:"bytes,2,rep,name=committed_tokens,json=committedTokens,proto3" json:"committed_tokens,omitempty"` - RewardsUnclaimed github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,3,rep,name=rewards_unclaimed,json=rewardsUnclaimed,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"rewards_unclaimed"` - Claimed github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,4,rep,name=claimed,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"claimed"` - VestingTokens []*VestingTokens `protobuf:"bytes,5,rep,name=vesting_tokens,json=vestingTokens,proto3" json:"vesting_tokens,omitempty"` - RewardsByElysUnclaimed github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,6,rep,name=rewards_by_elys_unclaimed,json=rewardsByElysUnclaimed,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"rewards_by_elys_unclaimed"` - RewardsByEdenUnclaimed github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,7,rep,name=rewards_by_eden_unclaimed,json=rewardsByEdenUnclaimed,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"rewards_by_eden_unclaimed"` - RewardsByEdenbUnclaimed github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,8,rep,name=rewards_by_edenb_unclaimed,json=rewardsByEdenbUnclaimed,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"rewards_by_edenb_unclaimed"` - RewardsByUsdcUnclaimed github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,9,rep,name=rewards_by_usdc_unclaimed,json=rewardsByUsdcUnclaimed,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"rewards_by_usdc_unclaimed"` + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + CommittedTokens []*CommittedTokens `protobuf:"bytes,2,rep,name=committed_tokens,json=committedTokens,proto3" json:"committed_tokens,omitempty"` + Claimed github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,3,rep,name=claimed,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"claimed"` + VestingTokens []*VestingTokens `protobuf:"bytes,4,rep,name=vesting_tokens,json=vestingTokens,proto3" json:"vesting_tokens,omitempty"` } func (m *Commitments) Reset() { *m = Commitments{} } @@ -89,13 +84,6 @@ func (m *Commitments) GetCommittedTokens() []*CommittedTokens { return nil } -func (m *Commitments) GetRewardsUnclaimed() github_com_cosmos_cosmos_sdk_types.Coins { - if m != nil { - return m.RewardsUnclaimed - } - return nil -} - func (m *Commitments) GetClaimed() github_com_cosmos_cosmos_sdk_types.Coins { if m != nil { return m.Claimed @@ -110,34 +98,6 @@ func (m *Commitments) GetVestingTokens() []*VestingTokens { return nil } -func (m *Commitments) GetRewardsByElysUnclaimed() github_com_cosmos_cosmos_sdk_types.Coins { - if m != nil { - return m.RewardsByElysUnclaimed - } - return nil -} - -func (m *Commitments) GetRewardsByEdenUnclaimed() github_com_cosmos_cosmos_sdk_types.Coins { - if m != nil { - return m.RewardsByEdenUnclaimed - } - return nil -} - -func (m *Commitments) GetRewardsByEdenbUnclaimed() github_com_cosmos_cosmos_sdk_types.Coins { - if m != nil { - return m.RewardsByEdenbUnclaimed - } - return nil -} - -func (m *Commitments) GetRewardsByUsdcUnclaimed() github_com_cosmos_cosmos_sdk_types.Coins { - if m != nil { - return m.RewardsByUsdcUnclaimed - } - return nil -} - type Lockup 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"` UnlockTimestamp uint64 `protobuf:"varint,2,opt,name=unlock_timestamp,json=unlockTimestamp,proto3" json:"unlock_timestamp,omitempty"` @@ -236,51 +196,6 @@ func (m *CommittedTokens) GetLockups() []Lockup { return nil } -type RewardsUnclaimed struct { - Denom string `protobuf:"bytes,1,opt,name=denom,proto3" json:"denom,omitempty"` - Amount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=amount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"amount"` -} - -func (m *RewardsUnclaimed) Reset() { *m = RewardsUnclaimed{} } -func (m *RewardsUnclaimed) String() string { return proto.CompactTextString(m) } -func (*RewardsUnclaimed) ProtoMessage() {} -func (*RewardsUnclaimed) Descriptor() ([]byte, []int) { - return fileDescriptor_47379c930fe66ed6, []int{3} -} -func (m *RewardsUnclaimed) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *RewardsUnclaimed) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_RewardsUnclaimed.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 *RewardsUnclaimed) XXX_Merge(src proto.Message) { - xxx_messageInfo_RewardsUnclaimed.Merge(m, src) -} -func (m *RewardsUnclaimed) XXX_Size() int { - return m.Size() -} -func (m *RewardsUnclaimed) XXX_DiscardUnknown() { - xxx_messageInfo_RewardsUnclaimed.DiscardUnknown(m) -} - -var xxx_messageInfo_RewardsUnclaimed proto.InternalMessageInfo - -func (m *RewardsUnclaimed) GetDenom() string { - if m != nil { - return m.Denom - } - return "" -} - type VestingTokens struct { Denom string `protobuf:"bytes,1,opt,name=denom,proto3" json:"denom,omitempty"` TotalAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=total_amount,json=totalAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"total_amount"` @@ -294,7 +209,7 @@ func (m *VestingTokens) Reset() { *m = VestingTokens{} } func (m *VestingTokens) String() string { return proto.CompactTextString(m) } func (*VestingTokens) ProtoMessage() {} func (*VestingTokens) Descriptor() ([]byte, []int) { - return fileDescriptor_47379c930fe66ed6, []int{4} + return fileDescriptor_47379c930fe66ed6, []int{3} } func (m *VestingTokens) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -351,13 +266,12 @@ func (m *VestingTokens) GetVestStartedTimestamp() int64 { return 0 } -// GenesisState defines the commitment module's genesis state. type LegacyCommitments struct { Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` CommittedTokens []*CommittedTokens `protobuf:"bytes,2,rep,name=committed_tokens,json=committedTokens,proto3" json:"committed_tokens,omitempty"` RewardsUnclaimed github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,3,rep,name=rewards_unclaimed,json=rewardsUnclaimed,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"rewards_unclaimed"` Claimed github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,4,rep,name=claimed,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"claimed"` - VestingTokens []*LegacyVestingTokens `protobuf:"bytes,5,rep,name=vesting_tokens,json=vestingTokens,proto3" json:"vesting_tokens,omitempty"` + VestingTokens []*VestingTokens `protobuf:"bytes,5,rep,name=vesting_tokens,json=vestingTokens,proto3" json:"vesting_tokens,omitempty"` RewardsByElysUnclaimed github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,6,rep,name=rewards_by_elys_unclaimed,json=rewardsByElysUnclaimed,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"rewards_by_elys_unclaimed"` RewardsByEdenUnclaimed github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,7,rep,name=rewards_by_eden_unclaimed,json=rewardsByEdenUnclaimed,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"rewards_by_eden_unclaimed"` RewardsByEdenbUnclaimed github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,8,rep,name=rewards_by_edenb_unclaimed,json=rewardsByEdenbUnclaimed,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"rewards_by_edenb_unclaimed"` @@ -368,7 +282,7 @@ func (m *LegacyCommitments) Reset() { *m = LegacyCommitments{} } func (m *LegacyCommitments) String() string { return proto.CompactTextString(m) } func (*LegacyCommitments) ProtoMessage() {} func (*LegacyCommitments) Descriptor() ([]byte, []int) { - return fileDescriptor_47379c930fe66ed6, []int{5} + return fileDescriptor_47379c930fe66ed6, []int{4} } func (m *LegacyCommitments) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -425,7 +339,7 @@ func (m *LegacyCommitments) GetClaimed() github_com_cosmos_cosmos_sdk_types.Coin return nil } -func (m *LegacyCommitments) GetVestingTokens() []*LegacyVestingTokens { +func (m *LegacyCommitments) GetVestingTokens() []*VestingTokens { if m != nil { return m.VestingTokens } @@ -460,280 +374,62 @@ func (m *LegacyCommitments) GetRewardsByUsdcUnclaimed() github_com_cosmos_cosmos return nil } -type LegacyVestingTokens struct { - Denom string `protobuf:"bytes,1,opt,name=denom,proto3" json:"denom,omitempty"` - TotalAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=total_amount,json=totalAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"total_amount"` - UnvestedAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=unvested_amount,json=unvestedAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"unvested_amount"` - EpochIdentifier string `protobuf:"bytes,4,opt,name=epoch_identifier,json=epochIdentifier,proto3" json:"epoch_identifier,omitempty"` - NumEpochs int64 `protobuf:"varint,5,opt,name=num_epochs,json=numEpochs,proto3" json:"num_epochs,omitempty"` - CurrentEpoch int64 `protobuf:"varint,6,opt,name=current_epoch,json=currentEpoch,proto3" json:"current_epoch,omitempty"` - VestStartedTimestamp int64 `protobuf:"varint,7,opt,name=vest_started_timestamp,json=vestStartedTimestamp,proto3" json:"vest_started_timestamp,omitempty"` -} - -func (m *LegacyVestingTokens) Reset() { *m = LegacyVestingTokens{} } -func (m *LegacyVestingTokens) String() string { return proto.CompactTextString(m) } -func (*LegacyVestingTokens) ProtoMessage() {} -func (*LegacyVestingTokens) Descriptor() ([]byte, []int) { - return fileDescriptor_47379c930fe66ed6, []int{6} -} -func (m *LegacyVestingTokens) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *LegacyVestingTokens) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_LegacyVestingTokens.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 *LegacyVestingTokens) XXX_Merge(src proto.Message) { - xxx_messageInfo_LegacyVestingTokens.Merge(m, src) -} -func (m *LegacyVestingTokens) XXX_Size() int { - return m.Size() -} -func (m *LegacyVestingTokens) XXX_DiscardUnknown() { - xxx_messageInfo_LegacyVestingTokens.DiscardUnknown(m) -} - -var xxx_messageInfo_LegacyVestingTokens proto.InternalMessageInfo - -func (m *LegacyVestingTokens) GetDenom() string { - if m != nil { - return m.Denom - } - return "" -} - -func (m *LegacyVestingTokens) GetEpochIdentifier() string { - if m != nil { - return m.EpochIdentifier - } - return "" -} - -func (m *LegacyVestingTokens) GetNumEpochs() int64 { - if m != nil { - return m.NumEpochs - } - return 0 -} - -func (m *LegacyVestingTokens) GetCurrentEpoch() int64 { - if m != nil { - return m.CurrentEpoch - } - return 0 -} - -func (m *LegacyVestingTokens) GetVestStartedTimestamp() int64 { - if m != nil { - return m.VestStartedTimestamp - } - return 0 -} - -type LegacyVestingInfo struct { - BaseDenom string `protobuf:"bytes,1,opt,name=base_denom,json=baseDenom,proto3" json:"base_denom,omitempty"` - VestingDenom string `protobuf:"bytes,2,opt,name=vesting_denom,json=vestingDenom,proto3" json:"vesting_denom,omitempty"` - EpochIdentifier string `protobuf:"bytes,3,opt,name=epoch_identifier,json=epochIdentifier,proto3" json:"epoch_identifier,omitempty"` - NumEpochs int64 `protobuf:"varint,4,opt,name=num_epochs,json=numEpochs,proto3" json:"num_epochs,omitempty"` - VestNowFactor github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,5,opt,name=vest_now_factor,json=vestNowFactor,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"vest_now_factor"` - NumMaxVestings int64 `protobuf:"varint,6,opt,name=num_max_vestings,json=numMaxVestings,proto3" json:"num_max_vestings,omitempty"` -} - -func (m *LegacyVestingInfo) Reset() { *m = LegacyVestingInfo{} } -func (m *LegacyVestingInfo) String() string { return proto.CompactTextString(m) } -func (*LegacyVestingInfo) ProtoMessage() {} -func (*LegacyVestingInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_47379c930fe66ed6, []int{7} -} -func (m *LegacyVestingInfo) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *LegacyVestingInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_LegacyVestingInfo.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 *LegacyVestingInfo) XXX_Merge(src proto.Message) { - xxx_messageInfo_LegacyVestingInfo.Merge(m, src) -} -func (m *LegacyVestingInfo) XXX_Size() int { - return m.Size() -} -func (m *LegacyVestingInfo) XXX_DiscardUnknown() { - xxx_messageInfo_LegacyVestingInfo.DiscardUnknown(m) -} - -var xxx_messageInfo_LegacyVestingInfo proto.InternalMessageInfo - -func (m *LegacyVestingInfo) GetBaseDenom() string { - if m != nil { - return m.BaseDenom - } - return "" -} - -func (m *LegacyVestingInfo) GetVestingDenom() string { - if m != nil { - return m.VestingDenom - } - return "" -} - -func (m *LegacyVestingInfo) GetEpochIdentifier() string { - if m != nil { - return m.EpochIdentifier - } - return "" -} - -func (m *LegacyVestingInfo) GetNumEpochs() int64 { - if m != nil { - return m.NumEpochs - } - return 0 -} - -func (m *LegacyVestingInfo) GetNumMaxVestings() int64 { - if m != nil { - return m.NumMaxVestings - } - return 0 -} - -// Params defines the parameters for the module. -type LegacyParams struct { - VestingInfos []*LegacyVestingInfo `protobuf:"bytes,1,rep,name=vesting_infos,json=vestingInfos,proto3" json:"vesting_infos,omitempty"` -} - -func (m *LegacyParams) Reset() { *m = LegacyParams{} } -func (*LegacyParams) ProtoMessage() {} -func (*LegacyParams) Descriptor() ([]byte, []int) { - return fileDescriptor_47379c930fe66ed6, []int{8} -} -func (m *LegacyParams) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *LegacyParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_LegacyParams.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 *LegacyParams) XXX_Merge(src proto.Message) { - xxx_messageInfo_LegacyParams.Merge(m, src) -} -func (m *LegacyParams) XXX_Size() int { - return m.Size() -} -func (m *LegacyParams) XXX_DiscardUnknown() { - xxx_messageInfo_LegacyParams.DiscardUnknown(m) -} - -var xxx_messageInfo_LegacyParams proto.InternalMessageInfo - -func (m *LegacyParams) GetVestingInfos() []*LegacyVestingInfo { - if m != nil { - return m.VestingInfos - } - return nil -} - func init() { proto.RegisterType((*Commitments)(nil), "elys.commitment.Commitments") proto.RegisterType((*Lockup)(nil), "elys.commitment.Lockup") proto.RegisterType((*CommittedTokens)(nil), "elys.commitment.CommittedTokens") - proto.RegisterType((*RewardsUnclaimed)(nil), "elys.commitment.RewardsUnclaimed") proto.RegisterType((*VestingTokens)(nil), "elys.commitment.VestingTokens") proto.RegisterType((*LegacyCommitments)(nil), "elys.commitment.LegacyCommitments") - proto.RegisterType((*LegacyVestingTokens)(nil), "elys.commitment.LegacyVestingTokens") - proto.RegisterType((*LegacyVestingInfo)(nil), "elys.commitment.LegacyVestingInfo") - proto.RegisterType((*LegacyParams)(nil), "elys.commitment.LegacyParams") } func init() { proto.RegisterFile("elys/commitment/commitments.proto", fileDescriptor_47379c930fe66ed6) } var fileDescriptor_47379c930fe66ed6 = []byte{ - // 940 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x57, 0xcd, 0x6f, 0x1b, 0x45, - 0x14, 0xf7, 0xda, 0x8e, 0x4d, 0x5e, 0x3e, 0xec, 0x2c, 0x51, 0xeb, 0x44, 0x60, 0x07, 0x17, 0x21, - 0x73, 0xe8, 0x2e, 0x05, 0x24, 0x24, 0x6e, 0x75, 0x48, 0x51, 0xd4, 0x82, 0x60, 0x69, 0x8a, 0x84, - 0x84, 0x56, 0xb3, 0xbb, 0x63, 0x77, 0x65, 0xef, 0x8c, 0xb5, 0x33, 0x9b, 0xc4, 0xe2, 0x8e, 0x38, - 0x72, 0xe4, 0x88, 0xc4, 0x05, 0xf1, 0x67, 0x20, 0x21, 0xf5, 0x84, 0x7a, 0x44, 0x1c, 0x0a, 0x4a, - 0xfe, 0x0d, 0x0e, 0x68, 0xbe, 0xec, 0xcd, 0xa6, 0x41, 0x51, 0x3e, 0x38, 0xe5, 0x92, 0xf8, 0xfd, - 0xe6, 0xcd, 0xfb, 0xf8, 0xcd, 0xcc, 0xef, 0x69, 0xe1, 0x0d, 0x3c, 0x9e, 0x32, 0x37, 0xa4, 0x49, - 0x12, 0xf3, 0x04, 0x13, 0x9e, 0xfb, 0xc9, 0x9c, 0x49, 0x4a, 0x39, 0xb5, 0x1b, 0xc2, 0xc5, 0x99, - 0xe3, 0x9b, 0x9d, 0x21, 0xa5, 0xc3, 0x31, 0x76, 0xe5, 0x72, 0x90, 0x0d, 0x5c, 0x1e, 0x27, 0x98, - 0x71, 0x94, 0x4c, 0xd4, 0x8e, 0xcd, 0x76, 0xd1, 0x21, 0xca, 0x52, 0xc4, 0x63, 0x4a, 0xf4, 0xfa, - 0x46, 0x48, 0x59, 0x42, 0x99, 0x2f, 0x2d, 0x57, 0x19, 0x66, 0xab, 0xb2, 0xdc, 0x00, 0x31, 0xec, - 0xee, 0xdf, 0x0b, 0x30, 0x47, 0xf7, 0xdc, 0x90, 0xc6, 0x66, 0xeb, 0xfa, 0x90, 0x0e, 0xa9, 0xda, - 0x27, 0x7e, 0x69, 0xf4, 0xb5, 0x62, 0x17, 0x13, 0x94, 0xa2, 0xc4, 0xc4, 0x5c, 0x43, 0x49, 0x4c, - 0xa8, 0x2b, 0xff, 0x2a, 0xa8, 0xfb, 0x6b, 0x1d, 0x96, 0xb6, 0xe7, 0x9d, 0xda, 0x2d, 0xa8, 0x87, - 0x29, 0x46, 0x9c, 0xa6, 0x2d, 0x6b, 0xcb, 0xea, 0x2d, 0x7a, 0xc6, 0xb4, 0x1f, 0x42, 0x53, 0xc5, - 0xe5, 0x38, 0xf2, 0x39, 0x1d, 0x61, 0xc2, 0x5a, 0xe5, 0xad, 0x4a, 0x6f, 0xe9, 0xdd, 0x2d, 0xa7, - 0x40, 0x8c, 0xb3, 0x6d, 0x1c, 0x1f, 0x4b, 0x3f, 0xaf, 0x11, 0x9e, 0x04, 0xec, 0x43, 0x58, 0x4b, - 0xf1, 0x01, 0x4a, 0x23, 0xe6, 0x67, 0x24, 0x1c, 0xa3, 0x38, 0xc1, 0x51, 0xab, 0x22, 0xa3, 0x6d, - 0x38, 0x9a, 0x07, 0xd1, 0xb9, 0xa3, 0x3b, 0x77, 0xb6, 0x69, 0x4c, 0xfa, 0xef, 0x3c, 0x7b, 0xd1, - 0x29, 0xfd, 0xf2, 0x57, 0xa7, 0x37, 0x8c, 0xf9, 0xd3, 0x2c, 0x10, 0x19, 0x35, 0x69, 0xfa, 0xdf, - 0x5d, 0x16, 0x8d, 0x5c, 0x3e, 0x9d, 0x60, 0x26, 0x37, 0x30, 0xaf, 0xa9, 0xb3, 0xec, 0x99, 0x24, - 0x36, 0x86, 0xba, 0xc9, 0x57, 0xbd, 0xfa, 0x7c, 0x26, 0xb6, 0xbd, 0x03, 0xab, 0xfb, 0x98, 0xf1, - 0x98, 0x0c, 0x0d, 0x57, 0x0b, 0x32, 0x5b, 0xfb, 0x14, 0x57, 0x4f, 0x94, 0x9b, 0x66, 0x6a, 0x65, - 0x3f, 0x6f, 0xda, 0xdf, 0x5a, 0xb0, 0x61, 0x88, 0x0a, 0xa6, 0xbe, 0xd8, 0x9b, 0x23, 0xac, 0x76, - 0xf5, 0x0d, 0xdc, 0xd2, 0xd9, 0xfa, 0xd3, 0x9d, 0xf1, 0x34, 0x47, 0x5b, 0xb1, 0x90, 0x08, 0x93, - 0x5c, 0x21, 0xf5, 0x6b, 0x2d, 0x24, 0xc2, 0x64, 0x5e, 0xc8, 0x77, 0x16, 0x6c, 0x16, 0x0a, 0x09, - 0x72, 0x95, 0xbc, 0x72, 0xf5, 0x95, 0xdc, 0x3e, 0x51, 0x49, 0x70, 0x26, 0x27, 0x19, 0x8b, 0xc2, - 0x5c, 0x25, 0x8b, 0xd7, 0xc9, 0xc9, 0x1e, 0x8b, 0xc2, 0x59, 0x21, 0xdd, 0x6f, 0xa0, 0xf6, 0x88, - 0x86, 0xa3, 0x6c, 0x62, 0x3f, 0x80, 0x1a, 0x4a, 0x68, 0x46, 0xb8, 0x7a, 0xbd, 0x7d, 0x47, 0xe4, - 0xf8, 0xf3, 0x45, 0xe7, 0xad, 0x73, 0xe4, 0xd8, 0x25, 0xdc, 0xd3, 0xbb, 0xed, 0xb7, 0xa1, 0x99, - 0x91, 0x31, 0x0d, 0x47, 0xfe, 0x4c, 0xd2, 0x5a, 0xe5, 0x2d, 0xab, 0x57, 0xf5, 0x1a, 0x0a, 0x7f, - 0x6c, 0xe0, 0xee, 0xcf, 0x16, 0x34, 0x0a, 0xef, 0xdd, 0x5e, 0x87, 0x85, 0x08, 0x13, 0x9a, 0x68, - 0x0d, 0x51, 0x46, 0xae, 0xb8, 0xf2, 0xa5, 0x8a, 0xfb, 0x00, 0xea, 0x63, 0xd9, 0x2e, 0xd3, 0x92, - 0x71, 0xfb, 0xd4, 0xa3, 0x52, 0x74, 0xf4, 0xab, 0x22, 0x83, 0x67, 0xbc, 0xbb, 0x13, 0x68, 0x7a, - 0x45, 0x3d, 0xb8, 0xd6, 0x52, 0xbb, 0xbf, 0x95, 0x61, 0xe5, 0xc4, 0x03, 0x3f, 0x23, 0xdf, 0xe7, - 0xb0, 0xcc, 0x29, 0x47, 0x63, 0xff, 0x52, 0x59, 0x97, 0x64, 0x8c, 0xfb, 0x8a, 0xa5, 0x3d, 0x58, - 0xd5, 0x3d, 0x9a, 0xa0, 0x95, 0x0b, 0x05, 0x5d, 0xd1, 0x51, 0x74, 0xd8, 0xd7, 0x01, 0x48, 0x96, - 0xf8, 0x81, 0xe0, 0x54, 0x88, 0x9a, 0xd5, 0xab, 0x78, 0x8b, 0x24, 0x4b, 0xfa, 0x12, 0xb0, 0x3b, - 0xb0, 0xc4, 0x38, 0x4a, 0xb9, 0x72, 0x68, 0xd5, 0xe4, 0x3a, 0x48, 0x48, 0x7a, 0xd8, 0xef, 0xc3, - 0x2d, 0x21, 0x71, 0xbe, 0x84, 0xc4, 0x24, 0x99, 0xdd, 0xaf, 0xba, 0xf4, 0x5d, 0x17, 0xab, 0x5f, - 0xa8, 0xc5, 0xf9, 0x25, 0xfb, 0xbd, 0x0e, 0x6b, 0x8f, 0xf0, 0x10, 0x85, 0xd3, 0x9b, 0x61, 0x75, - 0xf5, 0xc3, 0xea, 0xe1, 0x19, 0xc3, 0xea, 0xcd, 0xd3, 0xef, 0x4a, 0x9e, 0xc1, 0xcd, 0xc8, 0xba, - 0x19, 0x59, 0x97, 0x1c, 0x59, 0xff, 0x94, 0xe1, 0xd5, 0x97, 0x5c, 0xa6, 0xff, 0x4f, 0x1e, 0xbf, - 0x84, 0x46, 0x46, 0xc4, 0xcd, 0xbd, 0xac, 0x3e, 0xae, 0x9a, 0x30, 0xf7, 0x67, 0xa3, 0x13, 0x4f, - 0x68, 0xf8, 0xd4, 0x8f, 0x23, 0x4c, 0x78, 0x3c, 0x88, 0x71, 0xda, 0xaa, 0xca, 0x66, 0x1a, 0x12, - 0xdf, 0x9d, 0xc1, 0x46, 0x4b, 0x25, 0x9c, 0xd7, 0xd2, 0x1d, 0x09, 0xd8, 0x77, 0x60, 0x25, 0xcc, - 0xd2, 0x14, 0x13, 0xae, 0x5c, 0xb4, 0x9a, 0x2e, 0x6b, 0x50, 0x7a, 0x5d, 0x50, 0x4f, 0x7f, 0x2a, - 0x1b, 0x3d, 0xd5, 0xf4, 0xef, 0x92, 0x01, 0x15, 0xf5, 0x88, 0x33, 0xf7, 0xf3, 0x27, 0xb0, 0x28, - 0x90, 0x8f, 0xe4, 0x29, 0xdc, 0x01, 0xf3, 0xd4, 0xb5, 0x87, 0x3c, 0x06, 0x6f, 0x59, 0x83, 0xca, - 0xe9, 0x65, 0xed, 0x57, 0xce, 0xd3, 0x7e, 0xb5, 0xd8, 0xfe, 0x13, 0x68, 0xc8, 0xce, 0x08, 0x3d, - 0xf0, 0x07, 0x28, 0x14, 0x2a, 0xbf, 0x70, 0xb1, 0x09, 0x26, 0xc2, 0x7c, 0x4a, 0x0f, 0x1e, 0xc8, - 0x20, 0x76, 0x0f, 0x9a, 0x22, 0x6d, 0x82, 0x0e, 0x7d, 0x5d, 0x39, 0xd3, 0xcc, 0xae, 0x92, 0x2c, - 0xf9, 0x04, 0x1d, 0x6a, 0x4a, 0x58, 0xf7, 0x6b, 0x58, 0x56, 0x24, 0x7d, 0x26, 0xbf, 0xa2, 0xec, - 0x8f, 0xe7, 0x04, 0xc4, 0x64, 0x40, 0x59, 0xcb, 0x92, 0x0f, 0xa6, 0xfb, 0xdf, 0x32, 0x29, 0xa8, - 0x9d, 0x91, 0x24, 0x0c, 0xf6, 0x61, 0xf5, 0x87, 0x1f, 0x3b, 0xa5, 0xfe, 0xee, 0xb3, 0xa3, 0xb6, - 0xf5, 0xfc, 0xa8, 0x6d, 0xfd, 0x7d, 0xd4, 0xb6, 0xbe, 0x3f, 0x6e, 0x97, 0x9e, 0x1f, 0xb7, 0x4b, - 0x7f, 0x1c, 0xb7, 0x4b, 0x5f, 0xb9, 0xb9, 0xce, 0x44, 0xec, 0xbb, 0x04, 0xf3, 0x03, 0x9a, 0x8e, - 0xa4, 0xe1, 0x1e, 0xe6, 0x3f, 0xf0, 0x64, 0x9b, 0x41, 0x4d, 0x7e, 0xcd, 0xbd, 0xf7, 0x6f, 0x00, - 0x00, 0x00, 0xff, 0xff, 0xea, 0x49, 0x0b, 0x4e, 0xc6, 0x0e, 0x00, 0x00, + // 701 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x95, 0x4f, 0x6f, 0xd3, 0x3e, + 0x18, 0xc7, 0x9b, 0xb6, 0x6b, 0x7f, 0x73, 0x7f, 0x5b, 0xb7, 0x68, 0xda, 0xb2, 0x09, 0xd2, 0xd2, + 0x03, 0x2a, 0x87, 0x25, 0x0c, 0x90, 0x38, 0xd3, 0x69, 0x48, 0x13, 0xbb, 0x10, 0x36, 0x0e, 0x5c, + 0x22, 0x27, 0x31, 0x21, 0x6a, 0x6c, 0x57, 0xb1, 0xb3, 0xad, 0xe2, 0x8e, 0x38, 0xf2, 0x1a, 0x38, + 0x21, 0xde, 0x07, 0xd2, 0x8e, 0x3b, 0x22, 0x0e, 0x03, 0x6d, 0x6f, 0x04, 0xc5, 0x76, 0xd6, 0x2c, + 0xd3, 0x24, 0xb4, 0xad, 0x70, 0x69, 0xf3, 0x3c, 0x7e, 0xfe, 0x7c, 0x9e, 0xaf, 0x63, 0x07, 0xdc, + 0x43, 0xf1, 0x98, 0xd9, 0x3e, 0xc5, 0x38, 0xe2, 0x18, 0x11, 0x5e, 0x78, 0x64, 0xd6, 0x28, 0xa1, + 0x9c, 0xea, 0xed, 0x2c, 0xc4, 0x9a, 0xf8, 0xd7, 0x3a, 0x21, 0xa5, 0x61, 0x8c, 0x6c, 0xb1, 0xec, + 0xa5, 0x6f, 0x6d, 0x1e, 0x61, 0xc4, 0x38, 0xc4, 0x23, 0x99, 0xb1, 0x66, 0x96, 0x03, 0x82, 0x34, + 0x81, 0x3c, 0xa2, 0x44, 0xad, 0xaf, 0xfa, 0x94, 0x61, 0xca, 0x5c, 0x61, 0xd9, 0xd2, 0xc8, 0x53, + 0xa5, 0x65, 0x7b, 0x90, 0x21, 0x7b, 0x7f, 0xc3, 0x43, 0x1c, 0x6e, 0xd8, 0x3e, 0x8d, 0xf2, 0xd4, + 0xa5, 0x90, 0x86, 0x54, 0xe6, 0x65, 0x4f, 0xca, 0x7b, 0xa7, 0x3c, 0xc5, 0x08, 0x26, 0x10, 0xe7, + 0x35, 0x17, 0x21, 0x8e, 0x08, 0xb5, 0xc5, 0xaf, 0x74, 0xf5, 0x3e, 0x57, 0x41, 0x6b, 0x73, 0x32, + 0xa9, 0x6e, 0x80, 0xa6, 0x9f, 0x20, 0xc8, 0x69, 0x62, 0x68, 0x5d, 0xad, 0x3f, 0xeb, 0xe4, 0xa6, + 0xfe, 0x02, 0x2c, 0xc8, 0xba, 0x1c, 0x05, 0x2e, 0xa7, 0x43, 0x44, 0x98, 0x51, 0xed, 0xd6, 0xfa, + 0xad, 0x47, 0x5d, 0xab, 0x24, 0x8c, 0xb5, 0x99, 0x07, 0xee, 0x8a, 0x38, 0xa7, 0xed, 0x5f, 0x74, + 0xe8, 0x08, 0x34, 0xfd, 0x18, 0x46, 0x18, 0x05, 0x46, 0x4d, 0xd4, 0x58, 0xb5, 0xd4, 0xf4, 0xd9, + 0xbc, 0x96, 0x9a, 0xd7, 0xda, 0xa4, 0x11, 0x19, 0x3c, 0x3c, 0x3a, 0xe9, 0x54, 0xbe, 0xfe, 0xec, + 0xf4, 0xc3, 0x88, 0xbf, 0x4b, 0xbd, 0xac, 0x8f, 0x92, 0x4a, 0xfd, 0xad, 0xb3, 0x60, 0x68, 0xf3, + 0xf1, 0x08, 0x31, 0x91, 0xc0, 0x9c, 0xbc, 0xb6, 0xbe, 0x05, 0xe6, 0xf7, 0x11, 0xe3, 0x11, 0x09, + 0x73, 0xe2, 0xba, 0xe8, 0x66, 0x5e, 0x22, 0x7e, 0x2d, 0xc3, 0x14, 0xef, 0xdc, 0x7e, 0xd1, 0xec, + 0xbd, 0x07, 0x8d, 0x1d, 0xea, 0x0f, 0xd3, 0x91, 0xfe, 0x1c, 0x34, 0x20, 0xa6, 0x29, 0xe1, 0x52, + 0x9d, 0x81, 0x95, 0xb1, 0xfd, 0x38, 0xe9, 0xdc, 0xff, 0x03, 0xb6, 0x6d, 0xc2, 0x1d, 0x95, 0xad, + 0x3f, 0x00, 0x0b, 0x29, 0x89, 0xa9, 0x3f, 0x74, 0xcf, 0x5f, 0x19, 0xa3, 0xda, 0xd5, 0xfa, 0x75, + 0xa7, 0x2d, 0xfd, 0xbb, 0xb9, 0xbb, 0xf7, 0x45, 0x03, 0xed, 0x92, 0x9e, 0xfa, 0x12, 0x98, 0x09, + 0x10, 0xa1, 0x58, 0xed, 0x91, 0x34, 0x0a, 0x70, 0xd5, 0x1b, 0xc1, 0x3d, 0x05, 0xcd, 0x58, 0x8c, + 0xcb, 0xd4, 0xe6, 0xac, 0x5c, 0x92, 0x4b, 0xca, 0x31, 0xa8, 0x67, 0x1d, 0x9c, 0x3c, 0xba, 0xf7, + 0xad, 0x0a, 0xe6, 0x2e, 0x08, 0x79, 0x05, 0xe8, 0x4b, 0xf0, 0x3f, 0xa7, 0x1c, 0xc6, 0xee, 0x8d, + 0x70, 0x5b, 0xa2, 0xc6, 0x33, 0xc9, 0xbc, 0x07, 0xe6, 0xd5, 0xa6, 0xe7, 0x45, 0x6b, 0xd7, 0x2a, + 0x3a, 0xa7, 0xaa, 0xa8, 0xb2, 0x77, 0x01, 0x20, 0x29, 0x76, 0xbd, 0x6c, 0x42, 0x66, 0xcc, 0x74, + 0xb5, 0x7e, 0xcd, 0x99, 0x25, 0x29, 0x1e, 0x08, 0x87, 0xde, 0x01, 0x2d, 0xc6, 0x61, 0xc2, 0x65, + 0x80, 0xd1, 0x10, 0xeb, 0x40, 0xb8, 0x44, 0x84, 0xfe, 0x04, 0x2c, 0x67, 0xaf, 0x92, 0x2b, 0x5c, + 0xd9, 0xb9, 0x39, 0xdf, 0xed, 0xa6, 0x88, 0x5d, 0xca, 0x56, 0x5f, 0xc9, 0xc5, 0xc9, 0x96, 0x1f, + 0x35, 0xc1, 0xe2, 0x0e, 0x0a, 0xa1, 0x3f, 0xfe, 0x07, 0x47, 0xf3, 0x10, 0x2c, 0x26, 0xe8, 0x00, + 0x26, 0x01, 0x73, 0x53, 0x32, 0xc5, 0x43, 0xba, 0xa0, 0xba, 0xec, 0xe5, 0x4d, 0x8a, 0x97, 0x42, + 0xfd, 0xaf, 0x5e, 0x0a, 0x33, 0xd7, 0xb8, 0x14, 0xf4, 0x0f, 0x1a, 0x58, 0xcd, 0x85, 0xf2, 0xc6, + 0x6e, 0x96, 0x5b, 0x10, 0xac, 0x71, 0xfb, 0x03, 0x2c, 0xab, 0x6e, 0x83, 0xf1, 0x56, 0x3c, 0x2e, + 0xc8, 0x56, 0x06, 0x09, 0x10, 0x29, 0x80, 0x34, 0xa7, 0x0a, 0x12, 0x20, 0x32, 0x01, 0xf9, 0xa8, + 0x81, 0xb5, 0x12, 0x88, 0x57, 0x20, 0xf9, 0xef, 0xf6, 0x49, 0x56, 0x2e, 0x90, 0x78, 0x57, 0x6a, + 0x92, 0xb2, 0xc0, 0x2f, 0x90, 0xcc, 0x4e, 0x53, 0x93, 0x3d, 0x16, 0xf8, 0xe7, 0x20, 0x83, 0xed, + 0xa3, 0x53, 0x53, 0x3b, 0x3e, 0x35, 0xb5, 0x5f, 0xa7, 0xa6, 0xf6, 0xe9, 0xcc, 0xac, 0x1c, 0x9f, + 0x99, 0x95, 0xef, 0x67, 0x66, 0xe5, 0x8d, 0x5d, 0xa8, 0x9d, 0xbd, 0x3c, 0xeb, 0x04, 0xf1, 0x03, + 0x9a, 0x0c, 0x85, 0x61, 0x1f, 0x16, 0x3f, 0xe2, 0xa2, 0x91, 0xd7, 0x10, 0x5f, 0xec, 0xc7, 0xbf, + 0x03, 0x00, 0x00, 0xff, 0xff, 0xf2, 0x35, 0xa3, 0x09, 0xaa, 0x08, 0x00, 0x00, } func (m *Commitments) Marshal() (dAtA []byte, err error) { @@ -756,24 +452,10 @@ func (m *Commitments) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.RewardsByUsdcUnclaimed) > 0 { - for iNdEx := len(m.RewardsByUsdcUnclaimed) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.RewardsByUsdcUnclaimed[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintCommitments(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x4a - } - } - if len(m.RewardsByEdenbUnclaimed) > 0 { - for iNdEx := len(m.RewardsByEdenbUnclaimed) - 1; iNdEx >= 0; iNdEx-- { + if len(m.VestingTokens) > 0 { + for iNdEx := len(m.VestingTokens) - 1; iNdEx >= 0; iNdEx-- { { - size, err := m.RewardsByEdenbUnclaimed[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + size, err := m.VestingTokens[iNdEx].MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -781,13 +463,13 @@ func (m *Commitments) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintCommitments(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x42 + dAtA[i] = 0x22 } } - if len(m.RewardsByEdenUnclaimed) > 0 { - for iNdEx := len(m.RewardsByEdenUnclaimed) - 1; iNdEx >= 0; iNdEx-- { + if len(m.Claimed) > 0 { + for iNdEx := len(m.Claimed) - 1; iNdEx >= 0; iNdEx-- { { - size, err := m.RewardsByEdenUnclaimed[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + size, err := m.Claimed[iNdEx].MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -795,13 +477,13 @@ func (m *Commitments) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintCommitments(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x3a + dAtA[i] = 0x1a } } - if len(m.RewardsByElysUnclaimed) > 0 { - for iNdEx := len(m.RewardsByElysUnclaimed) - 1; iNdEx >= 0; iNdEx-- { + if len(m.CommittedTokens) > 0 { + for iNdEx := len(m.CommittedTokens) - 1; iNdEx >= 0; iNdEx-- { { - size, err := m.RewardsByElysUnclaimed[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + size, err := m.CommittedTokens[iNdEx].MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -809,71 +491,15 @@ func (m *Commitments) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintCommitments(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x32 + dAtA[i] = 0x12 } } - if len(m.VestingTokens) > 0 { - for iNdEx := len(m.VestingTokens) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.VestingTokens[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintCommitments(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x2a - } - } - if len(m.Claimed) > 0 { - for iNdEx := len(m.Claimed) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Claimed[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintCommitments(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - } - } - if len(m.RewardsUnclaimed) > 0 { - for iNdEx := len(m.RewardsUnclaimed) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.RewardsUnclaimed[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintCommitments(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - } - } - if len(m.CommittedTokens) > 0 { - for iNdEx := len(m.CommittedTokens) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.CommittedTokens[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintCommitments(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - } - if len(m.Creator) > 0 { - i -= len(m.Creator) - copy(dAtA[i:], m.Creator) - i = encodeVarintCommitments(dAtA, i, uint64(len(m.Creator))) - i-- - dAtA[i] = 0xa + if len(m.Creator) > 0 { + i -= len(m.Creator) + copy(dAtA[i:], m.Creator) + i = encodeVarintCommitments(dAtA, i, uint64(len(m.Creator))) + i-- + dAtA[i] = 0xa } return len(dAtA) - i, nil } @@ -970,46 +596,6 @@ func (m *CommittedTokens) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *RewardsUnclaimed) 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 *RewardsUnclaimed) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *RewardsUnclaimed) 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 = encodeVarintCommitments(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - if len(m.Denom) > 0 { - i -= len(m.Denom) - copy(dAtA[i:], m.Denom) - i = encodeVarintCommitments(dAtA, i, uint64(len(m.Denom))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - func (m *VestingTokens) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1217,179 +803,6 @@ func (m *LegacyCommitments) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *LegacyVestingTokens) 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 *LegacyVestingTokens) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *LegacyVestingTokens) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.VestStartedTimestamp != 0 { - i = encodeVarintCommitments(dAtA, i, uint64(m.VestStartedTimestamp)) - i-- - dAtA[i] = 0x38 - } - if m.CurrentEpoch != 0 { - i = encodeVarintCommitments(dAtA, i, uint64(m.CurrentEpoch)) - i-- - dAtA[i] = 0x30 - } - if m.NumEpochs != 0 { - i = encodeVarintCommitments(dAtA, i, uint64(m.NumEpochs)) - i-- - dAtA[i] = 0x28 - } - if len(m.EpochIdentifier) > 0 { - i -= len(m.EpochIdentifier) - copy(dAtA[i:], m.EpochIdentifier) - i = encodeVarintCommitments(dAtA, i, uint64(len(m.EpochIdentifier))) - i-- - dAtA[i] = 0x22 - } - { - size := m.UnvestedAmount.Size() - i -= size - if _, err := m.UnvestedAmount.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintCommitments(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - { - size := m.TotalAmount.Size() - i -= size - if _, err := m.TotalAmount.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintCommitments(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - if len(m.Denom) > 0 { - i -= len(m.Denom) - copy(dAtA[i:], m.Denom) - i = encodeVarintCommitments(dAtA, i, uint64(len(m.Denom))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *LegacyVestingInfo) 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 *LegacyVestingInfo) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *LegacyVestingInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.NumMaxVestings != 0 { - i = encodeVarintCommitments(dAtA, i, uint64(m.NumMaxVestings)) - i-- - dAtA[i] = 0x30 - } - { - size := m.VestNowFactor.Size() - i -= size - if _, err := m.VestNowFactor.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintCommitments(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x2a - if m.NumEpochs != 0 { - i = encodeVarintCommitments(dAtA, i, uint64(m.NumEpochs)) - i-- - dAtA[i] = 0x20 - } - if len(m.EpochIdentifier) > 0 { - i -= len(m.EpochIdentifier) - copy(dAtA[i:], m.EpochIdentifier) - i = encodeVarintCommitments(dAtA, i, uint64(len(m.EpochIdentifier))) - i-- - dAtA[i] = 0x1a - } - if len(m.VestingDenom) > 0 { - i -= len(m.VestingDenom) - copy(dAtA[i:], m.VestingDenom) - i = encodeVarintCommitments(dAtA, i, uint64(len(m.VestingDenom))) - i-- - dAtA[i] = 0x12 - } - if len(m.BaseDenom) > 0 { - i -= len(m.BaseDenom) - copy(dAtA[i:], m.BaseDenom) - i = encodeVarintCommitments(dAtA, i, uint64(len(m.BaseDenom))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *LegacyParams) 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 *LegacyParams) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *LegacyParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.VestingInfos) > 0 { - for iNdEx := len(m.VestingInfos) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.VestingInfos[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintCommitments(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - func encodeVarintCommitments(dAtA []byte, offset int, v uint64) int { offset -= sovCommitments(v) base := offset @@ -1417,12 +830,6 @@ func (m *Commitments) Size() (n int) { n += 1 + l + sovCommitments(uint64(l)) } } - if len(m.RewardsUnclaimed) > 0 { - for _, e := range m.RewardsUnclaimed { - l = e.Size() - n += 1 + l + sovCommitments(uint64(l)) - } - } if len(m.Claimed) > 0 { for _, e := range m.Claimed { l = e.Size() @@ -1435,30 +842,6 @@ func (m *Commitments) Size() (n int) { n += 1 + l + sovCommitments(uint64(l)) } } - if len(m.RewardsByElysUnclaimed) > 0 { - for _, e := range m.RewardsByElysUnclaimed { - l = e.Size() - n += 1 + l + sovCommitments(uint64(l)) - } - } - if len(m.RewardsByEdenUnclaimed) > 0 { - for _, e := range m.RewardsByEdenUnclaimed { - l = e.Size() - n += 1 + l + sovCommitments(uint64(l)) - } - } - if len(m.RewardsByEdenbUnclaimed) > 0 { - for _, e := range m.RewardsByEdenbUnclaimed { - l = e.Size() - n += 1 + l + sovCommitments(uint64(l)) - } - } - if len(m.RewardsByUsdcUnclaimed) > 0 { - for _, e := range m.RewardsByUsdcUnclaimed { - l = e.Size() - n += 1 + l + sovCommitments(uint64(l)) - } - } return n } @@ -1497,21 +880,6 @@ func (m *CommittedTokens) Size() (n int) { return n } -func (m *RewardsUnclaimed) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Denom) - if l > 0 { - n += 1 + l + sovCommitments(uint64(l)) - } - l = m.Amount.Size() - n += 1 + l + sovCommitments(uint64(l)) - return n -} - func (m *VestingTokens) Size() (n int) { if m == nil { return 0 @@ -1599,80 +967,6 @@ func (m *LegacyCommitments) Size() (n int) { return n } -func (m *LegacyVestingTokens) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Denom) - if l > 0 { - n += 1 + l + sovCommitments(uint64(l)) - } - l = m.TotalAmount.Size() - n += 1 + l + sovCommitments(uint64(l)) - l = m.UnvestedAmount.Size() - n += 1 + l + sovCommitments(uint64(l)) - l = len(m.EpochIdentifier) - if l > 0 { - n += 1 + l + sovCommitments(uint64(l)) - } - if m.NumEpochs != 0 { - n += 1 + sovCommitments(uint64(m.NumEpochs)) - } - if m.CurrentEpoch != 0 { - n += 1 + sovCommitments(uint64(m.CurrentEpoch)) - } - if m.VestStartedTimestamp != 0 { - n += 1 + sovCommitments(uint64(m.VestStartedTimestamp)) - } - return n -} - -func (m *LegacyVestingInfo) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.BaseDenom) - if l > 0 { - n += 1 + l + sovCommitments(uint64(l)) - } - l = len(m.VestingDenom) - if l > 0 { - n += 1 + l + sovCommitments(uint64(l)) - } - l = len(m.EpochIdentifier) - if l > 0 { - n += 1 + l + sovCommitments(uint64(l)) - } - if m.NumEpochs != 0 { - n += 1 + sovCommitments(uint64(m.NumEpochs)) - } - l = m.VestNowFactor.Size() - n += 1 + l + sovCommitments(uint64(l)) - if m.NumMaxVestings != 0 { - n += 1 + sovCommitments(uint64(m.NumMaxVestings)) - } - return n -} - -func (m *LegacyParams) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.VestingInfos) > 0 { - for _, e := range m.VestingInfos { - l = e.Size() - n += 1 + l + sovCommitments(uint64(l)) - } - } - return n -} - func sovCommitments(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -1775,40 +1069,6 @@ func (m *Commitments) Unmarshal(dAtA []byte) error { } iNdEx = postIndex case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RewardsUnclaimed", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommitments - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthCommitments - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthCommitments - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.RewardsUnclaimed = append(m.RewardsUnclaimed, types.Coin{}) - if err := m.RewardsUnclaimed[len(m.RewardsUnclaimed)-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 Claimed", wireType) } @@ -1842,7 +1102,7 @@ func (m *Commitments) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 5: + case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field VestingTokens", wireType) } @@ -1876,142 +1136,6 @@ func (m *Commitments) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RewardsByElysUnclaimed", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommitments - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthCommitments - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthCommitments - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.RewardsByElysUnclaimed = append(m.RewardsByElysUnclaimed, types.Coin{}) - if err := m.RewardsByElysUnclaimed[len(m.RewardsByElysUnclaimed)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 7: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RewardsByEdenUnclaimed", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommitments - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthCommitments - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthCommitments - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.RewardsByEdenUnclaimed = append(m.RewardsByEdenUnclaimed, types.Coin{}) - if err := m.RewardsByEdenUnclaimed[len(m.RewardsByEdenUnclaimed)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 8: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RewardsByEdenbUnclaimed", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommitments - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthCommitments - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthCommitments - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.RewardsByEdenbUnclaimed = append(m.RewardsByEdenbUnclaimed, types.Coin{}) - if err := m.RewardsByEdenbUnclaimed[len(m.RewardsByEdenbUnclaimed)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 9: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RewardsByUsdcUnclaimed", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommitments - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthCommitments - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthCommitments - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.RewardsByUsdcUnclaimed = append(m.RewardsByUsdcUnclaimed, types.Coin{}) - if err := m.RewardsByUsdcUnclaimed[len(m.RewardsByUsdcUnclaimed)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipCommitments(dAtA[iNdEx:]) @@ -2188,697 +1312,20 @@ func (m *CommittedTokens) Unmarshal(dAtA []byte) error { if intStringLen < 0 { return ErrInvalidLengthCommitments } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthCommitments - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Denom = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - 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 ErrIntOverflowCommitments - } - 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 ErrInvalidLengthCommitments - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthCommitments - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Amount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Lockups", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommitments - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthCommitments - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthCommitments - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Lockups = append(m.Lockups, Lockup{}) - if err := m.Lockups[len(m.Lockups)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipCommitments(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthCommitments - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *RewardsUnclaimed) 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 ErrIntOverflowCommitments - } - 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: RewardsUnclaimed: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: RewardsUnclaimed: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Denom", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommitments - } - 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 ErrInvalidLengthCommitments - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthCommitments - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Denom = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - 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 ErrIntOverflowCommitments - } - 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 ErrInvalidLengthCommitments - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthCommitments - } - 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 := skipCommitments(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthCommitments - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *VestingTokens) 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 ErrIntOverflowCommitments - } - 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: VestingTokens: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: VestingTokens: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Denom", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommitments - } - 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 ErrInvalidLengthCommitments - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthCommitments - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Denom = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TotalAmount", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommitments - } - 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 ErrInvalidLengthCommitments - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthCommitments - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.TotalAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ClaimedAmount", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommitments - } - 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 ErrInvalidLengthCommitments - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthCommitments - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.ClaimedAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 5: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field NumBlocks", wireType) - } - m.NumBlocks = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommitments - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.NumBlocks |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 6: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field StartBlock", wireType) - } - m.StartBlock = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommitments - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.StartBlock |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 7: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field VestStartedTimestamp", wireType) - } - m.VestStartedTimestamp = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommitments - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.VestStartedTimestamp |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipCommitments(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthCommitments - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *LegacyCommitments) 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 ErrIntOverflowCommitments - } - 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: LegacyCommitments: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: LegacyCommitments: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommitments - } - 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 ErrInvalidLengthCommitments - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthCommitments - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Creator = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CommittedTokens", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommitments - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthCommitments - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthCommitments - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.CommittedTokens = append(m.CommittedTokens, &CommittedTokens{}) - if err := m.CommittedTokens[len(m.CommittedTokens)-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 RewardsUnclaimed", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommitments - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthCommitments - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthCommitments - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.RewardsUnclaimed = append(m.RewardsUnclaimed, types.Coin{}) - if err := m.RewardsUnclaimed[len(m.RewardsUnclaimed)-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 Claimed", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommitments - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthCommitments - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthCommitments - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Claimed = append(m.Claimed, types.Coin{}) - if err := m.Claimed[len(m.Claimed)-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 VestingTokens", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommitments - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthCommitments - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthCommitments - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.VestingTokens = append(m.VestingTokens, &LegacyVestingTokens{}) - if err := m.VestingTokens[len(m.VestingTokens)-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 RewardsByElysUnclaimed", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommitments - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthCommitments - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthCommitments - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.RewardsByElysUnclaimed = append(m.RewardsByElysUnclaimed, types.Coin{}) - if err := m.RewardsByElysUnclaimed[len(m.RewardsByElysUnclaimed)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 7: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RewardsByEdenUnclaimed", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommitments - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthCommitments - } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthCommitments } if postIndex > l { return io.ErrUnexpectedEOF } - m.RewardsByEdenUnclaimed = append(m.RewardsByEdenUnclaimed, types.Coin{}) - if err := m.RewardsByEdenUnclaimed[len(m.RewardsByEdenUnclaimed)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.Denom = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 8: + case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RewardsByEdenbUnclaimed", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowCommitments @@ -2888,29 +1335,29 @@ func (m *LegacyCommitments) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthCommitments } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthCommitments } if postIndex > l { return io.ErrUnexpectedEOF } - m.RewardsByEdenbUnclaimed = append(m.RewardsByEdenbUnclaimed, types.Coin{}) - if err := m.RewardsByEdenbUnclaimed[len(m.RewardsByEdenbUnclaimed)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.Amount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex - case 9: + case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RewardsByUsdcUnclaimed", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Lockups", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -2937,8 +1384,8 @@ func (m *LegacyCommitments) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.RewardsByUsdcUnclaimed = append(m.RewardsByUsdcUnclaimed, types.Coin{}) - if err := m.RewardsByUsdcUnclaimed[len(m.RewardsByUsdcUnclaimed)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.Lockups = append(m.Lockups, Lockup{}) + if err := m.Lockups[len(m.Lockups)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -2963,7 +1410,7 @@ func (m *LegacyCommitments) Unmarshal(dAtA []byte) error { } return nil } -func (m *LegacyVestingTokens) Unmarshal(dAtA []byte) error { +func (m *VestingTokens) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2986,10 +1433,10 @@ func (m *LegacyVestingTokens) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: LegacyVestingTokens: wiretype end group for non-group") + return fmt.Errorf("proto: VestingTokens: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: LegacyVestingTokens: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: VestingTokens: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -3060,7 +1507,7 @@ func (m *LegacyVestingTokens) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field UnvestedAmount", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ClaimedAmount", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -3088,47 +1535,15 @@ func (m *LegacyVestingTokens) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.UnvestedAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.ClaimedAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field EpochIdentifier", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommitments - } - 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 ErrInvalidLengthCommitments - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthCommitments - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.EpochIdentifier = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex case 5: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field NumEpochs", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field NumBlocks", wireType) } - m.NumEpochs = 0 + m.NumBlocks = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowCommitments @@ -3138,16 +1553,16 @@ func (m *LegacyVestingTokens) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.NumEpochs |= int64(b&0x7F) << shift + m.NumBlocks |= int64(b&0x7F) << shift if b < 0x80 { break } } case 6: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field CurrentEpoch", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field StartBlock", wireType) } - m.CurrentEpoch = 0 + m.StartBlock = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowCommitments @@ -3157,7 +1572,7 @@ func (m *LegacyVestingTokens) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.CurrentEpoch |= int64(b&0x7F) << shift + m.StartBlock |= int64(b&0x7F) << shift if b < 0x80 { break } @@ -3202,7 +1617,7 @@ func (m *LegacyVestingTokens) Unmarshal(dAtA []byte) error { } return nil } -func (m *LegacyVestingInfo) Unmarshal(dAtA []byte) error { +func (m *LegacyCommitments) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3225,15 +1640,15 @@ func (m *LegacyVestingInfo) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: LegacyVestingInfo: wiretype end group for non-group") + return fmt.Errorf("proto: LegacyCommitments: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: LegacyVestingInfo: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: LegacyCommitments: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field BaseDenom", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -3261,13 +1676,13 @@ func (m *LegacyVestingInfo) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.BaseDenom = string(dAtA[iNdEx:postIndex]) + m.Creator = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field VestingDenom", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field CommittedTokens", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowCommitments @@ -3277,29 +1692,31 @@ func (m *LegacyVestingInfo) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if msglen < 0 { return ErrInvalidLengthCommitments } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthCommitments } if postIndex > l { return io.ErrUnexpectedEOF } - m.VestingDenom = string(dAtA[iNdEx:postIndex]) + m.CommittedTokens = append(m.CommittedTokens, &CommittedTokens{}) + if err := m.CommittedTokens[len(m.CommittedTokens)-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 EpochIdentifier", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field RewardsUnclaimed", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowCommitments @@ -3309,29 +1726,31 @@ func (m *LegacyVestingInfo) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if msglen < 0 { return ErrInvalidLengthCommitments } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthCommitments } if postIndex > l { return io.ErrUnexpectedEOF } - m.EpochIdentifier = string(dAtA[iNdEx:postIndex]) + m.RewardsUnclaimed = append(m.RewardsUnclaimed, types.Coin{}) + if err := m.RewardsUnclaimed[len(m.RewardsUnclaimed)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field NumEpochs", wireType) + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Claimed", wireType) } - m.NumEpochs = 0 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowCommitments @@ -3341,16 +1760,31 @@ func (m *LegacyVestingInfo) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.NumEpochs |= int64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } + if msglen < 0 { + return ErrInvalidLengthCommitments + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthCommitments + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Claimed = append(m.Claimed, types.Coin{}) + if err := m.Claimed[len(m.Claimed)-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 VestNowFactor", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field VestingTokens", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowCommitments @@ -3360,31 +1794,31 @@ func (m *LegacyVestingInfo) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if msglen < 0 { return ErrInvalidLengthCommitments } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthCommitments } if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.VestNowFactor.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.VestingTokens = append(m.VestingTokens, &VestingTokens{}) + if err := m.VestingTokens[len(m.VestingTokens)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex case 6: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field NumMaxVestings", wireType) + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RewardsByElysUnclaimed", wireType) } - m.NumMaxVestings = 0 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowCommitments @@ -3394,64 +1828,97 @@ func (m *LegacyVestingInfo) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.NumMaxVestings |= int64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - default: - iNdEx = preIndex - skippy, err := skipCommitments(dAtA[iNdEx:]) - if err != nil { + if msglen < 0 { + return ErrInvalidLengthCommitments + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthCommitments + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RewardsByElysUnclaimed = append(m.RewardsByElysUnclaimed, types.Coin{}) + if err := m.RewardsByElysUnclaimed[len(m.RewardsByElysUnclaimed)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } - if (skippy < 0) || (iNdEx+skippy) < 0 { + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RewardsByEdenUnclaimed", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCommitments + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { return ErrInvalidLengthCommitments } - if (iNdEx + skippy) > l { + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthCommitments + } + if postIndex > l { return io.ErrUnexpectedEOF } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *LegacyParams) 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 ErrIntOverflowCommitments + m.RewardsByEdenUnclaimed = append(m.RewardsByEdenUnclaimed, types.Coin{}) + if err := m.RewardsByEdenUnclaimed[len(m.RewardsByEdenUnclaimed)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err } - if iNdEx >= l { + iNdEx = postIndex + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RewardsByEdenbUnclaimed", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCommitments + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthCommitments + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthCommitments + } + if postIndex > l { return io.ErrUnexpectedEOF } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break + m.RewardsByEdenbUnclaimed = append(m.RewardsByEdenbUnclaimed, types.Coin{}) + if err := m.RewardsByEdenbUnclaimed[len(m.RewardsByEdenbUnclaimed)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: LegacyParams: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: LegacyParams: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: + iNdEx = postIndex + case 9: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field VestingInfos", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field RewardsByUsdcUnclaimed", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -3478,8 +1945,8 @@ func (m *LegacyParams) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.VestingInfos = append(m.VestingInfos, &LegacyVestingInfo{}) - if err := m.VestingInfos[len(m.VestingInfos)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.RewardsByUsdcUnclaimed = append(m.RewardsByUsdcUnclaimed, types.Coin{}) + if err := m.RewardsByUsdcUnclaimed[len(m.RewardsByUsdcUnclaimed)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex diff --git a/x/commitment/types/commitments_test.go b/x/commitment/types/commitments_test.go index 06022bb68..bd4136f1a 100644 --- a/x/commitment/types/commitments_test.go +++ b/x/commitment/types/commitments_test.go @@ -10,10 +10,9 @@ import ( func TestCommitments_AddCommittedTokens(t *testing.T) { commitments := types.Commitments{ - Creator: "", - CommittedTokens: []*types.CommittedTokens{}, - RewardsUnclaimed: sdk.Coins{}, - VestingTokens: []*types.VestingTokens{}, + Creator: "", + CommittedTokens: []*types.CommittedTokens{}, + VestingTokens: []*types.VestingTokens{}, } commitments.AddCommittedTokens("lp/1", sdk.NewInt(100), 100) @@ -30,10 +29,9 @@ func TestCommitments_AddCommittedTokens(t *testing.T) { func TestCommitments_WithdrawCommitedTokens(t *testing.T) { commitments := types.Commitments{ - Creator: "", - CommittedTokens: []*types.CommittedTokens{}, - RewardsUnclaimed: sdk.Coins{}, - VestingTokens: []*types.VestingTokens{}, + Creator: "", + CommittedTokens: []*types.CommittedTokens{}, + VestingTokens: []*types.VestingTokens{}, } commitments.AddCommittedTokens("lp/1", sdk.NewInt(100), 100) diff --git a/x/commitment/types/expected_keepers.go b/x/commitment/types/expected_keepers.go index 56dbc04cd..918fe2b6b 100644 --- a/x/commitment/types/expected_keepers.go +++ b/x/commitment/types/expected_keepers.go @@ -14,10 +14,15 @@ type AccountKeeper interface { // BankKeeper defines the expected interface needed to retrieve account balances. type BankKeeper interface { - 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 + GetAllBalances(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins + SpendableCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins + BlockedAddr(addr sdk.AccAddress) bool + MintCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) error BurnCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) error + SendCoinsFromModuleToModule(ctx sdk.Context, senderModule string, recipientModule 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 // Methods imported from bank should be defined here } diff --git a/x/commitment/types/interfaces.go b/x/commitment/types/interfaces.go index f19971a30..b91e6438a 100644 --- a/x/commitment/types/interfaces.go +++ b/x/commitment/types/interfaces.go @@ -4,9 +4,11 @@ import sdk "github.com/cosmos/cosmos-sdk/types" // CommitmentHooks event hooks for commitment processing type CommitmentHooks interface { - // Token commitment changed - CommitmentChanged(ctx sdk.Context, creator string, amount sdk.Coins) - - // Eden uncommitted - EdenUncommitted(ctx sdk.Context, creator string, amount sdk.Coin) + CommitmentChanged(ctx sdk.Context, creator string, amount sdk.Coins) error + EdenUncommitted(ctx sdk.Context, creator string, amount sdk.Coin) error + // Hooks for estaking specific + BeforeEdenInitialCommit(ctx sdk.Context, addr sdk.AccAddress) error + BeforeEdenBInitialCommit(ctx sdk.Context, addr sdk.AccAddress) error + BeforeEdenCommitChange(ctx sdk.Context, addr sdk.AccAddress) error + BeforeEdenBCommitChange(ctx sdk.Context, addr sdk.AccAddress) error } diff --git a/x/commitment/types/params.go b/x/commitment/types/params.go index 7d22e6a34..e29a6c12b 100644 --- a/x/commitment/types/params.go +++ b/x/commitment/types/params.go @@ -1,29 +1,10 @@ package types import ( - fmt "fmt" - sdk "github.com/cosmos/cosmos-sdk/types" - paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" "gopkg.in/yaml.v2" ) -var _ paramtypes.ParamSet = (*LegacyParams)(nil) - -var KeyVestingInfos = []byte("VestingInfos") - -// ParamKeyTable the param key table for launch module -func ParamKeyTable() paramtypes.KeyTable { - return paramtypes.NewKeyTable().RegisterParamSet(&LegacyParams{}) -} - -// NewLegacyParams creates a new LegacyParams instance -func NewLegacyParams(vestingInfos []*LegacyVestingInfo) LegacyParams { - return LegacyParams{ - VestingInfos: vestingInfos, - } -} - // DefaultParams returns a default set of parameters func DefaultParams() Params { return Params{ @@ -32,24 +13,6 @@ func DefaultParams() Params { } } -// ParamSetPairs get the params.ParamSet -func (p *LegacyParams) ParamSetPairs() paramtypes.ParamSetPairs { - return paramtypes.ParamSetPairs{ - paramtypes.NewParamSetPair(KeyVestingInfos, &p.VestingInfos, validateVestingInfos), - } -} - -// Validate validates the set of params -func (p LegacyParams) Validate() error { - return nil -} - -// String implements the Stringer interface. -func (p LegacyParams) String() string { - out, _ := yaml.Marshal(p) - return string(out) -} - // Validate validates the set of params func (p Params) Validate() error { return nil @@ -60,39 +23,3 @@ func (p Params) String() string { out, _ := yaml.Marshal(p) return string(out) } - -// Add validators for the new parameters -func validateVestingInfos(i interface{}) error { - vestingInfos, ok := i.([]*VestingInfo) - if !ok { - return fmt.Errorf("invalid parameter type: %T", i) - } - - for _, vestingInfo := range vestingInfos { - if err := validateVestingInfo(vestingInfo); err != nil { - return err - } - } - - return nil -} - -func validateVestingInfo(info *VestingInfo) error { - if info.BaseDenom == "" { - return fmt.Errorf("base_denom cannot be empty") - } - - if info.VestingDenom == "" { - return fmt.Errorf("vesting_denom cannot be empty") - } - - if info.NumBlocks <= 0 { - return fmt.Errorf("num_blocks must be greater than zero") - } - - if info.NumMaxVestings < 0 { - return fmt.Errorf("num_max_vestings cannot be negative") - } - - return nil -} diff --git a/x/commitment/types/types_cw.pb.go b/x/commitment/types/types_cw.pb.go index c31367078..4fc9136f6 100644 --- a/x/commitment/types/types_cw.pb.go +++ b/x/commitment/types/types_cw.pb.go @@ -1052,66 +1052,6 @@ func (m *QueryUnstakedPositionResponse) GetUnstakedPosition() []UnstakedPosition return nil } -type QuerySubBucketBalanceRequest struct { - Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` - Denom string `protobuf:"bytes,2,opt,name=denom,proto3" json:"denom,omitempty"` - Program EarnType `protobuf:"varint,3,opt,name=program,proto3,enum=elys.commitment.EarnType" json:"program,omitempty"` -} - -func (m *QuerySubBucketBalanceRequest) Reset() { *m = QuerySubBucketBalanceRequest{} } -func (m *QuerySubBucketBalanceRequest) String() string { return proto.CompactTextString(m) } -func (*QuerySubBucketBalanceRequest) ProtoMessage() {} -func (*QuerySubBucketBalanceRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_f36c2a6a76250be7, []int{19} -} -func (m *QuerySubBucketBalanceRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QuerySubBucketBalanceRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QuerySubBucketBalanceRequest.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 *QuerySubBucketBalanceRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QuerySubBucketBalanceRequest.Merge(m, src) -} -func (m *QuerySubBucketBalanceRequest) XXX_Size() int { - return m.Size() -} -func (m *QuerySubBucketBalanceRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QuerySubBucketBalanceRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_QuerySubBucketBalanceRequest proto.InternalMessageInfo - -func (m *QuerySubBucketBalanceRequest) GetAddress() string { - if m != nil { - return m.Address - } - return "" -} - -func (m *QuerySubBucketBalanceRequest) GetDenom() string { - if m != nil { - return m.Denom - } - return "" -} - -func (m *QuerySubBucketBalanceRequest) GetProgram() EarnType { - if m != nil { - return m.Program - } - return EarnType_ALL_PROGRAM -} - type QueryVestingInfoRequest struct { Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` } @@ -1120,7 +1060,7 @@ func (m *QueryVestingInfoRequest) Reset() { *m = QueryVestingInfoRequest func (m *QueryVestingInfoRequest) String() string { return proto.CompactTextString(m) } func (*QueryVestingInfoRequest) ProtoMessage() {} func (*QueryVestingInfoRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_f36c2a6a76250be7, []int{20} + return fileDescriptor_f36c2a6a76250be7, []int{19} } func (m *QueryVestingInfoRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1172,7 +1112,7 @@ func (m *VestingDetail) Reset() { *m = VestingDetail{} } func (m *VestingDetail) String() string { return proto.CompactTextString(m) } func (*VestingDetail) ProtoMessage() {} func (*VestingDetail) Descriptor() ([]byte, []int) { - return fileDescriptor_f36c2a6a76250be7, []int{21} + return fileDescriptor_f36c2a6a76250be7, []int{20} } func (m *VestingDetail) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1245,7 +1185,7 @@ func (m *QueryVestingInfoResponse) Reset() { *m = QueryVestingInfoRespon func (m *QueryVestingInfoResponse) String() string { return proto.CompactTextString(m) } func (*QueryVestingInfoResponse) ProtoMessage() {} func (*QueryVestingInfoResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_f36c2a6a76250be7, []int{22} + return fileDescriptor_f36c2a6a76250be7, []int{21} } func (m *QueryVestingInfoResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1308,7 +1248,6 @@ func init() { proto.RegisterType((*QueryStakedPositionResponse)(nil), "elys.commitment.QueryStakedPositionResponse") proto.RegisterType((*UnstakedPosition)(nil), "elys.commitment.UnstakedPosition") proto.RegisterType((*QueryUnstakedPositionResponse)(nil), "elys.commitment.QueryUnstakedPositionResponse") - proto.RegisterType((*QuerySubBucketBalanceRequest)(nil), "elys.commitment.QuerySubBucketBalanceRequest") proto.RegisterType((*QueryVestingInfoRequest)(nil), "elys.commitment.QueryVestingInfoRequest") proto.RegisterType((*VestingDetail)(nil), "elys.commitment.VestingDetail") proto.RegisterType((*QueryVestingInfoResponse)(nil), "elys.commitment.QueryVestingInfoResponse") @@ -1317,86 +1256,82 @@ func init() { func init() { proto.RegisterFile("elys/commitment/types_cw.proto", fileDescriptor_f36c2a6a76250be7) } var fileDescriptor_f36c2a6a76250be7 = []byte{ - // 1250 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe4, 0x58, 0xcd, 0x6f, 0x1b, 0x45, - 0x14, 0xcf, 0xda, 0x69, 0x4c, 0x9e, 0x1b, 0xdb, 0x9d, 0x46, 0xd4, 0xfd, 0xc0, 0x4d, 0x96, 0xaf, - 0xb6, 0x52, 0x6c, 0x35, 0x3d, 0x70, 0x41, 0x48, 0x31, 0x49, 0xd4, 0x00, 0xaa, 0xd2, 0x4d, 0x5a, - 0x89, 0x0f, 0x69, 0x19, 0x7b, 0xa7, 0xce, 0x28, 0xbb, 0x33, 0x66, 0x67, 0xd6, 0x21, 0x5c, 0x91, - 0x38, 0x02, 0x7f, 0x00, 0x7f, 0x00, 0x47, 0x84, 0x2a, 0xf8, 0x0b, 0x90, 0x7a, 0x42, 0x55, 0xc5, - 0x01, 0x71, 0x28, 0x28, 0x39, 0x70, 0x45, 0xe2, 0x8c, 0x84, 0x76, 0x76, 0xf6, 0xc3, 0xeb, 0x24, - 0x4d, 0x53, 0x0b, 0x81, 0xb8, 0x24, 0xbb, 0xf3, 0xe6, 0xfd, 0xde, 0x7b, 0xbf, 0xf7, 0x31, 0xb3, - 0x86, 0x06, 0x71, 0x77, 0x45, 0xab, 0xcb, 0x3d, 0x8f, 0x4a, 0x8f, 0x30, 0xd9, 0x92, 0xbb, 0x7d, - 0x22, 0xec, 0xee, 0x4e, 0xb3, 0xef, 0x73, 0xc9, 0x51, 0x35, 0x94, 0x37, 0x53, 0xf9, 0x85, 0xd9, - 0x1e, 0xef, 0x71, 0x25, 0x6b, 0x85, 0x4f, 0xd1, 0xb6, 0x0b, 0xe7, 0xbb, 0x5c, 0x78, 0x5c, 0xd8, - 0x91, 0x20, 0x7a, 0xd1, 0xa2, 0x46, 0xf4, 0xd6, 0xea, 0x60, 0x41, 0x5a, 0x83, 0xeb, 0x1d, 0x22, - 0xf1, 0xf5, 0x56, 0x97, 0x53, 0xa6, 0xe5, 0x67, 0xb0, 0x47, 0x19, 0x6f, 0xa9, 0xbf, 0x7a, 0xe9, - 0x52, 0xde, 0xa9, 0x3e, 0xf6, 0xb1, 0x17, 0x03, 0xce, 0xe7, 0xa5, 0xe9, 0xa3, 0xde, 0x62, 0xde, - 0x82, 0xfa, 0xed, 0x80, 0xf8, 0xbb, 0x6d, 0xee, 0xfb, 0x7c, 0x67, 0xc9, 0xe3, 0x01, 0x93, 0x16, - 0xf9, 0x28, 0x20, 0x42, 0xa2, 0x45, 0x28, 0x61, 0xc7, 0xf1, 0x89, 0x10, 0x75, 0x63, 0xce, 0xb8, - 0x32, 0xdd, 0xae, 0x3f, 0xba, 0xbf, 0x30, 0xab, 0x5d, 0x5e, 0x8a, 0x24, 0x1b, 0xd2, 0xa7, 0xac, - 0x67, 0xc5, 0x1b, 0x4d, 0x0a, 0x73, 0x0a, 0x6f, 0x99, 0xb8, 0xa4, 0x87, 0x25, 0xf7, 0xf5, 0x03, - 0xe5, 0x4c, 0xc4, 0xb8, 0x2b, 0x70, 0xc6, 0x89, 0xc5, 0xf6, 0x71, 0x2d, 0xd4, 0x12, 0x15, 0xbd, - 0x6e, 0xfe, 0x61, 0x00, 0xa4, 0xe8, 0x63, 0x42, 0x0d, 0x61, 0x06, 0xd8, 0xa5, 0xce, 0x10, 0x4c, - 0xe1, 0x49, 0x30, 0x89, 0x4a, 0x0c, 0xb3, 0x09, 0x53, 0x62, 0x0b, 0xfb, 0x44, 0xd4, 0x8b, 0x4a, - 0xf7, 0xf5, 0x07, 0x8f, 0x2f, 0x4f, 0xfc, 0xf2, 0xf8, 0xf2, 0x2b, 0x3d, 0x2a, 0xb7, 0x82, 0x4e, - 0x58, 0x27, 0x3a, 0xf9, 0xfa, 0xdf, 0x82, 0x70, 0xb6, 0xa3, 0x92, 0x6a, 0x2e, 0x93, 0xee, 0xa3, - 0xfb, 0x0b, 0xa0, 0x2d, 0x2d, 0x93, 0xae, 0xa5, 0xb1, 0xcc, 0xaf, 0x0c, 0x40, 0x69, 0xc8, 0x16, - 0x11, 0x7d, 0xce, 0x04, 0x41, 0xab, 0x00, 0x4e, 0xb2, 0xaa, 0x62, 0x2e, 0x2f, 0x5e, 0x6c, 0xe6, - 0xea, 0xb1, 0x99, 0x2a, 0xb6, 0xa7, 0x43, 0x6f, 0xbe, 0xfe, 0xfd, 0x9b, 0x6b, 0x86, 0x95, 0xd1, - 0x44, 0x6f, 0x40, 0xa9, 0x83, 0x5d, 0xcc, 0xba, 0x44, 0x45, 0x5c, 0x5e, 0x3c, 0xdf, 0xd4, 0x4e, - 0x84, 0x25, 0xd9, 0xd4, 0x25, 0xd9, 0x7c, 0x93, 0xd3, 0x21, 0x88, 0x58, 0xc9, 0xfc, 0xcc, 0x80, - 0xf9, 0x23, 0xb2, 0xaf, 0xbd, 0xc5, 0x30, 0x9b, 0xda, 0xb4, 0x7d, 0xbd, 0x1c, 0xe6, 0xaa, 0x78, - 0xa5, 0xbc, 0xf8, 0xe2, 0x11, 0x7e, 0xc7, 0x10, 0x59, 0xe3, 0x67, 0x9d, 0x11, 0xb1, 0x30, 0x7f, - 0x2c, 0x40, 0xfd, 0x0e, 0xeb, 0x70, 0xe6, 0x50, 0xd6, 0x4b, 0xf5, 0x57, 0x98, 0xf4, 0x77, 0xd1, - 0xab, 0x50, 0xed, 0xfa, 0x24, 0xb2, 0xbe, 0x45, 0x68, 0x6f, 0x4b, 0x2a, 0xca, 0x8a, 0x56, 0x25, - 0x5e, 0xbe, 0xa9, 0x56, 0xd5, 0x46, 0xee, 0xf5, 0x5d, 0xa2, 0xb6, 0x4a, 0xea, 0x45, 0xb4, 0x84, - 0x1b, 0x93, 0xe5, 0x4d, 0xea, 0x11, 0x44, 0xa0, 0x4a, 0x19, 0x95, 0x14, 0xbb, 0x76, 0xcc, 0xdf, - 0xd3, 0x67, 0x7d, 0x8d, 0xc9, 0x4c, 0xd6, 0xd7, 0x98, 0xb4, 0x2a, 0x1a, 0xb4, 0x1d, 0x61, 0xa2, - 0xbb, 0x69, 0x7a, 0x26, 0xc7, 0x00, 0x1f, 0x83, 0xa1, 0x79, 0x38, 0x1d, 0xc4, 0x64, 0xd9, 0xd4, - 0xa9, 0x9f, 0x9a, 0x33, 0xae, 0x4c, 0x5a, 0xe5, 0x64, 0x6d, 0xcd, 0x31, 0x7d, 0xb8, 0x3a, 0x9c, - 0xd8, 0x03, 0xd8, 0x1d, 0x77, 0x7f, 0xff, 0x69, 0xc0, 0xd9, 0x03, 0xcc, 0xfc, 0xcb, 0x1a, 0xfd, - 0x16, 0x94, 0x08, 0x93, 0x3e, 0x55, 0x9d, 0x1e, 0x16, 0xf0, 0xd5, 0x91, 0x02, 0x3e, 0xac, 0x12, - 0x87, 0x7a, 0x48, 0x83, 0x98, 0x9f, 0x1b, 0x70, 0xed, 0x38, 0x54, 0xeb, 0x66, 0xfa, 0x10, 0xce, - 0xa6, 0xb9, 0xcb, 0xf7, 0xd2, 0x4b, 0xc7, 0x71, 0x25, 0xeb, 0x05, 0x4a, 0xb0, 0xd2, 0x5e, 0xb2, - 0xe1, 0x79, 0xe5, 0xcf, 0xdd, 0x38, 0xf2, 0x71, 0xe7, 0x99, 0xe7, 0x8f, 0x8c, 0xac, 0x25, 0x1d, - 0xe6, 0xdb, 0x00, 0x09, 0xf3, 0x71, 0x74, 0x73, 0x23, 0xd1, 0x25, 0x8a, 0xcb, 0x44, 0x62, 0xea, - 0x0e, 0x8d, 0xb9, 0x54, 0xdd, 0xfc, 0xc1, 0x80, 0x9a, 0xee, 0xa9, 0xa5, 0x01, 0xa6, 0x2e, 0xee, - 0xb8, 0x24, 0x1c, 0xd8, 0x58, 0x9d, 0x7e, 0x3a, 0x82, 0x67, 0xeb, 0x2d, 0x8d, 0x85, 0xde, 0x07, - 0x08, 0x84, 0x63, 0x6b, 0xe4, 0xc2, 0x18, 0x8e, 0x82, 0xe9, 0x40, 0x38, 0xd1, 0x31, 0x6d, 0xfe, - 0x65, 0x40, 0x75, 0x43, 0xe2, 0x6d, 0xe2, 0xfc, 0x97, 0xc3, 0x40, 0xaf, 0x41, 0xc9, 0xe5, 0xdd, - 0xed, 0xa0, 0x1f, 0x77, 0xd0, 0xb9, 0x91, 0xc4, 0xbe, 0xa3, 0xe4, 0xed, 0xc9, 0xd0, 0xa4, 0x15, - 0xef, 0x36, 0x7f, 0x2a, 0x40, 0x35, 0x97, 0x72, 0x54, 0x81, 0x02, 0x75, 0xa2, 0xd8, 0xad, 0x02, - 0x75, 0x50, 0x3d, 0xbd, 0xc3, 0x28, 0xb7, 0x93, 0x9b, 0x0a, 0x42, 0x30, 0xc9, 0xb0, 0xa7, 0x27, - 0xb5, 0xa5, 0x9e, 0x91, 0x0d, 0xa7, 0x07, 0x5c, 0x86, 0xad, 0xd4, 0xe7, 0x3b, 0xc4, 0x3f, 0xc1, - 0x98, 0x1d, 0x8d, 0xb4, 0x1c, 0x21, 0xae, 0x87, 0x80, 0xe8, 0x03, 0x00, 0x15, 0x96, 0x10, 0xe1, - 0x49, 0x7d, 0x6a, 0x0c, 0xf0, 0x19, 0x3c, 0xb4, 0x0c, 0x53, 0x42, 0xd5, 0x43, 0x7d, 0x4a, 0x1d, - 0xdf, 0xf3, 0x23, 0x44, 0xe6, 0xcb, 0x3e, 0xdb, 0x22, 0x5a, 0xd7, 0xfc, 0xa2, 0x00, 0xb5, 0xb0, - 0xac, 0x28, 0xeb, 0x25, 0xec, 0xfe, 0xaf, 0x79, 0x35, 0xbf, 0x35, 0xa0, 0x12, 0x35, 0xda, 0x3a, - 0x17, 0x54, 0x1d, 0x42, 0x79, 0x3e, 0xde, 0x82, 0xe9, 0x64, 0xc2, 0xe8, 0xcb, 0xd3, 0x28, 0xfb, - 0x79, 0x56, 0xb3, 0xec, 0xa7, 0xea, 0x99, 0x34, 0x16, 0x9f, 0x21, 0x8d, 0x3e, 0x5c, 0x54, 0x63, - 0x75, 0xd8, 0xf1, 0x64, 0xa2, 0x6e, 0x40, 0x35, 0xda, 0x68, 0xf7, 0xb5, 0x48, 0x8f, 0xd5, 0xcb, - 0x07, 0xba, 0x9d, 0x22, 0x64, 0x6d, 0x55, 0xc4, 0x90, 0xc8, 0xfc, 0xd5, 0x80, 0xda, 0x1d, 0x26, - 0xfe, 0x39, 0xaa, 0x5e, 0x86, 0x8a, 0x4f, 0x3c, 0x4c, 0x59, 0x58, 0x5b, 0xea, 0x86, 0x56, 0x54, - 0x97, 0x97, 0x99, 0x64, 0x55, 0x5d, 0xd0, 0x6e, 0xc2, 0x73, 0x81, 0x76, 0x4b, 0xd5, 0xde, 0xd3, - 0x72, 0x9a, 0x68, 0x9b, 0x9f, 0xc0, 0x0b, 0x8a, 0xd5, 0x7c, 0x94, 0x09, 0xaf, 0xef, 0xc2, 0x99, - 0x78, 0x73, 0x9e, 0xd9, 0xf9, 0x03, 0x8e, 0x63, 0x71, 0x28, 0xb7, 0xb5, 0x20, 0x27, 0x34, 0x3f, - 0x35, 0xe0, 0x52, 0x94, 0xd2, 0xa0, 0xd3, 0x0e, 0xba, 0xdb, 0x44, 0x6a, 0x9f, 0xe3, 0x03, 0xb9, - 0x9e, 0xfb, 0x60, 0x4b, 0x9b, 0x72, 0x16, 0x4e, 0x39, 0x84, 0x71, 0x4f, 0x37, 0x6b, 0xf4, 0x82, - 0x6e, 0x40, 0xa9, 0xef, 0xf3, 0x9e, 0x8f, 0x3d, 0x45, 0x5b, 0x65, 0xf1, 0xfc, 0x88, 0x87, 0x2b, - 0xd8, 0x67, 0x9b, 0xbb, 0x7d, 0x62, 0xc5, 0x3b, 0xcd, 0x1b, 0x70, 0x2e, 0xba, 0x0f, 0x10, 0x11, - 0xf6, 0xdf, 0x1a, 0xbb, 0xc7, 0x9f, 0x68, 0xdf, 0xfc, 0xbe, 0x00, 0x33, 0x5a, 0xe1, 0x90, 0x41, - 0x7d, 0x1b, 0x66, 0x24, 0x97, 0xd8, 0xb5, 0x07, 0xd1, 0xb6, 0x43, 0x2b, 0xe3, 0xa8, 0x3c, 0x9d, - 0x56, 0x10, 0xda, 0x10, 0x5a, 0x85, 0x52, 0xd7, 0xc5, 0xd4, 0x3b, 0x61, 0x23, 0xc5, 0xca, 0x68, - 0x1d, 0x66, 0x42, 0xa7, 0x88, 0x63, 0x0b, 0x6e, 0xdf, 0xc3, 0xfe, 0x89, 0x4a, 0xa8, 0x1c, 0x41, - 0x6c, 0xf0, 0x55, 0xec, 0xa3, 0xab, 0x50, 0x4b, 0xcb, 0xb6, 0x13, 0x9e, 0x67, 0x42, 0x0d, 0xad, - 0xa2, 0x55, 0x4d, 0xd6, 0xdb, 0x6a, 0xd9, 0xfc, 0xce, 0xd0, 0x5f, 0xe8, 0x43, 0x7c, 0x27, 0x1f, - 0x7e, 0xa5, 0x98, 0x2e, 0xe3, 0x24, 0x11, 0x6a, 0x65, 0x64, 0x41, 0x55, 0x3f, 0xda, 0x8e, 0x4a, - 0x4f, 0x38, 0xd5, 0xc3, 0x92, 0x6d, 0x8c, 0xde, 0xb1, 0xb2, 0x59, 0x1c, 0x9a, 0x05, 0x83, 0xac, - 0x44, 0xb4, 0xd7, 0x1e, 0xec, 0x35, 0x8c, 0x87, 0x7b, 0x0d, 0xe3, 0xb7, 0xbd, 0x86, 0xf1, 0xe5, - 0x7e, 0x63, 0xe2, 0xe1, 0x7e, 0x63, 0xe2, 0xe7, 0xfd, 0xc6, 0xc4, 0x7b, 0xad, 0xcc, 0x40, 0x0e, - 0xe1, 0x17, 0x18, 0x91, 0x3b, 0xdc, 0xdf, 0x56, 0x2f, 0xad, 0x8f, 0x47, 0x7e, 0x63, 0xe9, 0x4c, - 0xa9, 0xdf, 0x2a, 0x6e, 0xfc, 0x1d, 0x00, 0x00, 0xff, 0xff, 0x64, 0xc5, 0x3e, 0xd1, 0x83, 0x11, - 0x00, 0x00, + // 1197 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe4, 0x58, 0x4d, 0x6f, 0x1b, 0xc5, + 0x1b, 0xcf, 0xda, 0x69, 0xfc, 0xcf, 0xe3, 0xc4, 0x76, 0x26, 0xd1, 0xbf, 0x6e, 0x0b, 0x4e, 0xb2, + 0xbc, 0x25, 0x95, 0x62, 0xab, 0xe9, 0x81, 0x0b, 0x42, 0x8a, 0x49, 0xa3, 0x1a, 0x50, 0x95, 0x6e, + 0xda, 0x4a, 0xbc, 0x48, 0xcb, 0xd8, 0x3b, 0x75, 0x46, 0xd9, 0xdd, 0x31, 0x3b, 0x63, 0x87, 0xf0, + 0x01, 0x38, 0x02, 0x1f, 0x80, 0x0f, 0xc0, 0x11, 0xa1, 0x0a, 0x3e, 0x01, 0x52, 0x4f, 0xa8, 0xaa, + 0x38, 0x20, 0x0e, 0x05, 0x25, 0x07, 0xae, 0x48, 0x9c, 0x91, 0xd0, 0xcc, 0xce, 0xbe, 0x78, 0x9d, + 0x84, 0x34, 0xb5, 0x10, 0x88, 0x4b, 0xb2, 0x3b, 0xcf, 0x3c, 0xbf, 0x79, 0x9e, 0xdf, 0xf3, 0x36, + 0x6b, 0xa8, 0x11, 0xf7, 0x80, 0x37, 0x3a, 0xcc, 0xf3, 0xa8, 0xf0, 0x88, 0x2f, 0x1a, 0xe2, 0xa0, + 0x47, 0xb8, 0xdd, 0xd9, 0xaf, 0xf7, 0x02, 0x26, 0x18, 0x2a, 0x4b, 0x79, 0x3d, 0x91, 0x5f, 0x5e, + 0xe8, 0xb2, 0x2e, 0x53, 0xb2, 0x86, 0x7c, 0x0a, 0xb7, 0x5d, 0xbe, 0xd4, 0x61, 0xdc, 0x63, 0xdc, + 0x0e, 0x05, 0xe1, 0x8b, 0x16, 0xd5, 0xc2, 0xb7, 0x46, 0x1b, 0x73, 0xd2, 0x18, 0x5c, 0x6b, 0x13, + 0x81, 0xaf, 0x35, 0x3a, 0x8c, 0xfa, 0x5a, 0x3e, 0x87, 0x3d, 0xea, 0xb3, 0x86, 0xfa, 0xab, 0x97, + 0x9e, 0xcb, 0x1a, 0xd5, 0xc3, 0x01, 0xf6, 0x22, 0xc0, 0xe5, 0xac, 0x34, 0x79, 0xd4, 0x5b, 0xcc, + 0x5b, 0x50, 0xbd, 0xdd, 0x27, 0xc1, 0x41, 0x93, 0x05, 0x01, 0xdb, 0xdf, 0xf0, 0x58, 0xdf, 0x17, + 0x16, 0xf9, 0xb0, 0x4f, 0xb8, 0x40, 0xeb, 0x50, 0xc0, 0x8e, 0x13, 0x10, 0xce, 0xab, 0xc6, 0x92, + 0xb1, 0x32, 0xdd, 0xac, 0x3e, 0x7e, 0xb0, 0xb6, 0xa0, 0x4d, 0xde, 0x08, 0x25, 0x3b, 0x22, 0xa0, + 0x7e, 0xd7, 0x8a, 0x36, 0x9a, 0x14, 0x96, 0x14, 0xde, 0x26, 0x71, 0x49, 0x17, 0x0b, 0x16, 0xe8, + 0x07, 0xca, 0x7c, 0x1e, 0xe1, 0xde, 0x80, 0x39, 0x27, 0x12, 0xdb, 0x67, 0x3d, 0xa1, 0x12, 0xab, + 0xe8, 0x75, 0xf3, 0x37, 0x03, 0x20, 0x41, 0x1f, 0x13, 0xaa, 0x84, 0x19, 0x60, 0x97, 0x3a, 0x43, + 0x30, 0xb9, 0xbf, 0x82, 0x89, 0x55, 0x22, 0x98, 0x3b, 0x30, 0xc5, 0x77, 0x71, 0x40, 0x78, 0x35, + 0xaf, 0x74, 0x5f, 0x7b, 0xf8, 0x64, 0x71, 0xe2, 0xa7, 0x27, 0x8b, 0x2f, 0x77, 0xa9, 0xd8, 0xed, + 0xb7, 0x65, 0x9e, 0xe8, 0xe0, 0xeb, 0x7f, 0x6b, 0xdc, 0xd9, 0x0b, 0x53, 0xaa, 0xbe, 0x49, 0x3a, + 0x8f, 0x1f, 0xac, 0x81, 0x3e, 0x69, 0x93, 0x74, 0x2c, 0x8d, 0x65, 0x7e, 0x61, 0x00, 0x4a, 0x5c, + 0xb6, 0x08, 0xef, 0x31, 0x9f, 0x13, 0xb4, 0x05, 0xe0, 0xc4, 0xab, 0xca, 0xe7, 0xe2, 0xfa, 0x95, + 0x7a, 0x26, 0x1f, 0xeb, 0x89, 0x62, 0x73, 0x5a, 0x5a, 0xf3, 0xe5, 0xaf, 0x5f, 0x5d, 0x35, 0xac, + 0x94, 0x26, 0x7a, 0x1d, 0x0a, 0x6d, 0xec, 0x62, 0xbf, 0x43, 0x94, 0xc7, 0xc5, 0xf5, 0x4b, 0x75, + 0x6d, 0x84, 0x4c, 0xc9, 0xba, 0x4e, 0xc9, 0xfa, 0x1b, 0x8c, 0x0e, 0x41, 0x44, 0x4a, 0xe6, 0x27, + 0x06, 0x2c, 0x9f, 0x12, 0x7d, 0x6d, 0x2d, 0x86, 0x85, 0xe4, 0x4c, 0x3b, 0xd0, 0xcb, 0x32, 0x56, + 0xf9, 0x95, 0xe2, 0xfa, 0x0b, 0xa7, 0xd8, 0x1d, 0x41, 0xa4, 0x0f, 0x9f, 0x77, 0x46, 0xc4, 0xdc, + 0xfc, 0x3e, 0x07, 0xd5, 0xbb, 0x7e, 0x9b, 0xf9, 0x0e, 0xf5, 0xbb, 0x89, 0xfe, 0x0d, 0x5f, 0x04, + 0x07, 0xe8, 0x15, 0x28, 0x77, 0x02, 0x12, 0x9e, 0xbe, 0x4b, 0x68, 0x77, 0x57, 0x28, 0xca, 0xf2, + 0x56, 0x29, 0x5a, 0xbe, 0xa9, 0x56, 0xd5, 0x46, 0xe6, 0xf5, 0x5c, 0xa2, 0xb6, 0x0a, 0xea, 0x85, + 0xb4, 0xc8, 0x8d, 0xf1, 0xf2, 0x1d, 0xea, 0x11, 0x44, 0xa0, 0x4c, 0x7d, 0x2a, 0x28, 0x76, 0xed, + 0x88, 0xbf, 0xa7, 0x8f, 0x7a, 0xcb, 0x17, 0xa9, 0xa8, 0xb7, 0x7c, 0x61, 0x95, 0x34, 0x68, 0x33, + 0xc4, 0x44, 0xf7, 0x92, 0xf0, 0x4c, 0x8e, 0x01, 0x3e, 0x02, 0x43, 0xcb, 0x30, 0xd3, 0x8f, 0xc8, + 0xb2, 0xa9, 0x53, 0xbd, 0xb0, 0x64, 0xac, 0x4c, 0x5a, 0xc5, 0x78, 0xad, 0xe5, 0x98, 0x01, 0xac, + 0x0e, 0x07, 0xf6, 0x18, 0x76, 0xc7, 0x5d, 0xdf, 0xbf, 0x1b, 0x30, 0x7f, 0xcc, 0x31, 0xff, 0xb0, + 0x42, 0xbf, 0x05, 0x05, 0xe2, 0x8b, 0x80, 0xaa, 0x4a, 0x97, 0x09, 0xbc, 0x3a, 0x92, 0xc0, 0x27, + 0x65, 0xe2, 0x50, 0x0d, 0x69, 0x10, 0xf3, 0x53, 0x03, 0xae, 0x9e, 0x85, 0x6a, 0x5d, 0x4c, 0x1f, + 0xc0, 0x7c, 0x12, 0xbb, 0x6c, 0x2d, 0xbd, 0x78, 0x16, 0x53, 0xd2, 0x56, 0xa0, 0x18, 0x2b, 0xa9, + 0x25, 0x1b, 0xfe, 0xaf, 0xec, 0xb9, 0x17, 0x79, 0x3e, 0xee, 0x38, 0xb3, 0xec, 0xc8, 0x48, 0x9f, + 0xa4, 0xdd, 0x7c, 0x0b, 0x20, 0x66, 0x3e, 0xf2, 0x6e, 0x69, 0xc4, 0xbb, 0x58, 0x71, 0x93, 0x08, + 0x4c, 0xdd, 0xa1, 0x36, 0x97, 0xa8, 0x9b, 0xdf, 0x19, 0x50, 0xd1, 0x35, 0xb5, 0x31, 0xc0, 0xd4, + 0xc5, 0x6d, 0x97, 0xc8, 0x86, 0x8d, 0xd5, 0xf4, 0xd3, 0x1e, 0x3c, 0x5b, 0x6d, 0x69, 0x2c, 0xf4, + 0x1e, 0x40, 0x9f, 0x3b, 0xb6, 0x46, 0xce, 0x8d, 0x61, 0x14, 0x4c, 0xf7, 0xb9, 0x13, 0x8e, 0x69, + 0xf3, 0x0f, 0x03, 0xca, 0x3b, 0x02, 0xef, 0x11, 0xe7, 0xdf, 0xec, 0x06, 0x7a, 0x15, 0x0a, 0x2e, + 0xeb, 0xec, 0xf5, 0x7b, 0x51, 0x05, 0x5d, 0x1c, 0x09, 0xec, 0xdb, 0x4a, 0xde, 0x9c, 0x94, 0x47, + 0x5a, 0xd1, 0x6e, 0xf3, 0x87, 0x1c, 0x94, 0x33, 0x21, 0x47, 0x25, 0xc8, 0x51, 0x27, 0xf4, 0xdd, + 0xca, 0x51, 0x07, 0x55, 0x93, 0x3b, 0x8c, 0x32, 0x3b, 0xbe, 0xa9, 0x20, 0x04, 0x93, 0x3e, 0xf6, + 0x74, 0xa7, 0xb6, 0xd4, 0x33, 0xb2, 0x61, 0x66, 0xc0, 0x84, 0x2c, 0xa5, 0x1e, 0xdb, 0x27, 0xc1, + 0x39, 0xda, 0xec, 0xa8, 0xa7, 0xc5, 0x10, 0x71, 0x5b, 0x02, 0xa2, 0xf7, 0x01, 0x94, 0x5b, 0x9c, + 0xcb, 0x49, 0x7d, 0x61, 0x0c, 0xf0, 0x29, 0x3c, 0xb4, 0x09, 0x53, 0x5c, 0xe5, 0x43, 0x75, 0x4a, + 0x8d, 0xef, 0xe5, 0x11, 0x22, 0xb3, 0x69, 0x9f, 0x2e, 0x11, 0xad, 0x6b, 0x7e, 0x96, 0x83, 0x8a, + 0x4c, 0x2b, 0xea, 0x77, 0x63, 0x76, 0xff, 0xd3, 0xbc, 0x9a, 0x5f, 0x1b, 0x50, 0x0a, 0x0b, 0x6d, + 0x9b, 0x71, 0xaa, 0x86, 0x50, 0x96, 0x8f, 0x37, 0x61, 0x3a, 0xee, 0x30, 0xfa, 0xf2, 0x34, 0xca, + 0x7e, 0x96, 0xd5, 0x34, 0xfb, 0x89, 0x7a, 0x2a, 0x8c, 0xf9, 0x67, 0x08, 0x63, 0x00, 0x57, 0x54, + 0x5b, 0x1d, 0x36, 0x3c, 0xee, 0xa8, 0x3b, 0x50, 0x0e, 0x37, 0xda, 0x3d, 0x2d, 0xd2, 0x6d, 0x75, + 0xf1, 0x58, 0xb3, 0x13, 0x84, 0xf4, 0x59, 0x25, 0x3e, 0x24, 0x32, 0x7f, 0x36, 0xa0, 0x72, 0xd7, + 0xe7, 0x7f, 0x1f, 0x55, 0x2f, 0x41, 0x29, 0x20, 0x1e, 0xa6, 0xbe, 0xcc, 0x2d, 0x75, 0x43, 0xcb, + 0xab, 0xcb, 0xcb, 0x6c, 0xbc, 0xaa, 0x2e, 0x68, 0x37, 0xe1, 0x7f, 0x7d, 0x6d, 0x96, 0xca, 0xbd, + 0xa7, 0xe5, 0x34, 0xd6, 0x36, 0x3f, 0x86, 0xe7, 0x15, 0xab, 0x59, 0x2f, 0x63, 0x5e, 0xdf, 0x81, + 0xb9, 0x68, 0x73, 0x96, 0xd9, 0xe5, 0x63, 0xc6, 0x31, 0x3f, 0x91, 0xdb, 0x4a, 0x3f, 0x23, 0x34, + 0xaf, 0xc3, 0xc5, 0x70, 0x12, 0x13, 0x2e, 0x33, 0xbf, 0xe5, 0xdf, 0x67, 0xd1, 0x28, 0xae, 0x66, + 0x3e, 0xd5, 0x92, 0x0f, 0xb2, 0x6f, 0x73, 0x30, 0xab, 0x15, 0x4e, 0x68, 0x91, 0xb7, 0x61, 0x56, + 0x30, 0x81, 0x5d, 0x7b, 0x10, 0x6e, 0x3b, 0x31, 0x26, 0xa7, 0x31, 0x34, 0xa3, 0x20, 0xf4, 0x41, + 0x68, 0x0b, 0x0a, 0x1d, 0x17, 0x53, 0xef, 0x9c, 0x29, 0x1c, 0x29, 0xa3, 0x6d, 0x98, 0x95, 0x46, + 0x11, 0xc7, 0xe6, 0xcc, 0xbe, 0x8f, 0x83, 0x73, 0x05, 0xaf, 0x18, 0x42, 0xec, 0xb0, 0x2d, 0x1c, + 0xa0, 0x55, 0xa8, 0x24, 0x09, 0xd3, 0x96, 0x93, 0x84, 0xab, 0x76, 0x91, 0xb7, 0xca, 0xf1, 0x7a, + 0x53, 0x2d, 0x9b, 0xdf, 0x18, 0xfa, 0xdb, 0x78, 0x88, 0xef, 0xf8, 0x93, 0xab, 0x10, 0xd1, 0x65, + 0x9c, 0xc7, 0x43, 0xad, 0x8c, 0x2c, 0x28, 0xeb, 0x47, 0xdb, 0x51, 0xe1, 0x91, 0xfd, 0x54, 0x26, + 0x4b, 0x6d, 0xf4, 0x76, 0x93, 0x8e, 0xe2, 0x50, 0x15, 0x0e, 0xd2, 0x12, 0xde, 0x6c, 0x3d, 0x3c, + 0xac, 0x19, 0x8f, 0x0e, 0x6b, 0xc6, 0x2f, 0x87, 0x35, 0xe3, 0xf3, 0xa3, 0xda, 0xc4, 0xa3, 0xa3, + 0xda, 0xc4, 0x8f, 0x47, 0xb5, 0x89, 0x77, 0x1b, 0xa9, 0x56, 0x28, 0xe1, 0xd7, 0x7c, 0x22, 0xf6, + 0x59, 0xb0, 0xa7, 0x5e, 0x1a, 0x1f, 0x8d, 0xfc, 0xba, 0xd1, 0x9e, 0x52, 0xbf, 0x12, 0x5c, 0xff, + 0x33, 0x00, 0x00, 0xff, 0xff, 0xdd, 0x49, 0xaf, 0xd9, 0xfd, 0x10, 0x00, 0x00, } func (m *QueryBorrowAmountRequest) Marshal() (dAtA []byte, err error) { @@ -2246,48 +2181,6 @@ func (m *QueryUnstakedPositionResponse) MarshalToSizedBuffer(dAtA []byte) (int, return len(dAtA) - i, nil } -func (m *QuerySubBucketBalanceRequest) 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 *QuerySubBucketBalanceRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QuerySubBucketBalanceRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Program != 0 { - i = encodeVarintTypesCw(dAtA, i, uint64(m.Program)) - i-- - dAtA[i] = 0x18 - } - if len(m.Denom) > 0 { - i -= len(m.Denom) - copy(dAtA[i:], m.Denom) - i = encodeVarintTypesCw(dAtA, i, uint64(len(m.Denom))) - i-- - dAtA[i] = 0x12 - } - if len(m.Address) > 0 { - i -= len(m.Address) - copy(dAtA[i:], m.Address) - i = encodeVarintTypesCw(dAtA, i, uint64(len(m.Address))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - func (m *QueryVestingInfoRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -2766,26 +2659,6 @@ func (m *QueryUnstakedPositionResponse) Size() (n int) { return n } -func (m *QuerySubBucketBalanceRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Address) - if l > 0 { - n += 1 + l + sovTypesCw(uint64(l)) - } - l = len(m.Denom) - if l > 0 { - n += 1 + l + sovTypesCw(uint64(l)) - } - if m.Program != 0 { - n += 1 + sovTypesCw(uint64(m.Program)) - } - return n -} - func (m *QueryVestingInfoRequest) Size() (n int) { if m == nil { return 0 @@ -5225,139 +5098,6 @@ func (m *QueryUnstakedPositionResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QuerySubBucketBalanceRequest) 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 ErrIntOverflowTypesCw - } - 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: QuerySubBucketBalanceRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QuerySubBucketBalanceRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypesCw - } - 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 ErrInvalidLengthTypesCw - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTypesCw - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Address = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Denom", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypesCw - } - 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 ErrInvalidLengthTypesCw - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTypesCw - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Denom = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Program", wireType) - } - m.Program = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypesCw - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Program |= EarnType(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipTypesCw(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTypesCw - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} func (m *QueryVestingInfoRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/x/estaking/client/cli/query.go b/x/estaking/client/cli/query.go new file mode 100644 index 000000000..bedc2d57f --- /dev/null +++ b/x/estaking/client/cli/query.go @@ -0,0 +1,34 @@ +package cli + +import ( + "fmt" + // "strings" + + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client" + // "github.com/cosmos/cosmos-sdk/client/flags" + // sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/elys-network/elys/x/estaking/types" +) + +// GetQueryCmd returns the cli query commands for this module +func GetQueryCmd(queryRoute string) *cobra.Command { + // Group estaking queries under a subcommand + 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( + CmdQueryParams(), + CmdQueryRewards(), + ) + // this line is used by starport scaffolding # 1 + + return cmd +} diff --git a/x/estaking/client/cli/query_params.go b/x/estaking/client/cli/query_params.go new file mode 100644 index 000000000..75a954b41 --- /dev/null +++ b/x/estaking/client/cli/query_params.go @@ -0,0 +1,64 @@ +package cli + +import ( + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/spf13/cobra" + + "github.com/elys-network/elys/x/estaking/types" +) + +func CmdQueryParams() *cobra.Command { + cmd := &cobra.Command{ + Use: "params", + Short: "shows the parameters of the module", + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + res, err := queryClient.Params(cmd.Context(), &types.QueryParamsRequest{}) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +func CmdQueryRewards() *cobra.Command { + cmd := &cobra.Command{ + Use: "rewards", + Short: "shows the rewards of an account", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + res, err := queryClient.Rewards(cmd.Context(), &types.QueryRewardsRequest{ + Address: args[0], + }) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/estaking/client/cli/tx.go b/x/estaking/client/cli/tx.go new file mode 100644 index 000000000..12646cbd3 --- /dev/null +++ b/x/estaking/client/cli/tx.go @@ -0,0 +1,26 @@ +package cli + +import ( + "fmt" + + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client" + // "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/elys-network/elys/x/estaking/types" +) + +// GetTxCmd returns the transaction commands for this module +func GetTxCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: types.ModuleName, + Short: fmt.Sprintf("%s transactions subcommands", types.ModuleName), + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + // this line is used by starport scaffolding # 1 + + return cmd +} diff --git a/x/estaking/client/wasm/messenger.go b/x/estaking/client/wasm/messenger.go new file mode 100644 index 000000000..321c129bf --- /dev/null +++ b/x/estaking/client/wasm/messenger.go @@ -0,0 +1,36 @@ +package wasm + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + wasmbindingstypes "github.com/elys-network/elys/wasmbindings/types" + "github.com/elys-network/elys/x/estaking/keeper" + parameterkeeper "github.com/elys-network/elys/x/parameter/keeper" +) + +// Messenger handles messages for the Masterchef module. +type Messenger struct { + keeper *keeper.Keeper + parameterKeeper *parameterkeeper.Keeper +} + +func NewMessenger( + keeper *keeper.Keeper, + parameterKeeper *parameterkeeper.Keeper, +) *Messenger { + return &Messenger{ + keeper: keeper, + parameterKeeper: parameterKeeper, + } +} + +func (m *Messenger) HandleMsg(ctx sdk.Context, contractAddr sdk.AccAddress, contractIBCPortID string, msg wasmbindingstypes.ElysMsg) ([]sdk.Event, [][]byte, error) { + switch { + case msg.EstakingWithdrawReward != nil: + return m.msgWithdrawReward(ctx, contractAddr, msg.EstakingWithdrawReward) + case msg.EstakingWithdrawElysStakingRewards != nil: + return m.msgWithdrawElysStakingRewards(ctx, contractAddr, msg.EstakingWithdrawElysStakingRewards) + default: + // This handler cannot handle the message + return nil, nil, wasmbindingstypes.ErrCannotHandleMsg + } +} diff --git a/x/estaking/client/wasm/msg_withdraw_elys_staking_rewards.go b/x/estaking/client/wasm/msg_withdraw_elys_staking_rewards.go new file mode 100644 index 000000000..b1b1c4bc1 --- /dev/null +++ b/x/estaking/client/wasm/msg_withdraw_elys_staking_rewards.go @@ -0,0 +1,69 @@ +package wasm + +import ( + "encoding/json" + + errorsmod "cosmossdk.io/errors" + wasmvmtypes "github.com/CosmWasm/wasmvm/types" + sdk "github.com/cosmos/cosmos-sdk/types" + wasmbindingstypes "github.com/elys-network/elys/wasmbindings/types" + estakingkeeper "github.com/elys-network/elys/x/estaking/keeper" + "github.com/elys-network/elys/x/estaking/types" + paramtypes "github.com/elys-network/elys/x/parameter/types" +) + +func (m *Messenger) msgWithdrawElysStakingRewards(ctx sdk.Context, contractAddr sdk.AccAddress, msgWithdrawElysStakingRewards *types.MsgWithdrawElysStakingRewards) ([]sdk.Event, [][]byte, error) { + var res *wasmbindingstypes.RequestResponse + var err error + + brokerAddress := m.parameterKeeper.GetParams(ctx).BrokerAddress + if msgWithdrawElysStakingRewards.DelegatorAddress != contractAddr.String() && contractAddr.String() != brokerAddress { + return nil, nil, wasmvmtypes.InvalidRequest{Err: "wrong sender"} + } + + res, err = performMsgWithdrawElysStakingRewards(m.keeper, ctx, contractAddr, msgWithdrawElysStakingRewards) + if err != nil { + return nil, nil, errorsmod.Wrap(err, "perform elys claim rewards") + } + + responseBytes, err := json.Marshal(*res) + if err != nil { + return nil, nil, errorsmod.Wrap(err, "failed to serialize stake") + } + + resp := [][]byte{responseBytes} + + return nil, resp, nil +} + +func performMsgWithdrawElysStakingRewards(f *estakingkeeper.Keeper, ctx sdk.Context, contractAddr sdk.AccAddress, msgWithdrawElysStakingRewards *types.MsgWithdrawElysStakingRewards) (*wasmbindingstypes.RequestResponse, error) { + if msgWithdrawElysStakingRewards == nil { + return nil, wasmvmtypes.InvalidRequest{Err: "Invalid claim elys staking rewards parameter"} + } + + msgServer := estakingkeeper.NewMsgServerImpl(*f) + _, err := sdk.AccAddressFromBech32(msgWithdrawElysStakingRewards.DelegatorAddress) + if err != nil { + return nil, errorsmod.Wrap(err, "invalid address") + } + + msg := &types.MsgWithdrawElysStakingRewards{ + DelegatorAddress: msgWithdrawElysStakingRewards.DelegatorAddress, + } + + if err := msg.ValidateBasic(); err != nil { + return nil, errorsmod.Wrap(err, "failed validating MsgWithdrawElysStakingRewards") + } + + _, err = msgServer.WithdrawElysStakingRewards(sdk.WrapSDKContext(ctx), msg) // Discard the response because it's empty + if err != nil { + return nil, errorsmod.Wrap(err, "elys WithdrawElysStakingRewards msg") + } + + resp := &wasmbindingstypes.RequestResponse{ + Code: paramtypes.RES_OK, + Result: "WithdrawElysStakingRewards succeed!", + } + + return resp, nil +} diff --git a/x/estaking/client/wasm/msg_withdraw_reward.go b/x/estaking/client/wasm/msg_withdraw_reward.go new file mode 100644 index 000000000..ed4bbc0f7 --- /dev/null +++ b/x/estaking/client/wasm/msg_withdraw_reward.go @@ -0,0 +1,70 @@ +package wasm + +import ( + "encoding/json" + + errorsmod "cosmossdk.io/errors" + wasmvmtypes "github.com/CosmWasm/wasmvm/types" + sdk "github.com/cosmos/cosmos-sdk/types" + wasmbindingstypes "github.com/elys-network/elys/wasmbindings/types" + estakingkeeper "github.com/elys-network/elys/x/estaking/keeper" + "github.com/elys-network/elys/x/estaking/types" + paramtypes "github.com/elys-network/elys/x/parameter/types" +) + +func (m *Messenger) msgWithdrawReward(ctx sdk.Context, contractAddr sdk.AccAddress, msgWithdrawReward *types.MsgWithdrawReward) ([]sdk.Event, [][]byte, error) { + var res *wasmbindingstypes.RequestResponse + var err error + + brokerAddress := m.parameterKeeper.GetParams(ctx).BrokerAddress + if msgWithdrawReward.DelegatorAddress != contractAddr.String() && contractAddr.String() != brokerAddress { + return nil, nil, wasmvmtypes.InvalidRequest{Err: "wrong sender"} + } + + res, err = performMsgWithdrawReward(m.keeper, ctx, contractAddr, msgWithdrawReward) + if err != nil { + return nil, nil, errorsmod.Wrap(err, "perform elys claim rewards") + } + + responseBytes, err := json.Marshal(*res) + if err != nil { + return nil, nil, errorsmod.Wrap(err, "failed to serialize stake") + } + + resp := [][]byte{responseBytes} + + return nil, resp, nil +} + +func performMsgWithdrawReward(f *estakingkeeper.Keeper, ctx sdk.Context, contractAddr sdk.AccAddress, msgWithdrawReward *types.MsgWithdrawReward) (*wasmbindingstypes.RequestResponse, error) { + if msgWithdrawReward == nil { + return nil, wasmvmtypes.InvalidRequest{Err: "Invalid claim rewards parameter"} + } + + msgServer := estakingkeeper.NewMsgServerImpl(*f) + _, err := sdk.AccAddressFromBech32(msgWithdrawReward.DelegatorAddress) + if err != nil { + return nil, errorsmod.Wrap(err, "invalid address") + } + + msgMsgWithdrawReward := &types.MsgWithdrawReward{ + DelegatorAddress: msgWithdrawReward.DelegatorAddress, + ValidatorAddress: msgWithdrawReward.ValidatorAddress, + } + + if err := msgMsgWithdrawReward.ValidateBasic(); err != nil { + return nil, errorsmod.Wrap(err, "failed validating msgMsgWithdrawReward") + } + + _, err = msgServer.WithdrawReward(sdk.WrapSDKContext(ctx), msgMsgWithdrawReward) // Discard the response because it's empty + if err != nil { + return nil, errorsmod.Wrap(err, "elys withdrawReward msg") + } + + resp := &wasmbindingstypes.RequestResponse{ + Code: paramtypes.RES_OK, + Result: "WithdrawReward succeed!", + } + + return resp, nil +} diff --git a/x/estaking/client/wasm/querier.go b/x/estaking/client/wasm/querier.go new file mode 100644 index 000000000..261fa6ace --- /dev/null +++ b/x/estaking/client/wasm/querier.go @@ -0,0 +1,60 @@ +package wasm + +import ( + "encoding/json" + + errorsmod "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + wasmbindingstypes "github.com/elys-network/elys/wasmbindings/types" + "github.com/elys-network/elys/x/estaking/keeper" + "github.com/elys-network/elys/x/estaking/types" +) + +// Querier handles queries for the Estaking module. +type Querier struct { + keeper *keeper.Keeper +} + +func NewQuerier(keeper *keeper.Keeper) *Querier { + return &Querier{ + keeper: keeper, + } +} + +func (oq *Querier) HandleQuery(ctx sdk.Context, query wasmbindingstypes.ElysQuery) ([]byte, error) { + switch { + case query.EstakingParams != nil: + return oq.queryParams(ctx, query.EstakingParams) + case query.EstakingRewards != nil: + return oq.queryRewards(ctx, query.EstakingRewards) + default: + // This handler cannot handle the query + return nil, wasmbindingstypes.ErrCannotHandleQuery + } +} + +func (oq *Querier) queryParams(ctx sdk.Context, query *types.QueryParamsRequest) ([]byte, error) { + res, err := oq.keeper.Params(ctx, query) + if err != nil { + return nil, errorsmod.Wrap(err, "failed to get params") + } + + responseBytes, err := json.Marshal(res) + if err != nil { + return nil, errorsmod.Wrap(err, "failed to serialize params response") + } + return responseBytes, nil +} + +func (oq *Querier) queryRewards(ctx sdk.Context, query *types.QueryRewardsRequest) ([]byte, error) { + res, err := oq.keeper.Rewards(ctx, query) + if err != nil { + return nil, errorsmod.Wrap(err, "failed to get estaking rewards") + } + + responseBytes, err := json.Marshal(res) + if err != nil { + return nil, errorsmod.Wrap(err, "failed to serialize estaking rewards response") + } + return responseBytes, nil +} diff --git a/x/estaking/keeper/abci.go b/x/estaking/keeper/abci.go new file mode 100644 index 000000000..d4c714353 --- /dev/null +++ b/x/estaking/keeper/abci.go @@ -0,0 +1,202 @@ +package keeper + +import ( + "errors" + + errorsmod "cosmossdk.io/errors" + + sdk "github.com/cosmos/cosmos-sdk/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + assetprofiletypes "github.com/elys-network/elys/x/assetprofile/types" + "github.com/elys-network/elys/x/estaking/types" + ptypes "github.com/elys-network/elys/x/parameter/types" +) + +// EndBlocker of incentive module +func (k Keeper) EndBlocker(ctx sdk.Context) { + // Rewards distribution + k.ProcessRewardsDistribution(ctx) + // Burn EdenB tokens if staking changed + k.BurnEdenBIfElysStakingReduced(ctx) +} + +func (k Keeper) TakeDelegationSnapshot(ctx sdk.Context, addr string) { + // Calculate delegated amount per delegator + delAmount := k.CalcDelegationAmount(ctx, addr) + + elysStaked := types.ElysStaked{ + Address: addr, + Amount: delAmount, + } + + // Set Elys staked amount + k.SetElysStaked(ctx, elysStaked) +} + +func (k Keeper) BurnEdenBIfElysStakingReduced(ctx sdk.Context) { + addrs := k.GetAllElysStakeChange(ctx) + + // Handle addresses recorded on AfterDelegationModified + // This hook is exposed for genesis delegations as well + for _, delAddr := range addrs { + k.BurnEdenBFromElysUnstaking(ctx, delAddr) + k.TakeDelegationSnapshot(ctx, delAddr.String()) + k.RemoveElysStakeChange(ctx, delAddr) + } +} + +// Rewards distribution +func (k Keeper) ProcessRewardsDistribution(ctx sdk.Context) { + // Read tokenomics time based inflation params and update incentive module params. + if !k.ProcessUpdateIncentiveParams(ctx) { + ctx.Logger().Error("Invalid tokenomics params", "error", errors.New("invalid tokenomics params")) + return + } + + canDistribute := k.CanDistributeStakingRewards(ctx) + if canDistribute { + err := k.UpdateStakersRewards(ctx) + if err != nil { + ctx.Logger().Error("Failed to update staker rewards unclaimed", "error", err) + } + } +} + +func (k Keeper) ProcessUpdateIncentiveParams(ctx sdk.Context) bool { + // Non-linear inflation per year happens and this includes yearly inflation data + listTimeBasedInflations := k.tokenomicsKeeper.GetAllTimeBasedInflation(ctx) + if len(listTimeBasedInflations) < 1 { + return false + } + + params := k.GetParams(ctx) + + for _, inflation := range listTimeBasedInflations { + // Finding only current inflation data - and skip rest + if inflation.StartBlockHeight > uint64(ctx.BlockHeight()) || inflation.EndBlockHeight < uint64(ctx.BlockHeight()) { + continue + } + + totalBlocksPerYear := sdk.NewInt(int64(inflation.EndBlockHeight - inflation.StartBlockHeight + 1)) + + // If totalBlocksPerYear is zero, we skip this inflation to avoid division by zero + if totalBlocksPerYear == sdk.ZeroInt() { + continue + } + + // ------------- Stakers parameter ------------- + blocksDistributed := sdk.NewInt(ctx.BlockHeight() - int64(inflation.StartBlockHeight)) + incentiveInfo := types.IncentiveInfo{ + EdenAmountPerYear: sdk.NewInt(int64(inflation.Inflation.IcsStakingRewards)), + DistributionStartBlock: sdk.NewInt(int64(inflation.StartBlockHeight)), + TotalBlocksPerYear: totalBlocksPerYear, + BlocksDistributed: blocksDistributed, + } + + if params.StakeIncentives == nil { + params.StakeIncentives = &incentiveInfo + } else { + // If any of block number related parameter changed, we re-calculate the current epoch + if params.StakeIncentives.DistributionStartBlock != incentiveInfo.DistributionStartBlock || + params.StakeIncentives.TotalBlocksPerYear != incentiveInfo.TotalBlocksPerYear { + params.StakeIncentives.BlocksDistributed = blocksDistributed + } + params.StakeIncentives.EdenAmountPerYear = incentiveInfo.EdenAmountPerYear + params.StakeIncentives.DistributionStartBlock = incentiveInfo.DistributionStartBlock + params.StakeIncentives.TotalBlocksPerYear = incentiveInfo.TotalBlocksPerYear + } + break + } + + k.SetParams(ctx, params) + return true +} + +func (k Keeper) CanDistributeStakingRewards(ctx sdk.Context) bool { + // Fetch incentive params + params := k.GetParams(ctx) + if ctx.BlockHeight() < 1 { + return false + } + + // If we don't have enough params + if params.StakeIncentives == nil { + return false + } + + // Incentive params initialize + stakeIncentive := params.StakeIncentives + + curBlockHeight := sdk.NewInt(ctx.BlockHeight()) + if stakeIncentive.DistributionStartBlock.GT(curBlockHeight) { + return false + } + + // Increase current epoch of Stake incentive param + stakeIncentive.BlocksDistributed = stakeIncentive.BlocksDistributed.Add(sdk.OneInt()) + if stakeIncentive.BlocksDistributed.GTE(stakeIncentive.TotalBlocksPerYear) || curBlockHeight.GT(stakeIncentive.TotalBlocksPerYear.Add(stakeIncentive.DistributionStartBlock)) { + params.StakeIncentives = nil + k.SetParams(ctx, params) + return false + } + + params.StakeIncentives.BlocksDistributed = stakeIncentive.BlocksDistributed + k.SetParams(ctx, params) + + // return found, stake incentive params + return true +} + +func (k Keeper) UpdateStakersRewards(ctx sdk.Context) error { + entry, found := k.assetProfileKeeper.GetEntry(ctx, ptypes.BaseCurrency) + if !found { + return errorsmod.Wrapf(assetprofiletypes.ErrAssetProfileNotFound, "asset %s not found", ptypes.BaseCurrency) + } + baseCurrency := entry.Denom + + // USDC amount in sdk.Dec type + feeCollectorAddr := authtypes.NewModuleAddress(authtypes.FeeCollectorName) + totalFeesCollected := k.commKeeper.GetAllBalances(ctx, feeCollectorAddr) + gasFeeCollectedDec := sdk.NewDecCoinsFromCoins(totalFeesCollected...) + dexRevenueStakersAmount := gasFeeCollectedDec.AmountOf(baseCurrency) + + // Calculate eden amount per block + params := k.GetParams(ctx) + stakeIncentive := params.StakeIncentives + + // Ensure stakeIncentive.TotalBlocksPerYear are not zero to avoid division by zero + if stakeIncentive.TotalBlocksPerYear.IsZero() { + return errorsmod.Wrap(types.ErrNoInflationaryParams, "invalid inflationary params") + } + + // Calculate + stakersEdenAmount := stakeIncentive.EdenAmountPerYear. + Quo(stakeIncentive.TotalBlocksPerYear) + + // Maximum eden APR - 30% by default + // Allocated for staking per day = (0.3/365)* ( total elys staked + total Eden committed + total Eden boost committed) + totalElysEdenEdenBStake := k.TotalBondedTokens(ctx) + + stakersMaxEdenAmount := params.MaxEdenRewardAprStakers. + MulInt(totalElysEdenEdenBStake). + QuoInt(stakeIncentive.TotalBlocksPerYear) + + // Use min amount (eden allocation from tokenomics and max apr based eden amount) + stakersEdenAmount = sdk.MinInt(stakersEdenAmount, stakersMaxEdenAmount.TruncateInt()) + + stakersEdenBAmount := sdk.NewDecFromInt(totalElysEdenEdenBStake). + Mul(params.EdenBoostApr). + QuoInt(stakeIncentive.TotalBlocksPerYear). + RoundInt() + + // Set block number and total dex rewards given + params.DexRewardsStakers.NumBlocks = sdk.OneInt() + params.DexRewardsStakers.Amount = dexRevenueStakersAmount + k.SetParams(ctx, params) + + coins := sdk.NewCoins( + sdk.NewCoin(ptypes.Eden, stakersEdenAmount), + sdk.NewCoin(ptypes.EdenB, stakersEdenBAmount), + ) + return k.commKeeper.MintCoins(ctx, authtypes.FeeCollectorName, coins.Sort()) +} diff --git a/x/estaking/keeper/abci_test.go b/x/estaking/keeper/abci_test.go new file mode 100644 index 000000000..ca1d131fc --- /dev/null +++ b/x/estaking/keeper/abci_test.go @@ -0,0 +1,80 @@ +package keeper_test + +import ( + "testing" + + tmproto "github.com/cometbft/cometbft/proto/tendermint/types" + sdk "github.com/cosmos/cosmos-sdk/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" + simapp "github.com/elys-network/elys/app" + assetprofiletypes "github.com/elys-network/elys/x/assetprofile/types" + "github.com/elys-network/elys/x/estaking/keeper" + exdistr "github.com/elys-network/elys/x/estaking/modules/distribution" + "github.com/elys-network/elys/x/estaking/types" + ptypes "github.com/elys-network/elys/x/parameter/types" + "github.com/stretchr/testify/require" +) + +func TestUpdateStakersRewards(t *testing.T) { + app := simapp.InitElysTestApp(true) + ctx := app.BaseApp.NewContext(true, tmproto.Header{}) + + stakingKeeper := app.StakingKeeper + estakingKeeper := app.EstakingKeeper + + // create validator with 50% commission + validators := stakingKeeper.GetAllValidators(ctx) + require.True(t, len(validators) > 0) + valAddr := validators[0].GetOperator() + delegations := stakingKeeper.GetValidatorDelegations(ctx, valAddr) + require.True(t, len(delegations) > 0) + addr := sdk.MustAccAddressFromBech32(delegations[0].DelegatorAddress) + + app.AssetprofileKeeper.SetEntry(ctx, assetprofiletypes.Entry{ + BaseDenom: ptypes.Eden, + Denom: ptypes.Eden, + Decimals: 6, + CommitEnabled: true, + WithdrawEnabled: true, + }) + app.AssetprofileKeeper.SetEntry(ctx, assetprofiletypes.Entry{ + BaseDenom: ptypes.BaseCurrency, + Denom: ptypes.BaseCurrency, + Decimals: 6, + CommitEnabled: true, + WithdrawEnabled: true, + }) + + // next block + ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 1) + + params := estakingKeeper.GetParams(ctx) + params.StakeIncentives = &types.IncentiveInfo{ + EdenAmountPerYear: sdk.NewInt(1000_000_000_000_000), + DistributionStartBlock: sdk.NewInt(0), + TotalBlocksPerYear: sdk.NewInt(6307200), + BlocksDistributed: sdk.NewInt(1), + } + params.MaxEdenRewardAprStakers = sdk.NewDec(1000_000) + estakingKeeper.SetParams(ctx, params) + + // update staker rewards + err := estakingKeeper.UpdateStakersRewards(ctx) + require.Nil(t, err) + + distrAppModule := exdistr.NewAppModule( + app.AppCodec(), app.DistrKeeper, app.AccountKeeper, + app.CommitmentKeeper, &app.EstakingKeeper, + authtypes.FeeCollectorName, app.GetSubspace(distrtypes.ModuleName)) + distrAppModule.AllocateTokens(ctx) + + // withdraw eden rewards + msgServer := keeper.NewMsgServerImpl(estakingKeeper) + res, err := msgServer.WithdrawReward(ctx, &types.MsgWithdrawReward{ + DelegatorAddress: addr.String(), + ValidatorAddress: valAddr.String(), + }) + require.Nil(t, err) + require.Equal(t, res.Amount.String(), "147608ueden") +} diff --git a/x/estaking/keeper/elys_stake_change.go b/x/estaking/keeper/elys_stake_change.go new file mode 100644 index 000000000..c0f6de122 --- /dev/null +++ b/x/estaking/keeper/elys_stake_change.go @@ -0,0 +1,36 @@ +package keeper + +import ( + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/elys-network/elys/x/estaking/types" +) + +func (k Keeper) SetElysStakeChange(ctx sdk.Context, addr sdk.AccAddress) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.ElysStakeChangeKeyPrefix)) + store.Set([]byte(addr), addr) +} + +func (k Keeper) GetElysStakeChange(ctx sdk.Context, addr sdk.AccAddress) (found bool) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.ElysStakeChangeKeyPrefix)) + + return store.Has([]byte(addr)) +} + +func (k Keeper) RemoveElysStakeChange(ctx sdk.Context, address sdk.AccAddress) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.ElysStakeChangeKeyPrefix)) + store.Delete([]byte(address)) +} + +func (k Keeper) GetAllElysStakeChange(ctx sdk.Context) (list []sdk.AccAddress) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.ElysStakeChangeKeyPrefix)) + iterator := sdk.KVStorePrefixIterator(store, []byte{}) + + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + list = append(list, sdk.AccAddress(iterator.Value())) + } + + return +} diff --git a/x/estaking/keeper/elys_staked.go b/x/estaking/keeper/elys_staked.go new file mode 100644 index 000000000..aae3cfc76 --- /dev/null +++ b/x/estaking/keeper/elys_staked.go @@ -0,0 +1,51 @@ +package keeper + +import ( + "cosmossdk.io/math" + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/elys-network/elys/x/estaking/types" +) + +// SetElysStaked set a specific elysStaked in the store from its index +func (k Keeper) SetElysStaked(ctx sdk.Context, elysStaked types.ElysStaked) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.ElysStakedKeyPrefix)) + b := k.cdc.MustMarshal(&elysStaked) + store.Set(types.ElysStakedKey(elysStaked.Address), b) +} + +// GetElysStaked returns a elysStaked from its index +func (k Keeper) GetElysStaked(ctx sdk.Context, address string) math.Int { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.ElysStakedKeyPrefix)) + + b := store.Get(types.ElysStakedKey(address)) + if b == nil { + return math.ZeroInt() + } + + val := types.ElysStaked{} + k.cdc.MustUnmarshal(b, &val) + return val.Amount +} + +// RemoveElysStaked removes a elysStaked from the store +func (k Keeper) RemoveElysStaked(ctx sdk.Context, address string) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.ElysStakedKeyPrefix)) + store.Delete(types.ElysStakedKey(address)) +} + +// GetAllElysStaked returns all elysStaked +func (k Keeper) GetAllElysStaked(ctx sdk.Context) (list []types.ElysStaked) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.ElysStakedKeyPrefix)) + iterator := sdk.KVStorePrefixIterator(store, []byte{}) + + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + var val types.ElysStaked + k.cdc.MustUnmarshal(iterator.Value(), &val) + list = append(list, val) + } + + return +} diff --git a/x/estaking/keeper/genesis.go b/x/estaking/keeper/genesis.go new file mode 100644 index 000000000..0e81f775c --- /dev/null +++ b/x/estaking/keeper/genesis.go @@ -0,0 +1,58 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + "github.com/elys-network/elys/x/estaking/types" + ptypes "github.com/elys-network/elys/x/parameter/types" +) + +// InitGenesis initializes the module's state from a provided genesis state. +func (k Keeper) InitGenesis(ctx sdk.Context, genState types.GenesisState) { + var shouldRunEdenValHook = false + var shouldRunEdenBValHook = false + edenValAddr := sdk.ValAddress(authtypes.NewModuleAddress(ptypes.Eden)) + edenBValAddr := sdk.ValAddress(authtypes.NewModuleAddress(ptypes.EdenB)) + + // Create validators for Eden and EdenB + if genState.Params.EdenCommitVal == "" { + genState.Params.EdenCommitVal = edenValAddr.String() + shouldRunEdenValHook = true + } + + if genState.Params.EdenbCommitVal == "" { + genState.Params.EdenbCommitVal = edenBValAddr.String() + shouldRunEdenBValHook = true + } + + // this line is used by starport scaffolding # genesis/module/init + k.SetParams(ctx, genState.Params) + for _, snap := range genState.StakingSnapshots { + k.SetElysStaked(ctx, snap) + } + + if k.Hooks() != nil { + if shouldRunEdenValHook { + err := k.Hooks().AfterValidatorCreated(ctx, edenValAddr) + if err != nil { + panic(err) + } + } + if shouldRunEdenBValHook { + err := k.Hooks().AfterValidatorCreated(ctx, edenBValAddr) + if err != nil { + panic(err) + } + } + } +} + +// ExportGenesis returns the module's exported genesis +func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { + genesis := types.DefaultGenesis() + genesis.Params = k.GetParams(ctx) + genesis.StakingSnapshots = k.GetAllElysStaked(ctx) + // this line is used by starport scaffolding # genesis/module/export + + return genesis +} diff --git a/x/estaking/keeper/genesis_test.go b/x/estaking/keeper/genesis_test.go new file mode 100644 index 000000000..a19e54fc2 --- /dev/null +++ b/x/estaking/keeper/genesis_test.go @@ -0,0 +1,27 @@ +package keeper_test + +import ( + "testing" + + tmproto "github.com/cometbft/cometbft/proto/tendermint/types" + simapp "github.com/elys-network/elys/app" + "github.com/elys-network/elys/testutil/nullify" + "github.com/elys-network/elys/x/estaking/types" + "github.com/stretchr/testify/require" +) + +func TestGenesis(t *testing.T) { + app := simapp.InitElysTestApp(true) + ctx := app.BaseApp.NewContext(true, tmproto.Header{}) + genesisState := types.GenesisState{ + Params: types.DefaultParams(), + } + + k := app.EstakingKeeper + k.InitGenesis(ctx, genesisState) + got := k.ExportGenesis(ctx) + require.NotNil(t, got) + + nullify.Fill(&genesisState) + nullify.Fill(got) +} diff --git a/x/estaking/keeper/hooks.go b/x/estaking/keeper/hooks.go new file mode 100644 index 000000000..5d17df2a2 --- /dev/null +++ b/x/estaking/keeper/hooks.go @@ -0,0 +1,134 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + commitmenttypes "github.com/elys-network/elys/x/commitment/types" + ptypes "github.com/elys-network/elys/x/parameter/types" +) + +// Process commitmentChanged hook +func (k Keeper) CommitmentChanged(ctx sdk.Context, creator string, amount sdk.Coins) error { + params := k.GetParams(ctx) + addr := sdk.MustAccAddressFromBech32(creator) + + if !amount.AmountOf(ptypes.Eden).IsZero() { + edenValAddr, err := sdk.ValAddressFromBech32(params.EdenCommitVal) + if err != nil { + return err + } + err = k.Keeper.Hooks().AfterDelegationModified(ctx, addr, edenValAddr) + if err != nil { + return err + } + } + + if !amount.AmountOf(ptypes.EdenB).IsZero() { + edenBValAddr, err := sdk.ValAddressFromBech32(params.EdenbCommitVal) + if err != nil { + return err + } + err = k.Keeper.Hooks().AfterDelegationModified(ctx, addr, edenBValAddr) + if err != nil { + return err + } + } + return nil +} + +// Process eden uncommitted hook +func (k Keeper) EdenUncommitted(ctx sdk.Context, creator string, amount sdk.Coin) error { + k.BurnEdenBFromEdenUncommitted(ctx, creator, amount.Amount) + return nil +} + +func (k Keeper) BeforeEdenInitialCommit(ctx sdk.Context, addr sdk.AccAddress) error { + params := k.GetParams(ctx) + edenValAddr, err := sdk.ValAddressFromBech32(params.EdenCommitVal) + if err != nil { + return err + } + err = k.Keeper.Hooks().BeforeDelegationCreated(ctx, addr, edenValAddr) + if err != nil { + return err + } + return nil +} + +func (k Keeper) BeforeEdenBInitialCommit(ctx sdk.Context, addr sdk.AccAddress) error { + params := k.GetParams(ctx) + edenBValAddr, err := sdk.ValAddressFromBech32(params.EdenbCommitVal) + if err != nil { + return err + } + err = k.Keeper.Hooks().BeforeDelegationCreated(ctx, addr, edenBValAddr) + if err != nil { + return err + } + return nil +} + +func (k Keeper) BeforeEdenCommitChange(ctx sdk.Context, addr sdk.AccAddress) error { + params := k.GetParams(ctx) + edenValAddr, err := sdk.ValAddressFromBech32(params.EdenCommitVal) + if err != nil { + panic(err) + } + err = k.Keeper.Hooks().BeforeDelegationSharesModified(ctx, addr, edenValAddr) + if err != nil { + return err + } + return nil +} + +func (k Keeper) BeforeEdenBCommitChange(ctx sdk.Context, addr sdk.AccAddress) error { + params := k.GetParams(ctx) + edenBValAddr, err := sdk.ValAddressFromBech32(params.EdenbCommitVal) + if err != nil { + panic(err) + } + err = k.Keeper.Hooks().BeforeDelegationSharesModified(ctx, addr, edenBValAddr) + if err != nil { + return err + } + return nil +} + +// ___________________________________________________________________________________________________ + +// Hooks wrapper struct for incentive keeper +type CommitmentHooks struct { + k Keeper +} + +var _ commitmenttypes.CommitmentHooks = CommitmentHooks{} + +// Return the wrapper struct +func (k Keeper) CommitmentHooks() CommitmentHooks { + return CommitmentHooks{k} +} + +// CommitmentChanged implements CommentmentHook +func (h CommitmentHooks) CommitmentChanged(ctx sdk.Context, creator string, amount sdk.Coins) error { + return h.k.CommitmentChanged(ctx, creator, amount) +} + +// EdenUncommitted implements EdenUncommitted +func (h CommitmentHooks) EdenUncommitted(ctx sdk.Context, creator string, amount sdk.Coin) error { + return h.k.EdenUncommitted(ctx, creator, amount) +} + +func (h CommitmentHooks) BeforeEdenInitialCommit(ctx sdk.Context, addr sdk.AccAddress) error { + return h.k.BeforeEdenInitialCommit(ctx, addr) +} + +func (h CommitmentHooks) BeforeEdenBInitialCommit(ctx sdk.Context, addr sdk.AccAddress) error { + return h.k.BeforeEdenBInitialCommit(ctx, addr) +} + +func (h CommitmentHooks) BeforeEdenCommitChange(ctx sdk.Context, addr sdk.AccAddress) error { + return h.k.BeforeEdenCommitChange(ctx, addr) +} + +func (h CommitmentHooks) BeforeEdenBCommitChange(ctx sdk.Context, addr sdk.AccAddress) error { + return h.k.BeforeEdenBCommitChange(ctx, addr) +} diff --git a/x/incentive/keeper/hooks_staking.go b/x/estaking/keeper/hooks_staking.go similarity index 97% rename from x/incentive/keeper/hooks_staking.go rename to x/estaking/keeper/hooks_staking.go index 4c463e7a6..7494e6ca2 100644 --- a/x/incentive/keeper/hooks_staking.go +++ b/x/estaking/keeper/hooks_staking.go @@ -13,7 +13,7 @@ func (k Keeper) BeforeDelegationCreated(ctx sdk.Context, delAddr sdk.AccAddress, } // Create an entity in commitment module - k.cmk.BeforeDelegationCreated(ctx, delAddr.String(), valAddr.String()) + k.commKeeper.BeforeDelegationCreated(ctx, delAddr.String(), valAddr.String()) return nil } diff --git a/x/estaking/keeper/keeper.go b/x/estaking/keeper/keeper.go new file mode 100644 index 000000000..1a482642e --- /dev/null +++ b/x/estaking/keeper/keeper.go @@ -0,0 +1,305 @@ +package keeper + +import ( + "fmt" + "time" + + errorsmod "cosmossdk.io/errors" + "cosmossdk.io/math" + "github.com/cometbft/cometbft/libs/log" + "github.com/cosmos/cosmos-sdk/codec" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" + stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + "github.com/elys-network/elys/x/estaking/types" + ptypes "github.com/elys-network/elys/x/parameter/types" +) + +type ( + Keeper struct { + *stakingkeeper.Keeper + cdc codec.BinaryCodec + storeKey storetypes.StoreKey + memKey storetypes.StoreKey + commKeeper types.CommitmentKeeper + distrKeeper types.DistrKeeper + tokenomicsKeeper types.TokenomicsKeeper + assetProfileKeeper types.AssetProfileKeeper + authority string + } +) + +var ( + EdenValPubKey cryptotypes.PubKey + EdenBValPubKey cryptotypes.PubKey + EdenValPubKeyAny *codectypes.Any + EdenBValPubKeyAny *codectypes.Any +) + +func init() { + // validator with duplicated pubkey fails and this is unique pubKey + EdenValPubKey := ed25519.GenPrivKeyFromSecret([]byte(ptypes.Eden)).PubKey() + pk1Any, err := codectypes.NewAnyWithValue(EdenValPubKey) + if err != nil { + panic(err) + } + EdenValPubKeyAny = pk1Any + + EdenBValPubKey := ed25519.GenPrivKeyFromSecret([]byte(ptypes.EdenB)).PubKey() + pk2Any, err := codectypes.NewAnyWithValue(EdenBValPubKey) + if err != nil { + panic(err) + } + EdenBValPubKeyAny = pk2Any +} + +func NewKeeper( + cdc codec.BinaryCodec, + storeKey, + memKey storetypes.StoreKey, + stakingKeeper *stakingkeeper.Keeper, + commKeeper types.CommitmentKeeper, + distrKeeper types.DistrKeeper, + assetProfileKeeper types.AssetProfileKeeper, + tokenomicsKeeper types.TokenomicsKeeper, + authority string, +) *Keeper { + return &Keeper{ + Keeper: stakingKeeper, + cdc: cdc, + storeKey: storeKey, + memKey: memKey, + commKeeper: commKeeper, + authority: authority, + distrKeeper: distrKeeper, + assetProfileKeeper: assetProfileKeeper, + tokenomicsKeeper: tokenomicsKeeper, + } +} + +func (k Keeper) Logger(ctx sdk.Context) log.Logger { + return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) +} + +func (k Keeper) TotalBondedTokens(ctx sdk.Context) math.Int { + bondedTokens := k.Keeper.TotalBondedTokens(ctx) + edenValidator := k.GetEdenValidator(ctx) + edenBValidator := k.GetEdenBValidator(ctx) + bondedTokens = bondedTokens.Add(edenValidator.GetTokens()).Add(edenBValidator.GetTokens()) + return bondedTokens +} + +func (k Keeper) GetEdenValidator(ctx sdk.Context) stakingtypes.ValidatorI { + params := k.GetParams(ctx) + commParams := k.commKeeper.GetParams(ctx) + totalEdenCommit := commParams.TotalCommitted.AmountOf(ptypes.Eden) + + return stakingtypes.Validator{ + OperatorAddress: params.EdenCommitVal, + ConsensusPubkey: EdenValPubKeyAny, + Jailed: false, + Status: stakingtypes.Bonded, + Tokens: totalEdenCommit, + DelegatorShares: sdk.NewDecFromInt(totalEdenCommit), + Description: stakingtypes.Description{ + Moniker: "EdenValidator", + }, + UnbondingHeight: 0, + UnbondingTime: time.Time{}, + Commission: stakingtypes.NewCommission(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()), + MinSelfDelegation: sdk.ZeroInt(), + UnbondingOnHoldRefCount: 0, + UnbondingIds: []uint64{}, + } +} + +func (k Keeper) GetEdenBValidator(ctx sdk.Context) stakingtypes.ValidatorI { + params := k.GetParams(ctx) + commParams := k.commKeeper.GetParams(ctx) + totalEdenBCommit := commParams.TotalCommitted.AmountOf(ptypes.EdenB) + + return stakingtypes.Validator{ + OperatorAddress: params.EdenbCommitVal, + ConsensusPubkey: EdenBValPubKeyAny, + Jailed: false, + Status: stakingtypes.Unbonded, + Tokens: totalEdenBCommit, + DelegatorShares: sdk.NewDecFromInt(totalEdenBCommit), + Description: stakingtypes.Description{ + Moniker: "EdenBValidator", + }, + UnbondingHeight: 0, + UnbondingTime: time.Time{}, + Commission: stakingtypes.NewCommission(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()), + MinSelfDelegation: sdk.ZeroInt(), + UnbondingOnHoldRefCount: 0, + UnbondingIds: []uint64{}, + } +} + +// extended staking keeper functionalities +func (k Keeper) Validator(ctx sdk.Context, address sdk.ValAddress) stakingtypes.ValidatorI { + params := k.GetParams(ctx) + if address.String() == params.EdenCommitVal { + return k.GetEdenValidator(ctx) + } + + if address.String() == params.EdenbCommitVal { + return k.GetEdenBValidator(ctx) + } + + val, found := k.GetValidator(ctx, address) + if !found { + return nil + } + + return val +} + +func (k Keeper) IterateValidators(ctx sdk.Context, + fn func(index int64, validator stakingtypes.ValidatorI) (stop bool)) { + params := k.GetParams(ctx) + if params.EdenCommitVal != "" { + edenVal := k.GetEdenValidator(ctx) + fn(0, edenVal) + } + + if params.EdenbCommitVal != "" { + edenBVal := k.GetEdenBValidator(ctx) + fn(0, edenBVal) + } + k.Keeper.IterateValidators(ctx, fn) +} + +func (k Keeper) Delegation(ctx sdk.Context, addrDel sdk.AccAddress, addrVal sdk.ValAddress) stakingtypes.DelegationI { + params := k.GetParams(ctx) + if addrVal.String() == params.EdenCommitVal { + commitments := k.commKeeper.GetCommitments(ctx, addrDel.String()) + edenCommit := commitments.GetCommittedAmountForDenom(ptypes.Eden) + return stakingtypes.Delegation{ + DelegatorAddress: addrDel.String(), + ValidatorAddress: addrVal.String(), + Shares: sdk.NewDecFromInt(edenCommit), + } + } + + if addrVal.String() == params.EdenbCommitVal { + commitments := k.commKeeper.GetCommitments(ctx, addrDel.String()) + edenBCommit := commitments.GetCommittedAmountForDenom(ptypes.EdenB) + return stakingtypes.Delegation{ + DelegatorAddress: addrDel.String(), + ValidatorAddress: addrVal.String(), + Shares: sdk.NewDecFromInt(edenBCommit), + } + } + + bond, ok := k.GetDelegation(ctx, addrDel, addrVal) + if !ok { + return nil + } + + return bond +} + +func (k Keeper) IterateDelegations(ctx sdk.Context, delegator sdk.AccAddress, + fn func(index int64, delegation stakingtypes.DelegationI) (stop bool)) { + + params := k.GetParams(ctx) + commitments := k.commKeeper.GetCommitments(ctx, delegator.String()) + edenCommit := commitments.GetCommittedAmountForDenom(ptypes.Eden) + edenBCommit := commitments.GetCommittedAmountForDenom(ptypes.EdenB) + if edenCommit.IsPositive() { + edenDel := stakingtypes.Delegation{ + DelegatorAddress: delegator.String(), + ValidatorAddress: params.EdenCommitVal, + Shares: sdk.NewDecFromInt(edenCommit), + } + if stop := fn(0, edenDel); stop { + return + } + } + if edenBCommit.IsPositive() { + edenBDel := stakingtypes.Delegation{ + DelegatorAddress: delegator.String(), + ValidatorAddress: params.EdenbCommitVal, + Shares: sdk.NewDecFromInt(edenBCommit), + } + if stop := fn(0, edenBDel); stop { + return + } + } + k.Keeper.IterateDelegations(ctx, delegator, fn) +} + +// iterate through the bonded validator set and perform the provided function +func (k Keeper) IterateBondedValidatorsByPower(ctx sdk.Context, fn func(index int64, validator stakingtypes.ValidatorI) (stop bool)) { + commParams := k.commKeeper.GetParams(ctx) + + if commParams.TotalCommitted.AmountOf(ptypes.Eden).IsPositive() { + edenValidator := k.GetEdenValidator(ctx) + if stop := fn(0, edenValidator); stop { + return + } + } + + if commParams.TotalCommitted.AmountOf(ptypes.EdenB).IsPositive() { + edenBValidator := k.GetEdenBValidator(ctx) + if stop := fn(0, edenBValidator); stop { + return + } + } + k.Keeper.IterateBondedValidatorsByPower(ctx, fn) +} + +func (k Keeper) Slash(ctx sdk.Context, consAddr sdk.ConsAddress, infractionHeight int64, power int64, slashFactor sdk.Dec) math.Int { + return k.Keeper.Slash(ctx, consAddr, infractionHeight, power, slashFactor) +} + +func (k Keeper) SlashWithInfractionReason(ctx sdk.Context, consAddr sdk.ConsAddress, infractionHeight int64, power int64, slashFactor sdk.Dec, infraction stakingtypes.Infraction) math.Int { + return k.Keeper.SlashWithInfractionReason(ctx, consAddr, infractionHeight, power, slashFactor, infraction) +} + +func (k Keeper) WithdrawEdenBReward(ctx sdk.Context, addr sdk.AccAddress) error { + params := k.GetParams(ctx) + valAddr, err := sdk.ValAddressFromBech32(params.EdenbCommitVal) + if err != nil { + return err + } + _, err = k.distrKeeper.WithdrawDelegationRewards(ctx, addr, valAddr) + if err != nil { + return err + } + + return nil +} + +func (k Keeper) DelegationRewards(ctx sdk.Context, delegatorAddress string, validatorAddress string) (sdk.DecCoins, error) { + valAdr, err := sdk.ValAddressFromBech32(validatorAddress) + if err != nil { + return nil, err + } + + val := k.Validator(ctx, valAdr) + if val == nil { + return nil, errorsmod.Wrap(distrtypes.ErrNoValidatorExists, validatorAddress) + } + + delAdr, err := sdk.AccAddressFromBech32(delegatorAddress) + if err != nil { + return nil, err + } + + del := k.Delegation(ctx, delAdr, valAdr) + if del == nil { + return nil, distrtypes.ErrNoDelegationExists + } + + endingPeriod := k.distrKeeper.IncrementValidatorPeriod(ctx, val) + rewards := k.distrKeeper.CalculateDelegationRewards(ctx, val, del, endingPeriod) + return rewards, nil +} diff --git a/x/incentive/keeper/keeper_burn_edenB.go b/x/estaking/keeper/keeper_burn_edenB.go similarity index 73% rename from x/incentive/keeper/keeper_burn_edenB.go rename to x/estaking/keeper/keeper_burn_edenB.go index 606219a6e..18c4d121f 100644 --- a/x/incentive/keeper/keeper_burn_edenB.go +++ b/x/estaking/keeper/keeper_burn_edenB.go @@ -8,9 +8,18 @@ import ( // Burn EdenBoost from Elys unstaked func (k Keeper) BurnEdenBFromElysUnstaking(ctx sdk.Context, delegator sdk.AccAddress) { - delAddr := delegator.String() + // Claim EdenB rewards + cacheCtx, write := ctx.CacheContext() + err := k.WithdrawEdenBReward(cacheCtx, delegator) + if err != nil { + k.Logger(ctx).Error(err.Error()) + } else { + write() + } + // Get commitments - commitments := k.cmk.GetCommitments(ctx, delAddr) + delAddr := delegator.String() + commitments := k.commKeeper.GetCommitments(ctx, delAddr) // Get previous amount prevElysStaked := k.GetElysStaked(ctx, delAddr) @@ -31,11 +40,10 @@ func (k Keeper) BurnEdenBFromElysUnstaking(ctx sdk.Context, delegator sdk.AccAdd // Total EdenB amount edenBCommitted := commitments.GetCommittedAmountForDenom(ptypes.EdenB) - edenBUnclaimed := commitments.GetRewardUnclaimedForDenom(ptypes.EdenB) edenBClaimed := commitments.GetClaimedForDenom(ptypes.EdenB) // Total EdenB amount - totalEdenB := edenBCommitted.Add(edenBUnclaimed).Add(edenBClaimed) + totalEdenB := edenBCommitted.Add(edenBClaimed) // Unstaked unstakedElys := prevElysStaked.Sub(delAmount) @@ -48,32 +56,41 @@ func (k Keeper) BurnEdenBFromElysUnstaking(ctx sdk.Context, delegator sdk.AccAdd edenBToBurn = unstakedElysDec.Quo(edenCommittedAndElysStakedDec).Mul(totalEdenBDec) } // Burn EdenB in commitment module - commitment, err := k.cmk.BurnEdenBoost(ctx, delAddr, ptypes.EdenB, edenBToBurn.TruncateInt()) + commitment, err := k.commKeeper.BurnEdenBoost(ctx, delAddr, ptypes.EdenB, edenBToBurn.TruncateInt()) if err != nil { k.Logger(ctx).Error("EdenB burn failure", err) } else { - k.cmk.SetCommitments(ctx, commitment) + k.commKeeper.SetCommitments(ctx, commitment) } } // Burn EdenBoost from Eden unclaimed func (k Keeper) BurnEdenBFromEdenUncommitted(ctx sdk.Context, delegator string, uncommitAmt math.Int) error { + // Claim EdenB rewards + delAddr := sdk.MustAccAddressFromBech32(delegator) + cacheCtx, write := ctx.CacheContext() + err := k.WithdrawEdenBReward(cacheCtx, delAddr) + if err != nil { + k.Logger(ctx).Error(err.Error()) + } else { + write() + } + // Get elys staked amount elysStaked := k.GetElysStaked(ctx, delegator) if elysStaked.IsZero() { return nil } - commitments := k.cmk.GetCommitments(ctx, delegator) + commitments := k.commKeeper.GetCommitments(ctx, delegator) edenCommitted := commitments.GetCommittedAmountForDenom(ptypes.Eden) // Total EdenB amount edenBCommitted := commitments.GetCommittedAmountForDenom(ptypes.EdenB) - edenBUnclaimed := commitments.GetRewardUnclaimedForDenom(ptypes.EdenB) edenBClaimed := commitments.GetClaimedForDenom(ptypes.EdenB) // Total EdenB amount - totalEdenB := edenBCommitted.Add(edenBUnclaimed).Add(edenBClaimed) + totalEdenB := edenBCommitted.Add(edenBClaimed) unclaimedAmtDec := sdk.NewDecFromInt(uncommitAmt) // This formula shud be applied before eden uncommitted or elys staked is removed from eden committed amount and elys staked amount respectively @@ -87,8 +104,8 @@ func (k Keeper) BurnEdenBFromEdenUncommitted(ctx sdk.Context, delegator string, } // Burn EdenB ( Deduction EdenB in commitment module) - commitment, err := k.cmk.BurnEdenBoost(ctx, delegator, ptypes.EdenB, edenBToBurn.TruncateInt()) - k.cmk.SetCommitments(ctx, commitment) + commitment, err := k.commKeeper.BurnEdenBoost(ctx, delegator, ptypes.EdenB, edenBToBurn.TruncateInt()) + k.commKeeper.SetCommitments(ctx, commitment) return err } diff --git a/x/incentive/keeper/keeper_burn_edenB_test.go b/x/estaking/keeper/keeper_burn_edenB_test.go similarity index 64% rename from x/incentive/keeper/keeper_burn_edenB_test.go rename to x/estaking/keeper/keeper_burn_edenB_test.go index 9d660776e..df6a9b0b2 100644 --- a/x/incentive/keeper/keeper_burn_edenB_test.go +++ b/x/estaking/keeper/keeper_burn_edenB_test.go @@ -15,9 +15,9 @@ import ( func TestBurnEdenBFromElysUnstaked(t *testing.T) { app, genAccount, valAddr := simapp.InitElysTestAppWithGenAccount() - ctx := app.BaseApp.NewContext(initChain, tmproto.Header{}) + ctx := app.BaseApp.NewContext(true, tmproto.Header{}) - ik, sk := app.IncentiveKeeper, app.StakingKeeper + ek, sk := app.EstakingKeeper, app.StakingKeeper var committed sdk.Coins var unclaimed sdk.Coins @@ -45,14 +45,10 @@ func TestBurnEdenBFromElysUnstaked(t *testing.T) { require.NoError(t, err) // Add testing commitment - simapp.AddTestCommitment(app, ctx, genAccount, committed, unclaimed) - - commitment := app.CommitmentKeeper.GetCommitments(ctx, genAccount.String()) - require.Equal(t, commitment.RewardsUnclaimed[1].Denom, ptypes.EdenB) - require.Equal(t, commitment.RewardsUnclaimed[1].Amount, sdk.NewInt(20000)) + simapp.AddTestCommitment(app, ctx, genAccount, committed) // Take elys staked snapshot - ik.TakeDelegationSnapshot(ctx, genAccount.String()) + ek.TakeDelegationSnapshot(ctx, genAccount.String()) // burn amount = 100000 (unbonded amt) / (1000000 (elys staked) + 10000 (Eden committed)) * (20000 EdenB + 5000 EdenB committed) unbondAmt, err := sk.Unbond(ctx, genAccount, valAddr, sdk.NewDecWithPrec(10, 2)) @@ -60,18 +56,14 @@ func TestBurnEdenBFromElysUnstaked(t *testing.T) { require.NoError(t, err) // Process EdenB burn operation - ik.EndBlocker(ctx) - - commitment = app.CommitmentKeeper.GetCommitments(ctx, genAccount.String()) - require.Equal(t, commitment.RewardsUnclaimed[1].Denom, ptypes.EdenB) - require.Equal(t, commitment.RewardsUnclaimed[1].Amount, sdk.NewInt(17525)) + ek.EndBlocker(ctx) } func TestBurnEdenBFromEdenUncommitted(t *testing.T) { app, genAccount, _ := simapp.InitElysTestAppWithGenAccount() - ctx := app.BaseApp.NewContext(initChain, tmproto.Header{}) + ctx := app.BaseApp.NewContext(true, tmproto.Header{}) - ik, cmk := app.IncentiveKeeper, app.CommitmentKeeper + ek, cmk := app.EstakingKeeper, app.CommitmentKeeper var committed sdk.Coins var unclaimed sdk.Coins @@ -92,37 +84,29 @@ func TestBurnEdenBFromEdenUncommitted(t *testing.T) { uedenBToken = sdk.NewCoin(ptypes.EdenB, sdk.NewInt(5000)) committed = committed.Add(uedenToken, uedenBToken) - // Mint coins - err = app.BankKeeper.MintCoins(ctx, ctypes.ModuleName, committed) - require.NoError(t, err) - err = app.BankKeeper.SendCoinsFromModuleToAccount(ctx, ctypes.ModuleName, genAccount, committed) - require.NoError(t, err) - - // Add testing commitment - simapp.AddTestCommitment(app, ctx, genAccount, committed, unclaimed) + // Set assetprofile entry for denom + app.AssetprofileKeeper.SetEntry(ctx, aptypes.Entry{BaseDenom: ptypes.Eden, CommitEnabled: true, WithdrawEnabled: true}) commitment := app.CommitmentKeeper.GetCommitments(ctx, genAccount.String()) - require.Equal(t, commitment.RewardsUnclaimed[1].Denom, ptypes.EdenB) - require.Equal(t, commitment.RewardsUnclaimed[1].Amount, sdk.NewInt(20000)) + commitment.Claimed = commitment.Claimed.Add(committed...) + app.CommitmentKeeper.SetCommitments(ctx, commitment) - // Track Elys staked amount - ik.EndBlocker(ctx) + msgServer := commkeeper.NewMsgServerImpl(cmk) + _, err = msgServer.CommitClaimedRewards(ctx, &ctypes.MsgCommitClaimedRewards{ + Creator: genAccount.String(), + Amount: sdk.NewInt(1000), + Denom: ptypes.Eden, + }) + require.NoError(t, err) - // Set assetprofile entry for denom - app.AssetprofileKeeper.SetEntry(ctx, aptypes.Entry{BaseDenom: ptypes.Eden, CommitEnabled: true, WithdrawEnabled: true}) + // Track Elys staked amount + ek.EndBlocker(ctx) - msg := &ctypes.MsgUncommitTokens{ + // Uncommit tokens + _, err = msgServer.UncommitTokens(sdk.WrapSDKContext(ctx), &ctypes.MsgUncommitTokens{ Creator: genAccount.String(), Amount: sdk.NewInt(1000), Denom: ptypes.Eden, - } - - msgServer := commkeeper.NewMsgServerImpl(cmk) - _, err = msgServer.UncommitTokens(sdk.WrapSDKContext(ctx), msg) + }) require.NoError(t, err) - - // burn amount = 1000 (unclaimed amt) / (1000000 (elys staked) + 10000 (Eden committed)) * (20000 EdenB + 5000 EdenB committed) - commitment = app.CommitmentKeeper.GetCommitments(ctx, genAccount.String()) - require.Equal(t, commitment.RewardsUnclaimed[1].Denom, ptypes.EdenB) - require.Equal(t, commitment.RewardsUnclaimed[1].Amount, sdk.NewInt(19976)) } diff --git a/x/incentive/keeper/keeper_shares.go b/x/estaking/keeper/keeper_shares.go similarity index 51% rename from x/incentive/keeper/keeper_shares.go rename to x/estaking/keeper/keeper_shares.go index 9aa3b4d13..0a1af3e33 100644 --- a/x/incentive/keeper/keeper_shares.go +++ b/x/estaking/keeper/keeper_shares.go @@ -1,26 +1,12 @@ package keeper import ( - "fmt" gomath "math" "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" - ammtypes "github.com/elys-network/elys/x/amm/types" ) -// Calculate total share of staking -func (k Keeper) CalcTotalShareOfStaking(amount math.Int) sdk.Dec { - // Total staked = Elys staked + Eden Committed + Eden boost Committed - totalStaked := k.tci.TotalElysBonded.Add(k.tci.TotalEdenEdenBoostCommitted) - if totalStaked.LTE(sdk.ZeroInt()) { - return sdk.ZeroDec() - } - - // Share = Amount / Total Staked - return sdk.NewDecFromInt(amount).QuoInt(totalStaked) -} - // Calculate the delegated amount func (k Keeper) CalcDelegationAmount(ctx sdk.Context, delegator string) math.Int { // Derivate bech32 based delegator address @@ -34,12 +20,12 @@ func (k Keeper) CalcDelegationAmount(ctx sdk.Context, delegator string) math.Int delAmount := sdk.ZeroDec() // Get all delegations - delegations := k.stk.GetDelegatorDelegations(ctx, delAddr, gomath.MaxUint16) + delegations := k.Keeper.GetDelegatorDelegations(ctx, delAddr, gomath.MaxUint16) for _, del := range delegations { // Get validator address valAddr := del.GetValidatorAddr() // Get validator - val := k.stk.Validator(ctx, valAddr) + val := k.Keeper.Validator(ctx, valAddr) shares := del.GetShares() tokens := val.TokensFromSharesTruncated(shares) @@ -62,12 +48,12 @@ func (k Keeper) CalcBondedDelegationAmount(ctx sdk.Context, delegator string) ma delAmount := sdk.ZeroDec() // Get all delegations - delegations := k.stk.GetDelegatorDelegations(ctx, delAddr, gomath.MaxUint16) + delegations := k.Keeper.GetDelegatorDelegations(ctx, delAddr, gomath.MaxUint16) for _, del := range delegations { // Get validator address valAddr := del.GetValidatorAddr() // Get validator - val := k.stk.Validator(ctx, valAddr) + val := k.Keeper.Validator(ctx, valAddr) if !val.IsBonded() { continue @@ -79,29 +65,3 @@ func (k Keeper) CalcBondedDelegationAmount(ctx sdk.Context, delegator string) ma return delAmount.TruncateInt() } - -// Calculate the amm pool ratio -func (k Keeper) CalculatePoolRatio(ctx sdk.Context, pool *ammtypes.Pool) string { - weightString := "" - totalWeight := sdk.ZeroInt() - for _, asset := range pool.PoolAssets { - totalWeight = totalWeight.Add(asset.Weight) - } - - if totalWeight.IsZero() { - return weightString - } - - for _, asset := range pool.PoolAssets { - weight := sdk.NewDecFromInt(asset.Weight).QuoInt(totalWeight).MulInt(sdk.NewInt(100)).TruncateInt64() - weightString = fmt.Sprintf("%s : %d", weightString, weight) - } - - // remove prefix " : " 3 characters - if len(weightString) > 1 { - weightString = weightString[3:] - } - - // returns pool weight string - return weightString -} diff --git a/x/estaking/keeper/keeper_shares_test.go b/x/estaking/keeper/keeper_shares_test.go new file mode 100644 index 000000000..a6e790d14 --- /dev/null +++ b/x/estaking/keeper/keeper_shares_test.go @@ -0,0 +1,26 @@ +package keeper_test + +import ( + "testing" + + tmproto "github.com/cometbft/cometbft/proto/tendermint/types" + sdk "github.com/cosmos/cosmos-sdk/types" + simapp "github.com/elys-network/elys/app" + "github.com/stretchr/testify/require" +) + +func TestCalcDelegationAmount(t *testing.T) { + app, genAccount, _ := simapp.InitElysTestAppWithGenAccount() + ctx := app.BaseApp.NewContext(true, tmproto.Header{}) + + ek := app.EstakingKeeper + addr := simapp.AddTestAddrs(app, ctx, 1, sdk.NewInt(1000)) + + // Check with non-delegator + delegatedAmount := ek.CalcDelegationAmount(ctx, addr[0].String()) + require.Equal(t, delegatedAmount, sdk.ZeroInt()) + + // Check with genesis account (delegator) + delegatedAmount = ek.CalcDelegationAmount(ctx, genAccount.String()) + require.Equal(t, delegatedAmount, sdk.DefaultPowerReduction) +} diff --git a/x/estaking/keeper/keeper_test.go b/x/estaking/keeper/keeper_test.go new file mode 100644 index 000000000..ed6d341fd --- /dev/null +++ b/x/estaking/keeper/keeper_test.go @@ -0,0 +1,85 @@ +package keeper_test + +import ( + "testing" + + tmproto "github.com/cometbft/cometbft/proto/tendermint/types" + sdk "github.com/cosmos/cosmos-sdk/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + simapp "github.com/elys-network/elys/app" + assetprofiletypes "github.com/elys-network/elys/x/assetprofile/types" + commitmentkeeper "github.com/elys-network/elys/x/commitment/keeper" + commitmenttypes "github.com/elys-network/elys/x/commitment/types" + ptypes "github.com/elys-network/elys/x/parameter/types" + "github.com/stretchr/testify/require" +) + +func TestEstakingExtendedFunctions(t *testing.T) { + app := simapp.InitElysTestApp(true) + ctx := app.BaseApp.NewContext(true, tmproto.Header{}) + + stakingKeeper := app.StakingKeeper + estakingKeeper := app.EstakingKeeper + + // create validator with 50% commission + validators := stakingKeeper.GetAllValidators(ctx) + require.True(t, len(validators) > 0) + valAddr := validators[0].GetOperator() + delegations := stakingKeeper.GetValidatorDelegations(ctx, valAddr) + require.True(t, len(delegations) > 0) + addr := sdk.MustAccAddressFromBech32(delegations[0].DelegatorAddress) + + totalBonded := estakingKeeper.TotalBondedTokens(ctx) + require.Equal(t, totalBonded.String(), "1000000") + + // set commitments + commitments := app.CommitmentKeeper.GetCommitments(ctx, addr.String()) + commitments.AddClaimed(sdk.NewInt64Coin(ptypes.Eden, 1000_000)) + app.CommitmentKeeper.SetCommitments(ctx, commitments) + app.AssetprofileKeeper.SetEntry(ctx, assetprofiletypes.Entry{ + BaseDenom: ptypes.Eden, + Denom: ptypes.Eden, + Decimals: 6, + CommitEnabled: true, + WithdrawEnabled: true, + }) + commitmentMsgServer := commitmentkeeper.NewMsgServerImpl(app.CommitmentKeeper) + _, err := commitmentMsgServer.CommitClaimedRewards(sdk.WrapSDKContext(ctx), &commitmenttypes.MsgCommitClaimedRewards{ + Creator: addr.String(), + Denom: ptypes.Eden, + Amount: sdk.NewInt(1000_000), + }) + require.Nil(t, err) + + totalBonded = estakingKeeper.TotalBondedTokens(ctx) + require.Equal(t, totalBonded.String(), "2000000") + + edenVal := estakingKeeper.GetEdenValidator(ctx) + require.Equal(t, edenVal.GetMoniker(), "EdenValidator") + + edenBVal := estakingKeeper.GetEdenBValidator(ctx) + require.Equal(t, edenBVal.GetMoniker(), "EdenBValidator") + + require.Equal(t, estakingKeeper.Validator(ctx, edenVal.GetOperator()), edenVal) + require.Equal(t, estakingKeeper.Validator(ctx, edenBVal.GetOperator()), edenBVal) + + edenDel := estakingKeeper.Delegation(ctx, addr, edenVal.GetOperator()) + require.Equal(t, edenDel.GetShares(), sdk.NewDec(1000_000)) + + edenBDel := estakingKeeper.Delegation(ctx, addr, edenBVal.GetOperator()) + require.Equal(t, edenBDel.GetShares(), sdk.NewDec(0)) + + numDelegations := int64(0) + estakingKeeper.IterateDelegations(ctx, addr, func(index int64, delegation stakingtypes.DelegationI) (stop bool) { + numDelegations++ + return false + }) + require.Equal(t, numDelegations, int64(2)) + + numBondedValidators := int64(0) + estakingKeeper.IterateBondedValidatorsByPower(ctx, func(index int64, delegation stakingtypes.ValidatorI) (stop bool) { + numBondedValidators++ + return false + }) + require.Equal(t, numBondedValidators, int64(2)) +} diff --git a/x/estaking/keeper/msg_server.go b/x/estaking/keeper/msg_server.go new file mode 100644 index 000000000..19e90478d --- /dev/null +++ b/x/estaking/keeper/msg_server.go @@ -0,0 +1,70 @@ +package keeper + +import ( + "context" + + errorsmod "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + "github.com/elys-network/elys/x/estaking/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{} + +func (k msgServer) UpdateParams(goCtx context.Context, req *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) { + if k.authority != req.Authority { + return nil, errorsmod.Wrapf(govtypes.ErrInvalidSigner, "invalid authority; expected %s, got %s", k.authority, req.Authority) + } + + ctx := sdk.UnwrapSDKContext(goCtx) + k.SetParams(ctx, req.Params) + + return &types.MsgUpdateParamsResponse{}, nil +} + +func (k msgServer) WithdrawReward(goCtx context.Context, msg *types.MsgWithdrawReward) (*types.MsgWithdrawRewardResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + delAddr := sdk.MustAccAddressFromBech32(msg.DelegatorAddress) + valAddr, err := sdk.ValAddressFromBech32(msg.ValidatorAddress) + if err != nil { + return nil, err + } + amount, err := k.distrKeeper.WithdrawDelegationRewards(ctx, delAddr, valAddr) + if err != nil { + return nil, err + } + + return &types.MsgWithdrawRewardResponse{Amount: amount}, nil +} + +func (k msgServer) WithdrawElysStakingRewards(goCtx context.Context, msg *types.MsgWithdrawElysStakingRewards) (*types.MsgWithdrawElysStakingRewardsResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + delAddr := sdk.MustAccAddressFromBech32(msg.DelegatorAddress) + delegations := k.Keeper.Keeper.GetAllDelegations(ctx) + rewards := sdk.Coins{} + for _, del := range delegations { + valAddr, err := sdk.ValAddressFromBech32(del.ValidatorAddress) + if err != nil { + return nil, err + } + amount, err := k.distrKeeper.WithdrawDelegationRewards(ctx, delAddr, valAddr) + if err != nil { + return nil, err + } + rewards = rewards.Add(amount...) + } + + return &types.MsgWithdrawElysStakingRewardsResponse{Amount: rewards}, nil +} diff --git a/x/estaking/keeper/msg_server_test.go b/x/estaking/keeper/msg_server_test.go new file mode 100644 index 000000000..910e9747e --- /dev/null +++ b/x/estaking/keeper/msg_server_test.go @@ -0,0 +1,248 @@ +package keeper_test + +import ( + "context" + "testing" + + tmproto "github.com/cometbft/cometbft/proto/tendermint/types" + sdk "github.com/cosmos/cosmos-sdk/types" + disttypes "github.com/cosmos/cosmos-sdk/x/distribution/types" + minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" + simapp "github.com/elys-network/elys/app" + keepertest "github.com/elys-network/elys/testutil/keeper" + assetprofiletypes "github.com/elys-network/elys/x/assetprofile/types" + commitmentkeeper "github.com/elys-network/elys/x/commitment/keeper" + commitmenttypes "github.com/elys-network/elys/x/commitment/types" + "github.com/elys-network/elys/x/estaking/keeper" + "github.com/elys-network/elys/x/estaking/types" + ptypes "github.com/elys-network/elys/x/parameter/types" + "github.com/stretchr/testify/require" +) + +func setupMsgServer(t testing.TB) (types.MsgServer, context.Context) { + k, ctx := keepertest.EstakingKeeper(t) + return keeper.NewMsgServerImpl(*k), sdk.WrapSDKContext(ctx) +} + +func TestMsgServer(t *testing.T) { + ms, ctx := setupMsgServer(t) + require.NotNil(t, ms) + require.NotNil(t, ctx) +} + +func TestWithdrawElysStakingRewards(t *testing.T) { + app := simapp.InitElysTestApp(true) + ctx := app.BaseApp.NewContext(true, tmproto.Header{}) + + bankKeeper := app.BankKeeper + stakingKeeper := app.StakingKeeper + distrKeeper := app.DistrKeeper + estakingKeeper := app.EstakingKeeper + + // create validator with 50% commission + validators := stakingKeeper.GetAllValidators(ctx) + require.True(t, len(validators) > 0) + valAddr := validators[0].GetOperator() + delegations := stakingKeeper.GetValidatorDelegations(ctx, valAddr) + require.True(t, len(delegations) > 0) + addr := sdk.MustAccAddressFromBech32(delegations[0].DelegatorAddress) + + // next block + ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 1) + + // allocate some rewards + initial := sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction) + tokens := sdk.DecCoins{sdk.NewDecCoin(sdk.DefaultBondDenom, initial)} + + initialCoins := sdk.Coins{sdk.NewCoin(sdk.DefaultBondDenom, initial)} + err := bankKeeper.MintCoins(ctx, minttypes.ModuleName, initialCoins) + require.Nil(t, err) + err = bankKeeper.SendCoinsFromModuleToModule(ctx, minttypes.ModuleName, disttypes.ModuleName, initialCoins) + require.Nil(t, err) + + distrKeeper.AllocateTokensToValidator(ctx, validators[0], tokens) + + // historical count should be 4 (initial + latest for delegation) + require.Equal(t, uint64(4), distrKeeper.GetValidatorHistoricalReferenceCount(ctx)) + + // withdraw single rewards + msgServer := keeper.NewMsgServerImpl(estakingKeeper) + res, err := msgServer.WithdrawElysStakingRewards(ctx, &types.MsgWithdrawElysStakingRewards{ + DelegatorAddress: addr.String(), + }) + require.Nil(t, err) + require.NotEmpty(t, res.Amount.String()) +} + +func TestWithdrawReward_NormalValidator(t *testing.T) { + app := simapp.InitElysTestApp(true) + ctx := app.BaseApp.NewContext(true, tmproto.Header{}) + + bankKeeper := app.BankKeeper + stakingKeeper := app.StakingKeeper + distrKeeper := app.DistrKeeper + estakingKeeper := app.EstakingKeeper + + // create validator with 50% commission + validators := stakingKeeper.GetAllValidators(ctx) + require.True(t, len(validators) > 0) + valAddr := validators[0].GetOperator() + delegations := stakingKeeper.GetValidatorDelegations(ctx, valAddr) + require.True(t, len(delegations) > 0) + addr := sdk.MustAccAddressFromBech32(delegations[0].DelegatorAddress) + + // next block + ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 1) + + // allocate some rewards + initial := sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction) + tokens := sdk.DecCoins{sdk.NewDecCoin(sdk.DefaultBondDenom, initial)} + + initialCoins := sdk.Coins{sdk.NewCoin(sdk.DefaultBondDenom, initial)} + err := bankKeeper.MintCoins(ctx, minttypes.ModuleName, initialCoins) + require.Nil(t, err) + err = bankKeeper.SendCoinsFromModuleToModule(ctx, minttypes.ModuleName, disttypes.ModuleName, initialCoins) + require.Nil(t, err) + + distrKeeper.AllocateTokensToValidator(ctx, validators[0], tokens) + + // historical count should be 4 (initial + latest for delegation) + require.Equal(t, uint64(4), distrKeeper.GetValidatorHistoricalReferenceCount(ctx)) + + // withdraw single rewards + msgServer := keeper.NewMsgServerImpl(estakingKeeper) + res, err := msgServer.WithdrawReward(ctx, &types.MsgWithdrawReward{ + DelegatorAddress: addr.String(), + ValidatorAddress: valAddr.String(), + }) + require.Nil(t, err) + require.NotEmpty(t, res.Amount.String()) +} + +func TestWithdrawReward_EdenValidator(t *testing.T) { + app := simapp.InitElysTestApp(true) + ctx := app.BaseApp.NewContext(true, tmproto.Header{}) + + bankKeeper := app.BankKeeper + stakingKeeper := app.StakingKeeper + distrKeeper := app.DistrKeeper + estakingKeeper := app.EstakingKeeper + + // create validator with 50% commission + validators := stakingKeeper.GetAllValidators(ctx) + require.True(t, len(validators) > 0) + valAddr := validators[0].GetOperator() + delegations := stakingKeeper.GetValidatorDelegations(ctx, valAddr) + require.True(t, len(delegations) > 0) + addr := sdk.MustAccAddressFromBech32(delegations[0].DelegatorAddress) + + // set commitments + commitments := app.CommitmentKeeper.GetCommitments(ctx, addr.String()) + commitments.AddClaimed(sdk.NewInt64Coin(ptypes.Eden, 1000_000)) + app.CommitmentKeeper.SetCommitments(ctx, commitments) + app.AssetprofileKeeper.SetEntry(ctx, assetprofiletypes.Entry{ + BaseDenom: ptypes.Eden, + Denom: ptypes.Eden, + Decimals: 6, + CommitEnabled: true, + WithdrawEnabled: true, + }) + commitmentMsgServer := commitmentkeeper.NewMsgServerImpl(app.CommitmentKeeper) + _, err := commitmentMsgServer.CommitClaimedRewards(sdk.WrapSDKContext(ctx), &commitmenttypes.MsgCommitClaimedRewards{ + Creator: addr.String(), + Denom: ptypes.Eden, + Amount: sdk.NewInt(1000_000), + }) + require.Nil(t, err) + + // next block + ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 1) + + // allocate some rewards + initial := sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction) + tokens := sdk.DecCoins{sdk.NewDecCoin(sdk.DefaultBondDenom, initial)} + + initialCoins := sdk.Coins{sdk.NewCoin(sdk.DefaultBondDenom, initial)} + err = bankKeeper.MintCoins(ctx, minttypes.ModuleName, initialCoins) + require.Nil(t, err) + err = bankKeeper.SendCoinsFromModuleToModule(ctx, minttypes.ModuleName, disttypes.ModuleName, initialCoins) + require.Nil(t, err) + + distrKeeper.AllocateTokensToValidator(ctx, validators[0], tokens) + + // historical count should be 5 (initial + latest for delegation) + require.Equal(t, uint64(5), distrKeeper.GetValidatorHistoricalReferenceCount(ctx)) + + // withdraw single rewards + msgServer := keeper.NewMsgServerImpl(estakingKeeper) + res, err := msgServer.WithdrawReward(ctx, &types.MsgWithdrawReward{ + DelegatorAddress: addr.String(), + ValidatorAddress: estakingKeeper.GetParams(ctx).EdenCommitVal, + }) + require.Nil(t, err) + require.NotEmpty(t, res.Amount.String()) +} + +func TestWithdrawReward_EdenBValidator(t *testing.T) { + app := simapp.InitElysTestApp(true) + ctx := app.BaseApp.NewContext(true, tmproto.Header{}) + + bankKeeper := app.BankKeeper + stakingKeeper := app.StakingKeeper + distrKeeper := app.DistrKeeper + estakingKeeper := app.EstakingKeeper + + // create validator with 50% commission + validators := stakingKeeper.GetAllValidators(ctx) + require.True(t, len(validators) > 0) + valAddr := validators[0].GetOperator() + delegations := stakingKeeper.GetValidatorDelegations(ctx, valAddr) + require.True(t, len(delegations) > 0) + addr := sdk.MustAccAddressFromBech32(delegations[0].DelegatorAddress) + + // set commitments + commitments := app.CommitmentKeeper.GetCommitments(ctx, addr.String()) + commitments.AddClaimed(sdk.NewInt64Coin(ptypes.EdenB, 1000_000)) + app.CommitmentKeeper.SetCommitments(ctx, commitments) + app.AssetprofileKeeper.SetEntry(ctx, assetprofiletypes.Entry{ + BaseDenom: ptypes.EdenB, + Denom: ptypes.EdenB, + Decimals: 6, + CommitEnabled: true, + WithdrawEnabled: true, + }) + commitmentMsgServer := commitmentkeeper.NewMsgServerImpl(app.CommitmentKeeper) + _, err := commitmentMsgServer.CommitClaimedRewards(sdk.WrapSDKContext(ctx), &commitmenttypes.MsgCommitClaimedRewards{ + Creator: addr.String(), + Denom: ptypes.EdenB, + Amount: sdk.NewInt(1000_000), + }) + require.Nil(t, err) + + // next block + ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 1) + + // allocate some rewards + initial := sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction) + tokens := sdk.DecCoins{sdk.NewDecCoin(sdk.DefaultBondDenom, initial)} + + initialCoins := sdk.Coins{sdk.NewCoin(sdk.DefaultBondDenom, initial)} + err = bankKeeper.MintCoins(ctx, minttypes.ModuleName, initialCoins) + require.Nil(t, err) + err = bankKeeper.SendCoinsFromModuleToModule(ctx, minttypes.ModuleName, disttypes.ModuleName, initialCoins) + require.Nil(t, err) + + distrKeeper.AllocateTokensToValidator(ctx, validators[0], tokens) + + // historical count should be 5 (initial + latest for delegation) + require.Equal(t, uint64(5), distrKeeper.GetValidatorHistoricalReferenceCount(ctx)) + + // withdraw single rewards + msgServer := keeper.NewMsgServerImpl(estakingKeeper) + res, err := msgServer.WithdrawReward(ctx, &types.MsgWithdrawReward{ + DelegatorAddress: addr.String(), + ValidatorAddress: estakingKeeper.GetParams(ctx).EdenbCommitVal, + }) + require.Nil(t, err) + require.NotEmpty(t, res.Amount.String()) +} diff --git a/x/estaking/keeper/params.go b/x/estaking/keeper/params.go new file mode 100644 index 000000000..a827ca109 --- /dev/null +++ b/x/estaking/keeper/params.go @@ -0,0 +1,26 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/elys-network/elys/x/estaking/types" +) + +// GetParams get all parameters as types.Params +func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) { + store := ctx.KVStore(k.storeKey) + + b := store.Get([]byte(types.ParamsKey)) + if b == nil { + return + } + + k.cdc.MustUnmarshal(b, ¶ms) + return +} + +// SetParams set the params +func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { + store := ctx.KVStore(k.storeKey) + b := k.cdc.MustMarshal(¶ms) + store.Set([]byte(types.ParamsKey), b) +} diff --git a/x/estaking/keeper/params_test.go b/x/estaking/keeper/params_test.go new file mode 100644 index 000000000..9c1fce9ad --- /dev/null +++ b/x/estaking/keeper/params_test.go @@ -0,0 +1,18 @@ +package keeper_test + +import ( + "testing" + + testkeeper "github.com/elys-network/elys/testutil/keeper" + "github.com/elys-network/elys/x/estaking/types" + "github.com/stretchr/testify/require" +) + +func TestGetParams(t *testing.T) { + k, ctx := testkeeper.EstakingKeeper(t) + params := types.DefaultParams() + + k.SetParams(ctx, params) + + require.EqualValues(t, params, k.GetParams(ctx)) +} diff --git a/x/estaking/keeper/query.go b/x/estaking/keeper/query.go new file mode 100644 index 000000000..4d2d0758c --- /dev/null +++ b/x/estaking/keeper/query.go @@ -0,0 +1,52 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + "github.com/elys-network/elys/x/estaking/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +var _ types.QueryServer = Keeper{} + +func (k Keeper) Rewards(goCtx context.Context, req *types.QueryRewardsRequest) (*types.QueryRewardsResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + if req.Address == "" { + return nil, status.Error(codes.InvalidArgument, "empty delegator address") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + + total := sdk.DecCoins{} + var delRewards []types.DelegationDelegatorReward + + delAdr, err := sdk.AccAddressFromBech32(req.Address) + if err != nil { + return nil, err + } + + k.IterateDelegations( + ctx, delAdr, + func(_ int64, del stakingtypes.DelegationI) (stop bool) { + valAddr := del.GetValidatorAddr() + val := k.Keeper.Validator(ctx, valAddr) + endingPeriod := k.distrKeeper.IncrementValidatorPeriod(ctx, val) + delReward := k.distrKeeper.CalculateDelegationRewards(ctx, val, del, endingPeriod) + + delRewards = append(delRewards, types.DelegationDelegatorReward{ + ValidatorAddress: valAddr.String(), + Reward: delReward, + }) + total = total.Add(delReward...) + return false + }, + ) + + return &types.QueryRewardsResponse{Rewards: delRewards, Total: total}, nil +} diff --git a/x/estaking/keeper/query_params.go b/x/estaking/keeper/query_params.go new file mode 100644 index 000000000..eb0b65772 --- /dev/null +++ b/x/estaking/keeper/query_params.go @@ -0,0 +1,19 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/elys-network/elys/x/estaking/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func (k Keeper) Params(goCtx context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + ctx := sdk.UnwrapSDKContext(goCtx) + + return &types.QueryParamsResponse{Params: k.GetParams(ctx)}, nil +} diff --git a/x/incentive/keeper/queries_test.go b/x/estaking/keeper/query_params_test.go similarity index 83% rename from x/incentive/keeper/queries_test.go rename to x/estaking/keeper/query_params_test.go index 139496e76..ebbc55690 100644 --- a/x/incentive/keeper/queries_test.go +++ b/x/estaking/keeper/query_params_test.go @@ -5,12 +5,12 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" testkeeper "github.com/elys-network/elys/testutil/keeper" - "github.com/elys-network/elys/x/incentive/types" + "github.com/elys-network/elys/x/estaking/types" "github.com/stretchr/testify/require" ) func TestParamsQuery(t *testing.T) { - keeper, ctx := testkeeper.IncentiveKeeper(t) + keeper, ctx := testkeeper.EstakingKeeper(t) wctx := sdk.WrapSDKContext(ctx) params := types.DefaultParams() keeper.SetParams(ctx, params) diff --git a/x/estaking/keeper/query_test.go b/x/estaking/keeper/query_test.go new file mode 100644 index 000000000..6d26d5e33 --- /dev/null +++ b/x/estaking/keeper/query_test.go @@ -0,0 +1,77 @@ +package keeper_test + +import ( + "testing" + + tmproto "github.com/cometbft/cometbft/proto/tendermint/types" + sdk "github.com/cosmos/cosmos-sdk/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" + simapp "github.com/elys-network/elys/app" + assetprofiletypes "github.com/elys-network/elys/x/assetprofile/types" + exdistr "github.com/elys-network/elys/x/estaking/modules/distribution" + "github.com/elys-network/elys/x/estaking/types" + ptypes "github.com/elys-network/elys/x/parameter/types" + "github.com/stretchr/testify/require" +) + +func TestQueryRewards(t *testing.T) { + app := simapp.InitElysTestApp(true) + ctx := app.BaseApp.NewContext(true, tmproto.Header{}) + + stakingKeeper := app.StakingKeeper + estakingKeeper := app.EstakingKeeper + + // create validator with 50% commission + validators := stakingKeeper.GetAllValidators(ctx) + require.True(t, len(validators) > 0) + valAddr := validators[0].GetOperator() + delegations := stakingKeeper.GetValidatorDelegations(ctx, valAddr) + require.True(t, len(delegations) > 0) + addr := sdk.MustAccAddressFromBech32(delegations[0].DelegatorAddress) + + app.AssetprofileKeeper.SetEntry(ctx, assetprofiletypes.Entry{ + BaseDenom: ptypes.Eden, + Denom: ptypes.Eden, + Decimals: 6, + CommitEnabled: true, + WithdrawEnabled: true, + }) + app.AssetprofileKeeper.SetEntry(ctx, assetprofiletypes.Entry{ + BaseDenom: ptypes.BaseCurrency, + Denom: ptypes.BaseCurrency, + Decimals: 6, + CommitEnabled: true, + WithdrawEnabled: true, + }) + + // next block + ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 1) + + params := estakingKeeper.GetParams(ctx) + params.StakeIncentives = &types.IncentiveInfo{ + EdenAmountPerYear: sdk.NewInt(1000_000_000_000_000), + DistributionStartBlock: sdk.NewInt(0), + TotalBlocksPerYear: sdk.NewInt(6307200), + BlocksDistributed: sdk.NewInt(1), + } + params.MaxEdenRewardAprStakers = sdk.NewDec(1000_000) + estakingKeeper.SetParams(ctx, params) + + // update staker rewards + err := estakingKeeper.UpdateStakersRewards(ctx) + require.Nil(t, err) + + distrAppModule := exdistr.NewAppModule( + app.AppCodec(), app.DistrKeeper, app.AccountKeeper, + app.CommitmentKeeper, &app.EstakingKeeper, + authtypes.FeeCollectorName, app.GetSubspace(distrtypes.ModuleName)) + distrAppModule.AllocateTokens(ctx) + + // query rewards + res, err := estakingKeeper.Rewards(ctx, &types.QueryRewardsRequest{ + Address: addr.String(), + }) + require.Nil(t, err) + require.Equal(t, res.Total.String(), "147608.188000000000000000ueden") +} diff --git a/x/estaking/module.go b/x/estaking/module.go new file mode 100644 index 000000000..05fa55381 --- /dev/null +++ b/x/estaking/module.go @@ -0,0 +1,150 @@ +package estaking + +import ( + "context" + "encoding/json" + "fmt" + + // this line is used by starport scaffolding # 1 + + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/spf13/cobra" + + abci "github.com/cometbft/cometbft/abci/types" + + "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" + "github.com/elys-network/elys/x/estaking/client/cli" + "github.com/elys-network/elys/x/estaking/keeper" + "github.com/elys-network/elys/x/estaking/types" +) + +var ( + _ module.AppModule = AppModule{} + _ module.AppModuleBasic = AppModuleBasic{} +) + +// ---------------------------------------------------------------------------- +// AppModuleBasic +// ---------------------------------------------------------------------------- + +// AppModuleBasic implements the AppModuleBasic interface that defines the independent methods a Cosmos SDK module needs to implement. +type AppModuleBasic struct { + cdc codec.BinaryCodec +} + +func NewAppModuleBasic(cdc codec.BinaryCodec) AppModuleBasic { + return AppModuleBasic{cdc: cdc} +} + +// Name returns the name of the module as a string +func (AppModuleBasic) Name() string { + return types.ModuleName +} + +// RegisterLegacyAminoCodec registers the amino codec for the module, which is used to marshal and unmarshal structs to/from []byte in order to persist them in the module's KVStore +func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + types.RegisterCodec(cdc) +} + +// RegisterInterfaces registers a module's interface types and their concrete implementations as proto.Message +func (a AppModuleBasic) RegisterInterfaces(reg cdctypes.InterfaceRegistry) { + types.RegisterInterfaces(reg) +} + +// DefaultGenesis returns a default GenesisState for the module, marshalled to json.RawMessage. The default GenesisState need to be defined by the module developer and is primarily used for testing +func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { + return cdc.MustMarshalJSON(types.DefaultGenesis()) +} + +// ValidateGenesis used to validate the GenesisState, given in its json.RawMessage form +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() +} + +// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module +func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { + types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) +} + +// GetTxCmd returns the root Tx command for the module. The subcommands of this root command are used by end-users to generate new transactions containing messages defined in the module +func (a AppModuleBasic) GetTxCmd() *cobra.Command { + return cli.GetTxCmd() +} + +// GetQueryCmd returns the root query command for the module. The subcommands of this root command are used by end-users to generate new queries to the subset of the state defined by the module +func (AppModuleBasic) GetQueryCmd() *cobra.Command { + return cli.GetQueryCmd(types.StoreKey) +} + +// ---------------------------------------------------------------------------- +// AppModule +// ---------------------------------------------------------------------------- + +// AppModule implements the AppModule interface that defines the inter-dependent methods that modules need to implement +type AppModule struct { + AppModuleBasic + + keeper keeper.Keeper + accountKeeper types.AccountKeeper + bankKeeper types.BankKeeper +} + +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, + } +} + +// RegisterServices registers a gRPC query service to respond to the module-specific gRPC queries +func (am AppModule) RegisterServices(cfg module.Configurator) { + types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) + types.RegisterQueryServer(cfg.QueryServer(), am.keeper) +} + +// RegisterInvariants registers the invariants of the module. If an invariant deviates from its predicted value, the InvariantRegistry triggers appropriate logic (most often the chain will be halted) +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 + // Initialize global index to index in genesis state + 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 is a sequence number for state-breaking change of the module. It should be incremented on each consensus-breaking change introduced by the module. To avoid wrong/empty versions, the initial version should be set to 1 +func (AppModule) ConsensusVersion() uint64 { return 1 } + +// BeginBlock contains the logic that is automatically triggered at the beginning of each block +func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {} + +// EndBlock contains the logic that is automatically triggered at the end of each block +func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { + am.keeper.EndBlocker(ctx) + return []abci.ValidatorUpdate{} +} diff --git a/x/estaking/module_simulation.go b/x/estaking/module_simulation.go new file mode 100644 index 000000000..d825f9a3e --- /dev/null +++ b/x/estaking/module_simulation.go @@ -0,0 +1,64 @@ +package estaking + +import ( + "math/rand" + + "github.com/cosmos/cosmos-sdk/baseapp" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + "github.com/cosmos/cosmos-sdk/x/simulation" + "github.com/elys-network/elys/testutil/sample" + estakingsimulation "github.com/elys-network/elys/x/estaking/simulation" + "github.com/elys-network/elys/x/estaking/types" +) + +// avoid unused import issue +var ( + _ = sample.AccAddress + _ = estakingsimulation.FindAccount + _ = simulation.MsgEntryKind + _ = baseapp.Paramspace + _ = rand.Rand{} +) + +const ( +// this line is used by starport scaffolding # simapp/module/const +) + +// GenerateGenesisState creates a randomized GenState of the module. +func (AppModule) GenerateGenesisState(simState *module.SimulationState) { + accs := make([]string, len(simState.Accounts)) + for i, acc := range simState.Accounts { + accs[i] = acc.Address.String() + } + estakingGenesis := types.GenesisState{ + Params: types.DefaultParams(), + // this line is used by starport scaffolding # simapp/module/genesisState + } + simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(&estakingGenesis) +} + +// RegisterStoreDecoder registers a decoder. +func (am AppModule) RegisterStoreDecoder(_ sdk.StoreDecoderRegistry) {} + +// ProposalContents doesn't return any content functions for governance proposals. +func (AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedProposalContent { + return nil +} + +// WeightedOperations returns the all the gov module operations with their respective weights. +func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation { + operations := make([]simtypes.WeightedOperation, 0) + + // this line is used by starport scaffolding # simapp/module/operation + + return operations +} + +// ProposalMsgs returns msgs used for governance proposals for simulations. +func (am AppModule) ProposalMsgs(simState module.SimulationState) []simtypes.WeightedProposalMsg { + return []simtypes.WeightedProposalMsg{ + // this line is used by starport scaffolding # simapp/module/OpMsg + } +} diff --git a/x/estaking/modules/distribution/module.go b/x/estaking/modules/distribution/module.go new file mode 100644 index 000000000..091a1ddb4 --- /dev/null +++ b/x/estaking/modules/distribution/module.go @@ -0,0 +1,113 @@ +package distribution + +import ( + "time" + + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/telemetry" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + distr "github.com/cosmos/cosmos-sdk/x/distribution" + "github.com/cosmos/cosmos-sdk/x/distribution/exported" + "github.com/cosmos/cosmos-sdk/x/distribution/keeper" + distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + estakingkeeper "github.com/elys-network/elys/x/estaking/keeper" + + abci "github.com/cometbft/cometbft/abci/types" +) + +var ( + _ module.AppModule = AppModule{} + _ module.AppModuleBasic = AppModuleBasic{} + _ module.AppModuleSimulation = AppModule{} +) + +// AppModule embeds the Cosmos SDK's x/distribution AppModuleBasic. +type AppModuleBasic struct { + distr.AppModuleBasic +} + +// AppModule embeds the Cosmos SDK's x/distribution AppModule +type AppModule struct { + // embed the Cosmos SDK's x/distribution AppModule + distr.AppModule + + keeper keeper.Keeper + accountKeeper distrtypes.AccountKeeper + bankKeeper distrtypes.BankKeeper + estakingKeeper *estakingkeeper.Keeper + + feeCollectorName string +} + +// NewAppModule creates a new AppModule object using the native x/distribution module +// AppModule constructor. +func NewAppModule( + cdc codec.Codec, keeper keeper.Keeper, ak distrtypes.AccountKeeper, + bk distrtypes.BankKeeper, sk *estakingkeeper.Keeper, feeCollectorName string, subspace exported.Subspace, +) AppModule { + distrAppMod := distr.NewAppModule(cdc, keeper, ak, bk, sk, subspace) + return AppModule{ + AppModule: distrAppMod, + keeper: keeper, + accountKeeper: ak, + bankKeeper: bk, + estakingKeeper: sk, + feeCollectorName: feeCollectorName, + } +} + +// BeginBlocker mirror functionality of cosmos-sdk/distribution BeginBlocker +// however it allocates no proposer reward +func (am AppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) { + defer telemetry.ModuleMeasureSince(distrtypes.ModuleName, time.Now(), telemetry.MetricKeyBeginBlocker) + + if ctx.BlockHeight() > 1 { + am.AllocateTokens(ctx) + } +} + +// RegisterInvariants registers the distribution module invariants. +func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) { +} + +// AllocateTokens handles distribution of the collected fees +func (am AppModule) AllocateTokens(ctx sdk.Context) { + // fetch and clear the collected fees for distribution, since this is + // called in BeginBlock, collected fees will be from the previous block + // (and distributed to the current representatives) + feeCollector := am.accountKeeper.GetModuleAccount(ctx, am.feeCollectorName) + feesCollectedInt := am.bankKeeper.GetAllBalances(ctx, feeCollector.GetAddress()) + feesCollected := sdk.NewDecCoinsFromCoins(feesCollectedInt...) + + // transfer collected fees to the distribution module account + err := am.bankKeeper.SendCoinsFromModuleToModule(ctx, am.feeCollectorName, distrtypes.ModuleName, feesCollectedInt) + if err != nil { + panic(err) + } + + // calculate the fraction allocated to representatives by subtracting the community tax. + // e.g. if community tax is 0.02, representatives fraction will be 0.98 (2% goes to the community pool and the rest to the representatives) + remaining := feesCollected + communityTax := am.keeper.GetCommunityTax(ctx) + representativesFraction := sdk.OneDec().Sub(communityTax) + + totalBondedTokens := am.estakingKeeper.TotalBondedTokens(ctx) + + // allocate tokens proportionally to representatives voting power + am.estakingKeeper.IterateBondedValidatorsByPower(ctx, func(_ int64, validator stakingtypes.ValidatorI) bool { + // we get this validator's percentage of the total power by dividing their tokens by the total bonded tokens + powerFraction := sdk.NewDecFromInt(validator.GetTokens()).QuoTruncate(sdk.NewDecFromInt(totalBondedTokens)) + // we truncate here again, which means that the reward will be slightly lower than it should be + reward := feesCollected.MulDecTruncate(representativesFraction).MulDecTruncate(powerFraction) + am.keeper.AllocateTokensToValidator(ctx, validator, reward) + remaining = remaining.Sub(reward) + return false + }) + + // temporary workaround to keep CanWithdrawInvariant happy + feePool := am.keeper.GetFeePool(ctx) + feePool.CommunityPool = feePool.CommunityPool.Add(remaining...) + am.keeper.SetFeePool(ctx, feePool) +} diff --git a/x/estaking/modules/staking/module.go b/x/estaking/modules/staking/module.go new file mode 100644 index 000000000..b3192a1fc --- /dev/null +++ b/x/estaking/modules/staking/module.go @@ -0,0 +1,63 @@ +package staking + +import ( + "encoding/json" + + "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + "github.com/cosmos/cosmos-sdk/x/staking" + "github.com/cosmos/cosmos-sdk/x/staking/exported" + "github.com/cosmos/cosmos-sdk/x/staking/keeper" + "github.com/cosmos/cosmos-sdk/x/staking/types" + + abci "github.com/cometbft/cometbft/abci/types" +) + +var ( + _ module.AppModule = AppModule{} + _ module.AppModuleBasic = AppModuleBasic{} + _ module.AppModuleSimulation = AppModule{} +) + +// AppModule embeds the Cosmos SDK's x/staking AppModuleBasic. +type AppModuleBasic struct { + staking.AppModuleBasic +} + +// AppModule embeds the Cosmos SDK's x/staking AppModule where we only override +// specific methods. +type AppModule struct { + // embed the Cosmos SDK's x/staking AppModule + staking.AppModule + + keeper *keeper.Keeper + accKeeper types.AccountKeeper + bankKeeper types.BankKeeper +} + +// NewAppModule creates a new AppModule object using the native x/staking module +// AppModule constructor. +func NewAppModule(cdc codec.Codec, keeper *keeper.Keeper, ak types.AccountKeeper, bk types.BankKeeper, subspace exported.Subspace) AppModule { + stakingAppMod := staking.NewAppModule(cdc, keeper, ak, bk, subspace) + return AppModule{ + AppModule: stakingAppMod, + keeper: keeper, + accKeeper: ak, + bankKeeper: bk, + } +} + +// InitGenesis delegates the InitGenesis call to the underlying x/staking module, +func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate { + var genesisState types.GenesisState + + cdc.MustUnmarshalJSON(data, &genesisState) + return am.keeper.InitGenesis(ctx, &genesisState) +} + +// EndBlock delegates the EndBlock call to the underlying x/staking module, +func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { + updates := am.keeper.BlockValidatorUpdates(ctx) + return updates +} diff --git a/x/estaking/simulation/helpers.go b/x/estaking/simulation/helpers.go new file mode 100644 index 000000000..92c437c0d --- /dev/null +++ b/x/estaking/simulation/helpers.go @@ -0,0 +1,15 @@ +package simulation + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" +) + +// FindAccount find a specific address from an account list +func FindAccount(accs []simtypes.Account, address string) (simtypes.Account, bool) { + creator, err := sdk.AccAddressFromBech32(address) + if err != nil { + panic(err) + } + return simtypes.FindAccount(accs, creator) +} diff --git a/x/estaking/types/codec.go b/x/estaking/types/codec.go new file mode 100644 index 000000000..c615e2f0e --- /dev/null +++ b/x/estaking/types/codec.go @@ -0,0 +1,33 @@ +package types + +import ( + "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + + // this line is used by starport scaffolding # 1 + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/msgservice" +) + +func RegisterCodec(cdc *codec.LegacyAmino) { + cdc.RegisterConcrete(&MsgUpdateParams{}, "estaking/UpdateParams", nil) + cdc.RegisterConcrete(&MsgWithdrawReward{}, "estaking/WithdrawReward", nil) + cdc.RegisterConcrete(&MsgWithdrawElysStakingRewards{}, "estaking/WithdrawElysStakingRewards", nil) + // this line is used by starport scaffolding # 2 +} + +func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgUpdateParams{}, + &MsgWithdrawReward{}, + &MsgWithdrawElysStakingRewards{}, + ) + // this line is used by starport scaffolding # 3 + + msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) +} + +var ( + Amino = codec.NewLegacyAmino() + ModuleCdc = codec.NewProtoCodec(cdctypes.NewInterfaceRegistry()) +) diff --git a/x/estaking/types/dex_rewards_tracker.pb.go b/x/estaking/types/dex_rewards_tracker.pb.go new file mode 100644 index 000000000..ade5651a2 --- /dev/null +++ b/x/estaking/types/dex_rewards_tracker.pb.go @@ -0,0 +1,399 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: elys/estaking/dex_rewards_tracker.proto + +package types + +import ( + fmt "fmt" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + 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 + +// DexRewardsTracker is used for tracking rewards for stakers and LPs, all +// amount here is in USDC +type DexRewardsTracker struct { + // Number of blocks since start of epoch (distribution epoch) + NumBlocks github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=num_blocks,json=numBlocks,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"num_blocks"` + // Accumulated amount at distribution epoch - recalculated at every + // distribution epoch + Amount github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=amount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"amount"` +} + +func (m *DexRewardsTracker) Reset() { *m = DexRewardsTracker{} } +func (m *DexRewardsTracker) String() string { return proto.CompactTextString(m) } +func (*DexRewardsTracker) ProtoMessage() {} +func (*DexRewardsTracker) Descriptor() ([]byte, []int) { + return fileDescriptor_061875a2058b444a, []int{0} +} +func (m *DexRewardsTracker) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *DexRewardsTracker) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_DexRewardsTracker.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 *DexRewardsTracker) XXX_Merge(src proto.Message) { + xxx_messageInfo_DexRewardsTracker.Merge(m, src) +} +func (m *DexRewardsTracker) XXX_Size() int { + return m.Size() +} +func (m *DexRewardsTracker) XXX_DiscardUnknown() { + xxx_messageInfo_DexRewardsTracker.DiscardUnknown(m) +} + +var xxx_messageInfo_DexRewardsTracker proto.InternalMessageInfo + +func init() { + proto.RegisterType((*DexRewardsTracker)(nil), "elys.estaking.DexRewardsTracker") +} + +func init() { + proto.RegisterFile("elys/estaking/dex_rewards_tracker.proto", fileDescriptor_061875a2058b444a) +} + +var fileDescriptor_061875a2058b444a = []byte{ + // 251 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4f, 0xcd, 0xa9, 0x2c, + 0xd6, 0x4f, 0x2d, 0x2e, 0x49, 0xcc, 0xce, 0xcc, 0x4b, 0xd7, 0x4f, 0x49, 0xad, 0x88, 0x2f, 0x4a, + 0x2d, 0x4f, 0x2c, 0x4a, 0x29, 0x8e, 0x2f, 0x29, 0x4a, 0x4c, 0xce, 0x4e, 0x2d, 0xd2, 0x2b, 0x28, + 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x05, 0x29, 0xd4, 0x83, 0x29, 0x94, 0x12, 0x49, 0xcf, 0x4f, 0xcf, + 0x07, 0xcb, 0xe8, 0x83, 0x58, 0x10, 0x45, 0x4a, 0xab, 0x18, 0xb9, 0x04, 0x5d, 0x52, 0x2b, 0x82, + 0x20, 0x26, 0x84, 0x40, 0x0c, 0x10, 0xf2, 0xe5, 0xe2, 0xca, 0x2b, 0xcd, 0x8d, 0x4f, 0xca, 0xc9, + 0x4f, 0xce, 0x2e, 0x96, 0x60, 0x54, 0x60, 0xd4, 0xe0, 0x74, 0xd2, 0x3b, 0x71, 0x4f, 0x9e, 0xe1, + 0xd6, 0x3d, 0x79, 0xb5, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0xfd, 0xe4, + 0xfc, 0xe2, 0xdc, 0xfc, 0x62, 0x28, 0xa5, 0x5b, 0x9c, 0x92, 0xad, 0x5f, 0x52, 0x59, 0x90, 0x5a, + 0xac, 0xe7, 0x99, 0x57, 0x12, 0xc4, 0x99, 0x57, 0x9a, 0xeb, 0x04, 0x36, 0x40, 0xc8, 0x8d, 0x8b, + 0x2d, 0x31, 0x37, 0xbf, 0x34, 0xaf, 0x44, 0x82, 0x89, 0x64, 0xa3, 0x5c, 0x52, 0x93, 0x83, 0xa0, + 0xba, 0x9d, 0xbc, 0x57, 0x3c, 0x92, 0x63, 0x3c, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, + 0x07, 0x8f, 0xe4, 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, + 0x86, 0x28, 0x5d, 0x24, 0xd3, 0x40, 0x5e, 0xd7, 0xcd, 0x4b, 0x2d, 0x29, 0xcf, 0x2f, 0xca, 0x06, + 0x73, 0xf4, 0x2b, 0x10, 0x41, 0x06, 0x36, 0x38, 0x89, 0x0d, 0x1c, 0x00, 0xc6, 0x80, 0x00, 0x00, + 0x00, 0xff, 0xff, 0xcf, 0xcf, 0x55, 0x69, 0x50, 0x01, 0x00, 0x00, +} + +func (this *DexRewardsTracker) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*DexRewardsTracker) + if !ok { + that2, ok := that.(DexRewardsTracker) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if !this.NumBlocks.Equal(that1.NumBlocks) { + return false + } + if !this.Amount.Equal(that1.Amount) { + return false + } + return true +} +func (m *DexRewardsTracker) 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 *DexRewardsTracker) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *DexRewardsTracker) 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 = encodeVarintDexRewardsTracker(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + { + size := m.NumBlocks.Size() + i -= size + if _, err := m.NumBlocks.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintDexRewardsTracker(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func encodeVarintDexRewardsTracker(dAtA []byte, offset int, v uint64) int { + offset -= sovDexRewardsTracker(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *DexRewardsTracker) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.NumBlocks.Size() + n += 1 + l + sovDexRewardsTracker(uint64(l)) + l = m.Amount.Size() + n += 1 + l + sovDexRewardsTracker(uint64(l)) + return n +} + +func sovDexRewardsTracker(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozDexRewardsTracker(x uint64) (n int) { + return sovDexRewardsTracker(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *DexRewardsTracker) 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 ErrIntOverflowDexRewardsTracker + } + 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: DexRewardsTracker: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DexRewardsTracker: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NumBlocks", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDexRewardsTracker + } + 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 ErrInvalidLengthDexRewardsTracker + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthDexRewardsTracker + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.NumBlocks.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + 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 ErrIntOverflowDexRewardsTracker + } + 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 ErrInvalidLengthDexRewardsTracker + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthDexRewardsTracker + } + 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 := skipDexRewardsTracker(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthDexRewardsTracker + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipDexRewardsTracker(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, ErrIntOverflowDexRewardsTracker + } + 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, ErrIntOverflowDexRewardsTracker + } + 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, ErrIntOverflowDexRewardsTracker + } + 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, ErrInvalidLengthDexRewardsTracker + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupDexRewardsTracker + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthDexRewardsTracker + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthDexRewardsTracker = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowDexRewardsTracker = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupDexRewardsTracker = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/estaking/types/elys_staked.pb.go b/x/estaking/types/elys_staked.pb.go new file mode 100644 index 000000000..350b0ab65 --- /dev/null +++ b/x/estaking/types/elys_staked.pb.go @@ -0,0 +1,396 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: elys/estaking/elys_staked.proto + +package types + +import ( + fmt "fmt" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + 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 + +// Elys staked amount is tracked because EdenBoost has to be burnt when unstake ELYS event happens, +// and there's no way to track staked amount change from staking hook and this struct is added. +type ElysStaked struct { + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + Amount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=amount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"amount"` +} + +func (m *ElysStaked) Reset() { *m = ElysStaked{} } +func (m *ElysStaked) String() string { return proto.CompactTextString(m) } +func (*ElysStaked) ProtoMessage() {} +func (*ElysStaked) Descriptor() ([]byte, []int) { + return fileDescriptor_f2ccdbb886debb3c, []int{0} +} +func (m *ElysStaked) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ElysStaked) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ElysStaked.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 *ElysStaked) XXX_Merge(src proto.Message) { + xxx_messageInfo_ElysStaked.Merge(m, src) +} +func (m *ElysStaked) XXX_Size() int { + return m.Size() +} +func (m *ElysStaked) XXX_DiscardUnknown() { + xxx_messageInfo_ElysStaked.DiscardUnknown(m) +} + +var xxx_messageInfo_ElysStaked proto.InternalMessageInfo + +func (m *ElysStaked) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +func init() { + proto.RegisterType((*ElysStaked)(nil), "elys.estaking.ElysStaked") +} + +func init() { proto.RegisterFile("elys/estaking/elys_staked.proto", fileDescriptor_f2ccdbb886debb3c) } + +var fileDescriptor_f2ccdbb886debb3c = []byte{ + // 222 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4f, 0xcd, 0xa9, 0x2c, + 0xd6, 0x4f, 0x2d, 0x2e, 0x49, 0xcc, 0xce, 0xcc, 0x4b, 0xd7, 0x07, 0xf1, 0xe2, 0x41, 0x9c, 0xd4, + 0x14, 0xbd, 0x82, 0xa2, 0xfc, 0x92, 0x7c, 0x21, 0x5e, 0x90, 0x90, 0x1e, 0x4c, 0x81, 0x94, 0x48, + 0x7a, 0x7e, 0x7a, 0x3e, 0x58, 0x46, 0x1f, 0xc4, 0x82, 0x28, 0x52, 0xca, 0xe3, 0xe2, 0x72, 0xcd, + 0xa9, 0x2c, 0x0e, 0x06, 0x6b, 0x14, 0x92, 0xe0, 0x62, 0x4f, 0x4c, 0x49, 0x29, 0x4a, 0x2d, 0x2e, + 0x96, 0x60, 0x54, 0x60, 0xd4, 0xe0, 0x0c, 0x82, 0x71, 0x85, 0xdc, 0xb8, 0xd8, 0x12, 0x73, 0xf3, + 0x4b, 0xf3, 0x4a, 0x24, 0x98, 0x40, 0x12, 0x4e, 0x7a, 0x27, 0xee, 0xc9, 0x33, 0xdc, 0xba, 0x27, + 0xaf, 0x96, 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, 0x9f, 0x9c, 0x5f, 0x9c, + 0x9b, 0x5f, 0x0c, 0xa5, 0x74, 0x8b, 0x53, 0xb2, 0xf5, 0x4b, 0x2a, 0x0b, 0x52, 0x8b, 0xf5, 0x3c, + 0xf3, 0x4a, 0x82, 0xa0, 0xba, 0x9d, 0xbc, 0x57, 0x3c, 0x92, 0x63, 0x3c, 0xf1, 0x48, 0x8e, 0xf1, + 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, + 0xe1, 0xc6, 0x63, 0x39, 0x86, 0x28, 0x5d, 0x24, 0xd3, 0x40, 0xae, 0xd7, 0xcd, 0x4b, 0x2d, 0x29, + 0xcf, 0x2f, 0xca, 0x06, 0x73, 0xf4, 0x2b, 0x10, 0xbe, 0x05, 0x1b, 0x9c, 0xc4, 0x06, 0xf6, 0x83, + 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0xc0, 0x74, 0x78, 0x75, 0x0b, 0x01, 0x00, 0x00, +} + +func (this *ElysStaked) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*ElysStaked) + if !ok { + that2, ok := that.(ElysStaked) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Address != that1.Address { + return false + } + if !this.Amount.Equal(that1.Amount) { + return false + } + return true +} +func (m *ElysStaked) 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 *ElysStaked) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ElysStaked) 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 = encodeVarintElysStaked(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintElysStaked(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintElysStaked(dAtA []byte, offset int, v uint64) int { + offset -= sovElysStaked(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *ElysStaked) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovElysStaked(uint64(l)) + } + l = m.Amount.Size() + n += 1 + l + sovElysStaked(uint64(l)) + return n +} + +func sovElysStaked(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozElysStaked(x uint64) (n int) { + return sovElysStaked(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *ElysStaked) 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 ErrIntOverflowElysStaked + } + 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: ElysStaked: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ElysStaked: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowElysStaked + } + 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 ErrInvalidLengthElysStaked + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthElysStaked + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + 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 ErrIntOverflowElysStaked + } + 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 ErrInvalidLengthElysStaked + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthElysStaked + } + 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 := skipElysStaked(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthElysStaked + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipElysStaked(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, ErrIntOverflowElysStaked + } + 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, ErrIntOverflowElysStaked + } + 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, ErrIntOverflowElysStaked + } + 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, ErrInvalidLengthElysStaked + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupElysStaked + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthElysStaked + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthElysStaked = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowElysStaked = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupElysStaked = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/estaking/types/errors.go b/x/estaking/types/errors.go new file mode 100644 index 000000000..ebf15f81e --- /dev/null +++ b/x/estaking/types/errors.go @@ -0,0 +1,12 @@ +package types + +// DONTCOVER + +import ( + errorsmod "cosmossdk.io/errors" +) + +// x/estaking module sentinel errors +var ( + ErrNoInflationaryParams = errorsmod.Register(ModuleName, 14, "no inflationary rewards params") +) diff --git a/x/estaking/types/expected_keepers.go b/x/estaking/types/expected_keepers.go new file mode 100644 index 000000000..693a1b901 --- /dev/null +++ b/x/estaking/types/expected_keepers.go @@ -0,0 +1,76 @@ +package types + +import ( + "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/auth/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + assetprofiletypes "github.com/elys-network/elys/x/assetprofile/types" + commitmenttypes "github.com/elys-network/elys/x/commitment/types" + tokenomictypes "github.com/elys-network/elys/x/tokenomics/types" +) + +// AccountKeeper defines the expected account keeper used for simulations (noalias) +type AccountKeeper interface { + GetAccount(ctx sdk.Context, addr sdk.AccAddress) types.AccountI + // Methods imported from account should be defined here +} + +// BankKeeper defines the expected interface needed to retrieve account balances. +type BankKeeper interface { + SpendableCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins + // Methods imported from bank should be defined here +} + +// StakingKeeper expected staking keeper (noalias) +type StakingKeeper interface { + // iterate through validators by operator address, execute func for each validator + IterateValidators(sdk.Context, + func(index int64, validator stakingtypes.ValidatorI) (stop bool)) + + Validator(sdk.Context, sdk.ValAddress) stakingtypes.ValidatorI // get a particular validator by operator address + ValidatorByConsAddr(sdk.Context, sdk.ConsAddress) stakingtypes.ValidatorI // get a particular validator by consensus address + + // Delegation allows for getting a particular delegation for a given validator + // and delegator outside the scope of the staking module. + Delegation(sdk.Context, sdk.AccAddress, sdk.ValAddress) stakingtypes.DelegationI + + IterateDelegations(ctx sdk.Context, delegator sdk.AccAddress, + fn func(index int64, delegation stakingtypes.DelegationI) (stop bool)) + + GetAllSDKDelegations(ctx sdk.Context) []stakingtypes.Delegation + GetAllValidators(ctx sdk.Context) (validators []stakingtypes.Validator) + GetAllDelegatorDelegations(ctx sdk.Context, delegator sdk.AccAddress) []stakingtypes.Delegation +} + +type CommitmentKeeper interface { + GetCommitments(ctx sdk.Context, creator string) commitmenttypes.Commitments + GetParams(ctx sdk.Context) commitmenttypes.Params + GetAllBalances(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins + MintCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) error + SendCoinsFromModuleToModule(ctx sdk.Context, senderModule string, recipientModule string, amt sdk.Coins) error + SetCommitments(sdk.Context, commitmenttypes.Commitments) + BurnEdenBoost(ctx sdk.Context, creator string, denom string, amount math.Int) (commitmenttypes.Commitments, error) + BeforeDelegationCreated(sdk.Context, string, string) error +} + +type DistrKeeper interface { + WithdrawDelegationRewards(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) (sdk.Coins, error) + IncrementValidatorPeriod(ctx sdk.Context, val stakingtypes.ValidatorI) uint64 + CalculateDelegationRewards(ctx sdk.Context, val stakingtypes.ValidatorI, del stakingtypes.DelegationI, endingPeriod uint64) (rewards sdk.DecCoins) +} + +// TokenomicsKeeper defines the expected tokenomics keeper used for simulations (noalias) +type TokenomicsKeeper interface { + GetAllTimeBasedInflation(ctx sdk.Context) (list []tokenomictypes.TimeBasedInflation) +} + +// AssetProfileKeeper defines the expected interfaces +type AssetProfileKeeper interface { + // SetEntry set a specific entry in the store from its index + SetEntry(ctx sdk.Context, entry assetprofiletypes.Entry) + // GetEntry returns a entry from its index + GetEntry(ctx sdk.Context, baseDenom string) (val assetprofiletypes.Entry, found bool) + // GetEntryByDenom returns a entry from its denom value + GetEntryByDenom(ctx sdk.Context, denom string) (val assetprofiletypes.Entry, found bool) +} diff --git a/x/estaking/types/genesis.go b/x/estaking/types/genesis.go new file mode 100644 index 000000000..0af9b4416 --- /dev/null +++ b/x/estaking/types/genesis.go @@ -0,0 +1,24 @@ +package types + +import ( +// this line is used by starport scaffolding # genesis/types/import +) + +// DefaultIndex is the default global index +const DefaultIndex uint64 = 1 + +// DefaultGenesis returns the default genesis state +func DefaultGenesis() *GenesisState { + return &GenesisState{ + // this line is used by starport scaffolding # genesis/types/default + Params: DefaultParams(), + } +} + +// Validate performs basic genesis state validation returning an error upon any +// failure. +func (gs GenesisState) Validate() error { + // this line is used by starport scaffolding # genesis/types/validate + + return gs.Params.Validate() +} diff --git a/x/estaking/types/genesis.pb.go b/x/estaking/types/genesis.pb.go new file mode 100644 index 000000000..158538690 --- /dev/null +++ b/x/estaking/types/genesis.pb.go @@ -0,0 +1,386 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: elys/estaking/genesis.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + 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 estaking module's genesis state. +type GenesisState struct { + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` + StakingSnapshots []ElysStaked `protobuf:"bytes,2,rep,name=staking_snapshots,json=stakingSnapshots,proto3" json:"staking_snapshots"` +} + +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_9cf9ec2ffb8a7f28, []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 + +func (m *GenesisState) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +func (m *GenesisState) GetStakingSnapshots() []ElysStaked { + if m != nil { + return m.StakingSnapshots + } + return nil +} + +func init() { + proto.RegisterType((*GenesisState)(nil), "elys.estaking.GenesisState") +} + +func init() { proto.RegisterFile("elys/estaking/genesis.proto", fileDescriptor_9cf9ec2ffb8a7f28) } + +var fileDescriptor_9cf9ec2ffb8a7f28 = []byte{ + // 248 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4e, 0xcd, 0xa9, 0x2c, + 0xd6, 0x4f, 0x2d, 0x2e, 0x49, 0xcc, 0xce, 0xcc, 0x4b, 0xd7, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, + 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x05, 0x49, 0xea, 0xc1, 0x24, 0xa5, 0x44, + 0xd2, 0xf3, 0xd3, 0xf3, 0xc1, 0x32, 0xfa, 0x20, 0x16, 0x44, 0x91, 0x94, 0x14, 0xaa, 0x09, 0x05, + 0x89, 0x45, 0x89, 0xb9, 0x50, 0x03, 0xa4, 0xe4, 0x51, 0xe5, 0x40, 0xbc, 0x78, 0x10, 0x27, 0x35, + 0x05, 0xa2, 0x40, 0x69, 0x22, 0x23, 0x17, 0x8f, 0x3b, 0xc4, 0xce, 0xe0, 0x92, 0xc4, 0x92, 0x54, + 0x21, 0x63, 0x2e, 0x36, 0x88, 0x09, 0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0xdc, 0x46, 0xa2, 0x7a, 0x28, + 0x6e, 0xd0, 0x0b, 0x00, 0x4b, 0x3a, 0xb1, 0x9c, 0xb8, 0x27, 0xcf, 0x10, 0x04, 0x55, 0x2a, 0xe4, + 0xc3, 0x25, 0x08, 0x95, 0x8f, 0x2f, 0xce, 0x4b, 0x2c, 0x28, 0xce, 0xc8, 0x2f, 0x29, 0x96, 0x60, + 0x52, 0x60, 0xd6, 0xe0, 0x36, 0x92, 0x44, 0xd3, 0xef, 0x9a, 0x53, 0x09, 0xb2, 0x29, 0x3b, 0x35, + 0x05, 0x6a, 0x86, 0x00, 0x54, 0x26, 0x18, 0xa6, 0xd1, 0xc9, 0xfd, 0xc4, 0x23, 0x39, 0xc6, 0x0b, + 0x8f, 0xe4, 0x18, 0x1f, 0x3c, 0x92, 0x63, 0x9c, 0xf0, 0x58, 0x8e, 0xe1, 0xc2, 0x63, 0x39, 0x86, + 0x1b, 0x8f, 0xe5, 0x18, 0xa2, 0x74, 0xd3, 0x33, 0x4b, 0x32, 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, + 0xc1, 0x7e, 0xd1, 0xcd, 0x4b, 0x2d, 0x29, 0xcf, 0x2f, 0xca, 0x06, 0x73, 0xf4, 0x2b, 0x10, 0x1e, + 0x2d, 0xa9, 0x2c, 0x48, 0x2d, 0x4e, 0x62, 0x03, 0xfb, 0xd1, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, + 0x4d, 0xbe, 0xb9, 0x3b, 0x64, 0x01, 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.StakingSnapshots) > 0 { + for iNdEx := len(m.StakingSnapshots) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.StakingSnapshots[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 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.StakingSnapshots) > 0 { + for _, e := range m.StakingSnapshots { + l = e.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 StakingSnapshots", 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.StakingSnapshots = append(m.StakingSnapshots, ElysStaked{}) + if err := m.StakingSnapshots[len(m.StakingSnapshots)-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 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/estaking/types/genesis_test.go b/x/estaking/types/genesis_test.go new file mode 100644 index 000000000..7cf050eb0 --- /dev/null +++ b/x/estaking/types/genesis_test.go @@ -0,0 +1,41 @@ +package types_test + +import ( + "testing" + + "github.com/elys-network/elys/x/estaking/types" + "github.com/stretchr/testify/require" +) + +func TestGenesisState_Validate(t *testing.T) { + tests := []struct { + desc string + genState *types.GenesisState + valid bool + }{ + { + desc: "default is valid", + genState: types.DefaultGenesis(), + valid: true, + }, + { + desc: "valid genesis state", + genState: &types.GenesisState{ + + // this line is used by starport scaffolding # types/genesis/validField + }, + valid: true, + }, + // this line is used by starport scaffolding # types/genesis/testcase + } + for _, tc := range tests { + t.Run(tc.desc, func(t *testing.T) { + err := tc.genState.Validate() + if tc.valid { + require.NoError(t, err) + } else { + require.Error(t, err) + } + }) + } +} diff --git a/x/estaking/types/incentive.pb.go b/x/estaking/types/incentive.pb.go new file mode 100644 index 000000000..92e5cd6dc --- /dev/null +++ b/x/estaking/types/incentive.pb.go @@ -0,0 +1,470 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: elys/estaking/incentive.proto + +package types + +import ( + fmt "fmt" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/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 + +// Incentive Info +type IncentiveInfo struct { + // reward amount in eden for 1 year + EdenAmountPerYear github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=eden_amount_per_year,json=edenAmountPerYear,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"eden_amount_per_year"` + // starting block height of the distribution + DistributionStartBlock github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=distribution_start_block,json=distributionStartBlock,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"distribution_start_block"` + // distribution duration - block number per year + TotalBlocksPerYear github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=total_blocks_per_year,json=totalBlocksPerYear,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"total_blocks_per_year"` + // blocks distributed + BlocksDistributed github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,4,opt,name=blocks_distributed,json=blocksDistributed,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"blocks_distributed"` +} + +func (m *IncentiveInfo) Reset() { *m = IncentiveInfo{} } +func (m *IncentiveInfo) String() string { return proto.CompactTextString(m) } +func (*IncentiveInfo) ProtoMessage() {} +func (*IncentiveInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_e9de1d3bcda4768b, []int{0} +} +func (m *IncentiveInfo) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *IncentiveInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_IncentiveInfo.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 *IncentiveInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_IncentiveInfo.Merge(m, src) +} +func (m *IncentiveInfo) XXX_Size() int { + return m.Size() +} +func (m *IncentiveInfo) XXX_DiscardUnknown() { + xxx_messageInfo_IncentiveInfo.DiscardUnknown(m) +} + +var xxx_messageInfo_IncentiveInfo proto.InternalMessageInfo + +func init() { + proto.RegisterType((*IncentiveInfo)(nil), "elys.estaking.IncentiveInfo") +} + +func init() { proto.RegisterFile("elys/estaking/incentive.proto", fileDescriptor_e9de1d3bcda4768b) } + +var fileDescriptor_e9de1d3bcda4768b = []byte{ + // 331 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0xd2, 0xc1, 0x4a, 0xf3, 0x40, + 0x10, 0x00, 0xe0, 0xe4, 0xef, 0xcf, 0x0f, 0x7f, 0xa0, 0x07, 0x43, 0x95, 0x50, 0x30, 0x15, 0x0f, + 0xe2, 0xa5, 0xd9, 0x83, 0x4f, 0x60, 0x11, 0xa4, 0x37, 0xd1, 0x93, 0x82, 0x84, 0x4d, 0x32, 0x4d, + 0x97, 0x24, 0x3b, 0x61, 0x77, 0xa2, 0xf6, 0x2d, 0x7c, 0x00, 0x1f, 0xa8, 0xc7, 0x1e, 0xc5, 0x43, + 0x91, 0xf6, 0x45, 0x64, 0x37, 0xad, 0xed, 0xb9, 0xa7, 0x64, 0x98, 0xc9, 0x37, 0x99, 0xdd, 0xf1, + 0x4e, 0xa1, 0x9c, 0x69, 0x06, 0x9a, 0x78, 0x21, 0x64, 0xce, 0x84, 0x4c, 0x41, 0x92, 0x78, 0x81, + 0xa8, 0x56, 0x48, 0xe8, 0x77, 0x4d, 0x3a, 0xda, 0xa6, 0xfb, 0xbd, 0x1c, 0x73, 0xb4, 0x19, 0x66, + 0xde, 0xda, 0xa2, 0xfe, 0x20, 0x47, 0xcc, 0x4b, 0x60, 0x36, 0x4a, 0x9a, 0x09, 0x23, 0x51, 0x99, + 0x4f, 0xaa, 0xba, 0x2d, 0x38, 0xff, 0xe8, 0x78, 0xdd, 0xf1, 0x56, 0x1e, 0xcb, 0x09, 0xfa, 0xb1, + 0xd7, 0x83, 0x0c, 0x64, 0xcc, 0x2b, 0x6c, 0x24, 0xc5, 0x35, 0xa8, 0x78, 0x06, 0x5c, 0x05, 0xee, + 0x99, 0x7b, 0xf9, 0x7f, 0x14, 0xcd, 0x97, 0x03, 0xe7, 0x6b, 0x39, 0xb8, 0xc8, 0x05, 0x4d, 0x9b, + 0x24, 0x4a, 0xb1, 0x62, 0x29, 0xea, 0x0a, 0xf5, 0xe6, 0x31, 0xd4, 0x59, 0xc1, 0x68, 0x56, 0x83, + 0x8e, 0xc6, 0x92, 0xee, 0x8f, 0x8c, 0x75, 0x6d, 0xa9, 0x3b, 0x50, 0x8f, 0xc0, 0x95, 0x3f, 0xf5, + 0x82, 0x4c, 0x68, 0x52, 0x22, 0x69, 0x48, 0xa0, 0x8c, 0x35, 0x71, 0x45, 0x71, 0x52, 0x62, 0x5a, + 0x04, 0x7f, 0x0e, 0x6a, 0x72, 0xb2, 0xef, 0x3d, 0x18, 0x6e, 0x64, 0x34, 0x9f, 0x7b, 0xc7, 0x84, + 0xc4, 0xcb, 0x16, 0xd7, 0xbb, 0x59, 0x3a, 0x07, 0xb5, 0xf1, 0x2d, 0x66, 0x69, 0xbd, 0x1d, 0xe6, + 0xd9, 0xf3, 0x37, 0xf8, 0xef, 0x3f, 0x40, 0x16, 0xfc, 0x3d, 0xec, 0xac, 0x5a, 0xe9, 0x66, 0x07, + 0x8d, 0x6e, 0xe7, 0xab, 0xd0, 0x5d, 0xac, 0x42, 0xf7, 0x7b, 0x15, 0xba, 0xef, 0xeb, 0xd0, 0x59, + 0xac, 0x43, 0xe7, 0x73, 0x1d, 0x3a, 0x4f, 0xc3, 0x3d, 0xd4, 0x6c, 0xc2, 0x50, 0x02, 0xbd, 0xa2, + 0x2a, 0x6c, 0xc0, 0xde, 0x76, 0x7b, 0x63, 0xfd, 0xe4, 0x9f, 0xbd, 0xee, 0xab, 0x9f, 0x00, 0x00, + 0x00, 0xff, 0xff, 0xc2, 0x59, 0x9d, 0x93, 0x55, 0x02, 0x00, 0x00, +} + +func (m *IncentiveInfo) 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 *IncentiveInfo) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *IncentiveInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.BlocksDistributed.Size() + i -= size + if _, err := m.BlocksDistributed.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintIncentive(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + { + size := m.TotalBlocksPerYear.Size() + i -= size + if _, err := m.TotalBlocksPerYear.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintIncentive(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + { + size := m.DistributionStartBlock.Size() + i -= size + if _, err := m.DistributionStartBlock.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintIncentive(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + { + size := m.EdenAmountPerYear.Size() + i -= size + if _, err := m.EdenAmountPerYear.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintIncentive(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func encodeVarintIncentive(dAtA []byte, offset int, v uint64) int { + offset -= sovIncentive(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *IncentiveInfo) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.EdenAmountPerYear.Size() + n += 1 + l + sovIncentive(uint64(l)) + l = m.DistributionStartBlock.Size() + n += 1 + l + sovIncentive(uint64(l)) + l = m.TotalBlocksPerYear.Size() + n += 1 + l + sovIncentive(uint64(l)) + l = m.BlocksDistributed.Size() + n += 1 + l + sovIncentive(uint64(l)) + return n +} + +func sovIncentive(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozIncentive(x uint64) (n int) { + return sovIncentive(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *IncentiveInfo) 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 ErrIntOverflowIncentive + } + 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: IncentiveInfo: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: IncentiveInfo: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EdenAmountPerYear", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowIncentive + } + 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 ErrInvalidLengthIncentive + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthIncentive + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.EdenAmountPerYear.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DistributionStartBlock", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowIncentive + } + 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 ErrInvalidLengthIncentive + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthIncentive + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.DistributionStartBlock.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TotalBlocksPerYear", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowIncentive + } + 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 ErrInvalidLengthIncentive + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthIncentive + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.TotalBlocksPerYear.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BlocksDistributed", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowIncentive + } + 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 ErrInvalidLengthIncentive + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthIncentive + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.BlocksDistributed.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipIncentive(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthIncentive + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipIncentive(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, ErrIntOverflowIncentive + } + 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, ErrIntOverflowIncentive + } + 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, ErrIntOverflowIncentive + } + 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, ErrInvalidLengthIncentive + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupIncentive + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthIncentive + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthIncentive = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowIncentive = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupIncentive = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/estaking/types/keys.go b/x/estaking/types/keys.go new file mode 100644 index 000000000..44178ff1a --- /dev/null +++ b/x/estaking/types/keys.go @@ -0,0 +1,36 @@ +package types + +const ( + // ModuleName defines the module name + ModuleName = "estaking" + + // StoreKey defines the primary module store key + StoreKey = ModuleName + + // RouterKey defines the module's message routing key + RouterKey = ModuleName + + // MemStoreKey defines the in-memory store key + MemStoreKey = "mem_estaking" + + // ParamsKey is the prefix to retrieve all Params + ParamsKey = "Params/value/" + + ElysStakedKeyPrefix = "ElysStaked/value/" + ElysStakeChangeKeyPrefix = "ElysStakeChanged/value/" +) + +func KeyPrefix(p string) []byte { + return []byte(p) +} + +// ElysStakedKey returns the store key to retrieve a ElysStaked from the address fields +func ElysStakedKey(address string) []byte { + var key []byte + + addressBytes := []byte(address) + key = append(key, addressBytes...) + key = append(key, []byte("/")...) + + return key +} diff --git a/x/estaking/types/msgs.go b/x/estaking/types/msgs.go new file mode 100644 index 000000000..a89845175 --- /dev/null +++ b/x/estaking/types/msgs.go @@ -0,0 +1,109 @@ +package types + +import ( + errorsmod "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +const TypeMsgUpdateParams = "update_params" + +var _ sdk.Msg = &MsgUpdateParams{} + +func (msg *MsgUpdateParams) Route() string { + return RouterKey +} + +func (msg *MsgUpdateParams) Type() string { + return TypeMsgUpdateParams +} + +func (msg *MsgUpdateParams) GetSigners() []sdk.AccAddress { + sender, err := sdk.AccAddressFromBech32(msg.Authority) + if err != nil { + panic(err) + } + return []sdk.AccAddress{sender} +} + +func (msg *MsgUpdateParams) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +func (msg *MsgUpdateParams) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.Authority) + if err != nil { + return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid sender address (%s)", err) + } + + return nil +} + +const TypeMsgWithdrawReward = "withdraw_reward" + +var _ sdk.Msg = &MsgWithdrawReward{} + +func (msg *MsgWithdrawReward) Route() string { + return RouterKey +} + +func (msg *MsgWithdrawReward) Type() string { + return TypeMsgWithdrawReward +} + +func (msg *MsgWithdrawReward) GetSigners() []sdk.AccAddress { + sender, err := sdk.AccAddressFromBech32(msg.DelegatorAddress) + if err != nil { + panic(err) + } + return []sdk.AccAddress{sender} +} + +func (msg *MsgWithdrawReward) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +func (msg *MsgWithdrawReward) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.DelegatorAddress) + if err != nil { + return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid sender address (%s)", err) + } + + return nil +} + +const TypeMsgWithdrawElysStakingRewards = "withdraw_elys_staking_rewards" + +var _ sdk.Msg = &MsgWithdrawElysStakingRewards{} + +func (msg *MsgWithdrawElysStakingRewards) Route() string { + return RouterKey +} + +func (msg *MsgWithdrawElysStakingRewards) Type() string { + return TypeMsgWithdrawElysStakingRewards +} + +func (msg *MsgWithdrawElysStakingRewards) GetSigners() []sdk.AccAddress { + sender, err := sdk.AccAddressFromBech32(msg.DelegatorAddress) + if err != nil { + panic(err) + } + return []sdk.AccAddress{sender} +} + +func (msg *MsgWithdrawElysStakingRewards) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +func (msg *MsgWithdrawElysStakingRewards) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.DelegatorAddress) + if err != nil { + return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid sender address (%s)", err) + } + + return nil +} diff --git a/x/estaking/types/params.go b/x/estaking/types/params.go new file mode 100644 index 000000000..ac98187e2 --- /dev/null +++ b/x/estaking/types/params.go @@ -0,0 +1,32 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "gopkg.in/yaml.v2" +) + +// DefaultParams returns a default set of parameters +func DefaultParams() Params { + return Params{ + StakeIncentives: nil, + EdenCommitVal: "", + EdenbCommitVal: "", + MaxEdenRewardAprStakers: sdk.NewDecWithPrec(3, 1), // 30% + EdenBoostApr: sdk.OneDec(), + DexRewardsStakers: DexRewardsTracker{ + NumBlocks: sdk.OneInt(), + Amount: sdk.ZeroDec(), + }, + } +} + +// Validate validates the set of params +func (p Params) Validate() error { + return nil +} + +// String implements the Stringer interface. +func (p Params) String() string { + out, _ := yaml.Marshal(p) + return string(out) +} diff --git a/x/estaking/types/params.pb.go b/x/estaking/types/params.pb.go new file mode 100644 index 000000000..a15d6116a --- /dev/null +++ b/x/estaking/types/params.pb.go @@ -0,0 +1,592 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: elys/estaking/params.proto + +package types + +import ( + fmt "fmt" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + 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 + +// Params defines the parameters for the module. +type Params struct { + StakeIncentives *IncentiveInfo `protobuf:"bytes,1,opt,name=stake_incentives,json=stakeIncentives,proto3" json:"stake_incentives,omitempty"` + EdenCommitVal string `protobuf:"bytes,2,opt,name=eden_commit_val,json=edenCommitVal,proto3" json:"eden_commit_val,omitempty"` + EdenbCommitVal string `protobuf:"bytes,3,opt,name=edenb_commit_val,json=edenbCommitVal,proto3" json:"edenb_commit_val,omitempty"` + // Maximum eden reward apr for stakers - [0 - 0.3] + MaxEdenRewardAprStakers github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,5,opt,name=max_eden_reward_apr_stakers,json=maxEdenRewardAprStakers,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"max_eden_reward_apr_stakers"` + EdenBoostApr github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,6,opt,name=eden_boost_apr,json=edenBoostApr,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"eden_boost_apr"` + // Tracking dex rewards given to stakers + DexRewardsStakers DexRewardsTracker `protobuf:"bytes,7,opt,name=dex_rewards_stakers,json=dexRewardsStakers,proto3" json:"dex_rewards_stakers"` +} + +func (m *Params) Reset() { *m = Params{} } +func (*Params) ProtoMessage() {} +func (*Params) Descriptor() ([]byte, []int) { + return fileDescriptor_66041162e1ecb63b, []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 + +func (m *Params) GetStakeIncentives() *IncentiveInfo { + if m != nil { + return m.StakeIncentives + } + return nil +} + +func (m *Params) GetEdenCommitVal() string { + if m != nil { + return m.EdenCommitVal + } + return "" +} + +func (m *Params) GetEdenbCommitVal() string { + if m != nil { + return m.EdenbCommitVal + } + return "" +} + +func (m *Params) GetDexRewardsStakers() DexRewardsTracker { + if m != nil { + return m.DexRewardsStakers + } + return DexRewardsTracker{} +} + +func init() { + proto.RegisterType((*Params)(nil), "elys.estaking.Params") +} + +func init() { proto.RegisterFile("elys/estaking/params.proto", fileDescriptor_66041162e1ecb63b) } + +var fileDescriptor_66041162e1ecb63b = []byte{ + // 409 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x52, 0x3f, 0x6f, 0xda, 0x40, + 0x1c, 0xb5, 0x0b, 0xa5, 0xea, 0xb5, 0x14, 0xea, 0x56, 0xaa, 0x45, 0x5b, 0x83, 0x3a, 0x50, 0x16, + 0x6c, 0xa9, 0xdd, 0xb2, 0xe1, 0x10, 0x21, 0xb6, 0xc8, 0x41, 0x0c, 0x59, 0x4e, 0x67, 0xfb, 0xe2, + 0x58, 0xfe, 0x73, 0xd6, 0xdd, 0x05, 0xcc, 0xb7, 0xc8, 0x98, 0x31, 0x5f, 0x26, 0x12, 0x23, 0x63, + 0x94, 0x01, 0x45, 0xf0, 0x45, 0xa2, 0x3b, 0xf3, 0x37, 0x63, 0x26, 0xdb, 0xef, 0xbd, 0x7b, 0xef, + 0xf9, 0x7e, 0x3f, 0xd0, 0xc0, 0xf1, 0x8c, 0x59, 0x98, 0x71, 0x14, 0x85, 0x69, 0x60, 0x65, 0x88, + 0xa2, 0x84, 0x99, 0x19, 0x25, 0x9c, 0x68, 0x55, 0xc1, 0x99, 0x5b, 0xae, 0xf1, 0x3d, 0x20, 0x01, + 0x91, 0x8c, 0x25, 0xde, 0x0a, 0x51, 0xe3, 0xf7, 0xb1, 0x41, 0x98, 0x7a, 0x38, 0xe5, 0xe1, 0x04, + 0x6f, 0xe8, 0xbf, 0xc7, 0xb4, 0x8f, 0x73, 0x48, 0xf1, 0x14, 0x51, 0x9f, 0x41, 0x4e, 0x91, 0x17, + 0x61, 0x5a, 0x08, 0xff, 0x3c, 0x94, 0x40, 0xe5, 0x5c, 0xa6, 0x6b, 0x03, 0x50, 0x17, 0x7a, 0x0c, + 0x77, 0x66, 0x4c, 0x57, 0x5b, 0x6a, 0xe7, 0xd3, 0xbf, 0x5f, 0xe6, 0x51, 0x25, 0x73, 0xb8, 0x15, + 0x0c, 0xd3, 0x2b, 0xe2, 0xd4, 0xe4, 0xa9, 0x1d, 0xc6, 0xb4, 0x36, 0xa8, 0x61, 0x1f, 0xa7, 0xd0, + 0x23, 0x49, 0x12, 0x72, 0x38, 0x41, 0xb1, 0xfe, 0xae, 0xa5, 0x76, 0x3e, 0x3a, 0x55, 0x01, 0x9f, + 0x4a, 0x74, 0x8c, 0x62, 0xad, 0x03, 0xea, 0x02, 0x70, 0x0f, 0x85, 0x25, 0x29, 0xfc, 0x22, 0xf1, + 0xbd, 0x32, 0x06, 0x3f, 0x13, 0x94, 0x43, 0xe9, 0x5a, 0xfc, 0x07, 0x44, 0x19, 0x85, 0x32, 0x98, + 0x32, 0xfd, 0xbd, 0x38, 0x64, 0x9b, 0xf3, 0x65, 0x53, 0x79, 0x5a, 0x36, 0xdb, 0x41, 0xc8, 0xaf, + 0x6f, 0x5c, 0xd3, 0x23, 0x89, 0xe5, 0x11, 0x96, 0x10, 0xb6, 0x79, 0x74, 0x99, 0x1f, 0x59, 0x7c, + 0x96, 0x61, 0x66, 0xf6, 0xb1, 0xe7, 0xfc, 0x48, 0x50, 0x7e, 0xe6, 0xe3, 0xd4, 0x91, 0x86, 0xbd, + 0x8c, 0x5e, 0x14, 0x76, 0xda, 0x08, 0xc8, 0x7c, 0xe8, 0x12, 0xc2, 0xb8, 0x08, 0xd2, 0x2b, 0x6f, + 0x0a, 0xf8, 0x2c, 0x5c, 0x6c, 0x61, 0xd2, 0xcb, 0xa8, 0x36, 0x06, 0xdf, 0x0e, 0xc7, 0xb0, 0xed, + 0xfe, 0x41, 0xde, 0x70, 0xeb, 0xd5, 0x0d, 0xf7, 0x71, 0x5e, 0xd4, 0x62, 0xa3, 0x62, 0x5c, 0x76, + 0x59, 0x84, 0x3b, 0x5f, 0xfd, 0x1d, 0xb1, 0x69, 0x7b, 0x52, 0xbe, 0xbb, 0x6f, 0x2a, 0xf6, 0x60, + 0xbe, 0x32, 0xd4, 0xc5, 0xca, 0x50, 0x9f, 0x57, 0x86, 0x7a, 0xbb, 0x36, 0x94, 0xc5, 0xda, 0x50, + 0x1e, 0xd7, 0x86, 0x72, 0xd9, 0x3d, 0x68, 0x2b, 0x42, 0xba, 0x29, 0xe6, 0x53, 0x42, 0x23, 0xf9, + 0x61, 0xe5, 0xfb, 0x25, 0x91, 0xc5, 0xdd, 0x8a, 0xdc, 0x8b, 0xff, 0x2f, 0x01, 0x00, 0x00, 0xff, + 0xff, 0xfb, 0xd1, 0xc9, 0xc6, 0xa2, 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 + { + size, err := m.DexRewardsStakers.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x3a + { + size := m.EdenBoostApr.Size() + i -= size + if _, err := m.EdenBoostApr.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + { + size := m.MaxEdenRewardAprStakers.Size() + i -= size + if _, err := m.MaxEdenRewardAprStakers.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + if len(m.EdenbCommitVal) > 0 { + i -= len(m.EdenbCommitVal) + copy(dAtA[i:], m.EdenbCommitVal) + i = encodeVarintParams(dAtA, i, uint64(len(m.EdenbCommitVal))) + i-- + dAtA[i] = 0x1a + } + if len(m.EdenCommitVal) > 0 { + i -= len(m.EdenCommitVal) + copy(dAtA[i:], m.EdenCommitVal) + i = encodeVarintParams(dAtA, i, uint64(len(m.EdenCommitVal))) + i-- + dAtA[i] = 0x12 + } + if m.StakeIncentives != nil { + { + size, err := m.StakeIncentives.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 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 m.StakeIncentives != nil { + l = m.StakeIncentives.Size() + n += 1 + l + sovParams(uint64(l)) + } + l = len(m.EdenCommitVal) + if l > 0 { + n += 1 + l + sovParams(uint64(l)) + } + l = len(m.EdenbCommitVal) + if l > 0 { + n += 1 + l + sovParams(uint64(l)) + } + l = m.MaxEdenRewardAprStakers.Size() + n += 1 + l + sovParams(uint64(l)) + l = m.EdenBoostApr.Size() + n += 1 + l + sovParams(uint64(l)) + l = m.DexRewardsStakers.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 StakeIncentives", 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 m.StakeIncentives == nil { + m.StakeIncentives = &IncentiveInfo{} + } + if err := m.StakeIncentives.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EdenCommitVal", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.EdenCommitVal = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EdenbCommitVal", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.EdenbCommitVal = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MaxEdenRewardAprStakers", 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.MaxEdenRewardAprStakers.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EdenBoostApr", 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.EdenBoostApr.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DexRewardsStakers", 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 := m.DexRewardsStakers.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/estaking/types/query.pb.go b/x/estaking/types/query.pb.go new file mode 100644 index 000000000..a72e6a6a0 --- /dev/null +++ b/x/estaking/types/query.pb.go @@ -0,0 +1,1237 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: elys/estaking/query.proto + +package types + +import ( + context "context" + fmt "fmt" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/cosmos/cosmos-sdk/types/query" + _ "github.com/cosmos/gogoproto/gogoproto" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/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 + +// 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_c2581e8c6e0092fb, []int{0} +} +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 holds all the parameters of this module. + 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_c2581e8c6e0092fb, []int{1} +} +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{} +} + +type QueryRewardsRequest struct { + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` +} + +func (m *QueryRewardsRequest) Reset() { *m = QueryRewardsRequest{} } +func (m *QueryRewardsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryRewardsRequest) ProtoMessage() {} +func (*QueryRewardsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_c2581e8c6e0092fb, []int{2} +} +func (m *QueryRewardsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryRewardsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryRewardsRequest.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 *QueryRewardsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryRewardsRequest.Merge(m, src) +} +func (m *QueryRewardsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryRewardsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryRewardsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryRewardsRequest proto.InternalMessageInfo + +func (m *QueryRewardsRequest) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +type DelegationDelegatorReward struct { + ValidatorAddress string `protobuf:"bytes,1,opt,name=validator_address,json=validatorAddress,proto3" json:"validator_address,omitempty"` + Reward github_com_cosmos_cosmos_sdk_types.DecCoins `protobuf:"bytes,2,rep,name=reward,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.DecCoins" json:"reward"` +} + +func (m *DelegationDelegatorReward) Reset() { *m = DelegationDelegatorReward{} } +func (m *DelegationDelegatorReward) String() string { return proto.CompactTextString(m) } +func (*DelegationDelegatorReward) ProtoMessage() {} +func (*DelegationDelegatorReward) Descriptor() ([]byte, []int) { + return fileDescriptor_c2581e8c6e0092fb, []int{3} +} +func (m *DelegationDelegatorReward) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *DelegationDelegatorReward) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_DelegationDelegatorReward.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 *DelegationDelegatorReward) XXX_Merge(src proto.Message) { + xxx_messageInfo_DelegationDelegatorReward.Merge(m, src) +} +func (m *DelegationDelegatorReward) XXX_Size() int { + return m.Size() +} +func (m *DelegationDelegatorReward) XXX_DiscardUnknown() { + xxx_messageInfo_DelegationDelegatorReward.DiscardUnknown(m) +} + +var xxx_messageInfo_DelegationDelegatorReward proto.InternalMessageInfo + +func (m *DelegationDelegatorReward) GetValidatorAddress() string { + if m != nil { + return m.ValidatorAddress + } + return "" +} + +func (m *DelegationDelegatorReward) GetReward() github_com_cosmos_cosmos_sdk_types.DecCoins { + if m != nil { + return m.Reward + } + return nil +} + +type QueryRewardsResponse struct { + // rewards defines all the rewards accrued by a delegator. + Rewards []DelegationDelegatorReward `protobuf:"bytes,1,rep,name=rewards,proto3" json:"rewards"` + // total defines the sum of all the rewards. + Total github_com_cosmos_cosmos_sdk_types.DecCoins `protobuf:"bytes,2,rep,name=total,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.DecCoins" json:"total"` +} + +func (m *QueryRewardsResponse) Reset() { *m = QueryRewardsResponse{} } +func (m *QueryRewardsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryRewardsResponse) ProtoMessage() {} +func (*QueryRewardsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_c2581e8c6e0092fb, []int{4} +} +func (m *QueryRewardsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryRewardsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryRewardsResponse.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 *QueryRewardsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryRewardsResponse.Merge(m, src) +} +func (m *QueryRewardsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryRewardsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryRewardsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryRewardsResponse proto.InternalMessageInfo + +func (m *QueryRewardsResponse) GetRewards() []DelegationDelegatorReward { + if m != nil { + return m.Rewards + } + return nil +} + +func (m *QueryRewardsResponse) GetTotal() github_com_cosmos_cosmos_sdk_types.DecCoins { + if m != nil { + return m.Total + } + return nil +} + +func init() { + proto.RegisterType((*QueryParamsRequest)(nil), "elys.estaking.QueryParamsRequest") + proto.RegisterType((*QueryParamsResponse)(nil), "elys.estaking.QueryParamsResponse") + proto.RegisterType((*QueryRewardsRequest)(nil), "elys.estaking.QueryRewardsRequest") + proto.RegisterType((*DelegationDelegatorReward)(nil), "elys.estaking.DelegationDelegatorReward") + proto.RegisterType((*QueryRewardsResponse)(nil), "elys.estaking.QueryRewardsResponse") +} + +func init() { proto.RegisterFile("elys/estaking/query.proto", fileDescriptor_c2581e8c6e0092fb) } + +var fileDescriptor_c2581e8c6e0092fb = []byte{ + // 504 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x53, 0x4d, 0x6f, 0x13, 0x31, + 0x10, 0xcd, 0x06, 0x9a, 0x08, 0x57, 0x48, 0x60, 0x82, 0x94, 0xae, 0xaa, 0x6d, 0x59, 0x38, 0x44, + 0xad, 0x62, 0xab, 0x89, 0xf8, 0x01, 0x84, 0x4a, 0x20, 0x4e, 0xb0, 0x47, 0x2e, 0xc8, 0xd9, 0xb5, + 0x8c, 0x95, 0x8d, 0xbd, 0x5d, 0x3b, 0x2d, 0x51, 0xc5, 0x85, 0x1b, 0xb7, 0x4a, 0xfc, 0x0b, 0xae, + 0xfc, 0x89, 0x72, 0xab, 0xc4, 0x85, 0x13, 0xa0, 0x84, 0x1f, 0x82, 0xfc, 0xb1, 0xa5, 0xdb, 0x96, + 0xdc, 0x38, 0xc5, 0x99, 0xf7, 0xe6, 0xcd, 0x9b, 0x97, 0x09, 0xd8, 0xa0, 0xf9, 0x5c, 0x61, 0xaa, + 0x34, 0x99, 0x70, 0xc1, 0xf0, 0xc1, 0x8c, 0x96, 0x73, 0x54, 0x94, 0x52, 0x4b, 0x78, 0xdb, 0x40, + 0xa8, 0x82, 0xc2, 0x0e, 0x93, 0x4c, 0x5a, 0x04, 0x9b, 0x97, 0x23, 0x85, 0x9b, 0x4c, 0x4a, 0x96, + 0x53, 0x4c, 0x0a, 0x8e, 0x89, 0x10, 0x52, 0x13, 0xcd, 0xa5, 0x50, 0x1e, 0x8d, 0x52, 0xa9, 0xa6, + 0x52, 0xe1, 0x31, 0x51, 0x14, 0x1f, 0xee, 0x8d, 0xa9, 0x26, 0x7b, 0x38, 0x95, 0x5c, 0x78, 0x7c, + 0xe7, 0x22, 0x6e, 0x67, 0x9f, 0xb3, 0x0a, 0xc2, 0xb8, 0xb0, 0x62, 0x9e, 0x1b, 0xd6, 0x9d, 0x16, + 0xa4, 0x24, 0x53, 0x3f, 0x27, 0xee, 0x00, 0xf8, 0xca, 0x74, 0xbf, 0xb4, 0xc5, 0x84, 0x1e, 0xcc, + 0xa8, 0xd2, 0xf1, 0x0b, 0x70, 0xaf, 0x56, 0x55, 0x85, 0x14, 0x8a, 0xc2, 0x21, 0x68, 0xb9, 0xe6, + 0x6e, 0xb0, 0x1d, 0xf4, 0xd6, 0x07, 0xf7, 0x51, 0x6d, 0x51, 0xe4, 0xe8, 0xa3, 0x9b, 0xa7, 0x3f, + 0xb6, 0x1a, 0x89, 0xa7, 0xc6, 0xd8, 0x6b, 0x25, 0xf4, 0x88, 0x94, 0x59, 0x35, 0x02, 0x76, 0x41, + 0x9b, 0x64, 0x59, 0x49, 0x95, 0x13, 0xbb, 0x95, 0x54, 0x5f, 0xe3, 0x2f, 0x01, 0xd8, 0xd8, 0xa7, + 0x39, 0x65, 0x76, 0x07, 0xff, 0x92, 0xa5, 0xeb, 0x87, 0xbb, 0xe0, 0xee, 0x21, 0xc9, 0x79, 0x66, + 0x4a, 0x6f, 0xea, 0x0a, 0x77, 0xce, 0x81, 0x27, 0xae, 0x0e, 0x39, 0x68, 0x95, 0xb6, 0xad, 0xdb, + 0xdc, 0xbe, 0xd1, 0x5b, 0x1f, 0x6c, 0x22, 0x17, 0x1b, 0x32, 0xb1, 0x21, 0x1f, 0x18, 0xda, 0xa7, + 0xe9, 0x53, 0xc9, 0xc5, 0x68, 0x68, 0x7c, 0x7f, 0xfe, 0xb9, 0xb5, 0xcb, 0xb8, 0x7e, 0x3b, 0x1b, + 0xa3, 0x54, 0x4e, 0xb1, 0x8f, 0xd9, 0x7d, 0xf4, 0x55, 0x36, 0xc1, 0x7a, 0x5e, 0x50, 0x55, 0xf5, + 0xa8, 0xc4, 0x0f, 0x88, 0xbf, 0x06, 0xa0, 0x53, 0xdf, 0xd3, 0x87, 0xf6, 0x1c, 0xb4, 0x1d, 0xc5, + 0xd8, 0x34, 0x26, 0x7a, 0x97, 0x52, 0xfb, 0xe7, 0xae, 0x3e, 0xc8, 0xaa, 0x1d, 0x32, 0xb0, 0xa6, + 0xa5, 0x26, 0xf9, 0xff, 0x5b, 0xc6, 0xe9, 0x0f, 0x4e, 0x9a, 0x60, 0xcd, 0xee, 0x02, 0x8f, 0x41, + 0xcb, 0xfd, 0xa8, 0xf0, 0xc1, 0x25, 0xd7, 0x57, 0xaf, 0x26, 0x8c, 0x57, 0x51, 0x5c, 0x1a, 0xf1, + 0xce, 0x87, 0x6f, 0xbf, 0x3f, 0x35, 0x1f, 0xc1, 0x18, 0x1b, 0x6e, 0x5f, 0x50, 0x7d, 0x24, 0xcb, + 0x09, 0xbe, 0xee, 0x42, 0xe1, 0xc7, 0x00, 0xb4, 0x7d, 0x9a, 0xf0, 0x5a, 0xed, 0xfa, 0x49, 0x85, + 0x0f, 0x57, 0x72, 0xbc, 0x81, 0xc7, 0xd6, 0x00, 0x86, 0xfd, 0x55, 0x06, 0x7c, 0xe2, 0xf8, 0xd8, + 0x1f, 0xd8, 0xfb, 0xd1, 0xb3, 0xd3, 0x45, 0x14, 0x9c, 0x2d, 0xa2, 0xe0, 0xd7, 0x22, 0x0a, 0x4e, + 0x96, 0x51, 0xe3, 0x6c, 0x19, 0x35, 0xbe, 0x2f, 0xa3, 0xc6, 0xeb, 0xfe, 0x85, 0x80, 0xaf, 0x4a, + 0xbe, 0xfb, 0x2b, 0x6a, 0xb3, 0x1e, 0xb7, 0xec, 0xff, 0x6e, 0xf8, 0x27, 0x00, 0x00, 0xff, 0xff, + 0x1f, 0x57, 0x10, 0xe9, 0x3f, 0x04, 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 { + // Parameters queries the parameters of the module. + Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) + // Rewards queries the total rewards accrued by a delegation + Rewards(ctx context.Context, in *QueryRewardsRequest, opts ...grpc.CallOption) (*QueryRewardsResponse, 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, "/elys.estaking.Query/Params", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) Rewards(ctx context.Context, in *QueryRewardsRequest, opts ...grpc.CallOption) (*QueryRewardsResponse, error) { + out := new(QueryRewardsResponse) + err := c.cc.Invoke(ctx, "/elys.estaking.Query/Rewards", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + // Parameters queries the parameters of the module. + Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) + // Rewards queries the total rewards accrued by a delegation + Rewards(context.Context, *QueryRewardsRequest) (*QueryRewardsResponse, 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) Rewards(ctx context.Context, req *QueryRewardsRequest) (*QueryRewardsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Rewards 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: "/elys.estaking.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_Rewards_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryRewardsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Rewards(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/elys.estaking.Query/Rewards", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Rewards(ctx, req.(*QueryRewardsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "elys.estaking.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Params", + Handler: _Query_Params_Handler, + }, + { + MethodName: "Rewards", + Handler: _Query_Rewards_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "elys/estaking/query.proto", +} + +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 *QueryRewardsRequest) 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 *QueryRewardsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryRewardsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *DelegationDelegatorReward) 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 *DelegationDelegatorReward) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *DelegationDelegatorReward) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Reward) > 0 { + for iNdEx := len(m.Reward) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Reward[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if len(m.ValidatorAddress) > 0 { + i -= len(m.ValidatorAddress) + copy(dAtA[i:], m.ValidatorAddress) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ValidatorAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryRewardsResponse) 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 *QueryRewardsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryRewardsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Total) > 0 { + for iNdEx := len(m.Total) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Total[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + 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 = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + 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 *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 *QueryRewardsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *DelegationDelegatorReward) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ValidatorAddress) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if len(m.Reward) > 0 { + for _, e := range m.Reward { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + +func (m *QueryRewardsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Rewards) > 0 { + for _, e := range m.Rewards { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if len(m.Total) > 0 { + for _, e := range m.Total { + l = e.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 *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 *QueryRewardsRequest) 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: QueryRewardsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryRewardsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", 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.Address = string(dAtA[iNdEx:postIndex]) + 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 *DelegationDelegatorReward) 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: DelegationDelegatorReward: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DelegationDelegatorReward: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ValidatorAddress", 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.ValidatorAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Reward", 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.Reward = append(m.Reward, types.DecCoin{}) + if err := m.Reward[len(m.Reward)-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 *QueryRewardsResponse) 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: QueryRewardsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryRewardsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 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.Rewards = append(m.Rewards, DelegationDelegatorReward{}) + if err := m.Rewards[len(m.Rewards)-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 Total", 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.Total = append(m.Total, types.DecCoin{}) + if err := m.Total[len(m.Total)-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 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/estaking/types/query.pb.gw.go b/x/estaking/types/query.pb.gw.go new file mode 100644 index 000000000..7513470bc --- /dev/null +++ b/x/estaking/types/query.pb.gw.go @@ -0,0 +1,246 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: elys/estaking/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 + +} + +func request_Query_Rewards_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryRewardsRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["address"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "address") + } + + protoReq.Address, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "address", err) + } + + msg, err := client.Rewards(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Rewards_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryRewardsRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["address"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "address") + } + + protoReq.Address, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "address", err) + } + + msg, err := server.Rewards(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_Rewards_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_Rewards_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_Rewards_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_Rewards_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_Rewards_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_Rewards_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{"elys-network", "elys", "estaking", "params"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_Rewards_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"elys-network", "elys", "estaking", "rewards", "address"}, "", runtime.AssumeColonVerbOpt(true))) +) + +var ( + forward_Query_Params_0 = runtime.ForwardResponseMessage + + forward_Query_Rewards_0 = runtime.ForwardResponseMessage +) diff --git a/x/estaking/types/tx.pb.go b/x/estaking/types/tx.pb.go new file mode 100644 index 000000000..f4c67af39 --- /dev/null +++ b/x/estaking/types/tx.pb.go @@ -0,0 +1,1433 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: elys/estaking/tx.proto + +package types + +import ( + context "context" + fmt "fmt" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/cosmos/gogoproto/gogoproto" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/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 + +// MsgUpdateParams is the Msg/UpdateParams request type. +type MsgUpdateParams struct { + Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` + Params Params `protobuf:"bytes,2,opt,name=params,proto3" json:"params"` +} + +func (m *MsgUpdateParams) Reset() { *m = MsgUpdateParams{} } +func (m *MsgUpdateParams) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateParams) ProtoMessage() {} +func (*MsgUpdateParams) Descriptor() ([]byte, []int) { + return fileDescriptor_dcd8bcdd6e10f7de, []int{0} +} +func (m *MsgUpdateParams) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateParams.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 *MsgUpdateParams) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateParams.Merge(m, src) +} +func (m *MsgUpdateParams) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateParams) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateParams.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateParams proto.InternalMessageInfo + +func (m *MsgUpdateParams) GetAuthority() string { + if m != nil { + return m.Authority + } + return "" +} + +func (m *MsgUpdateParams) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +// MsgUpdateParamsResponse defines the response structure for executing a MsgUpdateParams message. +type MsgUpdateParamsResponse struct { +} + +func (m *MsgUpdateParamsResponse) Reset() { *m = MsgUpdateParamsResponse{} } +func (m *MsgUpdateParamsResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateParamsResponse) ProtoMessage() {} +func (*MsgUpdateParamsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_dcd8bcdd6e10f7de, []int{1} +} +func (m *MsgUpdateParamsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateParamsResponse.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 *MsgUpdateParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateParamsResponse.Merge(m, src) +} +func (m *MsgUpdateParamsResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateParamsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateParamsResponse proto.InternalMessageInfo + +// MsgWithdrawReward represents delegation withdrawal to a delegator from a single validator. +type MsgWithdrawReward struct { + DelegatorAddress string `protobuf:"bytes,1,opt,name=delegator_address,json=delegatorAddress,proto3" json:"delegator_address,omitempty"` + ValidatorAddress string `protobuf:"bytes,2,opt,name=validator_address,json=validatorAddress,proto3" json:"validator_address,omitempty"` +} + +func (m *MsgWithdrawReward) Reset() { *m = MsgWithdrawReward{} } +func (m *MsgWithdrawReward) String() string { return proto.CompactTextString(m) } +func (*MsgWithdrawReward) ProtoMessage() {} +func (*MsgWithdrawReward) Descriptor() ([]byte, []int) { + return fileDescriptor_dcd8bcdd6e10f7de, []int{2} +} +func (m *MsgWithdrawReward) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgWithdrawReward) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgWithdrawReward.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 *MsgWithdrawReward) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgWithdrawReward.Merge(m, src) +} +func (m *MsgWithdrawReward) XXX_Size() int { + return m.Size() +} +func (m *MsgWithdrawReward) XXX_DiscardUnknown() { + xxx_messageInfo_MsgWithdrawReward.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgWithdrawReward proto.InternalMessageInfo + +func (m *MsgWithdrawReward) GetDelegatorAddress() string { + if m != nil { + return m.DelegatorAddress + } + return "" +} + +func (m *MsgWithdrawReward) GetValidatorAddress() string { + if m != nil { + return m.ValidatorAddress + } + return "" +} + +// MsgWithdrawRewardResponse defines the Msg/WithdrawDelegatorReward response type. +type MsgWithdrawRewardResponse struct { + Amount github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,1,rep,name=amount,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"amount"` +} + +func (m *MsgWithdrawRewardResponse) Reset() { *m = MsgWithdrawRewardResponse{} } +func (m *MsgWithdrawRewardResponse) String() string { return proto.CompactTextString(m) } +func (*MsgWithdrawRewardResponse) ProtoMessage() {} +func (*MsgWithdrawRewardResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_dcd8bcdd6e10f7de, []int{3} +} +func (m *MsgWithdrawRewardResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgWithdrawRewardResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgWithdrawRewardResponse.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 *MsgWithdrawRewardResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgWithdrawRewardResponse.Merge(m, src) +} +func (m *MsgWithdrawRewardResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgWithdrawRewardResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgWithdrawRewardResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgWithdrawRewardResponse proto.InternalMessageInfo + +func (m *MsgWithdrawRewardResponse) GetAmount() github_com_cosmos_cosmos_sdk_types.Coins { + if m != nil { + return m.Amount + } + return nil +} + +// MsgWithdrawElysStakingRewards represents delegation withdrawal to a delegator from all the validators. +type MsgWithdrawElysStakingRewards struct { + DelegatorAddress string `protobuf:"bytes,1,opt,name=delegator_address,json=delegatorAddress,proto3" json:"delegator_address,omitempty"` +} + +func (m *MsgWithdrawElysStakingRewards) Reset() { *m = MsgWithdrawElysStakingRewards{} } +func (m *MsgWithdrawElysStakingRewards) String() string { return proto.CompactTextString(m) } +func (*MsgWithdrawElysStakingRewards) ProtoMessage() {} +func (*MsgWithdrawElysStakingRewards) Descriptor() ([]byte, []int) { + return fileDescriptor_dcd8bcdd6e10f7de, []int{4} +} +func (m *MsgWithdrawElysStakingRewards) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgWithdrawElysStakingRewards) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgWithdrawElysStakingRewards.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 *MsgWithdrawElysStakingRewards) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgWithdrawElysStakingRewards.Merge(m, src) +} +func (m *MsgWithdrawElysStakingRewards) XXX_Size() int { + return m.Size() +} +func (m *MsgWithdrawElysStakingRewards) XXX_DiscardUnknown() { + xxx_messageInfo_MsgWithdrawElysStakingRewards.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgWithdrawElysStakingRewards proto.InternalMessageInfo + +func (m *MsgWithdrawElysStakingRewards) GetDelegatorAddress() string { + if m != nil { + return m.DelegatorAddress + } + return "" +} + +// MsgWithdrawElysStakingRewards defines the Msg/WithdrawElysStakingRewards response type. +type MsgWithdrawElysStakingRewardsResponse struct { + Amount github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,1,rep,name=amount,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"amount"` +} + +func (m *MsgWithdrawElysStakingRewardsResponse) Reset() { *m = MsgWithdrawElysStakingRewardsResponse{} } +func (m *MsgWithdrawElysStakingRewardsResponse) String() string { return proto.CompactTextString(m) } +func (*MsgWithdrawElysStakingRewardsResponse) ProtoMessage() {} +func (*MsgWithdrawElysStakingRewardsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_dcd8bcdd6e10f7de, []int{5} +} +func (m *MsgWithdrawElysStakingRewardsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgWithdrawElysStakingRewardsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgWithdrawElysStakingRewardsResponse.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 *MsgWithdrawElysStakingRewardsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgWithdrawElysStakingRewardsResponse.Merge(m, src) +} +func (m *MsgWithdrawElysStakingRewardsResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgWithdrawElysStakingRewardsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgWithdrawElysStakingRewardsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgWithdrawElysStakingRewardsResponse proto.InternalMessageInfo + +func (m *MsgWithdrawElysStakingRewardsResponse) GetAmount() github_com_cosmos_cosmos_sdk_types.Coins { + if m != nil { + return m.Amount + } + return nil +} + +func init() { + proto.RegisterType((*MsgUpdateParams)(nil), "elys.estaking.MsgUpdateParams") + proto.RegisterType((*MsgUpdateParamsResponse)(nil), "elys.estaking.MsgUpdateParamsResponse") + proto.RegisterType((*MsgWithdrawReward)(nil), "elys.estaking.MsgWithdrawReward") + proto.RegisterType((*MsgWithdrawRewardResponse)(nil), "elys.estaking.MsgWithdrawRewardResponse") + proto.RegisterType((*MsgWithdrawElysStakingRewards)(nil), "elys.estaking.MsgWithdrawElysStakingRewards") + proto.RegisterType((*MsgWithdrawElysStakingRewardsResponse)(nil), "elys.estaking.MsgWithdrawElysStakingRewardsResponse") +} + +func init() { proto.RegisterFile("elys/estaking/tx.proto", fileDescriptor_dcd8bcdd6e10f7de) } + +var fileDescriptor_dcd8bcdd6e10f7de = []byte{ + // 476 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x54, 0x4d, 0x8b, 0xd3, 0x40, + 0x18, 0xee, 0x74, 0xa5, 0xb0, 0xb3, 0x7e, 0x6d, 0xf0, 0xa3, 0x0d, 0x9a, 0x2d, 0x01, 0x25, 0xa0, + 0x9d, 0x71, 0xbb, 0xfe, 0x01, 0x2b, 0xe2, 0xc5, 0x82, 0x44, 0x54, 0x10, 0x41, 0xa6, 0x9d, 0x61, + 0x1a, 0xda, 0x64, 0xc2, 0xbc, 0xd3, 0xed, 0xf6, 0xb6, 0x3f, 0xc0, 0x83, 0xbf, 0xc3, 0x1f, 0xe1, + 0x79, 0x8f, 0x7b, 0xf4, 0xa4, 0xd2, 0xfe, 0x11, 0x49, 0x26, 0xad, 0x4d, 0x8b, 0x95, 0x5e, 0x3c, + 0x25, 0x79, 0x9f, 0x67, 0x9e, 0xf7, 0x79, 0x3f, 0x32, 0xf8, 0x8e, 0x18, 0x4d, 0x81, 0x0a, 0x30, + 0x6c, 0x18, 0x25, 0x92, 0x9a, 0x33, 0x92, 0x6a, 0x65, 0x94, 0x73, 0x2d, 0x8b, 0x93, 0x45, 0xdc, + 0xbd, 0x25, 0x95, 0x54, 0x39, 0x42, 0xb3, 0x37, 0x4b, 0x72, 0xbd, 0xbe, 0x82, 0x58, 0x01, 0xed, + 0x31, 0x10, 0xf4, 0xf4, 0xb8, 0x27, 0x0c, 0x3b, 0xa6, 0x7d, 0x15, 0x25, 0x05, 0xee, 0x96, 0xc5, + 0x53, 0xa6, 0x59, 0x0c, 0x16, 0xf3, 0x39, 0xbe, 0xd1, 0x05, 0xf9, 0x36, 0xe5, 0xcc, 0x88, 0xd7, + 0x39, 0xe0, 0xdc, 0xc3, 0xfb, 0x6c, 0x6c, 0x06, 0x4a, 0x47, 0x66, 0x5a, 0x47, 0x4d, 0x14, 0xec, + 0x87, 0x7f, 0x02, 0xce, 0x09, 0xae, 0x59, 0x81, 0x7a, 0xb5, 0x89, 0x82, 0x83, 0xf6, 0x6d, 0x52, + 0xb2, 0x48, 0xac, 0x48, 0xe7, 0xca, 0xc5, 0x8f, 0xa3, 0x4a, 0x58, 0x50, 0xfd, 0x06, 0xbe, 0xbb, + 0x96, 0x25, 0x14, 0x90, 0xaa, 0x04, 0x84, 0x1f, 0xe3, 0xc3, 0x2e, 0xc8, 0xf7, 0x91, 0x19, 0x70, + 0xcd, 0x26, 0xa1, 0x98, 0x30, 0xcd, 0x9d, 0x47, 0xf8, 0x90, 0x8b, 0x91, 0x90, 0xcc, 0x28, 0xfd, + 0x89, 0x71, 0xae, 0x05, 0x40, 0x61, 0xe5, 0xe6, 0x12, 0x78, 0x66, 0xe3, 0x19, 0xf9, 0x94, 0x8d, + 0x22, 0x5e, 0x22, 0x57, 0x2d, 0x79, 0x09, 0x14, 0x64, 0xff, 0x1c, 0xe1, 0xc6, 0x46, 0xbe, 0x85, + 0x19, 0xa7, 0x8f, 0x6b, 0x2c, 0x56, 0xe3, 0xc4, 0xd4, 0x51, 0x73, 0x2f, 0x38, 0x68, 0x37, 0x88, + 0x6d, 0x2d, 0xc9, 0x5a, 0x4b, 0x8a, 0xd6, 0x92, 0xe7, 0x2a, 0x4a, 0x3a, 0x4f, 0xb2, 0x02, 0xbf, + 0xfe, 0x3c, 0x0a, 0x64, 0x64, 0x06, 0xe3, 0x1e, 0xe9, 0xab, 0x98, 0x16, 0x73, 0xb0, 0x8f, 0x16, + 0xf0, 0x21, 0x35, 0xd3, 0x54, 0x40, 0x7e, 0x00, 0xc2, 0x42, 0xda, 0x7f, 0x85, 0xef, 0xaf, 0x38, + 0x78, 0x31, 0x9a, 0xc2, 0x1b, 0xdb, 0x3b, 0x6b, 0x06, 0x76, 0xaa, 0xde, 0xff, 0x8c, 0xf0, 0x83, + 0xad, 0x72, 0xff, 0xb5, 0xb8, 0xf6, 0xb7, 0x2a, 0xde, 0xeb, 0x82, 0x74, 0xde, 0xe1, 0xab, 0xa5, + 0xa5, 0xf2, 0xd6, 0xd6, 0x64, 0x6d, 0x1d, 0xdc, 0x87, 0xdb, 0xf1, 0x65, 0x11, 0x1f, 0xf1, 0xf5, + 0xb5, 0x5d, 0x69, 0x6e, 0x9e, 0x2c, 0x33, 0xdc, 0xe0, 0x5f, 0x8c, 0xa5, 0xfa, 0x39, 0xc2, 0xee, + 0x96, 0xc1, 0x3c, 0xfe, 0xbb, 0xd0, 0x26, 0xdb, 0x7d, 0xba, 0x0b, 0x7b, 0x61, 0xa1, 0xf3, 0xf2, + 0x62, 0xe6, 0xa1, 0xcb, 0x99, 0x87, 0x7e, 0xcd, 0x3c, 0xf4, 0x65, 0xee, 0x55, 0x2e, 0xe7, 0x5e, + 0xe5, 0xfb, 0xdc, 0xab, 0x7c, 0x68, 0xad, 0x0c, 0x23, 0x53, 0x6e, 0x25, 0xc2, 0x4c, 0x94, 0x1e, + 0xe6, 0x1f, 0xf4, 0x6c, 0xe5, 0xf6, 0xc8, 0xe6, 0xd2, 0xab, 0xe5, 0x3f, 0xf8, 0xc9, 0xef, 0x00, + 0x00, 0x00, 0xff, 0xff, 0x16, 0xeb, 0xb8, 0x4f, 0x5b, 0x04, 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 { + // UpdateParams defines a governance operation for updating the x/distribution + // module parameters. The authority is defined in the keeper. + UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) + // WithdrawReward defines a method to withdraw rewards of delegator from a single validator. + WithdrawReward(ctx context.Context, in *MsgWithdrawReward, opts ...grpc.CallOption) (*MsgWithdrawRewardResponse, error) + // WithdrawElysStakingRewards defines a method to withdraw rewards of delegator from all the validators. + WithdrawElysStakingRewards(ctx context.Context, in *MsgWithdrawElysStakingRewards, opts ...grpc.CallOption) (*MsgWithdrawElysStakingRewardsResponse, error) +} + +type msgClient struct { + cc grpc1.ClientConn +} + +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} +} + +func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) { + out := new(MsgUpdateParamsResponse) + err := c.cc.Invoke(ctx, "/elys.estaking.Msg/UpdateParams", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) WithdrawReward(ctx context.Context, in *MsgWithdrawReward, opts ...grpc.CallOption) (*MsgWithdrawRewardResponse, error) { + out := new(MsgWithdrawRewardResponse) + err := c.cc.Invoke(ctx, "/elys.estaking.Msg/WithdrawReward", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) WithdrawElysStakingRewards(ctx context.Context, in *MsgWithdrawElysStakingRewards, opts ...grpc.CallOption) (*MsgWithdrawElysStakingRewardsResponse, error) { + out := new(MsgWithdrawElysStakingRewardsResponse) + err := c.cc.Invoke(ctx, "/elys.estaking.Msg/WithdrawElysStakingRewards", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MsgServer is the server API for Msg service. +type MsgServer interface { + // UpdateParams defines a governance operation for updating the x/distribution + // module parameters. The authority is defined in the keeper. + UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) + // WithdrawReward defines a method to withdraw rewards of delegator from a single validator. + WithdrawReward(context.Context, *MsgWithdrawReward) (*MsgWithdrawRewardResponse, error) + // WithdrawElysStakingRewards defines a method to withdraw rewards of delegator from all the validators. + WithdrawElysStakingRewards(context.Context, *MsgWithdrawElysStakingRewards) (*MsgWithdrawElysStakingRewardsResponse, error) +} + +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { +} + +func (*UnimplementedMsgServer) UpdateParams(ctx context.Context, req *MsgUpdateParams) (*MsgUpdateParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateParams not implemented") +} +func (*UnimplementedMsgServer) WithdrawReward(ctx context.Context, req *MsgWithdrawReward) (*MsgWithdrawRewardResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method WithdrawReward not implemented") +} +func (*UnimplementedMsgServer) WithdrawElysStakingRewards(ctx context.Context, req *MsgWithdrawElysStakingRewards) (*MsgWithdrawElysStakingRewardsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method WithdrawElysStakingRewards not implemented") +} + +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { + s.RegisterService(&_Msg_serviceDesc, srv) +} + +func _Msg_UpdateParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateParams) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).UpdateParams(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/elys.estaking.Msg/UpdateParams", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UpdateParams(ctx, req.(*MsgUpdateParams)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_WithdrawReward_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgWithdrawReward) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).WithdrawReward(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/elys.estaking.Msg/WithdrawReward", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).WithdrawReward(ctx, req.(*MsgWithdrawReward)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_WithdrawElysStakingRewards_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgWithdrawElysStakingRewards) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).WithdrawElysStakingRewards(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/elys.estaking.Msg/WithdrawElysStakingRewards", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).WithdrawElysStakingRewards(ctx, req.(*MsgWithdrawElysStakingRewards)) + } + return interceptor(ctx, in, info, handler) +} + +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "elys.estaking.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "UpdateParams", + Handler: _Msg_UpdateParams_Handler, + }, + { + MethodName: "WithdrawReward", + Handler: _Msg_WithdrawReward_Handler, + }, + { + MethodName: "WithdrawElysStakingRewards", + Handler: _Msg_WithdrawElysStakingRewards_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "elys/estaking/tx.proto", +} + +func (m *MsgUpdateParams) 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 *MsgUpdateParams) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateParams) 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 = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.Authority) > 0 { + i -= len(m.Authority) + copy(dAtA[i:], m.Authority) + i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgUpdateParamsResponse) 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 *MsgUpdateParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgWithdrawReward) 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 *MsgWithdrawReward) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgWithdrawReward) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ValidatorAddress) > 0 { + i -= len(m.ValidatorAddress) + copy(dAtA[i:], m.ValidatorAddress) + i = encodeVarintTx(dAtA, i, uint64(len(m.ValidatorAddress))) + i-- + dAtA[i] = 0x12 + } + if len(m.DelegatorAddress) > 0 { + i -= len(m.DelegatorAddress) + copy(dAtA[i:], m.DelegatorAddress) + i = encodeVarintTx(dAtA, i, uint64(len(m.DelegatorAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgWithdrawRewardResponse) 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 *MsgWithdrawRewardResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgWithdrawRewardResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Amount) > 0 { + for iNdEx := len(m.Amount) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Amount[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *MsgWithdrawElysStakingRewards) 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 *MsgWithdrawElysStakingRewards) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgWithdrawElysStakingRewards) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.DelegatorAddress) > 0 { + i -= len(m.DelegatorAddress) + copy(dAtA[i:], m.DelegatorAddress) + i = encodeVarintTx(dAtA, i, uint64(len(m.DelegatorAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgWithdrawElysStakingRewardsResponse) 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 *MsgWithdrawElysStakingRewardsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgWithdrawElysStakingRewardsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Amount) > 0 { + for iNdEx := len(m.Amount) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Amount[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + 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 *MsgUpdateParams) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Authority) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.Params.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *MsgUpdateParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgWithdrawReward) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.DelegatorAddress) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.ValidatorAddress) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgWithdrawRewardResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Amount) > 0 { + for _, e := range m.Amount { + l = e.Size() + n += 1 + l + sovTx(uint64(l)) + } + } + return n +} + +func (m *MsgWithdrawElysStakingRewards) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.DelegatorAddress) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgWithdrawElysStakingRewardsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Amount) > 0 { + for _, e := range m.Amount { + l = e.Size() + n += 1 + l + sovTx(uint64(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 *MsgUpdateParams) 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: MsgUpdateParams: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateParams: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Authority", 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.Authority = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + 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 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.Params.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 *MsgUpdateParamsResponse) 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: MsgUpdateParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateParamsResponse: 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 *MsgWithdrawReward) 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: MsgWithdrawReward: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgWithdrawReward: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DelegatorAddress", 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.DelegatorAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ValidatorAddress", 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.ValidatorAddress = 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 *MsgWithdrawRewardResponse) 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: MsgWithdrawRewardResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgWithdrawRewardResponse: 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 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 + } + m.Amount = append(m.Amount, types.Coin{}) + if err := m.Amount[len(m.Amount)-1].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 *MsgWithdrawElysStakingRewards) 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: MsgWithdrawElysStakingRewards: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgWithdrawElysStakingRewards: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DelegatorAddress", 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.DelegatorAddress = 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 *MsgWithdrawElysStakingRewardsResponse) 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: MsgWithdrawElysStakingRewardsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgWithdrawElysStakingRewardsResponse: 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 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 + } + m.Amount = append(m.Amount, types.Coin{}) + if err := m.Amount[len(m.Amount)-1].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 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") +) diff --git a/x/estaking/types/types.go b/x/estaking/types/types.go new file mode 100644 index 000000000..ab1254f4c --- /dev/null +++ b/x/estaking/types/types.go @@ -0,0 +1 @@ +package types diff --git a/x/incentive/client/cli/queries.go b/x/incentive/client/cli/queries.go index 9bb9eabaf..a4831876f 100644 --- a/x/incentive/client/cli/queries.go +++ b/x/incentive/client/cli/queries.go @@ -12,59 +12,6 @@ import ( "github.com/spf13/cobra" ) -func CmdCommunityPool() *cobra.Command { - cmd := &cobra.Command{ - Use: "community-pool", - Short: "Query community-pool", - Args: cobra.ExactArgs(0), - RunE: func(cmd *cobra.Command, args []string) (err error) { - clientCtx, err := client.GetClientQueryContext(cmd) - if err != nil { - return err - } - - queryClient := types.NewQueryClient(clientCtx) - - params := &types.QueryCommunityPoolRequest{} - - res, err := queryClient.CommunityPool(cmd.Context(), params) - if err != nil { - return err - } - - return clientCtx.PrintProto(res) - }, - } - - flags.AddQueryFlagsToCmd(cmd) - - return cmd -} - -func CmdQueryParams() *cobra.Command { - cmd := &cobra.Command{ - Use: "params", - Short: "shows the parameters of the module", - Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx := client.GetClientContextFromCmd(cmd) - - queryClient := types.NewQueryClient(clientCtx) - - res, err := queryClient.Params(context.Background(), &types.QueryParamsRequest{}) - if err != nil { - return err - } - - return clientCtx.PrintProto(res) - }, - } - - flags.AddQueryFlagsToCmd(cmd) - - return cmd -} - func CmdApr() *cobra.Command { cmd := &cobra.Command{ Use: "apr", @@ -129,45 +76,6 @@ func CmdAprs() *cobra.Command { return cmd } -func CmdPoolAprs() *cobra.Command { - cmd := &cobra.Command{ - Use: "pool-aprs", - Short: "calculate pool APRs", - Example: "elysd q incentive pool-aprs [ids]", - Args: cobra.ExactArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx := client.GetClientContextFromCmd(cmd) - queryClient := types.NewQueryClient(clientCtx) - - idStrs := strings.Split(args[0], ",") - ids := []uint64{} - if args[0] != "" { - for _, idStr := range idStrs { - id, err := strconv.Atoi(idStr) - if err != nil { - return err - } - ids = append(ids, uint64(id)) - } - } - params := &types.QueryPoolAprsRequest{ - PoolIds: ids, - } - - res, err := queryClient.PoolAprs(context.Background(), params) - if err != nil { - return err - } - - return clientCtx.PrintProto(res) - }, - } - - flags.AddQueryFlagsToCmd(cmd) - - return cmd -} - func CmdPoolRewards() *cobra.Command { cmd := &cobra.Command{ Use: "pool-rewards", diff --git a/x/incentive/client/cli/query.go b/x/incentive/client/cli/query.go index cd0419a05..283af7025 100644 --- a/x/incentive/client/cli/query.go +++ b/x/incentive/client/cli/query.go @@ -19,11 +19,8 @@ func GetQueryCmd(queryRoute string) *cobra.Command { RunE: client.ValidateCmd, } - cmd.AddCommand(CmdQueryParams()) - cmd.AddCommand(CmdCommunityPool()) cmd.AddCommand(CmdApr()) cmd.AddCommand(CmdAprs()) - cmd.AddCommand(CmdPoolAprs()) cmd.AddCommand(CmdPoolRewards()) // this line is used by starport scaffolding # 1 diff --git a/x/incentive/client/cli/tx.go b/x/incentive/client/cli/tx.go index 9df67f6d4..4893ed88f 100644 --- a/x/incentive/client/cli/tx.go +++ b/x/incentive/client/cli/tx.go @@ -2,17 +2,10 @@ package cli import ( "fmt" - "strings" "github.com/spf13/cobra" - "github.com/spf13/pflag" "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" - commitmenttypes "github.com/elys-network/elys/x/commitment/types" "github.com/elys-network/elys/x/incentive/types" ) @@ -31,96 +24,9 @@ func GetTxCmd() *cobra.Command { SuggestionsMinimumDistance: 2, RunE: client.ValidateCmd, } - cmd.AddCommand( - CmdWithdrawRewardsCmd(), - ) - cmd.AddCommand(CmdUpdateIncentiveParams()) + cmd.AddCommand() // this line is used by starport scaffolding # 1 return cmd } - -type newGenerateOrBroadcastFunc func(client.Context, *pflag.FlagSet, ...sdk.Msg) error - -func newSplitAndApply( - genOrBroadcastFn newGenerateOrBroadcastFunc, clientCtx client.Context, - fs *pflag.FlagSet, msgs []sdk.Msg, chunkSize int, -) error { - if chunkSize == 0 { - return genOrBroadcastFn(clientCtx, fs, msgs...) - } - - // split messages into slices of length chunkSize - totalMessages := len(msgs) - for i := 0; i < len(msgs); i += chunkSize { - - sliceEnd := i + chunkSize - if sliceEnd > totalMessages { - sliceEnd = totalMessages - } - - msgChunk := msgs[i:sliceEnd] - if err := genOrBroadcastFn(clientCtx, fs, msgChunk...); err != nil { - return err - } - } - - return nil -} - -// CmdWithdrawRewardsCmd returns a CLI command handler for creating a MsgWithdrawDelegatorReward transaction. -func CmdWithdrawRewardsCmd() *cobra.Command { - bech32PrefixValAddr := sdk.GetConfig().GetBech32ValidatorAddrPrefix() - - cmd := &cobra.Command{ - Use: "withdraw-rewards", - Short: "Withdraw rewards from a given delegation address, and optionally withdraw validator commission if the delegation address given is a validator operator", - Long: strings.TrimSpace( - fmt.Sprintf(`Withdraw rewards from a given delegation address, -and optionally withdraw validator commission if the delegation address given is a validator operator. - -Example: -$ %s tx incentive withdraw-rewards --from mykey --withdraw-type [0: withdraw all, 1: withdraw usdc program, 2: withdraw elys program, 3: withdraw eden program, 4: withdraw eden boost program.] -$ %s tx incentive withdraw-rewards --from mykey --commission --validator-address %s1gghjut3ccd8ay0zduzj64hwre2fxs9ldmqhffj -`, - version.AppName, bech32PrefixValAddr, bech32PrefixValAddr, - ), - ), - Args: cobra.ExactArgs(0), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - - delAddr := clientCtx.GetFromAddress() - earnType, err := cmd.Flags().GetInt64(FlagEarnType) - if err != nil { - earnType = int64(commitmenttypes.EarnType_ALL_PROGRAM) - } - - msgs := []sdk.Msg{types.NewMsgWithdrawRewards(delAddr, commitmenttypes.EarnType(earnType))} - - if commission, _ := cmd.Flags().GetBool(FlagCommission); commission { - if validatorAddr, _ := cmd.Flags().GetString(FlagValidatorAddress); len(validatorAddr) > 0 { - valAddr, err := sdk.ValAddressFromBech32(validatorAddr) - if err != nil { - return err - } - msgs = append(msgs, types.NewMsgWithdrawValidatorCommission(delAddr, valAddr)) - } - } - - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msgs...) - }, - } - - cmd.Flags().Bool(FlagCommission, false, "Withdraw the validator's commission in addition to the rewards") - cmd.Flags().String(FlagValidatorAddress, "", "Validator's operator address to withdraw commission from") - cmd.Flags().Int64(FlagEarnType, 0, "Earn type - 0: all earn, 1: usdc program, 2: elys program, 3: eden program, 4: eden boost program.") - - flags.AddTxFlagsToCmd(cmd) - - return cmd -} diff --git a/x/incentive/client/cli/tx_update_incentive_params.go b/x/incentive/client/cli/tx_update_incentive_params.go deleted file mode 100644 index 949d3ad71..000000000 --- a/x/incentive/client/cli/tx_update_incentive_params.go +++ /dev/null @@ -1,120 +0,0 @@ -package cli - -import ( - "errors" - "strconv" - - "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/types/address" - "github.com/cosmos/cosmos-sdk/x/gov/client/cli" - v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" - "github.com/elys-network/elys/x/incentive/types" - "github.com/spf13/cobra" -) - -func CmdUpdateIncentiveParams() *cobra.Command { - cmd := &cobra.Command{ - Use: "update-incentive-params [reward-portion-for-lps] [reward-portion-for-stakers] [elys-stake-tracking-rate] [max-eden-reward-apr-stakers] [max-eden-reward-apr-lps] [distribution-interval]", - Short: "Broadcast message update-incentive-params update-incentive-params [reward-portion-for-lps] [reward-portion-for-stakers] [elys-stake-tracking-rate] [max-eden-reward-apr-stakers] [max-eden-reward-apr-lps] [distribution-interval]", - Args: cobra.ExactArgs(6), - RunE: func(cmd *cobra.Command, args []string) (err error) { - argRewardPortionForLps := args[0] - argRewardPortionForStakers := args[1] - argElysStakeSnapInterval := args[2] - argMaxEdenRewardAprStakers := args[3] - argMaxEdenRewardAprLps := args[4] - argDistributionInterval := args[5] - - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - - title, err := cmd.Flags().GetString(cli.FlagTitle) - if err != nil { - return err - } - - summary, err := cmd.Flags().GetString(cli.FlagSummary) - if err != nil { - return err - } - - metadata, err := cmd.Flags().GetString(cli.FlagMetadata) - if err != nil { - return err - } - - signer := clientCtx.GetFromAddress() - if signer == nil { - return errors.New("signer address is missing") - } - - rewardPortionForLps := sdk.MustNewDecFromStr(argRewardPortionForLps) - rewardPortionForStakers := sdk.MustNewDecFromStr(argRewardPortionForStakers) - elysStakeSnapInterval, err := strconv.ParseInt(argElysStakeSnapInterval, 10, 64) - if err != nil { - return err - } - maxEdenRewardAprStakers := sdk.MustNewDecFromStr(argMaxEdenRewardAprStakers) - maxEdenRewardLps := sdk.MustNewDecFromStr(argMaxEdenRewardAprLps) - distributionInterval, err := strconv.ParseInt(argDistributionInterval, 10, 64) - if err != nil { - return err - } - - govAddress := sdk.AccAddress(address.Module("gov")) - msg := types.NewMsgUpdateIncentiveParams( - govAddress.String(), - rewardPortionForLps, - rewardPortionForStakers, - elysStakeSnapInterval, - maxEdenRewardAprStakers, - maxEdenRewardLps, - distributionInterval, - ) - if err := msg.ValidateBasic(); err != nil { - return err - } - - depositStr, err := cmd.Flags().GetString(cli.FlagDeposit) - if err != nil { - return err - } - - deposit, err := sdk.ParseCoinsNormalized(depositStr) - if err != nil { - return err - } - - govMsg, err := v1.NewMsgSubmitProposal([]sdk.Msg{msg}, deposit, signer.String(), metadata, title, summary) - if err != nil { - return err - } - - err = tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), govMsg) - if err != nil { - return err - } - - return nil - }, - } - - cmd.Flags().String(cli.FlagTitle, "", "title of proposal") - cmd.Flags().String(cli.FlagSummary, "", "summary of proposal") - cmd.Flags().String(cli.FlagMetadata, "", "metadata of proposal") - cmd.Flags().String(cli.FlagDeposit, "", "deposit of proposal") - - _ = cmd.MarkFlagRequired(cli.FlagTitle) - _ = cmd.MarkFlagRequired(cli.FlagSummary) - _ = cmd.MarkFlagRequired(cli.FlagMetadata) - _ = cmd.MarkFlagRequired(cli.FlagDeposit) - - flags.AddTxFlagsToCmd(cmd) - - return cmd -} diff --git a/x/incentive/client/cli/tx_update_incentive_params_test.go b/x/incentive/client/cli/tx_update_incentive_params_test.go deleted file mode 100644 index 4c4f8fc99..000000000 --- a/x/incentive/client/cli/tx_update_incentive_params_test.go +++ /dev/null @@ -1,46 +0,0 @@ -package cli_test - -import ( - "testing" - - clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" - "github.com/stretchr/testify/require" - - "github.com/elys-network/elys/testutil/network" - "github.com/elys-network/elys/x/incentive/client/cli" -) - -func setupNetwork(t *testing.T) *network.Network { - t.Helper() - - cfg := network.DefaultConfig() - return network.New(t, cfg) -} - -func TestGovUpdateIncentiveParams(t *testing.T) { - net := setupNetwork(t) - ctx := net.Validators[0].ClientCtx - val := net.Validators[0] - - // Use baseURL to make API HTTP requests or use val.RPCClient to make direct - // Tendermint RPC calls. - // ... - // [reward-portion-for-lps] [elys-stake-snap-interval] [max-eden-reward-apr-stakers] [max-eden-reward-par-lps] [distribution-interval] - args := []string{ - "0.60", - "0.30", - "10", - "0.30", - "0.30", - "10", - "--title=test", - "--summary=test", - "--metadata=test", - "--deposit=1000000uelys", - "--from=" + val.Address.String(), - "-y", - } - - _, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdUpdateIncentiveParams(), args) - require.NoError(t, err) -} diff --git a/x/incentive/client/wasm/messenger.go b/x/incentive/client/wasm/messenger.go index 7b7fa6884..218043a0d 100644 --- a/x/incentive/client/wasm/messenger.go +++ b/x/incentive/client/wasm/messenger.go @@ -37,10 +37,6 @@ func (m *Messenger) HandleMsg(ctx sdk.Context, contractAddr sdk.AccAddress, cont return m.msgBeginRedelegate(ctx, contractAddr, msg.IncentiveBeginRedelegate) case msg.IncentiveCancelUnbondingDelegation != nil: return m.msgCancelUnbondingDelegation(ctx, contractAddr, msg.IncentiveCancelUnbondingDelegation) - case msg.IncentiveWithdrawRewards != nil: - return m.msgWithdrawRewards(ctx, contractAddr, msg.IncentiveWithdrawRewards) - case msg.IncentiveWithdrawValidatorCommission != nil: - return m.msgWithdrawValidatorCommission(ctx, contractAddr, msg.IncentiveWithdrawValidatorCommission) default: // This handler cannot handle the message return nil, nil, wasmbindingstypes.ErrCannotHandleMsg diff --git a/x/incentive/client/wasm/msg_withdraw_rewards.go b/x/incentive/client/wasm/msg_withdraw_rewards.go deleted file mode 100644 index 24adbedc2..000000000 --- a/x/incentive/client/wasm/msg_withdraw_rewards.go +++ /dev/null @@ -1,67 +0,0 @@ -package wasm - -import ( - "encoding/json" - - errorsmod "cosmossdk.io/errors" - wasmvmtypes "github.com/CosmWasm/wasmvm/types" - sdk "github.com/cosmos/cosmos-sdk/types" - wasmbindingstypes "github.com/elys-network/elys/wasmbindings/types" - incentivekeeper "github.com/elys-network/elys/x/incentive/keeper" - incentivetypes "github.com/elys-network/elys/x/incentive/types" - paramtypes "github.com/elys-network/elys/x/parameter/types" -) - -func (m *Messenger) msgWithdrawRewards(ctx sdk.Context, contractAddr sdk.AccAddress, msgWithdrawRewards *incentivetypes.MsgWithdrawRewards) ([]sdk.Event, [][]byte, error) { - var res *wasmbindingstypes.RequestResponse - var err error - - brokerAddress := m.parameterKeeper.GetParams(ctx).BrokerAddress - if msgWithdrawRewards.DelegatorAddress != contractAddr.String() && contractAddr.String() != brokerAddress { - return nil, nil, wasmvmtypes.InvalidRequest{Err: "wrong sender"} - } - - res, err = performMsgWithdrawRewards(m.keeper, ctx, contractAddr, msgWithdrawRewards) - if err != nil { - return nil, nil, errorsmod.Wrap(err, "perform withdraw rewards") - } - - responseBytes, err := json.Marshal(*res) - if err != nil { - return nil, nil, errorsmod.Wrap(err, "failed to serialize withdraw rewards") - } - - resp := [][]byte{responseBytes} - - return nil, resp, nil -} - -func performMsgWithdrawRewards(f *incentivekeeper.Keeper, ctx sdk.Context, contractAddr sdk.AccAddress, msgWithdrawRewards *incentivetypes.MsgWithdrawRewards) (*wasmbindingstypes.RequestResponse, error) { - if msgWithdrawRewards == nil { - return nil, wasmvmtypes.InvalidRequest{Err: "Invalid withdraw rewards parameter"} - } - - address, err := sdk.AccAddressFromBech32(msgWithdrawRewards.DelegatorAddress) - if err != nil { - return nil, errorsmod.Wrap(err, "invalid address") - } - - msgServer := incentivekeeper.NewMsgServerImpl(*f) - msgMsgWithdrawRewards := incentivetypes.NewMsgWithdrawRewards(address, msgWithdrawRewards.WithdrawType) - - if err := msgMsgWithdrawRewards.ValidateBasic(); err != nil { - return nil, errorsmod.Wrap(err, "failed validating msgMsgWithdrawRewards") - } - - _, err = msgServer.WithdrawRewards(sdk.WrapSDKContext(ctx), msgMsgWithdrawRewards) // Discard the response because it's empty - if err != nil { - return nil, errorsmod.Wrap(err, "withdraw rewards msg") - } - - resp := &wasmbindingstypes.RequestResponse{ - Code: paramtypes.RES_OK, - Result: "Withdraw rewards succeed!", - } - - return resp, nil -} diff --git a/x/incentive/client/wasm/msg_withdraw_validator_commission.go b/x/incentive/client/wasm/msg_withdraw_validator_commission.go deleted file mode 100644 index 3dfbe2462..000000000 --- a/x/incentive/client/wasm/msg_withdraw_validator_commission.go +++ /dev/null @@ -1,72 +0,0 @@ -package wasm - -import ( - "encoding/json" - - errorsmod "cosmossdk.io/errors" - wasmvmtypes "github.com/CosmWasm/wasmvm/types" - sdk "github.com/cosmos/cosmos-sdk/types" - wasmbindingstypes "github.com/elys-network/elys/wasmbindings/types" - incentivekeeper "github.com/elys-network/elys/x/incentive/keeper" - incentivetypes "github.com/elys-network/elys/x/incentive/types" - paramtypes "github.com/elys-network/elys/x/parameter/types" -) - -func (m *Messenger) msgWithdrawValidatorCommission(ctx sdk.Context, contractAddr sdk.AccAddress, msgWithdrawValidatorCommission *incentivetypes.MsgWithdrawValidatorCommission) ([]sdk.Event, [][]byte, error) { - var res *wasmbindingstypes.RequestResponse - var err error - - brokerAddress := m.parameterKeeper.GetParams(ctx).BrokerAddress - if msgWithdrawValidatorCommission.DelegatorAddress != contractAddr.String() && contractAddr.String() != brokerAddress { - return nil, nil, wasmvmtypes.InvalidRequest{Err: "wrong sender"} - } - - res, err = performMsgWithdrawValidatorCommissions(m.keeper, ctx, contractAddr, msgWithdrawValidatorCommission) - if err != nil { - return nil, nil, errorsmod.Wrap(err, "perform withdraw validator commission") - } - - responseBytes, err := json.Marshal(*res) - if err != nil { - return nil, nil, errorsmod.Wrap(err, "failed to serialize withdraw validator commission") - } - - resp := [][]byte{responseBytes} - - return nil, resp, nil -} - -func performMsgWithdrawValidatorCommissions(f *incentivekeeper.Keeper, ctx sdk.Context, contractAddr sdk.AccAddress, msgWithdrawValidatorCommission *incentivetypes.MsgWithdrawValidatorCommission) (*wasmbindingstypes.RequestResponse, error) { - if msgWithdrawValidatorCommission == nil { - return nil, wasmvmtypes.InvalidRequest{Err: "Invalid withdraw validator commission parameter"} - } - - address, err := sdk.AccAddressFromBech32(msgWithdrawValidatorCommission.DelegatorAddress) - if err != nil { - return nil, errorsmod.Wrap(err, "invalid address") - } - - valAddr, err := sdk.ValAddressFromBech32(msgWithdrawValidatorCommission.ValidatorAddress) - if err != nil { - return nil, errorsmod.Wrap(err, "invalid address") - } - - msgServer := incentivekeeper.NewMsgServerImpl(*f) - msgMsgWithdrawValidatorCommissions := incentivetypes.NewMsgWithdrawValidatorCommission(address, valAddr) - - if err := msgMsgWithdrawValidatorCommissions.ValidateBasic(); err != nil { - return nil, errorsmod.Wrap(err, "failed validating msgWithdrawValidatorCommission") - } - - _, err = msgServer.WithdrawValidatorCommission(sdk.WrapSDKContext(ctx), msgMsgWithdrawValidatorCommissions) // Discard the response because it's empty - if err != nil { - return nil, errorsmod.Wrap(err, "withdraw validator commission msg") - } - - resp := &wasmbindingstypes.RequestResponse{ - Code: paramtypes.RES_OK, - Result: "Withdraw validator commissions succeed!", - } - - return resp, nil -} diff --git a/x/incentive/client/wasm/querier.go b/x/incentive/client/wasm/querier.go index 2f3c16b20..10bda75c4 100644 --- a/x/incentive/client/wasm/querier.go +++ b/x/incentive/client/wasm/querier.go @@ -22,16 +22,12 @@ func NewQuerier(keeper *keeper.Keeper, stakingKeeper *stakingkeeper.Keeper) *Que func (oq *Querier) HandleQuery(ctx sdk.Context, query wasmbindingstypes.ElysQuery) ([]byte, error) { switch { - case query.IncentiveParams != nil: - return oq.queryParams(ctx, query.IncentiveParams) - case query.IncentiveCommunityPool != nil: - return oq.queryCommunityPool(ctx, query.IncentiveCommunityPool) case query.IncentiveApr != nil: return oq.queryApr(ctx, query.IncentiveApr) case query.IncentiveAprs != nil: return oq.queryAprs(ctx, query.IncentiveAprs) - case query.IncentivePoolAprs != nil: - return oq.queryPoolAprs(ctx, query.IncentivePoolAprs) + case query.IncentiveAllProgramRewards != nil: + return oq.queryAllProgramRewards(ctx, query.IncentiveAllProgramRewards) default: // This handler cannot handle the query return nil, wasmbindingstypes.ErrCannotHandleQuery diff --git a/x/incentive/client/wasm/query_all_program_rewards.go b/x/incentive/client/wasm/query_all_program_rewards.go new file mode 100644 index 000000000..84a56db63 --- /dev/null +++ b/x/incentive/client/wasm/query_all_program_rewards.go @@ -0,0 +1,22 @@ +package wasm + +import ( + "encoding/json" + + errorsmod "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/elys-network/elys/x/incentive/types" +) + +func (oq *Querier) queryAllProgramRewards(ctx sdk.Context, query *types.QueryAllProgramRewardsRequest) ([]byte, error) { + resp, err := oq.keeper.AllProgramRewards(ctx, query) + if err != nil { + return nil, errorsmod.Wrap(err, "failed to get all program rewards") + } + + responseBytes, err := json.Marshal(resp) + if err != nil { + return nil, errorsmod.Wrap(err, "failed to serialize all program rewards response") + } + return responseBytes, nil +} diff --git a/x/incentive/client/wasm/query_community_pool.go b/x/incentive/client/wasm/query_community_pool.go deleted file mode 100644 index 313fb9a93..000000000 --- a/x/incentive/client/wasm/query_community_pool.go +++ /dev/null @@ -1,22 +0,0 @@ -package wasm - -import ( - "encoding/json" - - errorsmod "cosmossdk.io/errors" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/elys-network/elys/x/incentive/types" -) - -func (oq *Querier) queryCommunityPool(ctx sdk.Context, query *types.QueryCommunityPoolRequest) ([]byte, error) { - res, err := oq.keeper.CommunityPool(ctx, query) - if err != nil { - return nil, errorsmod.Wrap(err, "failed to get community pool") - } - - responseBytes, err := json.Marshal(res) - if err != nil { - return nil, errorsmod.Wrap(err, "failed to serialize community pool response") - } - return responseBytes, nil -} diff --git a/x/incentive/client/wasm/query_params.go b/x/incentive/client/wasm/query_params.go deleted file mode 100644 index fe31c9917..000000000 --- a/x/incentive/client/wasm/query_params.go +++ /dev/null @@ -1,22 +0,0 @@ -package wasm - -import ( - "encoding/json" - - errorsmod "cosmossdk.io/errors" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/elys-network/elys/x/incentive/types" -) - -func (oq *Querier) queryParams(ctx sdk.Context, query *types.QueryParamsRequest) ([]byte, error) { - res, err := oq.keeper.Params(ctx, query) - if err != nil { - return nil, errorsmod.Wrap(err, "failed to get params") - } - - responseBytes, err := json.Marshal(res) - if err != nil { - return nil, errorsmod.Wrap(err, "failed to serialize params response") - } - return responseBytes, nil -} diff --git a/x/incentive/client/wasm/query_pool_aprs.go b/x/incentive/client/wasm/query_pool_aprs.go deleted file mode 100644 index f77c9d135..000000000 --- a/x/incentive/client/wasm/query_pool_aprs.go +++ /dev/null @@ -1,22 +0,0 @@ -package wasm - -import ( - "encoding/json" - - errorsmod "cosmossdk.io/errors" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/elys-network/elys/x/incentive/types" -) - -func (oq *Querier) queryPoolAprs(ctx sdk.Context, query *types.QueryPoolAprsRequest) ([]byte, error) { - data := oq.keeper.CalculatePoolAprs(ctx, query.PoolIds) - - resp := types.QueryPoolAprsResponse{ - Data: data, - } - responseBytes, err := json.Marshal(resp) - if err != nil { - return nil, errorsmod.Wrap(err, "failed to serialize pool aprs response") - } - return responseBytes, nil -} diff --git a/x/incentive/keeper/abci.go b/x/incentive/keeper/abci.go index 23ed0c13f..b140c7b7a 100644 --- a/x/incentive/keeper/abci.go +++ b/x/incentive/keeper/abci.go @@ -1,7 +1,6 @@ package keeper import ( - "errors" "time" "github.com/cosmos/cosmos-sdk/telemetry" @@ -13,224 +12,5 @@ import ( // EndBlocker of incentive module func (k Keeper) EndBlocker(ctx sdk.Context) { defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyEndBlocker) - // Burn EdenB tokens if staking changed - k.BurnEdenBIfElysStakingReduced(ctx) - // Rewards distribution - k.ProcessRewardsDistribution(ctx) -} - -func (k Keeper) TakeDelegationSnapshot(ctx sdk.Context, addr string) { - // Calculate delegated amount per delegator - delAmount := k.CalcDelegationAmount(ctx, addr) - - elysStaked := types.ElysStaked{ - Address: addr, - Amount: delAmount, - } - - // Set Elys staked amount - k.SetElysStaked(ctx, elysStaked) -} - -func (k Keeper) BurnEdenBIfElysStakingReduced(ctx sdk.Context) { - addrs := k.GetAllElysStakeChange(ctx) - - // Handle addresses recorded on AfterDelegationModified - // This hook is exposed for genesis delegations as well - for _, delAddr := range addrs { - k.BurnEdenBFromElysUnstaking(ctx, delAddr) - k.TakeDelegationSnapshot(ctx, delAddr.String()) - k.RemoveElysStakeChange(ctx, delAddr) - } -} - -// Rewards distribution -func (k Keeper) ProcessRewardsDistribution(ctx sdk.Context) { - // Read tokenomics time based inflation params and update incentive module params. - if !k.ProcessUpdateIncentiveParams(ctx) { - ctx.Logger().Error("Invalid tokenomics params", "error", errors.New("invalid tokenomics params")) - return - } - - stakerEpoch, stakeIncentive := k.IsStakerRewardsDistributionEpoch(ctx) - if stakerEpoch { - err := k.UpdateStakersRewardsUnclaimed(ctx, *stakeIncentive) - if err != nil { - ctx.Logger().Error("Failed to update staker rewards unclaimed", "error", err) - } - } - - lpsEpoch, lpIncentive := k.IsLPRewardsDistributionEpoch(ctx) - if lpsEpoch { - err := k.UpdateLPRewardsUnclaimed(ctx, *lpIncentive) - if err != nil { - ctx.Logger().Error("Failed to update lp rewards unclaimed", "error", err) - } - } -} - -func (k Keeper) ProcessUpdateIncentiveParams(ctx sdk.Context) bool { - // Non-linear inflation per year happens and this includes yearly inflation data - listTimeBasedInflations := k.tokenomicsKeeper.GetAllTimeBasedInflation(ctx) - if len(listTimeBasedInflations) < 1 { - return false - } - - params := k.GetParams(ctx) - - // Ensure distribution epoch is not zero to avoid division by zero - if params.DistributionInterval == 0 { - return false - } - - for _, inflation := range listTimeBasedInflations { - // Finding only current inflation data - and skip rest - if inflation.StartBlockHeight > uint64(ctx.BlockHeight()) || inflation.EndBlockHeight < uint64(ctx.BlockHeight()) { - continue - } - - totalBlocksPerYear := sdk.NewInt(int64(inflation.EndBlockHeight - inflation.StartBlockHeight + 1)) - - // ------------- LP Incentive parameter ------------- - totalDistributionEpochPerYear := totalBlocksPerYear.Quo(sdk.NewInt(params.DistributionInterval)) - // If totalDistributionEpochPerYear is zero, we skip this inflation to avoid division by zero - if totalBlocksPerYear == sdk.ZeroInt() { - continue - } - currentEpochInBlocks := sdk.NewInt(ctx.BlockHeight() - int64(inflation.StartBlockHeight)). - Mul(totalDistributionEpochPerYear). - Quo(totalBlocksPerYear) - - incentiveInfo := types.IncentiveInfo{ - // reward amount in eden for 1 year - EdenAmountPerYear: sdk.NewInt(int64(inflation.Inflation.LmRewards)), - // starting block height of the distribution - DistributionStartBlock: sdk.NewInt(int64(inflation.StartBlockHeight)), - // distribution duration - block number per year - TotalBlocksPerYear: totalBlocksPerYear, - // current epoch in block number - CurrentEpochInBlocks: currentEpochInBlocks, - } - - if params.LpIncentives == nil { - params.LpIncentives = &incentiveInfo - } else { - // If any of block number related parameter changed, we re-calculate the current epoch - if params.LpIncentives.DistributionStartBlock != incentiveInfo.DistributionStartBlock || - params.LpIncentives.TotalBlocksPerYear != incentiveInfo.TotalBlocksPerYear { - params.LpIncentives.CurrentEpochInBlocks = currentEpochInBlocks - } - params.LpIncentives.EdenAmountPerYear = incentiveInfo.EdenAmountPerYear - params.LpIncentives.DistributionStartBlock = incentiveInfo.DistributionStartBlock - params.LpIncentives.TotalBlocksPerYear = incentiveInfo.TotalBlocksPerYear - } - - // ------------- Stakers parameter ------------- - totalDistributionEpochPerYear = totalBlocksPerYear.Quo(sdk.NewInt(params.DistributionInterval)) - currentEpochInBlocks = sdk.NewInt(ctx.BlockHeight() - int64(inflation.StartBlockHeight)).Mul(totalDistributionEpochPerYear).Quo(totalBlocksPerYear) - incentiveInfo = types.IncentiveInfo{ - // reward amount in eden for 1 year - EdenAmountPerYear: sdk.NewInt(int64(inflation.Inflation.IcsStakingRewards)), - // starting block height of the distribution - DistributionStartBlock: sdk.NewInt(int64(inflation.StartBlockHeight)), - // distribution duration - block number per year - TotalBlocksPerYear: totalBlocksPerYear, - // current epoch in block number - CurrentEpochInBlocks: currentEpochInBlocks, - } - - if params.StakeIncentives == nil { - params.StakeIncentives = &incentiveInfo - } else { - // If any of block number related parameter changed, we re-calculate the current epoch - if params.StakeIncentives.DistributionStartBlock != incentiveInfo.DistributionStartBlock || - params.StakeIncentives.TotalBlocksPerYear != incentiveInfo.TotalBlocksPerYear { - params.StakeIncentives.CurrentEpochInBlocks = currentEpochInBlocks - } - params.StakeIncentives.EdenAmountPerYear = incentiveInfo.EdenAmountPerYear - params.StakeIncentives.DistributionStartBlock = incentiveInfo.DistributionStartBlock - params.StakeIncentives.TotalBlocksPerYear = incentiveInfo.TotalBlocksPerYear - } - break - } - - k.SetParams(ctx, params) - return true -} - -func (k Keeper) IsStakerRewardsDistributionEpoch(ctx sdk.Context) (bool, *types.IncentiveInfo) { - // Fetch incentive params - params := k.GetParams(ctx) - if ctx.BlockHeight() < 1 { - return false, nil - } - - // If we don't have enough params - if params.StakeIncentives == nil { - return false, nil - } - - // Incentive params initialize - stakeIncentive := params.StakeIncentives - if ctx.BlockHeight()%params.DistributionInterval != 0 { - return false, nil - } - - curBlockHeight := sdk.NewInt(ctx.BlockHeight()) - if stakeIncentive.DistributionStartBlock.GT(curBlockHeight) { - return false, nil - } - - // Increase current epoch of Stake incentive param - stakeIncentive.CurrentEpochInBlocks = stakeIncentive.CurrentEpochInBlocks.Add(sdk.NewInt(params.DistributionInterval)) - if stakeIncentive.CurrentEpochInBlocks.GTE(stakeIncentive.TotalBlocksPerYear) || curBlockHeight.GT(stakeIncentive.TotalBlocksPerYear.Add(stakeIncentive.DistributionStartBlock)) { - params.StakeIncentives = nil - k.SetParams(ctx, params) - return false, nil - } - - params.StakeIncentives.CurrentEpochInBlocks = stakeIncentive.CurrentEpochInBlocks - k.SetParams(ctx, params) - - // return found, stake incentive params - return true, stakeIncentive -} - -func (k Keeper) IsLPRewardsDistributionEpoch(ctx sdk.Context) (bool, *types.IncentiveInfo) { - // Fetch incentive params - params := k.GetParams(ctx) - if ctx.BlockHeight() < 1 { - return false, nil - } - - // If we don't have enough params - if params.LpIncentives == nil { - return false, nil - } - - // Incentive params initialize - lpIncentive := params.LpIncentives - if ctx.BlockHeight()%params.DistributionInterval != 0 { - return false, nil - } - - curBlockHeight := sdk.NewInt(ctx.BlockHeight()) - if lpIncentive.DistributionStartBlock.GT(curBlockHeight) { - return false, nil - } - - // Increase current epoch of Stake incentive param - lpIncentive.CurrentEpochInBlocks = lpIncentive.CurrentEpochInBlocks.Add(sdk.NewInt(params.DistributionInterval)) - if lpIncentive.CurrentEpochInBlocks.GTE(lpIncentive.TotalBlocksPerYear) || curBlockHeight.GT(lpIncentive.TotalBlocksPerYear.Add(lpIncentive.DistributionStartBlock)) { - params.LpIncentives = nil - k.SetParams(ctx, params) - return false, nil - } - - params.LpIncentives.CurrentEpochInBlocks = lpIncentive.CurrentEpochInBlocks - k.SetParams(ctx, params) - - // return found, lp incentive params - return true, lpIncentive } diff --git a/x/incentive/keeper/abci_test.go b/x/incentive/keeper/abci_test.go deleted file mode 100644 index 0757cf347..000000000 --- a/x/incentive/keeper/abci_test.go +++ /dev/null @@ -1,126 +0,0 @@ -package keeper_test - -import ( - "testing" - - tmproto "github.com/cometbft/cometbft/proto/tendermint/types" - sdk "github.com/cosmos/cosmos-sdk/types" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" - simapp "github.com/elys-network/elys/app" - ctypes "github.com/elys-network/elys/x/commitment/types" - ptypes "github.com/elys-network/elys/x/parameter/types" - tokenomicskeeper "github.com/elys-network/elys/x/tokenomics/keeper" - tokenomicstypes "github.com/elys-network/elys/x/tokenomics/types" - "github.com/stretchr/testify/require" -) - -func TestABCI_EndBlocker(t *testing.T) { - app, genAccount, _ := simapp.InitElysTestAppWithGenAccount() - ctx := app.BaseApp.NewContext(initChain, tmproto.Header{}) - - ik := app.IncentiveKeeper - - var committed sdk.Coins - var unclaimed sdk.Coins - - // Prepare unclaimed tokens - uedenToken := sdk.NewCoin(ptypes.Eden, sdk.NewInt(2000)) - uedenBToken := sdk.NewCoin(ptypes.EdenB, sdk.NewInt(2000)) - unclaimed = unclaimed.Add(uedenToken, uedenBToken) - - // Mint coins - err := app.BankKeeper.MintCoins(ctx, ctypes.ModuleName, unclaimed) - require.NoError(t, err) - err = app.BankKeeper.SendCoinsFromModuleToAccount(ctx, ctypes.ModuleName, genAccount, unclaimed) - require.NoError(t, err) - - // Add testing commitment - simapp.AddTestCommitment(app, ctx, genAccount, committed, unclaimed) - ik.EndBlocker(ctx) - - // Get elys staked - elysStaked := ik.GetElysStaked(ctx, genAccount.String()) - require.Equal(t, elysStaked, sdk.DefaultPowerReduction) - - authority := authtypes.NewModuleAddress(govtypes.ModuleName).String() - - srv := tokenomicskeeper.NewMsgServerImpl(app.TokenomicsKeeper) - - expected := &tokenomicstypes.MsgCreateTimeBasedInflation{ - Authority: authority, - StartBlockHeight: uint64(1), - EndBlockHeight: uint64(6307200), - Inflation: &tokenomicstypes.InflationEntry{ - LmRewards: 9999999, - IcsStakingRewards: 9999999, - CommunityFund: 9999999, - StrategicReserve: 9999999, - TeamTokensVested: 9999999, - }, - } - - wctx := sdk.WrapSDKContext(ctx) - _, err = srv.CreateTimeBasedInflation(wctx, expected) - require.NoError(t, err) - - expected = &tokenomicstypes.MsgCreateTimeBasedInflation{ - Authority: authority, - StartBlockHeight: uint64(6307201), - EndBlockHeight: uint64(12614401), - Inflation: &tokenomicstypes.InflationEntry{ - LmRewards: 9999999, - IcsStakingRewards: 9999999, - CommunityFund: 9999999, - StrategicReserve: 9999999, - TeamTokensVested: 9999999, - }, - } - _, err = srv.CreateTimeBasedInflation(wctx, expected) - require.NoError(t, err) - - // Set tokenomics params - listTimeBasdInflations := app.TokenomicsKeeper.GetAllTimeBasedInflation(ctx) - - // After the first year - ctx = ctx.WithBlockHeight(1) - paramSet := ik.ProcessUpdateIncentiveParams(ctx) - require.Equal(t, paramSet, true) - - // Check if the params are correctly set - params := ik.GetParams(ctx) - require.NotNil(t, params.StakeIncentives) - require.NotNil(t, params.LpIncentives) - - require.Equal(t, params.StakeIncentives.EdenAmountPerYear, sdk.NewInt(int64(listTimeBasdInflations[0].Inflation.IcsStakingRewards))) - require.Equal(t, params.LpIncentives.EdenAmountPerYear, sdk.NewInt(int64(listTimeBasdInflations[0].Inflation.LmRewards))) - - // After the first year - ctx = ctx.WithBlockHeight(6307210) - - // Incentive param should be empty - stakerEpoch, _ := ik.IsStakerRewardsDistributionEpoch(ctx) - params = ik.GetParams(ctx) - require.Equal(t, stakerEpoch, false) - require.Nil(t, params.StakeIncentives) - - // Incentive param should be empty - lpEpoch, _ := ik.IsLPRewardsDistributionEpoch(ctx) - params = ik.GetParams(ctx) - require.Equal(t, lpEpoch, false) - require.Nil(t, params.LpIncentives) - - // After reading tokenomics again - paramSet = ik.ProcessUpdateIncentiveParams(ctx) - require.Equal(t, paramSet, true) - - // Check params - _, stakeIncentive := ik.IsStakerRewardsDistributionEpoch(ctx) - params = ik.GetParams(ctx) - require.Equal(t, stakeIncentive.EdenAmountPerYear, sdk.NewInt(int64(listTimeBasdInflations[0].Inflation.IcsStakingRewards))) - - // Check params - _, lpIncentive := ik.IsLPRewardsDistributionEpoch(ctx) - params = ik.GetParams(ctx) - require.Equal(t, lpIncentive.EdenAmountPerYear, sdk.NewInt(int64(listTimeBasdInflations[0].Inflation.IcsStakingRewards))) -} diff --git a/x/incentive/keeper/alias_functions.go b/x/incentive/keeper/alias_functions.go deleted file mode 100644 index 70071fccb..000000000 --- a/x/incentive/keeper/alias_functions.go +++ /dev/null @@ -1,10 +0,0 @@ -package keeper - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" -) - -// get the community coins -func (k Keeper) GetFeePoolCommunityCoins(ctx sdk.Context) sdk.DecCoins { - return k.GetFeePool(ctx).CommunityPool -} diff --git a/x/incentive/keeper/apr.go b/x/incentive/keeper/apr.go index 443aee7f9..9edf6bc79 100644 --- a/x/incentive/keeper/apr.go +++ b/x/incentive/keeper/apr.go @@ -7,6 +7,7 @@ import ( assetprofiletypes "github.com/elys-network/elys/x/assetprofile/types" commitmenttypes "github.com/elys-network/elys/x/commitment/types" "github.com/elys-network/elys/x/incentive/types" + mastercheftypes "github.com/elys-network/elys/x/masterchef/types" ptypes "github.com/elys-network/elys/x/parameter/types" stabletypes "github.com/elys-network/elys/x/stablestake/types" ) @@ -14,12 +15,14 @@ import ( func (k Keeper) CalculateApr(ctx sdk.Context, query *types.QueryAprRequest) (math.Int, error) { // Fetch incentive params params := k.GetParams(ctx) + masterchefParams := k.masterchef.GetParams(ctx) + estakingParams := k.estaking.GetParams(ctx) // Update params defer k.SetParams(ctx, params) // If we don't have enough params - if params.StakeIncentives == nil || params.LpIncentives == nil { + if estakingParams.StakeIncentives == nil || masterchefParams.LpIncentives == nil { return sdk.ZeroInt(), errorsmod.Wrap(types.ErrNoInflationaryParams, "no inflationary params available") } @@ -29,8 +32,8 @@ func (k Keeper) CalculateApr(ctx sdk.Context, query *types.QueryAprRequest) (mat } baseCurrency := entry.Denom - lpIncentive := params.LpIncentives - stkIncentive := params.StakeIncentives + lpIncentive := masterchefParams.LpIncentives + stkIncentive := estakingParams.StakeIncentives if lpIncentive.TotalBlocksPerYear.IsZero() || stkIncentive.TotalBlocksPerYear.IsZero() { return sdk.ZeroInt(), errorsmod.Wrap(types.ErrNoInflationaryParams, "invalid inflationary params") @@ -38,48 +41,12 @@ func (k Keeper) CalculateApr(ctx sdk.Context, query *types.QueryAprRequest) (mat if query.Denom == ptypes.Eden { if query.WithdrawType == commitmenttypes.EarnType_USDC_PROGRAM { - stableTvl := k.stableKeeper.TVL(ctx, k.oracleKeeper, baseCurrency) - if stableTvl.IsZero() { - return sdk.ZeroInt(), nil - } - - // Calculate total Proxy TVL - totalProxyTVL := k.CalculateProxyTVL(ctx, baseCurrency) - - // Eden amount for LP in 24hrs = EpochNumBlocks is the number of block for 24 hrs - epochEdenAmount := lpIncentive.EdenAmountPerYear. - Mul(sdk.NewInt(params.DistributionInterval)). - Quo(lpIncentive.TotalBlocksPerYear) - - // Eden amount for stable stake LP in 24hrs - stableStakePoolShare := k.CalculatePoolShareForStableStakeLPs(ctx, totalProxyTVL, baseCurrency) - epochStableStakeEdenAmount := sdk.NewDecFromInt(epochEdenAmount).Mul(stableStakePoolShare) - - edenDenomPrice := k.GetEdenDenomPrice(ctx, baseCurrency) - params := k.GetParams(ctx) - poolMaxEdenAmount := params.MaxEdenRewardAprLps. - Mul(stableTvl). - MulInt64(params.DistributionInterval). - QuoInt(lpIncentive.TotalBlocksPerYear). - Quo(edenDenomPrice) - - epochStableStakeEdenAmount = sdk.MinDec(epochStableStakeEdenAmount, poolMaxEdenAmount) - - // Eden Apr for usdc earn program = {stablestakeEdenAllocationYearly*edenPrice/UsdcTvl}*100 - apr := epochStableStakeEdenAmount. - MulInt(lpIncentive.TotalBlocksPerYear). - QuoInt64(params.DistributionInterval). - Mul(edenDenomPrice). - MulInt(sdk.NewInt(100)). - Quo(stableTvl) - - return apr.TruncateInt(), nil + return k.masterchef.CalculateStableStakeApr(ctx, &mastercheftypes.QueryStableStakeAprRequest{ + Denom: ptypes.Eden, + }) } else { // Elys staking, Eden committed, EdenB committed. - - // Update total committed states - k.UpdateTotalCommitmentInfo(ctx, baseCurrency) - totalStakedSnapshot := k.tci.TotalElysBonded.Add(k.tci.TotalEdenEdenBoostCommitted) + totalStakedSnapshot := k.estaking.TotalBondedTokens(ctx) // Ensure totalStakedSnapshot is not zero to avoid division by zero if totalStakedSnapshot.IsZero() { @@ -87,24 +54,21 @@ func (k Keeper) CalculateApr(ctx sdk.Context, query *types.QueryAprRequest) (mat } // Calculate - epochStakersEdenAmount := stkIncentive.EdenAmountPerYear. - Mul(sdk.NewInt(params.DistributionInterval)). + stakersEdenAmount := stkIncentive.EdenAmountPerYear. Quo(stkIncentive.TotalBlocksPerYear) - // Maximum eden based per distribution epoch on maximum APR - 30% by default + // Maximum eden APR - 30% by default // Allocated for staking per day = (0.3/365)* ( total elys staked + total Eden committed + total Eden boost committed) - epochStakersMaxEdenAmount := params.MaxEdenRewardAprStakers. + stakersMaxEdenAmount := estakingParams.MaxEdenRewardAprStakers. MulInt(totalStakedSnapshot). - MulInt64(params.DistributionInterval). QuoInt(stkIncentive.TotalBlocksPerYear) // Use min amount (eden allocation from tokenomics and max apr based eden amount) - epochStakersEdenAmount = sdk.MinInt(epochStakersEdenAmount, epochStakersMaxEdenAmount.TruncateInt()) + stakersEdenAmount = sdk.MinInt(stakersEdenAmount, stakersMaxEdenAmount.TruncateInt()) // For Eden reward Apr for elys staking = {(amount of Eden allocated for staking per day)*365/( total elys staked + total Eden committed + total Eden boost committed)}*100 - apr := epochStakersEdenAmount. + apr := stakersEdenAmount. Mul(lpIncentive.TotalBlocksPerYear). - Quo(sdk.NewInt(params.DistributionInterval)). Mul(sdk.NewInt(100)). Quo(totalStakedSnapshot) @@ -121,7 +85,7 @@ func (k Keeper) CalculateApr(ctx sdk.Context, query *types.QueryAprRequest) (mat return apr.TruncateInt(), nil } else { // Elys staking, Eden committed, EdenB committed. - params := k.GetParams(ctx) + params := k.estaking.GetParams(ctx) amount := params.DexRewardsStakers.Amount if amount.IsZero() { return sdk.ZeroInt(), nil @@ -134,14 +98,13 @@ func (k Keeper) CalculateApr(ctx sdk.Context, query *types.QueryAprRequest) (mat // Calc Eden price in usdc // We put Elys as denom as Eden won't be avaialble in amm pool and has the same value as Elys - edenPrice := k.EstimatePrice(ctx, ptypes.Elys, baseCurrency) - if edenPrice.IsZero() { + edenDenomPrice := k.amm.GetEdenDenomPrice(ctx, baseCurrency) + if edenDenomPrice.IsZero() { return sdk.ZeroInt(), nil } // Update total committed states - k.UpdateTotalCommitmentInfo(ctx, baseCurrency) - totalStakedSnapshot := k.tci.TotalElysBonded.Add(k.tci.TotalEdenEdenBoostCommitted) + totalStakedSnapshot := k.estaking.TotalBondedTokens(ctx) // Ensure totalStakedSnapshot is not zero to avoid division by zero if totalStakedSnapshot.IsZero() { @@ -149,20 +112,19 @@ func (k Keeper) CalculateApr(ctx sdk.Context, query *types.QueryAprRequest) (mat } // DexReward amount per day = amount distributed / duration(in seconds) * total seconds per day. - // EpochNumBlocks is the number of the block per day yearlyDexRewardAmount := amount.MulInt(lpIncentive.TotalBlocksPerYear).QuoInt(params.DexRewardsStakers.NumBlocks) // Usdc apr for elys staking = (24 hour dex rewards in USDC generated for stakers) * 365*100/ {price ( elys/usdc)*( sum of (elys staked, Eden committed, Eden boost committed))} // we multiply 10 as we have use 10elys as input in the price estimation apr := yearlyDexRewardAmount. MulInt(sdk.NewInt(100)). - Quo(edenPrice). + Quo(edenDenomPrice). QuoInt(totalStakedSnapshot) return apr.TruncateInt(), nil } } else if query.Denom == ptypes.EdenB { - apr := types.EdenBoostApr.MulInt(sdk.NewInt(100)).TruncateInt() + apr := estakingParams.EdenBoostApr.MulInt(sdk.NewInt(100)).TruncateInt() return apr, nil } diff --git a/x/incentive/keeper/estimate_price.go b/x/incentive/keeper/estimate_price.go deleted file mode 100644 index 3da132026..000000000 --- a/x/incentive/keeper/estimate_price.go +++ /dev/null @@ -1,45 +0,0 @@ -package keeper - -import ( - "cosmossdk.io/math" - sdk "github.com/cosmos/cosmos-sdk/types" - ptypes "github.com/elys-network/elys/x/parameter/types" -) - -// Estimate the price : eg, 1 Eden -> x usdc -func (k Keeper) EstimatePrice(ctx sdk.Context, tokenInDenom, baseCurrency string) math.LegacyDec { - // Find a pool that can convert tokenIn to usdc - pool, found := k.amm.GetBestPoolWithDenoms(ctx, []string{tokenInDenom, baseCurrency}) - if !found { - return sdk.ZeroDec() - } - - // Executes the swap in the pool and stores the output. Updates pool assets but - // does not actually transfer any tokens to or from the pool. - snapshot := k.amm.GetPoolSnapshotOrSet(ctx, pool) - - rate, err := pool.GetTokenARate(ctx, k.oracleKeeper, &snapshot, tokenInDenom, baseCurrency, k.accountedPoolKeeper) - if err != nil { - return sdk.ZeroDec() - } - - return rate -} - -func (k Keeper) GetEdenDenomPrice(ctx sdk.Context, baseCurrency string) math.LegacyDec { - // Calc ueden / uusdc rate - edenUsdcRate := k.EstimatePrice(ctx, ptypes.Elys, baseCurrency) - if edenUsdcRate.IsZero() { - edenUsdcRate = sdk.OneDec() - } - usdcDenomPrice := k.oracleKeeper.GetAssetPriceFromDenom(ctx, baseCurrency) - if usdcDenomPrice.IsZero() { - usdcDecimal := int64(6) - usdcEntry, found := k.assetProfileKeeper.GetEntry(ctx, ptypes.BaseCurrency) - if found { - usdcDecimal = int64(usdcEntry.Decimals) - } - usdcDenomPrice = sdk.NewDecWithPrec(1, usdcDecimal) - } - return edenUsdcRate.Mul(usdcDenomPrice) -} diff --git a/x/incentive/keeper/fee_pool.go b/x/incentive/keeper/fee_pool.go deleted file mode 100644 index a60475013..000000000 --- a/x/incentive/keeper/fee_pool.go +++ /dev/null @@ -1,30 +0,0 @@ -package keeper - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/distribution/types" -) - -// DistributeFromFeePool distributes funds from the distribution module account to -// a receiver address while updating the community pool -func (k Keeper) DistributeFromFeePool(ctx sdk.Context, amount sdk.Coins, receiveAddr sdk.AccAddress) error { - feePool := k.GetFeePool(ctx) - - // NOTE the community pool isn't a module account, however its coins - // are held in the distribution module account. Thus the community pool - // must be reduced separately from the SendCoinsFromModuleToAccount call - newPool, negative := feePool.CommunityPool.SafeSub(sdk.NewDecCoinsFromCoins(amount...)) - if negative { - return types.ErrBadDistribution - } - - feePool.CommunityPool = newPool - - err := k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, receiveAddr, amount) - if err != nil { - return err - } - - k.SetFeePool(ctx, feePool) - return nil -} diff --git a/x/incentive/keeper/genesis.go b/x/incentive/keeper/genesis.go index ce38006ad..1eaf4268d 100644 --- a/x/incentive/keeper/genesis.go +++ b/x/incentive/keeper/genesis.go @@ -8,14 +8,9 @@ import ( // InitGenesis initializes the module's state from a provided genesis state. func (k Keeper) InitGenesis(ctx sdk.Context, data types.GenesisState) { // this line is used by starport scaffolding # genesis/module/init - k.SetFeePool(ctx, data.FeePool) - k.SetParams(ctx, data.Params) } // ExportGenesis returns the module's exported genesis func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { - feePool := k.GetFeePool(ctx) - params := k.GetParams(ctx) - - return types.NewGenesisState(params, feePool) + return types.NewGenesisState() } diff --git a/x/incentive/keeper/hooks_commitment.go b/x/incentive/keeper/hooks_commitment.go deleted file mode 100644 index 583ebf833..000000000 --- a/x/incentive/keeper/hooks_commitment.go +++ /dev/null @@ -1,39 +0,0 @@ -package keeper - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - commitmenttypes "github.com/elys-network/elys/x/commitment/types" -) - -// Process commitmentChanged hook -func (k Keeper) CommitmentChanged(ctx sdk.Context, creator string, amount sdk.Coins) { -} - -// Process eden uncommitted hook -func (k Keeper) EdenUncommitted(ctx sdk.Context, creator string, amount sdk.Coin) { - k.BurnEdenBFromEdenUncommitted(ctx, creator, amount.Amount) -} - -// ___________________________________________________________________________________________________ - -// Hooks wrapper struct for incentive keeper -type CommitmentHooks struct { - k Keeper -} - -var _ commitmenttypes.CommitmentHooks = CommitmentHooks{} - -// Return the wrapper struct -func (k Keeper) CommitmentHooks() CommitmentHooks { - return CommitmentHooks{k} -} - -// CommitmentChanged implements CommentmentHook -func (h CommitmentHooks) CommitmentChanged(ctx sdk.Context, creator string, amount sdk.Coins) { - h.k.CommitmentChanged(ctx, creator, amount) -} - -// EdenUncommitted implements EdenUncommitted -func (h CommitmentHooks) EdenUncommitted(ctx sdk.Context, creator string, amount sdk.Coin) { - h.k.EdenUncommitted(ctx, creator, amount) -} diff --git a/x/incentive/keeper/keeper.go b/x/incentive/keeper/keeper.go index 5cc452fce..ae65c9544 100644 --- a/x/incentive/keeper/keeper.go +++ b/x/incentive/keeper/keeper.go @@ -8,14 +8,12 @@ import ( storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" - errorsmod "cosmossdk.io/errors" "cosmossdk.io/math" ammtypes "github.com/elys-network/elys/x/amm/types" - assetprofiletypes "github.com/elys-network/elys/x/assetprofile/types" - ctypes "github.com/elys-network/elys/x/commitment/types" + estakingkeeper "github.com/elys-network/elys/x/estaking/keeper" "github.com/elys-network/elys/x/incentive/types" + masterchefkeeper "github.com/elys-network/elys/x/masterchef/keeper" ptypes "github.com/elys-network/elys/x/parameter/types" - stabletypes "github.com/elys-network/elys/x/stablestake/types" ) type ( @@ -25,20 +23,18 @@ type ( memKey storetypes.StoreKey cmk types.CommitmentKeeper stk types.StakingKeeper - tci *types.TotalCommitmentInfo authKeeper types.AccountKeeper bankKeeper types.BankKeeper amm types.AmmKeeper oracleKeeper types.OracleKeeper assetProfileKeeper types.AssetProfileKeeper accountedPoolKeeper types.AccountedPoolKeeper - epochsKeeper types.EpochsKeeper stableKeeper types.StableStakeKeeper tokenomicsKeeper types.TokenomicsKeeper + masterchef *masterchefkeeper.Keeper + estaking *estakingkeeper.Keeper - feeCollectorName string // name of the FeeCollector ModuleAccount - dexRevCollectorName string // name of the Dex Revenue ModuleAccount - authority string // gov module addresss + authority string // gov module addresss } ) @@ -54,11 +50,11 @@ func NewKeeper( ok types.OracleKeeper, ap types.AssetProfileKeeper, accountedPoolKeeper types.AccountedPoolKeeper, - epochsKeeper types.EpochsKeeper, stableKeeper types.StableStakeKeeper, tokenomicsKeeper types.TokenomicsKeeper, + masterchef *masterchefkeeper.Keeper, + estaking *estakingkeeper.Keeper, feeCollectorName string, - dexRevCollectorName string, authority string, ) *Keeper { return &Keeper{ @@ -67,18 +63,16 @@ func NewKeeper( memKey: memKey, cmk: ck, stk: sk, - tci: &types.TotalCommitmentInfo{}, - feeCollectorName: feeCollectorName, - dexRevCollectorName: dexRevCollectorName, authKeeper: ak, bankKeeper: bk, amm: amm, oracleKeeper: ok, assetProfileKeeper: ap, accountedPoolKeeper: accountedPoolKeeper, - epochsKeeper: epochsKeeper, stableKeeper: stableKeeper, tokenomicsKeeper: tokenomicsKeeper, + masterchef: masterchef, + estaking: estaking, authority: authority, } } @@ -87,489 +81,6 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) } -// Update unclaimed token amount -// Called back through epoch hook -func (k Keeper) UpdateStakersRewardsUnclaimed(ctx sdk.Context, stakeIncentive types.IncentiveInfo) error { - entry, found := k.assetProfileKeeper.GetEntry(ctx, ptypes.BaseCurrency) - if !found { - return errorsmod.Wrapf(assetprofiletypes.ErrAssetProfileNotFound, "asset %s not found", ptypes.BaseCurrency) - } - baseCurrency := entry.Denom - - // Recalculate total committed info - k.UpdateTotalCommitmentInfo(ctx, baseCurrency) - - // Collect DEX revenue while tracking 65% of it for LPs reward calculation - // Assume these are collected in USDC - _, dexRevenueForLpsPerDistribution, dexRevenueForStakersPerDistribution := k.CollectDEXRevenue(ctx) - - // Calculate each portion of Gas fees collected - stakers, LPs - gasFeeCollectedDec := sdk.NewDecCoinsFromCoins(k.tci.TotalFeesCollected...) - rewardPortionForLps := k.GetDEXRewardPortionForLPs(ctx) - rewardPortionForStakers := k.GetDEXRewardPortionForStakers(ctx) - gasFeesForLps := gasFeeCollectedDec.MulDecTruncate(rewardPortionForLps) - gasFeesForStakers := gasFeeCollectedDec.MulDecTruncate(rewardPortionForStakers) - - // Sum Dex revenue for stakers + Gas fees for stakers and name it dex Revenus for stakers - // But won't sum dex revenue for LPs and gas fees for LPs as the LP revenue will be rewared by pool. - dexRevenueForStakersPerDistribution = dexRevenueForStakersPerDistribution.Add(gasFeesForStakers...) - - // USDC amount in sdk.Dec type - dexRevenueLPsAmtPerDistribution := dexRevenueForLpsPerDistribution.AmountOf(baseCurrency) - dexRevenueStakersAmtPerDistribution := dexRevenueForStakersPerDistribution.AmountOf(baseCurrency) - gasFeesLPsAmtPerDistribution := gasFeesForLps.AmountOf(baseCurrency) - - // Calculate eden amount per epoch - params := k.GetParams(ctx) - - // Ensure stakeIncentive.TotalBlocksPerYear or stakeIncentive.EpochNumBlocks are not zero to avoid division by zero - if stakeIncentive.TotalBlocksPerYear.IsZero() || params.DistributionInterval == 0 { - return errorsmod.Wrap(types.ErrNoInflationaryParams, "invalid inflationary params") - } - - // Calculate - epochStakersEdenAmount := stakeIncentive.EdenAmountPerYear. - Mul(sdk.NewInt(params.DistributionInterval)). - Quo(stakeIncentive.TotalBlocksPerYear) - - // Maximum eden based per distribution epoch on maximum APR - 30% by default - // Allocated for staking per day = (0.3/365)* ( total elys staked + total Eden committed + total Eden boost committed) - epochStakersMaxEdenAmount := params.MaxEdenRewardAprStakers. - MulInt(k.tci.TotalElysBonded.Add(k.tci.TotalEdenEdenBoostCommitted)). - MulInt(sdk.NewInt(params.DistributionInterval)). - QuoInt(stakeIncentive.TotalBlocksPerYear) - - // Use min amount (eden allocation from tokenomics and max apr based eden amount) - epochStakersEdenAmount = sdk.MinInt(epochStakersEdenAmount, epochStakersMaxEdenAmount.TruncateInt()) - - // Track the DEX rewards distribution for stakers - // Add dexRevenue amount that was tracked by Lp tracker - dexRevenueStakersAmtPerDistribution = dexRevenueStakersAmtPerDistribution.Add(params.DexRewardsStakers.AmountCollectedByOtherTracker) - // Increase block number - params.DexRewardsStakers.NumBlocks = sdk.NewInt(params.DistributionInterval) - // Incrase total dex rewards given - params.DexRewardsStakers.Amount = dexRevenueStakersAmtPerDistribution - // Reset amount from other tracker - params.DexRewardsStakers.AmountCollectedByOtherTracker = sdk.ZeroDec() - // Don't increase Lps rewards blocks, it will be increased whenever LP distribution epoch happens. - params.DexRewardsLps.AmountCollectedByOtherTracker = dexRevenueLPsAmtPerDistribution. - Add(gasFeesLPsAmtPerDistribution) - k.SetParams(ctx, params) - - totalEdenGiven := sdk.ZeroInt() - totalRewardsGiven := sdk.ZeroInt() - // Process to increase uncomitted token amount of Eden & Eden boost - k.cmk.IterateCommitments( - ctx, func(commitments ctypes.Commitments) bool { - // Commitment owner - creator := commitments.Creator - _, err := sdk.AccAddressFromBech32(creator) - if err != nil { - // This could be validator address - return false - } - - rewardsByElysStaking := sdk.NewCoins() - rewardsByEdenCommitted := sdk.NewCoins() - rewardsByEdenBCommitted := sdk.NewCoins() - rewardsByUSDCDeposit := sdk.NewCoins() - - newSumEdenRewardsUnClaimed := sdk.ZeroInt() - newSumEdenBRewardsUnClaimed := sdk.ZeroInt() - newSumDexRewardsUnClaimed := sdk.ZeroInt() - - // Calculate delegated amount per delegator - bondedDelAmount := k.CalcBondedDelegationAmount(ctx, creator) - - // Calculate new unclaimed Eden tokens from Eden & Eden boost committed, Dex rewards distribution - // Distribute gas fees to stakers - - // Calculate new unclaimed Eden tokens from Elys staked - // ---------------------------------------------------------- - newUnclaimedEdenTokens, dexRewards, dexRewardsByStakers := k.CalcRewardsForStakersByElysStaked( - ctx, bondedDelAmount, epochStakersEdenAmount, dexRevenueStakersAmtPerDistribution, - ) - - // Total - totalEdenGiven = totalEdenGiven.Add(newUnclaimedEdenTokens) - totalRewardsGiven = totalRewardsGiven.Add(dexRewards) - - // Sum for each loop - newSumEdenRewardsUnClaimed = newSumEdenRewardsUnClaimed.Add(newUnclaimedEdenTokens) - newSumDexRewardsUnClaimed = newSumDexRewardsUnClaimed.Add(dexRewards) - - // Store Eden rewards by Elys staking - newEdenFromElysStaking := newUnclaimedEdenTokens - newDexRewardFromElysStaking := dexRewards - // ---------------------------------------------------------- - - // Calculate new unclaimed Eden tokens from Eden committed - // ---------------------------------------------------------- - // ---------------------------------------------------------- - edenCommitted := commitments.GetCommittedAmountForDenom(ptypes.Eden) - newUnclaimedEdenTokens, dexRewards = k.CalcRewardsForStakersByCommitted( - ctx, edenCommitted, epochStakersEdenAmount, dexRevenueStakersAmtPerDistribution, - ) - - // Total - totalEdenGiven = totalEdenGiven.Add(newUnclaimedEdenTokens) - totalRewardsGiven = totalRewardsGiven.Add(dexRewards) - - // Sum for each loop - newSumEdenRewardsUnClaimed = newSumEdenRewardsUnClaimed.Add(newUnclaimedEdenTokens) - newSumDexRewardsUnClaimed = newSumDexRewardsUnClaimed.Add(dexRewards) - - // Sub bucket - rewardsByEdenCommitted = rewardsByEdenCommitted.Add(sdk.NewCoin(ptypes.Eden, newUnclaimedEdenTokens)) - rewardsByEdenCommitted = rewardsByEdenCommitted.Add(sdk.NewCoin(baseCurrency, dexRewards)) - // ---------------------------------------------------------- - // ---------------------------------------------------------- - - // Calculate new unclaimed Eden tokens from Eden Boost committed - // ---------------------------------------------------------- - // ---------------------------------------------------------- - edenBoostCommitted := commitments.GetCommittedAmountForDenom(ptypes.EdenB) - newUnclaimedEdenTokens, dexRewards = k.CalcRewardsForStakersByCommitted( - ctx, - edenBoostCommitted, - epochStakersEdenAmount, - dexRevenueStakersAmtPerDistribution, - ) - - // Total - totalEdenGiven = totalEdenGiven.Add(newUnclaimedEdenTokens) - totalRewardsGiven = totalRewardsGiven.Add(dexRewards) - - // Sum for each loop - newSumEdenRewardsUnClaimed = newSumEdenRewardsUnClaimed.Add(newUnclaimedEdenTokens) - newSumDexRewardsUnClaimed = newSumDexRewardsUnClaimed.Add(dexRewards) - - // Sub bucket - rewardsByEdenBCommitted = rewardsByEdenBCommitted.Add(sdk.NewCoin(ptypes.Eden, newUnclaimedEdenTokens)) - rewardsByEdenBCommitted = rewardsByEdenBCommitted.Add(sdk.NewCoin(baseCurrency, dexRewards)) - // ---------------------------------------------------------- - // ---------------------------------------------------------- - - // ---------------------------------------------------------- - // Give commission to validators ( Eden from stakers and Dex rewards from stakers. ) - // ---------------------------------------------------------- - // ---------------------------------------------------------- - edenCommissionGiven, dexRewardsCommissionGiven := k.GiveCommissionToValidators(ctx, creator, bondedDelAmount, newEdenFromElysStaking, dexRewardsByStakers, baseCurrency) - - // Minus the commission amount given - newSumEdenRewardsUnClaimed = newSumEdenRewardsUnClaimed.Sub(edenCommissionGiven) - - // Minus the commission amount given - newSumDexRewardsUnClaimed = newSumDexRewardsUnClaimed.Sub(dexRewardsCommissionGiven) - // ---------------------------------------------------------- - // ---------------------------------------------------------- - - // We should deduct validator commissions from "reward by elys staking sub bucket" - // ---------------------------------------------------------- - // ---------------------------------------------------------- - newEdenFromElysStaking = newEdenFromElysStaking.Sub(edenCommissionGiven) - newDexRewardFromElysStaking = newDexRewardFromElysStaking.Sub(dexRewardsCommissionGiven) - - // Add Eden rewards from Elys staking - rewardsByElysStaking = rewardsByElysStaking.Add(sdk.NewCoin(ptypes.Eden, newEdenFromElysStaking)) - rewardsByElysStaking = rewardsByElysStaking.Add(sdk.NewCoin(baseCurrency, newDexRewardFromElysStaking)) - // ---------------------------------------------------------- - // ---------------------------------------------------------- - - // Calculate new unclaimed Eden-Boost tokens for staker and Eden token holders - // ---------------------------------------------------------- - // ---------------------------------------------------------- - newEdenBTokens, newEdenBFromElysStaking, newEdenBFromEdenCommited := k.CalculateEdenBoostRewards( - ctx, bondedDelAmount, commitments, stakeIncentive, types.EdenBoostApr) - rewardsByElysStaking = rewardsByElysStaking.Add(sdk.NewCoin(ptypes.EdenB, newEdenBFromElysStaking)) - rewardsByEdenCommitted = rewardsByEdenCommitted.Add(sdk.NewCoin(ptypes.EdenB, newEdenBFromEdenCommited)) - - newSumEdenBRewardsUnClaimed = newSumEdenBRewardsUnClaimed.Add(newEdenBTokens) - // ---------------------------------------------------------- - // ---------------------------------------------------------- - - // Update Commitments with new unclaimed token amounts - k.UpdateCommitments(ctx, creator, &commitments, newSumEdenRewardsUnClaimed, newSumEdenBRewardsUnClaimed, newSumDexRewardsUnClaimed, baseCurrency) - - // Update sub buckets commitment with new unclaimed token amounts - k.UpdateCommitmentsSubBuckets(ctx, creator, &commitments, rewardsByElysStaking, rewardsByEdenCommitted, rewardsByEdenBCommitted, rewardsByUSDCDeposit) - return false - }, - ) - - // Calcualte the remainings - edenRemained := epochStakersEdenAmount.Sub(totalEdenGiven) - dexRewardsRemained := dexRevenueStakersAmtPerDistribution.Sub(sdk.NewDecFromInt(totalRewardsGiven)) - - // if edenRemained is negative, override it with zero - if edenRemained.IsNegative() { - edenRemained = sdk.ZeroInt() - } - // if dexRewardsRemained is negative, override it with zero - if dexRewardsRemained.IsNegative() { - dexRewardsRemained = sdk.ZeroDec() - } - - // Fund community the remain coins - // ---------------------------------- - edenRemainedCoin := sdk.NewDecCoin(ptypes.Eden, edenRemained) - dexRewardsRemainedCoin := sdk.NewDecCoinFromDec(baseCurrency, dexRewardsRemained) - - feePool := k.GetFeePool(ctx) - feePool.CommunityPool = feePool.CommunityPool.Add(edenRemainedCoin) - feePool.CommunityPool = feePool.CommunityPool.Add(dexRewardsRemainedCoin) - k.SetFeePool(ctx, feePool) - // ---------------------------------- - - return nil -} - -// Update unclaimed token amount -// Called back through epoch hook -func (k Keeper) UpdateLPRewardsUnclaimed(ctx sdk.Context, lpIncentive types.IncentiveInfo) error { - entry, found := k.assetProfileKeeper.GetEntry(ctx, ptypes.BaseCurrency) - if !found { - return errorsmod.Wrapf(assetprofiletypes.ErrAssetProfileNotFound, "asset %s not found", ptypes.BaseCurrency) - } - baseCurrency := entry.Denom - - params := k.GetParams(ctx) - - // Recalculate total committed info - k.UpdateTotalCommitmentInfo(ctx, baseCurrency) - - // Collect DEX revenue while tracking 65% of it for LPs reward calculation - // Assume these are collected in USDC - _, dexRevenueForLpsPerDistribution, dexRevenueForStakersPerDistribution := k.CollectDEXRevenue(ctx) - - // Calculate each portion of Gas fees collected - stakers, LPs - gasFeeCollectedDec := sdk.NewDecCoinsFromCoins(k.tci.TotalFeesCollected...) - rewardPortionForLps := k.GetDEXRewardPortionForLPs(ctx) - rewardPortionForStakers := k.GetDEXRewardPortionForStakers(ctx) - gasFeesForLpsPerDistribution := gasFeeCollectedDec.MulDecTruncate(rewardPortionForLps) - gasFeesForStakersPerDistribution := gasFeeCollectedDec.MulDecTruncate(rewardPortionForStakers) - - // Sum Dex revenue for stakers + Gas fees for stakers and name it dex Revenus for stakers - // But won't sum dex revenue for LPs and gas fees for LPs as the LP revenue will be rewared by pool. - dexRevenueForStakersPerDistribution = dexRevenueForStakersPerDistribution.Add(gasFeesForStakersPerDistribution...) - - // USDC amount in sdk.Dec type - dexRevenueLPsAmtPerDistribution := dexRevenueForLpsPerDistribution.AmountOf(baseCurrency) - dexRevenueStakersAmtPerDistribution := dexRevenueForStakersPerDistribution.AmountOf(baseCurrency) - gasFeesLPsAmtPerDistribution := gasFeesForLpsPerDistribution.AmountOf(baseCurrency) - - // Proxy TVL - // Multiplier on each liquidity pool - // We have 3 pools of 20, 30, 40 TVL - // We have mulitplier of 0.3, 0.5, 1.0 - // Proxy TVL = 20*0.3+30*0.5+40*1.0 - totalProxyTVL := k.CalculateProxyTVL(ctx, baseCurrency) - - // Ensure lpIncentive.TotalBlocksPerYear or lpIncentive.EpochNumBlocks are not zero to avoid division by zero - if lpIncentive.TotalBlocksPerYear.IsZero() || params.DistributionInterval == 0 { - return errorsmod.Wrap(types.ErrNoInflationaryParams, "invalid inflationary params") - } - - // Calculate eden amount per epoch - epochLpsEdenAmount := lpIncentive.EdenAmountPerYear. - Mul(sdk.NewInt(params.DistributionInterval)). - Quo(lpIncentive.TotalBlocksPerYear) - - // Maximum eden based per distribution epoch on maximum APR - 30% by default - // Allocated for staking per day = (0.3/365)* (total weighted proxy TVL) - edenDenomPrice := k.GetEdenDenomPrice(ctx, baseCurrency) - - // Ensure edenDenomPrice is not zero to avoid division by zero - if edenDenomPrice.IsZero() { - return errorsmod.Wrap(types.ErrNoInflationaryParams, "invalid eden price") - } - - // Add dexRevenue amount that was tracked by Lp tracker - dexRevenueLPsAmtPerDistribution = dexRevenueLPsAmtPerDistribution.Add(params.DexRewardsLps.AmountCollectedByOtherTracker) - // Increase block number - params.DexRewardsLps.NumBlocks = sdk.NewInt(params.DistributionInterval) - // Incrase total dex rewards given - params.DexRewardsLps.Amount = dexRevenueLPsAmtPerDistribution.Add(gasFeesLPsAmtPerDistribution) - // Reset amount from other tracker - params.DexRewardsLps.AmountCollectedByOtherTracker = sdk.ZeroDec() - // Don't increase Lps rewards blocks, it will be increased whenever LP distribution epoch happens. - params.DexRewardsStakers.AmountCollectedByOtherTracker = params.DexRewardsStakers.AmountCollectedByOtherTracker.Add(dexRevenueStakersAmtPerDistribution) - k.SetParams(ctx, params) - - totalEdenGivenLP := sdk.ZeroInt() - totalRewardsGivenLP := sdk.ZeroInt() - // Process to increase uncomitted token amount of Eden & Eden boost - k.cmk.IterateCommitments( - ctx, func(commitments ctypes.Commitments) bool { - // Commitment owner - creator := commitments.Creator - _, err := sdk.AccAddressFromBech32(creator) - if err != nil { - // This could be validator address - return false - } - - rewardsByElysStaking := sdk.NewCoins() - rewardsByEdenCommitted := sdk.NewCoins() - rewardsByEdenBCommitted := sdk.NewCoins() - rewardsByUSDCDeposit := sdk.NewCoins() - - newSumEdenRewardsUnClaimed := sdk.ZeroInt() - newSumEdenBRewardsUnClaimed := sdk.ZeroInt() - newSumDexRewardsUnClaimed := sdk.ZeroInt() - - // Calculate new unclaimed Eden tokens from LpTokens committed, Dex rewards distribution - // Distribute gas fees to LPs - // ---------------------------------------------------------- - // ---------------------------------------------------------- - newUnclaimedEdenTokensLp, dexRewardsLp := k.CalcRewardsForLPs( - ctx, lpIncentive.TotalBlocksPerYear, totalProxyTVL, - commitments, epochLpsEdenAmount, gasFeesLPsAmtPerDistribution, - ) - // Total - totalEdenGivenLP = totalEdenGivenLP.Add(newUnclaimedEdenTokensLp) - totalRewardsGivenLP = totalRewardsGivenLP.Add(dexRewardsLp) - - // Sum for each loop - newSumEdenRewardsUnClaimed = newSumEdenRewardsUnClaimed.Add(newUnclaimedEdenTokensLp) - newSumDexRewardsUnClaimed = newSumDexRewardsUnClaimed.Add(dexRewardsLp) - // ---------------------------------------------------------- - // ---------------------------------------------------------- - - // Calculate new unclaimed Eden tokens from stable stake LpTokens committed, Dex rewards distribution - // Distribute gas fees to LPs - // ---------------------------------------------------------- - // ---------------------------------------------------------- - newUnclaimedEdenTokensStableLp, dexRewardsStableLp := k.CalcRewardsForStableStakeLPs( - ctx, lpIncentive.TotalBlocksPerYear, totalProxyTVL, - commitments, epochLpsEdenAmount, gasFeesLPsAmtPerDistribution, baseCurrency, - ) - - // Total - totalEdenGivenLP = totalEdenGivenLP.Add(newUnclaimedEdenTokensStableLp) - totalRewardsGivenLP = totalRewardsGivenLP.Add(dexRewardsStableLp) - - // Sum for each loop - newSumEdenRewardsUnClaimed = newSumEdenRewardsUnClaimed.Add(newUnclaimedEdenTokensStableLp) - newSumDexRewardsUnClaimed = newSumDexRewardsUnClaimed.Add(dexRewardsStableLp) - - // Sub bucket - rewardsByUSDCDeposit = rewardsByUSDCDeposit.Add(sdk.NewCoin(ptypes.Eden, newUnclaimedEdenTokensStableLp)) - rewardsByUSDCDeposit = rewardsByUSDCDeposit.Add(sdk.NewCoin(baseCurrency, dexRewardsStableLp)) - // ---------------------------------------------------------- - // ---------------------------------------------------------- - - // Update Commitments with new unclaimed token amounts - k.UpdateCommitments(ctx, creator, &commitments, newSumEdenRewardsUnClaimed, newSumEdenBRewardsUnClaimed, newSumDexRewardsUnClaimed, baseCurrency) - - // Update sub buckets commitment with new unclaimed token amounts - k.UpdateCommitmentsSubBuckets(ctx, creator, &commitments, rewardsByElysStaking, rewardsByEdenCommitted, rewardsByEdenBCommitted, rewardsByUSDCDeposit) - return false - }, - ) - - // Calcualte the remainings - edenRemainedLP := epochLpsEdenAmount.Sub(totalEdenGivenLP) - dexRewardsRemainedLP := dexRevenueLPsAmtPerDistribution.Add(gasFeesLPsAmtPerDistribution).Sub(sdk.NewDecFromInt(totalRewardsGivenLP)) - - // Fund community the remain coins - // ---------------------------------- - edenRemainedCoin := sdk.NewDecCoin(ptypes.Eden, edenRemainedLP) - dexRewardsRemainedCoin := sdk.NewDecCoinFromDec(baseCurrency, dexRewardsRemainedLP) - - feePool := k.GetFeePool(ctx) - feePool.CommunityPool = feePool.CommunityPool.Add(edenRemainedCoin) - feePool.CommunityPool = feePool.CommunityPool.Add(dexRewardsRemainedCoin) - k.SetFeePool(ctx, feePool) - // ---------------------------------- - - // Update APR for amm pools - k.UpdateAmmPoolAPR(ctx, lpIncentive, totalProxyTVL, edenDenomPrice) - - return nil -} - -// Update commitment record -func (k Keeper) UpdateCommitments( - ctx sdk.Context, - creator string, - commitments *ctypes.Commitments, - newUnclaimedEdenTokens math.Int, - newUnclaimedEdenBTokens math.Int, - dexRewards math.Int, - baseCurrency string, -) { - // Update unclaimed Eden balances in the Commitments structure - commitments.AddRewardsUnclaimed(sdk.NewCoin(ptypes.Eden, newUnclaimedEdenTokens)) - // Update unclaimed Eden-Boost token balances in the Commitments structure - commitments.AddRewardsUnclaimed(sdk.NewCoin(ptypes.EdenB, newUnclaimedEdenBTokens)) - - // All dex revenue are collected to incentive module in USDC - // Gas fees (Elys) are also converted into USDC and collected into total dex revenue wallet of incentive module. - // Update USDC balances in the Commitments structure. - // These are the rewards from each pool, perpetual, gas fee. - commitments.AddRewardsUnclaimed(sdk.NewCoin(baseCurrency, dexRewards)) - - // Save the updated Commitments - k.cmk.SetCommitments(ctx, *commitments) -} - -// Update sub bucket commitment record -func (k Keeper) UpdateCommitmentsSubBuckets(ctx sdk.Context, creator string, commitments *ctypes.Commitments, rewardsByElysStaking sdk.Coins, rewardsByEdenCommitted sdk.Coins, rewardsByEdenBCommitted sdk.Coins, rewardsByUSDCDeposit sdk.Coins) { - // Add to Elys staking bucket - commitments.AddSubBucketRewardsByElysUnclaimed(rewardsByElysStaking) - // Add to Eden committed bucket - commitments.AddSubBucketRewardsByEdenUnclaimed(rewardsByEdenCommitted) - // Add to EdenB committed bucket - commitments.AddSubBucketRewardsByEdenBUnclaimed(rewardsByEdenBCommitted) - // Add to USDC deposit bucket - commitments.AddSubBucketRewardsByUsdcUnclaimed(rewardsByUSDCDeposit) - - // Save the updated Commitments - k.cmk.SetCommitments(ctx, *commitments) -} - -// Calculate Proxy TVL -func (k Keeper) CalculateProxyTVL(ctx sdk.Context, baseCurrency string) sdk.Dec { - multipliedShareSum := sdk.ZeroDec() - k.amm.IterateLiquidityPools(ctx, func(p ammtypes.Pool) bool { - tvl, err := p.TVL(ctx, k.oracleKeeper) - if err != nil { - return false - } - - // Get pool info from incentive param - poolInfo, found := k.GetPoolInfo(ctx, p.GetPoolId()) - if !found { - return false - } - - proxyTVL := tvl.Mul(poolInfo.Multiplier) - - // Calculate total pool share by TVL and multiplier - multipliedShareSum = multipliedShareSum.Add(proxyTVL) - - return false - }) - - //----------------------------------- - // Handle stable stake pool - stableStakePoolId := uint64(stabletypes.PoolId) - - // Get pool info from incentive param - poolInfo, found := k.GetPoolInfo(ctx, stableStakePoolId) - if !found { - k.InitStableStakePoolParams(ctx, stableStakePoolId) - poolInfo, _ = k.GetPoolInfo(ctx, stableStakePoolId) - } - tvl := k.stableKeeper.TVL(ctx, k.oracleKeeper, baseCurrency) - proxyTVL := tvl.Mul(poolInfo.Multiplier) - multipliedShareSum = multipliedShareSum.Add(proxyTVL) - - // return total sum of TVL share using multiplier of all pools - return multipliedShareSum -} - // Caculate total TVL func (k Keeper) CalculateTVL(ctx sdk.Context) sdk.Dec { TVL := sdk.ZeroDec() @@ -586,80 +97,25 @@ func (k Keeper) CalculateTVL(ctx sdk.Context) sdk.Dec { return TVL } -// Update APR for AMM pool -func (k Keeper) UpdateAmmPoolAPR(ctx sdk.Context, lpIncentive types.IncentiveInfo, totalProxyTVL sdk.Dec, edenDenomPrice sdk.Dec) { - params := k.GetParams(ctx) - - // Iterate to calculate total Eden from LpElys, MElys committed - k.amm.IterateLiquidityPools(ctx, func(p ammtypes.Pool) bool { - tvl, err := p.TVL(ctx, k.oracleKeeper) - if err != nil { - return false - } - - // Get pool Id - poolId := p.GetPoolId() - - // Get pool info from incentive param - poolInfo, found := k.GetPoolInfo(ctx, poolId) - if !found { - k.InitPoolParams(ctx, poolId) - poolInfo, _ = k.GetPoolInfo(ctx, poolId) - } - - poolInfo.NumBlocks = sdk.NewInt(params.DistributionInterval) - // Invalid block number - if poolInfo.NumBlocks.IsZero() { - return false - } - - if tvl.IsZero() { - return false - } - - // poolDexApr = usdcRewardPerBlock * lpIncentive.TotalBlocksPerYear / TVL of pool - yearlyDexRewardsTotal := poolInfo.DexRewardAmountGiven. - MulInt(lpIncentive.TotalBlocksPerYear). - QuoInt(poolInfo.NumBlocks) - poolInfo.DexApr = yearlyDexRewardsTotal.Quo(tvl) - - // poolEdenApr = edenRewardPerBlock * edenPrice * lpIncentive.TotalBlocksPerYear / TVL of pool - yearlyEdenRewardsTotal := poolInfo.EdenRewardAmountGiven. - Mul(lpIncentive.TotalBlocksPerYear). - Quo(poolInfo.NumBlocks) - - poolInfo.EdenApr = sdk.NewDecFromInt(yearlyEdenRewardsTotal). - Mul(edenDenomPrice). - Quo(tvl) - - // Update Pool Info - k.SetPoolInfo(ctx, poolId, poolInfo) - - return false - }) -} - // Get total dex rewards amount from the specified pool func (k Keeper) GetDailyRewardsAmountForPool(ctx sdk.Context, poolId uint64) (sdk.Dec, sdk.Coins) { - poolInfo, found := k.GetPoolInfo(ctx, poolId) + poolInfo, found := k.masterchef.GetPool(ctx, poolId) if !found { return sdk.ZeroDec(), sdk.Coins{} } // Fetch incentive params - params := k.GetParams(ctx) + params := k.masterchef.GetParams(ctx) if params.LpIncentives == nil { return sdk.ZeroDec(), sdk.Coins{} } // Dex reward Apr per pool = total accumulated usdc rewards for 7 day * 52/ tvl of pool dailyDexRewardsTotal := poolInfo.DexRewardAmountGiven. - MulInt(sdk.NewInt(params.DistributionInterval)). QuoInt(poolInfo.NumBlocks) // Eden reward Apr per pool = (total LM Eden reward allocated per day*((tvl of pool * multiplier)/total proxy TVL) ) * 365 / TVL of pool dailyEdenRewardsTotal := poolInfo.EdenRewardAmountGiven. - Mul(sdk.NewInt(params.DistributionInterval)). Quo(poolInfo.NumBlocks) entry, found := k.assetProfileKeeper.GetEntry(ctx, ptypes.BaseCurrency) @@ -672,7 +128,7 @@ func (k Keeper) GetDailyRewardsAmountForPool(ctx sdk.Context, poolId uint64) (sd rewardCoins = rewardCoins.Add(sdk.NewCoin(baseCurrency, math.Int(dailyDexRewardsTotal))) usdcDenomPrice := k.oracleKeeper.GetAssetPriceFromDenom(ctx, baseCurrency) - edenDenomPrice := k.GetEdenDenomPrice(ctx, baseCurrency) + edenDenomPrice := k.amm.GetEdenDenomPrice(ctx, baseCurrency) totalRewardsUsd := usdcDenomPrice.Mul(dailyDexRewardsTotal).Add(edenDenomPrice.MulInt(dailyEdenRewardsTotal)) return totalRewardsUsd, rewardCoins diff --git a/x/incentive/keeper/keeper_apr_per_pool_test.go b/x/incentive/keeper/keeper_apr_per_pool_test.go deleted file mode 100644 index 6942b820d..000000000 --- a/x/incentive/keeper/keeper_apr_per_pool_test.go +++ /dev/null @@ -1,116 +0,0 @@ -package keeper_test - -import ( - "testing" - - tmproto "github.com/cometbft/cometbft/proto/tendermint/types" - sdk "github.com/cosmos/cosmos-sdk/types" - simapp "github.com/elys-network/elys/app" - ammtypes "github.com/elys-network/elys/x/amm/types" - "github.com/elys-network/elys/x/incentive/types" - ptypes "github.com/elys-network/elys/x/parameter/types" - "github.com/stretchr/testify/require" -) - -func TestAPRCalculationPerPool(t *testing.T) { - app := simapp.InitElysTestApp(initChain) - ctx := app.BaseApp.NewContext(initChain, tmproto.Header{}) - - ik, amm, oracle := app.IncentiveKeeper, app.AmmKeeper, app.OracleKeeper - - // Setup coin prices - SetupStableCoinPrices(ctx, oracle) - - // Generate 1 random account with 1000stake balanced - addr := simapp.AddTestAddrs(app, ctx, 2, sdk.NewInt(1000000)) - - // Create a pool - // Mint 100000USDC - usdcToken := sdk.NewCoins(sdk.NewCoin(ptypes.BaseCurrency, sdk.NewInt(100000))) - - err := app.BankKeeper.MintCoins(ctx, ammtypes.ModuleName, usdcToken) - require.NoError(t, err) - err = app.BankKeeper.SendCoinsFromModuleToAccount(ctx, ammtypes.ModuleName, addr[0], usdcToken) - require.NoError(t, err) - - poolAssets := []ammtypes.PoolAsset{ - { - Weight: sdk.NewInt(50), - Token: sdk.NewCoin(ptypes.Elys, sdk.NewInt(100000)), - }, - { - Weight: sdk.NewInt(50), - Token: sdk.NewCoin(ptypes.BaseCurrency, sdk.NewInt(10000)), - }, - } - - argSwapFee := sdk.MustNewDecFromStr("0.0") - argExitFee := sdk.MustNewDecFromStr("0.0") - - poolParams := &ammtypes.PoolParams{ - SwapFee: argSwapFee, - ExitFee: argExitFee, - } - - msg := ammtypes.NewMsgCreatePool( - addr[0].String(), - poolParams, - poolAssets, - ) - - // Create a Elys+USDC pool - poolId, err := amm.CreatePool(ctx, msg) - require.NoError(t, err) - require.Equal(t, poolId, uint64(1)) - - pools := amm.GetAllPool(ctx) - - // check length of pools - require.Equal(t, len(pools), 1) - - // check block height - require.Equal(t, int64(0), ctx.BlockHeight()) - - params := ik.GetParams(ctx) - params.DistributionInterval = 10 - ik.SetParams(ctx, params) - - lpIncentive := types.IncentiveInfo{ - // reward amount in eden for 1 year - EdenAmountPerYear: sdk.NewInt(1000000000), - // starting block height of the distribution - DistributionStartBlock: sdk.NewInt(1), - // distribution duration - block number per year - TotalBlocksPerYear: sdk.NewInt(10000), - // current epoch in block number - CurrentEpochInBlocks: sdk.NewInt(1), - } - - ctx = ctx.WithBlockHeight(params.DistributionInterval) - ik.UpdateLPRewardsUnclaimed(ctx, lpIncentive) - - // Get pool info from incentive param - poolInfo, found := ik.GetPoolInfo(ctx, poolId) - require.Equal(t, found, true) - require.Equal(t, poolInfo.EdenApr.String(), "0.499500499500499500") - - // Get dex rewards per pool - revenueAddress := ammtypes.NewPoolRevenueAddress(poolId) - - // Feed dex rewards - usdcToken = sdk.NewCoins(sdk.NewCoin(ptypes.BaseCurrency, sdk.NewInt(1000))) - err = app.BankKeeper.MintCoins(ctx, ammtypes.ModuleName, usdcToken) - require.NoError(t, err) - err = app.BankKeeper.SendCoinsFromModuleToAccount(ctx, ammtypes.ModuleName, revenueAddress, usdcToken) - require.NoError(t, err) - - // 1 week later. - ctx = ctx.WithBlockHeight(params.DistributionInterval * 7) - poolInfo.NumBlocks = sdk.NewInt(ctx.BlockHeight()) - ik.SetPoolInfo(ctx, poolId, poolInfo) - - ik.UpdateLPRewardsUnclaimed(ctx, lpIncentive) - poolInfo, found = ik.GetPoolInfo(ctx, poolId) - require.Equal(t, found, true) - require.Equal(t, poolInfo.EdenApr.String(), "0.499500499500499500") -} diff --git a/x/incentive/keeper/keeper_fees.go b/x/incentive/keeper/keeper_fees.go deleted file mode 100644 index b28345e35..000000000 --- a/x/incentive/keeper/keeper_fees.go +++ /dev/null @@ -1,147 +0,0 @@ -package keeper - -import ( - "fmt" - - sdk "github.com/cosmos/cosmos-sdk/types" - ammtypes "github.com/elys-network/elys/x/amm/types" - "github.com/elys-network/elys/x/incentive/types" - ptypes "github.com/elys-network/elys/x/parameter/types" -) - -// Move gas fees collected to dex revenue wallet -// Convert it into USDC -func (k Keeper) CollectGasFeesToIncentiveModule(ctx sdk.Context, baseCurrency string) sdk.Coins { - // fetch and clear the collected fees for distribution, since this is - // called in BeginBlock, collected fees will be from the previous block - // (and distributed to the previous proposer) - feeCollector := k.authKeeper.GetModuleAccount(ctx, k.feeCollectorName) - feesCollected := k.bankKeeper.GetAllBalances(ctx, feeCollector.GetAddress()) - - // Total Swapped coin - totalSwappedCoins := sdk.Coins{} - - for _, tokenIn := range feesCollected { - // if it is base currency - usdc, we don't need convert. We just need to collect it to fee wallet. - if tokenIn.Denom == baseCurrency { - // Transfer converted USDC fees to the Dex revenue module account - err := k.bankKeeper.SendCoinsFromModuleToModule(ctx, k.feeCollectorName, k.dexRevCollectorName, sdk.Coins{tokenIn}) - if err != nil { - panic(err) - } - - // Sum total swapped - totalSwappedCoins = totalSwappedCoins.Add(tokenIn) - continue - } - - // Find a pool that can convert tokenIn to usdc - pool, found := k.amm.GetBestPoolWithDenoms(ctx, []string{tokenIn.Denom, baseCurrency}) - if !found { - continue - } - - // Executes the swap in the pool and stores the output. Updates pool assets but - // does not actually transfer any tokens to or from the pool. - snapshot := k.amm.GetPoolSnapshotOrSet(ctx, pool) - tokenOutCoin, _, _, _, err := k.amm.SwapOutAmtGivenIn(ctx, pool.PoolId, k.oracleKeeper, &snapshot, sdk.Coins{tokenIn}, baseCurrency, sdk.ZeroDec()) - if err != nil { - continue - } - - tokenOutAmount := tokenOutCoin.Amount - if !tokenOutAmount.IsPositive() { - continue - } - - // Settles balances between the tx sender and the pool to match the swap that was executed earlier. - // Also emits a swap event and updates related liquidity metrics. - cacheCtx, write := ctx.CacheContext() - _, err = k.amm.UpdatePoolForSwap(cacheCtx, pool, feeCollector.GetAddress(), feeCollector.GetAddress(), tokenIn, tokenOutCoin, sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()) - if err != nil { - continue - } - write() - - // Swapped USDC coin - swappedCoins := sdk.NewCoins(sdk.NewCoin(baseCurrency, tokenOutAmount)) - - // Transfer converted USDC fees to the Dex revenue module account - if swappedCoins.IsAllPositive() { - err = k.bankKeeper.SendCoinsFromModuleToModule(ctx, k.feeCollectorName, k.dexRevCollectorName, swappedCoins) - if err != nil { - panic(err) - } - } - - // Sum total swapped - totalSwappedCoins = totalSwappedCoins.Add(swappedCoins...) - } - - return totalSwappedCoins -} - -// Collect all DEX revenues to DEX revenue wallet, -// while tracking the 65% of it for LPs reward distribution -// transfer collected fees from different wallets(liquidity pool, perpetual module etc) to the distribution module account -// Assume this is already in USDC. -// TODO: -// + Collect revenue from perpetual, lend module -func (k Keeper) CollectDEXRevenue(ctx sdk.Context) (sdk.Coins, sdk.DecCoins, sdk.DecCoins) { - // Total colllected revenue amount - amountTotalCollected := sdk.Coins{} - amountLPsCollected := sdk.DecCoins{} - amountStakersCollected := sdk.DecCoins{} - - // Iterate to calculate total Eden from LpElys, MElys committed - k.amm.IterateLiquidityPools(ctx, func(p ammtypes.Pool) bool { - // Get pool Id - poolId := p.GetPoolId() - - // Get dex rewards per pool - revenueAddress := ammtypes.NewPoolRevenueAddress(poolId) - - // Transfer revenue to a single wallet of DEX revenue wallet. - revenue := k.bankKeeper.GetAllBalances(ctx, revenueAddress) - if revenue.IsAllPositive() { - err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, revenueAddress, k.dexRevCollectorName, revenue) - if err != nil { - panic(err) - } - } - - // LPs Portion param - rewardPortionForLps := k.GetDEXRewardPortionForLPs(ctx) - // Stakers Portion param - rewardPortionForStakers := k.GetDEXRewardPortionForStakers(ctx) - - // Calculate revenue portion for LPs - revenueDec := sdk.NewDecCoinsFromCoins(revenue...) - - // LPs portion of pool revenue - revenuePortionForLPs := revenueDec.MulDecTruncate(rewardPortionForLps) - revenuePortionForStakers := revenueDec.MulDecTruncate(rewardPortionForStakers) - - // Get track key - trackKey := types.GetPoolRevenueTrackKey(poolId) - - // Store revenue portion for Lps temporarilly - entry, found := k.assetProfileKeeper.GetEntry(ctx, ptypes.BaseCurrency) - if !found { - panic(fmt.Sprintf("asset %s not found", ptypes.BaseCurrency)) - } - baseCurrency := entry.Denom - k.tci.PoolRevenueTrack[trackKey] = revenuePortionForLPs.AmountOf(baseCurrency) - - // Sum total collected amount - amountTotalCollected = amountTotalCollected.Add(revenue...) - - // Sum total amount for LPs - amountLPsCollected = amountLPsCollected.Add(revenuePortionForLPs...) - amountStakersCollected = amountStakersCollected.Add(revenuePortionForStakers...) - - return false - }) - - return amountTotalCollected, amountLPsCollected, amountStakersCollected -} diff --git a/x/incentive/keeper/keeper_lps.go b/x/incentive/keeper/keeper_lps.go deleted file mode 100644 index e0d0a0adc..000000000 --- a/x/incentive/keeper/keeper_lps.go +++ /dev/null @@ -1,140 +0,0 @@ -package keeper - -import ( - "cosmossdk.io/math" - sdk "github.com/cosmos/cosmos-sdk/types" - ammtypes "github.com/elys-network/elys/x/amm/types" - ctypes "github.com/elys-network/elys/x/commitment/types" - "github.com/elys-network/elys/x/incentive/types" - ptypes "github.com/elys-network/elys/x/parameter/types" -) - -// Calculate new Eden token amounts based on LpElys committed and MElys committed -func (k Keeper) CalcRewardsForLPs( - ctx sdk.Context, - totalBlocksPerYear sdk.Int, - totalProxyTVL sdk.Dec, - commitments ctypes.Commitments, - edenAmountForLpPerDistribution math.Int, - gasFeesForLPsPerDistribution sdk.Dec, -) (math.Int, math.Int) { - // Method 2 - Using Proxy TVL - totalNewEdenAllocatedPerDistribution := sdk.ZeroInt() - totalDexRewardsAllocatedPerDistribution := sdk.ZeroDec() - - entry, found := k.assetProfileKeeper.GetEntry(ctx, ptypes.BaseCurrency) - if !found { - return sdk.ZeroInt(), sdk.ZeroInt() - } - baseCurrency := entry.Denom - - params := k.GetParams(ctx) - edenDenomPrice := k.GetEdenDenomPrice(ctx, baseCurrency) - - // Iterate to calculate total Eden from LpElys, MElys committed - k.amm.IterateLiquidityPools(ctx, func(p ammtypes.Pool) bool { - // ------------ New Eden calculation ------------------- - // ----------------------------------------------------- - // newEdenAllocated = 80 / ( 80 + 90 + 200 + 0) * 100 - // Pool share = 80 - // edenAmountPerEpochLp = 100 - tvl, err := p.TVL(ctx, k.oracleKeeper) - if err != nil { - return false - } - - // Get pool Id - poolId := p.GetPoolId() - - // Get pool share denom - lp token - lpToken := ammtypes.GetPoolShareDenom(poolId) - - // Get pool info from incentive param - poolInfo, found := k.GetPoolInfo(ctx, poolId) - if !found { - k.InitPoolParams(ctx, poolId) - poolInfo, _ = k.GetPoolInfo(ctx, poolId) - } - - // Calculate Proxy TVL share considering multiplier - proxyTVL := tvl.Mul(poolInfo.Multiplier) - poolShare := sdk.ZeroDec() - if totalProxyTVL.IsPositive() { - poolShare = proxyTVL.Quo(totalProxyTVL) - } - - // Calculate new Eden for this pool - newEdenAllocatedForPool := poolShare.MulInt(edenAmountForLpPerDistribution) - - poolMaxEdenAmount := params.MaxEdenRewardAprLps. - Mul(tvl). - MulInt64(params.DistributionInterval). - QuoInt(totalBlocksPerYear). - Quo(edenDenomPrice) - - // Use min amount (eden allocation from tokenomics and max apr based eden amount) - newEdenAllocatedForPool = sdk.MinDec(newEdenAllocatedForPool, poolMaxEdenAmount) - - // this lp token committed - commmittedLpToken := commitments.GetCommittedAmountForDenom(lpToken) - // this lp token total committed - totalCommittedLpToken, ok := k.tci.TotalLpTokensCommitted[lpToken] - if !ok { - return false - } - - // If total committed LP token amount is zero - if totalCommittedLpToken.LTE(sdk.ZeroInt()) { - return false - } - - // Calculalte lp token share of the pool - lpShare := sdk.NewDecFromInt(commmittedLpToken).QuoInt(totalCommittedLpToken) - - // Calculate new Eden allocated per LP - newEdenAllocated := lpShare.Mul(newEdenAllocatedForPool).TruncateInt() - - // Sum the total amount - totalNewEdenAllocatedPerDistribution = totalNewEdenAllocatedPerDistribution.Add(newEdenAllocated) - // ------------------------------------------------------- - - // ------------------- DEX rewards calculation ------------------- - // --------------------------------------------------------------- - // Get dex rewards per pool - // Get track key - trackKey := types.GetPoolRevenueTrackKey(poolId) - // Get tracked amount for Lps per pool - dexRewardsAllocatedForPool, ok := k.tci.PoolRevenueTrack[trackKey] - if !ok { - dexRewardsAllocatedForPool = sdk.NewDec(0) - } - - // Calculate dex rewards per lp - dexRewardsForLP := lpShare.Mul(dexRewardsAllocatedForPool) - // Sum total rewards per commitment - totalDexRewardsAllocatedPerDistribution = totalDexRewardsAllocatedPerDistribution.Add(dexRewardsForLP) - - //---------------------------------------------------------------- - - // ------------------- Gas rewards calculation ------------------- - // --------------------------------------------------------------- - // Get gas fee rewards per pool - gasRewardsAllocatedForPool := poolShare.Mul(gasFeesForLPsPerDistribution) - // Calculate gas fee rewards per lp - gasRewardsForLP := lpShare.Mul(gasRewardsAllocatedForPool) - // Sum total rewards per commitment - totalDexRewardsAllocatedPerDistribution = totalDexRewardsAllocatedPerDistribution.Add(gasRewardsForLP) - - //---------------------------------------------------------------- - - poolInfo.EdenRewardAmountGiven = newEdenAllocatedForPool.RoundInt() - poolInfo.DexRewardAmountGiven = gasRewardsAllocatedForPool.Add(dexRewardsAllocatedForPool) - // Update Pool Info - k.SetPoolInfo(ctx, poolId, poolInfo) - - return false - }) - - // return - return totalNewEdenAllocatedPerDistribution, totalDexRewardsAllocatedPerDistribution.TruncateInt() -} diff --git a/x/incentive/keeper/keeper_lps_test.go b/x/incentive/keeper/keeper_lps_test.go deleted file mode 100644 index 617c537cc..000000000 --- a/x/incentive/keeper/keeper_lps_test.go +++ /dev/null @@ -1,186 +0,0 @@ -package keeper_test - -import ( - "testing" - - "github.com/cometbft/cometbft/crypto/ed25519" - tmproto "github.com/cometbft/cometbft/proto/tendermint/types" - sdk "github.com/cosmos/cosmos-sdk/types" - simapp "github.com/elys-network/elys/app" - ammkeeper "github.com/elys-network/elys/x/amm/keeper" - ammtypes "github.com/elys-network/elys/x/amm/types" - ctypes "github.com/elys-network/elys/x/commitment/types" - oraclekeeper "github.com/elys-network/elys/x/oracle/keeper" - oracletypes "github.com/elys-network/elys/x/oracle/types" - ptypes "github.com/elys-network/elys/x/parameter/types" - "github.com/stretchr/testify/require" -) - -func SetupStableCoinPrices(ctx sdk.Context, oracle oraclekeeper.Keeper) { - // prices set for USDT and USDC - provider := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address()) - oracle.SetAssetInfo(ctx, oracletypes.AssetInfo{ - Denom: ptypes.BaseCurrency, - Display: "USDC", - Decimal: 6, - }) - oracle.SetAssetInfo(ctx, oracletypes.AssetInfo{ - Denom: "uusdt", - Display: "USDT", - Decimal: 6, - }) - oracle.SetAssetInfo(ctx, oracletypes.AssetInfo{ - Denom: ptypes.Elys, - Display: "ELYS", - Decimal: 6, - }) - oracle.SetAssetInfo(ctx, oracletypes.AssetInfo{ - Denom: ptypes.ATOM, - Display: "ATOM", - Decimal: 6, - }) - - oracle.SetPrice(ctx, oracletypes.Price{ - Asset: "USDC", - Price: sdk.NewDec(1000000), - Source: "elys", - Provider: provider.String(), - Timestamp: uint64(ctx.BlockTime().Unix()), - }) - oracle.SetPrice(ctx, oracletypes.Price{ - Asset: "USDT", - Price: sdk.NewDec(1000000), - Source: "elys", - Provider: provider.String(), - Timestamp: uint64(ctx.BlockTime().Unix()), - }) - oracle.SetPrice(ctx, oracletypes.Price{ - Asset: "ELYS", - Price: sdk.NewDec(100), - Source: "elys", - Provider: provider.String(), - Timestamp: uint64(ctx.BlockTime().Unix()), - }) - oracle.SetPrice(ctx, oracletypes.Price{ - Asset: "ATOM", - Price: sdk.NewDec(100), - Source: "atom", - Provider: provider.String(), - Timestamp: uint64(ctx.BlockTime().Unix()), - }) -} - -func TestCalcRewardsForLPs(t *testing.T) { - app := simapp.InitElysTestApp(initChain) - ctx := app.BaseApp.NewContext(initChain, tmproto.Header{}) - - ik, amm, oracle, bk, ck := app.IncentiveKeeper, app.AmmKeeper, app.OracleKeeper, app.BankKeeper, app.CommitmentKeeper - - // Setup coin prices - SetupStableCoinPrices(ctx, oracle) - - // Generate 1 random account with 1000stake balanced - addr := simapp.AddTestAddrs(app, ctx, 1, sdk.NewInt(100010)) - - var committed sdk.Coins - var unclaimed sdk.Coins - - // Prepare unclaimed tokens - uedenToken := sdk.NewCoin(ptypes.Eden, sdk.NewInt(2000)) - unclaimed = append(unclaimed, uedenToken) - - err := app.BankKeeper.MintCoins(ctx, ctypes.ModuleName, unclaimed) - require.NoError(t, err) - err = app.BankKeeper.SendCoinsFromModuleToAccount(ctx, ctypes.ModuleName, addr[0], unclaimed) - require.NoError(t, err) - - // Prepare committed tokens - uedenToken = sdk.NewCoin(ptypes.Eden, sdk.NewInt(500)) - lpToken1 := sdk.NewCoin("lp-elys-usdc", sdk.NewInt(500)) - lpToken2 := sdk.NewCoin("lp-ueden-usdc", sdk.NewInt(2000)) - committed = committed.Add(lpToken1, lpToken2, uedenToken) - - err = app.BankKeeper.MintCoins(ctx, ctypes.ModuleName, committed) - require.NoError(t, err) - err = app.BankKeeper.SendCoinsFromModuleToAccount(ctx, ctypes.ModuleName, addr[0], committed) - require.NoError(t, err) - - simapp.AddTestCommitment(app, ctx, addr[0], committed, unclaimed) - - // Create a pool - // Mint 100000USDC + 10 ELYS (pool creation fee) - coins := sdk.NewCoins(sdk.NewInt64Coin(ptypes.Elys, 10000000), sdk.NewInt64Coin(ptypes.BaseCurrency, 100000)) - err = app.BankKeeper.MintCoins(ctx, ammtypes.ModuleName, coins) - require.NoError(t, err) - err = app.BankKeeper.SendCoinsFromModuleToAccount(ctx, ammtypes.ModuleName, addr[0], coins) - require.NoError(t, err) - - var poolAssets []ammtypes.PoolAsset - // Elys - poolAssets = append(poolAssets, ammtypes.PoolAsset{ - Weight: sdk.NewInt(50), - Token: sdk.NewCoin(ptypes.Elys, sdk.NewInt(1000)), - }) - - // USDC - poolAssets = append(poolAssets, ammtypes.PoolAsset{ - Weight: sdk.NewInt(50), - Token: sdk.NewCoin(ptypes.BaseCurrency, sdk.NewInt(100)), - }) - - poolParams := &ammtypes.PoolParams{ - SwapFee: sdk.ZeroDec(), - ExitFee: sdk.ZeroDec(), - UseOracle: false, - WeightBreakingFeeMultiplier: sdk.ZeroDec(), - WeightBreakingFeeExponent: sdk.NewDecWithPrec(25, 1), // 2.5 - ExternalLiquidityRatio: sdk.OneDec(), - WeightRecoveryFeePortion: sdk.NewDecWithPrec(10, 2), // 10% - ThresholdWeightDifference: sdk.ZeroDec(), - FeeDenom: "", - } - - // Create a Elys+USDC pool - msgServer := ammkeeper.NewMsgServerImpl(amm) - resp, err := msgServer.CreatePool( - sdk.WrapSDKContext(ctx), - &ammtypes.MsgCreatePool{ - Sender: addr[0].String(), - PoolParams: poolParams, - PoolAssets: poolAssets, - }) - - require.NoError(t, err) - require.Equal(t, resp.PoolID, uint64(1)) - - pools := amm.GetAllPool(ctx) - - // check length of pools - require.Equal(t, len(pools), 1) - - // check balance change on sender - balances := bk.GetBalance(ctx, addr[0], "amm/pool/1") - require.Equal(t, balances, sdk.NewCoin("amm/pool/1", sdk.NewInt(0))) - - // check lp token commitment - commitments := ck.GetCommitments(ctx, addr[0].String()) - require.Len(t, commitments.CommittedTokens, 4) - require.Equal(t, commitments.CommittedTokens[3].Denom, "amm/pool/1") - require.Equal(t, commitments.CommittedTokens[3].Amount.String(), "100100000000000000000") - - require.Equal(t, ik.CalculateTVL(ctx), sdk.NewDecWithPrec(1001, 1)) - - edenAmountPerEpochLp := sdk.NewInt(1000000) - totalProxyTVL := ik.CalculateProxyTVL(ctx, ptypes.BaseCurrency) - - // Recalculate total committed info - ik.UpdateTotalCommitmentInfo(ctx, ptypes.BaseCurrency) - - gasFeesLPsAmt := sdk.NewDec(1000) - // Calculate rewards for LPs - newUnclaimedEdenTokensLp, dexRewardsLp := ik.CalcRewardsForLPs( - ctx, sdk.NewInt(1), totalProxyTVL, commitments, edenAmountPerEpochLp, gasFeesLPsAmt) - - require.Equal(t, newUnclaimedEdenTokensLp, sdk.NewInt(5005)) - require.Equal(t, dexRewardsLp, sdk.NewInt(1000)) -} diff --git a/x/incentive/keeper/keeper_shares_test.go b/x/incentive/keeper/keeper_shares_test.go deleted file mode 100644 index 5ac9677c8..000000000 --- a/x/incentive/keeper/keeper_shares_test.go +++ /dev/null @@ -1,100 +0,0 @@ -package keeper_test - -import ( - "testing" - - tmproto "github.com/cometbft/cometbft/proto/tendermint/types" - sdk "github.com/cosmos/cosmos-sdk/types" - simapp "github.com/elys-network/elys/app" - ctypes "github.com/elys-network/elys/x/commitment/types" - ptypes "github.com/elys-network/elys/x/parameter/types" - "github.com/stretchr/testify/require" -) - -func TestCalcTotalShareOfStaking(t *testing.T) { - app := simapp.InitElysTestApp(initChain) - ctx := app.BaseApp.NewContext(initChain, tmproto.Header{}) - - ik := app.IncentiveKeeper - - // Generate 2 random accounts with 1000000uelys balanced - addr := simapp.AddTestAddrs(app, ctx, 2, sdk.NewInt(1000)) - - var committed sdk.Coins - var unclaimed sdk.Coins - - // Prepare unclaimed tokens - uedenToken := sdk.NewCoin(ptypes.Eden, sdk.NewInt(1000)) - uedenBToken := sdk.NewCoin(ptypes.EdenB, sdk.NewInt(1000)) - unclaimed = unclaimed.Add(uedenToken, uedenBToken) - - // Mint coins - err := app.BankKeeper.MintCoins(ctx, ctypes.ModuleName, unclaimed) - require.NoError(t, err) - err = app.BankKeeper.SendCoinsFromModuleToAccount(ctx, ctypes.ModuleName, addr[0], unclaimed) - require.NoError(t, err) - - err = app.BankKeeper.MintCoins(ctx, ctypes.ModuleName, unclaimed) - require.NoError(t, err) - err = app.BankKeeper.SendCoinsFromModuleToAccount(ctx, ctypes.ModuleName, addr[1], unclaimed) - require.NoError(t, err) - - // Prepare committed tokens - uedenToken = sdk.NewCoin(ptypes.Eden, sdk.NewInt(1000)) - uedenBToken = sdk.NewCoin(ptypes.EdenB, sdk.NewInt(1000)) - committed = committed.Add(uedenToken, uedenBToken) - - // Eden - err = app.BankKeeper.MintCoins(ctx, ctypes.ModuleName, committed) - require.NoError(t, err) - err = app.BankKeeper.SendCoinsFromModuleToAccount(ctx, ctypes.ModuleName, addr[0], committed) - require.NoError(t, err) - - err = app.BankKeeper.MintCoins(ctx, ctypes.ModuleName, committed) - require.NoError(t, err) - err = app.BankKeeper.SendCoinsFromModuleToAccount(ctx, ctypes.ModuleName, addr[1], committed) - require.NoError(t, err) - - // Add testing commitment - simapp.AddTestCommitment(app, ctx, addr[0], committed, unclaimed) - simapp.AddTestCommitment(app, ctx, addr[1], committed, unclaimed) - - commitment := app.CommitmentKeeper.GetCommitments(ctx, addr[0].String()) - - require.Equal(t, commitment.RewardsUnclaimed[0].Denom, ptypes.Eden) - require.Equal(t, commitment.RewardsUnclaimed[0].Amount, sdk.NewInt(1000)) - - require.Equal(t, commitment.RewardsUnclaimed[1].Denom, ptypes.EdenB) - require.Equal(t, commitment.RewardsUnclaimed[1].Amount, sdk.NewInt(1000)) - - require.Equal(t, commitment.CommittedTokens[0].Denom, ptypes.Eden) - require.Equal(t, commitment.CommittedTokens[0].Amount, sdk.NewInt(1000)) - - require.Equal(t, commitment.CommittedTokens[1].Denom, ptypes.EdenB) - require.Equal(t, commitment.CommittedTokens[1].Amount, sdk.NewInt(1000)) - - // Recalculate total committed info - ik.UpdateTotalCommitmentInfo(ctx, ptypes.BaseCurrency) - - share1 := ik.CalcTotalShareOfStaking(sdk.ZeroInt()) - require.Equal(t, share1, sdk.ZeroDec()) - - share2 := ik.CalcTotalShareOfStaking(sdk.NewInt(1004000)) - require.Equal(t, share2, sdk.NewDecWithPrec(1, 0)) -} - -func TestCalcDelegationAmount(t *testing.T) { - app, genAccount, _ := simapp.InitElysTestAppWithGenAccount() - ctx := app.BaseApp.NewContext(initChain, tmproto.Header{}) - - ik := app.IncentiveKeeper - addr := simapp.AddTestAddrs(app, ctx, 1, sdk.NewInt(1000)) - - // Check with non-delegator - delegatedAmount := ik.CalcDelegationAmount(ctx, addr[0].String()) - require.Equal(t, delegatedAmount, sdk.ZeroInt()) - - // Check with genesis account (delegator) - delegatedAmount = ik.CalcDelegationAmount(ctx, genAccount.String()) - require.Equal(t, delegatedAmount, sdk.DefaultPowerReduction) -} diff --git a/x/incentive/keeper/keeper_stable_stake_lps.go b/x/incentive/keeper/keeper_stable_stake_lps.go deleted file mode 100644 index 697d3f74c..000000000 --- a/x/incentive/keeper/keeper_stable_stake_lps.go +++ /dev/null @@ -1,125 +0,0 @@ -package keeper - -import ( - "cosmossdk.io/math" - sdk "github.com/cosmos/cosmos-sdk/types" - ctypes "github.com/elys-network/elys/x/commitment/types" - "github.com/elys-network/elys/x/incentive/types" - stabletypes "github.com/elys-network/elys/x/stablestake/types" -) - -// Calculate pool share for stable stake pool -func (k Keeper) CalculatePoolShareForStableStakeLPs(ctx sdk.Context, totalProxyTVL sdk.Dec, baseCurrency string) sdk.Dec { - // ------------ New Eden calculation ------------------- - // ----------------------------------------------------- - // newEdenAllocated = 80 / ( 80 + 90 + 200 + 0) * 100 - // Pool share = 80 - // edenAmountPerEpochLp = 100 - tvl := k.stableKeeper.TVL(ctx, k.oracleKeeper, baseCurrency) - - // Get pool Id - poolId := uint64(stabletypes.PoolId) - - // Get pool info from incentive param - poolInfo, found := k.GetPoolInfo(ctx, poolId) - if !found { - return sdk.ZeroDec() - } - - // Calculate Proxy TVL share considering multiplier - proxyTVL := tvl.Mul(poolInfo.Multiplier) - if totalProxyTVL.IsZero() { - return sdk.ZeroDec() - } - poolShare := proxyTVL.Quo(totalProxyTVL) - - return poolShare -} - -// Calculate new Eden token amounts based on LpElys committed and MElys committed -func (k Keeper) CalcRewardsForStableStakeLPs( - ctx sdk.Context, - totalBlocksPerYear sdk.Int, - totalProxyTVL sdk.Dec, - commitments ctypes.Commitments, - edenAmountPerEpochLp math.Int, - gasFeesForLPs sdk.Dec, - baseCurrency string, -) (math.Int, math.Int) { - // Method 2 - Using Proxy TVL - totalDexRewardsAllocated := sdk.ZeroDec() - - // Calculate pool share for stable stake pool - poolShare := k.CalculatePoolShareForStableStakeLPs(ctx, totalProxyTVL, baseCurrency) - - // Calculate new Eden for this pool - newEdenAllocatedForPool := poolShare.MulInt(edenAmountPerEpochLp) - - tvl := k.stableKeeper.TVL(ctx, k.oracleKeeper, baseCurrency) - edenDenomPrice := k.GetEdenDenomPrice(ctx, baseCurrency) - params := k.GetParams(ctx) - poolMaxEdenAmount := params.MaxEdenRewardAprLps. - Mul(tvl). - MulInt64(params.DistributionInterval). - QuoInt(totalBlocksPerYear). - Quo(edenDenomPrice) - - // Use min amount (eden allocation from tokenomics and max apr based eden amount) - newEdenAllocatedForPool = sdk.MinDec(newEdenAllocatedForPool, poolMaxEdenAmount) - - // Get pool share denom - stable stake lp token - lpToken := stabletypes.GetShareDenom() - - // this lp token committed - commmittedLpToken := commitments.GetCommittedAmountForDenom(lpToken) - // this lp token total committed - totalCommittedLpToken, ok := k.tci.TotalLpTokensCommitted[lpToken] - if !ok { - return sdk.ZeroInt(), sdk.ZeroInt() - } - - // If total committed LP token amount is zero - if totalCommittedLpToken.LTE(sdk.ZeroInt()) { - return sdk.ZeroInt(), sdk.ZeroInt() - } - - // Calculalte lp token share of the pool - lpShare := sdk.NewDecFromInt(commmittedLpToken).QuoInt(totalCommittedLpToken) - - // Calculate new Eden allocated per LP - newEdenAllocated := lpShare.Mul(newEdenAllocatedForPool).TruncateInt() - - // ------------------------------------------------------- - - // ------------------- DEX rewards calculation ------------------- - // --------------------------------------------------------------- - // Get dex rewards per pool - // Get pool Id - poolId := uint64(stabletypes.PoolId) - // Get track key - trackKey := types.GetPoolRevenueTrackKey(poolId) - // Get tracked amount for Lps per pool - dexRewardsAllocatedForPool, ok := k.tci.PoolRevenueTrack[trackKey] - if !ok { - dexRewardsAllocatedForPool = sdk.NewDec(0) - } - - // Calculate dex rewards per lp - dexRewardsForLP := lpShare.Mul(dexRewardsAllocatedForPool) - // Sum total rewards per commitment - totalDexRewardsAllocated = totalDexRewardsAllocated.Add(dexRewardsForLP) - - //---------------------------------------------------------------- - - // ------------------- Gas rewards calculation ------------------- - // --------------------------------------------------------------- - // Get gas fee rewards per pool - gasRewardsAllocatedForPool := poolShare.Mul(gasFeesForLPs) - // Calculate gas fee rewards per lp - gasRewardsForLP := lpShare.Mul(gasRewardsAllocatedForPool) - // Sum total rewards per commitment - totalDexRewardsAllocated = totalDexRewardsAllocated.Add(gasRewardsForLP) - - // return - return newEdenAllocated, totalDexRewardsAllocated.TruncateInt() -} diff --git a/x/incentive/keeper/keeper_stakers.go b/x/incentive/keeper/keeper_stakers.go deleted file mode 100644 index 5149ddb08..000000000 --- a/x/incentive/keeper/keeper_stakers.go +++ /dev/null @@ -1,77 +0,0 @@ -package keeper - -import ( - "cosmossdk.io/math" - sdk "github.com/cosmos/cosmos-sdk/types" - ctypes "github.com/elys-network/elys/x/commitment/types" - "github.com/elys-network/elys/x/incentive/types" - ptypes "github.com/elys-network/elys/x/parameter/types" -) - -// Calculate new Eden token amounts based on the given conditions and user's current unclaimed token balance -func (k Keeper) CalcRewardsForStakersByElysStaked(ctx sdk.Context, delAmount math.Int, edenAmountPerDistribution math.Int, dexRevenueAmtForStakersPerDistribution sdk.Dec) (math.Int, math.Int, sdk.Dec) { - // -----------Eden calculation --------------------- - // -------------------------------------------------------------- - stakeShare := k.CalcTotalShareOfStaking(delAmount) - - // Calculate newly creating eden amount by its share - newEdenAllocated := stakeShare.MulInt(edenAmountPerDistribution) - - // --------------------DEX rewards calculation -------------------- - // ---------------------------------------------------------------- - // Calculate dex rewards - dexRewards := stakeShare.Mul(dexRevenueAmtForStakersPerDistribution).TruncateInt() - - // Calculate only elys staking share - stakeShareByStakeOnly := k.CalcTotalShareOfStaking(delAmount) - dexRewardsByStakeOnly := stakeShareByStakeOnly.Mul(dexRevenueAmtForStakersPerDistribution) - - return newEdenAllocated.TruncateInt(), dexRewards, dexRewardsByStakeOnly -} - -// Calculate new Eden token amounts based on the given conditions and user's current unclaimed token balance -func (k Keeper) CalcRewardsForStakersByCommitted(ctx sdk.Context, amount math.Int, edenAmountPerEpoch math.Int, dexRevenueAmtForStakers sdk.Dec) (math.Int, math.Int) { - // -----------Eden calculation --------------------- - // -------------------------------------------------------------- - stakeShare := k.CalcTotalShareOfStaking(amount) - - // Calculate newly creating eden amount by its share - newEdenAllocated := stakeShare.MulInt(edenAmountPerEpoch).TruncateInt() - - // --------------------DEX rewards calculation -------------------- - // ---------------------------------------------------------------- - // Calculate dex rewards - dexRewards := stakeShare.Mul(dexRevenueAmtForStakers).TruncateInt() - - return newEdenAllocated, dexRewards -} - -// Calculate new Eden-Boost token amounts based on the given conditions and user's current unclaimed token balance -func (k Keeper) CalculateEdenBoostRewards( - ctx sdk.Context, - delAmount math.Int, - commitments ctypes.Commitments, - incentiveInfo types.IncentiveInfo, - edenBoostAPR sdk.Dec, -) (math.Int, math.Int, math.Int) { - // Get eden commitments - edenCommitted := commitments.GetCommittedAmountForDenom(ptypes.Eden) - - params := k.GetParams(ctx) - - // Calculate the portion of each program contribution - newEdenBByElysStaked := sdk.NewDecFromInt(delAmount). - Mul(edenBoostAPR). - MulInt64(params.DistributionInterval). - QuoInt(incentiveInfo.TotalBlocksPerYear). - RoundInt() - - newEdenBByEdenCommitted := sdk.NewDecFromInt(edenCommitted). - Mul(edenBoostAPR). - MulInt64(params.DistributionInterval). - QuoInt(incentiveInfo.TotalBlocksPerYear). - RoundInt() - - newEdenBoost := newEdenBByElysStaked.Add(newEdenBByEdenCommitted) - return newEdenBoost, newEdenBByElysStaked, newEdenBByEdenCommitted -} diff --git a/x/incentive/keeper/keeper_stakers_test.go b/x/incentive/keeper/keeper_stakers_test.go deleted file mode 100644 index 43e49038f..000000000 --- a/x/incentive/keeper/keeper_stakers_test.go +++ /dev/null @@ -1,103 +0,0 @@ -package keeper_test - -import ( - "testing" - - tmproto "github.com/cometbft/cometbft/proto/tendermint/types" - sdk "github.com/cosmos/cosmos-sdk/types" - simapp "github.com/elys-network/elys/app" - ctypes "github.com/elys-network/elys/x/commitment/types" - ptypes "github.com/elys-network/elys/x/parameter/types" - "github.com/stretchr/testify/require" -) - -func TestCalcRewardsForStakers(t *testing.T) { - app := simapp.InitElysTestApp(initChain) - ctx := app.BaseApp.NewContext(initChain, tmproto.Header{}) - - ik := app.IncentiveKeeper - - // Generate 2 random accounts with 10000uelys balanced - addr := simapp.AddTestAddrs(app, ctx, 2, sdk.NewInt(10000)) - - var committed sdk.Coins - var unclaimed sdk.Coins - - // Prepare unclaimed tokens - uedenToken := sdk.NewCoin(ptypes.Eden, sdk.NewInt(2000)) - uedenBToken := sdk.NewCoin(ptypes.EdenB, sdk.NewInt(2000)) - unclaimed = unclaimed.Add(uedenToken, uedenBToken) - - // Mint coins - err := app.BankKeeper.MintCoins(ctx, ctypes.ModuleName, unclaimed) - require.NoError(t, err) - err = app.BankKeeper.SendCoinsFromModuleToAccount(ctx, ctypes.ModuleName, addr[0], unclaimed) - require.NoError(t, err) - - err = app.BankKeeper.MintCoins(ctx, ctypes.ModuleName, unclaimed) - require.NoError(t, err) - err = app.BankKeeper.SendCoinsFromModuleToAccount(ctx, ctypes.ModuleName, addr[1], unclaimed) - require.NoError(t, err) - - // Prepare committed tokens - uedenToken = sdk.NewCoin(ptypes.Eden, sdk.NewInt(1500)) - uedenBToken = sdk.NewCoin(ptypes.EdenB, sdk.NewInt(500)) - committed = committed.Add(uedenToken, uedenBToken) - - // Mint coins - err = app.BankKeeper.MintCoins(ctx, ctypes.ModuleName, committed) - require.NoError(t, err) - err = app.BankKeeper.SendCoinsFromModuleToAccount(ctx, ctypes.ModuleName, addr[0], committed) - require.NoError(t, err) - - err = app.BankKeeper.MintCoins(ctx, ctypes.ModuleName, committed) - require.NoError(t, err) - err = app.BankKeeper.SendCoinsFromModuleToAccount(ctx, ctypes.ModuleName, addr[1], committed) - require.NoError(t, err) - - // Add testing commitment - simapp.AddTestCommitment(app, ctx, addr[0], committed, unclaimed) - simapp.AddTestCommitment(app, ctx, addr[1], committed, unclaimed) - - commitment := app.CommitmentKeeper.GetCommitments(ctx, addr[0].String()) - - require.Equal(t, commitment.RewardsUnclaimed[0].Denom, ptypes.Eden) - require.Equal(t, commitment.RewardsUnclaimed[0].Amount, sdk.NewInt(2000)) - - require.Equal(t, commitment.RewardsUnclaimed[1].Denom, ptypes.EdenB) - require.Equal(t, commitment.RewardsUnclaimed[1].Amount, sdk.NewInt(2000)) - - require.Equal(t, commitment.CommittedTokens[0].Denom, ptypes.Eden) - require.Equal(t, commitment.CommittedTokens[0].Amount, sdk.NewInt(1500)) - - require.Equal(t, commitment.CommittedTokens[1].Denom, ptypes.EdenB) - require.Equal(t, commitment.CommittedTokens[1].Amount, sdk.NewInt(500)) - - // Recalculate total committed info - ik.UpdateTotalCommitmentInfo(ctx, ptypes.BaseCurrency) - - totalEdenGiven := sdk.ZeroInt() - totalRewardsGiven := sdk.ZeroInt() - - dexRevenueStakersAmt := sdk.NewDec(100000) - edenAmountPerEpochStakers := sdk.NewInt(100000) - // Calculate delegated amount per delegator - delAmount := sdk.NewInt(1000) - // Calculate new unclaimed Eden tokens from Elys staked Eden & Eden boost committed, Dex rewards distribution - newUnclaimedEdenTokens, dexRewards, _ := ik.CalcRewardsForStakersByElysStaked(ctx, delAmount, edenAmountPerEpochStakers, dexRevenueStakersAmt) - totalEdenGiven = totalEdenGiven.Add(newUnclaimedEdenTokens) - totalRewardsGiven = totalRewardsGiven.Add(dexRewards) - - // Calculate new unclaimed Eden tokens from Eden committed, Dex rewards distribution - newUnclaimedEdenTokens, dexRewards = ik.CalcRewardsForStakersByCommitted(ctx, delAmount, edenAmountPerEpochStakers, dexRevenueStakersAmt) - totalEdenGiven = totalEdenGiven.Add(newUnclaimedEdenTokens) - totalRewardsGiven = totalRewardsGiven.Add(dexRewards) - - // Calculate new unclaimed Eden tokens from Eden boost committed, Dex rewards distribution - newUnclaimedEdenTokens, dexRewards = ik.CalcRewardsForStakersByCommitted(ctx, delAmount, edenAmountPerEpochStakers, dexRevenueStakersAmt) - totalEdenGiven = totalEdenGiven.Add(newUnclaimedEdenTokens) - totalRewardsGiven = totalRewardsGiven.Add(dexRewards) - - require.Equal(t, totalEdenGiven, sdk.NewInt(297)) - require.Equal(t, totalRewardsGiven, sdk.NewInt(297)) -} diff --git a/x/incentive/keeper/keeper_test.go b/x/incentive/keeper/keeper_test.go index f9a979495..2dc45da42 100644 --- a/x/incentive/keeper/keeper_test.go +++ b/x/incentive/keeper/keeper_test.go @@ -3,12 +3,15 @@ package keeper_test import ( "github.com/stretchr/testify/suite" + "github.com/cometbft/cometbft/crypto/ed25519" tmproto "github.com/cometbft/cometbft/proto/tendermint/types" - "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" + oraclekeeper "github.com/elys-network/elys/x/oracle/keeper" + oracletypes "github.com/elys-network/elys/x/oracle/types" simapp "github.com/elys-network/elys/app" + ptypes "github.com/elys-network/elys/x/parameter/types" ) const ( @@ -30,3 +33,57 @@ func (suite *KeeperTestSuite) SetupTest() { suite.ctx = app.BaseApp.NewContext(initChain, tmproto.Header{}) suite.app = app } + +func SetupStableCoinPrices(ctx sdk.Context, oracle oraclekeeper.Keeper) { + // prices set for USDT and USDC + provider := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address()) + oracle.SetAssetInfo(ctx, oracletypes.AssetInfo{ + Denom: ptypes.BaseCurrency, + Display: "USDC", + Decimal: 6, + }) + oracle.SetAssetInfo(ctx, oracletypes.AssetInfo{ + Denom: "uusdt", + Display: "USDT", + Decimal: 6, + }) + oracle.SetAssetInfo(ctx, oracletypes.AssetInfo{ + Denom: ptypes.Elys, + Display: "ELYS", + Decimal: 6, + }) + oracle.SetAssetInfo(ctx, oracletypes.AssetInfo{ + Denom: ptypes.ATOM, + Display: "ATOM", + Decimal: 6, + }) + + oracle.SetPrice(ctx, oracletypes.Price{ + Asset: "USDC", + Price: sdk.NewDec(1000000), + Source: "elys", + Provider: provider.String(), + Timestamp: uint64(ctx.BlockTime().Unix()), + }) + oracle.SetPrice(ctx, oracletypes.Price{ + Asset: "USDT", + Price: sdk.NewDec(1000000), + Source: "elys", + Provider: provider.String(), + Timestamp: uint64(ctx.BlockTime().Unix()), + }) + oracle.SetPrice(ctx, oracletypes.Price{ + Asset: "ELYS", + Price: sdk.NewDec(100), + Source: "elys", + Provider: provider.String(), + Timestamp: uint64(ctx.BlockTime().Unix()), + }) + oracle.SetPrice(ctx, oracletypes.Price{ + Asset: "ATOM", + Price: sdk.NewDec(100), + Source: "atom", + Provider: provider.String(), + Timestamp: uint64(ctx.BlockTime().Unix()), + }) +} diff --git a/x/incentive/keeper/keeper_withdraw.go b/x/incentive/keeper/keeper_withdraw.go deleted file mode 100644 index 980f8f98c..000000000 --- a/x/incentive/keeper/keeper_withdraw.go +++ /dev/null @@ -1,257 +0,0 @@ -package keeper - -import ( - errorsmod "cosmossdk.io/errors" - "cosmossdk.io/math" - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/cosmos/cosmos-sdk/x/distribution/types" - stypes "github.com/cosmos/cosmos-sdk/x/staking/types" - assetprofiletypes "github.com/elys-network/elys/x/assetprofile/types" - commitmenttypes "github.com/elys-network/elys/x/commitment/types" - ptypes "github.com/elys-network/elys/x/parameter/types" -) - -// Increase unclaimed token amount for the corresponding validator -func (k Keeper) UpdateTokensForValidator(ctx sdk.Context, validator string, newUnclaimedEdenTokens math.Int, dexRewards sdk.Dec, baseCurrency string) { - commitments := k.cmk.GetCommitments(ctx, validator) - - // Update Eden amount - commitments.AddRewardsUnclaimed(sdk.NewCoin(ptypes.Eden, newUnclaimedEdenTokens)) - - // Update USDC amount - commitments.AddRewardsUnclaimed(sdk.NewCoin(baseCurrency, dexRewards.TruncateInt())) - - // Update commmitment - k.cmk.SetCommitments(ctx, commitments) -} - -// Give commissions to validators -func (k Keeper) GiveCommissionToValidators(ctx sdk.Context, delegator string, totalDelegationAmt math.Int, newUnclaimedAmt math.Int, dexRewards sdk.Dec, baseCurrency string) (math.Int, math.Int) { - delAddr, err := sdk.AccAddressFromBech32(delegator) - if err != nil { - return sdk.ZeroInt(), sdk.ZeroInt() - } - - // If there is no delegation, (not elys staker) - if totalDelegationAmt.LTE(sdk.ZeroInt()) { - return sdk.ZeroInt(), sdk.ZeroInt() - } - - // Total Eden given - totalEdenGiven := sdk.ZeroInt() - totalDexRewardsGiven := sdk.ZeroInt() - - // Iterate all delegated validators - k.stk.IterateDelegations(ctx, delAddr, func(index int64, del stypes.DelegationI) (stop bool) { - valAddr := del.GetValidatorAddr() - // Get validator - val := k.stk.Validator(ctx, valAddr) - if !val.IsBonded() { - return - } - - // Get commission rate - commRate := val.GetCommission() - // Get delegator share - shares := del.GetShares() - // Get token amount delegated - delAmount := val.TokensFromSharesTruncated(shares) - - //----------------------------- - // Eden commission - //----------------------------- - // to give = delegated amount / total delegation * newly minted eden * commission rate - edenCommission := delAmount.QuoInt(totalDelegationAmt).MulInt(newUnclaimedAmt).Mul(commRate) - - // Sum total commission given - totalEdenGiven = totalEdenGiven.Add(edenCommission.TruncateInt()) - //----------------------------- - - //----------------------------- - // Dex rewards commission - //----------------------------- - // to give = delegated amount / total delegation * newly minted eden * commission rate - dexRewardsCommission := delAmount.QuoInt(totalDelegationAmt).Mul(dexRewards).Mul(commRate) - // Sum total commission given - totalDexRewardsGiven = totalDexRewardsGiven.Add(dexRewardsCommission.TruncateInt()) - //----------------------------- - - // increase uncomitted token amount of validator's commitment - k.UpdateTokensForValidator(ctx, valAddr.String(), edenCommission.TruncateInt(), dexRewardsCommission, baseCurrency) - - return false - }) - - return totalEdenGiven, totalDexRewardsGiven -} - -// Deduct rewards per program per denom -func (k Keeper) CalcAmountSubbucketsPerProgram(ctx sdk.Context, delegator string, denom string, withdrawType commitmenttypes.EarnType, commitments commitmenttypes.Commitments) math.Int { - unclaimed := sdk.ZeroInt() - switch withdrawType { - case commitmenttypes.EarnType_ELYS_PROGRAM: - unclaimed = commitments.GetElysSubBucketRewardUnclaimedForDenom(denom) - case commitmenttypes.EarnType_EDEN_PROGRAM: - unclaimed = commitments.GetEdenSubBucketRewardUnclaimedForDenom(denom) - case commitmenttypes.EarnType_EDENB_PROGRAM: - unclaimed = commitments.GetEdenBSubBucketRewardUnclaimedForDenom(denom) - case commitmenttypes.EarnType_USDC_PROGRAM: - unclaimed = commitments.GetUsdcSubBucketRewardUnclaimedForDenom(denom) - case commitmenttypes.EarnType_LP_MINING_PROGRAM: - unclaimed = commitments.GetLPMiningSubBucketRewardUnclaimedForDenom(denom) - case commitmenttypes.EarnType_ALL_PROGRAM: - unclaimed = commitments.GetRewardUnclaimedForDenom(denom) - } - - return unclaimed -} - -// withdraw rewards -// Eden, EdenBoost and Elys to USDC -func (k Keeper) ProcessWithdrawRewards(ctx sdk.Context, delegator string, withdrawType commitmenttypes.EarnType) error { - _, err := sdk.AccAddressFromBech32(delegator) - if err != nil { - return err - } - - // Get commitments - commitments := k.cmk.GetCommitments(ctx, delegator) - - // Claim Eden - // --------------------------------------------------- - unclaimed := k.CalcAmountSubbucketsPerProgram(ctx, delegator, ptypes.Eden, withdrawType, commitments) - if !unclaimed.IsZero() { - err = k.cmk.RecordClaimReward(ctx, delegator, ptypes.Eden, unclaimed, withdrawType) - if err != nil { - return err - } - } - - // Claim EdenB - // --------------------------------------------------- - unclaimed = k.CalcAmountSubbucketsPerProgram(ctx, delegator, ptypes.EdenB, withdrawType, commitments) - if !unclaimed.IsZero() { - err = k.cmk.RecordClaimReward(ctx, delegator, ptypes.EdenB, unclaimed, withdrawType) - if err != nil { - return err - } - } - - // Claim USDC - // --------------------------------------------------- - entry, found := k.assetProfileKeeper.GetEntry(ctx, ptypes.BaseCurrency) - if !found { - return errorsmod.Wrapf(assetprofiletypes.ErrAssetProfileNotFound, "asset %s not found", ptypes.BaseCurrency) - } - baseCurrency := entry.Denom - - // Get available usdc amount can be withdraw - unclaimedUsdc := k.CalcAmountSubbucketsPerProgram(ctx, delegator, baseCurrency, withdrawType, commitments) - if unclaimedUsdc.IsZero() { - return nil - } - // Get dex revenue wallet - revenueCollector := k.authKeeper.GetModuleAccount(ctx, k.dexRevCollectorName) - - // Revenue wallet usdc balance - usdcBalance := k.bankKeeper.GetBalance(ctx, revenueCollector.GetAddress(), baseCurrency) - - // Balance check - if unclaimedUsdc.GT(usdcBalance.Amount) { - return errorsmod.Wrapf(types.ErrIntOverflowTx, "Amount excceed: %d", unclaimedUsdc) - } - - // All dex rewards are only paid in USDC - // This function call will deduct the accounting in commitment module only. - err = k.cmk.RecordClaimReward(ctx, delegator, ptypes.BaseCurrency, unclaimedUsdc, withdrawType) - if err != nil { - return errorsmod.Wrapf(types.ErrIntOverflowTx, "Internal error with amount: %d", unclaimedUsdc) - } - - // Get Bech32 address for creator - addr, err := sdk.AccAddressFromBech32(commitments.Creator) - if err != nil { - return errorsmod.Wrap(sdkerrors.ErrInvalidAddress, "unable to convert address from bech32") - } - - // Set withdraw usdc amount - revenue := sdk.NewCoin(baseCurrency, unclaimedUsdc) - // Transfer revenue from a single wallet of DEX revenue wallet to user. - return k.bankKeeper.SendCoinsFromModuleToAccount(ctx, k.dexRevCollectorName, addr, sdk.NewCoins(revenue)) -} - -// Update commitments for validator commission -// Eden, EdenBoost and USDC -func (k Keeper) RecordWithdrawValidatorCommission(ctx sdk.Context, delegator string, validator string) error { - _, err := sdk.AccAddressFromBech32(delegator) - if err != nil { - return err - } - - // Check validator address - _, err = sdk.ValAddressFromBech32(validator) - if err != nil { - return err - } - - // Get commitments - commitments := k.cmk.GetCommitments(ctx, validator) - - // Eden - unclaimed := commitments.GetRewardUnclaimedForDenom(ptypes.Eden) - if !unclaimed.IsZero() { - err = k.cmk.RecordWithdrawValidatorCommission(ctx, delegator, validator, ptypes.Eden, unclaimed) - if err != nil { - return err - } - } - - // EdenB - unclaimed = commitments.GetRewardUnclaimedForDenom(ptypes.EdenB) - if !unclaimed.IsZero() { - err = k.cmk.RecordWithdrawValidatorCommission(ctx, delegator, validator, ptypes.EdenB, unclaimed) - if err != nil { - return err - } - } - - entry, found := k.assetProfileKeeper.GetEntry(ctx, ptypes.BaseCurrency) - if !found { - return errorsmod.Wrapf(assetprofiletypes.ErrAssetProfileNotFound, "asset %s not found", ptypes.BaseCurrency) - } - baseCurrency := entry.Denom - - // USDC - unclaimedUsdc := commitments.GetRewardUnclaimedForDenom(baseCurrency) - if unclaimedUsdc.IsZero() { - return nil - } - // Get dex revenue wallet - revenueCollector := k.authKeeper.GetModuleAccount(ctx, k.dexRevCollectorName) - - // Revenue wallet usdc balance - usdcBalance := k.bankKeeper.GetBalance(ctx, revenueCollector.GetAddress(), baseCurrency) - - // Balance check - if unclaimedUsdc.GT(usdcBalance.Amount) { - return errorsmod.Wrapf(types.ErrIntOverflowTx, "Amount excceed: %d", unclaimedUsdc) - } - - // This function call will deduct the accounting in commitment module only. - err = k.cmk.RecordClaimReward(ctx, validator, baseCurrency, unclaimedUsdc, commitmenttypes.EarnType_ALL_PROGRAM) - if err != nil { - return err - } - - // Get Bech32 address for delegator - addr, err := sdk.AccAddressFromBech32(delegator) - if err != nil { - return errorsmod.Wrap(sdkerrors.ErrInvalidAddress, "unable to convert address from bech32") - } - - // Set withdraw usdc amount - revenue := sdk.NewCoin(baseCurrency, unclaimedUsdc) - // Transfer revenue from a single wallet of DEX revenue wallet to user's wallet. - return k.bankKeeper.SendCoinsFromModuleToAccount(ctx, k.dexRevCollectorName, addr, sdk.NewCoins(revenue)) -} diff --git a/x/incentive/keeper/keeper_withdraw_test.go b/x/incentive/keeper/keeper_withdraw_test.go deleted file mode 100644 index 5b53d6578..000000000 --- a/x/incentive/keeper/keeper_withdraw_test.go +++ /dev/null @@ -1,164 +0,0 @@ -package keeper_test - -import ( - "math" - "strings" - "testing" - - tmproto "github.com/cometbft/cometbft/proto/tendermint/types" - sdk "github.com/cosmos/cosmos-sdk/types" - simapp "github.com/elys-network/elys/app" - aptypes "github.com/elys-network/elys/x/assetprofile/types" - ctypes "github.com/elys-network/elys/x/commitment/types" - ptypes "github.com/elys-network/elys/x/parameter/types" - "github.com/stretchr/testify/require" -) - -// Test scenario -// We have one validator and delegator. -// In this testing, total delegation amount equals to the genesis delegator delegation amount. -// So the whole Eden amount will be for the genesis delegator -// And we apply the commission rate of the validator and calculate his commission amount -func TestGiveCommissionToValidators(t *testing.T) { - app, genAccount, _ := simapp.InitElysTestAppWithGenAccount() - ctx := app.BaseApp.NewContext(initChain, tmproto.Header{}) - - ik := app.IncentiveKeeper - - delegator := genAccount.String() - // Calculate delegated amount per delegator - delAmount := ik.CalcDelegationAmount(ctx, delegator) - newUnclaimedEdenTokens := sdk.NewInt(10000) - dexRewardsByStakers := sdk.NewDec(1000) - // Give commission to validators ( Eden from stakers and Dex rewards from stakers. ) - edenCommissionGiven, dexRewardsCommissionGiven := ik.GiveCommissionToValidators(ctx, delegator, delAmount, newUnclaimedEdenTokens, dexRewardsByStakers, ptypes.BaseCurrency) - - require.Equal(t, edenCommissionGiven, sdk.NewInt(500)) - require.Equal(t, dexRewardsCommissionGiven, sdk.NewInt(50)) -} - -func TestProcessWithdrawRewards(t *testing.T) { - app := simapp.InitElysTestApp(initChain) - ctx := app.BaseApp.NewContext(initChain, tmproto.Header{}) - - ik := app.IncentiveKeeper - - // Generate 2 random accounts with 10000uelys balanced - addr := simapp.AddTestAddrs(app, ctx, 2, sdk.NewInt(10000)) - - var committed sdk.Coins - var unclaimed sdk.Coins - - // Prepare unclaimed tokens - uedenToken := sdk.NewCoin(ptypes.Eden, sdk.NewInt(2000)) - uedenBToken := sdk.NewCoin(ptypes.EdenB, sdk.NewInt(2000)) - lpToken := sdk.NewCoin("lp-elys-usdc", sdk.NewInt(500)) - usdcToken := sdk.NewCoin(ptypes.BaseCurrency, sdk.NewInt(500)) - unclaimed = unclaimed.Add(lpToken, uedenToken, uedenBToken, usdcToken) - - // Set assetprofile entry for denom - app.AssetprofileKeeper.SetEntry(ctx, aptypes.Entry{BaseDenom: ptypes.BaseCurrency, CommitEnabled: false, WithdrawEnabled: true, Denom: ptypes.BaseCurrency}) - app.AssetprofileKeeper.SetEntry(ctx, aptypes.Entry{BaseDenom: ptypes.Eden, CommitEnabled: true, WithdrawEnabled: true, Denom: ptypes.Eden}) - app.AssetprofileKeeper.SetEntry(ctx, aptypes.Entry{BaseDenom: ptypes.EdenB, CommitEnabled: true, WithdrawEnabled: true, Denom: ptypes.EdenB}) - app.AssetprofileKeeper.SetEntry(ctx, aptypes.Entry{BaseDenom: "lp-elys-usdc", CommitEnabled: true, WithdrawEnabled: false, Denom: "lp-elys-usdc"}) - - // Prepare committed tokens - uedenTokenC := sdk.NewCoin(ptypes.Eden, sdk.NewInt(1500)) - uedenBTokenC := sdk.NewCoin(ptypes.EdenB, sdk.NewInt(500)) - committed = committed.Add(uedenTokenC, uedenBTokenC) - - // Add testing commitment - simapp.AddTestCommitment(app, ctx, addr[0], committed, unclaimed) - simapp.AddTestCommitment(app, ctx, addr[1], committed, unclaimed) - commitments := app.CommitmentKeeper.GetCommitments(ctx, addr[0].String()) - require.False(t, commitments.IsEmpty()) - - commitments = app.CommitmentKeeper.GetCommitments(ctx, addr[1].String()) - require.False(t, commitments.IsEmpty()) - - // Get dex revenue wallet - dexRewardUSDC := sdk.NewCoins(sdk.NewCoin(ptypes.BaseCurrency, sdk.NewInt(5000))) - - // Mint 5000 usdc - err := app.BankKeeper.MintCoins(ctx, ctypes.ModuleName, dexRewardUSDC) - require.NoError(t, err) - - // Transfer 5000 USDC to dex revenue wallet - err = app.BankKeeper.SendCoinsFromModuleToModule(ctx, ctypes.ModuleName, simapp.DexRevenueCollectorName, dexRewardUSDC) - require.NoError(t, err) - - // Withdraw rewards - err = ik.ProcessWithdrawRewards(ctx, addr[0].String(), ctypes.EarnType_ALL_PROGRAM) - require.NoError(t, err) - - commitments = app.CommitmentKeeper.GetCommitments(ctx, addr[0].String()) - require.Equal(t, commitments.Claimed.AmountOf(ptypes.Eden), uedenToken.Amount) - require.Equal(t, commitments.Claimed.AmountOf(ptypes.EdenB), uedenBToken.Amount) - - usdcCoin := app.BankKeeper.GetBalance(ctx, addr[0], ptypes.BaseCurrency) - require.Equal(t, usdcCoin, usdcToken) -} - -func TestRecordWithdrawValidatorCommission(t *testing.T) { - app, genAccount, valAddress := simapp.InitElysTestAppWithGenAccount() - ctx := app.BaseApp.NewContext(initChain, tmproto.Header{}) - - ik := app.IncentiveKeeper - - // Get dex revenue wallet - dexRewardUSDC := sdk.NewCoins(sdk.NewCoin(ptypes.BaseCurrency, sdk.NewInt(5000))) - - // Mint 5000 usdc - err := app.BankKeeper.MintCoins(ctx, ctypes.ModuleName, dexRewardUSDC) - require.NoError(t, err) - - // Transfer 5000 USDC to dex revenue wallet - err = app.BankKeeper.SendCoinsFromModuleToModule(ctx, ctypes.ModuleName, simapp.DexRevenueCollectorName, dexRewardUSDC) - require.NoError(t, err) - - delegator := genAccount.String() - // Calculate delegated amount per delegator - delAmount := ik.CalcDelegationAmount(ctx, delegator) - newUnclaimedEdenTokens := sdk.NewInt(10000) - dexRewardsByStakers := sdk.NewDec(1000) - - // Create an entity in commitment module for validator - app.CommitmentKeeper.BeforeDelegationCreated(ctx, delegator, valAddress.String()) - - // Set assetprofile entry for denom - app.AssetprofileKeeper.SetEntry(ctx, aptypes.Entry{BaseDenom: ptypes.BaseCurrency, Denom: ptypes.BaseCurrency, CommitEnabled: false, WithdrawEnabled: true}) - app.AssetprofileKeeper.SetEntry(ctx, aptypes.Entry{BaseDenom: ptypes.Eden, Denom: ptypes.Eden, CommitEnabled: true, WithdrawEnabled: true}) - app.AssetprofileKeeper.SetEntry(ctx, aptypes.Entry{BaseDenom: ptypes.EdenB, Denom: ptypes.EdenB, CommitEnabled: true, WithdrawEnabled: true}) - - // Give commission to validators ( Eden from stakers and Dex rewards from stakers. ) - edenCommissionGiven, dexRewardsCommissionGiven := ik.GiveCommissionToValidators(ctx, delegator, delAmount, newUnclaimedEdenTokens, dexRewardsByStakers, ptypes.BaseCurrency) - - commitments := app.CommitmentKeeper.GetCommitments(ctx, valAddress.String()) - - require.Equal(t, edenCommissionGiven, sdk.NewInt(500)) - require.Equal(t, dexRewardsCommissionGiven, sdk.NewInt(50)) - - delAddr, err := sdk.AccAddressFromBech32(delegator) - require.NoError(t, err) - - found := false - // Get all delegations - delegations := app.StakingKeeper.GetDelegatorDelegations(ctx, delAddr, math.MaxUint16) - for _, del := range delegations { - // Get validator address - valAddr := del.GetValidatorAddr() - - // If it is not requested by the validator creator - if strings.EqualFold(valAddress.String(), valAddr.String()) { - found = true - break - } - } - - require.True(t, found) - err = ik.RecordWithdrawValidatorCommission(ctx, delegator, valAddress.String()) - require.NoError(t, err) - - commitments = app.CommitmentKeeper.GetCommitments(ctx, delegator) - require.Equal(t, commitments.Claimed.String(), sdk.NewCoin(ptypes.Eden, edenCommissionGiven).String()) -} diff --git a/x/incentive/keeper/msg_server.go b/x/incentive/keeper/msg_server.go index acf622e12..59b348158 100644 --- a/x/incentive/keeper/msg_server.go +++ b/x/incentive/keeper/msg_server.go @@ -1,11 +1,6 @@ package keeper import ( - "context" - "math" - "strings" - - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/elys-network/elys/x/incentive/types" ) @@ -20,78 +15,3 @@ func NewMsgServerImpl(keeper Keeper) types.MsgServer { } var _ types.MsgServer = msgServer{} - -func (k msgServer) WithdrawRewards(goCtx context.Context, msg *types.MsgWithdrawRewards) (*types.MsgWithdrawRewardsResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - - _, err := sdk.AccAddressFromBech32(msg.DelegatorAddress) - if err != nil { - return nil, err - } - - // Withdraw rewards - err = k.ProcessWithdrawRewards(ctx, msg.DelegatorAddress, msg.WithdrawType) - if err != nil { - return nil, err - } - - ctx.EventManager().EmitEvent( - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - sdk.NewAttribute(sdk.AttributeKeySender, msg.DelegatorAddress), - ), - ) - return &types.MsgWithdrawRewardsResponse{}, nil -} - -func (k msgServer) WithdrawValidatorCommission(goCtx context.Context, msg *types.MsgWithdrawValidatorCommission) (*types.MsgWithdrawValidatorCommissionResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - - validatorAddr, err := sdk.ValAddressFromBech32(msg.ValidatorAddress) - if err != nil { - return nil, err - } - - delegator, err := sdk.AccAddressFromBech32(msg.DelegatorAddress) - if err != nil { - return nil, err - } - - found := false - // Get all delegations - delegations := k.stk.GetDelegatorDelegations(ctx, delegator, math.MaxUint16) - for _, del := range delegations { - // Get validator address - valAddr := del.GetValidatorAddr() - - // If it is not requested by the validator creator - if strings.EqualFold(validatorAddr.String(), valAddr.String()) { - found = true - break - } - } - - // Couldn't find the validator of the delegator. - if !found { - return &types.MsgWithdrawValidatorCommissionResponse{}, err - } - - // Withdraw validator commission - // Validator will receive commissions from Elys staking only, so the program type is only Rewards_Elys_Program - // And don't need to input program type - err = k.RecordWithdrawValidatorCommission(ctx, msg.DelegatorAddress, msg.ValidatorAddress) - if err != nil { - return &types.MsgWithdrawValidatorCommissionResponse{}, err - } - - ctx.EventManager().EmitEvent( - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - sdk.NewAttribute(sdk.AttributeKeySender, msg.ValidatorAddress), - ), - ) - - return &types.MsgWithdrawValidatorCommissionResponse{}, nil -} diff --git a/x/incentive/keeper/msg_server_update_incentive_params.go b/x/incentive/keeper/msg_server_update_incentive_params.go deleted file mode 100644 index 1f661441f..000000000 --- a/x/incentive/keeper/msg_server_update_incentive_params.go +++ /dev/null @@ -1,29 +0,0 @@ -package keeper - -import ( - "context" - - errorsmod "cosmossdk.io/errors" - sdk "github.com/cosmos/cosmos-sdk/types" - govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" - "github.com/elys-network/elys/x/incentive/types" -) - -func (k msgServer) UpdateIncentiveParams(goCtx context.Context, msg *types.MsgUpdateIncentiveParams) (*types.MsgUpdateIncentiveParamsResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - - if k.authority != msg.Authority { - return nil, errorsmod.Wrapf(govtypes.ErrInvalidSigner, "invalid authority; expected %s, got %s", k.authority, msg.Authority) - } - - params := k.GetParams(ctx) - params.RewardPortionForLps = msg.RewardPortionForLps - params.ElysStakeSnapInterval = msg.ElysStakeSnapInterval - params.MaxEdenRewardAprLps = msg.MaxEdenRewardAprLps - params.MaxEdenRewardAprStakers = msg.MaxEdenRewardAprStakers - params.DistributionInterval = msg.DistributionInterval - - k.SetParams(ctx, params) - - return &types.MsgUpdateIncentiveParamsResponse{}, nil -} diff --git a/x/incentive/keeper/msg_server_update_pool_multipliers.go b/x/incentive/keeper/msg_server_update_pool_multipliers.go deleted file mode 100644 index a90e7f3ce..000000000 --- a/x/incentive/keeper/msg_server_update_pool_multipliers.go +++ /dev/null @@ -1,22 +0,0 @@ -package keeper - -import ( - "context" - - errorsmod "cosmossdk.io/errors" - sdk "github.com/cosmos/cosmos-sdk/types" - govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" - "github.com/elys-network/elys/x/incentive/types" -) - -func (k msgServer) UpdatePoolMultipliers(goCtx context.Context, msg *types.MsgUpdatePoolMultipliers) (*types.MsgUpdatePoolMultipliersResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - - if k.authority != msg.Authority { - return nil, errorsmod.Wrapf(govtypes.ErrInvalidSigner, "invalid authority; expected %s, got %s", k.authority, msg.Authority) - } - - k.Keeper.UpdatePoolMultipliers(ctx, msg.PoolMultipliers) - - return &types.MsgUpdatePoolMultipliersResponse{}, nil -} diff --git a/x/incentive/keeper/params.go b/x/incentive/keeper/params.go index 874a589fe..1ef46c079 100644 --- a/x/incentive/keeper/params.go +++ b/x/incentive/keeper/params.go @@ -1,13 +1,8 @@ package keeper import ( - "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" - ammtypes "github.com/elys-network/elys/x/amm/types" - ctypes "github.com/elys-network/elys/x/commitment/types" "github.com/elys-network/elys/x/incentive/types" - ptypes "github.com/elys-network/elys/x/parameter/types" - stabletypes "github.com/elys-network/elys/x/stablestake/types" ) // GetParams get all parameters as types.Params @@ -29,194 +24,3 @@ func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { b := k.cdc.MustMarshal(¶ms) store.Set([]byte(types.ParamsKey), b) } - -// GetDEXRewardPortionForLPs returns the dex revenue percent for Lps -func (k Keeper) GetDEXRewardPortionForLPs(ctx sdk.Context) (percent sdk.Dec) { - return k.GetParams(ctx).RewardPortionForLps -} - -// GetDEXRewardPortionForStakers returns the dex revenue percent for Stakers -func (k Keeper) GetDEXRewardPortionForStakers(ctx sdk.Context) (percent sdk.Dec) { - return k.GetParams(ctx).RewardPortionForStakers -} - -// GetPoolInfo -func (k Keeper) GetPoolInfo(ctx sdk.Context, poolId uint64) (types.PoolInfo, bool) { - // Fetch incentive params - params := k.GetParams(ctx) - - poolInfos := params.PoolInfos - for _, ps := range poolInfos { - if ps.PoolId == poolId { - return ps, true - } - } - - return types.PoolInfo{}, false -} - -// SetPoolInfo -func (k Keeper) SetPoolInfo(ctx sdk.Context, poolId uint64, poolInfo types.PoolInfo) bool { - // Fetch incentive params - params := k.GetParams(ctx) - - poolInfos := params.PoolInfos - for i, ps := range poolInfos { - if ps.PoolId == poolId { - params.PoolInfos[i] = poolInfo - k.SetParams(ctx, params) - - return true - } - } - - return false -} - -// InitPoolParams: creates a poolInfo at the time of pool creation. -func (k Keeper) InitPoolParams(ctx sdk.Context, poolId uint64) bool { - // Fetch incentive params - params := k.GetParams(ctx) - poolInfos := params.PoolInfos - - for _, ps := range poolInfos { - if ps.PoolId == poolId { - return true - } - } - - // Initiate a new pool info - poolInfo := types.PoolInfo{ - // reward amount - PoolId: poolId, - // reward wallet address - RewardWallet: ammtypes.NewPoolRevenueAddress(poolId).String(), - // multiplier for lp rewards - Multiplier: sdk.NewDec(1), - // Number of blocks since creation - NumBlocks: sdk.NewInt(1), - // Total dex rewards given since creation - DexRewardAmountGiven: sdk.ZeroDec(), - // Total eden rewards given since creation - EdenRewardAmountGiven: sdk.ZeroInt(), - } - - // Update pool information - params.PoolInfos = append(params.PoolInfos, poolInfo) - k.SetParams(ctx, params) - - return true -} - -// InitStableStakePoolMultiplier: create a stable stake pool information responding to the pool creation. -func (k Keeper) InitStableStakePoolParams(ctx sdk.Context, poolId uint64) bool { - // Fetch incentive params - params := k.GetParams(ctx) - poolInfos := params.PoolInfos - - for _, ps := range poolInfos { - if ps.PoolId == poolId { - return true - } - } - - // Initiate a new pool info - poolInfo := types.PoolInfo{ - // reward amount - PoolId: poolId, - // reward wallet address - RewardWallet: stabletypes.PoolAddress().String(), - // multiplier for lp rewards - Multiplier: sdk.NewDec(1), - // Number of blocks since creation - NumBlocks: sdk.NewInt(1), - // Total dex rewards given since creation - DexRewardAmountGiven: sdk.ZeroDec(), - // Total eden rewards given since creation - EdenRewardAmountGiven: sdk.ZeroInt(), - } - - // Update pool information - params.PoolInfos = append(params.PoolInfos, poolInfo) - k.SetParams(ctx, params) - - return true -} - -// UpdatePoolMultipliers updates pool multipliers through gov proposal -func (k Keeper) UpdatePoolMultipliers(ctx sdk.Context, poolMultipliers []types.PoolMultiplier) bool { - if len(poolMultipliers) < 1 { - return false - } - - // Fetch incentive params - params := k.GetParams(ctx) - - // Update pool multiplier - for _, pm := range poolMultipliers { - for i, p := range params.PoolInfos { - // If we found matching poolId - if p.PoolId == pm.PoolId { - params.PoolInfos[i].Multiplier = pm.Multiplier - } - } - } - - // Update parameter - k.SetParams(ctx, params) - - return true -} - -// Update total commitment info -func (k Keeper) UpdateTotalCommitmentInfo(ctx sdk.Context, baseCurrency string) { - // Fetch total staked Elys amount again - k.tci.TotalElysBonded = k.stk.TotalBondedTokens(ctx) - // Initialize with amount zero - k.tci.TotalEdenEdenBoostCommitted = sdk.ZeroInt() - // Initialize with amount zero - k.tci.TotalFeesCollected = sdk.Coins{} - // Initialize Lp tokens amount - k.tci.TotalLpTokensCommitted = make(map[string]math.Int) - // Reinitialize Pool revenue tracker - k.tci.PoolRevenueTrack = make(map[string]sdk.Dec) - - // Collect gas fees collected - fees := k.CollectGasFeesToIncentiveModule(ctx, baseCurrency) - - // Calculate total fees - Gas fees collected - k.tci.TotalFeesCollected = k.tci.TotalFeesCollected.Add(fees...) - - // Iterate to calculate total Eden, Eden boost and Lp tokens committed - k.cmk.IterateCommitments(ctx, func(commitments ctypes.Commitments) bool { - committedEdenToken := commitments.GetCommittedAmountForDenom(ptypes.Eden) - committedEdenBoostToken := commitments.GetCommittedAmountForDenom(ptypes.EdenB) - - k.tci.TotalEdenEdenBoostCommitted = k.tci.TotalEdenEdenBoostCommitted.Add(committedEdenToken).Add(committedEdenBoostToken) - - // Iterate to calculate total Lp tokens committed - k.amm.IterateLiquidityPools(ctx, func(p ammtypes.Pool) bool { - lpToken := ammtypes.GetPoolShareDenom(p.GetPoolId()) - - committedLpToken := commitments.GetCommittedAmountForDenom(lpToken) - amt, ok := k.tci.TotalLpTokensCommitted[lpToken] - if !ok { - k.tci.TotalLpTokensCommitted[lpToken] = committedLpToken - } else { - k.tci.TotalLpTokensCommitted[lpToken] = amt.Add(committedLpToken) - } - return false - }) - - // handle stable stake pool lp token - lpStableStakeDenom := stabletypes.GetShareDenom() - committedLpToken := commitments.GetCommittedAmountForDenom(lpStableStakeDenom) - amt, ok := k.tci.TotalLpTokensCommitted[lpStableStakeDenom] - if !ok { - k.tci.TotalLpTokensCommitted[lpStableStakeDenom] = committedLpToken - } else { - k.tci.TotalLpTokensCommitted[lpStableStakeDenom] = amt.Add(committedLpToken) - } - return false - }) -} diff --git a/x/incentive/keeper/params_test.go b/x/incentive/keeper/params_test.go deleted file mode 100644 index 5f5296199..000000000 --- a/x/incentive/keeper/params_test.go +++ /dev/null @@ -1,132 +0,0 @@ -package keeper_test - -import ( - "strconv" - "strings" - "testing" - - tmproto "github.com/cometbft/cometbft/proto/tendermint/types" - sdk "github.com/cosmos/cosmos-sdk/types" - simapp "github.com/elys-network/elys/app" - testkeeper "github.com/elys-network/elys/testutil/keeper" - ammkeeper "github.com/elys-network/elys/x/amm/keeper" - ammtypes "github.com/elys-network/elys/x/amm/types" - "github.com/elys-network/elys/x/incentive/types" - ptypes "github.com/elys-network/elys/x/parameter/types" - "github.com/stretchr/testify/require" -) - -func TestGetParams(t *testing.T) { - k, ctx := testkeeper.IncentiveKeeper(t) - params := types.DefaultParams() - - k.SetParams(ctx, params) - - require.EqualValues(t, params, k.GetParams(ctx)) -} - -func TestUpdatePoolMultiplierInfo(t *testing.T) { - app := simapp.InitElysTestApp(initChain) - ctx := app.BaseApp.NewContext(initChain, tmproto.Header{}) - - ik, amm, oracle, bk, ck := app.IncentiveKeeper, app.AmmKeeper, app.OracleKeeper, app.BankKeeper, app.CommitmentKeeper - - // Setup coin prices - SetupStableCoinPrices(ctx, oracle) - - // Generate 1 random account with 1000stake balanced - addr := simapp.AddTestAddrs(app, ctx, 1, sdk.NewInt(100010)) - - // Create a pool - // Mint 100000USDC + 10 ELYS (pool creation fee) - coins := sdk.NewCoins(sdk.NewInt64Coin(ptypes.Elys, 10000000), sdk.NewInt64Coin(ptypes.BaseCurrency, 100000)) - err := app.BankKeeper.MintCoins(ctx, ammtypes.ModuleName, coins) - require.NoError(t, err) - err = app.BankKeeper.SendCoinsFromModuleToAccount(ctx, ammtypes.ModuleName, addr[0], coins) - require.NoError(t, err) - - var poolAssets []ammtypes.PoolAsset - // Elys - poolAssets = append(poolAssets, ammtypes.PoolAsset{ - Weight: sdk.NewInt(50), - Token: sdk.NewCoin(ptypes.Elys, sdk.NewInt(1000)), - }) - - // USDC - poolAssets = append(poolAssets, ammtypes.PoolAsset{ - Weight: sdk.NewInt(50), - Token: sdk.NewCoin(ptypes.BaseCurrency, sdk.NewInt(100)), - }) - - poolParams := &ammtypes.PoolParams{ - SwapFee: sdk.ZeroDec(), - ExitFee: sdk.ZeroDec(), - UseOracle: false, - WeightBreakingFeeMultiplier: sdk.ZeroDec(), - WeightBreakingFeeExponent: sdk.NewDecWithPrec(25, 1), // 2.5 - ExternalLiquidityRatio: sdk.OneDec(), - WeightRecoveryFeePortion: sdk.NewDecWithPrec(10, 2), // 10% - ThresholdWeightDifference: sdk.ZeroDec(), - FeeDenom: "", - } - - // Create a Elys+USDC pool - msgServer := ammkeeper.NewMsgServerImpl(amm) - resp, err := msgServer.CreatePool( - sdk.WrapSDKContext(ctx), - &ammtypes.MsgCreatePool{ - Sender: addr[0].String(), - PoolParams: poolParams, - PoolAssets: poolAssets, - }) - - require.NoError(t, err) - require.Equal(t, resp.PoolID, uint64(1)) - - pools := amm.GetAllPool(ctx) - - // check length of pools - require.Equal(t, len(pools), 1) - - // check balance change on sender - balances := bk.GetBalance(ctx, addr[0], "amm/pool/1") - require.Equal(t, balances, sdk.NewCoin("amm/pool/1", sdk.NewInt(0))) - - // check lp token commitment - commitments := ck.GetCommitments(ctx, addr[0].String()) - require.Len(t, commitments.CommittedTokens, 1) - require.Equal(t, commitments.CommittedTokens[0].Denom, "amm/pool/1") - require.Equal(t, commitments.CommittedTokens[0].Amount.String(), "100100000000000000000") - - poolIds := strings.Split("1,2,3", ",") - multipliers := strings.Split("5,1,1", ",") - require.Len(t, poolIds, 3) - - poolInfo, found := ik.GetPoolInfo(ctx, resp.PoolID) - require.True(t, found) - require.Equal(t, poolInfo.Multiplier, sdk.NewDec(1)) - - poolMultipliers := make([]types.PoolMultiplier, 0) - for i := range poolIds { - poolId, err := strconv.ParseUint(poolIds[i], 10, 64) - require.NoError(t, err) - - multiplier, err := sdk.NewDecFromStr(multipliers[i]) - require.NoError(t, err) - - poolMultiplier := types.PoolMultiplier{ - PoolId: poolId, - Multiplier: multiplier, - } - - poolMultipliers = append(poolMultipliers, poolMultiplier) - } - - ik.UpdatePoolMultipliers(ctx, poolMultipliers) - - poolInfo, found = ik.GetPoolInfo(ctx, resp.PoolID) - require.True(t, found) - - // After setting up, it should become 5. - require.Equal(t, poolInfo.Multiplier, sdk.NewDec(5)) -} diff --git a/x/incentive/keeper/queries.go b/x/incentive/keeper/queries.go index 315a6bfde..98aae43dc 100644 --- a/x/incentive/keeper/queries.go +++ b/x/incentive/keeper/queries.go @@ -8,32 +8,13 @@ import ( commitmenttypes "github.com/elys-network/elys/x/commitment/types" "github.com/elys-network/elys/x/incentive/types" ptypes "github.com/elys-network/elys/x/parameter/types" + stablestaketypes "github.com/elys-network/elys/x/stablestake/types" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) var _ types.QueryServer = Keeper{} -func (k Keeper) CommunityPool(goCtx context.Context, req *types.QueryCommunityPoolRequest) (*types.QueryCommunityPoolResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "invalid request") - } - - ctx := sdk.UnwrapSDKContext(goCtx) - pool := k.GetFeePoolCommunityCoins(ctx) - - return &types.QueryCommunityPoolResponse{Pool: pool}, nil -} - -func (k Keeper) Params(goCtx context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "invalid request") - } - ctx := sdk.UnwrapSDKContext(goCtx) - - return &types.QueryParamsResponse{Params: k.GetParams(ctx)}, nil -} - func (k Keeper) Apr(goCtx context.Context, req *types.QueryAprRequest) (*types.QueryAprResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "invalid request") @@ -120,16 +101,6 @@ func (k Keeper) Aprs(goCtx context.Context, req *types.QueryAprsRequest) (*types }, nil } -func (k Keeper) PoolAprs(goCtx context.Context, req *types.QueryPoolAprsRequest) (*types.QueryPoolAprsResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "invalid request") - } - - ctx := sdk.UnwrapSDKContext(goCtx) - data := k.CalculatePoolAprs(ctx, req.PoolIds) - return &types.QueryPoolAprsResponse{Data: data}, nil -} - func (k Keeper) PoolRewards(goCtx context.Context, req *types.QueryPoolRewardsRequest) (*types.QueryPoolRewardsResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "invalid request") @@ -188,6 +159,60 @@ func (k Keeper) PoolRewards(goCtx context.Context, req *types.QueryPoolRewardsRe }, nil } +func (k Keeper) AllProgramRewards(goCtx context.Context, req *types.QueryAllProgramRewardsRequest) (*types.QueryAllProgramRewardsResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + ctx := sdk.UnwrapSDKContext(goCtx) + + k.masterchef.AfterWithdraw(ctx, stablestaketypes.PoolId, req.Address, sdk.ZeroInt()) + + stableStakeRewards := sdk.NewDecCoins() + for _, rewardDenom := range k.masterchef.GetRewardDenoms(ctx, stablestaketypes.PoolId) { + userRewardInfo, found := k.masterchef.GetUserRewardInfo(ctx, req.Address, stablestaketypes.PoolId, rewardDenom) + if found && userRewardInfo.RewardPending.IsPositive() { + stableStakeRewards = stableStakeRewards.Add( + sdk.NewDecCoinFromDec( + rewardDenom, + userRewardInfo.RewardPending, + ), + ) + } + } + + delAddr := sdk.MustAccAddressFromBech32(req.Address) + delegations := k.estaking.Keeper.GetDelegatorDelegations(ctx, delAddr, 5000) + elysStakingRewards := sdk.DecCoins{} + for _, del := range delegations { + rewards, err := k.estaking.DelegationRewards(ctx, req.Address, del.ValidatorAddress) + if err != nil { + return nil, err + } + elysStakingRewards = elysStakingRewards.Add(rewards...) + } + + // Eden commit rewards + edenVal := k.estaking.GetParams(ctx).EdenCommitVal + edenCommitRewards, err := k.estaking.DelegationRewards(ctx, req.Address, edenVal) + if err != nil { + return nil, err + } + + // EdenB commit rewards + edenBVal := k.estaking.GetParams(ctx).EdenbCommitVal + edenBCommitRewards, err := k.estaking.DelegationRewards(ctx, req.Address, edenBVal) + if err != nil { + return nil, err + } + + return &types.QueryAllProgramRewardsResponse{ + UsdcStakingRewards: stableStakeRewards, + ElysStakingRewards: elysStakingRewards, + EdenStakingRewards: edenCommitRewards, + EdenbStakingRewards: edenBCommitRewards, + }, nil +} + // Generate earn pool struct func (k *Keeper) generatePoolRewards(ctx sdk.Context, ammPool *ammtypes.Pool) types.PoolRewards { // Get rewards amount diff --git a/x/incentive/keeper/store.go b/x/incentive/keeper/store.go deleted file mode 100644 index 0bf925990..000000000 --- a/x/incentive/keeper/store.go +++ /dev/null @@ -1,24 +0,0 @@ -package keeper - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/elys-network/elys/x/incentive/types" -) - -// get the global fee pool distribution info -func (k Keeper) GetFeePool(ctx sdk.Context) (feePool types.FeePool) { - store := ctx.KVStore(k.storeKey) - b := store.Get(types.FeePoolKey) - if b == nil { - panic("Stored fee pool should not have been nil") - } - k.cdc.MustUnmarshal(b, &feePool) - return -} - -// set the global fee pool distribution info -func (k Keeper) SetFeePool(ctx sdk.Context, feePool types.FeePool) { - store := ctx.KVStore(k.storeKey) - b := k.cdc.MustMarshal(&feePool) - store.Set(types.FeePoolKey, b) -} diff --git a/x/incentive/migrations/new_migrator.go b/x/incentive/migrations/new_migrator.go index efb434c4a..ee482abfb 100644 --- a/x/incentive/migrations/new_migrator.go +++ b/x/incentive/migrations/new_migrator.go @@ -1,13 +1,33 @@ package migrations import ( - "github.com/elys-network/elys/x/incentive/keeper" + distrkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper" + commitmentkeeper "github.com/elys-network/elys/x/commitment/keeper" + estakingkeeper "github.com/elys-network/elys/x/estaking/keeper" + incentivekeeper "github.com/elys-network/elys/x/incentive/keeper" + masterchefkeeper "github.com/elys-network/elys/x/masterchef/keeper" ) type Migrator struct { - keeper keeper.Keeper + incentiveKeeper incentivekeeper.Keeper + estakingKeeper estakingkeeper.Keeper + masterchefKeeper masterchefkeeper.Keeper + distrKeeper distrkeeper.Keeper + commitmentKeeper commitmentkeeper.Keeper } -func NewMigrator(keeper keeper.Keeper) Migrator { - return Migrator{keeper: keeper} +func NewMigrator( + incentiveKeeper incentivekeeper.Keeper, + estakingKeeper estakingkeeper.Keeper, + masterchefKeeper masterchefkeeper.Keeper, + distrKeeper distrkeeper.Keeper, + commitmentKeeper commitmentkeeper.Keeper, +) Migrator { + return Migrator{ + incentiveKeeper: incentiveKeeper, + estakingKeeper: estakingKeeper, + masterchefKeeper: masterchefKeeper, + distrKeeper: distrKeeper, + commitmentKeeper: commitmentKeeper, + } } diff --git a/x/incentive/migrations/v10_migration.go b/x/incentive/migrations/v10_migration.go deleted file mode 100644 index e42036712..000000000 --- a/x/incentive/migrations/v10_migration.go +++ /dev/null @@ -1,12 +0,0 @@ -package migrations - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" -) - -func (m Migrator) V10Migration(ctx sdk.Context) error { - params := m.keeper.GetParams(ctx) - params.DistributionInterval = 1200 - m.keeper.SetParams(ctx, params) - return nil -} diff --git a/x/incentive/migrations/v11_migration.go b/x/incentive/migrations/v11_migration.go new file mode 100644 index 000000000..b94afc44b --- /dev/null +++ b/x/incentive/migrations/v11_migration.go @@ -0,0 +1,154 @@ +package migrations + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" + ammtypes "github.com/elys-network/elys/x/amm/types" + commitmenttypes "github.com/elys-network/elys/x/commitment/types" + estakingtypes "github.com/elys-network/elys/x/estaking/types" + mastercheftypes "github.com/elys-network/elys/x/masterchef/types" + ptypes "github.com/elys-network/elys/x/parameter/types" + stablestaketypes "github.com/elys-network/elys/x/stablestake/types" +) + +func (m Migrator) V11Migration(ctx sdk.Context) error { + // initialize pool infos from incentive module + incentiveParams := m.incentiveKeeper.GetParams(ctx) + for _, poolInfo := range incentiveParams.PoolInfos { + m.masterchefKeeper.SetPool(ctx, mastercheftypes.PoolInfo{ + PoolId: poolInfo.PoolId, + RewardWallet: poolInfo.RewardWallet, + Multiplier: poolInfo.Multiplier, + NumBlocks: poolInfo.NumBlocks, + DexRewardAmountGiven: poolInfo.DexRewardAmountGiven, + EdenRewardAmountGiven: poolInfo.EdenRewardAmountGiven, + EdenApr: poolInfo.EdenApr, + DexApr: poolInfo.DexApr, + ExternalIncentiveApr: sdk.ZeroDec(), + ExternalRewardDenoms: []string{}, + }) + } + + // initiate masterchef params + m.masterchefKeeper.SetParams(ctx, mastercheftypes.NewParams( + nil, + sdk.NewDecWithPrec(60, 2), + sdk.NewDecWithPrec(25, 2), + mastercheftypes.DexRewardsTracker{ + NumBlocks: sdk.NewInt(1), + Amount: sdk.ZeroDec(), + }, + sdk.NewDecWithPrec(5, 1), + "elys10d07y265gmmuvt4z0w9aw880jnsr700j6z2zm3", + )) + + // initiate estaking module data + m.estakingKeeper.InitGenesis(ctx, estakingtypes.GenesisState{ + Params: estakingtypes.Params{ + StakeIncentives: nil, + EdenCommitVal: "", + EdenbCommitVal: "", + MaxEdenRewardAprStakers: sdk.NewDecWithPrec(3, 1), // 30% + EdenBoostApr: sdk.OneDec(), + DexRewardsStakers: estakingtypes.DexRewardsTracker{ + NumBlocks: sdk.OneInt(), + Amount: sdk.ZeroDec(), + }, + }, + }) + + // initiate delegation snapshot + stakedSnapshots := m.incentiveKeeper.GetAllElysStaked(ctx) + for _, snap := range stakedSnapshots { + m.estakingKeeper.SetElysStaked(ctx, estakingtypes.ElysStaked{ + Address: snap.Address, + Amount: snap.Amount, + }) + } + + // initiate missing distribution module data + m.distrKeeper.InitGenesis(ctx, *distrtypes.DefaultGenesisState()) + + // execute missing validator creation hooks + validators := m.estakingKeeper.Keeper.GetAllValidators(ctx) + for _, val := range validators { + err := m.estakingKeeper.Hooks().AfterValidatorCreated(ctx, val.GetOperator()) + if err != nil { + panic(err) + } + } + + // execute missing delegation creation hooks + allDelegations := m.estakingKeeper.Keeper.GetAllDelegations(ctx) + for _, delegation := range allDelegations { + delAddr := sdk.MustAccAddressFromBech32(delegation.DelegatorAddress) + valAddr, err := sdk.ValAddressFromBech32(delegation.ValidatorAddress) + if err != nil { + panic(err) + } + err = m.estakingKeeper.Hooks().AfterDelegationModified(ctx, delAddr, valAddr) + if err != nil { + panic(err) + } + } + + // Update all commitments (move all unclaimed into claimed) + // and execute missing eden/edenb commitment hooks + edenValAddr := sdk.ValAddress(authtypes.NewModuleAddress(ptypes.Eden)) + edenBValAddr := sdk.ValAddress(authtypes.NewModuleAddress(ptypes.EdenB)) + legacyCommitments := m.commitmentKeeper.GetAllLegacyCommitments(ctx) + for _, legacy := range legacyCommitments { + creator := legacy.Creator + addr, err := sdk.AccAddressFromBech32(creator) + if err != nil { + // This is validator address + m.commitmentKeeper.RemoveCommitments(ctx, creator) + continue + } + + commitments := commitmenttypes.Commitments{ + Creator: legacy.Creator, + CommittedTokens: legacy.CommittedTokens, + Claimed: legacy.Claimed.Add(legacy.RewardsUnclaimed...), + VestingTokens: legacy.VestingTokens, + } + m.commitmentKeeper.SetCommitments(ctx, commitments) + commParams := m.commitmentKeeper.GetParams(ctx) + for _, committed := range commitments.CommittedTokens { + if committed.Denom == ptypes.Eden && commParams.TotalCommitted.AmountOf(ptypes.Eden).IsPositive() { + err = m.estakingKeeper.Hooks().BeforeDelegationCreated(ctx, addr, edenValAddr) + if err != nil { + return err + } + err = m.estakingKeeper.Hooks().AfterDelegationModified(ctx, addr, edenValAddr) + if err != nil { + return err + } + } + if committed.Denom == ptypes.EdenB && commParams.TotalCommitted.AmountOf(ptypes.EdenB).IsPositive() { + err = m.estakingKeeper.Hooks().BeforeDelegationCreated(ctx, addr, edenBValAddr) + if err != nil { + return err + } + err = m.estakingKeeper.Hooks().AfterDelegationModified(ctx, addr, edenBValAddr) + if err != nil { + return err + } + } + + // Execute hook for normal amm pool deposit + poolId, err := ammtypes.GetPoolIdFromShareDenom(committed.Denom) + if err == nil { + m.masterchefKeeper.AfterDeposit(ctx, poolId, addr.String(), committed.Amount) + } + + // Execute hook for stablestake deposit + if committed.Denom == stablestaketypes.GetShareDenom() { + m.masterchefKeeper.AfterDeposit(ctx, stablestaketypes.PoolId, addr.String(), committed.Amount) + } + } + } + + return nil +} diff --git a/x/incentive/migrations/v2_migration.go b/x/incentive/migrations/v2_migration.go deleted file mode 100644 index 24badeb86..000000000 --- a/x/incentive/migrations/v2_migration.go +++ /dev/null @@ -1,11 +0,0 @@ -package migrations - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/elys-network/elys/x/incentive/types" -) - -func (m Migrator) V2Migration(ctx sdk.Context) error { - m.keeper.SetParams(ctx, types.DefaultParams()) - return nil -} diff --git a/x/incentive/migrations/v3_migration.go b/x/incentive/migrations/v3_migration.go deleted file mode 100644 index 10b5c8de5..000000000 --- a/x/incentive/migrations/v3_migration.go +++ /dev/null @@ -1,11 +0,0 @@ -package migrations - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/elys-network/elys/x/incentive/types" -) - -func (m Migrator) V3Migration(ctx sdk.Context) error { - m.keeper.SetParams(ctx, types.DefaultParams()) - return nil -} diff --git a/x/incentive/migrations/v4_migration.go b/x/incentive/migrations/v4_migration.go deleted file mode 100644 index d6bc38a81..000000000 --- a/x/incentive/migrations/v4_migration.go +++ /dev/null @@ -1,11 +0,0 @@ -package migrations - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/elys-network/elys/x/incentive/types" -) - -func (m Migrator) V4Migration(ctx sdk.Context) error { - m.keeper.SetParams(ctx, types.DefaultParams()) - return nil -} diff --git a/x/incentive/migrations/v5_migration.go b/x/incentive/migrations/v5_migration.go deleted file mode 100644 index 6f19fcf42..000000000 --- a/x/incentive/migrations/v5_migration.go +++ /dev/null @@ -1,11 +0,0 @@ -package migrations - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/elys-network/elys/x/incentive/types" -) - -func (m Migrator) V5Migration(ctx sdk.Context) error { - m.keeper.SetParams(ctx, types.DefaultParams()) - return nil -} diff --git a/x/incentive/migrations/v6_migration.go b/x/incentive/migrations/v6_migration.go deleted file mode 100644 index 05db6514a..000000000 --- a/x/incentive/migrations/v6_migration.go +++ /dev/null @@ -1,11 +0,0 @@ -package migrations - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/elys-network/elys/x/incentive/types" -) - -func (m Migrator) V6Migration(ctx sdk.Context) error { - m.keeper.SetParams(ctx, types.DefaultParams()) - return nil -} diff --git a/x/incentive/migrations/v7_migration.go b/x/incentive/migrations/v7_migration.go deleted file mode 100644 index 24043633f..000000000 --- a/x/incentive/migrations/v7_migration.go +++ /dev/null @@ -1,11 +0,0 @@ -package migrations - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/elys-network/elys/x/incentive/types" -) - -func (m Migrator) V7Migration(ctx sdk.Context) error { - m.keeper.SetParams(ctx, types.DefaultParams()) - return nil -} diff --git a/x/incentive/migrations/v8_migration.go b/x/incentive/migrations/v8_migration.go deleted file mode 100644 index 01b18e400..000000000 --- a/x/incentive/migrations/v8_migration.go +++ /dev/null @@ -1,11 +0,0 @@ -package migrations - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/elys-network/elys/x/incentive/types" -) - -func (m Migrator) V8Migration(ctx sdk.Context) error { - m.keeper.SetParams(ctx, types.DefaultParams()) - return nil -} diff --git a/x/incentive/migrations/v9_migration.go b/x/incentive/migrations/v9_migration.go deleted file mode 100644 index 5ad49d4de..000000000 --- a/x/incentive/migrations/v9_migration.go +++ /dev/null @@ -1,42 +0,0 @@ -package migrations - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/elys-network/elys/x/incentive/types" -) - -func (m Migrator) V9Migration(ctx sdk.Context) error { - m.keeper.SetParams(ctx, types.Params{ - LpIncentives: nil, - StakeIncentives: nil, - RewardPortionForLps: sdk.NewDecWithPrec(60, 2), - RewardPortionForStakers: sdk.NewDecWithPrec(30, 2), - PoolInfos: []types.PoolInfo{ - { - DexApr: sdk.ZeroDec(), - EdenApr: sdk.ZeroDec(), - EdenRewardAmountGiven: sdk.ZeroInt(), - DexRewardAmountGiven: sdk.ZeroDec(), - Multiplier: sdk.NewDec(1), - NumBlocks: sdk.NewInt(1), - PoolId: 32767, - RewardWallet: "elys12dxadvd5def5gfy6jwmmt3gqs2pt5k9xupx8ja", - }, - }, - ElysStakeSnapInterval: 10, - DexRewardsStakers: types.DexRewardsTracker{ - NumBlocks: sdk.NewInt(1011431), - Amount: sdk.NewDec(708624172), - AmountCollectedByOtherTracker: sdk.ZeroDec(), - }, - DexRewardsLps: types.DexRewardsTracker{ - NumBlocks: sdk.NewInt(1011431), - Amount: sdk.NewDec(1446171780), - AmountCollectedByOtherTracker: sdk.ZeroDec(), - }, - MaxEdenRewardAprStakers: sdk.NewDecWithPrec(3, 1), // 30% - MaxEdenRewardAprLps: sdk.NewDecWithPrec(5, 1), // 50% - DistributionInterval: 10, - }) - return nil -} diff --git a/x/incentive/module.go b/x/incentive/module.go index 79e263ce8..3894636f4 100644 --- a/x/incentive/module.go +++ b/x/incentive/module.go @@ -17,10 +17,14 @@ import ( cdctypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" + distrkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper" + commitmentkeeper "github.com/elys-network/elys/x/commitment/keeper" + estakingkeeper "github.com/elys-network/elys/x/estaking/keeper" "github.com/elys-network/elys/x/incentive/client/cli" "github.com/elys-network/elys/x/incentive/keeper" "github.com/elys-network/elys/x/incentive/migrations" "github.com/elys-network/elys/x/incentive/types" + masterchefkeeper "github.com/elys-network/elys/x/masterchef/keeper" ) var ( @@ -93,16 +97,28 @@ func (AppModuleBasic) GetQueryCmd() *cobra.Command { type AppModule struct { AppModuleBasic - keeper keeper.Keeper + keeper keeper.Keeper + estakingKeeper estakingkeeper.Keeper + masterchefKeeper masterchefkeeper.Keeper + distrKeeper distrkeeper.Keeper + commitmentKeeper commitmentkeeper.Keeper } func NewAppModule( cdc codec.Codec, keeper keeper.Keeper, + estakingKeeper estakingkeeper.Keeper, + masterchefKeeper masterchefkeeper.Keeper, + distrKeeper distrkeeper.Keeper, + commitmentKeeper commitmentkeeper.Keeper, ) AppModule { return AppModule{ - AppModuleBasic: NewAppModuleBasic(cdc), - keeper: keeper, + AppModuleBasic: NewAppModuleBasic(cdc), + keeper: keeper, + estakingKeeper: estakingKeeper, + masterchefKeeper: masterchefKeeper, + distrKeeper: distrKeeper, + commitmentKeeper: commitmentKeeper, } } @@ -110,8 +126,8 @@ func NewAppModule( func (am AppModule) RegisterServices(cfg module.Configurator) { types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) types.RegisterQueryServer(cfg.QueryServer(), am.keeper) - m := migrations.NewMigrator(am.keeper) - err := cfg.RegisterMigration(types.ModuleName, 9, m.V10Migration) + m := migrations.NewMigrator(am.keeper, am.estakingKeeper, am.masterchefKeeper, am.distrKeeper, am.commitmentKeeper) + err := cfg.RegisterMigration(types.ModuleName, 10, m.V11Migration) if err != nil { panic(err) } @@ -137,7 +153,7 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw } // ConsensusVersion is a sequence number for state-breaking change of the module. It should be incremented on each consensus-breaking change introduced by the module. To avoid wrong/empty versions, the initial version should be set to 1 -func (AppModule) ConsensusVersion() uint64 { return 10 } +func (AppModule) ConsensusVersion() uint64 { return 11 } // BeginBlock contains the logic that is automatically triggered at the beginning of each block func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {} diff --git a/x/incentive/module_simulation.go b/x/incentive/module_simulation.go index b122db5ba..c1653f108 100644 --- a/x/incentive/module_simulation.go +++ b/x/incentive/module_simulation.go @@ -34,10 +34,6 @@ const ( // TODO: Determine the simulation weight value defaultWeightMsgWithdrawDelegatorReward int = 100 - opWeightMsgUpdateIncentiveParams = "op_weight_msg_update_incentive_params" - // TODO: Determine the simulation weight value - defaultWeightMsgUpdateIncentiveParams int = 100 - // this line is used by starport scaffolding # simapp/module/const ) @@ -48,7 +44,6 @@ func (AppModule) GenerateGenesisState(simState *module.SimulationState) { accs[i] = acc.Address.String() } incentiveGenesis := types.GenesisState{ - Params: types.DefaultParams(), // this line is used by starport scaffolding # simapp/module/genesisState } simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(&incentiveGenesis) diff --git a/x/incentive/simulation/update_incentive_params.go b/x/incentive/simulation/update_incentive_params.go deleted file mode 100644 index b94d52943..000000000 --- a/x/incentive/simulation/update_incentive_params.go +++ /dev/null @@ -1,29 +0,0 @@ -package simulation - -import ( - "math/rand" - - "github.com/cosmos/cosmos-sdk/baseapp" - sdk "github.com/cosmos/cosmos-sdk/types" - simtypes "github.com/cosmos/cosmos-sdk/types/simulation" - "github.com/elys-network/elys/x/incentive/keeper" - "github.com/elys-network/elys/x/incentive/types" -) - -func SimulateMsgUpdateIncentiveParams( - 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) { - simAccount, _ := simtypes.RandomAcc(r, accs) - msg := &types.MsgUpdateIncentiveParams{ - Authority: simAccount.Address.String(), - } - - // TODO: Handling the UpdateIncentiveParams simulation - - return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "UpdateIncentiveParams simulation not implemented"), nil, nil - } -} diff --git a/x/incentive/spec/02_state.md b/x/incentive/spec/02_state.md index a8c00baa2..4101e4b1d 100644 --- a/x/incentive/spec/02_state.md +++ b/x/incentive/spec/02_state.md @@ -5,50 +5,3 @@ order: 2 # State ## Params - -```proto -message Params { - option (gogoproto.goproto_stringer) = false; - - IncentiveInfo lp_incentives = 1; - IncentiveInfo stake_incentives = 2; - string reward_portion_for_lps = 3 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false - ]; -} -``` - -## IncentiveInfo - -```proto -message IncentiveInfo { - // reward amount - string amount = 1 - [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"amount\""]; - // epoch identifier - string epoch_identifier = 2 [(gogoproto.moretags) = "yaml:\"epoch_identifier\""]; - // start_time of the distribution - google.protobuf.Timestamp start_time = 3 - [(gogoproto.stdtime) = true, (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"start_time\""]; - // distribution duration - int64 num_epochs = 4 [(gogoproto.moretags) = "yaml:\"num_epochs\""]; - int64 current_epoch = 5 [(gogoproto.moretags) = "yaml:\"current_epoch\""]; - int64 eden_boost_apr = 6 [(gogoproto.moretags) = "yaml:\"eden_boost_apr\""]; -} -``` - -`IncentiveInfo` has the inflationary reward amount per epoch - Eden token. - -## FeePool - -```proto -message FeePool { - repeated cosmos.base.v1beta1.DecCoin community_pool = 1 [ - (gogoproto.nullable) = false, - (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins" - ]; -} -``` - -`FeePool` describes the amount of tokens on community pool. diff --git a/x/incentive/types/codec.go b/x/incentive/types/codec.go index d87ffc845..2a65ba6d3 100644 --- a/x/incentive/types/codec.go +++ b/x/incentive/types/codec.go @@ -3,20 +3,15 @@ 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" ) func RegisterCodec(cdc *codec.LegacyAmino) { - cdc.RegisterConcrete(&MsgUpdateIncentiveParams{}, "incentive/UpdateIncentiveParams", nil) // this line is used by starport scaffolding # 2 } func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { - registry.RegisterImplementations((*sdk.Msg)(nil), - &MsgUpdateIncentiveParams{}, - &MsgUpdatePoolMultipliers{}, - ) + // this line is used by starport scaffolding # 3 msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) } diff --git a/x/incentive/types/dex_rewards_traker.pb.go b/x/incentive/types/dex_rewards_traker.pb.go index 3a3d38097..f99658679 100644 --- a/x/incentive/types/dex_rewards_traker.pb.go +++ b/x/incentive/types/dex_rewards_traker.pb.go @@ -24,13 +24,16 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// DexRewardsTracker is used for tracking rewards for stakers and LPs, all amount here is in USDC +// DexRewardsTracker is used for tracking rewards for stakers and LPs, all +// amount here is in USDC type DexRewardsTracker struct { // Number of blocks since start of epoch (distribution epoch) NumBlocks github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=num_blocks,json=numBlocks,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"num_blocks"` - // Accumulated amount at distribution epoch - recalculated at every distribution epoch + // Accumulated amount at distribution epoch - recalculated at every + // distribution epoch Amount github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=amount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"amount"` - // Accumulated rewards tracked by other (when it's for staking, from lp, if it's for lp, from staking) + // Accumulated rewards tracked by other (when it's for staking, from lp, if + // it's for lp, from staking) AmountCollectedByOtherTracker github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=amount_collected_by_other_tracker,json=amountCollectedByOtherTracker,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"amount_collected_by_other_tracker"` } diff --git a/x/incentive/types/distribution.pb.go b/x/incentive/types/distribution.pb.go deleted file mode 100644 index 7aeea80be..000000000 --- a/x/incentive/types/distribution.pb.go +++ /dev/null @@ -1,365 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: elys/incentive/distribution.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/cosmos/gogoproto/gogoproto" - proto "github.com/cosmos/gogoproto/proto" - 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 - -// FeePool is the global fee pool for distribution. -type FeePool struct { - CommunityPool github_com_cosmos_cosmos_sdk_types.DecCoins `protobuf:"bytes,1,rep,name=community_pool,json=communityPool,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.DecCoins" json:"community_pool"` -} - -func (m *FeePool) Reset() { *m = FeePool{} } -func (m *FeePool) String() string { return proto.CompactTextString(m) } -func (*FeePool) ProtoMessage() {} -func (*FeePool) Descriptor() ([]byte, []int) { - return fileDescriptor_4fd7627d4268669e, []int{0} -} -func (m *FeePool) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *FeePool) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_FeePool.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 *FeePool) XXX_Merge(src proto.Message) { - xxx_messageInfo_FeePool.Merge(m, src) -} -func (m *FeePool) XXX_Size() int { - return m.Size() -} -func (m *FeePool) XXX_DiscardUnknown() { - xxx_messageInfo_FeePool.DiscardUnknown(m) -} - -var xxx_messageInfo_FeePool proto.InternalMessageInfo - -func (m *FeePool) GetCommunityPool() github_com_cosmos_cosmos_sdk_types.DecCoins { - if m != nil { - return m.CommunityPool - } - return nil -} - -func init() { - proto.RegisterType((*FeePool)(nil), "elys.incentive.FeePool") -} - -func init() { proto.RegisterFile("elys/incentive/distribution.proto", fileDescriptor_4fd7627d4268669e) } - -var fileDescriptor_4fd7627d4268669e = []byte{ - // 266 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4c, 0xcd, 0xa9, 0x2c, - 0xd6, 0xcf, 0xcc, 0x4b, 0x4e, 0xcd, 0x2b, 0xc9, 0x2c, 0x4b, 0xd5, 0x4f, 0xc9, 0x2c, 0x2e, 0x29, - 0xca, 0x4c, 0x2a, 0x2d, 0xc9, 0xcc, 0xcf, 0xd3, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x03, - 0x29, 0xd1, 0x83, 0x2b, 0x91, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0x4b, 0xe9, 0x83, 0x58, 0x10, - 0x55, 0x52, 0x72, 0xc9, 0xf9, 0xc5, 0xb9, 0xf9, 0xc5, 0xfa, 0x49, 0x89, 0xc5, 0xa9, 0xfa, 0x65, - 0x86, 0x49, 0xa9, 0x25, 0x89, 0x86, 0xfa, 0xc9, 0xf9, 0x99, 0x50, 0x53, 0x94, 0x9a, 0x19, 0xb9, - 0xd8, 0xdd, 0x52, 0x53, 0x03, 0xf2, 0xf3, 0x73, 0x84, 0x2a, 0xb8, 0xf8, 0x92, 0xf3, 0x73, 0x73, - 0x4b, 0xf3, 0x32, 0x4b, 0x2a, 0xe3, 0x0b, 0xf2, 0xf3, 0x73, 0x24, 0x18, 0x15, 0x98, 0x35, 0xb8, - 0x8d, 0x64, 0xf4, 0x20, 0x86, 0xe8, 0x81, 0x0c, 0xd1, 0x83, 0x1a, 0xa2, 0xe7, 0x92, 0x9a, 0xec, - 0x9c, 0x9f, 0x99, 0xe7, 0x64, 0x7c, 0xe2, 0x9e, 0x3c, 0xc3, 0xaa, 0xfb, 0xf2, 0xda, 0xe9, 0x99, - 0x25, 0x19, 0xa5, 0x49, 0x7a, 0xc9, 0xf9, 0xb9, 0xfa, 0x50, 0x4b, 0x21, 0x94, 0x6e, 0x71, 0x4a, - 0xb6, 0x7e, 0x49, 0x65, 0x41, 0x6a, 0x31, 0x4c, 0x4f, 0x71, 0x10, 0x2f, 0xdc, 0x22, 0x90, 0xcd, - 0x4e, 0x3e, 0x2b, 0x1e, 0xc9, 0x31, 0x9e, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, - 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x43, - 0x94, 0x1e, 0x92, 0xc9, 0x20, 0x4f, 0xeb, 0xe6, 0xa5, 0x96, 0x94, 0xe7, 0x17, 0x65, 0x83, 0x39, - 0xfa, 0x15, 0x48, 0xc1, 0x04, 0xb6, 0x25, 0x89, 0x0d, 0xec, 0x35, 0x63, 0x40, 0x00, 0x00, 0x00, - 0xff, 0xff, 0x90, 0x97, 0x92, 0x2f, 0x45, 0x01, 0x00, 0x00, -} - -func (this *FeePool) Equal(that interface{}) bool { - if that == nil { - return this == nil - } - - that1, ok := that.(*FeePool) - if !ok { - that2, ok := that.(FeePool) - if ok { - that1 = &that2 - } else { - return false - } - } - if that1 == nil { - return this == nil - } else if this == nil { - return false - } - if len(this.CommunityPool) != len(that1.CommunityPool) { - return false - } - for i := range this.CommunityPool { - if !this.CommunityPool[i].Equal(&that1.CommunityPool[i]) { - return false - } - } - return true -} -func (m *FeePool) 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 *FeePool) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *FeePool) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.CommunityPool) > 0 { - for iNdEx := len(m.CommunityPool) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.CommunityPool[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintDistribution(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func encodeVarintDistribution(dAtA []byte, offset int, v uint64) int { - offset -= sovDistribution(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *FeePool) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.CommunityPool) > 0 { - for _, e := range m.CommunityPool { - l = e.Size() - n += 1 + l + sovDistribution(uint64(l)) - } - } - return n -} - -func sovDistribution(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozDistribution(x uint64) (n int) { - return sovDistribution(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *FeePool) 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 ErrIntOverflowDistribution - } - 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: FeePool: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: FeePool: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CommunityPool", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowDistribution - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthDistribution - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthDistribution - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.CommunityPool = append(m.CommunityPool, types.DecCoin{}) - if err := m.CommunityPool[len(m.CommunityPool)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipDistribution(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthDistribution - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipDistribution(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, ErrIntOverflowDistribution - } - 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, ErrIntOverflowDistribution - } - 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, ErrIntOverflowDistribution - } - 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, ErrInvalidLengthDistribution - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupDistribution - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthDistribution - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthDistribution = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowDistribution = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupDistribution = fmt.Errorf("proto: unexpected end of group") -) diff --git a/x/incentive/types/expected_keepers.go b/x/incentive/types/expected_keepers.go index 7a03e6e05..d7c0343a7 100644 --- a/x/incentive/types/expected_keepers.go +++ b/x/incentive/types/expected_keepers.go @@ -10,7 +10,6 @@ import ( ammtypes "github.com/elys-network/elys/x/amm/types" aptypes "github.com/elys-network/elys/x/assetprofile/types" ctypes "github.com/elys-network/elys/x/commitment/types" - epochstypes "github.com/elys-network/elys/x/epochs/types" oracletypes "github.com/elys-network/elys/x/oracle/types" stabletypes "github.com/elys-network/elys/x/stablestake/types" tokenomictypes "github.com/elys-network/elys/x/tokenomics/types" @@ -26,10 +25,6 @@ type CommitmentKeeper interface { SetCommitments(sdk.Context, ctypes.Commitments) // Get commitment GetCommitments(sdk.Context, string) ctypes.Commitments - // Update commitments for claim reward operation - RecordClaimReward(sdk.Context, string, string, math.Int, ctypes.EarnType) error - // Update commitments for validator commission - RecordWithdrawValidatorCommission(sdk.Context, string, string, string, math.Int) error // Burn eden boost BurnEdenBoost(ctx sdk.Context, creator string, denom string, amount math.Int) (ctypes.Commitments, error) } @@ -57,9 +52,6 @@ type AccountKeeper interface { GetModuleAddress(name string) sdk.AccAddress GetModuleAccount(ctx sdk.Context, name string) types.ModuleAccountI - - // TODO remove with genesis 2-phases refactor https://github.com/cosmos/cosmos-sdk/issues/2862 - SetModuleAccount(sdk.Context, types.ModuleAccountI) } // BankKeeper defines the expected interface needed to retrieve account balances. @@ -112,6 +104,8 @@ type AmmKeeper interface { swapFee sdk.Dec, ) (tokenOut sdk.Coin, slippage, slippageAmount sdk.Dec, weightBalanceBonus sdk.Dec, err error) CalcOutAmtGivenIn(ctx sdk.Context, poolId uint64, oracle ammtypes.OracleKeeper, snapshot *ammtypes.Pool, tokensIn sdk.Coins, tokenOutDenom string, swapFee sdk.Dec) (sdk.Coin, sdk.Dec, error) + GetEdenDenomPrice(ctx sdk.Context, baseCurrency string) math.LegacyDec + GetTokenPrice(ctx sdk.Context, tokenInDenom, baseCurrency string) math.LegacyDec } // OracleKeeper defines the expected interface needed to retrieve price info @@ -131,12 +125,7 @@ type AssetProfileKeeper interface { GetEntry(ctx sdk.Context, baseDenom string) (val aptypes.Entry, found bool) } -// EpochsKeeper defines the expected epochs keeper used for simulations (noalias) -type EpochsKeeper interface { - GetEpochInfo(ctx sdk.Context, identifier string) (epochstypes.EpochInfo, bool) -} - -// StableStakeKeeper defines the expected epochs keeper used for simulations (noalias) +// StableStakeKeeper defines the expected StableStake keeper used for simulations (noalias) type StableStakeKeeper interface { GetParams(ctx sdk.Context) (params stabletypes.Params) BorrowRatio(goCtx context.Context, req *stabletypes.QueryBorrowRatioRequest) (*stabletypes.QueryBorrowRatioResponse, error) diff --git a/x/incentive/types/feel_pool.go b/x/incentive/types/feel_pool.go deleted file mode 100644 index fa3fe6dc7..000000000 --- a/x/incentive/types/feel_pool.go +++ /dev/null @@ -1,23 +0,0 @@ -package types - -import ( - "fmt" - - sdk "github.com/cosmos/cosmos-sdk/types" -) - -// zero fee pool -func InitialFeePool() FeePool { - return FeePool{ - CommunityPool: sdk.DecCoins{}, - } -} - -// ValidateGenesis validates the fee pool for a genesis state -func (f FeePool) ValidateGenesis() error { - if f.CommunityPool.IsAnyNegative() { - return fmt.Errorf("negative CommunityPool in distribution fee pool, is %v", f.CommunityPool) - } - - return nil -} diff --git a/x/incentive/types/genesis.go b/x/incentive/types/genesis.go index 62f1d161e..bad628eb4 100644 --- a/x/incentive/types/genesis.go +++ b/x/incentive/types/genesis.go @@ -4,31 +4,19 @@ package types const DefaultIndex uint64 = 1 //nolint:interfacer -func NewGenesisState( - params Params, fp FeePool, -) *GenesisState { - return &GenesisState{ - Params: params, - FeePool: fp, - } +func NewGenesisState() *GenesisState { + return &GenesisState{} } // DefaultGenesis returns the default genesis state func DefaultGenesis() *GenesisState { return &GenesisState{ // this line is used by starport scaffolding # genesis/types/default - Params: DefaultParams(), - FeePool: InitialFeePool(), } } // Validate performs basic genesis state validation returning an error upon any // failure. func (gs GenesisState) Validate() error { - // this line is used by starport scaffolding # genesis/types/validate - if err := gs.Params.Validate(); err != nil { - return err - } - - return gs.FeePool.ValidateGenesis() + return nil } diff --git a/x/incentive/types/genesis.pb.go b/x/incentive/types/genesis.pb.go index 55cf9ff0a..43dd5dc12 100644 --- a/x/incentive/types/genesis.pb.go +++ b/x/incentive/types/genesis.pb.go @@ -26,9 +26,6 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // GenesisState defines the incentive module's genesis state. type GenesisState struct { - Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` - // fee_pool defines the fee pool at genesis. - FeePool FeePool `protobuf:"bytes,2,opt,name=fee_pool,json=feePool,proto3" json:"fee_pool"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -64,20 +61,6 @@ func (m *GenesisState) XXX_DiscardUnknown() { var xxx_messageInfo_GenesisState proto.InternalMessageInfo -func (m *GenesisState) GetParams() Params { - if m != nil { - return m.Params - } - return Params{} -} - -func (m *GenesisState) GetFeePool() FeePool { - if m != nil { - return m.FeePool - } - return FeePool{} -} - func init() { proto.RegisterType((*GenesisState)(nil), "elys.incentive.GenesisState") } @@ -85,24 +68,19 @@ func init() { func init() { proto.RegisterFile("elys/incentive/genesis.proto", fileDescriptor_83b8e7899b41b162) } var fileDescriptor_83b8e7899b41b162 = []byte{ - // 268 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x8f, 0x3f, 0x4f, 0xc3, 0x30, - 0x14, 0xc4, 0x13, 0x84, 0x0a, 0x0a, 0x88, 0x21, 0x42, 0x50, 0x05, 0x64, 0xfe, 0x4c, 0x2c, 0xd8, - 0x2a, 0x30, 0x30, 0x33, 0x00, 0x63, 0x05, 0x1b, 0x0b, 0xb2, 0xc3, 0x6b, 0xb0, 0x48, 0xfc, 0xa2, - 0xf8, 0xb5, 0xd0, 0x85, 0xcf, 0xc0, 0xc7, 0xea, 0xd8, 0x91, 0x09, 0xa1, 0xe4, 0x8b, 0xa0, 0x38, - 0x16, 0x82, 0x6c, 0x7e, 0xfa, 0xdd, 0x9d, 0xef, 0xa2, 0x7d, 0xc8, 0xe7, 0x56, 0x68, 0x93, 0x82, - 0x21, 0x3d, 0x03, 0x91, 0x81, 0x01, 0xab, 0x2d, 0x2f, 0x2b, 0x24, 0x8c, 0xb7, 0x5a, 0xca, 0x7f, - 0x69, 0xb2, 0x9d, 0x61, 0x86, 0x0e, 0x89, 0xf6, 0xd5, 0xa9, 0x92, 0xbd, 0x5e, 0x46, 0x29, 0x2b, - 0x59, 0xf8, 0x88, 0xe4, 0xa8, 0x07, 0x9f, 0xb4, 0xa5, 0x4a, 0xab, 0x29, 0x69, 0x34, 0x5e, 0xc2, - 0x52, 0xb4, 0x05, 0x5a, 0xa1, 0xa4, 0x05, 0x31, 0x1b, 0x29, 0x20, 0x39, 0x12, 0x29, 0x6a, 0xcf, - 0x8f, 0xdf, 0xa3, 0xcd, 0x9b, 0xae, 0xd6, 0x3d, 0x49, 0x82, 0xf8, 0x22, 0x1a, 0x74, 0x5f, 0x0c, - 0xc3, 0xc3, 0xf0, 0x64, 0xe3, 0x6c, 0x87, 0xff, 0xaf, 0xc9, 0xc7, 0x8e, 0x5e, 0xad, 0x2e, 0xbe, - 0x0e, 0x82, 0x3b, 0xaf, 0x8d, 0x2f, 0xa3, 0xf5, 0x09, 0xc0, 0x63, 0x89, 0x98, 0x0f, 0x57, 0x9c, - 0x6f, 0xb7, 0xef, 0xbb, 0x06, 0x18, 0x23, 0xe6, 0xde, 0xb8, 0x36, 0xf1, 0xe7, 0xed, 0xa2, 0x66, - 0xe1, 0xb2, 0x66, 0xe1, 0x77, 0xcd, 0xc2, 0x8f, 0x86, 0x05, 0xcb, 0x86, 0x05, 0x9f, 0x0d, 0x0b, - 0x1e, 0x78, 0xa6, 0xe9, 0x79, 0xaa, 0x78, 0x8a, 0x85, 0x68, 0xb3, 0x4e, 0x0d, 0xd0, 0x2b, 0x56, - 0x2f, 0xee, 0x10, 0x6f, 0x7f, 0x66, 0xd3, 0xbc, 0x04, 0xab, 0x06, 0x6e, 0xd0, 0xf9, 0x4f, 0x00, - 0x00, 0x00, 0xff, 0xff, 0xc7, 0xb6, 0xb7, 0xf0, 0x76, 0x01, 0x00, 0x00, + // 180 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x49, 0xcd, 0xa9, 0x2c, + 0xd6, 0xcf, 0xcc, 0x4b, 0x4e, 0xcd, 0x2b, 0xc9, 0x2c, 0x4b, 0xd5, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, + 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x03, 0xc9, 0xea, 0xc1, 0x65, 0xa5, + 0x44, 0xd2, 0xf3, 0xd3, 0xf3, 0xc1, 0x52, 0xfa, 0x20, 0x16, 0x44, 0x95, 0x94, 0x5c, 0x72, 0x7e, + 0x71, 0x6e, 0x7e, 0xb1, 0x7e, 0x52, 0x62, 0x71, 0xaa, 0x7e, 0x99, 0x61, 0x52, 0x6a, 0x49, 0xa2, + 0xa1, 0x7e, 0x72, 0x7e, 0x66, 0x1e, 0x44, 0x5e, 0x89, 0x8f, 0x8b, 0xc7, 0x1d, 0x62, 0x6c, 0x70, + 0x49, 0x62, 0x49, 0xaa, 0x93, 0xc7, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, + 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, + 0xe9, 0xa5, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0x83, 0xac, 0xd6, 0xcd, + 0x4b, 0x2d, 0x29, 0xcf, 0x2f, 0xca, 0x06, 0x73, 0xf4, 0x2b, 0x90, 0xdc, 0x59, 0x52, 0x59, 0x90, + 0x5a, 0x9c, 0xc4, 0x06, 0xb6, 0xc0, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0x03, 0x4b, 0x45, 0xce, + 0xc6, 0x00, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -125,26 +103,6 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - { - size, err := m.FeePool.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 } @@ -165,10 +123,6 @@ func (m *GenesisState) Size() (n int) { } var l int _ = l - l = m.Params.Size() - n += 1 + l + sovGenesis(uint64(l)) - l = m.FeePool.Size() - n += 1 + l + sovGenesis(uint64(l)) return n } @@ -207,72 +161,6 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { 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 FeePool", 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.FeePool.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) diff --git a/x/incentive/types/incentive.pb.go b/x/incentive/types/incentive.pb.go index 4c6ea845c..eb0c3a1ad 100644 --- a/x/incentive/types/incentive.pb.go +++ b/x/incentive/types/incentive.pb.go @@ -35,7 +35,7 @@ type IncentiveInfo struct { TotalBlocksPerYear github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=total_blocks_per_year,json=totalBlocksPerYear,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"total_blocks_per_year"` // unused EpochNumBlocks github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,4,opt,name=epoch_num_blocks,json=epochNumBlocks,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"epoch_num_blocks"` - // maximum eden allocation per day that won't exceed 30% apr + // unused MaxEdenPerAllocation github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,5,opt,name=max_eden_per_allocation,json=maxEdenPerAllocation,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"max_eden_per_allocation"` // unused DistributionEpochInBlocks github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,6,opt,name=distribution_epoch_in_blocks,json=distributionEpochInBlocks,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"distribution_epoch_in_blocks"` diff --git a/x/incentive/types/message_update_incentive_params.go b/x/incentive/types/message_update_incentive_params.go deleted file mode 100644 index 969188748..000000000 --- a/x/incentive/types/message_update_incentive_params.go +++ /dev/null @@ -1,75 +0,0 @@ -package types - -import ( - "errors" - - errorsmod "cosmossdk.io/errors" - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" -) - -const TypeMsgUpdateIncentiveParams = "update_incentive_params" - -var _ sdk.Msg = &MsgUpdateIncentiveParams{} - -func NewMsgUpdateIncentiveParams(creator string, rewardPortionForLps sdk.Dec, rewardPortionForStakers sdk.Dec, elysStakeSnapInterval int64, maxEdenRewardAprStakers sdk.Dec, maxEdenRewardParLps sdk.Dec, distributionInterval int64) *MsgUpdateIncentiveParams { - return &MsgUpdateIncentiveParams{ - Authority: creator, - RewardPortionForLps: rewardPortionForLps, - RewardPortionForStakers: rewardPortionForStakers, - ElysStakeSnapInterval: elysStakeSnapInterval, - MaxEdenRewardAprStakers: maxEdenRewardAprStakers, - MaxEdenRewardAprLps: maxEdenRewardParLps, - DistributionInterval: distributionInterval, - } -} - -func (msg *MsgUpdateIncentiveParams) Route() string { - return RouterKey -} - -func (msg *MsgUpdateIncentiveParams) Type() string { - return TypeMsgUpdateIncentiveParams -} - -func (msg *MsgUpdateIncentiveParams) GetSigners() []sdk.AccAddress { - creator, err := sdk.AccAddressFromBech32(msg.Authority) - if err != nil { - panic(err) - } - return []sdk.AccAddress{creator} -} - -func (msg *MsgUpdateIncentiveParams) GetSignBytes() []byte { - bz := ModuleCdc.MustMarshalJSON(msg) - return sdk.MustSortJSON(bz) -} - -func (msg *MsgUpdateIncentiveParams) ValidateBasic() error { - _, err := sdk.AccAddressFromBech32(msg.Authority) - if err != nil { - return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) - } - if msg.RewardPortionForLps.GT(sdk.NewDec(1)) { - return errorsmod.Wrapf(sdkerrors.ErrNotSupported, "invalid rewards portion for LPs (%s)", errors.New("Invalid LP portion")) - } - if msg.RewardPortionForStakers.GT(sdk.NewDec(1)) { - return errorsmod.Wrapf(sdkerrors.ErrNotSupported, "invalid rewards portion for Stakers (%s)", errors.New("Invalid Staker portion")) - } - if msg.RewardPortionForLps.Add(msg.RewardPortionForStakers).GT(sdk.NewDec(1)) { - return errorsmod.Wrapf(sdkerrors.ErrNotSupported, "invalid rewards portion for Stakers and LPs (%s)", errors.New("Invalid Staker and LP portion")) - } - if msg.MaxEdenRewardAprStakers.LT(sdk.ZeroDec()) { - return errorsmod.Wrapf(sdkerrors.ErrNotSupported, "invalid max eden rewards apr for stakers (%s)", errors.New("Invalid Rewards APR")) - } - if msg.MaxEdenRewardAprLps.LT(sdk.ZeroDec()) { - return errorsmod.Wrapf(sdkerrors.ErrNotSupported, "invalid max eden rewards apr for stakers (%s)", errors.New("Invalid Rewards APR")) - } - if msg.DistributionInterval < 1 { - return errorsmod.Wrapf(sdkerrors.ErrNotSupported, "invalid distribution epoch (%s)", errors.New("Invalid epoch")) - } - if msg.ElysStakeSnapInterval < 1 { - return errorsmod.Wrapf(sdkerrors.ErrNotSupported, "invalid elys staked tracking epoch (%s)", errors.New("Invalid elys staked tracking epoch")) - } - return nil -} diff --git a/x/incentive/types/message_update_incentive_params_test.go b/x/incentive/types/message_update_incentive_params_test.go deleted file mode 100644 index 188b42842..000000000 --- a/x/incentive/types/message_update_incentive_params_test.go +++ /dev/null @@ -1,53 +0,0 @@ -package types - -import ( - "testing" - - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/elys-network/elys/testutil/sample" - "github.com/stretchr/testify/require" -) - -func TestMsgUpdateIncentiveParams_ValidateBasic(t *testing.T) { - tests := []struct { - name string - msg MsgUpdateIncentiveParams - err error - }{ - { - name: "invalid address", - msg: MsgUpdateIncentiveParams{ - Authority: "invalid_address", - RewardPortionForLps: sdk.NewDecWithPrec(60, 2), - RewardPortionForStakers: sdk.NewDecWithPrec(30, 2), - MaxEdenRewardAprStakers: sdk.NewDecWithPrec(3, 1), - MaxEdenRewardAprLps: sdk.NewDecWithPrec(3, 1), - DistributionInterval: 10, - ElysStakeSnapInterval: 10, - }, - err: sdkerrors.ErrInvalidAddress, - }, { - name: "valid address", - msg: MsgUpdateIncentiveParams{ - Authority: sample.AccAddress(), - RewardPortionForLps: sdk.NewDecWithPrec(60, 2), - RewardPortionForStakers: sdk.NewDecWithPrec(30, 2), - MaxEdenRewardAprStakers: sdk.NewDecWithPrec(3, 1), - MaxEdenRewardAprLps: sdk.NewDecWithPrec(3, 1), - DistributionInterval: 10, - ElysStakeSnapInterval: 10, - }, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - err := tt.msg.ValidateBasic() - if tt.err != nil { - require.ErrorIs(t, err, tt.err) - return - } - require.NoError(t, err) - }) - } -} diff --git a/x/incentive/types/msg.go b/x/incentive/types/msg.go index 624b50520..ab1254f4c 100644 --- a/x/incentive/types/msg.go +++ b/x/incentive/types/msg.go @@ -1,79 +1 @@ package types - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - commitmenttypes "github.com/elys-network/elys/x/commitment/types" -) - -// distribution message types -const ( - TypeMsgWithdrawRewards = "withdraw_reward" - TypeMsgWithdrawValidatorCommission = "withdraw_validator_commission" -) - -// Verify interface at compile time -var _, _ sdk.Msg = &MsgWithdrawRewards{}, &MsgWithdrawValidatorCommission{} - -func NewMsgWithdrawRewards(delAddr sdk.AccAddress, earnType commitmenttypes.EarnType) *MsgWithdrawRewards { - return &MsgWithdrawRewards{ - DelegatorAddress: delAddr.String(), - WithdrawType: earnType, - } -} - -func (msg MsgWithdrawRewards) Route() string { return ModuleName } -func (msg MsgWithdrawRewards) Type() string { return TypeMsgWithdrawRewards } - -// Return address that must sign over msg.GetSignBytes() -func (msg MsgWithdrawRewards) GetSigners() []sdk.AccAddress { - delegator, _ := sdk.AccAddressFromBech32(msg.DelegatorAddress) - return []sdk.AccAddress{delegator} -} - -// get the bytes for the message signer to sign on -func (msg MsgWithdrawRewards) GetSignBytes() []byte { - bz := ModuleCdc.MustMarshalJSON(&msg) - return sdk.MustSortJSON(bz) -} - -// quick validity check -func (msg MsgWithdrawRewards) ValidateBasic() error { - if _, err := sdk.AccAddressFromBech32(msg.DelegatorAddress); err != nil { - return sdkerrors.ErrInvalidAddress.Wrapf("invalid delegator address: %s", err) - } - return nil -} - -func NewMsgWithdrawValidatorCommission(delAddr sdk.AccAddress, valAddr sdk.ValAddress) *MsgWithdrawValidatorCommission { - return &MsgWithdrawValidatorCommission{ - DelegatorAddress: delAddr.String(), - ValidatorAddress: valAddr.String(), - } -} - -func (msg MsgWithdrawValidatorCommission) Route() string { return ModuleName } -func (msg MsgWithdrawValidatorCommission) Type() string { return TypeMsgWithdrawValidatorCommission } - -// Return address that must sign over msg.GetSignBytes() -func (msg MsgWithdrawValidatorCommission) GetSigners() []sdk.AccAddress { - valAddr, _ := sdk.ValAddressFromBech32(msg.ValidatorAddress) - return []sdk.AccAddress{sdk.AccAddress(valAddr)} -} - -// get the bytes for the message signer to sign on -func (msg MsgWithdrawValidatorCommission) GetSignBytes() []byte { - bz := ModuleCdc.MustMarshalJSON(&msg) - return sdk.MustSortJSON(bz) -} - -// quick validity check -func (msg MsgWithdrawValidatorCommission) ValidateBasic() error { - if _, err := sdk.ValAddressFromBech32(msg.ValidatorAddress); err != nil { - return sdkerrors.ErrInvalidAddress.Wrapf("invalid validator address: %s", err) - } - if _, err := sdk.AccAddressFromBech32(msg.DelegatorAddress); err != nil { - return sdkerrors.ErrInvalidAddress.Wrapf("invalid delegator address: %s", err) - } - return nil -} diff --git a/x/incentive/types/params.go b/x/incentive/types/params.go index 4a97a470d..0f6ea58d7 100644 --- a/x/incentive/types/params.go +++ b/x/incentive/types/params.go @@ -1,110 +1,21 @@ package types import ( - "errors" - fmt "fmt" - - sdk "github.com/cosmos/cosmos-sdk/types" "gopkg.in/yaml.v2" ) -var EdenBoostApr = sdk.NewDec(1) - // NewParams creates a new Params instance -func NewParams( - lpIncentives *IncentiveInfo, - stkIncentives *IncentiveInfo, - rewardPortionForLps sdk.Dec, - rewardPortionForStakers sdk.Dec, - poolInfos []PoolInfo, - elysStakeSnapInterval int64, - dexRewardsStakers DexRewardsTracker, - dexRewardsLps DexRewardsTracker, - maxEdenRewardAprStakers sdk.Dec, - maxEdenRewardAprLps sdk.Dec, - distributionInterval int64, -) Params { - return Params{ - LpIncentives: lpIncentives, - StakeIncentives: stkIncentives, - RewardPortionForLps: rewardPortionForLps, - RewardPortionForStakers: rewardPortionForStakers, - PoolInfos: poolInfos, - ElysStakeSnapInterval: elysStakeSnapInterval, - DexRewardsStakers: dexRewardsStakers, - DexRewardsLps: dexRewardsLps, - MaxEdenRewardAprStakers: maxEdenRewardAprStakers, - MaxEdenRewardAprLps: maxEdenRewardAprLps, - DistributionInterval: distributionInterval, - } +func NewParams() Params { + return Params{} } // DefaultParams returns a default set of parameters func DefaultParams() Params { - return NewParams( - nil, - nil, - sdk.NewDecWithPrec(60, 2), - sdk.NewDecWithPrec(30, 2), - []PoolInfo(nil), - 10, - DexRewardsTracker{ - NumBlocks: sdk.NewInt(1), - Amount: sdk.ZeroDec(), - AmountCollectedByOtherTracker: sdk.ZeroDec(), - }, - DexRewardsTracker{ - NumBlocks: sdk.NewInt(1), - Amount: sdk.ZeroDec(), - AmountCollectedByOtherTracker: sdk.ZeroDec(), - }, - sdk.NewDecWithPrec(3, 1), - sdk.NewDecWithPrec(5, 1), - 10, - ) + return NewParams() } // Validate validates the set of params func (p Params) Validate() error { - if err := validateRewardPortionForLps(p.RewardPortionForLps); err != nil { - return err - } - - if err := validateRewardPortionForStakers(p.RewardPortionForStakers); err != nil { - return err - } - - if err := validateLPIncentives(p.LpIncentives); err != nil { - return err - } - - if err := validateStakeIncentives(p.StakeIncentives); err != nil { - return err - } - - if err := validatePoolInfos(p.PoolInfos); err != nil { - return err - } - - if err := validateElysStakeSnapInterval(p.ElysStakeSnapInterval); err != nil { - return err - } - - if err := validateDexRewardsStakers(p.DexRewardsStakers); err != nil { - return err - } - - if err := validateDexRewardsLps(p.DexRewardsLps); err != nil { - return err - } - - if err := validateDistributionInterval(p.DistributionInterval); err != nil { - return err - } - - if p.RewardPortionForLps.Add(p.RewardPortionForStakers).GT(sdk.NewDec(1)) { - return errors.New("invalid rewards portion parameter") - } return nil } @@ -114,159 +25,3 @@ func (p Params) String() string { out, _ := yaml.Marshal(p) return string(out) } - -func validateRewardPortionForLps(i interface{}) error { - v, ok := i.(sdk.Dec) - if !ok { - return fmt.Errorf("invalid parameter type: %T", i) - } - - if v.IsNil() { - return fmt.Errorf("reward percent for lp must be not nil") - } - if v.IsNegative() { - return fmt.Errorf("reward percent for lp must be positive: %s", v) - } - if v.GT(sdk.OneDec()) { - return fmt.Errorf("reward percent for lp too large: %s", v) - } - - return nil -} - -func validateRewardPortionForStakers(i interface{}) error { - v, ok := i.(sdk.Dec) - if !ok { - return fmt.Errorf("invalid parameter type: %T", i) - } - - if v.IsNil() { - return fmt.Errorf("reward percent for lp must be not nil") - } - if v.IsNegative() { - return fmt.Errorf("reward percent for lp must be positive: %s", v) - } - if v.GT(sdk.OneDec()) { - return fmt.Errorf("reward percent for lp too large: %s", v) - } - - return nil -} - -func validateLPIncentives(i interface{}) error { - vv, ok := i.(*IncentiveInfo) - if !ok { - return fmt.Errorf("invalid parameter type: %T", i) - } - if vv == nil { - return nil - } - - if vv.EdenAmountPerYear.LTE(sdk.ZeroInt()) { - return fmt.Errorf("invalid eden amount per year: %v", vv) - } - - if vv.TotalBlocksPerYear.LT(sdk.NewInt(1)) { - return fmt.Errorf("invalid total blocks per year: %v", vv) - } - - if vv.CurrentEpochInBlocks.LT(sdk.NewInt(0)) { - return fmt.Errorf("invalid current epoch: %v", vv) - } - - if vv.DistributionStartBlock.LT(sdk.NewInt(0)) { - return fmt.Errorf("invalid distribution epoch: %v", vv) - } - - return nil -} - -func validateStakeIncentives(i interface{}) error { - vv, ok := i.(*IncentiveInfo) - if !ok { - return fmt.Errorf("invalid parameter type: %T", i) - } - if vv == nil { - return nil - } - - if vv.EdenAmountPerYear.LTE(sdk.ZeroInt()) { - return fmt.Errorf("invalid eden amount per year: %v", vv) - } - - if vv.TotalBlocksPerYear.LT(sdk.NewInt(1)) { - return fmt.Errorf("invalid total blocks per year: %v", vv) - } - - if vv.CurrentEpochInBlocks.LT(sdk.NewInt(0)) { - return fmt.Errorf("invalid current epoch: %v", vv) - } - - if vv.DistributionStartBlock.LT(sdk.NewInt(0)) { - return fmt.Errorf("invalid distribution epoch: %v", vv) - } - - return nil -} - -func validatePoolInfos(i interface{}) error { - _, ok := i.([]PoolInfo) - if !ok { - return fmt.Errorf("invalid parameter type: %T", i) - } - - return nil -} - -func validateElysStakeSnapInterval(i interface{}) error { - _, ok := i.(int64) - if !ok { - return fmt.Errorf("invalid parameter type: %T", i) - } - - return nil -} - -func validateDexRewardsStakers(i interface{}) error { - _, ok := i.(DexRewardsTracker) - if !ok { - return fmt.Errorf("invalid parameter type: %T", i) - } - - return nil -} - -func validateDexRewardsLps(i interface{}) error { - _, ok := i.(DexRewardsTracker) - if !ok { - return fmt.Errorf("invalid parameter type: %T", i) - } - - return nil -} - -func validateEdenRewardApr(i interface{}) error { - v, ok := i.(sdk.Dec) - if !ok { - return fmt.Errorf("invalid parameter type: %T", i) - } - - if v.IsNegative() { - return fmt.Errorf("invalid parameter type: %T", i) - } - - return nil -} - -func validateDistributionInterval(i interface{}) error { - v, ok := i.(int64) - if !ok { - return fmt.Errorf("invalid parameter type: %T", i) - } - - if v == 0 { - return fmt.Errorf("invalid parameter type: %T", i) - } - - return nil -} diff --git a/x/incentive/types/params.pb.go b/x/incentive/types/params.pb.go index e6d6a4e31..1ace7ef60 100644 --- a/x/incentive/types/params.pb.go +++ b/x/incentive/types/params.pb.go @@ -28,9 +28,11 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Params struct { LpIncentives *IncentiveInfo `protobuf:"bytes,1,opt,name=lp_incentives,json=lpIncentives,proto3" json:"lp_incentives,omitempty"` StakeIncentives *IncentiveInfo `protobuf:"bytes,2,opt,name=stake_incentives,json=stakeIncentives,proto3" json:"stake_incentives,omitempty"` - // Dex revenue percent for lps, `100 - reward_portion_for_lps - reward_portion_for_stakers = revenue percent for protocol`. + // Dex revenue percent for lps, `100 - reward_portion_for_lps - + // reward_portion_for_stakers = revenue percent for protocol`. RewardPortionForLps github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=reward_portion_for_lps,json=rewardPortionForLps,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"reward_portion_for_lps"` - // Dex revenue percent for lps, `100 - reward_portion_for_lps - reward_portion_for_stakers = revenue percent for protocol`. + // Dex revenue percent for lps, `100 - reward_portion_for_lps - + // reward_portion_for_stakers = revenue percent for protocol`. RewardPortionForStakers github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,4,opt,name=reward_portion_for_stakers,json=rewardPortionForStakers,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"reward_portion_for_stakers"` // Pool information // poolId, reward wallet, **multiplier**, dex rewards given diff --git a/x/incentive/types/params_test.go b/x/incentive/types/params_test.go deleted file mode 100644 index ba5052636..000000000 --- a/x/incentive/types/params_test.go +++ /dev/null @@ -1,35 +0,0 @@ -package types_test - -import ( - "testing" - - "github.com/stretchr/testify/require" - - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/elys-network/elys/x/incentive/types" -) - -func Test_validateParams(t *testing.T) { - params := types.DefaultParams() - - // default params have no error - require.NoError(t, params.Validate()) - - // validate mincommision - params.RewardPortionForLps = sdk.NewDecWithPrec(12, 1) - require.Error(t, params.Validate()) - - lpIncentive := types.IncentiveInfo{ - // reward amount in eden for 1 year - EdenAmountPerYear: sdk.NewInt(10000000000000), - // starting block height of the distribution - DistributionStartBlock: sdk.ZeroInt(), - // distribution duration - block number per year - TotalBlocksPerYear: sdk.NewInt(10512000), - // current epoch in block number - CurrentEpochInBlocks: sdk.NewInt(0), - } - - params.LpIncentives = &lpIncentive - require.Error(t, params.Validate()) -} diff --git a/x/incentive/types/query.pb.go b/x/incentive/types/query.pb.go index 0158543d8..bba038b83 100644 --- a/x/incentive/types/query.pb.go +++ b/x/incentive/types/query.pb.go @@ -6,13 +6,14 @@ package types import ( context "context" fmt "fmt" + _ "github.com/cosmos/cosmos-proto" github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" - types "github.com/cosmos/cosmos-sdk/types" + types1 "github.com/cosmos/cosmos-sdk/types" query "github.com/cosmos/cosmos-sdk/types/query" _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" - types1 "github.com/elys-network/elys/x/commitment/types" + types "github.com/elys-network/elys/x/commitment/types" _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" @@ -33,180 +34,16 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// 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_29b04b3fcad26af2, []int{0} -} -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 holds all the parameters of this module. - 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_29b04b3fcad26af2, []int{1} -} -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{} -} - -type QueryCommunityPoolRequest struct { -} - -func (m *QueryCommunityPoolRequest) Reset() { *m = QueryCommunityPoolRequest{} } -func (m *QueryCommunityPoolRequest) String() string { return proto.CompactTextString(m) } -func (*QueryCommunityPoolRequest) ProtoMessage() {} -func (*QueryCommunityPoolRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_29b04b3fcad26af2, []int{2} -} -func (m *QueryCommunityPoolRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryCommunityPoolRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryCommunityPoolRequest.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 *QueryCommunityPoolRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryCommunityPoolRequest.Merge(m, src) -} -func (m *QueryCommunityPoolRequest) XXX_Size() int { - return m.Size() -} -func (m *QueryCommunityPoolRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryCommunityPoolRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryCommunityPoolRequest proto.InternalMessageInfo - -type QueryCommunityPoolResponse struct { - // pool defines community pool's coins. - Pool github_com_cosmos_cosmos_sdk_types.DecCoins `protobuf:"bytes,1,rep,name=pool,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.DecCoins" json:"pool"` -} - -func (m *QueryCommunityPoolResponse) Reset() { *m = QueryCommunityPoolResponse{} } -func (m *QueryCommunityPoolResponse) String() string { return proto.CompactTextString(m) } -func (*QueryCommunityPoolResponse) ProtoMessage() {} -func (*QueryCommunityPoolResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_29b04b3fcad26af2, []int{3} -} -func (m *QueryCommunityPoolResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryCommunityPoolResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryCommunityPoolResponse.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 *QueryCommunityPoolResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryCommunityPoolResponse.Merge(m, src) -} -func (m *QueryCommunityPoolResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryCommunityPoolResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryCommunityPoolResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryCommunityPoolResponse proto.InternalMessageInfo - -func (m *QueryCommunityPoolResponse) GetPool() github_com_cosmos_cosmos_sdk_types.DecCoins { - if m != nil { - return m.Pool - } - return nil -} - type QueryAprRequest struct { - WithdrawType types1.EarnType `protobuf:"varint,1,opt,name=withdraw_type,json=withdrawType,proto3,enum=elys.commitment.EarnType" json:"withdraw_type,omitempty"` - Denom string `protobuf:"bytes,2,opt,name=denom,proto3" json:"denom,omitempty"` + WithdrawType types.EarnType `protobuf:"varint,1,opt,name=withdraw_type,json=withdrawType,proto3,enum=elys.commitment.EarnType" json:"withdraw_type,omitempty"` + Denom string `protobuf:"bytes,2,opt,name=denom,proto3" json:"denom,omitempty"` } func (m *QueryAprRequest) Reset() { *m = QueryAprRequest{} } func (m *QueryAprRequest) String() string { return proto.CompactTextString(m) } func (*QueryAprRequest) ProtoMessage() {} func (*QueryAprRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_29b04b3fcad26af2, []int{4} + return fileDescriptor_29b04b3fcad26af2, []int{0} } func (m *QueryAprRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -235,11 +72,11 @@ func (m *QueryAprRequest) XXX_DiscardUnknown() { var xxx_messageInfo_QueryAprRequest proto.InternalMessageInfo -func (m *QueryAprRequest) GetWithdrawType() types1.EarnType { +func (m *QueryAprRequest) GetWithdrawType() types.EarnType { if m != nil { return m.WithdrawType } - return types1.EarnType_ALL_PROGRAM + return types.EarnType_ALL_PROGRAM } func (m *QueryAprRequest) GetDenom() string { @@ -257,7 +94,7 @@ func (m *QueryAprResponse) Reset() { *m = QueryAprResponse{} } func (m *QueryAprResponse) String() string { return proto.CompactTextString(m) } func (*QueryAprResponse) ProtoMessage() {} func (*QueryAprResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_29b04b3fcad26af2, []int{5} + return fileDescriptor_29b04b3fcad26af2, []int{1} } func (m *QueryAprResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -293,7 +130,7 @@ func (m *QueryAprsRequest) Reset() { *m = QueryAprsRequest{} } func (m *QueryAprsRequest) String() string { return proto.CompactTextString(m) } func (*QueryAprsRequest) ProtoMessage() {} func (*QueryAprsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_29b04b3fcad26af2, []int{6} + return fileDescriptor_29b04b3fcad26af2, []int{2} } func (m *QueryAprsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -339,7 +176,7 @@ func (m *QueryAprsResponse) Reset() { *m = QueryAprsResponse{} } func (m *QueryAprsResponse) String() string { return proto.CompactTextString(m) } func (*QueryAprsResponse) ProtoMessage() {} func (*QueryAprsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_29b04b3fcad26af2, []int{7} + return fileDescriptor_29b04b3fcad26af2, []int{3} } func (m *QueryAprsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -368,22 +205,22 @@ func (m *QueryAprsResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryAprsResponse proto.InternalMessageInfo -type QueryPoolAprsRequest struct { - PoolIds []uint64 `protobuf:"varint,1,rep,packed,name=pool_ids,json=poolIds,proto3" json:"pool_ids,omitempty"` +type QueryAllProgramRewardsRequest struct { + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` } -func (m *QueryPoolAprsRequest) Reset() { *m = QueryPoolAprsRequest{} } -func (m *QueryPoolAprsRequest) String() string { return proto.CompactTextString(m) } -func (*QueryPoolAprsRequest) ProtoMessage() {} -func (*QueryPoolAprsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_29b04b3fcad26af2, []int{8} +func (m *QueryAllProgramRewardsRequest) Reset() { *m = QueryAllProgramRewardsRequest{} } +func (m *QueryAllProgramRewardsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryAllProgramRewardsRequest) ProtoMessage() {} +func (*QueryAllProgramRewardsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_29b04b3fcad26af2, []int{4} } -func (m *QueryPoolAprsRequest) XXX_Unmarshal(b []byte) error { +func (m *QueryAllProgramRewardsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryPoolAprsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryAllProgramRewardsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryPoolAprsRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryAllProgramRewardsRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -393,41 +230,44 @@ func (m *QueryPoolAprsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte return b[:n], nil } } -func (m *QueryPoolAprsRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryPoolAprsRequest.Merge(m, src) +func (m *QueryAllProgramRewardsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAllProgramRewardsRequest.Merge(m, src) } -func (m *QueryPoolAprsRequest) XXX_Size() int { +func (m *QueryAllProgramRewardsRequest) XXX_Size() int { return m.Size() } -func (m *QueryPoolAprsRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryPoolAprsRequest.DiscardUnknown(m) +func (m *QueryAllProgramRewardsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAllProgramRewardsRequest.DiscardUnknown(m) } -var xxx_messageInfo_QueryPoolAprsRequest proto.InternalMessageInfo +var xxx_messageInfo_QueryAllProgramRewardsRequest proto.InternalMessageInfo -func (m *QueryPoolAprsRequest) GetPoolIds() []uint64 { +func (m *QueryAllProgramRewardsRequest) GetAddress() string { if m != nil { - return m.PoolIds + return m.Address } - return nil + return "" } -type QueryPoolAprsResponse struct { - Data []PoolApr `protobuf:"bytes,1,rep,name=data,proto3" json:"data"` +type QueryAllProgramRewardsResponse struct { + UsdcStakingRewards github_com_cosmos_cosmos_sdk_types.DecCoins `protobuf:"bytes,1,rep,name=usdc_staking_rewards,json=usdcStakingRewards,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.DecCoins" json:"usdc_staking_rewards"` + ElysStakingRewards github_com_cosmos_cosmos_sdk_types.DecCoins `protobuf:"bytes,2,rep,name=elys_staking_rewards,json=elysStakingRewards,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.DecCoins" json:"elys_staking_rewards"` + EdenStakingRewards github_com_cosmos_cosmos_sdk_types.DecCoins `protobuf:"bytes,3,rep,name=eden_staking_rewards,json=edenStakingRewards,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.DecCoins" json:"eden_staking_rewards"` + EdenbStakingRewards github_com_cosmos_cosmos_sdk_types.DecCoins `protobuf:"bytes,4,rep,name=edenb_staking_rewards,json=edenbStakingRewards,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.DecCoins" json:"edenb_staking_rewards"` } -func (m *QueryPoolAprsResponse) Reset() { *m = QueryPoolAprsResponse{} } -func (m *QueryPoolAprsResponse) String() string { return proto.CompactTextString(m) } -func (*QueryPoolAprsResponse) ProtoMessage() {} -func (*QueryPoolAprsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_29b04b3fcad26af2, []int{9} +func (m *QueryAllProgramRewardsResponse) Reset() { *m = QueryAllProgramRewardsResponse{} } +func (m *QueryAllProgramRewardsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryAllProgramRewardsResponse) ProtoMessage() {} +func (*QueryAllProgramRewardsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_29b04b3fcad26af2, []int{5} } -func (m *QueryPoolAprsResponse) XXX_Unmarshal(b []byte) error { +func (m *QueryAllProgramRewardsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryPoolAprsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryAllProgramRewardsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryPoolAprsResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryAllProgramRewardsResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -437,68 +277,44 @@ func (m *QueryPoolAprsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byt return b[:n], nil } } -func (m *QueryPoolAprsResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryPoolAprsResponse.Merge(m, src) +func (m *QueryAllProgramRewardsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAllProgramRewardsResponse.Merge(m, src) } -func (m *QueryPoolAprsResponse) XXX_Size() int { +func (m *QueryAllProgramRewardsResponse) XXX_Size() int { return m.Size() } -func (m *QueryPoolAprsResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryPoolAprsResponse.DiscardUnknown(m) +func (m *QueryAllProgramRewardsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAllProgramRewardsResponse.DiscardUnknown(m) } -var xxx_messageInfo_QueryPoolAprsResponse proto.InternalMessageInfo +var xxx_messageInfo_QueryAllProgramRewardsResponse proto.InternalMessageInfo -func (m *QueryPoolAprsResponse) GetData() []PoolApr { +func (m *QueryAllProgramRewardsResponse) GetUsdcStakingRewards() github_com_cosmos_cosmos_sdk_types.DecCoins { if m != nil { - return m.Data + return m.UsdcStakingRewards } return nil } -type PoolApr struct { - PoolId uint64 `protobuf:"varint,1,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty"` - Apr github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=apr,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"apr"` +func (m *QueryAllProgramRewardsResponse) GetElysStakingRewards() github_com_cosmos_cosmos_sdk_types.DecCoins { + if m != nil { + return m.ElysStakingRewards + } + return nil } -func (m *PoolApr) Reset() { *m = PoolApr{} } -func (m *PoolApr) String() string { return proto.CompactTextString(m) } -func (*PoolApr) ProtoMessage() {} -func (*PoolApr) Descriptor() ([]byte, []int) { - return fileDescriptor_29b04b3fcad26af2, []int{10} -} -func (m *PoolApr) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *PoolApr) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_PoolApr.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 *QueryAllProgramRewardsResponse) GetEdenStakingRewards() github_com_cosmos_cosmos_sdk_types.DecCoins { + if m != nil { + return m.EdenStakingRewards } + return nil } -func (m *PoolApr) XXX_Merge(src proto.Message) { - xxx_messageInfo_PoolApr.Merge(m, src) -} -func (m *PoolApr) XXX_Size() int { - return m.Size() -} -func (m *PoolApr) XXX_DiscardUnknown() { - xxx_messageInfo_PoolApr.DiscardUnknown(m) -} - -var xxx_messageInfo_PoolApr proto.InternalMessageInfo -func (m *PoolApr) GetPoolId() uint64 { +func (m *QueryAllProgramRewardsResponse) GetEdenbStakingRewards() github_com_cosmos_cosmos_sdk_types.DecCoins { if m != nil { - return m.PoolId + return m.EdenbStakingRewards } - return 0 + return nil } type QueryPoolRewardsRequest struct { @@ -510,7 +326,7 @@ func (m *QueryPoolRewardsRequest) Reset() { *m = QueryPoolRewardsRequest func (m *QueryPoolRewardsRequest) String() string { return proto.CompactTextString(m) } func (*QueryPoolRewardsRequest) ProtoMessage() {} func (*QueryPoolRewardsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_29b04b3fcad26af2, []int{11} + return fileDescriptor_29b04b3fcad26af2, []int{6} } func (m *QueryPoolRewardsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -563,7 +379,7 @@ func (m *PoolRewards) Reset() { *m = PoolRewards{} } func (m *PoolRewards) String() string { return proto.CompactTextString(m) } func (*PoolRewards) ProtoMessage() {} func (*PoolRewards) Descriptor() ([]byte, []int) { - return fileDescriptor_29b04b3fcad26af2, []int{12} + return fileDescriptor_29b04b3fcad26af2, []int{7} } func (m *PoolRewards) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -614,7 +430,7 @@ func (m *QueryPoolRewardsResponse) Reset() { *m = QueryPoolRewardsRespon func (m *QueryPoolRewardsResponse) String() string { return proto.CompactTextString(m) } func (*QueryPoolRewardsResponse) ProtoMessage() {} func (*QueryPoolRewardsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_29b04b3fcad26af2, []int{13} + return fileDescriptor_29b04b3fcad26af2, []int{8} } func (m *QueryPoolRewardsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -651,17 +467,12 @@ func (m *QueryPoolRewardsResponse) GetPools() []PoolRewards { } func init() { - proto.RegisterType((*QueryParamsRequest)(nil), "elys.incentive.QueryParamsRequest") - proto.RegisterType((*QueryParamsResponse)(nil), "elys.incentive.QueryParamsResponse") - proto.RegisterType((*QueryCommunityPoolRequest)(nil), "elys.incentive.QueryCommunityPoolRequest") - proto.RegisterType((*QueryCommunityPoolResponse)(nil), "elys.incentive.QueryCommunityPoolResponse") proto.RegisterType((*QueryAprRequest)(nil), "elys.incentive.QueryAprRequest") proto.RegisterType((*QueryAprResponse)(nil), "elys.incentive.QueryAprResponse") proto.RegisterType((*QueryAprsRequest)(nil), "elys.incentive.QueryAprsRequest") proto.RegisterType((*QueryAprsResponse)(nil), "elys.incentive.QueryAprsResponse") - proto.RegisterType((*QueryPoolAprsRequest)(nil), "elys.incentive.QueryPoolAprsRequest") - proto.RegisterType((*QueryPoolAprsResponse)(nil), "elys.incentive.QueryPoolAprsResponse") - proto.RegisterType((*PoolApr)(nil), "elys.incentive.PoolApr") + proto.RegisterType((*QueryAllProgramRewardsRequest)(nil), "elys.incentive.QueryAllProgramRewardsRequest") + proto.RegisterType((*QueryAllProgramRewardsResponse)(nil), "elys.incentive.QueryAllProgramRewardsResponse") proto.RegisterType((*QueryPoolRewardsRequest)(nil), "elys.incentive.QueryPoolRewardsRequest") proto.RegisterType((*PoolRewards)(nil), "elys.incentive.PoolRewards") proto.RegisterType((*QueryPoolRewardsResponse)(nil), "elys.incentive.QueryPoolRewardsResponse") @@ -670,71 +481,67 @@ func init() { func init() { proto.RegisterFile("elys/incentive/query.proto", fileDescriptor_29b04b3fcad26af2) } var fileDescriptor_29b04b3fcad26af2 = []byte{ - // 1024 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x56, 0x4f, 0x6f, 0xe3, 0x44, - 0x14, 0xaf, 0x9b, 0x34, 0x6d, 0x5f, 0xda, 0x02, 0x43, 0xa1, 0xa9, 0x5b, 0xa5, 0xad, 0xcb, 0x96, - 0x74, 0xab, 0xda, 0x24, 0x45, 0x02, 0x71, 0x40, 0xbb, 0xdd, 0x5d, 0xc4, 0xc2, 0x81, 0x62, 0xba, - 0x17, 0x2e, 0xd1, 0xc4, 0x1e, 0x65, 0xad, 0x8d, 0x3d, 0x5e, 0x8f, 0xd3, 0x12, 0x2d, 0xcb, 0x01, - 0x0e, 0x48, 0x9c, 0x90, 0xf6, 0xc8, 0x37, 0xe0, 0x93, 0xac, 0x38, 0xad, 0xc4, 0x05, 0x71, 0x28, - 0xa8, 0x45, 0xe2, 0x6b, 0xa0, 0xf9, 0xe3, 0xc4, 0x4e, 0xdd, 0xb4, 0x24, 0xa7, 0x64, 0x66, 0xde, - 0xfb, 0xfd, 0x19, 0xcf, 0xbc, 0x37, 0xa0, 0x93, 0x4e, 0x8f, 0x59, 0x5e, 0xe0, 0x90, 0x20, 0xf6, - 0x4e, 0x88, 0xf5, 0xb4, 0x4b, 0xa2, 0x9e, 0x19, 0x46, 0x34, 0xa6, 0x68, 0x89, 0xaf, 0x99, 0xfd, - 0x35, 0x7d, 0x6d, 0x28, 0x36, 0xc4, 0x11, 0xf6, 0x99, 0x0c, 0xd6, 0xb7, 0x86, 0x16, 0x5d, 0x8f, - 0xc5, 0x91, 0xd7, 0xea, 0xc6, 0x1e, 0x0d, 0x54, 0xc8, 0x72, 0x9b, 0xb6, 0xa9, 0xf8, 0x6b, 0xf1, - 0x7f, 0x6a, 0x76, 0xbd, 0x4d, 0x69, 0xbb, 0x43, 0x2c, 0x1c, 0x7a, 0x16, 0x0e, 0x02, 0x1a, 0x63, - 0x9e, 0x92, 0xc0, 0x56, 0x1d, 0xca, 0x7c, 0xca, 0xac, 0x16, 0x66, 0xc4, 0x3a, 0xa9, 0xb7, 0x48, - 0x8c, 0xeb, 0x96, 0x43, 0xbd, 0x04, 0xf3, 0x76, 0x7a, 0x5d, 0x88, 0xef, 0x47, 0x85, 0xb8, 0xed, - 0x05, 0x38, 0xc5, 0xbf, 0x2e, 0x24, 0x3a, 0xd4, 0xf7, 0xbd, 0xd8, 0x27, 0x41, 0x9c, 0x31, 0x60, - 0x2c, 0x03, 0xfa, 0x92, 0xe7, 0x1f, 0x89, 0x49, 0x9b, 0x3c, 0xed, 0x12, 0x16, 0x1b, 0x9f, 0xc3, - 0x9b, 0x99, 0x59, 0x16, 0xd2, 0x80, 0x11, 0xf4, 0x3e, 0x94, 0x64, 0x72, 0x45, 0xdb, 0xd4, 0x6a, - 0xe5, 0xc6, 0xdb, 0x66, 0x76, 0xaf, 0x4c, 0x19, 0x7f, 0x58, 0x7c, 0x79, 0xb6, 0x31, 0x65, 0xab, - 0x58, 0x63, 0x0d, 0x56, 0x05, 0xd8, 0x3d, 0xea, 0xfb, 0xdd, 0xc0, 0x8b, 0x7b, 0x47, 0x94, 0x76, - 0x12, 0xa6, 0x1f, 0x34, 0xd0, 0xf3, 0x56, 0x15, 0x23, 0x81, 0x62, 0x48, 0x69, 0xa7, 0xa2, 0x6d, - 0x16, 0x6a, 0xe5, 0xc6, 0xba, 0x29, 0x7d, 0x9b, 0xdc, 0xb7, 0xa9, 0x1c, 0x9b, 0xf7, 0x89, 0x73, - 0x8f, 0x7a, 0xc1, 0xe1, 0x01, 0x67, 0xfd, 0xf5, 0xaf, 0x8d, 0xbd, 0xb6, 0x17, 0x3f, 0xee, 0xb6, - 0x4c, 0x87, 0xfa, 0x96, 0xda, 0x27, 0xf9, 0xb3, 0xcf, 0xdc, 0x27, 0x56, 0xdc, 0x0b, 0x09, 0x4b, - 0x72, 0x98, 0x2d, 0xe0, 0x8d, 0x36, 0xbc, 0x26, 0x44, 0xdc, 0x0d, 0x23, 0x25, 0x0c, 0x7d, 0x0c, - 0x8b, 0xa7, 0x5e, 0xfc, 0xd8, 0x8d, 0xf0, 0x69, 0x93, 0xe7, 0x08, 0xcb, 0x4b, 0x8d, 0x55, 0x69, - 0x79, 0xb0, 0x9d, 0xe6, 0x03, 0x1c, 0x05, 0xc7, 0xbd, 0x90, 0xd8, 0x0b, 0x49, 0x3c, 0x1f, 0xa1, - 0x65, 0x98, 0x71, 0x49, 0x40, 0xfd, 0xca, 0xf4, 0xa6, 0x56, 0x9b, 0xb7, 0xe5, 0xc0, 0x38, 0x86, - 0xd7, 0x07, 0x44, 0xca, 0xe3, 0x1d, 0x28, 0xe0, 0x30, 0x12, 0xf8, 0xf3, 0x87, 0x26, 0x37, 0xf1, - 0xe7, 0xd9, 0xc6, 0xce, 0x0d, 0x4c, 0x3c, 0x0c, 0x62, 0x9b, 0xa7, 0x1a, 0x68, 0x80, 0xda, 0xff, - 0x84, 0x17, 0x25, 0x78, 0x23, 0x35, 0xa9, 0xb8, 0x6c, 0x58, 0xec, 0x32, 0xd7, 0x69, 0xe2, 0x30, - 0x6a, 0xf2, 0x3f, 0x63, 0xb2, 0x96, 0x79, 0xee, 0xdd, 0x30, 0x7a, 0xc4, 0x5c, 0x87, 0x63, 0x12, - 0x97, 0x04, 0x03, 0xcc, 0xe9, 0xf1, 0x30, 0x39, 0x48, 0x82, 0x79, 0x0c, 0x4b, 0x7d, 0x9d, 0x7c, - 0xbe, 0x55, 0x29, 0x8c, 0x05, 0xba, 0xa0, 0x84, 0x3e, 0xe0, 0x18, 0x1c, 0xb5, 0xaf, 0x54, 0xa2, - 0x16, 0xc7, 0x43, 0x55, 0x52, 0x25, 0x6a, 0x7a, 0x4f, 0xf9, 0x42, 0x65, 0x66, 0xa2, 0x3d, 0xe5, - 0xa0, 0x99, 0x3d, 0x15, 0x98, 0xa5, 0x89, 0xf6, 0x54, 0x60, 0x2a, 0xf7, 0xad, 0x01, 0xe8, 0xec, - 0xf8, 0xee, 0x5b, 0x29, 0xa5, 0x03, 0xf7, 0x9d, 0x1e, 0xab, 0xcc, 0x4d, 0xe6, 0xbe, 0xd3, 0x63, - 0x59, 0xf7, 0x1c, 0x73, 0x7e, 0x32, 0xf7, 0x1c, 0x33, 0xeb, 0x9e, 0x83, 0xc2, 0x84, 0xee, 0x3b, - 0x3d, 0x66, 0xd4, 0x61, 0x59, 0x16, 0x4a, 0x4a, 0x3b, 0xa9, 0xdb, 0x87, 0x56, 0x61, 0x8e, 0x17, - 0x96, 0xa6, 0xe7, 0x32, 0x51, 0xbb, 0x8a, 0xf6, 0x2c, 0x1f, 0x3f, 0x74, 0x99, 0xf1, 0x19, 0xbc, - 0x35, 0x94, 0xa2, 0xee, 0x66, 0x1d, 0x8a, 0x2e, 0x8e, 0xb1, 0xaa, 0x75, 0x2b, 0x97, 0x6a, 0xab, - 0x8c, 0x57, 0xc5, 0x55, 0x84, 0x1a, 0x2e, 0xcc, 0xaa, 0x69, 0xb4, 0x02, 0xb3, 0x8a, 0x51, 0xdc, - 0xe9, 0xa2, 0x5d, 0x92, 0x84, 0x49, 0x79, 0xf9, 0xff, 0x97, 0xf2, 0x3e, 0x71, 0x64, 0x79, 0xf9, - 0x16, 0x56, 0xfa, 0x8a, 0x6d, 0x72, 0x8a, 0x23, 0xf7, 0x06, 0x3e, 0xd1, 0x27, 0x00, 0x83, 0x5e, - 0x24, 0xe8, 0xcb, 0x8d, 0x9d, 0x4c, 0x01, 0x97, 0x5d, 0x37, 0x29, 0xe3, 0x47, 0xb8, 0x4d, 0x14, - 0xac, 0x9d, 0xca, 0x34, 0xfe, 0xd5, 0xa0, 0x9c, 0x62, 0xbe, 0xda, 0xe8, 0x17, 0x50, 0x8e, 0x64, - 0x0c, 0x2f, 0x43, 0x63, 0x1a, 0x06, 0x05, 0xf1, 0x88, 0xb9, 0x28, 0x80, 0x05, 0x39, 0x6a, 0xf2, - 0xd6, 0xcb, 0x2a, 0x05, 0xf1, 0x61, 0x56, 0x73, 0x9b, 0x90, 0xe8, 0x40, 0xef, 0xa9, 0x0e, 0x54, - 0xbb, 0x01, 0x99, 0x6c, 0x3f, 0x4a, 0xb1, 0x18, 0x18, 0x5f, 0x41, 0xe5, 0xf2, 0x3e, 0xab, 0xc3, - 0xf1, 0x01, 0xcc, 0x70, 0x9b, 0x4c, 0x9d, 0x8e, 0xb5, 0xbc, 0xd3, 0xa1, 0x72, 0xd4, 0x09, 0x91, - 0xf1, 0x8d, 0xdf, 0x4a, 0x30, 0x23, 0x50, 0xd1, 0x77, 0x50, 0x92, 0xfd, 0x19, 0x19, 0xc3, 0xd9, - 0x97, 0x9f, 0x00, 0xfa, 0xf6, 0xc8, 0x18, 0xa9, 0xca, 0xd8, 0xfb, 0xfe, 0xf7, 0x7f, 0x5e, 0x4c, - 0xdf, 0x42, 0xdb, 0x16, 0x0f, 0xde, 0x0f, 0x48, 0x7c, 0x4a, 0xa3, 0x27, 0x56, 0xee, 0x8b, 0x09, - 0xfd, 0xa2, 0xc1, 0x62, 0xa6, 0xcb, 0xa3, 0xdd, 0x5c, 0x8e, 0xbc, 0x77, 0x82, 0x7e, 0xfb, 0x26, - 0xa1, 0x4a, 0xd5, 0x81, 0x50, 0xb5, 0x8f, 0xf6, 0x46, 0xaa, 0x72, 0x92, 0xdc, 0x26, 0xdf, 0x28, - 0xf4, 0x93, 0x06, 0x05, 0x7e, 0x8f, 0x36, 0x72, 0x89, 0x06, 0x0f, 0x03, 0x7d, 0xf3, 0xea, 0x00, - 0xc5, 0x7f, 0x47, 0xf0, 0x7f, 0x84, 0x3e, 0x1c, 0xc9, 0x8f, 0xc3, 0xc8, 0x7a, 0x96, 0x79, 0x62, - 0x3c, 0xb7, 0x9e, 0x89, 0x57, 0xc2, 0x73, 0x74, 0x02, 0x45, 0x5e, 0x1a, 0xd0, 0x95, 0x5c, 0xfd, - 0xcf, 0xb4, 0x35, 0x22, 0x42, 0xc9, 0xd9, 0x15, 0x72, 0xb6, 0xd1, 0xd6, 0x75, 0x72, 0x18, 0xfa, - 0x51, 0x83, 0xb9, 0xa4, 0x2e, 0xa1, 0x77, 0xf2, 0x4f, 0x40, 0xb6, 0xd2, 0xe9, 0xb7, 0xae, 0x89, - 0x52, 0x22, 0x4c, 0x21, 0xa2, 0x86, 0x76, 0x46, 0x9f, 0x14, 0x7e, 0xb1, 0x85, 0x92, 0x17, 0x43, - 0xb7, 0xfe, 0xdd, 0x2b, 0x69, 0xb2, 0x15, 0x49, 0xaf, 0x5d, 0x1f, 0xa8, 0x24, 0xd5, 0x85, 0xa4, - 0x3d, 0xb4, 0x7b, 0xbd, 0x24, 0x55, 0x14, 0x0e, 0x3f, 0x7d, 0x79, 0x5e, 0xd5, 0x5e, 0x9d, 0x57, - 0xb5, 0xbf, 0xcf, 0xab, 0xda, 0xcf, 0x17, 0xd5, 0xa9, 0x57, 0x17, 0xd5, 0xa9, 0x3f, 0x2e, 0xaa, - 0x53, 0x5f, 0x9b, 0xa9, 0x2b, 0x7f, 0x19, 0xee, 0x9b, 0x14, 0xa0, 0xb8, 0xfe, 0xad, 0x92, 0x78, - 0x7e, 0x1f, 0xfc, 0x17, 0x00, 0x00, 0xff, 0xff, 0x2f, 0xba, 0x82, 0xf7, 0x8a, 0x0c, 0x00, 0x00, + // 953 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x96, 0x41, 0x6f, 0xdc, 0x44, + 0x14, 0xc7, 0xe3, 0xec, 0x26, 0x69, 0x66, 0xd3, 0x40, 0x87, 0xa0, 0x3a, 0x4b, 0x71, 0x52, 0x23, + 0x95, 0x2d, 0x55, 0xec, 0x66, 0x7b, 0xa0, 0x70, 0x40, 0x4d, 0x68, 0x11, 0x3d, 0x11, 0xdc, 0xf4, + 0xc2, 0x65, 0x35, 0x6b, 0x8f, 0x5c, 0x2b, 0xde, 0x19, 0x77, 0xc6, 0x49, 0x58, 0x95, 0x5e, 0x40, + 0x5c, 0x38, 0x21, 0xf5, 0x5b, 0x20, 0x3e, 0x01, 0x9f, 0xa0, 0xc7, 0x22, 0x2e, 0x88, 0x43, 0x41, + 0x09, 0x12, 0x5f, 0x03, 0xbd, 0x99, 0x71, 0xd6, 0xeb, 0xcd, 0xa6, 0xd1, 0xae, 0x72, 0xca, 0x8e, + 0xe7, 0xbd, 0xff, 0xfb, 0xbd, 0x97, 0x37, 0x33, 0x0f, 0x35, 0x69, 0xda, 0x97, 0x7e, 0xc2, 0x42, + 0xca, 0xf2, 0xe4, 0x80, 0xfa, 0x4f, 0xf7, 0xa9, 0xe8, 0x7b, 0x99, 0xe0, 0x39, 0xc7, 0xcb, 0xb0, + 0xe7, 0x9d, 0xec, 0x35, 0x57, 0x43, 0x2e, 0x7b, 0x5c, 0x76, 0xd4, 0xae, 0xaf, 0x17, 0xda, 0xb4, + 0xb9, 0x12, 0xf3, 0x98, 0xeb, 0xef, 0xf0, 0xcb, 0x7c, 0xbd, 0x16, 0x73, 0x1e, 0xa7, 0xd4, 0x27, + 0x59, 0xe2, 0x13, 0xc6, 0x78, 0x4e, 0xf2, 0x84, 0xb3, 0xc2, 0xc7, 0xd1, 0x0a, 0x7e, 0x97, 0x48, + 0xea, 0x1f, 0x6c, 0x76, 0x69, 0x4e, 0x36, 0xfd, 0x90, 0x27, 0xcc, 0xec, 0x7f, 0x54, 0xde, 0x57, + 0x5c, 0x27, 0x56, 0x19, 0x89, 0x13, 0xa6, 0xc4, 0x8a, 0x48, 0x2a, 0x8d, 0x90, 0xf7, 0x7a, 0x49, + 0xde, 0xa3, 0x2c, 0xf7, 0x33, 0x22, 0x48, 0xcf, 0x44, 0x72, 0x63, 0xf4, 0xd6, 0xd7, 0xe0, 0xbf, + 0x95, 0x89, 0x80, 0x3e, 0xdd, 0xa7, 0x32, 0xc7, 0x9f, 0xa1, 0xcb, 0x87, 0x49, 0xfe, 0x24, 0x12, + 0xe4, 0xb0, 0x93, 0xf7, 0x33, 0x6a, 0x5b, 0xeb, 0x56, 0x6b, 0xb9, 0xbd, 0xea, 0xa9, 0x9c, 0x07, + 0x42, 0xde, 0x03, 0x22, 0xd8, 0x6e, 0x3f, 0xa3, 0xc1, 0x52, 0x61, 0x0f, 0x2b, 0xbc, 0x82, 0xe6, + 0x22, 0xca, 0x78, 0xcf, 0x9e, 0x5d, 0xb7, 0x5a, 0x8b, 0x81, 0x5e, 0xb8, 0xbb, 0xe8, 0xed, 0x41, + 0x20, 0x99, 0x71, 0x26, 0x29, 0xbe, 0x87, 0x6a, 0x24, 0x13, 0x4a, 0x7f, 0x71, 0xdb, 0x7b, 0xf9, + 0x7a, 0x6d, 0xe6, 0xaf, 0xd7, 0x6b, 0x37, 0xe2, 0x24, 0x7f, 0xb2, 0xdf, 0x85, 0x40, 0xa6, 0x90, + 0xe6, 0xcf, 0x86, 0x8c, 0xf6, 0x7c, 0x00, 0x92, 0xde, 0x43, 0x96, 0x07, 0xe0, 0xea, 0xe2, 0x81, + 0xaa, 0x34, 0xfc, 0xee, 0xf1, 0x3c, 0xba, 0x52, 0xfa, 0x68, 0x62, 0x05, 0xe8, 0xf2, 0xbe, 0x8c, + 0xc2, 0x0e, 0xc9, 0x44, 0x07, 0x7e, 0x4c, 0x18, 0xb5, 0x01, 0xbe, 0x5b, 0x99, 0x78, 0x2c, 0xa3, + 0x10, 0x34, 0x69, 0x44, 0xd9, 0x40, 0x73, 0x76, 0x32, 0x4d, 0x10, 0x29, 0x34, 0x77, 0xd1, 0xf2, + 0x09, 0x27, 0x7c, 0xef, 0xda, 0xb5, 0x89, 0x44, 0x97, 0x0c, 0xe8, 0x03, 0xd0, 0x00, 0xd5, 0x13, + 0x52, 0xad, 0x5a, 0x9f, 0x4c, 0xd5, 0xa0, 0x6a, 0xd5, 0x72, 0x4d, 0x61, 0xc3, 0x9e, 0x9b, 0xaa, + 0xa6, 0x20, 0x3a, 0x54, 0x53, 0xa5, 0x39, 0x3f, 0x55, 0x4d, 0x95, 0xa6, 0xc9, 0xbe, 0x3b, 0x10, + 0x5d, 0x98, 0x3c, 0xfb, 0x6e, 0x89, 0x74, 0x90, 0x7d, 0xda, 0x97, 0xf6, 0xa5, 0xe9, 0xb2, 0x4f, + 0xfb, 0x72, 0x38, 0x7b, 0xd0, 0x5c, 0x9c, 0x2e, 0x7b, 0xd0, 0x1c, 0xce, 0x1e, 0x44, 0xd1, 0x94, + 0xd9, 0xa7, 0x7d, 0xe9, 0x7e, 0x82, 0xde, 0xd7, 0x87, 0x2c, 0x4d, 0x77, 0x04, 0x8f, 0x05, 0xe9, + 0x05, 0xf4, 0x90, 0x88, 0xa8, 0x38, 0x86, 0xd8, 0x46, 0x0b, 0x24, 0x8a, 0x04, 0x95, 0x52, 0x1f, + 0xb5, 0xa0, 0x58, 0xba, 0xbf, 0xd5, 0x91, 0x33, 0xce, 0xd7, 0x9c, 0xd6, 0x1f, 0x2c, 0xb4, 0xa2, + 0x8a, 0x2b, 0x73, 0xb2, 0x97, 0xb0, 0xb8, 0x23, 0xb4, 0x81, 0x6d, 0xad, 0xd7, 0x5a, 0x8d, 0xf6, + 0x35, 0xcf, 0x5c, 0xb1, 0x70, 0x01, 0x7a, 0xe6, 0xea, 0xf3, 0xee, 0xd3, 0xf0, 0x73, 0x9e, 0xb0, + 0xed, 0x3b, 0x90, 0xd8, 0x2f, 0x7f, 0xaf, 0xdd, 0x3a, 0x47, 0x62, 0xc6, 0x47, 0x06, 0x18, 0xc2, + 0x3d, 0xd2, 0xd1, 0x0c, 0x8d, 0xa2, 0x80, 0x82, 0x8d, 0x50, 0xcc, 0x5e, 0x18, 0x05, 0x84, 0x3b, + 0x8d, 0x02, 0x9a, 0xa2, 0x4a, 0x51, 0xbb, 0x38, 0x8a, 0x88, 0xb2, 0x0a, 0xc5, 0x8f, 0x16, 0x7a, + 0x57, 0xb7, 0x51, 0x15, 0xa3, 0x7e, 0x51, 0x18, 0xef, 0xa8, 0x78, 0xc3, 0x1c, 0xee, 0x77, 0xe8, + 0xaa, 0xea, 0x9d, 0x1d, 0xce, 0xd3, 0x4a, 0xc7, 0xad, 0xa2, 0x4b, 0x19, 0xe7, 0x69, 0x27, 0x31, + 0x7d, 0x52, 0x0f, 0x16, 0x60, 0xfd, 0x30, 0x92, 0xf8, 0x0b, 0x84, 0x06, 0x0f, 0xa3, 0xba, 0xa6, + 0x1b, 0xed, 0x1b, 0x43, 0xc4, 0xfa, 0x75, 0x2f, 0xb8, 0x77, 0x48, 0x4c, 0x8d, 0x6c, 0x50, 0xf2, + 0x74, 0xff, 0xb3, 0x50, 0xa3, 0x14, 0x19, 0x5f, 0x45, 0x0b, 0x26, 0xa4, 0x6a, 0xf2, 0x7a, 0x30, + 0xaf, 0x23, 0xe2, 0xaf, 0x50, 0xc3, 0xd4, 0x07, 0x5e, 0x86, 0x09, 0x1e, 0x86, 0xfb, 0x34, 0x0c, + 0x90, 0x91, 0x78, 0x2c, 0x23, 0xcc, 0xd0, 0x92, 0x5e, 0x75, 0x60, 0x0e, 0x28, 0xfe, 0xf9, 0xab, + 0xa7, 0x56, 0x5d, 0x95, 0xfc, 0xb6, 0x29, 0x79, 0xeb, 0x1c, 0xc1, 0x74, 0xbd, 0x0d, 0xb1, 0x5a, + 0xb8, 0x8f, 0x90, 0x3d, 0x5a, 0x67, 0x73, 0x3a, 0x3f, 0x46, 0x73, 0x90, 0x66, 0x71, 0x1a, 0xdf, + 0xf3, 0x86, 0xa7, 0x21, 0xaf, 0xe4, 0xb3, 0x5d, 0x07, 0x8c, 0x40, 0xdb, 0xb7, 0x7f, 0xaf, 0xa3, + 0x39, 0xa5, 0x8a, 0x7f, 0xb2, 0x50, 0x6d, 0x2b, 0x13, 0x78, 0xad, 0xea, 0x5b, 0x99, 0x46, 0x9a, + 0xeb, 0xe3, 0x0d, 0x34, 0x8d, 0x7b, 0xef, 0xfb, 0x3f, 0xfe, 0x7d, 0x31, 0xfb, 0x29, 0xbe, 0xeb, + 0x83, 0xe5, 0x06, 0xa3, 0xf9, 0x21, 0x17, 0x7b, 0x7e, 0x65, 0x7a, 0x23, 0x99, 0xf0, 0x9f, 0x0d, + 0xcd, 0x35, 0xcf, 0xfd, 0x67, 0x6a, 0x34, 0x79, 0x8e, 0x0f, 0x50, 0x1d, 0x66, 0x05, 0x3c, 0x36, + 0x56, 0xd1, 0x62, 0xcd, 0xeb, 0x67, 0x58, 0x18, 0x9c, 0x9b, 0x0a, 0xe7, 0x03, 0x7c, 0xfd, 0x4d, + 0x38, 0x12, 0xbf, 0xa8, 0x74, 0xd3, 0x87, 0xa7, 0xaa, 0x8f, 0x76, 0x7a, 0xb3, 0xf5, 0x66, 0x43, + 0x43, 0xb3, 0xa9, 0x68, 0x6e, 0xe1, 0x9b, 0x67, 0xd2, 0xa8, 0x1e, 0x36, 0xcd, 0x86, 0x7f, 0xb5, + 0xd0, 0x95, 0x91, 0x9b, 0x19, 0x6f, 0x9c, 0x9e, 0xf9, 0x98, 0xdb, 0xbf, 0xe9, 0x9d, 0xd7, 0xdc, + 0x70, 0xde, 0x55, 0x9c, 0x6d, 0x7c, 0xfb, 0xec, 0xaa, 0xa5, 0x29, 0x8c, 0xd8, 0x20, 0x50, 0xe0, + 0x6e, 0x7f, 0xf9, 0xf2, 0xc8, 0xb1, 0x5e, 0x1d, 0x39, 0xd6, 0x3f, 0x47, 0x8e, 0xf5, 0xf3, 0xb1, + 0x33, 0xf3, 0xea, 0xd8, 0x99, 0xf9, 0xf3, 0xd8, 0x99, 0xf9, 0xc6, 0x2b, 0x75, 0xfe, 0xa8, 0xea, + 0xb7, 0x25, 0x5d, 0x75, 0x0a, 0xba, 0xf3, 0x6a, 0x24, 0xbe, 0xf3, 0x7f, 0x00, 0x00, 0x00, 0xff, + 0xff, 0xc2, 0x17, 0x24, 0xd5, 0xf9, 0x0b, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -749,18 +556,14 @@ const _ = grpc.SupportPackageIsVersion4 // // 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 { - // Parameters queries the parameters of the module. - Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) - // Queries a list of CommunityPool items. - CommunityPool(ctx context.Context, in *QueryCommunityPoolRequest, opts ...grpc.CallOption) (*QueryCommunityPoolResponse, error) // Calculate APR Apr(ctx context.Context, in *QueryAprRequest, opts ...grpc.CallOption) (*QueryAprResponse, error) // Calculate APRs Aprs(ctx context.Context, in *QueryAprsRequest, opts ...grpc.CallOption) (*QueryAprsResponse, error) - // Calculate liquidity mining pool APRs - PoolAprs(ctx context.Context, in *QueryPoolAprsRequest, opts ...grpc.CallOption) (*QueryPoolAprsResponse, error) // Queries PoolReward items PoolRewards(ctx context.Context, in *QueryPoolRewardsRequest, opts ...grpc.CallOption) (*QueryPoolRewardsResponse, error) + // Queries all program rewards + AllProgramRewards(ctx context.Context, in *QueryAllProgramRewardsRequest, opts ...grpc.CallOption) (*QueryAllProgramRewardsResponse, error) } type queryClient struct { @@ -771,24 +574,6 @@ 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, "/elys.incentive.Query/Params", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *queryClient) CommunityPool(ctx context.Context, in *QueryCommunityPoolRequest, opts ...grpc.CallOption) (*QueryCommunityPoolResponse, error) { - out := new(QueryCommunityPoolResponse) - err := c.cc.Invoke(ctx, "/elys.incentive.Query/CommunityPool", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - func (c *queryClient) Apr(ctx context.Context, in *QueryAprRequest, opts ...grpc.CallOption) (*QueryAprResponse, error) { out := new(QueryAprResponse) err := c.cc.Invoke(ctx, "/elys.incentive.Query/Apr", in, out, opts...) @@ -807,18 +592,18 @@ func (c *queryClient) Aprs(ctx context.Context, in *QueryAprsRequest, opts ...gr return out, nil } -func (c *queryClient) PoolAprs(ctx context.Context, in *QueryPoolAprsRequest, opts ...grpc.CallOption) (*QueryPoolAprsResponse, error) { - out := new(QueryPoolAprsResponse) - err := c.cc.Invoke(ctx, "/elys.incentive.Query/PoolAprs", in, out, opts...) +func (c *queryClient) PoolRewards(ctx context.Context, in *QueryPoolRewardsRequest, opts ...grpc.CallOption) (*QueryPoolRewardsResponse, error) { + out := new(QueryPoolRewardsResponse) + err := c.cc.Invoke(ctx, "/elys.incentive.Query/PoolRewards", in, out, opts...) if err != nil { return nil, err } return out, nil } -func (c *queryClient) PoolRewards(ctx context.Context, in *QueryPoolRewardsRequest, opts ...grpc.CallOption) (*QueryPoolRewardsResponse, error) { - out := new(QueryPoolRewardsResponse) - err := c.cc.Invoke(ctx, "/elys.incentive.Query/PoolRewards", in, out, opts...) +func (c *queryClient) AllProgramRewards(ctx context.Context, in *QueryAllProgramRewardsRequest, opts ...grpc.CallOption) (*QueryAllProgramRewardsResponse, error) { + out := new(QueryAllProgramRewardsResponse) + err := c.cc.Invoke(ctx, "/elys.incentive.Query/AllProgramRewards", in, out, opts...) if err != nil { return nil, err } @@ -827,83 +612,37 @@ func (c *queryClient) PoolRewards(ctx context.Context, in *QueryPoolRewardsReque // QueryServer is the server API for Query service. type QueryServer interface { - // Parameters queries the parameters of the module. - Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) - // Queries a list of CommunityPool items. - CommunityPool(context.Context, *QueryCommunityPoolRequest) (*QueryCommunityPoolResponse, error) // Calculate APR Apr(context.Context, *QueryAprRequest) (*QueryAprResponse, error) // Calculate APRs Aprs(context.Context, *QueryAprsRequest) (*QueryAprsResponse, error) - // Calculate liquidity mining pool APRs - PoolAprs(context.Context, *QueryPoolAprsRequest) (*QueryPoolAprsResponse, error) // Queries PoolReward items PoolRewards(context.Context, *QueryPoolRewardsRequest) (*QueryPoolRewardsResponse, error) + // Queries all program rewards + AllProgramRewards(context.Context, *QueryAllProgramRewardsRequest) (*QueryAllProgramRewardsResponse, 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) CommunityPool(ctx context.Context, req *QueryCommunityPoolRequest) (*QueryCommunityPoolResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method CommunityPool not implemented") -} func (*UnimplementedQueryServer) Apr(ctx context.Context, req *QueryAprRequest) (*QueryAprResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Apr not implemented") } func (*UnimplementedQueryServer) Aprs(ctx context.Context, req *QueryAprsRequest) (*QueryAprsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Aprs not implemented") } -func (*UnimplementedQueryServer) PoolAprs(ctx context.Context, req *QueryPoolAprsRequest) (*QueryPoolAprsResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method PoolAprs not implemented") -} func (*UnimplementedQueryServer) PoolRewards(ctx context.Context, req *QueryPoolRewardsRequest) (*QueryPoolRewardsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method PoolRewards not implemented") } +func (*UnimplementedQueryServer) AllProgramRewards(ctx context.Context, req *QueryAllProgramRewardsRequest) (*QueryAllProgramRewardsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method AllProgramRewards 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: "/elys.incentive.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_CommunityPool_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryCommunityPoolRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).CommunityPool(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/elys.incentive.Query/CommunityPool", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).CommunityPool(ctx, req.(*QueryCommunityPoolRequest)) - } - return interceptor(ctx, in, info, handler) -} - func _Query_Apr_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(QueryAprRequest) if err := dec(in); err != nil { @@ -940,38 +679,38 @@ func _Query_Aprs_Handler(srv interface{}, ctx context.Context, dec func(interfac return interceptor(ctx, in, info, handler) } -func _Query_PoolAprs_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryPoolAprsRequest) +func _Query_PoolRewards_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryPoolRewardsRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(QueryServer).PoolAprs(ctx, in) + return srv.(QueryServer).PoolRewards(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/elys.incentive.Query/PoolAprs", + FullMethod: "/elys.incentive.Query/PoolRewards", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).PoolAprs(ctx, req.(*QueryPoolAprsRequest)) + return srv.(QueryServer).PoolRewards(ctx, req.(*QueryPoolRewardsRequest)) } return interceptor(ctx, in, info, handler) } -func _Query_PoolRewards_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryPoolRewardsRequest) +func _Query_AllProgramRewards_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryAllProgramRewardsRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(QueryServer).PoolRewards(ctx, in) + return srv.(QueryServer).AllProgramRewards(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/elys.incentive.Query/PoolRewards", + FullMethod: "/elys.incentive.Query/AllProgramRewards", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).PoolRewards(ctx, req.(*QueryPoolRewardsRequest)) + return srv.(QueryServer).AllProgramRewards(ctx, req.(*QueryAllProgramRewardsRequest)) } return interceptor(ctx, in, info, handler) } @@ -980,14 +719,6 @@ var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "elys.incentive.Query", HandlerType: (*QueryServer)(nil), Methods: []grpc.MethodDesc{ - { - MethodName: "Params", - Handler: _Query_Params_Handler, - }, - { - MethodName: "CommunityPool", - Handler: _Query_CommunityPool_Handler, - }, { MethodName: "Apr", Handler: _Query_Apr_Handler, @@ -996,20 +727,20 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "Aprs", Handler: _Query_Aprs_Handler, }, - { - MethodName: "PoolAprs", - Handler: _Query_PoolAprs_Handler, - }, { MethodName: "PoolRewards", Handler: _Query_PoolRewards_Handler, }, + { + MethodName: "AllProgramRewards", + Handler: _Query_AllProgramRewards_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "elys/incentive/query.proto", } -func (m *QueryParamsRequest) Marshal() (dAtA []byte, err error) { +func (m *QueryAprRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1019,20 +750,32 @@ func (m *QueryParamsRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryParamsRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryAprRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryAprRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l + if len(m.Denom) > 0 { + i -= len(m.Denom) + copy(dAtA[i:], m.Denom) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Denom))) + i-- + dAtA[i] = 0x12 + } + if m.WithdrawType != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.WithdrawType)) + i-- + dAtA[i] = 0x8 + } return len(dAtA) - i, nil } -func (m *QueryParamsResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryAprResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1042,22 +785,22 @@ func (m *QueryParamsResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryParamsResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryAprResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryAprResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l { - size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { + size := m.Apr.Size() + i -= size + if _, err := m.Apr.MarshalTo(dAtA[i:]); err != nil { return 0, err } - i -= size i = encodeVarintQuery(dAtA, i, uint64(size)) } i-- @@ -1065,7 +808,7 @@ func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *QueryCommunityPoolRequest) Marshal() (dAtA []byte, err error) { +func (m *QueryAprsRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1075,12 +818,12 @@ func (m *QueryCommunityPoolRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryCommunityPoolRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryAprsRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryCommunityPoolRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryAprsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1088,7 +831,7 @@ func (m *QueryCommunityPoolRequest) MarshalToSizedBuffer(dAtA []byte) (int, erro return len(dAtA) - i, nil } -func (m *QueryCommunityPoolResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryAprsResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1098,151 +841,23 @@ func (m *QueryCommunityPoolResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryCommunityPoolResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryAprsResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryCommunityPoolResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryAprsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.Pool) > 0 { - for iNdEx := len(m.Pool) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Pool[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa + { + size := m.EdenbAprElys.Size() + i -= size + if _, err := m.EdenbAprElys.MarshalTo(dAtA[i:]); err != nil { + return 0, err } - } - return len(dAtA) - i, nil -} - -func (m *QueryAprRequest) 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 *QueryAprRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryAprRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Denom) > 0 { - i -= len(m.Denom) - copy(dAtA[i:], m.Denom) - i = encodeVarintQuery(dAtA, i, uint64(len(m.Denom))) - i-- - dAtA[i] = 0x12 - } - if m.WithdrawType != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.WithdrawType)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *QueryAprResponse) 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 *QueryAprResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryAprResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size := m.Apr.Size() - i -= size - if _, err := m.Apr.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 *QueryAprsRequest) 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 *QueryAprsRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryAprsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func (m *QueryAprsResponse) 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 *QueryAprsResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryAprsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size := m.EdenbAprElys.Size() - i -= size - if _, err := m.EdenbAprElys.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintQuery(dAtA, i, uint64(size)) + i = encodeVarintQuery(dAtA, i, uint64(size)) } i-- dAtA[i] = 0x52 @@ -1339,7 +954,7 @@ func (m *QueryAprsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *QueryPoolAprsRequest) Marshal() (dAtA []byte, err error) { +func (m *QueryAllProgramRewardsRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1349,38 +964,27 @@ func (m *QueryPoolAprsRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryPoolAprsRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryAllProgramRewardsRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryPoolAprsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryAllProgramRewardsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.PoolIds) > 0 { - dAtA3 := make([]byte, len(m.PoolIds)*10) - var j2 int - for _, num := range m.PoolIds { - for num >= 1<<7 { - dAtA3[j2] = uint8(uint64(num)&0x7f | 0x80) - num >>= 7 - j2++ - } - dAtA3[j2] = uint8(num) - j2++ - } - i -= j2 - copy(dAtA[i:], dAtA3[:j2]) - i = encodeVarintQuery(dAtA, i, uint64(j2)) + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Address))) i-- dAtA[i] = 0xa } return len(dAtA) - i, nil } -func (m *QueryPoolAprsResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryAllProgramRewardsResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1390,20 +994,20 @@ func (m *QueryPoolAprsResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryPoolAprsResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryAllProgramRewardsResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryPoolAprsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryAllProgramRewardsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.Data) > 0 { - for iNdEx := len(m.Data) - 1; iNdEx >= 0; iNdEx-- { + if len(m.EdenbStakingRewards) > 0 { + for iNdEx := len(m.EdenbStakingRewards) - 1; iNdEx >= 0; iNdEx-- { { - size, err := m.Data[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + size, err := m.EdenbStakingRewards[iNdEx].MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -1411,46 +1015,50 @@ func (m *QueryPoolAprsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintQuery(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0xa + dAtA[i] = 0x22 } } - return len(dAtA) - i, nil -} - -func (m *PoolApr) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err + if len(m.EdenStakingRewards) > 0 { + for iNdEx := len(m.EdenStakingRewards) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.EdenStakingRewards[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } } - return dAtA[:n], nil -} - -func (m *PoolApr) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *PoolApr) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size := m.Apr.Size() - i -= size - if _, err := m.Apr.MarshalTo(dAtA[i:]); err != nil { - return 0, err + if len(m.ElysStakingRewards) > 0 { + for iNdEx := len(m.ElysStakingRewards) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.ElysStakingRewards[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 } - 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 + if len(m.UsdcStakingRewards) > 0 { + for iNdEx := len(m.UsdcStakingRewards) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.UsdcStakingRewards[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 } @@ -1488,20 +1096,20 @@ func (m *QueryPoolRewardsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) dAtA[i] = 0x12 } if len(m.PoolIds) > 0 { - dAtA6 := make([]byte, len(m.PoolIds)*10) - var j5 int + dAtA3 := make([]byte, len(m.PoolIds)*10) + var j2 int for _, num := range m.PoolIds { for num >= 1<<7 { - dAtA6[j5] = uint8(uint64(num)&0x7f | 0x80) + dAtA3[j2] = uint8(uint64(num)&0x7f | 0x80) num >>= 7 - j5++ + j2++ } - dAtA6[j5] = uint8(num) - j5++ + dAtA3[j2] = uint8(num) + j2++ } - i -= j5 - copy(dAtA[i:], dAtA6[:j5]) - i = encodeVarintQuery(dAtA, i, uint64(j5)) + i -= j2 + copy(dAtA[i:], dAtA3[:j2]) + i = encodeVarintQuery(dAtA, i, uint64(j2)) i-- dAtA[i] = 0xa } @@ -1608,50 +1216,6 @@ func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } -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 *QueryCommunityPoolRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *QueryCommunityPoolResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.Pool) > 0 { - for _, e := range m.Pool { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) - } - } - return n -} - func (m *QueryAprRequest) Size() (n int) { if m == nil { return 0 @@ -1717,378 +1281,112 @@ func (m *QueryAprsResponse) Size() (n int) { return n } -func (m *QueryPoolAprsRequest) Size() (n int) { +func (m *QueryAllProgramRewardsRequest) Size() (n int) { if m == nil { return 0 } var l int _ = l - if len(m.PoolIds) > 0 { - l = 0 - for _, e := range m.PoolIds { - l += sovQuery(uint64(e)) - } - n += 1 + sovQuery(uint64(l)) + l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) } return n } -func (m *QueryPoolAprsResponse) Size() (n int) { +func (m *QueryAllProgramRewardsResponse) Size() (n int) { if m == nil { return 0 } var l int _ = l - if len(m.Data) > 0 { - for _, e := range m.Data { + if len(m.UsdcStakingRewards) > 0 { + for _, e := range m.UsdcStakingRewards { l = e.Size() n += 1 + l + sovQuery(uint64(l)) } } - return n -} - -func (m *PoolApr) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.PoolId != 0 { - n += 1 + sovQuery(uint64(m.PoolId)) + if len(m.ElysStakingRewards) > 0 { + for _, e := range m.ElysStakingRewards { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } } - l = m.Apr.Size() - n += 1 + l + sovQuery(uint64(l)) - return n -} - -func (m *QueryPoolRewardsRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.PoolIds) > 0 { - l = 0 - for _, e := range m.PoolIds { - l += sovQuery(uint64(e)) - } - n += 1 + sovQuery(uint64(l)) + l - } - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *PoolRewards) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.PoolId != 0 { - n += 1 + sovQuery(uint64(m.PoolId)) - } - l = m.RewardsUsd.Size() - n += 1 + l + sovQuery(uint64(l)) - if len(m.RewardCoins) > 0 { - for _, e := range m.RewardCoins { + if len(m.EdenStakingRewards) > 0 { + for _, e := range m.EdenStakingRewards { l = e.Size() n += 1 + l + sovQuery(uint64(l)) } } - return n -} - -func (m *QueryPoolRewardsResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.Pools) > 0 { - for _, e := range m.Pools { + if len(m.EdenbStakingRewards) > 0 { + for _, e := range m.EdenbStakingRewards { l = e.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 *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 *QueryCommunityPoolRequest) 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: QueryCommunityPoolRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryCommunityPoolRequest: 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 *QueryCommunityPoolResponse) 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: QueryCommunityPoolResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryCommunityPoolResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Pool", 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.Pool = append(m.Pool, types.DecCoin{}) - if err := m.Pool[len(m.Pool)-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 + } + return n +} + +func (m *QueryPoolRewardsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.PoolIds) > 0 { + l = 0 + for _, e := range m.PoolIds { + l += sovQuery(uint64(e)) } + n += 1 + sovQuery(uint64(l)) + l + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) } + return n +} - if iNdEx > l { - return io.ErrUnexpectedEOF +func (m *PoolRewards) Size() (n int) { + if m == nil { + return 0 } - return nil + var l int + _ = l + if m.PoolId != 0 { + n += 1 + sovQuery(uint64(m.PoolId)) + } + l = m.RewardsUsd.Size() + n += 1 + l + sovQuery(uint64(l)) + if len(m.RewardCoins) > 0 { + for _, e := range m.RewardCoins { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + +func (m *QueryPoolRewardsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Pools) > 0 { + for _, e := range m.Pools { + l = e.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 *QueryAprRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) @@ -2133,7 +1431,7 @@ func (m *QueryAprRequest) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.WithdrawType |= types1.EarnType(b&0x7F) << shift + m.WithdrawType |= types.EarnType(b&0x7F) << shift if b < 0x80 { break } @@ -2715,7 +2013,7 @@ func (m *QueryAprsResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryPoolAprsRequest) Unmarshal(dAtA []byte) error { +func (m *QueryAllProgramRewardsRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2738,88 +2036,44 @@ func (m *QueryPoolAprsRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryPoolAprsRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryAllProgramRewardsRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryPoolAprsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryAllProgramRewardsRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: - if wireType == 0 { - var v uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.PoolIds = append(m.PoolIds, v) - } else if wireType == 2 { - var packedLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - packedLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if packedLen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + packedLen - if postIndex < 0 { - return ErrInvalidLengthQuery + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery } - if postIndex > l { + if iNdEx >= l { return io.ErrUnexpectedEOF } - var elementCount int - var count int - for _, integer := range dAtA[iNdEx:postIndex] { - if integer < 128 { - count++ - } - } - elementCount = count - if elementCount != 0 && len(m.PoolIds) == 0 { - m.PoolIds = make([]uint64, 0, elementCount) - } - for iNdEx < postIndex { - var v uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.PoolIds = append(m.PoolIds, v) + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break } - } else { - return fmt.Errorf("proto: wrong wireType = %d for field PoolIds", wireType) } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -2841,7 +2095,7 @@ func (m *QueryPoolAprsRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryPoolAprsResponse) Unmarshal(dAtA []byte) error { +func (m *QueryAllProgramRewardsResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2864,15 +2118,15 @@ func (m *QueryPoolAprsResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryPoolAprsResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryAllProgramRewardsResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryPoolAprsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryAllProgramRewardsResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field UsdcStakingRewards", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -2899,66 +2153,50 @@ func (m *QueryPoolAprsResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Data = append(m.Data, PoolApr{}) - if err := m.Data[len(m.Data)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.UsdcStakingRewards = append(m.UsdcStakingRewards, types1.DecCoin{}) + if err := m.UsdcStakingRewards[len(m.UsdcStakingRewards)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ElysStakingRewards", wireType) } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery + 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 (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF + if msglen < 0 { + return ErrInvalidLengthQuery } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *PoolApr) 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 + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery } - if iNdEx >= l { + if postIndex > l { return io.ErrUnexpectedEOF } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break + m.ElysStakingRewards = append(m.ElysStakingRewards, types1.DecCoin{}) + if err := m.ElysStakingRewards[len(m.ElysStakingRewards)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: PoolApr: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: PoolApr: 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) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EdenStakingRewards", wireType) } - m.PoolId = 0 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -2968,16 +2206,31 @@ func (m *PoolApr) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.PoolId |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - case 2: + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.EdenStakingRewards = append(m.EdenStakingRewards, types1.DecCoin{}) + if err := m.EdenStakingRewards[len(m.EdenStakingRewards)-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 Apr", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field EdenbStakingRewards", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -2987,23 +2240,23 @@ func (m *PoolApr) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if msglen < 0 { return ErrInvalidLengthQuery } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthQuery } if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.Apr.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.EdenbStakingRewards = append(m.EdenbStakingRewards, types1.DecCoin{}) + if err := m.EdenbStakingRewards[len(m.EdenbStakingRewards)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -3301,7 +2554,7 @@ func (m *PoolRewards) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.RewardCoins = append(m.RewardCoins, types.Coin{}) + m.RewardCoins = append(m.RewardCoins, types1.Coin{}) if err := m.RewardCoins[len(m.RewardCoins)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } diff --git a/x/incentive/types/query.pb.gw.go b/x/incentive/types/query.pb.gw.go index 6632e291c..53be496d5 100644 --- a/x/incentive/types/query.pb.gw.go +++ b/x/incentive/types/query.pb.gw.go @@ -32,42 +32,6 @@ 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 - -} - -func request_Query_CommunityPool_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryCommunityPoolRequest - var metadata runtime.ServerMetadata - - msg, err := client.CommunityPool(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_CommunityPool_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryCommunityPoolRequest - var metadata runtime.ServerMetadata - - msg, err := server.CommunityPool(ctx, &protoReq) - return msg, metadata, err - -} - func request_Query_Apr_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryAprRequest var metadata runtime.ServerMetadata @@ -169,73 +133,73 @@ func local_request_Query_Aprs_0(ctx context.Context, marshaler runtime.Marshaler } var ( - filter_Query_PoolAprs_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} + filter_Query_PoolRewards_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} ) -func request_Query_PoolAprs_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryPoolAprsRequest +func request_Query_PoolRewards_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryPoolRewardsRequest 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_PoolAprs_0); err != nil { + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_PoolRewards_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - msg, err := client.PoolAprs(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := client.PoolRewards(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_Query_PoolAprs_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryPoolAprsRequest +func local_request_Query_PoolRewards_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryPoolRewardsRequest 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_PoolAprs_0); err != nil { + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_PoolRewards_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - msg, err := server.PoolAprs(ctx, &protoReq) + msg, err := server.PoolRewards(ctx, &protoReq) return msg, metadata, err } var ( - filter_Query_PoolRewards_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} + filter_Query_AllProgramRewards_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} ) -func request_Query_PoolRewards_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryPoolRewardsRequest +func request_Query_AllProgramRewards_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAllProgramRewardsRequest 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_PoolRewards_0); err != nil { + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_AllProgramRewards_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - msg, err := client.PoolRewards(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := client.AllProgramRewards(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_Query_PoolRewards_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryPoolRewardsRequest +func local_request_Query_AllProgramRewards_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAllProgramRewardsRequest 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_PoolRewards_0); err != nil { + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_AllProgramRewards_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - msg, err := server.PoolRewards(ctx, &protoReq) + msg, err := server.AllProgramRewards(ctx, &protoReq) return msg, metadata, err } @@ -246,46 +210,6 @@ func local_request_Query_PoolRewards_0(ctx context.Context, marshaler runtime.Ma // 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_CommunityPool_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_CommunityPool_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_CommunityPool_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - mux.Handle("GET", pattern_Query_Apr_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -326,7 +250,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) - mux.Handle("GET", pattern_Query_PoolAprs_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_PoolRewards_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) @@ -335,18 +259,18 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Query_PoolAprs_0(rctx, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_Query_PoolRewards_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_PoolAprs_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_PoolRewards_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("GET", pattern_Query_PoolRewards_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_AllProgramRewards_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) @@ -355,14 +279,14 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Query_PoolRewards_0(rctx, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_Query_AllProgramRewards_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_PoolRewards_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_AllProgramRewards_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -407,46 +331,6 @@ func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc // "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_CommunityPool_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_CommunityPool_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_CommunityPool_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - mux.Handle("GET", pattern_Query_Apr_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -487,7 +371,7 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) - mux.Handle("GET", pattern_Query_PoolAprs_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_PoolRewards_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) @@ -496,18 +380,18 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Query_PoolAprs_0(rctx, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Query_PoolRewards_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_PoolAprs_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_PoolRewards_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("GET", pattern_Query_PoolRewards_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_AllProgramRewards_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) @@ -516,14 +400,14 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Query_PoolRewards_0(rctx, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Query_AllProgramRewards_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_PoolRewards_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_AllProgramRewards_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -531,29 +415,21 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } var ( - pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"elys-network", "elys", "incentive", "params"}, "", runtime.AssumeColonVerbOpt(true))) - - pattern_Query_CommunityPool_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"elys-network", "elys", "incentive", "community_pool"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_Query_Apr_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 1, 0, 4, 1, 5, 5}, []string{"elys-network", "elys", "incentive", "apr", "withdraw_type", "denom"}, "", runtime.AssumeColonVerbOpt(true))) pattern_Query_Aprs_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"elys-network", "elys", "incentive", "aprs"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_Query_PoolAprs_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"elys-network", "elys", "incentive", "pool_aprs"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_Query_PoolRewards_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"elys-network", "elys", "incentive", "pool_rewards"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_AllProgramRewards_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"elys-network", "elys", "incentive", "all_program_rewards"}, "", runtime.AssumeColonVerbOpt(true))) ) var ( - forward_Query_Params_0 = runtime.ForwardResponseMessage - - forward_Query_CommunityPool_0 = runtime.ForwardResponseMessage - forward_Query_Apr_0 = runtime.ForwardResponseMessage forward_Query_Aprs_0 = runtime.ForwardResponseMessage - forward_Query_PoolAprs_0 = runtime.ForwardResponseMessage - forward_Query_PoolRewards_0 = runtime.ForwardResponseMessage + + forward_Query_AllProgramRewards_0 = runtime.ForwardResponseMessage ) diff --git a/x/incentive/types/tx.pb.go b/x/incentive/types/tx.pb.go index 41825eb73..4e2a82b0c 100644 --- a/x/incentive/types/tx.pb.go +++ b/x/incentive/types/tx.pb.go @@ -7,15 +7,12 @@ import ( context "context" fmt "fmt" _ "github.com/cosmos/cosmos-proto" - github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" - types1 "github.com/cosmos/cosmos-sdk/types" + types "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" - types "github.com/elys-network/elys/x/commitment/types" + _ "github.com/elys-network/elys/x/commitment/types" 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" @@ -32,274 +29,18 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// MsgWithdrawDelegatorReward represents delegation withdrawal to a delegator -// from a single validator. -type MsgWithdrawRewards struct { - DelegatorAddress string `protobuf:"bytes,1,opt,name=delegator_address,json=delegatorAddress,proto3" json:"delegator_address,omitempty"` - WithdrawType types.EarnType `protobuf:"varint,2,opt,name=withdraw_type,json=withdrawType,proto3,enum=elys.commitment.EarnType" json:"withdraw_type,omitempty"` -} - -func (m *MsgWithdrawRewards) Reset() { *m = MsgWithdrawRewards{} } -func (m *MsgWithdrawRewards) String() string { return proto.CompactTextString(m) } -func (*MsgWithdrawRewards) ProtoMessage() {} -func (*MsgWithdrawRewards) Descriptor() ([]byte, []int) { - return fileDescriptor_59dc3bedfb1cce84, []int{0} -} -func (m *MsgWithdrawRewards) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgWithdrawRewards) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgWithdrawRewards.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 *MsgWithdrawRewards) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgWithdrawRewards.Merge(m, src) -} -func (m *MsgWithdrawRewards) XXX_Size() int { - return m.Size() -} -func (m *MsgWithdrawRewards) XXX_DiscardUnknown() { - xxx_messageInfo_MsgWithdrawRewards.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgWithdrawRewards proto.InternalMessageInfo - -// MsgWithdrawDelegatorRewardResponse defines the Msg/WithdrawDelegatorReward response type. -type MsgWithdrawRewardsResponse struct { -} - -func (m *MsgWithdrawRewardsResponse) Reset() { *m = MsgWithdrawRewardsResponse{} } -func (m *MsgWithdrawRewardsResponse) String() string { return proto.CompactTextString(m) } -func (*MsgWithdrawRewardsResponse) ProtoMessage() {} -func (*MsgWithdrawRewardsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_59dc3bedfb1cce84, []int{1} -} -func (m *MsgWithdrawRewardsResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgWithdrawRewardsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgWithdrawRewardsResponse.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 *MsgWithdrawRewardsResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgWithdrawRewardsResponse.Merge(m, src) -} -func (m *MsgWithdrawRewardsResponse) XXX_Size() int { - return m.Size() -} -func (m *MsgWithdrawRewardsResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgWithdrawRewardsResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgWithdrawRewardsResponse proto.InternalMessageInfo - -// MsgWithdrawValidatorCommission withdraws the full commission to the validator -// address. -type MsgWithdrawValidatorCommission struct { - DelegatorAddress string `protobuf:"bytes,1,opt,name=delegator_address,json=delegatorAddress,proto3" json:"delegator_address,omitempty"` - ValidatorAddress string `protobuf:"bytes,2,opt,name=validator_address,json=validatorAddress,proto3" json:"validator_address,omitempty"` -} - -func (m *MsgWithdrawValidatorCommission) Reset() { *m = MsgWithdrawValidatorCommission{} } -func (m *MsgWithdrawValidatorCommission) String() string { return proto.CompactTextString(m) } -func (*MsgWithdrawValidatorCommission) ProtoMessage() {} -func (*MsgWithdrawValidatorCommission) Descriptor() ([]byte, []int) { - return fileDescriptor_59dc3bedfb1cce84, []int{2} -} -func (m *MsgWithdrawValidatorCommission) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgWithdrawValidatorCommission) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgWithdrawValidatorCommission.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 *MsgWithdrawValidatorCommission) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgWithdrawValidatorCommission.Merge(m, src) -} -func (m *MsgWithdrawValidatorCommission) XXX_Size() int { - return m.Size() -} -func (m *MsgWithdrawValidatorCommission) XXX_DiscardUnknown() { - xxx_messageInfo_MsgWithdrawValidatorCommission.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgWithdrawValidatorCommission proto.InternalMessageInfo - -// MsgWithdrawValidatorCommissionResponse defines the Msg/WithdrawValidatorCommission response type. -type MsgWithdrawValidatorCommissionResponse struct { -} - -func (m *MsgWithdrawValidatorCommissionResponse) Reset() { - *m = MsgWithdrawValidatorCommissionResponse{} -} -func (m *MsgWithdrawValidatorCommissionResponse) String() string { return proto.CompactTextString(m) } -func (*MsgWithdrawValidatorCommissionResponse) ProtoMessage() {} -func (*MsgWithdrawValidatorCommissionResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_59dc3bedfb1cce84, []int{3} -} -func (m *MsgWithdrawValidatorCommissionResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgWithdrawValidatorCommissionResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgWithdrawValidatorCommissionResponse.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 *MsgWithdrawValidatorCommissionResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgWithdrawValidatorCommissionResponse.Merge(m, src) -} -func (m *MsgWithdrawValidatorCommissionResponse) XXX_Size() int { - return m.Size() -} -func (m *MsgWithdrawValidatorCommissionResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgWithdrawValidatorCommissionResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgWithdrawValidatorCommissionResponse proto.InternalMessageInfo - -type MsgUpdateIncentiveParams struct { - Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` - RewardPortionForLps github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=reward_portion_for_lps,json=rewardPortionForLps,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"reward_portion_for_lps"` - RewardPortionForStakers github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=reward_portion_for_stakers,json=rewardPortionForStakers,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"reward_portion_for_stakers"` - ElysStakeSnapInterval int64 `protobuf:"varint,4,opt,name=elys_stake_snap_interval,json=elysStakeSnapInterval,proto3" json:"elys_stake_snap_interval,omitempty"` - MaxEdenRewardAprStakers github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,5,opt,name=max_eden_reward_apr_stakers,json=maxEdenRewardAprStakers,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"max_eden_reward_apr_stakers"` - MaxEdenRewardAprLps github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,6,opt,name=max_eden_reward_apr_lps,json=maxEdenRewardAprLps,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"max_eden_reward_apr_lps"` - DistributionInterval int64 `protobuf:"varint,7,opt,name=distribution_interval,json=distributionInterval,proto3" json:"distribution_interval,omitempty"` -} - -func (m *MsgUpdateIncentiveParams) Reset() { *m = MsgUpdateIncentiveParams{} } -func (m *MsgUpdateIncentiveParams) String() string { return proto.CompactTextString(m) } -func (*MsgUpdateIncentiveParams) ProtoMessage() {} -func (*MsgUpdateIncentiveParams) Descriptor() ([]byte, []int) { - return fileDescriptor_59dc3bedfb1cce84, []int{4} -} -func (m *MsgUpdateIncentiveParams) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgUpdateIncentiveParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgUpdateIncentiveParams.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 *MsgUpdateIncentiveParams) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgUpdateIncentiveParams.Merge(m, src) -} -func (m *MsgUpdateIncentiveParams) XXX_Size() int { - return m.Size() -} -func (m *MsgUpdateIncentiveParams) XXX_DiscardUnknown() { - xxx_messageInfo_MsgUpdateIncentiveParams.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgUpdateIncentiveParams proto.InternalMessageInfo - -func (m *MsgUpdateIncentiveParams) GetAuthority() string { - if m != nil { - return m.Authority - } - return "" -} - -func (m *MsgUpdateIncentiveParams) GetElysStakeSnapInterval() int64 { - if m != nil { - return m.ElysStakeSnapInterval - } - return 0 -} - -func (m *MsgUpdateIncentiveParams) GetDistributionInterval() int64 { - if m != nil { - return m.DistributionInterval - } - return 0 -} - -type MsgUpdateIncentiveParamsResponse struct { -} - -func (m *MsgUpdateIncentiveParamsResponse) Reset() { *m = MsgUpdateIncentiveParamsResponse{} } -func (m *MsgUpdateIncentiveParamsResponse) String() string { return proto.CompactTextString(m) } -func (*MsgUpdateIncentiveParamsResponse) ProtoMessage() {} -func (*MsgUpdateIncentiveParamsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_59dc3bedfb1cce84, []int{5} -} -func (m *MsgUpdateIncentiveParamsResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgUpdateIncentiveParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgUpdateIncentiveParamsResponse.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 *MsgUpdateIncentiveParamsResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgUpdateIncentiveParamsResponse.Merge(m, src) -} -func (m *MsgUpdateIncentiveParamsResponse) XXX_Size() int { - return m.Size() -} -func (m *MsgUpdateIncentiveParamsResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgUpdateIncentiveParamsResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgUpdateIncentiveParamsResponse proto.InternalMessageInfo - type MsgBeginRedelegate struct { - DelegatorAddress string `protobuf:"bytes,1,opt,name=delegator_address,json=delegatorAddress,proto3" json:"delegator_address,omitempty"` - ValidatorSrcAddress string `protobuf:"bytes,2,opt,name=validator_src_address,json=validatorSrcAddress,proto3" json:"validator_src_address,omitempty"` - ValidatorDstAddress string `protobuf:"bytes,3,opt,name=validator_dst_address,json=validatorDstAddress,proto3" json:"validator_dst_address,omitempty"` - Amount types1.Coin `protobuf:"bytes,4,opt,name=amount,proto3" json:"amount"` + DelegatorAddress string `protobuf:"bytes,1,opt,name=delegator_address,json=delegatorAddress,proto3" json:"delegator_address,omitempty"` + ValidatorSrcAddress string `protobuf:"bytes,2,opt,name=validator_src_address,json=validatorSrcAddress,proto3" json:"validator_src_address,omitempty"` + ValidatorDstAddress string `protobuf:"bytes,3,opt,name=validator_dst_address,json=validatorDstAddress,proto3" json:"validator_dst_address,omitempty"` + Amount types.Coin `protobuf:"bytes,4,opt,name=amount,proto3" json:"amount"` } func (m *MsgBeginRedelegate) Reset() { *m = MsgBeginRedelegate{} } func (m *MsgBeginRedelegate) String() string { return proto.CompactTextString(m) } func (*MsgBeginRedelegate) ProtoMessage() {} func (*MsgBeginRedelegate) Descriptor() ([]byte, []int) { - return fileDescriptor_59dc3bedfb1cce84, []int{6} + return fileDescriptor_59dc3bedfb1cce84, []int{0} } func (m *MsgBeginRedelegate) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -332,7 +73,7 @@ type MsgCancelUnbondingDelegation struct { DelegatorAddress string `protobuf:"bytes,1,opt,name=delegator_address,json=delegatorAddress,proto3" json:"delegator_address,omitempty"` ValidatorAddress string `protobuf:"bytes,2,opt,name=validator_address,json=validatorAddress,proto3" json:"validator_address,omitempty"` // amount is always less than or equal to unbonding delegation entry balance - Amount types1.Coin `protobuf:"bytes,3,opt,name=amount,proto3" json:"amount"` + Amount types.Coin `protobuf:"bytes,3,opt,name=amount,proto3" json:"amount"` // creation_height is the height which the unbonding took place. CreationHeight int64 `protobuf:"varint,4,opt,name=creation_height,json=creationHeight,proto3" json:"creation_height,omitempty"` } @@ -341,7 +82,7 @@ func (m *MsgCancelUnbondingDelegation) Reset() { *m = MsgCancelUnbonding func (m *MsgCancelUnbondingDelegation) String() string { return proto.CompactTextString(m) } func (*MsgCancelUnbondingDelegation) ProtoMessage() {} func (*MsgCancelUnbondingDelegation) Descriptor() ([]byte, []int) { - return fileDescriptor_59dc3bedfb1cce84, []int{7} + return fileDescriptor_59dc3bedfb1cce84, []int{1} } func (m *MsgCancelUnbondingDelegation) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -370,214 +111,42 @@ func (m *MsgCancelUnbondingDelegation) XXX_DiscardUnknown() { var xxx_messageInfo_MsgCancelUnbondingDelegation proto.InternalMessageInfo -type PoolMultiplier struct { - PoolId uint64 `protobuf:"varint,1,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty"` - Multiplier github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=multiplier,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"multiplier"` -} - -func (m *PoolMultiplier) Reset() { *m = PoolMultiplier{} } -func (m *PoolMultiplier) String() string { return proto.CompactTextString(m) } -func (*PoolMultiplier) ProtoMessage() {} -func (*PoolMultiplier) Descriptor() ([]byte, []int) { - return fileDescriptor_59dc3bedfb1cce84, []int{8} -} -func (m *PoolMultiplier) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *PoolMultiplier) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_PoolMultiplier.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 *PoolMultiplier) XXX_Merge(src proto.Message) { - xxx_messageInfo_PoolMultiplier.Merge(m, src) -} -func (m *PoolMultiplier) XXX_Size() int { - return m.Size() -} -func (m *PoolMultiplier) XXX_DiscardUnknown() { - xxx_messageInfo_PoolMultiplier.DiscardUnknown(m) -} - -var xxx_messageInfo_PoolMultiplier proto.InternalMessageInfo - -func (m *PoolMultiplier) GetPoolId() uint64 { - if m != nil { - return m.PoolId - } - return 0 -} - -type MsgUpdatePoolMultipliers struct { - Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` - PoolMultipliers []PoolMultiplier `protobuf:"bytes,2,rep,name=pool_multipliers,json=poolMultipliers,proto3" json:"pool_multipliers"` -} - -func (m *MsgUpdatePoolMultipliers) Reset() { *m = MsgUpdatePoolMultipliers{} } -func (m *MsgUpdatePoolMultipliers) String() string { return proto.CompactTextString(m) } -func (*MsgUpdatePoolMultipliers) ProtoMessage() {} -func (*MsgUpdatePoolMultipliers) Descriptor() ([]byte, []int) { - return fileDescriptor_59dc3bedfb1cce84, []int{9} -} -func (m *MsgUpdatePoolMultipliers) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgUpdatePoolMultipliers) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgUpdatePoolMultipliers.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 *MsgUpdatePoolMultipliers) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgUpdatePoolMultipliers.Merge(m, src) -} -func (m *MsgUpdatePoolMultipliers) XXX_Size() int { - return m.Size() -} -func (m *MsgUpdatePoolMultipliers) XXX_DiscardUnknown() { - xxx_messageInfo_MsgUpdatePoolMultipliers.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgUpdatePoolMultipliers proto.InternalMessageInfo - -func (m *MsgUpdatePoolMultipliers) GetAuthority() string { - if m != nil { - return m.Authority - } - return "" -} - -func (m *MsgUpdatePoolMultipliers) GetPoolMultipliers() []PoolMultiplier { - if m != nil { - return m.PoolMultipliers - } - return nil -} - -type MsgUpdatePoolMultipliersResponse struct { -} - -func (m *MsgUpdatePoolMultipliersResponse) Reset() { *m = MsgUpdatePoolMultipliersResponse{} } -func (m *MsgUpdatePoolMultipliersResponse) String() string { return proto.CompactTextString(m) } -func (*MsgUpdatePoolMultipliersResponse) ProtoMessage() {} -func (*MsgUpdatePoolMultipliersResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_59dc3bedfb1cce84, []int{10} -} -func (m *MsgUpdatePoolMultipliersResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgUpdatePoolMultipliersResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgUpdatePoolMultipliersResponse.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 *MsgUpdatePoolMultipliersResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgUpdatePoolMultipliersResponse.Merge(m, src) -} -func (m *MsgUpdatePoolMultipliersResponse) XXX_Size() int { - return m.Size() -} -func (m *MsgUpdatePoolMultipliersResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgUpdatePoolMultipliersResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgUpdatePoolMultipliersResponse proto.InternalMessageInfo - func init() { - proto.RegisterType((*MsgWithdrawRewards)(nil), "elys.incentive.MsgWithdrawRewards") - proto.RegisterType((*MsgWithdrawRewardsResponse)(nil), "elys.incentive.MsgWithdrawRewardsResponse") - proto.RegisterType((*MsgWithdrawValidatorCommission)(nil), "elys.incentive.MsgWithdrawValidatorCommission") - proto.RegisterType((*MsgWithdrawValidatorCommissionResponse)(nil), "elys.incentive.MsgWithdrawValidatorCommissionResponse") - proto.RegisterType((*MsgUpdateIncentiveParams)(nil), "elys.incentive.MsgUpdateIncentiveParams") - proto.RegisterType((*MsgUpdateIncentiveParamsResponse)(nil), "elys.incentive.MsgUpdateIncentiveParamsResponse") proto.RegisterType((*MsgBeginRedelegate)(nil), "elys.incentive.MsgBeginRedelegate") proto.RegisterType((*MsgCancelUnbondingDelegation)(nil), "elys.incentive.MsgCancelUnbondingDelegation") - proto.RegisterType((*PoolMultiplier)(nil), "elys.incentive.PoolMultiplier") - proto.RegisterType((*MsgUpdatePoolMultipliers)(nil), "elys.incentive.MsgUpdatePoolMultipliers") - proto.RegisterType((*MsgUpdatePoolMultipliersResponse)(nil), "elys.incentive.MsgUpdatePoolMultipliersResponse") } func init() { proto.RegisterFile("elys/incentive/tx.proto", fileDescriptor_59dc3bedfb1cce84) } var fileDescriptor_59dc3bedfb1cce84 = []byte{ - // 903 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x56, 0xcd, 0x6e, 0x1b, 0x37, - 0x10, 0xd6, 0x5a, 0xae, 0xd3, 0x30, 0xad, 0x9d, 0x6c, 0xec, 0x5a, 0x56, 0x8c, 0xb5, 0xa1, 0x43, - 0x2a, 0x14, 0xf0, 0x6e, 0xe3, 0x00, 0x0d, 0xd0, 0x43, 0x81, 0xf8, 0xa7, 0x88, 0x81, 0xa8, 0x35, - 0xd6, 0x4d, 0x0b, 0xf4, 0xb2, 0xa0, 0x96, 0xec, 0x8a, 0xf0, 0x2e, 0x49, 0x90, 0xd4, 0xdf, 0x03, - 0x14, 0x68, 0x6f, 0x3d, 0xf6, 0x98, 0x4b, 0xdf, 0xa0, 0x87, 0xa2, 0x4f, 0x90, 0x43, 0x0f, 0x41, - 0x4f, 0x45, 0x0e, 0x41, 0x61, 0x5f, 0xfa, 0x18, 0x05, 0xb9, 0x3f, 0x5a, 0xc9, 0xb2, 0xec, 0x08, - 0x39, 0xe4, 0x24, 0x91, 0x33, 0xfc, 0xe6, 0x9b, 0x8f, 0x33, 0xc3, 0x05, 0xeb, 0x38, 0x1e, 0x4a, - 0x8f, 0xd0, 0x10, 0x53, 0x45, 0x7a, 0xd8, 0x53, 0x03, 0x97, 0x0b, 0xa6, 0x98, 0xbd, 0xac, 0x0d, - 0x6e, 0x61, 0xa8, 0xaf, 0x46, 0x2c, 0x62, 0xc6, 0xe4, 0xe9, 0x7f, 0xa9, 0x57, 0x7d, 0x23, 0x64, - 0x32, 0x61, 0x32, 0x48, 0x0d, 0xe9, 0x22, 0x33, 0x6d, 0x1a, 0xe4, 0x90, 0x25, 0x09, 0x51, 0x09, - 0xa6, 0xca, 0xe3, 0x50, 0xc0, 0x24, 0xb7, 0x3a, 0xa9, 0xaf, 0xd7, 0x86, 0x12, 0x7b, 0xbd, 0x07, - 0x6d, 0xac, 0xe0, 0x03, 0x2f, 0x64, 0x84, 0xa6, 0xf6, 0xc6, 0x6f, 0x16, 0xb0, 0x5b, 0x32, 0xfa, - 0x8e, 0xa8, 0x0e, 0x12, 0xb0, 0xef, 0xe3, 0x3e, 0x14, 0x48, 0xda, 0x87, 0xe0, 0x0e, 0xc2, 0x31, - 0x8e, 0xa0, 0x62, 0x22, 0x80, 0x08, 0x09, 0x2c, 0x65, 0xcd, 0xda, 0xb6, 0x9a, 0x37, 0xf7, 0x6a, - 0x7f, 0xff, 0xbe, 0xb3, 0x9a, 0x31, 0x78, 0x9c, 0x5a, 0x4e, 0x94, 0x20, 0x34, 0xf2, 0x6f, 0x17, - 0x47, 0xb2, 0x7d, 0xfb, 0x0b, 0xf0, 0x61, 0x3f, 0x43, 0x0e, 0xd4, 0x90, 0xe3, 0xda, 0xc2, 0xb6, - 0xd5, 0x5c, 0xde, 0xdd, 0x70, 0x4d, 0xd2, 0x23, 0xce, 0xee, 0x21, 0x14, 0xf4, 0x9b, 0x21, 0xc7, - 0xfe, 0x07, 0xb9, 0xbf, 0x5e, 0x7d, 0xfe, 0xfe, 0x4f, 0xcf, 0xb7, 0x2a, 0xff, 0x3d, 0xdf, 0xaa, - 0x34, 0x36, 0x41, 0xfd, 0x22, 0x4d, 0x1f, 0x4b, 0xce, 0xa8, 0xc4, 0x8d, 0x3f, 0x2c, 0xe0, 0x94, - 0xcc, 0xdf, 0xc2, 0x98, 0x20, 0xcd, 0x63, 0x5f, 0x47, 0x90, 0x92, 0x30, 0xfa, 0xb6, 0x32, 0x3a, - 0x04, 0x77, 0x7a, 0x39, 0x7a, 0x01, 0xb3, 0x70, 0x15, 0x4c, 0x71, 0x24, 0xdb, 0x2f, 0x25, 0xd6, - 0x04, 0xf7, 0x67, 0x33, 0x2f, 0x92, 0xfc, 0x6b, 0x11, 0xd4, 0x5a, 0x32, 0x7a, 0xc6, 0x11, 0x54, - 0xf8, 0x28, 0x2f, 0x98, 0x63, 0x73, 0xdb, 0xf6, 0x26, 0xb8, 0x09, 0xbb, 0xaa, 0xc3, 0x04, 0x51, - 0xc3, 0x34, 0x2d, 0x7f, 0xb4, 0x61, 0x87, 0xe0, 0x23, 0x61, 0x24, 0x0b, 0x38, 0x13, 0x8a, 0x30, - 0x1a, 0xfc, 0xc0, 0x44, 0x10, 0xf3, 0x9c, 0xba, 0xfb, 0xe2, 0xf5, 0x56, 0xe5, 0xd5, 0xeb, 0xad, - 0xfb, 0x11, 0x51, 0x9d, 0x6e, 0x5b, 0xdf, 0x4c, 0x56, 0x64, 0xd9, 0xcf, 0x8e, 0x44, 0xa7, 0x9e, - 0xbe, 0x41, 0xe9, 0x1e, 0xe0, 0xd0, 0xbf, 0x9b, 0xa2, 0x1d, 0xa7, 0x60, 0x5f, 0x32, 0xf1, 0x94, - 0x4b, 0xfb, 0x14, 0xd4, 0xa7, 0x04, 0x91, 0x0a, 0x9e, 0x62, 0x21, 0x6b, 0xd5, 0xb9, 0x02, 0xad, - 0x4f, 0x06, 0x3a, 0x49, 0xe1, 0xec, 0x47, 0xa0, 0xa6, 0x6b, 0x28, 0x85, 0x0f, 0x24, 0x85, 0x3c, - 0x20, 0x54, 0x61, 0xd1, 0x83, 0x71, 0x6d, 0x71, 0xdb, 0x6a, 0x56, 0xfd, 0x35, 0x6d, 0x37, 0xee, - 0x27, 0x14, 0xf2, 0xa3, 0xcc, 0x68, 0xc7, 0xe0, 0x5e, 0x02, 0x07, 0x01, 0x46, 0x98, 0x06, 0x19, - 0x5d, 0xc8, 0x47, 0x34, 0xdf, 0x9b, 0x8f, 0x66, 0x02, 0x07, 0x87, 0x08, 0xd3, 0xb4, 0x2e, 0x1f, - 0xf3, 0x82, 0x26, 0x02, 0xeb, 0xd3, 0xa2, 0x69, 0xe5, 0x97, 0xe6, 0x53, 0x7e, 0x32, 0x92, 0x56, - 0xfe, 0x21, 0x58, 0x43, 0x44, 0x2a, 0x41, 0xda, 0x5d, 0xa3, 0x7b, 0xa1, 0xc4, 0x0d, 0xa3, 0xc4, - 0x6a, 0xd9, 0x98, 0x0b, 0xd1, 0x68, 0x80, 0xed, 0xcb, 0xaa, 0xa9, 0x28, 0xb9, 0x3f, 0x17, 0xcc, - 0x74, 0xd8, 0xc3, 0x11, 0xa1, 0x3e, 0xce, 0x9a, 0x01, 0xbf, 0xad, 0x5e, 0x7a, 0x0a, 0xd6, 0x46, - 0xbd, 0x24, 0x45, 0x78, 0xed, 0x7e, 0xba, 0x5b, 0x1c, 0x3b, 0x11, 0xe1, 0x54, 0x34, 0x24, 0x55, - 0x81, 0x56, 0xbd, 0x36, 0xda, 0x81, 0x54, 0x39, 0xda, 0x23, 0xb0, 0x04, 0x13, 0xd6, 0xa5, 0xca, - 0x54, 0xd3, 0xad, 0xdd, 0x0d, 0x37, 0x3b, 0xab, 0x07, 0xa9, 0x9b, 0x0d, 0x52, 0x77, 0x9f, 0x11, - 0xba, 0xb7, 0xa8, 0xaf, 0xd0, 0xcf, 0xdc, 0x4b, 0x9d, 0xfd, 0xeb, 0x02, 0xd8, 0x6c, 0xc9, 0x68, - 0x1f, 0xd2, 0x10, 0xc7, 0xcf, 0x68, 0x9b, 0x51, 0x44, 0x68, 0x74, 0x90, 0xaa, 0xf0, 0xce, 0x8d, - 0xa4, 0x52, 0xc6, 0xd5, 0x37, 0xca, 0xd8, 0xfe, 0x18, 0xac, 0x84, 0x02, 0x9b, 0x94, 0x82, 0x0e, - 0x26, 0x51, 0x47, 0x65, 0x1d, 0xb8, 0x9c, 0x6f, 0x3f, 0x31, 0xbb, 0x25, 0x69, 0x86, 0x60, 0xf9, - 0x98, 0xb1, 0xb8, 0xd5, 0x8d, 0x15, 0xe1, 0x31, 0xc1, 0xc2, 0x5e, 0x07, 0x37, 0x38, 0x63, 0x71, - 0x40, 0x90, 0x51, 0x60, 0xd1, 0x5f, 0xd2, 0xcb, 0x23, 0x64, 0x7f, 0x05, 0x40, 0x52, 0xb8, 0xcd, - 0x39, 0xae, 0x4a, 0x08, 0x8d, 0x9f, 0xad, 0xd2, 0x14, 0x1d, 0x27, 0x71, 0xd5, 0x14, 0xfd, 0x1a, - 0xdc, 0x36, 0x1c, 0x47, 0x68, 0x5a, 0xe7, 0x6a, 0xf3, 0xd6, 0xae, 0xe3, 0x8e, 0xbf, 0xe2, 0xee, - 0x38, 0x70, 0x26, 0xd8, 0x0a, 0x1f, 0x0f, 0x37, 0xd6, 0x82, 0x13, 0x54, 0xf2, 0x16, 0xdc, 0x7d, - 0x55, 0x05, 0xd5, 0x96, 0x8c, 0x6c, 0x08, 0x56, 0x26, 0x1f, 0xe9, 0xc6, 0x64, 0xd4, 0x8b, 0x2f, - 0x64, 0xfd, 0x93, 0xab, 0x7d, 0xf2, 0x50, 0xf6, 0x8f, 0x16, 0xb8, 0x37, 0xeb, 0x09, 0x75, 0x67, - 0x60, 0x4d, 0xf1, 0xaf, 0x7f, 0xf6, 0x66, 0xfe, 0x05, 0x0f, 0x09, 0xd6, 0xa6, 0x3f, 0x72, 0xcd, - 0x29, 0x80, 0x53, 0x3d, 0xeb, 0x9f, 0x5e, 0xd7, 0xf3, 0x62, 0xd0, 0xc9, 0x9a, 0xb8, 0x3c, 0xe8, - 0x84, 0xe7, 0x8c, 0xa0, 0x97, 0x5c, 0xee, 0xde, 0x93, 0x17, 0x67, 0x8e, 0xf5, 0xf2, 0xcc, 0xb1, - 0xfe, 0x3d, 0x73, 0xac, 0x5f, 0xce, 0x9d, 0xca, 0xcb, 0x73, 0xa7, 0xf2, 0xcf, 0xb9, 0x53, 0xf9, - 0xde, 0x2d, 0x95, 0xb6, 0x46, 0xdd, 0xa1, 0x58, 0xf5, 0x99, 0x38, 0x35, 0x0b, 0x6f, 0x50, 0xfe, - 0x92, 0xd4, 0x65, 0xde, 0x5e, 0x32, 0x9f, 0x73, 0x0f, 0xff, 0x0f, 0x00, 0x00, 0xff, 0xff, 0x81, - 0x82, 0xfb, 0x24, 0x68, 0x0a, 0x00, 0x00, + // 431 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x93, 0xbf, 0x8e, 0xd3, 0x40, + 0x10, 0xc6, 0xed, 0xf8, 0x38, 0xc1, 0x22, 0x1d, 0x77, 0xe6, 0x10, 0xb9, 0xd3, 0xc9, 0x39, 0x5d, + 0xc3, 0x35, 0xe7, 0xd5, 0x85, 0x02, 0x89, 0x8e, 0xfc, 0x91, 0x52, 0x90, 0xc6, 0x11, 0x0d, 0x4d, + 0xb4, 0x5e, 0x8f, 0x36, 0x2b, 0xec, 0xdd, 0x68, 0x77, 0x13, 0x92, 0x37, 0xa0, 0xa4, 0xa4, 0xcc, + 0x43, 0x50, 0xf1, 0x04, 0x29, 0x23, 0x2a, 0x2a, 0x84, 0x92, 0x86, 0xc7, 0x40, 0xf6, 0x3a, 0x0e, + 0x12, 0x48, 0x04, 0xe9, 0xba, 0x9d, 0xf9, 0x66, 0x7e, 0xf2, 0xf7, 0x69, 0x8c, 0x9e, 0x42, 0x3a, + 0xd7, 0x98, 0x0b, 0x0a, 0xc2, 0xf0, 0x29, 0x60, 0x33, 0x0b, 0xc7, 0x4a, 0x1a, 0xe9, 0x1f, 0xe5, + 0x42, 0x58, 0x09, 0xe7, 0xa7, 0x4c, 0x32, 0x59, 0x48, 0x38, 0x7f, 0xd9, 0xa9, 0xf3, 0x33, 0x2a, + 0x75, 0x26, 0xf5, 0xd0, 0x0a, 0xb6, 0x28, 0xa5, 0x8b, 0x82, 0x4c, 0x65, 0x96, 0x71, 0x93, 0x81, + 0x30, 0x78, 0x4c, 0x14, 0xc9, 0xb6, 0x6a, 0x60, 0x67, 0x71, 0x4c, 0x34, 0xe0, 0xe9, 0x6d, 0x0c, + 0x86, 0xdc, 0x62, 0x2a, 0xb9, 0xb0, 0xfa, 0xd5, 0x97, 0x1a, 0xf2, 0xfb, 0x9a, 0xb5, 0x80, 0x71, + 0x11, 0x41, 0x02, 0x29, 0x30, 0x62, 0xc0, 0xef, 0xa2, 0x93, 0xf2, 0x2d, 0xd5, 0x90, 0x24, 0x89, + 0x02, 0xad, 0xeb, 0xee, 0xa5, 0x7b, 0xfd, 0xa0, 0x55, 0xff, 0xfa, 0xf9, 0xe6, 0xb4, 0xfc, 0x82, + 0x57, 0x56, 0x19, 0x18, 0xc5, 0x05, 0x8b, 0x8e, 0xab, 0x95, 0xb2, 0xef, 0xbf, 0x46, 0x4f, 0xa6, + 0x24, 0xe5, 0x49, 0x81, 0xd1, 0x8a, 0x56, 0xa8, 0xda, 0x3f, 0x50, 0x8f, 0xab, 0xb5, 0x81, 0xa2, + 0x7f, 0xa5, 0x25, 0xda, 0x54, 0x34, 0x6f, 0x6f, 0x5a, 0x47, 0x9b, 0x2d, 0xed, 0x05, 0x3a, 0x24, + 0x99, 0x9c, 0x08, 0x53, 0x3f, 0xb8, 0x74, 0xaf, 0x1f, 0x36, 0xcf, 0xc2, 0x72, 0x37, 0x8f, 0x2a, + 0x2c, 0xa3, 0x0a, 0xdb, 0x92, 0x8b, 0xd6, 0xc1, 0xf2, 0x7b, 0xc3, 0x89, 0xca, 0xf1, 0x97, 0xf7, + 0x3f, 0x2c, 0x1a, 0xce, 0xcf, 0x45, 0xc3, 0xb9, 0xfa, 0x54, 0x43, 0x17, 0x7d, 0xcd, 0xda, 0x44, + 0x50, 0x48, 0xdf, 0x88, 0x58, 0x8a, 0x84, 0x0b, 0xd6, 0xb1, 0x29, 0x70, 0x29, 0xee, 0x2a, 0xc6, + 0x2e, 0x3a, 0xd9, 0x19, 0xdf, 0x37, 0xc2, 0xe3, 0x6a, 0xe5, 0x4f, 0xc7, 0xde, 0x7f, 0x39, 0xf6, + 0x9f, 0xa1, 0x47, 0x54, 0x41, 0x61, 0x69, 0x38, 0x02, 0xce, 0x46, 0x36, 0x33, 0x2f, 0x3a, 0xda, + 0xb6, 0x7b, 0x45, 0x77, 0x17, 0x4d, 0xf3, 0x1e, 0xf2, 0xf2, 0xb3, 0xea, 0x2d, 0xd7, 0x81, 0xbb, + 0x5a, 0x07, 0xee, 0x8f, 0x75, 0xe0, 0x7e, 0xdc, 0x04, 0xce, 0x6a, 0x13, 0x38, 0xdf, 0x36, 0x81, + 0xf3, 0x36, 0x64, 0xdc, 0x8c, 0x26, 0x71, 0x48, 0x65, 0x86, 0xf3, 0x0b, 0xbe, 0x11, 0x60, 0xde, + 0x4b, 0xf5, 0xae, 0x28, 0xf0, 0xec, 0xf7, 0x5f, 0x65, 0x3e, 0x06, 0x1d, 0x1f, 0x16, 0xf7, 0xfa, + 0xfc, 0x57, 0x00, 0x00, 0x00, 0xff, 0xff, 0x5f, 0x58, 0x1b, 0x4d, 0x49, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -592,14 +161,6 @@ const _ = grpc.SupportPackageIsVersion4 // // 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 { - // WithdrawDelegatorReward defines a method to withdraw rewards of delegator - // from a single validator. - WithdrawRewards(ctx context.Context, in *MsgWithdrawRewards, opts ...grpc.CallOption) (*MsgWithdrawRewardsResponse, error) - // WithdrawValidatorCommission defines a method to withdraw the - // full commission to the validator address. - WithdrawValidatorCommission(ctx context.Context, in *MsgWithdrawValidatorCommission, opts ...grpc.CallOption) (*MsgWithdrawValidatorCommissionResponse, error) - UpdateIncentiveParams(ctx context.Context, in *MsgUpdateIncentiveParams, opts ...grpc.CallOption) (*MsgUpdateIncentiveParamsResponse, error) - UpdatePoolMultipliers(ctx context.Context, in *MsgUpdatePoolMultipliers, opts ...grpc.CallOption) (*MsgUpdatePoolMultipliersResponse, error) } type msgClient struct { @@ -610,398 +171,31 @@ func NewMsgClient(cc grpc1.ClientConn) MsgClient { return &msgClient{cc} } -func (c *msgClient) WithdrawRewards(ctx context.Context, in *MsgWithdrawRewards, opts ...grpc.CallOption) (*MsgWithdrawRewardsResponse, error) { - out := new(MsgWithdrawRewardsResponse) - err := c.cc.Invoke(ctx, "/elys.incentive.Msg/WithdrawRewards", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *msgClient) WithdrawValidatorCommission(ctx context.Context, in *MsgWithdrawValidatorCommission, opts ...grpc.CallOption) (*MsgWithdrawValidatorCommissionResponse, error) { - out := new(MsgWithdrawValidatorCommissionResponse) - err := c.cc.Invoke(ctx, "/elys.incentive.Msg/WithdrawValidatorCommission", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *msgClient) UpdateIncentiveParams(ctx context.Context, in *MsgUpdateIncentiveParams, opts ...grpc.CallOption) (*MsgUpdateIncentiveParamsResponse, error) { - out := new(MsgUpdateIncentiveParamsResponse) - err := c.cc.Invoke(ctx, "/elys.incentive.Msg/UpdateIncentiveParams", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *msgClient) UpdatePoolMultipliers(ctx context.Context, in *MsgUpdatePoolMultipliers, opts ...grpc.CallOption) (*MsgUpdatePoolMultipliersResponse, error) { - out := new(MsgUpdatePoolMultipliersResponse) - err := c.cc.Invoke(ctx, "/elys.incentive.Msg/UpdatePoolMultipliers", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - // MsgServer is the server API for Msg service. type MsgServer interface { - // WithdrawDelegatorReward defines a method to withdraw rewards of delegator - // from a single validator. - WithdrawRewards(context.Context, *MsgWithdrawRewards) (*MsgWithdrawRewardsResponse, error) - // WithdrawValidatorCommission defines a method to withdraw the - // full commission to the validator address. - WithdrawValidatorCommission(context.Context, *MsgWithdrawValidatorCommission) (*MsgWithdrawValidatorCommissionResponse, error) - UpdateIncentiveParams(context.Context, *MsgUpdateIncentiveParams) (*MsgUpdateIncentiveParamsResponse, error) - UpdatePoolMultipliers(context.Context, *MsgUpdatePoolMultipliers) (*MsgUpdatePoolMultipliersResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. type UnimplementedMsgServer struct { } -func (*UnimplementedMsgServer) WithdrawRewards(ctx context.Context, req *MsgWithdrawRewards) (*MsgWithdrawRewardsResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method WithdrawRewards not implemented") -} -func (*UnimplementedMsgServer) WithdrawValidatorCommission(ctx context.Context, req *MsgWithdrawValidatorCommission) (*MsgWithdrawValidatorCommissionResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method WithdrawValidatorCommission not implemented") -} -func (*UnimplementedMsgServer) UpdateIncentiveParams(ctx context.Context, req *MsgUpdateIncentiveParams) (*MsgUpdateIncentiveParamsResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method UpdateIncentiveParams not implemented") -} -func (*UnimplementedMsgServer) UpdatePoolMultipliers(ctx context.Context, req *MsgUpdatePoolMultipliers) (*MsgUpdatePoolMultipliersResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method UpdatePoolMultipliers not implemented") -} - func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) } -func _Msg_WithdrawRewards_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgWithdrawRewards) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).WithdrawRewards(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/elys.incentive.Msg/WithdrawRewards", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).WithdrawRewards(ctx, req.(*MsgWithdrawRewards)) - } - return interceptor(ctx, in, info, handler) +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "elys.incentive.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{}, + Streams: []grpc.StreamDesc{}, + Metadata: "elys/incentive/tx.proto", } -func _Msg_WithdrawValidatorCommission_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgWithdrawValidatorCommission) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).WithdrawValidatorCommission(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/elys.incentive.Msg/WithdrawValidatorCommission", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).WithdrawValidatorCommission(ctx, req.(*MsgWithdrawValidatorCommission)) - } - return interceptor(ctx, in, info, handler) -} - -func _Msg_UpdateIncentiveParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgUpdateIncentiveParams) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).UpdateIncentiveParams(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/elys.incentive.Msg/UpdateIncentiveParams", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).UpdateIncentiveParams(ctx, req.(*MsgUpdateIncentiveParams)) - } - return interceptor(ctx, in, info, handler) -} - -func _Msg_UpdatePoolMultipliers_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgUpdatePoolMultipliers) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).UpdatePoolMultipliers(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/elys.incentive.Msg/UpdatePoolMultipliers", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).UpdatePoolMultipliers(ctx, req.(*MsgUpdatePoolMultipliers)) - } - return interceptor(ctx, in, info, handler) -} - -var _Msg_serviceDesc = grpc.ServiceDesc{ - ServiceName: "elys.incentive.Msg", - HandlerType: (*MsgServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "WithdrawRewards", - Handler: _Msg_WithdrawRewards_Handler, - }, - { - MethodName: "WithdrawValidatorCommission", - Handler: _Msg_WithdrawValidatorCommission_Handler, - }, - { - MethodName: "UpdateIncentiveParams", - Handler: _Msg_UpdateIncentiveParams_Handler, - }, - { - MethodName: "UpdatePoolMultipliers", - Handler: _Msg_UpdatePoolMultipliers_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "elys/incentive/tx.proto", -} - -func (m *MsgWithdrawRewards) 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 *MsgWithdrawRewards) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgWithdrawRewards) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.WithdrawType != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.WithdrawType)) - i-- - dAtA[i] = 0x10 - } - if len(m.DelegatorAddress) > 0 { - i -= len(m.DelegatorAddress) - copy(dAtA[i:], m.DelegatorAddress) - i = encodeVarintTx(dAtA, i, uint64(len(m.DelegatorAddress))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgWithdrawRewardsResponse) 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 *MsgWithdrawRewardsResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgWithdrawRewardsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func (m *MsgWithdrawValidatorCommission) 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 *MsgWithdrawValidatorCommission) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgWithdrawValidatorCommission) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.ValidatorAddress) > 0 { - i -= len(m.ValidatorAddress) - copy(dAtA[i:], m.ValidatorAddress) - i = encodeVarintTx(dAtA, i, uint64(len(m.ValidatorAddress))) - i-- - dAtA[i] = 0x12 - } - if len(m.DelegatorAddress) > 0 { - i -= len(m.DelegatorAddress) - copy(dAtA[i:], m.DelegatorAddress) - i = encodeVarintTx(dAtA, i, uint64(len(m.DelegatorAddress))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgWithdrawValidatorCommissionResponse) 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 *MsgWithdrawValidatorCommissionResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgWithdrawValidatorCommissionResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func (m *MsgUpdateIncentiveParams) 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 *MsgUpdateIncentiveParams) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgUpdateIncentiveParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.DistributionInterval != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.DistributionInterval)) - i-- - dAtA[i] = 0x38 - } - { - size := m.MaxEdenRewardAprLps.Size() - i -= size - if _, err := m.MaxEdenRewardAprLps.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x32 - { - size := m.MaxEdenRewardAprStakers.Size() - i -= size - if _, err := m.MaxEdenRewardAprStakers.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x2a - if m.ElysStakeSnapInterval != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.ElysStakeSnapInterval)) - i-- - dAtA[i] = 0x20 - } - { - size := m.RewardPortionForStakers.Size() - i -= size - if _, err := m.RewardPortionForStakers.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - { - size := m.RewardPortionForLps.Size() - i -= size - if _, err := m.RewardPortionForLps.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - if len(m.Authority) > 0 { - i -= len(m.Authority) - copy(dAtA[i:], m.Authority) - i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgUpdateIncentiveParamsResponse) 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 *MsgUpdateIncentiveParamsResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgUpdateIncentiveParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func (m *MsgBeginRedelegate) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { +func (m *MsgBeginRedelegate) 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 @@ -1103,230 +297,38 @@ func (m *MsgCancelUnbondingDelegation) MarshalToSizedBuffer(dAtA []byte) (int, e return len(dAtA) - i, nil } -func (m *PoolMultiplier) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err +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++ } - return dAtA[:n], nil -} - -func (m *PoolMultiplier) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) + dAtA[offset] = uint8(v) + return base } - -func (m *PoolMultiplier) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i +func (m *MsgBeginRedelegate) Size() (n int) { + if m == nil { + return 0 + } var l int _ = l - { - size := m.Multiplier.Size() - i -= size - if _, err := m.Multiplier.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintTx(dAtA, i, uint64(size)) + l = len(m.DelegatorAddress) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) } - i-- - dAtA[i] = 0x12 - if m.PoolId != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.PoolId)) - i-- - dAtA[i] = 0x8 + l = len(m.ValidatorSrcAddress) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) } - return len(dAtA) - i, nil -} - -func (m *MsgUpdatePoolMultipliers) 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 *MsgUpdatePoolMultipliers) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgUpdatePoolMultipliers) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.PoolMultipliers) > 0 { - for iNdEx := len(m.PoolMultipliers) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.PoolMultipliers[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - } - if len(m.Authority) > 0 { - i -= len(m.Authority) - copy(dAtA[i:], m.Authority) - i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgUpdatePoolMultipliersResponse) 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 *MsgUpdatePoolMultipliersResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgUpdatePoolMultipliersResponse) 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 *MsgWithdrawRewards) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.DelegatorAddress) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - if m.WithdrawType != 0 { - n += 1 + sovTx(uint64(m.WithdrawType)) - } - return n -} - -func (m *MsgWithdrawRewardsResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *MsgWithdrawValidatorCommission) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.DelegatorAddress) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.ValidatorAddress) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - return n -} - -func (m *MsgWithdrawValidatorCommissionResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *MsgUpdateIncentiveParams) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Authority) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = m.RewardPortionForLps.Size() - n += 1 + l + sovTx(uint64(l)) - l = m.RewardPortionForStakers.Size() - n += 1 + l + sovTx(uint64(l)) - if m.ElysStakeSnapInterval != 0 { - n += 1 + sovTx(uint64(m.ElysStakeSnapInterval)) - } - l = m.MaxEdenRewardAprStakers.Size() - n += 1 + l + sovTx(uint64(l)) - l = m.MaxEdenRewardAprLps.Size() - n += 1 + l + sovTx(uint64(l)) - if m.DistributionInterval != 0 { - n += 1 + sovTx(uint64(m.DistributionInterval)) - } - return n -} - -func (m *MsgUpdateIncentiveParamsResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *MsgBeginRedelegate) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.DelegatorAddress) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.ValidatorSrcAddress) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.ValidatorDstAddress) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = m.Amount.Size() - n += 1 + l + sovTx(uint64(l)) - return n + l = len(m.ValidatorDstAddress) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.Amount.Size() + n += 1 + l + sovTx(uint64(l)) + return n } func (m *MsgCancelUnbondingDelegation) Size() (n int) { @@ -1350,675 +352,12 @@ func (m *MsgCancelUnbondingDelegation) Size() (n int) { } return n } - -func (m *PoolMultiplier) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.PoolId != 0 { - n += 1 + sovTx(uint64(m.PoolId)) - } - l = m.Multiplier.Size() - n += 1 + l + sovTx(uint64(l)) - return n -} - -func (m *MsgUpdatePoolMultipliers) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Authority) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - if len(m.PoolMultipliers) > 0 { - for _, e := range m.PoolMultipliers { - l = e.Size() - n += 1 + l + sovTx(uint64(l)) - } - } - return n -} - -func (m *MsgUpdatePoolMultipliersResponse) 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 *MsgWithdrawRewards) 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: MsgWithdrawRewards: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgWithdrawRewards: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DelegatorAddress", 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.DelegatorAddress = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field WithdrawType", wireType) - } - m.WithdrawType = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.WithdrawType |= types.EarnType(b&0x7F) << shift - if b < 0x80 { - break - } - } - 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 *MsgWithdrawRewardsResponse) 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: MsgWithdrawRewardsResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgWithdrawRewardsResponse: 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 *MsgWithdrawValidatorCommission) 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: MsgWithdrawValidatorCommission: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgWithdrawValidatorCommission: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DelegatorAddress", 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.DelegatorAddress = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ValidatorAddress", 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.ValidatorAddress = 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 *MsgWithdrawValidatorCommissionResponse) 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: MsgWithdrawValidatorCommissionResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgWithdrawValidatorCommissionResponse: 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 *MsgUpdateIncentiveParams) 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: MsgUpdateIncentiveParams: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpdateIncentiveParams: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Authority", 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.Authority = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RewardPortionForLps", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.RewardPortionForLps.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RewardPortionForStakers", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.RewardPortionForStakers.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ElysStakeSnapInterval", wireType) - } - m.ElysStakeSnapInterval = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.ElysStakeSnapInterval |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field MaxEdenRewardAprStakers", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.MaxEdenRewardAprStakers.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field MaxEdenRewardAprLps", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.MaxEdenRewardAprLps.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 7: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field DistributionInterval", wireType) - } - m.DistributionInterval = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.DistributionInterval |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - 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 *MsgUpdateIncentiveParamsResponse) 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: MsgUpdateIncentiveParamsResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpdateIncentiveParamsResponse: 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 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 *MsgBeginRedelegate) Unmarshal(dAtA []byte) error { l := len(dAtA) @@ -2365,275 +704,6 @@ func (m *MsgCancelUnbondingDelegation) Unmarshal(dAtA []byte) error { } return nil } -func (m *PoolMultiplier) 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: PoolMultiplier: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: PoolMultiplier: 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 Multiplier", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Multiplier.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 *MsgUpdatePoolMultipliers) 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: MsgUpdatePoolMultipliers: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpdatePoolMultipliers: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Authority", 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.Authority = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PoolMultipliers", 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 - } - m.PoolMultipliers = append(m.PoolMultipliers, PoolMultiplier{}) - if err := m.PoolMultipliers[len(m.PoolMultipliers)-1].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 *MsgUpdatePoolMultipliersResponse) 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: MsgUpdatePoolMultipliersResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpdatePoolMultipliersResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} func skipTx(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/incentive/types/types.go b/x/incentive/types/types.go index b387d7b5f..ab1254f4c 100644 --- a/x/incentive/types/types.go +++ b/x/incentive/types/types.go @@ -1,29 +1 @@ package types - -import ( - fmt "fmt" - - "cosmossdk.io/math" - sdk "github.com/cosmos/cosmos-sdk/types" -) - -// TotalCommitmentInfo -// Stores the -type TotalCommitmentInfo struct { - // Total Elys staked - TotalElysBonded math.Int - // Total Eden + Eden boost committed - TotalEdenEdenBoostCommitted math.Int - // Gas fees collected and DEX revenus - TotalFeesCollected sdk.Coins - // Total Lp Token committed - TotalLpTokensCommitted map[string]math.Int - // Revenue tracking per pool, key => (poolId) - PoolRevenueTrack map[string]sdk.Dec -} - -// Returns the pool revenue tracking key. -// Unique per pool per epoch, clean once complete the calculation. -func GetPoolRevenueTrackKey(poolId uint64) string { - return fmt.Sprintf("pool_revenue_%d", poolId) -} diff --git a/x/masterchef/client/cli/query.go b/x/masterchef/client/cli/query.go new file mode 100644 index 000000000..25a39e63e --- /dev/null +++ b/x/masterchef/client/cli/query.go @@ -0,0 +1,33 @@ +package cli + +import ( + "fmt" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/elys-network/elys/x/masterchef/types" + "github.com/spf13/cobra" +) + +// GetQueryCmd returns the cli query commands for this module +func GetQueryCmd(queryRoute string) *cobra.Command { + // Group masterchef queries under a subcommand + 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(CmdQueryParams()) + cmd.AddCommand(CmdQueryExternalIncentive()) + cmd.AddCommand(CmdQueryPoolInfo()) + cmd.AddCommand(CmdQueryPoolRewardInfo()) + cmd.AddCommand(CmdQueryUserRewardInfo()) + cmd.AddCommand(CmdQueryUserPendingReward()) + cmd.AddCommand(CmdQueryStableStakeApr()) + cmd.AddCommand(CmdQueryPoolAprs()) + // this line is used by starport scaffolding # 1 + + return cmd +} diff --git a/x/masterchef/client/cli/query_cmds.go b/x/masterchef/client/cli/query_cmds.go new file mode 100644 index 000000000..aef265d23 --- /dev/null +++ b/x/masterchef/client/cli/query_cmds.go @@ -0,0 +1,253 @@ +package cli + +import ( + "context" + "strconv" + "strings" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/elys-network/elys/x/masterchef/types" + "github.com/spf13/cobra" +) + +func CmdQueryParams() *cobra.Command { + cmd := &cobra.Command{ + Use: "params", + Short: "shows the parameters of the module", + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + + queryClient := types.NewQueryClient(clientCtx) + + res, err := queryClient.Params(context.Background(), &types.QueryParamsRequest{}) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +func CmdQueryStableStakeApr() *cobra.Command { + cmd := &cobra.Command{ + Use: "stable-stake-apr", + Short: "calculate Stable Stake APR", + Example: "elysd q masterchef stable-stake-apr [denom]", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + + queryClient := types.NewQueryClient(clientCtx) + + denom := args[0] + + params := &types.QueryStableStakeAprRequest{ + Denom: denom, + } + + res, err := queryClient.StableStakeApr(context.Background(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +func CmdQueryPoolAprs() *cobra.Command { + cmd := &cobra.Command{ + Use: "pool-aprs", + Short: "calculate pool APRs", + Example: "elysd q masterchef pool-aprs [ids]", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + queryClient := types.NewQueryClient(clientCtx) + + idStrs := strings.Split(args[0], ",") + ids := []uint64{} + if args[0] != "" { + for _, idStr := range idStrs { + id, err := strconv.Atoi(idStr) + if err != nil { + return err + } + ids = append(ids, uint64(id)) + } + } + params := &types.QueryPoolAprsRequest{ + PoolIds: ids, + } + + res, err := queryClient.PoolAprs(context.Background(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +func CmdQueryExternalIncentive() *cobra.Command { + cmd := &cobra.Command{ + Use: "external-incentive", + Short: "shows external incentive", + Example: "elysd q masterchef external-incentive [id]", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + queryClient := types.NewQueryClient(clientCtx) + + id, _ := strconv.Atoi(args[0]) + params := &types.QueryExternalIncentiveRequest{ + Id: uint64(id), + } + + res, err := queryClient.ExternalIncentive(context.Background(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +func CmdQueryPoolInfo() *cobra.Command { + cmd := &cobra.Command{ + Use: "pool-info", + Short: "shows pool info", + Example: "elysd q masterchef pool-info [id]", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + queryClient := types.NewQueryClient(clientCtx) + + id, _ := strconv.Atoi(args[0]) + params := &types.QueryPoolInfoRequest{ + PoolId: uint64(id), + } + + res, err := queryClient.PoolInfo(context.Background(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +func CmdQueryPoolRewardInfo() *cobra.Command { + cmd := &cobra.Command{ + Use: "pool-reward-info", + Short: "shows pool reward info", + Example: "elysd q masterchef pool-reward-info [id] [reward-denom]", + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + queryClient := types.NewQueryClient(clientCtx) + + id, _ := strconv.Atoi(args[0]) + params := &types.QueryPoolRewardInfoRequest{ + PoolId: uint64(id), + RewardDenom: args[1], + } + + res, err := queryClient.PoolRewardInfo(context.Background(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +func CmdQueryUserRewardInfo() *cobra.Command { + cmd := &cobra.Command{ + Use: "user-reward-info", + Short: "shows user reward info", + Example: "elysd q masterchef user-reward-info [user] [id] [reward-denom]", + Args: cobra.ExactArgs(3), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + queryClient := types.NewQueryClient(clientCtx) + + id, _ := strconv.Atoi(args[1]) + params := &types.QueryUserRewardInfoRequest{ + User: args[0], + PoolId: uint64(id), + RewardDenom: args[2], + } + + res, err := queryClient.UserRewardInfo(context.Background(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +func CmdQueryUserPendingReward() *cobra.Command { + cmd := &cobra.Command{ + Use: "user-pending-reward", + Short: "shows user pending reward", + Example: "elysd q masterchef user-pending-reward [user]", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + queryClient := types.NewQueryClient(clientCtx) + + params := &types.QueryUserPendingRewardRequest{ + User: args[0], + } + + res, err := queryClient.UserPendingReward(context.Background(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/masterchef/client/cli/tx.go b/x/masterchef/client/cli/tx.go new file mode 100644 index 000000000..b494c06e3 --- /dev/null +++ b/x/masterchef/client/cli/tx.go @@ -0,0 +1,47 @@ +package cli + +import ( + "fmt" + "time" + + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client" + // "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/elys-network/elys/x/masterchef/types" +) + +var ( + DefaultRelativePacketTimeoutTimestamp = uint64((time.Duration(10) * time.Minute).Nanoseconds()) +) + +const ( + flagPacketTimeoutTimestamp = "packet-timeout-timestamp" + listSeparator = "," +) + +var ( + FlagPoolIds = "pool-ids" +) + +// GetTxCmd returns the transaction commands for this module +func GetTxCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: types.ModuleName, + Short: fmt.Sprintf("%s transactions subcommands", types.ModuleName), + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + cmd.AddCommand( + CmdAddExternalRewardDenom(), + CmdAddExternalIncentive(), + CmdUpdatePoolMultipliers(), + CmdClaimRewards(), + ) + + // this line is used by starport scaffolding # 1 + + return cmd +} diff --git a/x/masterchef/client/cli/tx_cmds.go b/x/masterchef/client/cli/tx_cmds.go new file mode 100644 index 000000000..234ca415e --- /dev/null +++ b/x/masterchef/client/cli/tx_cmds.go @@ -0,0 +1,308 @@ +package cli + +import ( + "errors" + "fmt" + "strconv" + "strings" + + "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/types/address" + "github.com/cosmos/cosmos-sdk/version" + "github.com/cosmos/cosmos-sdk/x/gov/client/cli" + v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" + "github.com/elys-network/elys/x/masterchef/types" + "github.com/spf13/cobra" +) + +func CmdAddExternalIncentive() *cobra.Command { + cmd := &cobra.Command{ + Use: "add-external-incentive [reward-denom] [pool-id] [from-block] [to-block] [amount-per-block]", + Short: "Broadcast message add-external-incentive [reward-denom] [pool-id] [from-block] [to-block] [amount-per-block]", + Args: cobra.ExactArgs(5), + RunE: func(cmd *cobra.Command, args []string) (err error) { + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + signer := clientCtx.GetFromAddress() + if signer == nil { + return errors.New("signer address is missing") + } + + rewardDenom := args[0] + poolId, err := strconv.ParseUint(args[1], 10, 64) + if err != nil { + return errors.New("invalid pool id") + } + fromBlock, err := strconv.ParseUint(args[2], 10, 64) + if err != nil { + return errors.New("invalid from block") + } + toBlock, err := strconv.ParseUint(args[3], 10, 64) + if err != nil { + return errors.New("invalid to block") + } + amountPerBlock, ok := sdk.NewIntFromString(args[4]) + if !ok { + return errors.New("invalid amount per block") + } + + msg := &types.MsgAddExternalIncentive{ + Sender: signer.String(), + RewardDenom: rewardDenom, + PoolId: poolId, + FromBlock: fromBlock, + ToBlock: toBlock, + AmountPerBlock: amountPerBlock, + } + + if err := msg.ValidateBasic(); err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + +func CmdAddExternalRewardDenom() *cobra.Command { + cmd := &cobra.Command{ + Use: "add-external-reward-denom [reward-denom] [min-amount] [supported]", + Short: "Broadcast message add-external-reward-denom [reward-denom] [min-amount] [supported]", + Args: cobra.ExactArgs(3), + RunE: func(cmd *cobra.Command, args []string) (err error) { + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + title, err := cmd.Flags().GetString(cli.FlagTitle) + if err != nil { + return err + } + + summary, err := cmd.Flags().GetString(cli.FlagSummary) + if err != nil { + return err + } + + metadata, err := cmd.Flags().GetString(cli.FlagMetadata) + if err != nil { + return err + } + + signer := clientCtx.GetFromAddress() + if signer == nil { + return errors.New("signer address is missing") + } + + rewardDenom := args[0] + minAmount, ok := sdk.NewIntFromString(args[1]) + if !ok { + return errors.New("invalid min amount") + } + supported, err := strconv.ParseBool(args[2]) + if err != nil { + return err + } + + govAddress := sdk.AccAddress(address.Module("gov")) + msg := &types.MsgAddExternalRewardDenom{ + Authority: govAddress.String(), + RewardDenom: rewardDenom, + MinAmount: minAmount, + Supported: supported, + } + if err := msg.ValidateBasic(); err != nil { + return err + } + + depositStr, err := cmd.Flags().GetString(cli.FlagDeposit) + if err != nil { + return err + } + + deposit, err := sdk.ParseCoinsNormalized(depositStr) + if err != nil { + return err + } + + govMsg, err := v1.NewMsgSubmitProposal([]sdk.Msg{msg}, deposit, signer.String(), metadata, title, summary) + if err != nil { + return err + } + + err = tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), govMsg) + if err != nil { + return err + } + + return nil + }, + } + + cmd.Flags().String(cli.FlagTitle, "", "title of proposal") + cmd.Flags().String(cli.FlagSummary, "", "summary of proposal") + cmd.Flags().String(cli.FlagMetadata, "", "metadata of proposal") + cmd.Flags().String(cli.FlagDeposit, "", "deposit of proposal") + + _ = cmd.MarkFlagRequired(cli.FlagTitle) + _ = cmd.MarkFlagRequired(cli.FlagSummary) + _ = cmd.MarkFlagRequired(cli.FlagMetadata) + _ = cmd.MarkFlagRequired(cli.FlagDeposit) + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + +func CmdUpdatePoolMultipliers() *cobra.Command { + cmd := &cobra.Command{ + Use: "update-pool-multipliers [pool-id] [multiplier]", + Short: "Broadcast message update-pool-multipliers [pool-id] [multiplier]", + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) (err error) { + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + title, err := cmd.Flags().GetString(cli.FlagTitle) + if err != nil { + return err + } + + summary, err := cmd.Flags().GetString(cli.FlagSummary) + if err != nil { + return err + } + + metadata, err := cmd.Flags().GetString(cli.FlagMetadata) + if err != nil { + return err + } + + signer := clientCtx.GetFromAddress() + if signer == nil { + return errors.New("signer address is missing") + } + + poolId, err := strconv.ParseUint(args[0], 10, 64) + if err != nil { + return err + } + multiplier := sdk.MustNewDecFromStr(args[1]) + + poolMultipliers := []types.PoolMultiplier{} + poolMultipliers = append(poolMultipliers, types.PoolMultiplier{ + PoolId: poolId, + Multiplier: multiplier, + }) + govAddress := sdk.AccAddress(address.Module("gov")) + msg := &types.MsgUpdatePoolMultipliers{ + Authority: govAddress.String(), + PoolMultipliers: poolMultipliers, + } + if err := msg.ValidateBasic(); err != nil { + return err + } + + depositStr, err := cmd.Flags().GetString(cli.FlagDeposit) + if err != nil { + return err + } + + deposit, err := sdk.ParseCoinsNormalized(depositStr) + if err != nil { + return err + } + + govMsg, err := v1.NewMsgSubmitProposal([]sdk.Msg{msg}, deposit, signer.String(), metadata, title, summary) + if err != nil { + return err + } + + err = tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), govMsg) + if err != nil { + return err + } + + return nil + }, + } + + cmd.Flags().String(cli.FlagTitle, "", "title of proposal") + cmd.Flags().String(cli.FlagSummary, "", "summary of proposal") + cmd.Flags().String(cli.FlagMetadata, "", "metadata of proposal") + cmd.Flags().String(cli.FlagDeposit, "", "deposit of proposal") + + _ = cmd.MarkFlagRequired(cli.FlagTitle) + _ = cmd.MarkFlagRequired(cli.FlagSummary) + _ = cmd.MarkFlagRequired(cli.FlagMetadata) + _ = cmd.MarkFlagRequired(cli.FlagDeposit) + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + +func CmdClaimRewards() *cobra.Command { + cmd := &cobra.Command{ + Use: "claim-rewards", + Short: "claim rewards including external incentives", + Long: strings.TrimSpace( + fmt.Sprintf(`Claim rewards from a given delegation address, +Example: +$ %s tx masterchef claim-rewards --from mykey --pool-ids [pool-ids] +`, + version.AppName, + ), + ), + Args: cobra.ExactArgs(0), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + delAddr := clientCtx.GetFromAddress() + poolIds := []uint64{} + + poolIdsString, err := cmd.Flags().GetString(FlagPoolIds) + if err != nil { + poolIdsArray := strings.Split(poolIdsString, ",") + for _, poolIdStr := range poolIdsArray { + poolId, err := strconv.ParseUint(poolIdStr, 10, 64) + if err != nil { + return err + } + poolIds = append(poolIds, poolId) + } + } + + msgs := []sdk.Msg{&types.MsgClaimRewards{ + Sender: delAddr.String(), + PoolIds: poolIds, + }} + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msgs...) + }, + } + + cmd.Flags().String(FlagPoolIds, "", "Validator's operator address to withdraw commission from") + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} diff --git a/x/masterchef/client/wasm/messenger.go b/x/masterchef/client/wasm/messenger.go new file mode 100644 index 000000000..7b0ceca81 --- /dev/null +++ b/x/masterchef/client/wasm/messenger.go @@ -0,0 +1,44 @@ +package wasm + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" + wasmbindingstypes "github.com/elys-network/elys/wasmbindings/types" + commitmentkeeper "github.com/elys-network/elys/x/commitment/keeper" + "github.com/elys-network/elys/x/masterchef/keeper" + masterchefkeeper "github.com/elys-network/elys/x/masterchef/keeper" + parameterkeeper "github.com/elys-network/elys/x/parameter/keeper" +) + +// Messenger handles messages for the Masterchef module. +type Messenger struct { + keeper *keeper.Keeper + stakingKeeper *stakingkeeper.Keeper + commitmentKeeper *commitmentkeeper.Keeper + parameterKeeper *parameterkeeper.Keeper + masterchefKeeper *masterchefkeeper.Keeper +} + +func NewMessenger( + keeper *keeper.Keeper, + stakingKeeper *stakingkeeper.Keeper, + commitmentKeeper *commitmentkeeper.Keeper, + parameterKeeper *parameterkeeper.Keeper, +) *Messenger { + return &Messenger{ + keeper: keeper, + stakingKeeper: stakingKeeper, + commitmentKeeper: commitmentKeeper, + parameterKeeper: parameterKeeper, + } +} + +func (m *Messenger) HandleMsg(ctx sdk.Context, contractAddr sdk.AccAddress, contractIBCPortID string, msg wasmbindingstypes.ElysMsg) ([]sdk.Event, [][]byte, error) { + switch { + case msg.MasterchefClaimRewards != nil: + return m.msgClaimRewards(ctx, contractAddr, msg.MasterchefClaimRewards) + default: + // This handler cannot handle the message + return nil, nil, wasmbindingstypes.ErrCannotHandleMsg + } +} diff --git a/x/masterchef/client/wasm/msg_claim_rewards.go b/x/masterchef/client/wasm/msg_claim_rewards.go new file mode 100644 index 000000000..7ce60d0e5 --- /dev/null +++ b/x/masterchef/client/wasm/msg_claim_rewards.go @@ -0,0 +1,70 @@ +package wasm + +import ( + "encoding/json" + + errorsmod "cosmossdk.io/errors" + wasmvmtypes "github.com/CosmWasm/wasmvm/types" + sdk "github.com/cosmos/cosmos-sdk/types" + wasmbindingstypes "github.com/elys-network/elys/wasmbindings/types" + masterchefkeeper "github.com/elys-network/elys/x/masterchef/keeper" + "github.com/elys-network/elys/x/masterchef/types" + paramtypes "github.com/elys-network/elys/x/parameter/types" +) + +func (m *Messenger) msgClaimRewards(ctx sdk.Context, contractAddr sdk.AccAddress, msgClaimRewards *types.MsgClaimRewards) ([]sdk.Event, [][]byte, error) { + var res *wasmbindingstypes.RequestResponse + var err error + + brokerAddress := m.parameterKeeper.GetParams(ctx).BrokerAddress + if msgClaimRewards.Sender != contractAddr.String() && contractAddr.String() != brokerAddress { + return nil, nil, wasmvmtypes.InvalidRequest{Err: "wrong sender"} + } + + res, err = performMsgClaimRewards(m.masterchefKeeper, ctx, contractAddr, msgClaimRewards) + if err != nil { + return nil, nil, errorsmod.Wrap(err, "perform elys claim rewards") + } + + responseBytes, err := json.Marshal(*res) + if err != nil { + return nil, nil, errorsmod.Wrap(err, "failed to serialize stake") + } + + resp := [][]byte{responseBytes} + + return nil, resp, nil +} + +func performMsgClaimRewards(f *masterchefkeeper.Keeper, ctx sdk.Context, contractAddr sdk.AccAddress, msgClaimRewards *types.MsgClaimRewards) (*wasmbindingstypes.RequestResponse, error) { + if msgClaimRewards == nil { + return nil, wasmvmtypes.InvalidRequest{Err: "Invalid claim rewards parameter"} + } + + msgServer := masterchefkeeper.NewMsgServerImpl(*f) + _, err := sdk.AccAddressFromBech32(msgClaimRewards.Sender) + if err != nil { + return nil, errorsmod.Wrap(err, "invalid address") + } + + msgMsgClaimRewards := &types.MsgClaimRewards{ + Sender: msgClaimRewards.Sender, + PoolIds: msgClaimRewards.PoolIds, + } + + if err := msgMsgClaimRewards.ValidateBasic(); err != nil { + return nil, errorsmod.Wrap(err, "failed validating msgMsgDelegate") + } + + _, err = msgServer.ClaimRewards(sdk.WrapSDKContext(ctx), msgMsgClaimRewards) // Discard the response because it's empty + if err != nil { + return nil, errorsmod.Wrap(err, "elys redelegation msg") + } + + resp := &wasmbindingstypes.RequestResponse{ + Code: paramtypes.RES_OK, + Result: "Redelegation succeed!", + } + + return resp, nil +} diff --git a/x/masterchef/client/wasm/querier.go b/x/masterchef/client/wasm/querier.go new file mode 100644 index 000000000..2f237d13f --- /dev/null +++ b/x/masterchef/client/wasm/querier.go @@ -0,0 +1,153 @@ +package wasm + +import ( + "encoding/json" + + errorsmod "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" + wasmbindingstypes "github.com/elys-network/elys/wasmbindings/types" + "github.com/elys-network/elys/x/masterchef/keeper" + "github.com/elys-network/elys/x/masterchef/types" +) + +// Querier handles queries for the Masterchef module. +type Querier struct { + keeper *keeper.Keeper + stakingKeeper *stakingkeeper.Keeper +} + +func NewQuerier(keeper *keeper.Keeper, stakingKeeper *stakingkeeper.Keeper) *Querier { + return &Querier{ + keeper: keeper, + stakingKeeper: stakingKeeper, + } +} + +func (oq *Querier) HandleQuery(ctx sdk.Context, query wasmbindingstypes.ElysQuery) ([]byte, error) { + switch { + case query.MasterchefParams != nil: + return oq.queryParams(ctx, query.MasterchefParams) + case query.MasterchefExternalIncentive != nil: + return oq.queryExternalIncentive(ctx, query.MasterchefExternalIncentive) + case query.MasterchefPoolInfo != nil: + return oq.queryPoolInfo(ctx, query.MasterchefPoolInfo) + case query.MasterchefPoolRewardInfo != nil: + return oq.queryPoolRewardInfo(ctx, query.MasterchefPoolRewardInfo) + case query.MasterchefUserRewardInfo != nil: + return oq.queryUserRewardInfo(ctx, query.MasterchefUserRewardInfo) + case query.MasterchefUserPendingReward != nil: + return oq.queryUserPendingReward(ctx, query.MasterchefUserPendingReward) + case query.MasterchefStableStakeApr != nil: + return oq.queryStableStakeApr(ctx, query.MasterchefStableStakeApr) + case query.MasterchefPoolAprs != nil: + return oq.queryPoolAprs(ctx, query.MasterchefPoolAprs) + default: + // This handler cannot handle the query + return nil, wasmbindingstypes.ErrCannotHandleQuery + } +} + +func (oq *Querier) queryParams(ctx sdk.Context, query *types.QueryParamsRequest) ([]byte, error) { + res, err := oq.keeper.Params(ctx, query) + if err != nil { + return nil, errorsmod.Wrap(err, "failed to get params") + } + + responseBytes, err := json.Marshal(res) + if err != nil { + return nil, errorsmod.Wrap(err, "failed to serialize params response") + } + return responseBytes, nil +} + +func (oq *Querier) queryExternalIncentive(ctx sdk.Context, query *types.QueryExternalIncentiveRequest) ([]byte, error) { + res, err := oq.keeper.ExternalIncentive(ctx, query) + if err != nil { + return nil, errorsmod.Wrap(err, "failed to get external incentive") + } + + responseBytes, err := json.Marshal(res) + if err != nil { + return nil, errorsmod.Wrap(err, "failed to serialize external incentive response") + } + return responseBytes, nil +} + +func (oq *Querier) queryPoolInfo(ctx sdk.Context, query *types.QueryPoolInfoRequest) ([]byte, error) { + res, err := oq.keeper.PoolInfo(ctx, query) + if err != nil { + return nil, errorsmod.Wrap(err, "failed to get pool info") + } + + responseBytes, err := json.Marshal(res) + if err != nil { + return nil, errorsmod.Wrap(err, "failed to serialize pool info response") + } + return responseBytes, nil +} + +func (oq *Querier) queryPoolRewardInfo(ctx sdk.Context, query *types.QueryPoolRewardInfoRequest) ([]byte, error) { + res, err := oq.keeper.PoolRewardInfo(ctx, query) + if err != nil { + return nil, errorsmod.Wrap(err, "failed to get pool reward info") + } + + responseBytes, err := json.Marshal(res) + if err != nil { + return nil, errorsmod.Wrap(err, "failed to serialize pool reward info response") + } + return responseBytes, nil +} + +func (oq *Querier) queryUserRewardInfo(ctx sdk.Context, query *types.QueryUserRewardInfoRequest) ([]byte, error) { + res, err := oq.keeper.UserRewardInfo(ctx, query) + if err != nil { + return nil, errorsmod.Wrap(err, "failed to get user reward info") + } + + responseBytes, err := json.Marshal(res) + if err != nil { + return nil, errorsmod.Wrap(err, "failed to serialize user reward info response") + } + return responseBytes, nil +} + +func (oq *Querier) queryUserPendingReward(ctx sdk.Context, query *types.QueryUserPendingRewardRequest) ([]byte, error) { + res, err := oq.keeper.UserPendingReward(ctx, query) + if err != nil { + return nil, errorsmod.Wrap(err, "failed to get user pending reward") + } + + responseBytes, err := json.Marshal(res) + if err != nil { + return nil, errorsmod.Wrap(err, "failed to serialize user pending reward response") + } + return responseBytes, nil +} + +func (oq *Querier) queryStableStakeApr(ctx sdk.Context, query *types.QueryStableStakeAprRequest) ([]byte, error) { + res, err := oq.keeper.StableStakeApr(ctx, query) + if err != nil { + return nil, errorsmod.Wrap(err, "failed to get user pending reward") + } + + responseBytes, err := json.Marshal(res) + if err != nil { + return nil, errorsmod.Wrap(err, "failed to serialize user pending reward response") + } + return responseBytes, nil +} + +func (oq *Querier) queryPoolAprs(ctx sdk.Context, query *types.QueryPoolAprsRequest) ([]byte, error) { + res, err := oq.keeper.PoolAprs(ctx, query) + if err != nil { + return nil, errorsmod.Wrap(err, "failed to get user pending reward") + } + + responseBytes, err := json.Marshal(res) + if err != nil { + return nil, errorsmod.Wrap(err, "failed to serialize user pending reward response") + } + return responseBytes, nil +} diff --git a/x/masterchef/genesis.go b/x/masterchef/genesis.go new file mode 100644 index 000000000..aac2c96a5 --- /dev/null +++ b/x/masterchef/genesis.go @@ -0,0 +1,43 @@ +package masterchef + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/elys-network/elys/x/masterchef/keeper" + "github.com/elys-network/elys/x/masterchef/types" +) + +// InitGenesis initializes the module's state from a provided genesis state. +func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) { + // this line is used by starport scaffolding # genesis/module/init + k.SetParams(ctx, genState.Params) + + for _, elem := range genState.PoolInfos { + k.SetPool(ctx, elem) + } + + for _, elem := range genState.ExternalIncentives { + k.SetExternalIncentive(ctx, elem) + } + + for _, elem := range genState.PoolRewardInfos { + k.SetPoolRewardInfo(ctx, elem) + } + + for _, elem := range genState.UserRewardInfos { + k.SetUserRewardInfo(ctx, elem) + } +} + +// ExportGenesis returns the module's exported genesis +func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { + genesis := types.DefaultGenesis() + genesis.Params = k.GetParams(ctx) + genesis.ExternalIncentives = k.GetAllExternalIncentives(ctx) + genesis.PoolInfos = k.GetAllPools(ctx) + genesis.PoolRewardInfos = k.GetAllPoolRewardInfos(ctx) + genesis.UserRewardInfos = k.GetAllUserRewardInfos(ctx) + + // this line is used by starport scaffolding # genesis/module/export + + return genesis +} diff --git a/x/masterchef/genesis_test.go b/x/masterchef/genesis_test.go new file mode 100644 index 000000000..bd03cd25e --- /dev/null +++ b/x/masterchef/genesis_test.go @@ -0,0 +1,29 @@ +package masterchef_test + +import ( + "testing" + + keepertest "github.com/elys-network/elys/testutil/keeper" + "github.com/elys-network/elys/testutil/nullify" + "github.com/elys-network/elys/x/masterchef" + "github.com/elys-network/elys/x/masterchef/types" + "github.com/stretchr/testify/require" +) + +func TestGenesis(t *testing.T) { + genesisState := types.GenesisState{ + Params: types.DefaultParams(), + + // this line is used by starport scaffolding # genesis/test/state + } + + k, ctx := keepertest.MasterchefKeeper(t) + masterchef.InitGenesis(ctx, *k, genesisState) + got := masterchef.ExportGenesis(ctx, *k) + require.NotNil(t, got) + + nullify.Fill(&genesisState) + nullify.Fill(got) + + // this line is used by starport scaffolding # genesis/test/assert +} diff --git a/x/masterchef/keeper/abci.go b/x/masterchef/keeper/abci.go new file mode 100644 index 000000000..36f03a0f8 --- /dev/null +++ b/x/masterchef/keeper/abci.go @@ -0,0 +1,632 @@ +package keeper + +import ( + "errors" + + errorsmod "cosmossdk.io/errors" + "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + ammtypes "github.com/elys-network/elys/x/amm/types" + assetprofiletypes "github.com/elys-network/elys/x/assetprofile/types" + "github.com/elys-network/elys/x/masterchef/types" + ptypes "github.com/elys-network/elys/x/parameter/types" + stabletypes "github.com/elys-network/elys/x/stablestake/types" +) + +// EndBlocker of amm module +func (k Keeper) EndBlocker(ctx sdk.Context) { + // distribute LP rewards + k.ProcessLPRewardDistribution(ctx) + // distribute external rewards + k.ProcessExternalRewardsDistribution(ctx) +} + +func (k Keeper) GetPoolTVL(ctx sdk.Context, poolId uint64) math.LegacyDec { + if poolId == stabletypes.PoolId { + entry, found := k.assetProfileKeeper.GetEntry(ctx, ptypes.BaseCurrency) + if !found { + return math.LegacyZeroDec() + } + baseCurrency := entry.Denom + return k.stableKeeper.TVL(ctx, k.oracleKeeper, baseCurrency) + } + ammPool, found := k.amm.GetPool(ctx, poolId) + if found { + tvl, err := ammPool.TVL(ctx, k.oracleKeeper) + if err != nil { + return math.LegacyZeroDec() + } + return tvl + } + return math.LegacyZeroDec() +} + +func (k Keeper) ProcessExternalRewardsDistribution(ctx sdk.Context) { + canDistribute := k.CanDistributeLPRewards(ctx) + if !canDistribute { + return + } + + // Fetch incentive params + params := k.GetParams(ctx) + lpIncentive := params.LpIncentives + + curBlockHeight := sdk.NewInt(ctx.BlockHeight()) + + externalIncentives := k.GetAllExternalIncentives(ctx) + for _, externalIncentive := range externalIncentives { + pool, found := k.GetPool(ctx, externalIncentive.PoolId) + if !found { + continue + } + + if externalIncentive.FromBlock < curBlockHeight.Uint64() && curBlockHeight.Uint64() <= externalIncentive.ToBlock { + k.UpdateAccPerShare(ctx, externalIncentive.PoolId, externalIncentive.RewardDenom, externalIncentive.AmountPerBlock) + + hasRewardDenom := false + poolRewardDenoms := pool.ExternalRewardDenoms + for _, poolRewardDenom := range poolRewardDenoms { + if poolRewardDenom == externalIncentive.RewardDenom { + hasRewardDenom = true + } + } + if !hasRewardDenom { + pool.ExternalRewardDenoms = append(pool.ExternalRewardDenoms, externalIncentive.RewardDenom) + k.SetPool(ctx, pool) + } + + tvl := k.GetPoolTVL(ctx, pool.PoolId) + if tvl.IsPositive() { + yearlyIncentiveRewardsTotal := externalIncentive.AmountPerBlock. + Mul(lpIncentive.TotalBlocksPerYear). + Quo(pool.NumBlocks) + + entry, found := k.assetProfileKeeper.GetEntry(ctx, ptypes.BaseCurrency) + if found { + baseCurrency := entry.Denom + pool.ExternalIncentiveApr = sdk.NewDecFromInt(yearlyIncentiveRewardsTotal). + Mul(k.amm.GetTokenPrice(ctx, externalIncentive.RewardDenom, baseCurrency)). + Quo(tvl) + k.SetPool(ctx, pool) + } + } + } + + if curBlockHeight.Uint64() == externalIncentive.ToBlock { + k.RemoveExternalIncentive(ctx, externalIncentive.Id) + } + } +} + +func (k Keeper) ProcessLPRewardDistribution(ctx sdk.Context) { + // Read tokenomics time based inflation params and update incentive module params. + if !k.ProcessUpdateIncentiveParams(ctx) { + ctx.Logger().Error("Invalid tokenomics params", "error", errors.New("invalid tokenomics params")) + return + } + + canDistribute := k.CanDistributeLPRewards(ctx) + if canDistribute { + err := k.UpdateLPRewards(ctx) + if err != nil { + ctx.Logger().Error("Failed to update lp rewards unclaimed", "error", err) + } + } +} + +func (k Keeper) ProcessUpdateIncentiveParams(ctx sdk.Context) bool { + // Non-linear inflation per year happens and this includes yearly inflation data + listTimeBasedInflations := k.tokenomicsKeeper.GetAllTimeBasedInflation(ctx) + if len(listTimeBasedInflations) < 1 { + return false + } + + params := k.GetParams(ctx) + + for _, inflation := range listTimeBasedInflations { + // Finding only current inflation data - and skip rest + if inflation.StartBlockHeight > uint64(ctx.BlockHeight()) || inflation.EndBlockHeight < uint64(ctx.BlockHeight()) { + continue + } + + totalBlocksPerYear := sdk.NewInt(int64(inflation.EndBlockHeight - inflation.StartBlockHeight + 1)) + + // If totalBlocksPerYear is zero, we skip this inflation to avoid division by zero + if totalBlocksPerYear == sdk.ZeroInt() { + continue + } + blocksDistributed := sdk.NewInt(ctx.BlockHeight() - int64(inflation.StartBlockHeight)) + + incentiveInfo := types.IncentiveInfo{ + // reward amount in eden for 1 year + EdenAmountPerYear: sdk.NewInt(int64(inflation.Inflation.LmRewards)), + // starting block height of the distribution + DistributionStartBlock: sdk.NewInt(int64(inflation.StartBlockHeight)), + // distribution duration - block number per year + TotalBlocksPerYear: totalBlocksPerYear, + // number of blocks distributed + BlocksDistributed: blocksDistributed, + } + + if params.LpIncentives == nil { + params.LpIncentives = &incentiveInfo + } else { + // If any of block number related parameter changed, we re-calculate the current epoch + if params.LpIncentives.DistributionStartBlock != incentiveInfo.DistributionStartBlock || + params.LpIncentives.TotalBlocksPerYear != incentiveInfo.TotalBlocksPerYear { + params.LpIncentives.BlocksDistributed = blocksDistributed + } + params.LpIncentives.EdenAmountPerYear = incentiveInfo.EdenAmountPerYear + params.LpIncentives.DistributionStartBlock = incentiveInfo.DistributionStartBlock + params.LpIncentives.TotalBlocksPerYear = incentiveInfo.TotalBlocksPerYear + } + break + } + + k.SetParams(ctx, params) + return true +} + +func (k Keeper) CanDistributeLPRewards(ctx sdk.Context) bool { + // Fetch incentive params + params := k.GetParams(ctx) + if ctx.BlockHeight() < 1 { + return false + } + + // If we don't have enough params + if params.LpIncentives == nil { + return false + } + + // Incentive params initialize + lpIncentive := params.LpIncentives + + curBlockHeight := sdk.NewInt(ctx.BlockHeight()) + if lpIncentive.DistributionStartBlock.GT(curBlockHeight) { + return false + } + + // Increase current epoch of incentive param + lpIncentive.BlocksDistributed = lpIncentive.BlocksDistributed.Add(sdk.OneInt()) + if lpIncentive.BlocksDistributed.GTE(lpIncentive.TotalBlocksPerYear) || curBlockHeight.GT(lpIncentive.TotalBlocksPerYear.Add(lpIncentive.DistributionStartBlock)) { + params.LpIncentives = nil + k.SetParams(ctx, params) + return false + } + + params.LpIncentives.BlocksDistributed = lpIncentive.BlocksDistributed + k.SetParams(ctx, params) + + return true +} + +func (k Keeper) UpdateLPRewards(ctx sdk.Context) error { + // Fetch incentive params + params := k.GetParams(ctx) + lpIncentive := params.LpIncentives + + entry, found := k.assetProfileKeeper.GetEntry(ctx, ptypes.BaseCurrency) + if !found { + return errorsmod.Wrapf(assetprofiletypes.ErrAssetProfileNotFound, "asset %s not found", ptypes.BaseCurrency) + } + baseCurrency := entry.Denom + + // Collect Gas fees + swap fees + gasFeesForLpsDec := k.CollectGasFees(ctx, baseCurrency) + _, dexRevenueForLps := k.CollectDEXRevenue(ctx) + + // USDC amount in sdk.Dec type + dexUsdcAmountForLps := dexRevenueForLps.AmountOf(baseCurrency) + gasFeeUsdcAmountForLps := gasFeesForLpsDec.AmountOf(baseCurrency) + + // Proxy TVL + // Multiplier on each liquidity pool + // We have 3 pools of 20, 30, 40 TVL + // We have mulitplier of 0.3, 0.5, 1.0 + // Proxy TVL = 20*0.3+30*0.5+40*1.0 + totalProxyTVL := k.CalculateProxyTVL(ctx, baseCurrency) + + // Ensure lpIncentive.TotalBlocksPerYear is not zero to avoid division by zero + if lpIncentive.TotalBlocksPerYear.IsZero() { + return errorsmod.Wrap(types.ErrNoInflationaryParams, "invalid inflationary params") + } + + // Calculate eden amount per block + lpsEdenAmount := lpIncentive.EdenAmountPerYear. + Quo(lpIncentive.TotalBlocksPerYear) + + // Maximum eden APR - 30% by default + // Allocated for staking per day = (0.3/365)* (total weighted proxy TVL) + edenDenomPrice := k.amm.GetEdenDenomPrice(ctx, baseCurrency) + + // Ensure edenDenomPrice is not zero to avoid division by zero + if edenDenomPrice.IsZero() { + return errorsmod.Wrap(types.ErrNoInflationaryParams, "invalid eden price") + } + + // Distribute Eden / USDC Rewards + for _, pool := range k.GetAllPools(ctx) { + var err error + tvl := k.GetPoolTVL(ctx, pool.PoolId) + proxyTVL := tvl.Mul(pool.Multiplier) + if proxyTVL.IsZero() { + continue + } + + poolShare := sdk.ZeroDec() + if totalProxyTVL.IsPositive() { + poolShare = proxyTVL.Quo(totalProxyTVL) + } + + // Calculate new Eden for this pool + newEdenAllocatedForPool := poolShare.MulInt(lpsEdenAmount) + + poolMaxEdenAmount := params.MaxEdenRewardAprLps. + Mul(tvl). + QuoInt(lpIncentive.TotalBlocksPerYear). + Quo(edenDenomPrice) + + // Use min amount (eden allocation from tokenomics and max apr based eden amount) + newEdenAllocatedForPool = sdk.MinDec(newEdenAllocatedForPool, poolMaxEdenAmount) + err = k.cmk.MintCoins(ctx, types.ModuleName, sdk.Coins{sdk.NewCoin(ptypes.Eden, newEdenAllocatedForPool.TruncateInt())}) + if err != nil { + panic(err) + } + + // Get gas fee rewards per pool + gasRewardsAllocatedForPool := poolShare.Mul(gasFeeUsdcAmountForLps) + + // ------------------- DEX rewards calculation ------------------- + // --------------------------------------------------------------- + // Get dex rewards per pool + // Get track key + trackKey := types.GetPoolRevenueTrackKey(pool.PoolId) + // Get tracked amount for Lps per pool + dexRewardsAllocatedForPool, ok := k.tci.PoolRevenueTrack[trackKey] + if !ok { + dexRewardsAllocatedForPool = sdk.NewDec(0) + } + + // Distribute Eden + k.UpdateAccPerShare(ctx, pool.PoolId, ptypes.Eden, newEdenAllocatedForPool.TruncateInt()) + // Distribute Gas fees + Dex rewards (USDC) + k.UpdateAccPerShare(ctx, pool.PoolId, k.GetBaseCurrencyDenom(ctx), gasRewardsAllocatedForPool.Add(dexRewardsAllocatedForPool).TruncateInt()) + + // Update Pool Info + pool.EdenRewardAmountGiven = newEdenAllocatedForPool.RoundInt() + pool.DexRewardAmountGiven = gasRewardsAllocatedForPool.Add(dexRewardsAllocatedForPool) + k.SetPool(ctx, pool) + } + + // Set DexRewards info + params.DexRewardsLps.NumBlocks = sdk.OneInt() + params.DexRewardsLps.Amount = dexUsdcAmountForLps.Add(gasFeeUsdcAmountForLps) + k.SetParams(ctx, params) + + // Update APR for amm pools + k.UpdateAmmPoolAPR(ctx, lpIncentive.TotalBlocksPerYear, totalProxyTVL, edenDenomPrice) + + return nil +} + +// Move gas fees collected to dex revenue wallet +// Convert it into USDC +func (k Keeper) ConvertGasFeesToUsdc(ctx sdk.Context, baseCurrency string) sdk.Coins { + // fetch and clear the collected fees for distribution, since this is + // called in BeginBlock, collected fees will be from the previous block + // (and distributed to the previous proposer) + feeCollector := k.authKeeper.GetModuleAccount(ctx, authtypes.FeeCollectorName) + feesCollected := k.bankKeeper.GetAllBalances(ctx, feeCollector.GetAddress()) + + // Total Swapped coin + totalSwappedCoins := sdk.Coins{} + + for _, tokenIn := range feesCollected { + // if it is base currency - usdc, we don't need convert. We just need to collect it to fee wallet. + if tokenIn.Denom == baseCurrency { + // Sum total swapped + totalSwappedCoins = totalSwappedCoins.Add(tokenIn) + continue + } + + // Find a pool that can convert tokenIn to usdc + pool, found := k.amm.GetBestPoolWithDenoms(ctx, []string{tokenIn.Denom, baseCurrency}) + if !found { + continue + } + + // Executes the swap in the pool and stores the output. Updates pool assets but + // does not actually transfer any tokens to or from the pool. + snapshot := k.amm.GetPoolSnapshotOrSet(ctx, pool) + tokenOutCoin, _, _, _, err := k.amm.SwapOutAmtGivenIn(ctx, pool.PoolId, k.oracleKeeper, &snapshot, sdk.Coins{tokenIn}, baseCurrency, sdk.ZeroDec()) + if err != nil { + continue + } + + tokenOutAmount := tokenOutCoin.Amount + if !tokenOutAmount.IsPositive() { + continue + } + + // Settles balances between the tx sender and the pool to match the swap that was executed earlier. + // Also emits a swap event and updates related liquidity metrics. + cacheCtx, write := ctx.CacheContext() + _, err = k.amm.UpdatePoolForSwap(cacheCtx, pool, feeCollector.GetAddress(), feeCollector.GetAddress(), tokenIn, tokenOutCoin, sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()) + if err != nil { + continue + } + write() + + // Swapped USDC coin + swappedCoins := sdk.NewCoins(sdk.NewCoin(baseCurrency, tokenOutAmount)) + + // Sum total swapped + totalSwappedCoins = totalSwappedCoins.Add(swappedCoins...) + } + + return totalSwappedCoins +} + +func (k Keeper) CollectGasFees(ctx sdk.Context, baseCurrency string) sdk.DecCoins { + params := k.GetParams(ctx) + + // Calculate each portion of Gas fees collected - stakers, LPs + fees := k.ConvertGasFeesToUsdc(ctx, baseCurrency) + gasFeeCollectedDec := sdk.NewDecCoinsFromCoins(fees...) + + gasFeesForLpsDec := gasFeeCollectedDec.MulDecTruncate(params.RewardPortionForLps) + gasFeesForStakersDec := gasFeeCollectedDec.MulDecTruncate(params.RewardPortionForStakers) + gasFeesForProtocolDec := gasFeeCollectedDec.Sub(gasFeesForLpsDec).Sub(gasFeesForStakersDec) + + lpsGasFeeCoins, _ := gasFeesForLpsDec.TruncateDecimal() + protocolGasFeeCoins, _ := gasFeesForProtocolDec.TruncateDecimal() + + // Send coins from fee collector name to masterchef + if lpsGasFeeCoins.IsAllPositive() { + err := k.bankKeeper.SendCoinsFromModuleToModule(ctx, authtypes.FeeCollectorName, types.ModuleName, lpsGasFeeCoins) + if err != nil { + panic(err) + } + } + + // Send coins to protocol revenue address + if protocolGasFeeCoins.IsAllPositive() { + protocolRevenueAddress := sdk.MustAccAddressFromBech32(params.ProtocolRevenueAddress) + err := k.bankKeeper.SendCoinsFromModuleToAccount(ctx, authtypes.FeeCollectorName, protocolRevenueAddress, protocolGasFeeCoins) + if err != nil { + panic(err) + } + } + return gasFeesForLpsDec +} + +// Collect all DEX revenues to DEX revenue wallet, +// while tracking the 60% of it for LPs reward distribution +// transfer collected fees from different wallets(liquidity pool, perpetual module etc) to the distribution module account +// Assume this is already in USDC. +// TODO: +// + Collect revenue from perpetual, lend module +func (k Keeper) CollectDEXRevenue(ctx sdk.Context) (sdk.Coins, sdk.DecCoins) { + // Total colllected revenue amount + amountTotalCollected := sdk.Coins{} + amountLPsCollected := sdk.DecCoins{} + + k.tci.PoolRevenueTrack = make(map[string]sdk.Dec) + + // Iterate to calculate total Eden from LpElys, MElys committed + k.amm.IterateLiquidityPools(ctx, func(p ammtypes.Pool) bool { + // Get pool Id + poolId := p.GetPoolId() + + // Get dex rewards per pool + revenueAddress := ammtypes.NewPoolRevenueAddress(poolId) + + // Transfer revenue to a single wallet of DEX revenue wallet. + revenue := k.bankKeeper.GetAllBalances(ctx, revenueAddress) + if revenue.IsAllPositive() { + err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, revenueAddress, types.ModuleName, revenue) + if err != nil { + panic(err) + } + } + + // LPs Portion param + params := k.GetParams(ctx) + rewardPortionForLps := params.RewardPortionForLps + rewardPortionForStakers := params.RewardPortionForStakers + + // Calculate revenue portion for LPs + revenueDec := sdk.NewDecCoinsFromCoins(revenue...) + + // LPs portion of pool revenue + revenuePortionForLPs := revenueDec.MulDecTruncate(rewardPortionForLps) + revenuePortionForStakers := revenueDec.MulDecTruncate(rewardPortionForStakers) + revenuePortionForProtocol := revenueDec.Sub(revenuePortionForLPs).Sub(revenuePortionForStakers) + stakerRevenueCoins, _ := revenuePortionForStakers.TruncateDecimal() + protocolRevenueCoins, _ := revenuePortionForProtocol.TruncateDecimal() + + // Send coins to fee collector name + if stakerRevenueCoins.IsAllPositive() { + err := k.bankKeeper.SendCoinsFromModuleToModule(ctx, types.ModuleName, authtypes.FeeCollectorName, stakerRevenueCoins) + if err != nil { + panic(err) + } + } + + // Send coins to protocol revenue address + if protocolRevenueCoins.IsAllPositive() { + protocolRevenueAddress := sdk.MustAccAddressFromBech32(params.ProtocolRevenueAddress) + err := k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, protocolRevenueAddress, protocolRevenueCoins) + if err != nil { + panic(err) + } + } + + // Get track key + trackKey := types.GetPoolRevenueTrackKey(poolId) + + // Store revenue portion for Lps temporarilly + k.tci.PoolRevenueTrack[trackKey] = revenuePortionForLPs.AmountOf(ptypes.BaseCurrency) + + // Sum total collected amount + amountTotalCollected = amountTotalCollected.Add(revenue...) + + // Sum total amount for LPs + amountLPsCollected = amountLPsCollected.Add(revenuePortionForLPs...) + + return false + }) + + return amountTotalCollected, amountLPsCollected +} + +// Calculate Proxy TVL +func (k Keeper) CalculateProxyTVL(ctx sdk.Context, baseCurrency string) sdk.Dec { + multipliedShareSum := sdk.ZeroDec() + stableStakePoolId := uint64(stabletypes.PoolId) + _, found := k.GetPool(ctx, stableStakePoolId) + // Ensure stablestakePoolParams exist + if !found { + k.InitStableStakePoolParams(ctx, stableStakePoolId) + } + for _, pool := range k.GetAllPools(ctx) { + tvl := k.GetPoolTVL(ctx, pool.PoolId) + proxyTVL := tvl.Mul(pool.Multiplier) + + // Calculate total pool share by TVL and multiplier + multipliedShareSum = multipliedShareSum.Add(proxyTVL) + } + + // return total sum of TVL share using multiplier of all pools + return multipliedShareSum +} + +// InitPoolParams: creates a poolInfo at the time of pool creation. +func (k Keeper) InitPoolParams(ctx sdk.Context, poolId uint64) bool { + _, found := k.GetPool(ctx, poolId) + if !found { + poolInfo := types.PoolInfo{ + // reward amount + PoolId: poolId, + // reward wallet address + RewardWallet: ammtypes.NewPoolRevenueAddress(poolId).String(), + // multiplier for lp rewards + Multiplier: sdk.NewDec(1), + // Number of blocks since creation + NumBlocks: sdk.NewInt(1), + // Total dex rewards given since creation + DexRewardAmountGiven: sdk.ZeroDec(), + // Total eden rewards given since creation + EdenRewardAmountGiven: sdk.ZeroInt(), + } + k.SetPool(ctx, poolInfo) + } + + return true +} + +// InitStableStakePoolMultiplier: create a stable stake pool information responding to the pool creation. +func (k Keeper) InitStableStakePoolParams(ctx sdk.Context, poolId uint64) bool { + _, found := k.GetPool(ctx, poolId) + if !found { + poolInfo := types.PoolInfo{ + // reward amount + PoolId: poolId, + // reward wallet address + RewardWallet: stabletypes.PoolAddress().String(), + // multiplier for lp rewards + Multiplier: sdk.NewDec(1), + // Number of blocks since creation + NumBlocks: sdk.NewInt(1), + // Total dex rewards given since creation + DexRewardAmountGiven: sdk.ZeroDec(), + // Total eden rewards given since creation + EdenRewardAmountGiven: sdk.ZeroInt(), + } + k.SetPool(ctx, poolInfo) + } + + return true +} + +// Calculate pool share for stable stake pool +func (k Keeper) CalculatePoolShareForStableStakeLPs(ctx sdk.Context, totalProxyTVL sdk.Dec, baseCurrency string) sdk.Dec { + // ------------ New Eden calculation ------------------- + // ----------------------------------------------------- + // newEdenAllocated = 80 / ( 80 + 90 + 200 + 0) * 100 + // Pool share = 80 + // edenAmountLp = 100 + tvl := k.stableKeeper.TVL(ctx, k.oracleKeeper, baseCurrency) + + // Get pool Id + poolId := uint64(stabletypes.PoolId) + + // Get pool info from incentive param + poolInfo, found := k.GetPool(ctx, poolId) + if !found { + return sdk.ZeroDec() + } + + // Calculate Proxy TVL share considering multiplier + proxyTVL := tvl.Mul(poolInfo.Multiplier) + if totalProxyTVL.IsZero() { + return sdk.ZeroDec() + } + poolShare := proxyTVL.Quo(totalProxyTVL) + + return poolShare +} + +// Update APR for AMM pool +func (k Keeper) UpdateAmmPoolAPR(ctx sdk.Context, totalBlocksPerYear sdk.Int, totalProxyTVL sdk.Dec, edenDenomPrice sdk.Dec) { + // Iterate to calculate total Eden from LpElys, MElys committed + k.amm.IterateLiquidityPools(ctx, func(p ammtypes.Pool) bool { + tvl, err := p.TVL(ctx, k.oracleKeeper) + if err != nil { + return false + } + + // Get pool Id + poolId := p.GetPoolId() + + // Get pool info from incentive param + poolInfo, found := k.GetPool(ctx, poolId) + if !found { + k.InitPoolParams(ctx, poolId) + poolInfo, _ = k.GetPool(ctx, poolId) + } + + poolInfo.NumBlocks = sdk.OneInt() + // Invalid block number + if poolInfo.NumBlocks.IsZero() { + return false + } + + if tvl.IsZero() { + return false + } + + // Dex reward Apr per pool = total accumulated usdc rewards for 7 day * 52/ tvl of pool + yearlyDexRewardsTotal := poolInfo.DexRewardAmountGiven. + MulInt(totalBlocksPerYear). + QuoInt(poolInfo.NumBlocks) + poolInfo.DexApr = yearlyDexRewardsTotal. + Quo(tvl) + + // Eden reward Apr per pool = (total LM Eden reward allocated per day*((tvl of pool * multiplier)/total proxy TVL) ) * 365 / TVL of pool + yearlyEdenRewardsTotal := poolInfo.EdenRewardAmountGiven. + Mul(totalBlocksPerYear). + Quo(poolInfo.NumBlocks) + + poolInfo.EdenApr = sdk.NewDecFromInt(yearlyEdenRewardsTotal). + Mul(edenDenomPrice). + Quo(tvl) + + // Update Pool Info + k.SetPool(ctx, poolInfo) + + return false + }) +} diff --git a/x/incentive/keeper/keeper_fees_test.go b/x/masterchef/keeper/abci_test.go similarity index 59% rename from x/incentive/keeper/keeper_fees_test.go rename to x/masterchef/keeper/abci_test.go index 0c943ed3c..e1000ef7c 100644 --- a/x/incentive/keeper/keeper_fees_test.go +++ b/x/masterchef/keeper/abci_test.go @@ -6,23 +6,113 @@ import ( tmproto "github.com/cometbft/cometbft/proto/tendermint/types" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" simapp "github.com/elys-network/elys/app" ammtypes "github.com/elys-network/elys/x/amm/types" + ctypes "github.com/elys-network/elys/x/commitment/types" ptypes "github.com/elys-network/elys/x/parameter/types" + tokenomicskeeper "github.com/elys-network/elys/x/tokenomics/keeper" + tokenomicstypes "github.com/elys-network/elys/x/tokenomics/types" "github.com/stretchr/testify/require" ) -func TestCollectGasFeesToIncentiveModule(t *testing.T) { - app := simapp.InitElysTestApp(initChain) - ctx := app.BaseApp.NewContext(initChain, tmproto.Header{}) +func TestABCI_EndBlocker(t *testing.T) { + app, genAccount, _ := simapp.InitElysTestAppWithGenAccount() + ctx := app.BaseApp.NewContext(true, tmproto.Header{}) - ik, bk, amm, oracle := app.IncentiveKeeper, app.BankKeeper, app.AmmKeeper, app.OracleKeeper + mk := app.MasterchefKeeper + + var committed sdk.Coins + var unclaimed sdk.Coins + + // Prepare unclaimed tokens + uedenToken := sdk.NewCoin(ptypes.Eden, sdk.NewInt(2000)) + uedenBToken := sdk.NewCoin(ptypes.EdenB, sdk.NewInt(2000)) + unclaimed = unclaimed.Add(uedenToken, uedenBToken) + + // Mint coins + err := app.BankKeeper.MintCoins(ctx, ctypes.ModuleName, unclaimed) + require.NoError(t, err) + err = app.BankKeeper.SendCoinsFromModuleToAccount(ctx, ctypes.ModuleName, genAccount, unclaimed) + require.NoError(t, err) + + // Add testing commitment + simapp.AddTestCommitment(app, ctx, genAccount, committed) + mk.EndBlocker(ctx) + + authority := authtypes.NewModuleAddress(govtypes.ModuleName).String() + srv := tokenomicskeeper.NewMsgServerImpl(app.TokenomicsKeeper) + + expected := &tokenomicstypes.MsgCreateTimeBasedInflation{ + Authority: authority, + StartBlockHeight: uint64(1), + EndBlockHeight: uint64(6307200), + Inflation: &tokenomicstypes.InflationEntry{ + LmRewards: 9999999, + IcsStakingRewards: 9999999, + CommunityFund: 9999999, + StrategicReserve: 9999999, + TeamTokensVested: 9999999, + }, + } + + wctx := sdk.WrapSDKContext(ctx) + _, err = srv.CreateTimeBasedInflation(wctx, expected) + require.NoError(t, err) + + expected = &tokenomicstypes.MsgCreateTimeBasedInflation{ + Authority: authority, + StartBlockHeight: uint64(6307201), + EndBlockHeight: uint64(12614401), + Inflation: &tokenomicstypes.InflationEntry{ + LmRewards: 9999999, + IcsStakingRewards: 9999999, + CommunityFund: 9999999, + StrategicReserve: 9999999, + TeamTokensVested: 9999999, + }, + } + _, err = srv.CreateTimeBasedInflation(wctx, expected) + require.NoError(t, err) + + // Set tokenomics params + listTimeBasdInflations := app.TokenomicsKeeper.GetAllTimeBasedInflation(ctx) + + // After the first year + ctx = ctx.WithBlockHeight(1) + paramSet := mk.ProcessUpdateIncentiveParams(ctx) + require.Equal(t, paramSet, true) + + // Check if the params are correctly set + params := mk.GetParams(ctx) + require.NotNil(t, params.LpIncentives) + require.Equal(t, params.LpIncentives.EdenAmountPerYear, sdk.NewInt(int64(listTimeBasdInflations[0].Inflation.LmRewards))) + + // After the first year + ctx = ctx.WithBlockHeight(6307210) + + // Incentive param should be empty + lpEpoch := mk.CanDistributeLPRewards(ctx) + params = mk.GetParams(ctx) + require.Equal(t, lpEpoch, false) + require.Nil(t, params.LpIncentives) + + // After reading tokenomics again + paramSet = mk.ProcessUpdateIncentiveParams(ctx) + require.Equal(t, paramSet, true) +} + +func TestCollectGasFees(t *testing.T) { + app := simapp.InitElysTestApp(true) + ctx := app.BaseApp.NewContext(true, tmproto.Header{}) + + mk, bk, amm, oracle := app.MasterchefKeeper, app.BankKeeper, app.AmmKeeper, app.OracleKeeper // Setup coin prices SetupStableCoinPrices(ctx, oracle) // Collect gas fees - collectedAmt := ik.CollectGasFeesToIncentiveModule(ctx, ptypes.BaseCurrency) + collectedAmt := mk.CollectGasFees(ctx, ptypes.BaseCurrency) // rewards should be zero require.True(t, collectedAmt.IsZero()) @@ -31,6 +121,11 @@ func TestCollectGasFeesToIncentiveModule(t *testing.T) { addr := simapp.AddTestAddrs(app, ctx, 1, sdk.NewInt(1000000)) transferAmt := sdk.NewCoin(ptypes.Elys, sdk.NewInt(100)) + // Set revenue address + params := mk.GetParams(ctx) + params.ProtocolRevenueAddress = addr[0].String() + mk.SetParams(ctx, params) + // Deposit 100elys to FeeCollectorName wallet err := bk.SendCoinsFromAccountToModule(ctx, addr[0], authtypes.FeeCollectorName, sdk.NewCoins(transferAmt)) require.NoError(t, err) @@ -83,23 +178,20 @@ func TestCollectGasFeesToIncentiveModule(t *testing.T) { require.Equal(t, int64(0), ctx.BlockHeight()) // Collect gas fees again - collectedAmt = ik.CollectGasFeesToIncentiveModule(ctx, ptypes.BaseCurrency) + collectedAmt = mk.CollectGasFees(ctx, ptypes.BaseCurrency) // check block height require.Equal(t, int64(0), ctx.BlockHeight()) - // It should be 9 usdc - require.Equal(t, collectedAmt, sdk.Coins{sdk.NewCoin(ptypes.BaseCurrency, sdk.NewInt(9))}) + // It should be 5.4 usdc + require.Equal(t, collectedAmt.String(), "5.400000000000000000uusdc") } -func TestCollectDEXRevenueToIncentiveModule(t *testing.T) { - app := simapp.InitElysTestApp(initChain) - ctx := app.BaseApp.NewContext(initChain, tmproto.Header{}) - - ik, bk, amm, oracle := app.IncentiveKeeper, app.BankKeeper, app.AmmKeeper, app.OracleKeeper +func TestCollectDEXRevenue(t *testing.T) { + app := simapp.InitElysTestApp(true) + ctx := app.BaseApp.NewContext(true, tmproto.Header{}) - // Recalculate total committed info - ik.UpdateTotalCommitmentInfo(ctx, ptypes.BaseCurrency) + mk, bk, amm, oracle := app.MasterchefKeeper, app.BankKeeper, app.AmmKeeper, app.OracleKeeper // Setup coin prices SetupStableCoinPrices(ctx, oracle) @@ -212,8 +304,13 @@ func TestCollectDEXRevenueToIncentiveModule(t *testing.T) { err = app.BankKeeper.SendCoinsFromModuleToAccount(ctx, ammtypes.ModuleName, revenueAddress2, usdcRevToken2) require.NoError(t, err) + // Set revenue address + params := mk.GetParams(ctx) + params.ProtocolRevenueAddress = addr[0].String() + mk.SetParams(ctx, params) + // Collect revenue - collectedAmt, rewardForLpsAmt, _ := ik.CollectDEXRevenue(ctx) + collectedAmt, rewardForLpsAmt := mk.CollectDEXRevenue(ctx) // check block height require.Equal(t, int64(0), ctx.BlockHeight()) diff --git a/x/incentive/keeper/pool_apr.go b/x/masterchef/keeper/apr_pool.go similarity index 54% rename from x/incentive/keeper/pool_apr.go rename to x/masterchef/keeper/apr_pool.go index 80f8282f1..d6f448126 100644 --- a/x/incentive/keeper/pool_apr.go +++ b/x/masterchef/keeper/apr_pool.go @@ -2,12 +2,12 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/elys-network/elys/x/incentive/types" + "github.com/elys-network/elys/x/masterchef/types" ) func (k Keeper) CalculatePoolAprs(ctx sdk.Context, ids []uint64) []types.PoolApr { if len(ids) == 0 { - pools := k.amm.GetAllPool(ctx) + pools := k.GetAllPools(ctx) for _, pool := range pools { ids = append(ids, pool.PoolId) } @@ -15,17 +15,21 @@ func (k Keeper) CalculatePoolAprs(ctx sdk.Context, ids []uint64) []types.PoolApr data := []types.PoolApr{} for _, poolId := range ids { - poolInfo, found := k.GetPoolInfo(ctx, poolId) + poolInfo, found := k.GetPool(ctx, poolId) if !found { data = append(data, types.PoolApr{ - PoolId: poolId, - Apr: sdk.ZeroDec(), + PoolId: poolId, + UsdcApr: sdk.ZeroDec(), + EdenApr: sdk.ZeroDec(), + TotalApr: sdk.ZeroDec(), }) continue } data = append(data, types.PoolApr{ - PoolId: poolId, - Apr: poolInfo.DexApr.Add(poolInfo.EdenApr), + PoolId: poolId, + UsdcApr: poolInfo.DexApr, + EdenApr: poolInfo.EdenApr, + TotalApr: poolInfo.DexApr.Add(poolInfo.EdenApr), }) } diff --git a/x/incentive/keeper/pool_apr_test.go b/x/masterchef/keeper/apr_pool_test.go similarity index 80% rename from x/incentive/keeper/pool_apr_test.go rename to x/masterchef/keeper/apr_pool_test.go index 5ace582a6..991672c6f 100644 --- a/x/incentive/keeper/pool_apr_test.go +++ b/x/masterchef/keeper/apr_pool_test.go @@ -13,10 +13,10 @@ import ( ) func TestCalculatePoolAprs(t *testing.T) { - app := simapp.InitElysTestApp(initChain) - ctx := app.BaseApp.NewContext(initChain, tmproto.Header{}) + app := simapp.InitElysTestApp(true) + ctx := app.BaseApp.NewContext(true, tmproto.Header{}) - ik, amm, oracle := app.IncentiveKeeper, app.AmmKeeper, app.OracleKeeper + mk, amm, oracle := app.MasterchefKeeper, app.AmmKeeper, app.OracleKeeper // Setup coin prices SetupStableCoinPrices(ctx, oracle) @@ -70,25 +70,25 @@ func TestCalculatePoolAprs(t *testing.T) { require.NoError(t, err) require.Equal(t, resp.PoolID, uint64(1)) - poolInfo, found := ik.GetPoolInfo(ctx, resp.PoolID) + poolInfo, found := mk.GetPool(ctx, resp.PoolID) require.True(t, found) poolInfo.DexApr = sdk.NewDecWithPrec(1, 2) // 1% poolInfo.EdenApr = sdk.NewDecWithPrec(2, 2) // 2% - ik.SetPoolInfo(ctx, poolInfo.PoolId, poolInfo) + mk.SetPool(ctx, poolInfo) // When passing empty array - aprs := ik.CalculatePoolAprs(ctx, []uint64{}) + aprs := mk.CalculatePoolAprs(ctx, []uint64{}) require.Len(t, aprs, 1) - require.Equal(t, aprs[0].Apr.String(), "0.030000000000000000") + require.Equal(t, aprs[0].TotalApr.String(), "0.030000000000000000") // When passing specific id - aprs = ik.CalculatePoolAprs(ctx, []uint64{1}) + aprs = mk.CalculatePoolAprs(ctx, []uint64{1}) require.Len(t, aprs, 1) - require.Equal(t, aprs[0].Apr.String(), "0.030000000000000000") + require.Equal(t, aprs[0].TotalApr.String(), "0.030000000000000000") // When passing invalid id - aprs = ik.CalculatePoolAprs(ctx, []uint64{4}) + aprs = mk.CalculatePoolAprs(ctx, []uint64{4}) require.Len(t, aprs, 1) - require.Equal(t, aprs[0].Apr.String(), "0.000000000000000000") + require.Equal(t, aprs[0].TotalApr.String(), "0.000000000000000000") } diff --git a/x/masterchef/keeper/apr_stable_stake.go b/x/masterchef/keeper/apr_stable_stake.go new file mode 100644 index 000000000..09de77f3e --- /dev/null +++ b/x/masterchef/keeper/apr_stable_stake.go @@ -0,0 +1,80 @@ +package keeper + +import ( + errorsmod "cosmossdk.io/errors" + "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" + assetprofiletypes "github.com/elys-network/elys/x/assetprofile/types" + "github.com/elys-network/elys/x/masterchef/types" + ptypes "github.com/elys-network/elys/x/parameter/types" + stabletypes "github.com/elys-network/elys/x/stablestake/types" +) + +func (k Keeper) CalculateStableStakeApr(ctx sdk.Context, query *types.QueryStableStakeAprRequest) (math.Int, error) { + // Fetch incentive params + params := k.GetParams(ctx) + + // Update params + defer k.SetParams(ctx, params) + + // If we don't have enough params + if params.LpIncentives == nil { + return sdk.ZeroInt(), errorsmod.Wrap(types.ErrNoInflationaryParams, "no inflationary params available") + } + + entry, found := k.assetProfileKeeper.GetEntry(ctx, ptypes.BaseCurrency) + if !found { + return sdk.ZeroInt(), errorsmod.Wrapf(assetprofiletypes.ErrAssetProfileNotFound, "asset %s not found", ptypes.BaseCurrency) + } + + baseCurrency := entry.Denom + lpIncentive := params.LpIncentives + + if lpIncentive.TotalBlocksPerYear.IsZero() { + return sdk.ZeroInt(), errorsmod.Wrap(types.ErrNoInflationaryParams, "invalid inflationary params") + } + + if query.Denom == ptypes.Eden { + stableTvl := k.stableKeeper.TVL(ctx, k.oracleKeeper, baseCurrency) + if stableTvl.IsZero() { + return sdk.ZeroInt(), nil + } + + // Calculate total Proxy TVL + totalProxyTVL := k.CalculateProxyTVL(ctx, baseCurrency) + + edenAmount := lpIncentive.EdenAmountPerYear. + Quo(lpIncentive.TotalBlocksPerYear) + + edenDenomPrice := k.amm.GetEdenDenomPrice(ctx, baseCurrency) + + // Eden amount for stable stake LP in 24hrs + stableStakePoolShare := k.CalculatePoolShareForStableStakeLPs(ctx, totalProxyTVL, baseCurrency) + stableStakeEdenAmount := sdk.NewDecFromInt(edenAmount).Mul(stableStakePoolShare) + + params := k.GetParams(ctx) + poolMaxEdenAmount := params.MaxEdenRewardAprLps. + Mul(stableTvl). + QuoInt(lpIncentive.TotalBlocksPerYear). + Quo(edenDenomPrice) + stableStakeEdenAmount = sdk.MinDec(stableStakeEdenAmount, poolMaxEdenAmount) + + // Eden Apr for usdc earn program = {(Eden allocated for stable stake pool per day*365*price{eden/usdc}/(total usdc deposit)}*100 + apr := stableStakeEdenAmount. + MulInt(sdk.NewInt(ptypes.DaysPerYear)). + Mul(edenDenomPrice). + MulInt(sdk.NewInt(100)). + Quo(stableTvl) + return apr.TruncateInt(), nil + } else if query.Denom == ptypes.BaseCurrency { + params := k.stableKeeper.GetParams(ctx) + res, err := k.stableKeeper.BorrowRatio(ctx, &stabletypes.QueryBorrowRatioRequest{}) + if err != nil { + return sdk.ZeroInt(), err + } + apr := params.InterestRate.Mul(res.BorrowRatio).MulInt(sdk.NewInt(100)) + return apr.TruncateInt(), nil + } + + return sdk.ZeroInt(), nil +} diff --git a/x/masterchef/keeper/external_incentive.go b/x/masterchef/keeper/external_incentive.go new file mode 100644 index 000000000..9dd17a9e0 --- /dev/null +++ b/x/masterchef/keeper/external_incentive.go @@ -0,0 +1,67 @@ +package keeper + +import ( + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/elys-network/elys/x/masterchef/types" +) + +func (k Keeper) GetExternalIncentiveIndex(ctx sdk.Context) (index uint64) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.ExternalIncentiveIndexKeyPrefix)) + + index = sdk.BigEndianToUint64(store.Get(types.ExternalIncentiveIndex())) + + return index +} + +func (k Keeper) SetExternalIncentiveIndex(ctx sdk.Context, index uint64) error { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.ExternalIncentiveIndexKeyPrefix)) + + store.Set(types.ExternalIncentiveIndex(), sdk.Uint64ToBigEndian(index)) + + return nil +} + +func (k Keeper) SetExternalIncentive(ctx sdk.Context, externalIncentive types.ExternalIncentive) error { + // Update external incentive index and increase +1 + index := k.GetExternalIncentiveIndex(ctx) + externalIncentive.Id = index + k.SetExternalIncentiveIndex(ctx, index+1) + + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.ExternalIncentiveKeyPrefix)) + b := k.cdc.MustMarshal(&externalIncentive) + store.Set(types.ExternalIncentiveKey(externalIncentive.Id), b) + return nil +} + +func (k Keeper) GetExternalIncentive(ctx sdk.Context, id uint64) (val types.ExternalIncentive, found bool) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.ExternalIncentiveKeyPrefix)) + + b := store.Get(types.ExternalIncentiveKey(id)) + if b == nil { + return val, false + } + + k.cdc.MustUnmarshal(b, &val) + return val, true +} + +func (k Keeper) RemoveExternalIncentive(ctx sdk.Context, id uint64) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.ExternalIncentiveKeyPrefix)) + store.Delete(types.ExternalIncentiveKey(id)) +} + +func (k Keeper) GetAllExternalIncentives(ctx sdk.Context) (list []types.ExternalIncentive) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.ExternalIncentiveKeyPrefix)) + iterator := sdk.KVStorePrefixIterator(store, []byte{}) + + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + var val types.ExternalIncentive + k.cdc.MustUnmarshal(iterator.Value(), &val) + list = append(list, val) + } + + return +} diff --git a/x/masterchef/keeper/external_incentive_test.go b/x/masterchef/keeper/external_incentive_test.go new file mode 100644 index 000000000..7c01d91e7 --- /dev/null +++ b/x/masterchef/keeper/external_incentive_test.go @@ -0,0 +1,60 @@ +package keeper_test + +import ( + "testing" + + tmproto "github.com/cometbft/cometbft/proto/tendermint/types" + sdk "github.com/cosmos/cosmos-sdk/types" + simapp "github.com/elys-network/elys/app" + "github.com/elys-network/elys/x/masterchef/types" + "github.com/stretchr/testify/require" +) + +func TestExternalIncentive(t *testing.T) { + app := simapp.InitElysTestApp(true) + ctx := app.BaseApp.NewContext(true, tmproto.Header{}) + + externalIncentives := []types.ExternalIncentive{ + { + Id: 0, + RewardDenom: "reward1", + PoolId: 1, + FromBlock: 0, + ToBlock: 100, + AmountPerBlock: sdk.OneInt(), + }, + { + Id: 1, + RewardDenom: "reward1", + PoolId: 1, + FromBlock: 0, + ToBlock: 100, + AmountPerBlock: sdk.OneInt(), + }, + { + Id: 2, + RewardDenom: "reward1", + PoolId: 2, + FromBlock: 0, + ToBlock: 100, + AmountPerBlock: sdk.OneInt(), + }, + } + require.Equal(t, app.MasterchefKeeper.GetExternalIncentiveIndex(ctx), uint64(0)) + for _, externalIncentive := range externalIncentives { + err := app.MasterchefKeeper.SetExternalIncentive(ctx, externalIncentive) + require.NoError(t, err) + } + require.Equal(t, app.MasterchefKeeper.GetExternalIncentiveIndex(ctx), uint64(3)) + for _, externalIncentive := range externalIncentives { + info, found := app.MasterchefKeeper.GetExternalIncentive(ctx, externalIncentive.Id) + require.True(t, found) + require.Equal(t, info, externalIncentive) + } + externalIncentivesStored := app.MasterchefKeeper.GetAllExternalIncentives(ctx) + require.Len(t, externalIncentivesStored, 3) + + app.MasterchefKeeper.RemoveExternalIncentive(ctx, externalIncentives[0].Id) + externalIncentivesStored = app.MasterchefKeeper.GetAllExternalIncentives(ctx) + require.Len(t, externalIncentivesStored, 2) +} diff --git a/x/incentive/keeper/hooks_amm.go b/x/masterchef/keeper/hooks_amm.go similarity index 75% rename from x/incentive/keeper/hooks_amm.go rename to x/masterchef/keeper/hooks_amm.go index 1d0aec2f2..bbcf1f26b 100644 --- a/x/incentive/keeper/hooks_amm.go +++ b/x/masterchef/keeper/hooks_amm.go @@ -4,19 +4,42 @@ import ( "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" ammtypes "github.com/elys-network/elys/x/amm/types" + "github.com/elys-network/elys/x/masterchef/types" ) // AfterPoolCreated is called after CreatePool func (k Keeper) AfterPoolCreated(ctx sdk.Context, sender sdk.AccAddress, poolId uint64) { - k.InitPoolParams(ctx, poolId) + _, found := k.GetPool(ctx, poolId) + if found { + return + } + // Initiate a new pool info + poolInfo := types.PoolInfo{ + // reward amount + PoolId: poolId, + // reward wallet address + RewardWallet: ammtypes.NewPoolRevenueAddress(poolId).String(), + // multiplier for lp rewards + Multiplier: sdk.NewDec(1), + // Number of blocks since creation + NumBlocks: sdk.NewInt(1), + // Total dex rewards given since creation + DexRewardAmountGiven: sdk.ZeroDec(), + // Total eden rewards given since creation + EdenRewardAmountGiven: sdk.ZeroInt(), + } + k.SetPool(ctx, poolInfo) } // AfterJoinPool is called after JoinPool, JoinSwapExternAmountIn, and JoinSwapShareAmountOut func (k Keeper) AfterJoinPool(ctx sdk.Context, sender sdk.AccAddress, poolId uint64, enterCoins sdk.Coins, shareOutAmount math.Int) { + k.AfterDeposit(ctx, poolId, sender.String(), shareOutAmount) } // AfterExitPool is called after ExitPool, ExitSwapShareAmountIn, and ExitSwapExternAmountOut func (k Keeper) AfterExitPool(ctx sdk.Context, sender sdk.AccAddress, poolId uint64, shareInAmount math.Int, exitCoins sdk.Coins) error { + k.AfterWithdraw(ctx, poolId, sender.String(), shareInAmount) + return nil } diff --git a/x/masterchef/keeper/hooks_masterchef.go b/x/masterchef/keeper/hooks_masterchef.go new file mode 100644 index 000000000..f1c989954 --- /dev/null +++ b/x/masterchef/keeper/hooks_masterchef.go @@ -0,0 +1,124 @@ +package keeper + +import ( + "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" + ammtypes "github.com/elys-network/elys/x/amm/types" + "github.com/elys-network/elys/x/masterchef/types" + stablestaketypes "github.com/elys-network/elys/x/stablestake/types" +) + +func (k Keeper) GetPoolTotalCommit(ctx sdk.Context, poolId uint64) sdk.Int { + shareDenom := ammtypes.GetPoolShareDenom(poolId) + if poolId == stablestaketypes.PoolId { + shareDenom = stablestaketypes.GetShareDenom() + } + + params := k.cmk.GetParams(ctx) + return params.TotalCommitted.AmountOf(shareDenom) +} + +func (k Keeper) GetPoolBalance(ctx sdk.Context, poolId uint64, user string) sdk.Int { + commitments := k.cmk.GetCommitments(ctx, user) + shareDenom := stablestaketypes.GetShareDenom() + if poolId != stablestaketypes.PoolId { + shareDenom = ammtypes.GetPoolShareDenom(poolId) + } + + return commitments.GetCommittedAmountForDenom(shareDenom) +} + +func (k Keeper) UpdateAccPerShare(ctx sdk.Context, poolId uint64, rewardDenom string, amount sdk.Int) { + poolRewardInfo, found := k.GetPoolRewardInfo(ctx, poolId, rewardDenom) + + if !found { + poolRewardInfo = types.PoolRewardInfo{ + PoolId: poolId, + RewardDenom: rewardDenom, + PoolAccRewardPerShare: sdk.NewDec(0), + LastUpdatedBlock: 0, + } + } + + totalCommit := k.GetPoolTotalCommit(ctx, poolId) + if totalCommit.IsZero() { + return + } + poolRewardInfo.PoolAccRewardPerShare = poolRewardInfo.PoolAccRewardPerShare.Add( + math.LegacyNewDecFromInt(amount.Mul(ammtypes.OneShare)). + Quo(math.LegacyNewDecFromInt(totalCommit)), + ) + poolRewardInfo.LastUpdatedBlock = uint64(ctx.BlockHeight()) + k.SetPoolRewardInfo(ctx, poolRewardInfo) +} + +func (k Keeper) UpdateUserRewardPending(ctx sdk.Context, poolId uint64, rewardDenom string, user string, isDeposit bool, amount sdk.Int) { + poolRewardInfo, found := k.GetPoolRewardInfo(ctx, poolId, rewardDenom) + if !found { + poolRewardInfo = types.PoolRewardInfo{ + PoolId: poolId, + RewardDenom: rewardDenom, + PoolAccRewardPerShare: sdk.NewDec(0), + LastUpdatedBlock: 0, + } + } + + userRewardInfo, found := k.GetUserRewardInfo(ctx, user, poolId, rewardDenom) + if !found { + userRewardInfo = types.UserRewardInfo{ + User: user, + PoolId: poolId, + RewardDenom: rewardDenom, + RewardDebt: sdk.NewDec(0), + RewardPending: sdk.NewDec(0), + } + } + + // need to consider balance change on deposit/withdraw + userBalance := k.GetPoolBalance(ctx, poolId, user) + if isDeposit { + userBalance = userBalance.Sub(amount) + } else { + userBalance = userBalance.Add(amount) + } + + userRewardInfo.RewardPending = userRewardInfo.RewardPending.Add( + poolRewardInfo.PoolAccRewardPerShare. + Mul(math.LegacyNewDecFromInt(userBalance)). + Sub(userRewardInfo.RewardDebt). + Quo(math.LegacyNewDecFromInt(ammtypes.OneShare)), + ) + + k.SetUserRewardInfo(ctx, userRewardInfo) +} + +func (k Keeper) UpdateUserRewardDebt(ctx sdk.Context, poolId uint64, rewardDenom string, user string) { + poolRewardInfo, found := k.GetPoolRewardInfo(ctx, poolId, rewardDenom) + + if !found { + poolRewardInfo = types.PoolRewardInfo{ + PoolId: poolId, + RewardDenom: rewardDenom, + PoolAccRewardPerShare: sdk.NewDec(0), + LastUpdatedBlock: 0, + } + } + + userRewardInfo, found := k.GetUserRewardInfo(ctx, user, poolId, rewardDenom) + + if !found { + userRewardInfo = types.UserRewardInfo{ + User: user, + PoolId: poolId, + RewardDenom: rewardDenom, + RewardDebt: sdk.NewDec(0), + RewardPending: sdk.NewDec(0), + } + } + + userRewardInfo.RewardDebt = poolRewardInfo.PoolAccRewardPerShare.Mul( + math.LegacyNewDecFromInt(k.GetPoolBalance(ctx, poolId, user)), + ) + + k.SetUserRewardInfo(ctx, userRewardInfo) +} diff --git a/x/masterchef/keeper/hooks_masterchef_test.go b/x/masterchef/keeper/hooks_masterchef_test.go new file mode 100644 index 000000000..618e2987d --- /dev/null +++ b/x/masterchef/keeper/hooks_masterchef_test.go @@ -0,0 +1,311 @@ +package keeper_test + +import ( + "testing" + + "cosmossdk.io/math" + "github.com/cometbft/cometbft/crypto/ed25519" + tmproto "github.com/cometbft/cometbft/proto/tendermint/types" + sdk "github.com/cosmos/cosmos-sdk/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + simapp "github.com/elys-network/elys/app" + ammtypes "github.com/elys-network/elys/x/amm/types" + masterchefkeeper "github.com/elys-network/elys/x/masterchef/keeper" + "github.com/elys-network/elys/x/masterchef/types" + oraclekeeper "github.com/elys-network/elys/x/oracle/keeper" + oracletypes "github.com/elys-network/elys/x/oracle/types" + ptypes "github.com/elys-network/elys/x/parameter/types" + tokenomicskeeper "github.com/elys-network/elys/x/tokenomics/keeper" + tokenomicstypes "github.com/elys-network/elys/x/tokenomics/types" + "github.com/stretchr/testify/require" +) + +func SetupStableCoinPrices(ctx sdk.Context, oracle oraclekeeper.Keeper) { + // prices set for USDT and USDC + provider := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address()) + oracle.SetAssetInfo(ctx, oracletypes.AssetInfo{ + Denom: ptypes.BaseCurrency, + Display: "USDC", + Decimal: 6, + }) + oracle.SetAssetInfo(ctx, oracletypes.AssetInfo{ + Denom: "uusdt", + Display: "USDT", + Decimal: 6, + }) + oracle.SetAssetInfo(ctx, oracletypes.AssetInfo{ + Denom: ptypes.Elys, + Display: "ELYS", + Decimal: 6, + }) + oracle.SetAssetInfo(ctx, oracletypes.AssetInfo{ + Denom: ptypes.ATOM, + Display: "ATOM", + Decimal: 6, + }) + + oracle.SetPrice(ctx, oracletypes.Price{ + Asset: "USDC", + Price: sdk.NewDec(1000000), + Source: "elys", + Provider: provider.String(), + Timestamp: uint64(ctx.BlockTime().Unix()), + }) + oracle.SetPrice(ctx, oracletypes.Price{ + Asset: "USDT", + Price: sdk.NewDec(1000000), + Source: "elys", + Provider: provider.String(), + Timestamp: uint64(ctx.BlockTime().Unix()), + }) + oracle.SetPrice(ctx, oracletypes.Price{ + Asset: "ELYS", + Price: sdk.NewDec(100), + Source: "elys", + Provider: provider.String(), + Timestamp: uint64(ctx.BlockTime().Unix()), + }) + oracle.SetPrice(ctx, oracletypes.Price{ + Asset: "ATOM", + Price: sdk.NewDec(100), + Source: "atom", + Provider: provider.String(), + Timestamp: uint64(ctx.BlockTime().Unix()), + }) +} + +func TestHookMasterchef(t *testing.T) { + app, _, _ := simapp.InitElysTestAppWithGenAccount() + ctx := app.BaseApp.NewContext(true, tmproto.Header{}) + + mk, amm, oracle := app.MasterchefKeeper, app.AmmKeeper, app.OracleKeeper + + // Setup coin prices + SetupStableCoinPrices(ctx, oracle) + + authority := authtypes.NewModuleAddress(govtypes.ModuleName).String() + + srv := tokenomicskeeper.NewMsgServerImpl(app.TokenomicsKeeper) + + expected := &tokenomicstypes.MsgCreateTimeBasedInflation{ + Authority: authority, + StartBlockHeight: uint64(1), + EndBlockHeight: uint64(6307200), + Inflation: &tokenomicstypes.InflationEntry{ + LmRewards: 9999999, + IcsStakingRewards: 9999999, + CommunityFund: 9999999, + StrategicReserve: 9999999, + TeamTokensVested: 9999999, + }, + } + + wctx := sdk.WrapSDKContext(ctx) + _, err := srv.CreateTimeBasedInflation(wctx, expected) + require.NoError(t, err) + + expected = &tokenomicstypes.MsgCreateTimeBasedInflation{ + Authority: authority, + StartBlockHeight: uint64(6307201), + EndBlockHeight: uint64(12614401), + Inflation: &tokenomicstypes.InflationEntry{ + LmRewards: 9999999, + IcsStakingRewards: 9999999, + CommunityFund: 9999999, + StrategicReserve: 9999999, + TeamTokensVested: 9999999, + }, + } + _, err = srv.CreateTimeBasedInflation(wctx, expected) + require.NoError(t, err) + + // Generate 1 random account with 1000stake balanced + addr := simapp.AddTestAddrs(app, ctx, 2, sdk.NewInt(10000000000)) + + // Create a pool + // Mint 100000USDC + usdcToken := sdk.NewCoins(sdk.NewCoin(ptypes.BaseCurrency, sdk.NewInt(10000000000))) + + err = app.BankKeeper.MintCoins(ctx, ammtypes.ModuleName, usdcToken.MulInt(sdk.NewInt(2))) + require.NoError(t, err) + err = app.BankKeeper.SendCoinsFromModuleToAccount(ctx, ammtypes.ModuleName, addr[0], usdcToken) + require.NoError(t, err) + err = app.BankKeeper.SendCoinsFromModuleToAccount(ctx, ammtypes.ModuleName, addr[1], usdcToken) + require.NoError(t, err) + + poolAssets := []ammtypes.PoolAsset{ + { + Weight: sdk.NewInt(50), + Token: sdk.NewCoin(ptypes.Elys, sdk.NewInt(10000000)), + }, + { + Weight: sdk.NewInt(50), + Token: sdk.NewCoin(ptypes.BaseCurrency, sdk.NewInt(10000000)), + }, + } + + argSwapFee := sdk.MustNewDecFromStr("0.0") + argExitFee := sdk.MustNewDecFromStr("0.0") + + poolParams := &ammtypes.PoolParams{ + SwapFee: argSwapFee, + ExitFee: argExitFee, + } + + msg := ammtypes.NewMsgCreatePool( + addr[0].String(), + poolParams, + poolAssets, + ) + + // Create a Elys+USDC pool + poolId, err := amm.CreatePool(ctx, msg) + require.NoError(t, err) + require.Equal(t, poolId, uint64(1)) + + pools := amm.GetAllPool(ctx) + + // check length of pools + require.Equal(t, len(pools), 1) + + _, err = amm.ExitPool(ctx, addr[0], pools[0].PoolId, math.NewIntWithDecimal(1, 21), sdk.NewCoins(), "") + require.NoError(t, err) + + // new user join pool with same shares + share := ammtypes.InitPoolSharesSupply.Mul(math.NewIntWithDecimal(1, 5)) + t.Log(mk.GetPoolTotalCommit(ctx, pools[0].PoolId)) + require.Equal(t, mk.GetPoolTotalCommit(ctx, pools[0].PoolId).String(), "10002000000000000000000000") + require.Equal(t, mk.GetPoolBalance(ctx, pools[0].PoolId, addr[0].String()).String(), "10000000000000000000000000") + _, _, err = amm.JoinPoolNoSwap(ctx, addr[1], pools[0].PoolId, share, sdk.NewCoins(sdk.NewCoin(ptypes.Elys, sdk.NewInt(10000000)), sdk.NewCoin(ptypes.BaseCurrency, sdk.NewInt(10000000)))) + require.NoError(t, err) + require.Equal(t, mk.GetPoolTotalCommit(ctx, pools[0].PoolId).String(), "20002000000000000000000000") + require.Equal(t, mk.GetPoolBalance(ctx, pools[0].PoolId, addr[1].String()), share) + + atomToken := sdk.NewCoins(sdk.NewCoin("uatom", math.NewIntWithDecimal(100000000, 6))) + err = app.BankKeeper.MintCoins(ctx, ammtypes.ModuleName, atomToken) + require.NoError(t, err) + err = app.BankKeeper.SendCoinsFromModuleToAccount(ctx, ammtypes.ModuleName, addr[0], atomToken) + require.NoError(t, err) + // external reward distribute + masterchefSrv := masterchefkeeper.NewMsgServerImpl(app.MasterchefKeeper) + _, err = masterchefSrv.AddExternalRewardDenom(sdk.WrapSDKContext(ctx), &types.MsgAddExternalRewardDenom{ + Authority: app.GovKeeper.GetAuthority(), + RewardDenom: "uatom", + MinAmount: sdk.OneInt(), + Supported: true, + }) + require.NoError(t, err) + _, err = masterchefSrv.AddExternalIncentive(sdk.WrapSDKContext(ctx), &types.MsgAddExternalIncentive{ + Sender: addr[0].String(), + RewardDenom: "uatom", + PoolId: pools[0].PoolId, + AmountPerBlock: math.NewIntWithDecimal(100, 6), + FromBlock: 0, + ToBlock: 1000, + }) + require.NoError(t, err) + + // check rewards after 100 block + for i := 1; i <= 100; i++ { + mk.EndBlocker(ctx) + ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 1) + } + + require.Equal(t, ctx.BlockHeight(), int64(100)) + poolRewardInfo, _ := app.MasterchefKeeper.GetPoolRewardInfo(ctx, pools[0].PoolId, "uatom") + require.Equal(t, poolRewardInfo.LastUpdatedBlock, uint64(99)) + + res, err := mk.UserPendingReward(ctx, &types.QueryUserPendingRewardRequest{ + User: addr[0].String(), + }) + require.NoError(t, err) + require.Equal(t, res.TotalRewards[0].Amount.String(), "4949505049") + res, err = mk.UserPendingReward(ctx, &types.QueryUserPendingRewardRequest{ + User: addr[1].String(), + }) + require.NoError(t, err) + require.Equal(t, res.TotalRewards[0].Amount.String(), "4949505049") + + // check rewards claimed + _, err = masterchefSrv.ClaimRewards(sdk.WrapSDKContext(ctx), &types.MsgClaimRewards{ + Sender: addr[0].String(), + PoolIds: []uint64{pools[0].PoolId}, + }) + require.NoError(t, err) + _, err = masterchefSrv.ClaimRewards(sdk.WrapSDKContext(ctx), &types.MsgClaimRewards{ + Sender: addr[1].String(), + PoolIds: []uint64{pools[0].PoolId}, + }) + require.NoError(t, err) + + atomAmount := app.BankKeeper.GetBalance(ctx, addr[1], "uatom") + require.Equal(t, atomAmount.Amount.String(), "4949505049") + + // no pending rewards + res, err = mk.UserPendingReward(ctx, &types.QueryUserPendingRewardRequest{ + User: addr[0].String(), + }) + require.NoError(t, err) + require.Len(t, res.TotalRewards, 0) + res, err = mk.UserPendingReward(ctx, &types.QueryUserPendingRewardRequest{ + User: addr[1].String(), + }) + require.NoError(t, err) + require.Len(t, res.TotalRewards, 0) + + // first user exit pool + _, err = amm.ExitPool(ctx, addr[1], pools[0].PoolId, share.Quo(math.NewInt(2)), sdk.NewCoins(), "") + require.NoError(t, err) + + // check rewards after 100 block + for i := 1; i <= 100; i++ { + mk.EndBlocker(ctx) + ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 1) + } + + require.Equal(t, ctx.BlockHeight(), int64(200)) + poolRewardInfo, _ = app.MasterchefKeeper.GetPoolRewardInfo(ctx, pools[0].PoolId, "uatom") + require.Equal(t, poolRewardInfo.LastUpdatedBlock, uint64(199)) + + res, err = mk.UserPendingReward(ctx, &types.QueryUserPendingRewardRequest{ + User: addr[0].String(), + }) + require.NoError(t, err) + require.Equal(t, res.TotalRewards[0].String(), "3999680025uatom") + res, err = mk.UserPendingReward(ctx, &types.QueryUserPendingRewardRequest{ + User: addr[1].String(), + }) + require.NoError(t, err) + require.Equal(t, res.TotalRewards[0].String(), "1999840012uatom") + + // check rewards claimed + _, err = masterchefSrv.ClaimRewards(sdk.WrapSDKContext(ctx), &types.MsgClaimRewards{ + Sender: addr[0].String(), + PoolIds: []uint64{pools[0].PoolId}, + }) + require.NoError(t, err) + _, err = masterchefSrv.ClaimRewards(sdk.WrapSDKContext(ctx), &types.MsgClaimRewards{ + Sender: addr[1].String(), + PoolIds: []uint64{pools[0].PoolId}, + }) + require.NoError(t, err) + + atomAmount = app.BankKeeper.GetBalance(ctx, addr[1], "uatom") + require.Equal(t, atomAmount.String(), "6949345061uatom") + + // no pending rewards + res, err = mk.UserPendingReward(ctx, &types.QueryUserPendingRewardRequest{ + User: addr[0].String(), + }) + require.NoError(t, err) + require.Len(t, res.TotalRewards, 0) + res, err = mk.UserPendingReward(ctx, &types.QueryUserPendingRewardRequest{ + User: addr[1].String(), + }) + require.NoError(t, err) + require.Len(t, res.TotalRewards, 0) + + pool, _ := mk.GetPool(ctx, pools[0].PoolId) + require.Equal(t, pool.ExternalIncentiveApr.String(), "4204.799481351999973502") +} diff --git a/x/masterchef/keeper/hooks_stablestake.go b/x/masterchef/keeper/hooks_stablestake.go new file mode 100644 index 000000000..e4283126c --- /dev/null +++ b/x/masterchef/keeper/hooks_stablestake.go @@ -0,0 +1,29 @@ +package keeper + +import ( + "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" + stablestaketypes "github.com/elys-network/elys/x/stablestake/types" +) + +// Hooks wrapper struct for incentive keeper +type StableStakeHooks struct { + k Keeper +} + +var _ stablestaketypes.StableStakeHooks = StableStakeHooks{} + +// Return the wrapper struct +func (k Keeper) StableStakeHooks() StableStakeHooks { + return StableStakeHooks{k} +} + +func (h StableStakeHooks) AfterBond(ctx sdk.Context, sender string, shareAmount math.Int) error { + h.k.AfterDeposit(ctx, stablestaketypes.PoolId, sender, shareAmount) + return nil +} + +func (h StableStakeHooks) AfterUnbond(ctx sdk.Context, sender string, shareAmount math.Int) error { + h.k.AfterWithdraw(ctx, stablestaketypes.PoolId, sender, shareAmount) + return nil +} diff --git a/x/masterchef/keeper/hooks_user_actions.go b/x/masterchef/keeper/hooks_user_actions.go new file mode 100644 index 000000000..d508f34dd --- /dev/null +++ b/x/masterchef/keeper/hooks_user_actions.go @@ -0,0 +1,85 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + ptypes "github.com/elys-network/elys/x/parameter/types" +) + +func (k Keeper) AfterDepositPerReward(ctx sdk.Context, poolId uint64, rewardDenom string, user string, amount sdk.Int) { + k.UpdateUserRewardPending( + ctx, + poolId, + rewardDenom, + user, + true, + amount, + ) + k.UpdateUserRewardDebt( + ctx, + poolId, + rewardDenom, + user, + ) +} + +func (k Keeper) AfterDeposit(ctx sdk.Context, poolId uint64, user string, amount sdk.Int) { + for _, rewardDenom := range k.GetRewardDenoms(ctx, poolId) { + k.AfterDepositPerReward(ctx, poolId, rewardDenom, user, amount) + } +} + +func (k Keeper) AfterWithdrawPerReward(ctx sdk.Context, poolId uint64, rewardDenom string, user string, amount sdk.Int) { + k.UpdateUserRewardPending( + ctx, + poolId, + rewardDenom, + user, + false, + amount, + ) + k.UpdateUserRewardDebt( + ctx, + poolId, + rewardDenom, + user, + ) +} + +func (k Keeper) AfterWithdraw(ctx sdk.Context, poolId uint64, user string, amount sdk.Int) { + for _, rewardDenom := range k.GetRewardDenoms(ctx, poolId) { + k.AfterWithdrawPerReward(ctx, poolId, rewardDenom, user, amount) + } +} + +func (k Keeper) GetRewardDenoms(ctx sdk.Context, poolId uint64) []string { + rewardDenoms := make(map[string]bool) + + rewardDenoms[ptypes.Eden] = true + rewardDenoms[k.GetBaseCurrencyDenom(ctx)] = true + + poolInfo, found := k.GetPool(ctx, poolId) + if !found { + return []string{} + } + + externalIncentives := poolInfo.ExternalRewardDenoms + for _, externalIncentive := range externalIncentives { + rewardDenoms[externalIncentive] = true + } + + keys := make([]string, 0, len(rewardDenoms)) + for k2 := range rewardDenoms { + keys = append(keys, k2) + } + + return keys +} + +func (k Keeper) GetBaseCurrencyDenom(ctx sdk.Context) string { + baseCurrency := ptypes.BaseCurrency + entry, found := k.assetProfileKeeper.GetEntry(ctx, ptypes.BaseCurrency) + if found { + baseCurrency = entry.Denom + } + return baseCurrency +} diff --git a/x/masterchef/keeper/keeper.go b/x/masterchef/keeper/keeper.go new file mode 100644 index 000000000..e6d1c32b4 --- /dev/null +++ b/x/masterchef/keeper/keeper.go @@ -0,0 +1,74 @@ +package keeper + +import ( + "fmt" + + "github.com/cometbft/cometbft/libs/log" + "github.com/cosmos/cosmos-sdk/codec" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" + + "github.com/elys-network/elys/x/masterchef/types" +) + +type ( + Keeper struct { + cdc codec.BinaryCodec + storeKey storetypes.StoreKey + memKey storetypes.StoreKey + paramstore paramtypes.Subspace + + cmk types.CommitmentKeeper + tci *types.TotalCommitmentInfo + amm types.AmmKeeper + oracleKeeper types.OracleKeeper + assetProfileKeeper types.AssetProfileKeeper + accountedPoolKeeper types.AccountedPoolKeeper + stableKeeper types.StableStakeKeeper + tokenomicsKeeper types.TokenomicsKeeper + authKeeper types.AccountKeeper + bankKeeper types.BankKeeper + + authority string // gov module addresss + } +) + +func NewKeeper( + cdc codec.BinaryCodec, + storeKey, + memKey storetypes.StoreKey, + ps paramtypes.Subspace, + ck types.CommitmentKeeper, + amm types.AmmKeeper, + ok types.OracleKeeper, + ap types.AssetProfileKeeper, + accountedPoolKeeper types.AccountedPoolKeeper, + stableKeeper types.StableStakeKeeper, + tokenomicsKeeper types.TokenomicsKeeper, + ak types.AccountKeeper, + bk types.BankKeeper, + authority string, +) *Keeper { + return &Keeper{ + cdc: cdc, + storeKey: storeKey, + memKey: memKey, + paramstore: ps, + cmk: ck, + tci: &types.TotalCommitmentInfo{}, + amm: amm, + oracleKeeper: ok, + assetProfileKeeper: ap, + accountedPoolKeeper: accountedPoolKeeper, + stableKeeper: stableKeeper, + tokenomicsKeeper: tokenomicsKeeper, + authKeeper: ak, + bankKeeper: bk, + authority: authority, + } +} + +func (k Keeper) Logger(ctx sdk.Context) log.Logger { + return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) +} diff --git a/x/masterchef/keeper/msg_server.go b/x/masterchef/keeper/msg_server.go new file mode 100644 index 000000000..edd358d73 --- /dev/null +++ b/x/masterchef/keeper/msg_server.go @@ -0,0 +1,188 @@ +package keeper + +import ( + "context" + + errorsmod "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + "github.com/elys-network/elys/x/masterchef/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +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{} + +func (k msgServer) AddExternalRewardDenom(goCtx context.Context, msg *types.MsgAddExternalRewardDenom) (*types.MsgAddExternalRewardDenomResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + if k.authority != msg.Authority { + return nil, errorsmod.Wrapf(govtypes.ErrInvalidSigner, "invalid authority; expected %s, got %s", k.authority, msg.Authority) + } + + params := k.GetParams(ctx) + + index := -1 + for i, rewardDenom := range params.SupportedRewardDenoms { + if rewardDenom.Denom == msg.RewardDenom { + index = i + break + } + } + + if index == -1 && msg.Supported { + params.SupportedRewardDenoms = append(params.SupportedRewardDenoms, &types.SupportedRewardDenom{ + Denom: msg.RewardDenom, + MinAmount: msg.MinAmount, + }) + } + + if index != -1 && !msg.Supported { + params.SupportedRewardDenoms = append( + params.SupportedRewardDenoms[:index], + params.SupportedRewardDenoms[index+1:]..., + ) + } + + if index != -1 && msg.Supported { + params.SupportedRewardDenoms[index].MinAmount = msg.MinAmount + } + + k.SetParams(ctx, params) + + return &types.MsgAddExternalRewardDenomResponse{}, nil +} + +func (k msgServer) AddExternalIncentive(goCtx context.Context, msg *types.MsgAddExternalIncentive) (*types.MsgAddExternalIncentiveResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + if msg.FromBlock < uint64(ctx.BlockHeight()) { + return nil, status.Error(codes.InvalidArgument, "invalid from block") + } + if msg.FromBlock >= msg.ToBlock { + return nil, status.Error(codes.InvalidArgument, "invalid block range") + } + if msg.AmountPerBlock.IsZero() { + return nil, status.Error(codes.InvalidArgument, "invalid amount per block") + } + + found := false + params := k.GetParams(ctx) + for _, rewardDenom := range params.SupportedRewardDenoms { + if msg.RewardDenom == rewardDenom.Denom { + found = true + if msg.AmountPerBlock.Mul( + sdk.NewInt(int64(msg.ToBlock - msg.FromBlock)), + ).LT(rewardDenom.MinAmount) { + return nil, status.Error(codes.InvalidArgument, "too small amount") + } + break + } + } + if !found { + return nil, status.Error(codes.InvalidArgument, "invalid reward denom") + } + + err := k.bankKeeper.SendCoinsFromAccountToModule( + ctx, + sdk.MustAccAddressFromBech32(msg.Sender), + types.ModuleName, + sdk.NewCoins( + sdk.NewCoin( + msg.RewardDenom, + msg.AmountPerBlock.Mul( + sdk.NewInt(int64(msg.ToBlock-msg.FromBlock)), + ), + ), + ), + ) + if err != nil { + return nil, err + } + + k.SetExternalIncentive( + ctx, + types.ExternalIncentive{ + Id: 0, + RewardDenom: msg.RewardDenom, + PoolId: msg.PoolId, + FromBlock: msg.FromBlock, + ToBlock: msg.ToBlock, + AmountPerBlock: msg.AmountPerBlock, + }, + ) + + return &types.MsgAddExternalIncentiveResponse{}, nil +} + +func (k msgServer) ClaimRewards(goCtx context.Context, msg *types.MsgClaimRewards) (*types.MsgClaimRewardsResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + sender := sdk.MustAccAddressFromBech32(msg.Sender) + + if len(msg.PoolIds) == 0 { + allPools := k.GetAllPools(ctx) + for _, pool := range allPools { + msg.PoolIds = append(msg.PoolIds, pool.PoolId) + } + } + + coins := sdk.NewCoins() + for _, poolId := range msg.PoolIds { + k.AfterWithdraw(ctx, poolId, msg.Sender, sdk.ZeroInt()) + + for _, rewardDenom := range k.GetRewardDenoms(ctx, poolId) { + userRewardInfo, found := k.GetUserRewardInfo(ctx, msg.Sender, poolId, rewardDenom) + + if found && userRewardInfo.RewardPending.IsPositive() { + coin := sdk.NewCoin(rewardDenom, userRewardInfo.RewardPending.TruncateInt()) + coins = coins.Add(coin) + + userRewardInfo.RewardPending = sdk.ZeroDec() + k.SetUserRewardInfo(ctx, userRewardInfo) + } + } + } + + // Send coins for rest of rewards + err := k.cmk.SendCoinsFromModuleToAccount(ctx, types.ModuleName, sender, coins) + if err != nil { + return nil, err + } + + return &types.MsgClaimRewardsResponse{}, nil +} + +func (k msgServer) UpdateParams(goCtx context.Context, msg *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + if k.authority != msg.Authority { + return nil, errorsmod.Wrapf(govtypes.ErrInvalidSigner, "invalid authority; expected %s, got %s", k.authority, msg.Authority) + } + + k.SetParams(ctx, msg.Params) + + return &types.MsgUpdateParamsResponse{}, nil +} + +func (k msgServer) UpdatePoolMultipliers(goCtx context.Context, msg *types.MsgUpdatePoolMultipliers) (*types.MsgUpdatePoolMultipliersResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + if k.authority != msg.Authority { + return nil, errorsmod.Wrapf(govtypes.ErrInvalidSigner, "invalid authority; expected %s, got %s", k.authority, msg.Authority) + } + + k.Keeper.UpdatePoolMultipliers(ctx, msg.PoolMultipliers) + + return &types.MsgUpdatePoolMultipliersResponse{}, nil +} diff --git a/x/masterchef/keeper/msg_server_test.go b/x/masterchef/keeper/msg_server_test.go new file mode 100644 index 000000000..fe6a537c4 --- /dev/null +++ b/x/masterchef/keeper/msg_server_test.go @@ -0,0 +1,23 @@ +package keeper_test + +import ( + "context" + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + keepertest "github.com/elys-network/elys/testutil/keeper" + "github.com/elys-network/elys/x/masterchef/keeper" + "github.com/elys-network/elys/x/masterchef/types" + "github.com/stretchr/testify/require" +) + +func setupMsgServer(t testing.TB) (types.MsgServer, context.Context) { + k, ctx := keepertest.MasterchefKeeper(t) + return keeper.NewMsgServerImpl(*k), sdk.WrapSDKContext(ctx) +} + +func TestMsgServer(t *testing.T) { + ms, ctx := setupMsgServer(t) + require.NotNil(t, ms) + require.NotNil(t, ctx) +} diff --git a/x/masterchef/keeper/params.go b/x/masterchef/keeper/params.go new file mode 100644 index 000000000..c737047ba --- /dev/null +++ b/x/masterchef/keeper/params.go @@ -0,0 +1,26 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/elys-network/elys/x/masterchef/types" +) + +// GetParams get all parameters as types.Params +func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) { + store := ctx.KVStore(k.storeKey) + + b := store.Get([]byte(types.ParamsKey)) + if b == nil { + return + } + + k.cdc.MustUnmarshal(b, ¶ms) + return +} + +// SetParams set the params +func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { + store := ctx.KVStore(k.storeKey) + b := k.cdc.MustMarshal(¶ms) + store.Set([]byte(types.ParamsKey), b) +} diff --git a/x/masterchef/keeper/params_test.go b/x/masterchef/keeper/params_test.go new file mode 100644 index 000000000..29aa333a5 --- /dev/null +++ b/x/masterchef/keeper/params_test.go @@ -0,0 +1,18 @@ +package keeper_test + +import ( + "testing" + + testkeeper "github.com/elys-network/elys/testutil/keeper" + "github.com/elys-network/elys/x/masterchef/types" + "github.com/stretchr/testify/require" +) + +func TestGetParams(t *testing.T) { + k, ctx := testkeeper.MasterchefKeeper(t) + params := types.DefaultParams() + + k.SetParams(ctx, params) + + require.EqualValues(t, params, k.GetParams(ctx)) +} diff --git a/x/masterchef/keeper/pool.go b/x/masterchef/keeper/pool.go new file mode 100644 index 000000000..8a546b9a8 --- /dev/null +++ b/x/masterchef/keeper/pool.go @@ -0,0 +1,63 @@ +package keeper + +import ( + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/elys-network/elys/x/masterchef/types" +) + +func (k Keeper) SetPool(ctx sdk.Context, pool types.PoolInfo) error { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.PoolInfoKeyPrefix)) + b := k.cdc.MustMarshal(&pool) + store.Set(types.PoolInfoKey(pool.PoolId), b) + return nil +} + +func (k Keeper) GetPool(ctx sdk.Context, poolId uint64) (val types.PoolInfo, found bool) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.PoolInfoKeyPrefix)) + + b := store.Get(types.PoolInfoKey(poolId)) + if b == nil { + return val, false + } + + k.cdc.MustUnmarshal(b, &val) + return val, true +} + +func (k Keeper) RemovePool(ctx sdk.Context, poolId uint64) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.PoolInfoKeyPrefix)) + store.Delete(types.PoolInfoKey(poolId)) +} + +func (k Keeper) GetAllPools(ctx sdk.Context) (list []types.PoolInfo) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.PoolInfoKeyPrefix)) + iterator := sdk.KVStorePrefixIterator(store, []byte{}) + + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + var val types.PoolInfo + k.cdc.MustUnmarshal(iterator.Value(), &val) + list = append(list, val) + } + + return +} + +func (k Keeper) UpdatePoolMultipliers(ctx sdk.Context, poolMultipliers []types.PoolMultiplier) bool { + if len(poolMultipliers) < 1 { + return false + } + + // Update pool multiplier + for _, pm := range poolMultipliers { + p, found := k.GetPool(ctx, pm.PoolId) + if found { + p.Multiplier = pm.Multiplier + k.SetPool(ctx, p) + } + } + + return true +} diff --git a/x/masterchef/keeper/pool_reward_info.go b/x/masterchef/keeper/pool_reward_info.go new file mode 100644 index 000000000..6eb768fe9 --- /dev/null +++ b/x/masterchef/keeper/pool_reward_info.go @@ -0,0 +1,46 @@ +package keeper + +import ( + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/elys-network/elys/x/masterchef/types" +) + +func (k Keeper) SetPoolRewardInfo(ctx sdk.Context, poolReward types.PoolRewardInfo) error { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.PoolRewardInfoKeyPrefix)) + b := k.cdc.MustMarshal(&poolReward) + store.Set(types.PoolRewardInfoKey(poolReward.PoolId, poolReward.RewardDenom), b) + return nil +} + +func (k Keeper) GetPoolRewardInfo(ctx sdk.Context, poolId uint64, rewardDenom string) (val types.PoolRewardInfo, found bool) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.PoolRewardInfoKeyPrefix)) + + b := store.Get(types.PoolRewardInfoKey(poolId, rewardDenom)) + if b == nil { + return val, false + } + + k.cdc.MustUnmarshal(b, &val) + return val, true +} + +func (k Keeper) RemovePoolRewardInfo(ctx sdk.Context, poolId uint64, rewardDenom string) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.PoolRewardInfoKeyPrefix)) + store.Delete(types.PoolRewardInfoKey(poolId, rewardDenom)) +} + +func (k Keeper) GetAllPoolRewardInfos(ctx sdk.Context) (list []types.PoolRewardInfo) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.PoolRewardInfoKeyPrefix)) + iterator := sdk.KVStorePrefixIterator(store, []byte{}) + + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + var val types.PoolRewardInfo + k.cdc.MustUnmarshal(iterator.Value(), &val) + list = append(list, val) + } + + return +} diff --git a/x/masterchef/keeper/pool_reward_info_test.go b/x/masterchef/keeper/pool_reward_info_test.go new file mode 100644 index 000000000..63654ff12 --- /dev/null +++ b/x/masterchef/keeper/pool_reward_info_test.go @@ -0,0 +1,52 @@ +package keeper_test + +import ( + "testing" + + tmproto "github.com/cometbft/cometbft/proto/tendermint/types" + sdk "github.com/cosmos/cosmos-sdk/types" + simapp "github.com/elys-network/elys/app" + "github.com/elys-network/elys/x/masterchef/types" + "github.com/stretchr/testify/require" +) + +func TestPoolRewardInfo(t *testing.T) { + app := simapp.InitElysTestApp(true) + ctx := app.BaseApp.NewContext(true, tmproto.Header{}) + + poolRewardInfos := []types.PoolRewardInfo{ + { + PoolId: 1, + RewardDenom: "reward1", + PoolAccRewardPerShare: sdk.OneDec(), + LastUpdatedBlock: 0, + }, + { + PoolId: 1, + RewardDenom: "reward2", + PoolAccRewardPerShare: sdk.OneDec(), + LastUpdatedBlock: 0, + }, + { + PoolId: 2, + RewardDenom: "reward2", + PoolAccRewardPerShare: sdk.OneDec(), + LastUpdatedBlock: 0, + }, + } + for _, rewardInfo := range poolRewardInfos { + err := app.MasterchefKeeper.SetPoolRewardInfo(ctx, rewardInfo) + require.NoError(t, err) + } + for _, rewardInfo := range poolRewardInfos { + info, found := app.MasterchefKeeper.GetPoolRewardInfo(ctx, rewardInfo.PoolId, rewardInfo.RewardDenom) + require.True(t, found) + require.Equal(t, info, rewardInfo) + } + rewardInfosStored := app.MasterchefKeeper.GetAllPoolRewardInfos(ctx) + require.Len(t, rewardInfosStored, 3) + + app.MasterchefKeeper.RemovePoolRewardInfo(ctx, poolRewardInfos[0].PoolId, poolRewardInfos[0].RewardDenom) + rewardInfosStored = app.MasterchefKeeper.GetAllPoolRewardInfos(ctx) + require.Len(t, rewardInfosStored, 2) +} diff --git a/x/masterchef/keeper/pool_test.go b/x/masterchef/keeper/pool_test.go new file mode 100644 index 000000000..674022681 --- /dev/null +++ b/x/masterchef/keeper/pool_test.go @@ -0,0 +1,162 @@ +package keeper_test + +import ( + "testing" + + tmproto "github.com/cometbft/cometbft/proto/tendermint/types" + sdk "github.com/cosmos/cosmos-sdk/types" + simapp "github.com/elys-network/elys/app" + ammtypes "github.com/elys-network/elys/x/amm/types" + "github.com/elys-network/elys/x/masterchef/types" + "github.com/stretchr/testify/require" +) + +func TestPool(t *testing.T) { + app := simapp.InitElysTestApp(true) + ctx := app.BaseApp.NewContext(true, tmproto.Header{}) + + pools := []types.PoolInfo{ + { + PoolId: 1, + RewardWallet: ammtypes.NewPoolRevenueAddress(1).String(), + Multiplier: sdk.OneDec(), + NumBlocks: sdk.OneInt(), + DexRewardAmountGiven: sdk.OneDec(), + EdenRewardAmountGiven: sdk.OneInt(), + EdenApr: sdk.OneDec(), + DexApr: sdk.OneDec(), + ExternalIncentiveApr: sdk.OneDec(), + ExternalRewardDenoms: []string{ + "rewardDenom1", + "rewardDenom2", + }, + }, + { + PoolId: 2, + RewardWallet: ammtypes.NewPoolRevenueAddress(2).String(), + Multiplier: sdk.OneDec(), + NumBlocks: sdk.OneInt(), + DexRewardAmountGiven: sdk.OneDec(), + EdenRewardAmountGiven: sdk.OneInt(), + EdenApr: sdk.OneDec(), + DexApr: sdk.OneDec(), + ExternalIncentiveApr: sdk.OneDec(), + ExternalRewardDenoms: []string{ + "rewardDenom1", + "rewardDenom2", + }, + }, + { + PoolId: 3, + RewardWallet: ammtypes.NewPoolRevenueAddress(3).String(), + Multiplier: sdk.OneDec(), + NumBlocks: sdk.OneInt(), + DexRewardAmountGiven: sdk.OneDec(), + EdenRewardAmountGiven: sdk.OneInt(), + EdenApr: sdk.OneDec(), + DexApr: sdk.OneDec(), + ExternalIncentiveApr: sdk.OneDec(), + ExternalRewardDenoms: []string{ + "rewardDenom1", + "rewardDenom2", + }, + }, + } + for _, pool := range pools { + err := app.MasterchefKeeper.SetPool(ctx, pool) + require.NoError(t, err) + } + for _, pool := range pools { + info, found := app.MasterchefKeeper.GetPool(ctx, pool.PoolId) + require.True(t, found) + require.Equal(t, info, pool) + } + poolStored := app.MasterchefKeeper.GetAllPools(ctx) + require.Len(t, poolStored, 3) + + app.MasterchefKeeper.RemovePool(ctx, pools[0].PoolId) + poolStored = app.MasterchefKeeper.GetAllPools(ctx) + require.Len(t, poolStored, 2) +} + +func TestUpdatePoolMultipliers(t *testing.T) { + app := simapp.InitElysTestApp(true) + ctx := app.BaseApp.NewContext(true, tmproto.Header{}) + + pools := []types.PoolInfo{ + { + PoolId: 1, + RewardWallet: ammtypes.NewPoolRevenueAddress(1).String(), + Multiplier: sdk.OneDec(), + NumBlocks: sdk.OneInt(), + DexRewardAmountGiven: sdk.OneDec(), + EdenRewardAmountGiven: sdk.OneInt(), + EdenApr: sdk.OneDec(), + DexApr: sdk.OneDec(), + ExternalIncentiveApr: sdk.OneDec(), + ExternalRewardDenoms: []string{ + "rewardDenom1", + "rewardDenom2", + }, + }, + { + PoolId: 2, + RewardWallet: ammtypes.NewPoolRevenueAddress(2).String(), + Multiplier: sdk.OneDec(), + NumBlocks: sdk.OneInt(), + DexRewardAmountGiven: sdk.OneDec(), + EdenRewardAmountGiven: sdk.OneInt(), + EdenApr: sdk.OneDec(), + DexApr: sdk.OneDec(), + ExternalIncentiveApr: sdk.OneDec(), + ExternalRewardDenoms: []string{ + "rewardDenom1", + "rewardDenom2", + }, + }, + { + PoolId: 3, + RewardWallet: ammtypes.NewPoolRevenueAddress(3).String(), + Multiplier: sdk.OneDec(), + NumBlocks: sdk.OneInt(), + DexRewardAmountGiven: sdk.OneDec(), + EdenRewardAmountGiven: sdk.OneInt(), + EdenApr: sdk.OneDec(), + DexApr: sdk.OneDec(), + ExternalIncentiveApr: sdk.OneDec(), + ExternalRewardDenoms: []string{ + "rewardDenom1", + "rewardDenom2", + }, + }, + } + for _, pool := range pools { + err := app.MasterchefKeeper.SetPool(ctx, pool) + require.NoError(t, err) + } + for _, pool := range pools { + info, found := app.MasterchefKeeper.GetPool(ctx, pool.PoolId) + require.True(t, found) + require.Equal(t, info.Multiplier, sdk.OneDec()) + } + + poolMultipliers := []types.PoolMultiplier{ + { + PoolId: 1, + Multiplier: sdk.OneDec().Add(sdk.OneDec()), + }, { + PoolId: 2, + Multiplier: sdk.OneDec().Add(sdk.OneDec()), + }, { + PoolId: 3, + Multiplier: sdk.OneDec().Add(sdk.OneDec()), + }, + } + success := app.MasterchefKeeper.UpdatePoolMultipliers(ctx, poolMultipliers) + require.True(t, success) + for _, pool := range pools { + info, found := app.MasterchefKeeper.GetPool(ctx, pool.PoolId) + require.True(t, found) + require.Equal(t, info.Multiplier, sdk.OneDec().Add(sdk.OneDec())) + } +} diff --git a/x/masterchef/keeper/query.go b/x/masterchef/keeper/query.go new file mode 100644 index 000000000..4970740e7 --- /dev/null +++ b/x/masterchef/keeper/query.go @@ -0,0 +1,125 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/elys-network/elys/x/masterchef/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +var _ types.QueryServer = Keeper{} + +func (k Keeper) ExternalIncentive(goCtx context.Context, req *types.QueryExternalIncentiveRequest) (*types.QueryExternalIncentiveResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + externalIncentive, found := k.GetExternalIncentive(ctx, req.Id) + if !found { + return nil, status.Error(codes.InvalidArgument, "invalid external incentive id") + } + + return &types.QueryExternalIncentiveResponse{ExternalIncentive: externalIncentive}, nil +} + +func (k Keeper) PoolInfo(goCtx context.Context, req *types.QueryPoolInfoRequest) (*types.QueryPoolInfoResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + poolInfo, found := k.GetPool(ctx, req.PoolId) + if !found { + return nil, status.Error(codes.InvalidArgument, "invalid pool id") + } + + return &types.QueryPoolInfoResponse{PoolInfo: poolInfo}, nil +} + +func (k Keeper) PoolRewardInfo(goCtx context.Context, req *types.QueryPoolRewardInfoRequest) (*types.QueryPoolRewardInfoResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + poolRewardInfo, found := k.GetPoolRewardInfo(ctx, req.PoolId, req.RewardDenom) + if !found { + return nil, status.Error(codes.InvalidArgument, "invalid pool id") + } + + return &types.QueryPoolRewardInfoResponse{PoolRewardInfo: poolRewardInfo}, nil +} + +func (k Keeper) UserRewardInfo(goCtx context.Context, req *types.QueryUserRewardInfoRequest) (*types.QueryUserRewardInfoResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + userRewardInfo, found := k.GetUserRewardInfo(ctx, req.User, req.PoolId, req.RewardDenom) + if !found { + return nil, status.Error(codes.InvalidArgument, "invalid pool id or denom") + } + + return &types.QueryUserRewardInfoResponse{UserRewardInfo: userRewardInfo}, nil +} + +func (k Keeper) UserPendingReward(goCtx context.Context, req *types.QueryUserPendingRewardRequest) (*types.QueryUserPendingRewardResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + totalRewards := sdk.NewCoins() + rewardsInfos := []*types.RewardInfo{} + + for _, pool := range k.GetAllPools(ctx) { + k.AfterWithdraw( + ctx, + pool.PoolId, + req.User, + sdk.ZeroInt(), + ) + + poolRewards := sdk.NewCoins() + for _, rewardDenom := range k.GetRewardDenoms(ctx, pool.PoolId) { + userRewardInfo, found := k.GetUserRewardInfo(ctx, req.User, pool.PoolId, rewardDenom) + if found && userRewardInfo.RewardPending.IsPositive() { + poolRewards = poolRewards.Add( + sdk.NewCoin( + rewardDenom, + userRewardInfo.RewardPending.TruncateInt(), + ), + ) + } + } + rewardsInfos = append(rewardsInfos, + &types.RewardInfo{ + PoolId: pool.PoolId, + Reward: poolRewards, + }, + ) + + totalRewards = totalRewards.Add( + poolRewards..., + ) + } + + return &types.QueryUserPendingRewardResponse{ + Rewards: rewardsInfos, + TotalRewards: totalRewards, + }, nil +} + +func (k Keeper) StableStakeApr(goCtx context.Context, req *types.QueryStableStakeAprRequest) (*types.QueryStableStakeAprResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + + apr, err := k.CalculateStableStakeApr(ctx, req) + if err != nil { + return nil, err + } + + return &types.QueryStableStakeAprResponse{Apr: apr}, nil +} + +func (k Keeper) PoolAprs(goCtx context.Context, req *types.QueryPoolAprsRequest) (*types.QueryPoolAprsResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + data := k.CalculatePoolAprs(ctx, req.PoolIds) + return &types.QueryPoolAprsResponse{Data: data}, nil +} diff --git a/x/masterchef/keeper/query_params.go b/x/masterchef/keeper/query_params.go new file mode 100644 index 000000000..fccad9230 --- /dev/null +++ b/x/masterchef/keeper/query_params.go @@ -0,0 +1,19 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/elys-network/elys/x/masterchef/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func (k Keeper) Params(goCtx context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + ctx := sdk.UnwrapSDKContext(goCtx) + + return &types.QueryParamsResponse{Params: k.GetParams(ctx)}, nil +} diff --git a/x/masterchef/keeper/query_params_test.go b/x/masterchef/keeper/query_params_test.go new file mode 100644 index 000000000..126d1180e --- /dev/null +++ b/x/masterchef/keeper/query_params_test.go @@ -0,0 +1,21 @@ +package keeper_test + +import ( + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + testkeeper "github.com/elys-network/elys/testutil/keeper" + "github.com/elys-network/elys/x/masterchef/types" + "github.com/stretchr/testify/require" +) + +func TestParamsQuery(t *testing.T) { + keeper, ctx := testkeeper.MasterchefKeeper(t) + wctx := sdk.WrapSDKContext(ctx) + params := types.DefaultParams() + keeper.SetParams(ctx, params) + + response, err := keeper.Params(wctx, &types.QueryParamsRequest{}) + require.NoError(t, err) + require.Equal(t, &types.QueryParamsResponse{Params: params}, response) +} diff --git a/x/masterchef/keeper/user_reward_info.go b/x/masterchef/keeper/user_reward_info.go new file mode 100644 index 000000000..c827cc11f --- /dev/null +++ b/x/masterchef/keeper/user_reward_info.go @@ -0,0 +1,46 @@ +package keeper + +import ( + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/elys-network/elys/x/masterchef/types" +) + +func (k Keeper) SetUserRewardInfo(ctx sdk.Context, userReward types.UserRewardInfo) error { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.UserRewardInfoKeyPrefix)) + b := k.cdc.MustMarshal(&userReward) + store.Set(types.UserRewardInfoKey(userReward.User, userReward.PoolId, userReward.RewardDenom), b) + return nil +} + +func (k Keeper) GetUserRewardInfo(ctx sdk.Context, user string, poolId uint64, rewardDenom string) (val types.UserRewardInfo, found bool) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.UserRewardInfoKeyPrefix)) + + b := store.Get(types.UserRewardInfoKey(user, poolId, rewardDenom)) + if b == nil { + return val, false + } + + k.cdc.MustUnmarshal(b, &val) + return val, true +} + +func (k Keeper) RemoveUserRewardInfo(ctx sdk.Context, user string, poolId uint64, rewardDenom string) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.UserRewardInfoKeyPrefix)) + store.Delete(types.UserRewardInfoKey(user, poolId, rewardDenom)) +} + +func (k Keeper) GetAllUserRewardInfos(ctx sdk.Context) (list []types.UserRewardInfo) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.UserRewardInfoKeyPrefix)) + iterator := sdk.KVStorePrefixIterator(store, []byte{}) + + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + var val types.UserRewardInfo + k.cdc.MustUnmarshal(iterator.Value(), &val) + list = append(list, val) + } + + return +} diff --git a/x/masterchef/keeper/user_reward_info_test.go b/x/masterchef/keeper/user_reward_info_test.go new file mode 100644 index 000000000..e1a3df71e --- /dev/null +++ b/x/masterchef/keeper/user_reward_info_test.go @@ -0,0 +1,58 @@ +package keeper_test + +import ( + "testing" + + "github.com/cometbft/cometbft/crypto/ed25519" + tmproto "github.com/cometbft/cometbft/proto/tendermint/types" + sdk "github.com/cosmos/cosmos-sdk/types" + simapp "github.com/elys-network/elys/app" + "github.com/elys-network/elys/x/masterchef/types" + "github.com/stretchr/testify/require" +) + +func TestUserRewardInfo(t *testing.T) { + app := simapp.InitElysTestApp(true) + ctx := app.BaseApp.NewContext(true, tmproto.Header{}) + + user1 := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address()) + user2 := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address()) + userRewardInfos := []types.UserRewardInfo{ + { + User: user1.String(), + PoolId: 1, + RewardDenom: "reward1", + RewardDebt: sdk.ZeroDec(), + RewardPending: sdk.ZeroDec(), + }, + { + User: user1.String(), + PoolId: 1, + RewardDenom: "reward2", + RewardDebt: sdk.ZeroDec(), + RewardPending: sdk.ZeroDec(), + }, + { + User: user2.String(), + PoolId: 2, + RewardDenom: "reward2", + RewardDebt: sdk.ZeroDec(), + RewardPending: sdk.ZeroDec(), + }, + } + for _, rewardInfo := range userRewardInfos { + err := app.MasterchefKeeper.SetUserRewardInfo(ctx, rewardInfo) + require.NoError(t, err) + } + for _, rewardInfo := range userRewardInfos { + info, found := app.MasterchefKeeper.GetUserRewardInfo(ctx, rewardInfo.User, rewardInfo.PoolId, rewardInfo.RewardDenom) + require.True(t, found) + require.Equal(t, info, rewardInfo) + } + rewardInfosStored := app.MasterchefKeeper.GetAllUserRewardInfos(ctx) + require.Len(t, rewardInfosStored, 3) + + app.MasterchefKeeper.RemoveUserRewardInfo(ctx, userRewardInfos[0].User, userRewardInfos[0].PoolId, userRewardInfos[0].RewardDenom) + rewardInfosStored = app.MasterchefKeeper.GetAllUserRewardInfos(ctx) + require.Len(t, rewardInfosStored, 2) +} diff --git a/x/masterchef/module.go b/x/masterchef/module.go new file mode 100644 index 000000000..99d56941e --- /dev/null +++ b/x/masterchef/module.go @@ -0,0 +1,151 @@ +package masterchef + +import ( + "context" + "encoding/json" + "fmt" + + // this line is used by starport scaffolding # 1 + + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/spf13/cobra" + + abci "github.com/cometbft/cometbft/abci/types" + + "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" + "github.com/elys-network/elys/x/masterchef/client/cli" + "github.com/elys-network/elys/x/masterchef/keeper" + "github.com/elys-network/elys/x/masterchef/types" +) + +var ( + _ module.AppModule = AppModule{} + _ module.AppModuleBasic = AppModuleBasic{} +) + +// ---------------------------------------------------------------------------- +// AppModuleBasic +// ---------------------------------------------------------------------------- + +// AppModuleBasic implements the AppModuleBasic interface that defines the independent methods a Cosmos SDK module needs to implement. +type AppModuleBasic struct { + cdc codec.BinaryCodec +} + +func NewAppModuleBasic(cdc codec.BinaryCodec) AppModuleBasic { + return AppModuleBasic{cdc: cdc} +} + +// Name returns the name of the module as a string +func (AppModuleBasic) Name() string { + return types.ModuleName +} + +// RegisterLegacyAminoCodec registers the amino codec for the module, which is used to marshal and unmarshal structs to/from []byte in order to persist them in the module's KVStore +func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + types.RegisterCodec(cdc) +} + +// RegisterInterfaces registers a module's interface types and their concrete implementations as proto.Message +func (a AppModuleBasic) RegisterInterfaces(reg cdctypes.InterfaceRegistry) { + types.RegisterInterfaces(reg) +} + +// DefaultGenesis returns a default GenesisState for the module, marshalled to json.RawMessage. The default GenesisState need to be defined by the module developer and is primarily used for testing +func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { + return cdc.MustMarshalJSON(types.DefaultGenesis()) +} + +// ValidateGenesis used to validate the GenesisState, given in its json.RawMessage form +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() +} + +// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module +func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { + types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) +} + +// GetTxCmd returns the root Tx command for the module. The subcommands of this root command are used by end-users to generate new transactions containing messages defined in the module +func (a AppModuleBasic) GetTxCmd() *cobra.Command { + return cli.GetTxCmd() +} + +// GetQueryCmd returns the root query command for the module. The subcommands of this root command are used by end-users to generate new queries to the subset of the state defined by the module +func (AppModuleBasic) GetQueryCmd() *cobra.Command { + return cli.GetQueryCmd(types.StoreKey) +} + +// ---------------------------------------------------------------------------- +// AppModule +// ---------------------------------------------------------------------------- + +// AppModule implements the AppModule interface that defines the inter-dependent methods that modules need to implement +type AppModule struct { + AppModuleBasic + + keeper keeper.Keeper + accountKeeper types.AccountKeeper + bankKeeper types.BankKeeper +} + +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, + } +} + +// RegisterServices registers a gRPC query service to respond to the module-specific gRPC queries +func (am AppModule) RegisterServices(cfg module.Configurator) { + types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) + types.RegisterQueryServer(cfg.QueryServer(), am.keeper) +} + +// RegisterInvariants registers the invariants of the module. If an invariant deviates from its predicted value, the InvariantRegistry triggers appropriate logic (most often the chain will be halted) +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 + // Initialize global index to index in genesis state + cdc.MustUnmarshalJSON(gs, &genState) + + InitGenesis(ctx, am.keeper, 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 := ExportGenesis(ctx, am.keeper) + return cdc.MustMarshalJSON(genState) +} + +// ConsensusVersion is a sequence number for state-breaking change of the module. It should be incremented on each consensus-breaking change introduced by the module. To avoid wrong/empty versions, the initial version should be set to 1 +func (AppModule) ConsensusVersion() uint64 { return 1 } + +// BeginBlock contains the logic that is automatically triggered at the beginning of each block +func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {} + +// EndBlock contains the logic that is automatically triggered at the end of each block +func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { + am.keeper.EndBlocker(ctx) + + return []abci.ValidatorUpdate{} +} diff --git a/x/masterchef/module_simulation.go b/x/masterchef/module_simulation.go new file mode 100644 index 000000000..a537658f9 --- /dev/null +++ b/x/masterchef/module_simulation.go @@ -0,0 +1,64 @@ +package masterchef + +import ( + "math/rand" + + "github.com/cosmos/cosmos-sdk/baseapp" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + "github.com/cosmos/cosmos-sdk/x/simulation" + "github.com/elys-network/elys/testutil/sample" + masterchefsimulation "github.com/elys-network/elys/x/masterchef/simulation" + "github.com/elys-network/elys/x/masterchef/types" +) + +// avoid unused import issue +var ( + _ = sample.AccAddress + _ = masterchefsimulation.FindAccount + _ = simulation.MsgEntryKind + _ = baseapp.Paramspace + _ = rand.Rand{} +) + +const ( +// this line is used by starport scaffolding # simapp/module/const +) + +// GenerateGenesisState creates a randomized GenState of the module. +func (AppModule) GenerateGenesisState(simState *module.SimulationState) { + accs := make([]string, len(simState.Accounts)) + for i, acc := range simState.Accounts { + accs[i] = acc.Address.String() + } + masterchefGenesis := types.GenesisState{ + Params: types.DefaultParams(), + // this line is used by starport scaffolding # simapp/module/genesisState + } + simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(&masterchefGenesis) +} + +// RegisterStoreDecoder registers a decoder. +func (am AppModule) RegisterStoreDecoder(_ sdk.StoreDecoderRegistry) {} + +// ProposalContents doesn't return any content functions for governance proposals. +func (AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedProposalContent { + return nil +} + +// WeightedOperations returns the all the gov module operations with their respective weights. +func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation { + operations := make([]simtypes.WeightedOperation, 0) + + // this line is used by starport scaffolding # simapp/module/operation + + return operations +} + +// ProposalMsgs returns msgs used for governance proposals for simulations. +func (am AppModule) ProposalMsgs(simState module.SimulationState) []simtypes.WeightedProposalMsg { + return []simtypes.WeightedProposalMsg{ + // this line is used by starport scaffolding # simapp/module/OpMsg + } +} diff --git a/x/masterchef/simulation/helpers.go b/x/masterchef/simulation/helpers.go new file mode 100644 index 000000000..92c437c0d --- /dev/null +++ b/x/masterchef/simulation/helpers.go @@ -0,0 +1,15 @@ +package simulation + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" +) + +// FindAccount find a specific address from an account list +func FindAccount(accs []simtypes.Account, address string) (simtypes.Account, bool) { + creator, err := sdk.AccAddressFromBech32(address) + if err != nil { + panic(err) + } + return simtypes.FindAccount(accs, creator) +} diff --git a/x/masterchef/types/codec.go b/x/masterchef/types/codec.go new file mode 100644 index 000000000..093b3a217 --- /dev/null +++ b/x/masterchef/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" + + // this line is used by starport scaffolding # 1 + "github.com/cosmos/cosmos-sdk/types/msgservice" +) + +func RegisterCodec(cdc *codec.LegacyAmino) { + cdc.RegisterConcrete(&MsgAddExternalIncentive{}, "masterchef/AddExternalIncentive", nil) + cdc.RegisterConcrete(&MsgClaimRewards{}, "masterchef/ClaimRewards", nil) + cdc.RegisterConcrete(&MsgUpdateParams{}, "masterchef/UpdateParams", nil) + cdc.RegisterConcrete(&MsgUpdatePoolMultipliers{}, "masterchef/UpdatePoolMultipliers", nil) + cdc.RegisterConcrete(&MsgAddExternalRewardDenom{}, "masterchef/AddExternalRewardDenom", nil) + // this line is used by starport scaffolding # 2 +} + +func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgAddExternalIncentive{}, + &MsgClaimRewards{}, + &MsgUpdateParams{}, + &MsgUpdatePoolMultipliers{}, + &MsgAddExternalRewardDenom{}, + ) + // this line is used by starport scaffolding # 3 + + msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) +} + +var ( + Amino = codec.NewLegacyAmino() + ModuleCdc = codec.NewProtoCodec(cdctypes.NewInterfaceRegistry()) +) diff --git a/x/masterchef/types/dex_rewards_traker.pb.go b/x/masterchef/types/dex_rewards_traker.pb.go new file mode 100644 index 000000000..d4991a805 --- /dev/null +++ b/x/masterchef/types/dex_rewards_traker.pb.go @@ -0,0 +1,397 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: elys/masterchef/dex_rewards_traker.proto + +package types + +import ( + fmt "fmt" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + 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 + +// DexRewardsTracker is used for tracking rewards for LPs, all amount here is in USDC +type DexRewardsTracker struct { + // Number of blocks since start of epoch (distribution epoch) + NumBlocks github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=num_blocks,json=numBlocks,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"num_blocks"` + // Accumulated amount at distribution epoch - recalculated at every distribution epoch + Amount github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=amount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"amount"` +} + +func (m *DexRewardsTracker) Reset() { *m = DexRewardsTracker{} } +func (m *DexRewardsTracker) String() string { return proto.CompactTextString(m) } +func (*DexRewardsTracker) ProtoMessage() {} +func (*DexRewardsTracker) Descriptor() ([]byte, []int) { + return fileDescriptor_c1c2f8f06d589e3d, []int{0} +} +func (m *DexRewardsTracker) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *DexRewardsTracker) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_DexRewardsTracker.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 *DexRewardsTracker) XXX_Merge(src proto.Message) { + xxx_messageInfo_DexRewardsTracker.Merge(m, src) +} +func (m *DexRewardsTracker) XXX_Size() int { + return m.Size() +} +func (m *DexRewardsTracker) XXX_DiscardUnknown() { + xxx_messageInfo_DexRewardsTracker.DiscardUnknown(m) +} + +var xxx_messageInfo_DexRewardsTracker proto.InternalMessageInfo + +func init() { + proto.RegisterType((*DexRewardsTracker)(nil), "elys.masterchef.DexRewardsTracker") +} + +func init() { + proto.RegisterFile("elys/masterchef/dex_rewards_traker.proto", fileDescriptor_c1c2f8f06d589e3d) +} + +var fileDescriptor_c1c2f8f06d589e3d = []byte{ + // 256 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0x48, 0xcd, 0xa9, 0x2c, + 0xd6, 0xcf, 0x4d, 0x2c, 0x2e, 0x49, 0x2d, 0x4a, 0xce, 0x48, 0x4d, 0xd3, 0x4f, 0x49, 0xad, 0x88, + 0x2f, 0x4a, 0x2d, 0x4f, 0x2c, 0x4a, 0x29, 0x8e, 0x2f, 0x29, 0x4a, 0xcc, 0x4e, 0x2d, 0xd2, 0x2b, + 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x07, 0xa9, 0xd4, 0x43, 0xa8, 0x94, 0x12, 0x49, 0xcf, 0x4f, + 0xcf, 0x07, 0xcb, 0xe9, 0x83, 0x58, 0x10, 0x65, 0x4a, 0xab, 0x18, 0xb9, 0x04, 0x5d, 0x52, 0x2b, + 0x82, 0x20, 0x46, 0x84, 0x14, 0x25, 0x26, 0x67, 0xa7, 0x16, 0x09, 0xf9, 0x72, 0x71, 0xe5, 0x95, + 0xe6, 0xc6, 0x27, 0xe5, 0xe4, 0x27, 0x67, 0x17, 0x4b, 0x30, 0x2a, 0x30, 0x6a, 0x70, 0x3a, 0xe9, + 0x9d, 0xb8, 0x27, 0xcf, 0x70, 0xeb, 0x9e, 0xbc, 0x5a, 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, + 0x72, 0x7e, 0xae, 0x7e, 0x72, 0x7e, 0x71, 0x6e, 0x7e, 0x31, 0x94, 0xd2, 0x2d, 0x4e, 0xc9, 0xd6, + 0x2f, 0xa9, 0x2c, 0x48, 0x2d, 0xd6, 0xf3, 0xcc, 0x2b, 0x09, 0xe2, 0xcc, 0x2b, 0xcd, 0x75, 0x02, + 0x1b, 0x20, 0xe4, 0xc6, 0xc5, 0x96, 0x98, 0x9b, 0x5f, 0x9a, 0x57, 0x22, 0xc1, 0x44, 0xb2, 0x51, + 0x2e, 0xa9, 0xc9, 0x41, 0x50, 0xdd, 0x4e, 0xbe, 0x2b, 0x1e, 0xc9, 0x31, 0x9e, 0x78, 0x24, 0xc7, + 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, 0x2c, + 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x43, 0x94, 0x3e, 0x92, 0x69, 0x20, 0xcf, 0xeb, 0xe6, 0xa5, 0x96, + 0x94, 0xe7, 0x17, 0x65, 0x83, 0x39, 0xfa, 0x15, 0xc8, 0xa1, 0x06, 0x36, 0x3a, 0x89, 0x0d, 0x1c, + 0x04, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0xa2, 0x69, 0xe1, 0x38, 0x55, 0x01, 0x00, 0x00, +} + +func (this *DexRewardsTracker) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*DexRewardsTracker) + if !ok { + that2, ok := that.(DexRewardsTracker) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if !this.NumBlocks.Equal(that1.NumBlocks) { + return false + } + if !this.Amount.Equal(that1.Amount) { + return false + } + return true +} +func (m *DexRewardsTracker) 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 *DexRewardsTracker) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *DexRewardsTracker) 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 = encodeVarintDexRewardsTraker(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + { + size := m.NumBlocks.Size() + i -= size + if _, err := m.NumBlocks.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintDexRewardsTraker(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func encodeVarintDexRewardsTraker(dAtA []byte, offset int, v uint64) int { + offset -= sovDexRewardsTraker(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *DexRewardsTracker) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.NumBlocks.Size() + n += 1 + l + sovDexRewardsTraker(uint64(l)) + l = m.Amount.Size() + n += 1 + l + sovDexRewardsTraker(uint64(l)) + return n +} + +func sovDexRewardsTraker(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozDexRewardsTraker(x uint64) (n int) { + return sovDexRewardsTraker(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *DexRewardsTracker) 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 ErrIntOverflowDexRewardsTraker + } + 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: DexRewardsTracker: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DexRewardsTracker: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NumBlocks", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDexRewardsTraker + } + 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 ErrInvalidLengthDexRewardsTraker + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthDexRewardsTraker + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.NumBlocks.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + 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 ErrIntOverflowDexRewardsTraker + } + 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 ErrInvalidLengthDexRewardsTraker + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthDexRewardsTraker + } + 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 := skipDexRewardsTraker(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthDexRewardsTraker + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipDexRewardsTraker(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, ErrIntOverflowDexRewardsTraker + } + 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, ErrIntOverflowDexRewardsTraker + } + 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, ErrIntOverflowDexRewardsTraker + } + 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, ErrInvalidLengthDexRewardsTraker + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupDexRewardsTraker + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthDexRewardsTraker + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthDexRewardsTraker = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowDexRewardsTraker = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupDexRewardsTraker = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/masterchef/types/errors.go b/x/masterchef/types/errors.go new file mode 100644 index 000000000..97d717d0d --- /dev/null +++ b/x/masterchef/types/errors.go @@ -0,0 +1,12 @@ +package types + +// DONTCOVER + +import ( + errorsmod "cosmossdk.io/errors" +) + +// x/masterchef module sentinel errors +var ( + ErrNoInflationaryParams = errorsmod.Register(ModuleName, 14, "no inflationary rewards params") +) diff --git a/x/masterchef/types/expected_keepers.go b/x/masterchef/types/expected_keepers.go new file mode 100644 index 000000000..165a3cb3e --- /dev/null +++ b/x/masterchef/types/expected_keepers.go @@ -0,0 +1,136 @@ +package types + +import ( + context "context" + + "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/auth/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + ammtypes "github.com/elys-network/elys/x/amm/types" + aptypes "github.com/elys-network/elys/x/assetprofile/types" + ctypes "github.com/elys-network/elys/x/commitment/types" + oracletypes "github.com/elys-network/elys/x/oracle/types" + stabletypes "github.com/elys-network/elys/x/stablestake/types" + tokenomictypes "github.com/elys-network/elys/x/tokenomics/types" +) + +// CommitmentKeeper +type CommitmentKeeper interface { + BeforeDelegationCreated(sdk.Context, string, string) error + IterateCommitments(sdk.Context, func(ctypes.Commitments) (stop bool)) + GetCommitments(sdk.Context, string) ctypes.Commitments + SetCommitments(sdk.Context, ctypes.Commitments) + MintCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) error + BurnEdenBoost(ctx sdk.Context, creator string, denom string, amount math.Int) (ctypes.Commitments, error) + SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error + GetParams(sdk.Context) ctypes.Params +} + +// Staking keeper +type StakingKeeper interface { + TotalBondedTokens(sdk.Context) math.Int // total bonded tokens within the validator set + // iterate through all delegations from one delegator by validator-AccAddress, + // execute func for each validator + IterateDelegations(ctx sdk.Context, delegator sdk.AccAddress, fn func(index int64, delegation stakingtypes.DelegationI) (stop bool)) + // get a particular validator by operator address + Validator(sdk.Context, sdk.ValAddress) stakingtypes.ValidatorI + // GetDelegatorDelegations returns a given amount of all the delegations from a delegator. + GetDelegatorDelegations(ctx sdk.Context, delegator sdk.AccAddress, maxRetrieve uint16) (delegations []stakingtypes.Delegation) + // get a particular validator by consensus address + ValidatorByConsAddr(sdk.Context, sdk.ConsAddress) stakingtypes.ValidatorI + // Delegation allows for getting a particular delegation for a given validator + // and delegator outside the scope of the staking module. + Delegation(sdk.Context, sdk.AccAddress, sdk.ValAddress) stakingtypes.DelegationI +} + +// AccountKeeper defines the expected account keeper used for simulations (noalias) +type AccountKeeper interface { + GetAccount(ctx sdk.Context, addr sdk.AccAddress) types.AccountI + + GetModuleAddress(name string) sdk.AccAddress + GetModuleAccount(ctx sdk.Context, name string) types.ModuleAccountI +} + +// BankKeeper defines the expected interface needed to retrieve account balances. +type BankKeeper interface { + GetAllBalances(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins + GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin + + SpendableCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins + + SendCoinsFromModuleToModule(ctx sdk.Context, senderModule string, recipientModule 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 + + BlockedAddr(addr sdk.AccAddress) bool + BurnCoins(ctx sdk.Context, name string, amt sdk.Coins) error + MintCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) error +} + +// AmmKeeper defines the expected interface needed to swap tokens +type AmmKeeper interface { + // UpdatePoolForSwap takes a pool, sender, and tokenIn, tokenOut amounts + // It then updates the pool's balances to the new reserve amounts, and + // sends the in tokens from the sender to the pool, and the out tokens from the pool to the sender. + UpdatePoolForSwap( + ctx sdk.Context, + pool ammtypes.Pool, + sender sdk.AccAddress, + recipient sdk.AccAddress, + tokenIn sdk.Coin, + tokenOut sdk.Coin, + swapFeeIn sdk.Dec, + swapFeeOut sdk.Dec, + weightBalanceBonus sdk.Dec, + ) (math.Int, error) + GetBestPoolWithDenoms(ctx sdk.Context, denoms []string) (pool ammtypes.Pool, found bool) + // GetPool returns a pool from its index + GetPool(sdk.Context, uint64) (ammtypes.Pool, bool) + // Get all pools + GetAllPool(sdk.Context) []ammtypes.Pool + // IterateCommitments iterates over all Commitments and performs a callback. + IterateLiquidityPools(sdk.Context, func(ammtypes.Pool) bool) + GetPoolSnapshotOrSet(ctx sdk.Context, pool ammtypes.Pool) (val ammtypes.Pool) + + SwapOutAmtGivenIn( + ctx sdk.Context, poolId uint64, + oracleKeeper ammtypes.OracleKeeper, + snapshot *ammtypes.Pool, + tokensIn sdk.Coins, + tokenOutDenom string, + swapFee sdk.Dec, + ) (tokenOut sdk.Coin, slippage, slippageAmount sdk.Dec, weightBalanceBonus sdk.Dec, err error) + CalcOutAmtGivenIn(ctx sdk.Context, poolId uint64, oracle ammtypes.OracleKeeper, snapshot *ammtypes.Pool, tokensIn sdk.Coins, tokenOutDenom string, swapFee sdk.Dec) (sdk.Coin, sdk.Dec, error) + GetEdenDenomPrice(ctx sdk.Context, baseCurrency string) math.LegacyDec + GetTokenPrice(ctx sdk.Context, tokenInDenom, baseCurrency string) math.LegacyDec +} + +// OracleKeeper defines the expected interface needed to retrieve price info +type OracleKeeper interface { + GetAssetPrice(ctx sdk.Context, asset string) (oracletypes.Price, bool) + GetAssetPriceFromDenom(ctx sdk.Context, denom string) sdk.Dec + GetPriceFeeder(ctx sdk.Context, feeder string) (val oracletypes.PriceFeeder, found bool) +} + +// AccountedPoolKeeper +type AccountedPoolKeeper interface { + GetAccountedBalance(sdk.Context, uint64, string) math.Int +} + +// AssetProfileKeeper defines the expected interface needed to retrieve denom info +type AssetProfileKeeper interface { + GetEntry(ctx sdk.Context, baseDenom string) (val aptypes.Entry, found bool) +} + +// StableStakeKeeper defines the expected stablestake keeper used for simulations (noalias) +type StableStakeKeeper interface { + GetParams(ctx sdk.Context) (params stabletypes.Params) + BorrowRatio(goCtx context.Context, req *stabletypes.QueryBorrowRatioRequest) (*stabletypes.QueryBorrowRatioResponse, error) + TVL(ctx sdk.Context, oracleKeeper stabletypes.OracleKeeper, baseCurrency string) math.LegacyDec +} + +// TokenomicsKeeper defines the expected tokenomics keeper used for simulations (noalias) +type TokenomicsKeeper interface { + GetAllTimeBasedInflation(ctx sdk.Context) (list []tokenomictypes.TimeBasedInflation) +} diff --git a/x/masterchef/types/external_incentive.pb.go b/x/masterchef/types/external_incentive.pb.go new file mode 100644 index 000000000..5ea46099a --- /dev/null +++ b/x/masterchef/types/external_incentive.pb.go @@ -0,0 +1,516 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: elys/masterchef/external_incentive.proto + +package types + +import ( + fmt "fmt" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + 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 + +// ExternalIncentive defines the external incentives. +type ExternalIncentive struct { + Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + RewardDenom string `protobuf:"bytes,2,opt,name=reward_denom,json=rewardDenom,proto3" json:"reward_denom,omitempty"` + PoolId uint64 `protobuf:"varint,3,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty"` + FromBlock uint64 `protobuf:"varint,4,opt,name=from_block,json=fromBlock,proto3" json:"from_block,omitempty"` + ToBlock uint64 `protobuf:"varint,5,opt,name=to_block,json=toBlock,proto3" json:"to_block,omitempty"` + AmountPerBlock github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,6,opt,name=amount_per_block,json=amountPerBlock,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"amount_per_block"` +} + +func (m *ExternalIncentive) Reset() { *m = ExternalIncentive{} } +func (m *ExternalIncentive) String() string { return proto.CompactTextString(m) } +func (*ExternalIncentive) ProtoMessage() {} +func (*ExternalIncentive) Descriptor() ([]byte, []int) { + return fileDescriptor_3d270e9faef9dc8d, []int{0} +} +func (m *ExternalIncentive) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ExternalIncentive) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ExternalIncentive.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 *ExternalIncentive) XXX_Merge(src proto.Message) { + xxx_messageInfo_ExternalIncentive.Merge(m, src) +} +func (m *ExternalIncentive) XXX_Size() int { + return m.Size() +} +func (m *ExternalIncentive) XXX_DiscardUnknown() { + xxx_messageInfo_ExternalIncentive.DiscardUnknown(m) +} + +var xxx_messageInfo_ExternalIncentive proto.InternalMessageInfo + +func (m *ExternalIncentive) GetId() uint64 { + if m != nil { + return m.Id + } + return 0 +} + +func (m *ExternalIncentive) GetRewardDenom() string { + if m != nil { + return m.RewardDenom + } + return "" +} + +func (m *ExternalIncentive) GetPoolId() uint64 { + if m != nil { + return m.PoolId + } + return 0 +} + +func (m *ExternalIncentive) GetFromBlock() uint64 { + if m != nil { + return m.FromBlock + } + return 0 +} + +func (m *ExternalIncentive) GetToBlock() uint64 { + if m != nil { + return m.ToBlock + } + return 0 +} + +func init() { + proto.RegisterType((*ExternalIncentive)(nil), "elys.masterchef.ExternalIncentive") +} + +func init() { + proto.RegisterFile("elys/masterchef/external_incentive.proto", fileDescriptor_3d270e9faef9dc8d) +} + +var fileDescriptor_3d270e9faef9dc8d = []byte{ + // 318 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x90, 0xc1, 0x4e, 0xea, 0x40, + 0x14, 0x86, 0x3b, 0x5c, 0x2e, 0xc8, 0x68, 0x50, 0x1b, 0x13, 0xab, 0x89, 0x05, 0x5d, 0x18, 0x36, + 0x74, 0x16, 0xbe, 0x01, 0xd1, 0x45, 0x77, 0x86, 0x95, 0x71, 0xd3, 0x94, 0xce, 0x01, 0x1a, 0xda, + 0x39, 0xcd, 0xcc, 0x20, 0xf0, 0x16, 0x3e, 0x16, 0x4b, 0x96, 0xc6, 0x05, 0x31, 0xf0, 0x08, 0xbe, + 0x80, 0x99, 0x69, 0x8d, 0xac, 0x66, 0xce, 0xff, 0xfd, 0xf3, 0x4d, 0x72, 0x68, 0x0f, 0xb2, 0x95, + 0x62, 0x79, 0xac, 0x34, 0xc8, 0x64, 0x0a, 0x63, 0x06, 0x4b, 0x0d, 0x52, 0xc4, 0x59, 0x94, 0x8a, + 0x04, 0x84, 0x4e, 0xdf, 0x20, 0x28, 0x24, 0x6a, 0x74, 0x4f, 0x4d, 0x33, 0xf8, 0x6b, 0x5e, 0x5f, + 0x4c, 0x70, 0x82, 0x96, 0x31, 0x73, 0x2b, 0x6b, 0x77, 0xdf, 0x84, 0x9e, 0x3f, 0x55, 0x8e, 0xf0, + 0x57, 0xe1, 0xb6, 0x69, 0x2d, 0xe5, 0x1e, 0xe9, 0x92, 0x5e, 0x7d, 0x58, 0x4b, 0xb9, 0x7b, 0x4b, + 0x4f, 0x24, 0x2c, 0x62, 0xc9, 0x23, 0x0e, 0x02, 0x73, 0xaf, 0xd6, 0x25, 0xbd, 0xd6, 0xf0, 0xb8, + 0xcc, 0x1e, 0x4d, 0xe4, 0x5e, 0xd2, 0x66, 0x81, 0x98, 0x45, 0x29, 0xf7, 0xfe, 0xd9, 0x77, 0x0d, + 0x33, 0x86, 0xdc, 0xbd, 0xa1, 0x74, 0x2c, 0x31, 0x8f, 0x46, 0x19, 0x26, 0x33, 0xaf, 0x6e, 0x59, + 0xcb, 0x24, 0x03, 0x13, 0xb8, 0x57, 0xf4, 0x48, 0x63, 0x05, 0xff, 0x5b, 0xd8, 0xd4, 0x58, 0xa2, + 0x17, 0x7a, 0x16, 0xe7, 0x38, 0x17, 0x3a, 0x2a, 0x40, 0x56, 0x95, 0x86, 0xf9, 0x79, 0x10, 0xac, + 0xb7, 0x1d, 0xe7, 0x73, 0xdb, 0xb9, 0x9f, 0xa4, 0x7a, 0x3a, 0x1f, 0x05, 0x09, 0xe6, 0x2c, 0x41, + 0x95, 0xa3, 0xaa, 0x8e, 0xbe, 0xe2, 0x33, 0xa6, 0x57, 0x05, 0xa8, 0x20, 0x14, 0x7a, 0xd8, 0x2e, + 0x3d, 0xcf, 0x20, 0xad, 0x79, 0x10, 0xae, 0x77, 0x3e, 0xd9, 0xec, 0x7c, 0xf2, 0xb5, 0xf3, 0xc9, + 0xfb, 0xde, 0x77, 0x36, 0x7b, 0xdf, 0xf9, 0xd8, 0xfb, 0xce, 0x2b, 0x3b, 0x30, 0x9a, 0x0d, 0xf6, + 0x05, 0xe8, 0x05, 0xca, 0x99, 0x1d, 0xd8, 0xf2, 0x70, 0xf5, 0x56, 0x3f, 0x6a, 0xd8, 0x3d, 0x3e, + 0xfc, 0x04, 0x00, 0x00, 0xff, 0xff, 0xd9, 0xf4, 0xab, 0xe0, 0x9a, 0x01, 0x00, 0x00, +} + +func (m *ExternalIncentive) 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 *ExternalIncentive) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ExternalIncentive) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.AmountPerBlock.Size() + i -= size + if _, err := m.AmountPerBlock.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintExternalIncentive(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + if m.ToBlock != 0 { + i = encodeVarintExternalIncentive(dAtA, i, uint64(m.ToBlock)) + i-- + dAtA[i] = 0x28 + } + if m.FromBlock != 0 { + i = encodeVarintExternalIncentive(dAtA, i, uint64(m.FromBlock)) + i-- + dAtA[i] = 0x20 + } + if m.PoolId != 0 { + i = encodeVarintExternalIncentive(dAtA, i, uint64(m.PoolId)) + i-- + dAtA[i] = 0x18 + } + if len(m.RewardDenom) > 0 { + i -= len(m.RewardDenom) + copy(dAtA[i:], m.RewardDenom) + i = encodeVarintExternalIncentive(dAtA, i, uint64(len(m.RewardDenom))) + i-- + dAtA[i] = 0x12 + } + if m.Id != 0 { + i = encodeVarintExternalIncentive(dAtA, i, uint64(m.Id)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintExternalIncentive(dAtA []byte, offset int, v uint64) int { + offset -= sovExternalIncentive(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *ExternalIncentive) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Id != 0 { + n += 1 + sovExternalIncentive(uint64(m.Id)) + } + l = len(m.RewardDenom) + if l > 0 { + n += 1 + l + sovExternalIncentive(uint64(l)) + } + if m.PoolId != 0 { + n += 1 + sovExternalIncentive(uint64(m.PoolId)) + } + if m.FromBlock != 0 { + n += 1 + sovExternalIncentive(uint64(m.FromBlock)) + } + if m.ToBlock != 0 { + n += 1 + sovExternalIncentive(uint64(m.ToBlock)) + } + l = m.AmountPerBlock.Size() + n += 1 + l + sovExternalIncentive(uint64(l)) + return n +} + +func sovExternalIncentive(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozExternalIncentive(x uint64) (n int) { + return sovExternalIncentive(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *ExternalIncentive) 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 ErrIntOverflowExternalIncentive + } + 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: ExternalIncentive: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ExternalIncentive: 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 ErrIntOverflowExternalIncentive + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Id |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RewardDenom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowExternalIncentive + } + 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 ErrInvalidLengthExternalIncentive + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthExternalIncentive + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RewardDenom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + 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 ErrIntOverflowExternalIncentive + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PoolId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field FromBlock", wireType) + } + m.FromBlock = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowExternalIncentive + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.FromBlock |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ToBlock", wireType) + } + m.ToBlock = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowExternalIncentive + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ToBlock |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AmountPerBlock", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowExternalIncentive + } + 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 ErrInvalidLengthExternalIncentive + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthExternalIncentive + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.AmountPerBlock.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipExternalIncentive(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthExternalIncentive + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipExternalIncentive(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, ErrIntOverflowExternalIncentive + } + 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, ErrIntOverflowExternalIncentive + } + 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, ErrIntOverflowExternalIncentive + } + 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, ErrInvalidLengthExternalIncentive + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupExternalIncentive + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthExternalIncentive + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthExternalIncentive = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowExternalIncentive = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupExternalIncentive = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/masterchef/types/genesis.go b/x/masterchef/types/genesis.go new file mode 100644 index 000000000..0af9b4416 --- /dev/null +++ b/x/masterchef/types/genesis.go @@ -0,0 +1,24 @@ +package types + +import ( +// this line is used by starport scaffolding # genesis/types/import +) + +// DefaultIndex is the default global index +const DefaultIndex uint64 = 1 + +// DefaultGenesis returns the default genesis state +func DefaultGenesis() *GenesisState { + return &GenesisState{ + // this line is used by starport scaffolding # genesis/types/default + Params: DefaultParams(), + } +} + +// Validate performs basic genesis state validation returning an error upon any +// failure. +func (gs GenesisState) Validate() error { + // this line is used by starport scaffolding # genesis/types/validate + + return gs.Params.Validate() +} diff --git a/x/masterchef/types/genesis.pb.go b/x/masterchef/types/genesis.pb.go new file mode 100644 index 000000000..85f9be374 --- /dev/null +++ b/x/masterchef/types/genesis.pb.go @@ -0,0 +1,577 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: elys/masterchef/genesis.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + 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 masterchef module's genesis state. +type GenesisState struct { + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` + ExternalIncentives []ExternalIncentive `protobuf:"bytes,2,rep,name=external_incentives,json=externalIncentives,proto3" json:"external_incentives"` + PoolInfos []PoolInfo `protobuf:"bytes,3,rep,name=pool_infos,json=poolInfos,proto3" json:"pool_infos"` + PoolRewardInfos []PoolRewardInfo `protobuf:"bytes,4,rep,name=pool_reward_infos,json=poolRewardInfos,proto3" json:"pool_reward_infos"` + UserRewardInfos []UserRewardInfo `protobuf:"bytes,5,rep,name=user_reward_infos,json=userRewardInfos,proto3" json:"user_reward_infos"` +} + +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_b55d8c0403fbd8da, []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 + +func (m *GenesisState) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +func (m *GenesisState) GetExternalIncentives() []ExternalIncentive { + if m != nil { + return m.ExternalIncentives + } + return nil +} + +func (m *GenesisState) GetPoolInfos() []PoolInfo { + if m != nil { + return m.PoolInfos + } + return nil +} + +func (m *GenesisState) GetPoolRewardInfos() []PoolRewardInfo { + if m != nil { + return m.PoolRewardInfos + } + return nil +} + +func (m *GenesisState) GetUserRewardInfos() []UserRewardInfo { + if m != nil { + return m.UserRewardInfos + } + return nil +} + +func init() { + proto.RegisterType((*GenesisState)(nil), "elys.masterchef.GenesisState") +} + +func init() { proto.RegisterFile("elys/masterchef/genesis.proto", fileDescriptor_b55d8c0403fbd8da) } + +var fileDescriptor_b55d8c0403fbd8da = []byte{ + // 336 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0xd1, 0x31, 0x4f, 0xc2, 0x40, + 0x14, 0x07, 0xf0, 0x56, 0x90, 0xc4, 0xc3, 0x84, 0x58, 0x4d, 0xc4, 0x46, 0x0b, 0x61, 0x62, 0xb1, + 0x4d, 0x30, 0xae, 0x0e, 0x24, 0xc6, 0xb0, 0x29, 0xc6, 0x41, 0x17, 0x52, 0xf0, 0x51, 0x1a, 0xcb, + 0xbd, 0xe6, 0xde, 0x21, 0xf0, 0x05, 0x9c, 0xfd, 0x58, 0x8c, 0x8c, 0x4e, 0xc6, 0xc0, 0x17, 0x31, + 0xbd, 0x9e, 0x11, 0x5a, 0xdd, 0x7a, 0xf7, 0xff, 0xf7, 0x77, 0x2f, 0x79, 0xec, 0x0c, 0xa2, 0x39, + 0x79, 0x63, 0x9f, 0x24, 0x88, 0xc1, 0x08, 0x86, 0x5e, 0x00, 0x1c, 0x28, 0x24, 0x37, 0x16, 0x28, + 0xd1, 0xaa, 0x24, 0xb1, 0xfb, 0x1b, 0xdb, 0x47, 0x01, 0x06, 0xa8, 0x32, 0x2f, 0xf9, 0x4a, 0x6b, + 0xf6, 0x69, 0x56, 0x89, 0x7d, 0xe1, 0x8f, 0x35, 0x62, 0x37, 0xb3, 0x29, 0xcc, 0x24, 0x08, 0xee, + 0x47, 0xbd, 0x90, 0x0f, 0x80, 0xcb, 0xf0, 0x15, 0x74, 0xd3, 0xce, 0x39, 0x88, 0x51, 0x9a, 0x35, + 0xde, 0x0a, 0x6c, 0xff, 0x26, 0x1d, 0xee, 0x5e, 0xfa, 0x12, 0xac, 0x4b, 0x56, 0x4a, 0x9f, 0xa9, + 0x9a, 0x75, 0xb3, 0x59, 0x6e, 0x1d, 0xbb, 0x99, 0x61, 0xdd, 0x5b, 0x15, 0xb7, 0x8b, 0x8b, 0xcf, + 0x9a, 0xd1, 0xd5, 0x65, 0xeb, 0x91, 0x1d, 0xe6, 0xdf, 0xa7, 0xea, 0x4e, 0xbd, 0xd0, 0x2c, 0xb7, + 0x1a, 0x39, 0xe3, 0x5a, 0x77, 0x3b, 0x3f, 0x55, 0xcd, 0x59, 0x90, 0x0d, 0xc8, 0xba, 0x62, 0x2c, + 0x19, 0xb8, 0x17, 0xf2, 0x21, 0x52, 0xb5, 0xa0, 0xc4, 0x93, 0xfc, 0x54, 0x88, 0x51, 0x87, 0x0f, + 0x51, 0x43, 0x7b, 0xb1, 0x3e, 0x93, 0x75, 0xc7, 0x0e, 0xd4, 0xff, 0x02, 0xa6, 0xbe, 0x78, 0xd6, + 0x4c, 0x51, 0x31, 0xb5, 0x3f, 0x99, 0xae, 0x2a, 0x6e, 0x60, 0x95, 0x78, 0xeb, 0x56, 0x91, 0x13, + 0x02, 0xb1, 0x4d, 0xee, 0xfe, 0x43, 0x3e, 0x10, 0x88, 0x3c, 0x39, 0xd9, 0xba, 0xa5, 0x76, 0x67, + 0xb1, 0x72, 0xcc, 0xe5, 0xca, 0x31, 0xbf, 0x56, 0x8e, 0xf9, 0xbe, 0x76, 0x8c, 0xe5, 0xda, 0x31, + 0x3e, 0xd6, 0x8e, 0xf1, 0xe4, 0x05, 0xa1, 0x1c, 0x4d, 0xfa, 0xee, 0x00, 0xc7, 0x5e, 0x62, 0x9f, + 0x73, 0x90, 0x53, 0x14, 0x2f, 0xea, 0xe0, 0xcd, 0x36, 0x17, 0x2b, 0xe7, 0x31, 0x50, 0xbf, 0xa4, + 0x56, 0x7b, 0xf1, 0x1d, 0x00, 0x00, 0xff, 0xff, 0xc3, 0x17, 0x5f, 0x62, 0x86, 0x02, 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.UserRewardInfos) > 0 { + for iNdEx := len(m.UserRewardInfos) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.UserRewardInfos[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.PoolRewardInfos) > 0 { + for iNdEx := len(m.PoolRewardInfos) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.PoolRewardInfos[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.PoolInfos) > 0 { + for iNdEx := len(m.PoolInfos) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.PoolInfos[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.ExternalIncentives) > 0 { + for iNdEx := len(m.ExternalIncentives) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.ExternalIncentives[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 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.ExternalIncentives) > 0 { + for _, e := range m.ExternalIncentives { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.PoolInfos) > 0 { + for _, e := range m.PoolInfos { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.PoolRewardInfos) > 0 { + for _, e := range m.PoolRewardInfos { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.UserRewardInfos) > 0 { + for _, e := range m.UserRewardInfos { + l = e.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 ExternalIncentives", 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.ExternalIncentives = append(m.ExternalIncentives, ExternalIncentive{}) + if err := m.ExternalIncentives[len(m.ExternalIncentives)-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 PoolInfos", 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.PoolInfos = append(m.PoolInfos, PoolInfo{}) + if err := m.PoolInfos[len(m.PoolInfos)-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 PoolRewardInfos", 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.PoolRewardInfos = append(m.PoolRewardInfos, PoolRewardInfo{}) + if err := m.PoolRewardInfos[len(m.PoolRewardInfos)-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 UserRewardInfos", 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.UserRewardInfos = append(m.UserRewardInfos, UserRewardInfo{}) + if err := m.UserRewardInfos[len(m.UserRewardInfos)-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 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/masterchef/types/genesis_test.go b/x/masterchef/types/genesis_test.go new file mode 100644 index 000000000..9bcdacbcd --- /dev/null +++ b/x/masterchef/types/genesis_test.go @@ -0,0 +1,33 @@ +package types_test + +import ( + "testing" + + "github.com/elys-network/elys/x/masterchef/types" + "github.com/stretchr/testify/require" +) + +func TestGenesisState_Validate(t *testing.T) { + tests := []struct { + desc string + genState *types.GenesisState + valid bool + }{ + { + desc: "default is valid", + genState: types.DefaultGenesis(), + valid: true, + }, + // this line is used by starport scaffolding # types/genesis/testcase + } + for _, tc := range tests { + t.Run(tc.desc, func(t *testing.T) { + err := tc.genState.Validate() + if tc.valid { + require.NoError(t, err) + } else { + require.Error(t, err) + } + }) + } +} diff --git a/x/masterchef/types/incentive.pb.go b/x/masterchef/types/incentive.pb.go new file mode 100644 index 000000000..96e6af9f3 --- /dev/null +++ b/x/masterchef/types/incentive.pb.go @@ -0,0 +1,470 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: elys/masterchef/incentive.proto + +package types + +import ( + fmt "fmt" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/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 + +// Incentive Info +type IncentiveInfo struct { + // reward amount in eden for 1 year + EdenAmountPerYear github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=eden_amount_per_year,json=edenAmountPerYear,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"eden_amount_per_year"` + // starting block height of the distribution + DistributionStartBlock github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=distribution_start_block,json=distributionStartBlock,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"distribution_start_block"` + // distribution duration - block number per year + TotalBlocksPerYear github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=total_blocks_per_year,json=totalBlocksPerYear,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"total_blocks_per_year"` + // blocks distributed + BlocksDistributed github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,4,opt,name=blocks_distributed,json=blocksDistributed,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"blocks_distributed"` +} + +func (m *IncentiveInfo) Reset() { *m = IncentiveInfo{} } +func (m *IncentiveInfo) String() string { return proto.CompactTextString(m) } +func (*IncentiveInfo) ProtoMessage() {} +func (*IncentiveInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_fbfbd92cca5ccf94, []int{0} +} +func (m *IncentiveInfo) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *IncentiveInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_IncentiveInfo.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 *IncentiveInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_IncentiveInfo.Merge(m, src) +} +func (m *IncentiveInfo) XXX_Size() int { + return m.Size() +} +func (m *IncentiveInfo) XXX_DiscardUnknown() { + xxx_messageInfo_IncentiveInfo.DiscardUnknown(m) +} + +var xxx_messageInfo_IncentiveInfo proto.InternalMessageInfo + +func init() { + proto.RegisterType((*IncentiveInfo)(nil), "elys.masterchef.IncentiveInfo") +} + +func init() { proto.RegisterFile("elys/masterchef/incentive.proto", fileDescriptor_fbfbd92cca5ccf94) } + +var fileDescriptor_fbfbd92cca5ccf94 = []byte{ + // 330 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0xd2, 0xc1, 0x4a, 0xc3, 0x40, + 0x10, 0x06, 0xe0, 0xc4, 0x8a, 0x60, 0x40, 0xc4, 0x50, 0x25, 0xf4, 0x90, 0x88, 0x07, 0xf1, 0xd2, + 0xec, 0xc1, 0x27, 0xb0, 0x78, 0xc9, 0x4d, 0xf4, 0xa4, 0x20, 0x61, 0x93, 0x4c, 0xd3, 0xa5, 0xc9, + 0x4e, 0xd8, 0x9d, 0xa8, 0x7d, 0x0b, 0x1f, 0xc0, 0x07, 0xea, 0xb1, 0x47, 0xf1, 0x50, 0xa4, 0x7d, + 0x11, 0xc9, 0xa6, 0xb5, 0x3d, 0xe7, 0x94, 0x0c, 0xf9, 0xf9, 0x26, 0xb3, 0x3b, 0x4e, 0x00, 0xc5, + 0x4c, 0xb3, 0x92, 0x6b, 0x02, 0x95, 0x4e, 0x60, 0xcc, 0x84, 0x4c, 0x41, 0x92, 0x78, 0x83, 0xb0, + 0x52, 0x48, 0xe8, 0x9e, 0x36, 0x81, 0x70, 0x17, 0x18, 0xf4, 0x73, 0xcc, 0xd1, 0x7c, 0x63, 0xcd, + 0x5b, 0x1b, 0x1b, 0x04, 0x39, 0x62, 0x5e, 0x00, 0x33, 0x55, 0x52, 0x8f, 0x19, 0x89, 0x12, 0x34, + 0xf1, 0xb2, 0x6a, 0x03, 0x57, 0x5f, 0x3d, 0xe7, 0x24, 0xda, 0xda, 0x91, 0x1c, 0xa3, 0x1b, 0x3b, + 0x7d, 0xc8, 0x40, 0xc6, 0xbc, 0xc4, 0x5a, 0x52, 0x5c, 0x81, 0x8a, 0x67, 0xc0, 0x95, 0x67, 0x5f, + 0xda, 0x37, 0xc7, 0xa3, 0x70, 0xbe, 0x0c, 0xac, 0x9f, 0x65, 0x70, 0x9d, 0x0b, 0x9a, 0xd4, 0x49, + 0x98, 0x62, 0xc9, 0x52, 0xd4, 0x25, 0xea, 0xcd, 0x63, 0xa8, 0xb3, 0x29, 0xa3, 0x59, 0x05, 0x3a, + 0x8c, 0x24, 0x3d, 0x9e, 0x35, 0xd6, 0x9d, 0xa1, 0x1e, 0x40, 0x3d, 0x03, 0x57, 0xee, 0xc4, 0xf1, + 0x32, 0xa1, 0x49, 0x89, 0xa4, 0x26, 0x81, 0x32, 0xd6, 0xc4, 0x15, 0xc5, 0x49, 0x81, 0xe9, 0xd4, + 0x3b, 0xe8, 0xd4, 0xe4, 0x62, 0xdf, 0x7b, 0x6a, 0xb8, 0x51, 0xa3, 0xb9, 0xdc, 0x39, 0x27, 0x24, + 0x5e, 0xb4, 0xb8, 0xde, 0xcd, 0xd2, 0xeb, 0xd4, 0xc6, 0x35, 0x98, 0xa1, 0xf5, 0x76, 0x98, 0x57, + 0xc7, 0xdd, 0xe0, 0xff, 0xff, 0x00, 0x99, 0x77, 0xd8, 0xed, 0xac, 0x5a, 0xe9, 0x7e, 0x07, 0x8d, + 0xa2, 0xf9, 0xca, 0xb7, 0x17, 0x2b, 0xdf, 0xfe, 0x5d, 0xf9, 0xf6, 0xe7, 0xda, 0xb7, 0x16, 0x6b, + 0xdf, 0xfa, 0x5e, 0xfb, 0xd6, 0x0b, 0xdb, 0x43, 0x9b, 0x5d, 0x18, 0x4a, 0xa0, 0x77, 0x54, 0x53, + 0x53, 0xb0, 0x8f, 0xfd, 0xdd, 0x31, 0x1d, 0x92, 0x23, 0x73, 0xe1, 0xb7, 0x7f, 0x01, 0x00, 0x00, + 0xff, 0xff, 0xf4, 0x19, 0xf8, 0xca, 0x5b, 0x02, 0x00, 0x00, +} + +func (m *IncentiveInfo) 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 *IncentiveInfo) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *IncentiveInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.BlocksDistributed.Size() + i -= size + if _, err := m.BlocksDistributed.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintIncentive(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + { + size := m.TotalBlocksPerYear.Size() + i -= size + if _, err := m.TotalBlocksPerYear.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintIncentive(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + { + size := m.DistributionStartBlock.Size() + i -= size + if _, err := m.DistributionStartBlock.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintIncentive(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + { + size := m.EdenAmountPerYear.Size() + i -= size + if _, err := m.EdenAmountPerYear.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintIncentive(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func encodeVarintIncentive(dAtA []byte, offset int, v uint64) int { + offset -= sovIncentive(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *IncentiveInfo) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.EdenAmountPerYear.Size() + n += 1 + l + sovIncentive(uint64(l)) + l = m.DistributionStartBlock.Size() + n += 1 + l + sovIncentive(uint64(l)) + l = m.TotalBlocksPerYear.Size() + n += 1 + l + sovIncentive(uint64(l)) + l = m.BlocksDistributed.Size() + n += 1 + l + sovIncentive(uint64(l)) + return n +} + +func sovIncentive(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozIncentive(x uint64) (n int) { + return sovIncentive(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *IncentiveInfo) 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 ErrIntOverflowIncentive + } + 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: IncentiveInfo: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: IncentiveInfo: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EdenAmountPerYear", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowIncentive + } + 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 ErrInvalidLengthIncentive + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthIncentive + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.EdenAmountPerYear.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DistributionStartBlock", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowIncentive + } + 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 ErrInvalidLengthIncentive + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthIncentive + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.DistributionStartBlock.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TotalBlocksPerYear", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowIncentive + } + 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 ErrInvalidLengthIncentive + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthIncentive + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.TotalBlocksPerYear.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BlocksDistributed", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowIncentive + } + 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 ErrInvalidLengthIncentive + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthIncentive + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.BlocksDistributed.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipIncentive(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthIncentive + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipIncentive(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, ErrIntOverflowIncentive + } + 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, ErrIntOverflowIncentive + } + 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, ErrIntOverflowIncentive + } + 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, ErrInvalidLengthIncentive + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupIncentive + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthIncentive + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthIncentive = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowIncentive = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupIncentive = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/masterchef/types/keys.go b/x/masterchef/types/keys.go new file mode 100644 index 000000000..f1e7062ca --- /dev/null +++ b/x/masterchef/types/keys.go @@ -0,0 +1,92 @@ +package types + +import ( + "encoding/binary" +) + +const ( + // ModuleName defines the module name + ModuleName = "masterchef" + + // StoreKey defines the primary module store key + StoreKey = ModuleName + + // RouterKey defines the module's message routing key + RouterKey = ModuleName + + // MemStoreKey defines the in-memory store key + MemStoreKey = "mem_masterchef" + + ParamsKey = "ParamsKey" + + PoolInfoKeyPrefix = "PoolInfo" + + ExternalIncentiveIndexKeyPrefix = "IndexExternalIncentive" + + ExternalIncentiveKeyPrefix = "ExternalIncentive" + + PoolRewardInfoKeyPrefix = "PoolRewardInfo" + + UserRewardInfoKeyPrefix = "UserRewardInfo" +) + +func KeyPrefix(p string) []byte { + return []byte(p) +} + +func PoolInfoKey(poolId uint64) []byte { + var key []byte + + poolIdBytes := make([]byte, 8) + binary.BigEndian.PutUint64(poolIdBytes, poolId) + key = append(key, poolIdBytes...) + key = append(key, []byte("/")...) + + return key +} + +func ExternalIncentiveKey(incentiveId uint64) []byte { + var key []byte + + incentiveIdBytes := make([]byte, 8) + binary.BigEndian.PutUint64(incentiveIdBytes, incentiveId) + key = append(key, incentiveIdBytes...) + key = append(key, []byte("/")...) + + return key +} + +func ExternalIncentiveIndex() []byte { + var key []byte + + key = append(key, ExternalIncentiveIndexKeyPrefix...) + return key +} + +func PoolRewardInfoKey(poolId uint64, rewardDenom string) []byte { + var key []byte + + poolIdBytes := make([]byte, 8) + binary.BigEndian.PutUint64(poolIdBytes, poolId) + key = append(key, poolIdBytes...) + key = append(key, []byte("/")...) + key = append(key, rewardDenom...) + key = append(key, []byte("/")...) + + return key +} + +func UserRewardInfoKey(user string, poolId uint64, rewardDenom string) []byte { + var key []byte + + key = append(key, user...) + key = append(key, []byte("/")...) + poolIdBytes := make([]byte, 8) + binary.BigEndian.PutUint64(poolIdBytes, poolId) + key = append(key, poolIdBytes...) + key = append(key, []byte("/")...) + key = append(key, rewardDenom...) + key = append(key, []byte("/")...) + + return key +} diff --git a/x/masterchef/types/message_add_external_incentive.go b/x/masterchef/types/message_add_external_incentive.go new file mode 100644 index 000000000..4682e9966 --- /dev/null +++ b/x/masterchef/types/message_add_external_incentive.go @@ -0,0 +1,41 @@ +package types + +import ( + errorsmod "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +const TypeMsgAddExternalIncentive = "add_external_incentive" + +var _ sdk.Msg = &MsgAddExternalIncentive{} + +func (msg *MsgAddExternalIncentive) Route() string { + return RouterKey +} + +func (msg *MsgAddExternalIncentive) Type() string { + return TypeMsgAddExternalIncentive +} + +func (msg *MsgAddExternalIncentive) GetSigners() []sdk.AccAddress { + sender, err := sdk.AccAddressFromBech32(msg.Sender) + if err != nil { + panic(err) + } + return []sdk.AccAddress{sender} +} + +func (msg *MsgAddExternalIncentive) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +func (msg *MsgAddExternalIncentive) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.Sender) + if err != nil { + return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid sender address (%s)", err) + } + + return nil +} diff --git a/x/masterchef/types/message_add_external_reward_denom.go b/x/masterchef/types/message_add_external_reward_denom.go new file mode 100644 index 000000000..19713adeb --- /dev/null +++ b/x/masterchef/types/message_add_external_reward_denom.go @@ -0,0 +1,41 @@ +package types + +import ( + errorsmod "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +const TypeMsgAddExternalRewardDenom = "add_external_reward_denom" + +var _ sdk.Msg = &MsgAddExternalRewardDenom{} + +func (msg *MsgAddExternalRewardDenom) Route() string { + return RouterKey +} + +func (msg *MsgAddExternalRewardDenom) Type() string { + return TypeMsgAddExternalRewardDenom +} + +func (msg *MsgAddExternalRewardDenom) GetSigners() []sdk.AccAddress { + sender, err := sdk.AccAddressFromBech32(msg.Authority) + if err != nil { + panic(err) + } + return []sdk.AccAddress{sender} +} + +func (msg *MsgAddExternalRewardDenom) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +func (msg *MsgAddExternalRewardDenom) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.Authority) + if err != nil { + return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid sender address (%s)", err) + } + + return nil +} diff --git a/x/masterchef/types/message_claim_rewards.go b/x/masterchef/types/message_claim_rewards.go new file mode 100644 index 000000000..c05e057c3 --- /dev/null +++ b/x/masterchef/types/message_claim_rewards.go @@ -0,0 +1,41 @@ +package types + +import ( + errorsmod "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +const TypeMsgClaimRewards = "claim_rewards" + +var _ sdk.Msg = &MsgClaimRewards{} + +func (msg *MsgClaimRewards) Route() string { + return RouterKey +} + +func (msg *MsgClaimRewards) Type() string { + return TypeMsgClaimRewards +} + +func (msg *MsgClaimRewards) GetSigners() []sdk.AccAddress { + sender, err := sdk.AccAddressFromBech32(msg.Sender) + if err != nil { + panic(err) + } + return []sdk.AccAddress{sender} +} + +func (msg *MsgClaimRewards) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +func (msg *MsgClaimRewards) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.Sender) + if err != nil { + return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid sender address (%s)", err) + } + + return nil +} diff --git a/x/masterchef/types/message_update_incentive_params.go b/x/masterchef/types/message_update_incentive_params.go new file mode 100644 index 000000000..150b77ace --- /dev/null +++ b/x/masterchef/types/message_update_incentive_params.go @@ -0,0 +1,41 @@ +package types + +import ( + errorsmod "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +const TypeMsgUpdateParams = "update_incentive_params" + +var _ sdk.Msg = &MsgUpdateParams{} + +func (msg *MsgUpdateParams) Route() string { + return RouterKey +} + +func (msg *MsgUpdateParams) Type() string { + return TypeMsgUpdateParams +} + +func (msg *MsgUpdateParams) GetSigners() []sdk.AccAddress { + sender, err := sdk.AccAddressFromBech32(msg.Authority) + if err != nil { + panic(err) + } + return []sdk.AccAddress{sender} +} + +func (msg *MsgUpdateParams) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +func (msg *MsgUpdateParams) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.Authority) + if err != nil { + return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid sender address (%s)", err) + } + + return nil +} diff --git a/x/incentive/types/message_update_pool_multipliers.go b/x/masterchef/types/message_update_pool_multipliers.go similarity index 59% rename from x/incentive/types/message_update_pool_multipliers.go rename to x/masterchef/types/message_update_pool_multipliers.go index 1904da705..476c8c862 100644 --- a/x/incentive/types/message_update_pool_multipliers.go +++ b/x/masterchef/types/message_update_pool_multipliers.go @@ -10,13 +10,6 @@ const TypeMsgUpdatePoolMultipliers = "update_pool_multipliers" var _ sdk.Msg = &MsgUpdatePoolMultipliers{} -func NewMsgUpdatePoolMultipliers(creator string, multipliers []PoolMultiplier) *MsgUpdatePoolMultipliers { - return &MsgUpdatePoolMultipliers{ - Authority: creator, - PoolMultipliers: multipliers, - } -} - func (msg *MsgUpdatePoolMultipliers) Route() string { return RouterKey } @@ -26,11 +19,11 @@ func (msg *MsgUpdatePoolMultipliers) Type() string { } func (msg *MsgUpdatePoolMultipliers) GetSigners() []sdk.AccAddress { - creator, err := sdk.AccAddressFromBech32(msg.Authority) + sender, err := sdk.AccAddressFromBech32(msg.Authority) if err != nil { panic(err) } - return []sdk.AccAddress{creator} + return []sdk.AccAddress{sender} } func (msg *MsgUpdatePoolMultipliers) GetSignBytes() []byte { @@ -41,10 +34,8 @@ func (msg *MsgUpdatePoolMultipliers) GetSignBytes() []byte { func (msg *MsgUpdatePoolMultipliers) ValidateBasic() error { _, err := sdk.AccAddressFromBech32(msg.Authority) if err != nil { - return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) - } - if len(msg.PoolMultipliers) == 0 { - return errorsmod.Wrapf(sdkerrors.ErrNotSupported, "invalid number of pool multipliers (%d)", len(msg.PoolMultipliers)) + return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid sender address (%s)", err) } + return nil } diff --git a/x/masterchef/types/params.go b/x/masterchef/types/params.go new file mode 100644 index 000000000..18bab01e3 --- /dev/null +++ b/x/masterchef/types/params.go @@ -0,0 +1,122 @@ +package types + +import ( + fmt "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" + "gopkg.in/yaml.v2" +) + +// NewParams creates a new Params instance +func NewParams( + lpIncentives *IncentiveInfo, + rewardPortionForLps sdk.Dec, + rewardPortionForStakers sdk.Dec, + dexRewardsLps DexRewardsTracker, + maxEdenRewardAprLps sdk.Dec, + protocolRevenueAddress string, +) Params { + return Params{ + LpIncentives: lpIncentives, + RewardPortionForLps: rewardPortionForLps, + RewardPortionForStakers: rewardPortionForStakers, + DexRewardsLps: dexRewardsLps, + MaxEdenRewardAprLps: maxEdenRewardAprLps, + SupportedRewardDenoms: nil, + ProtocolRevenueAddress: protocolRevenueAddress, + } +} + +// DefaultParams returns a default set of parameters +func DefaultParams() Params { + return NewParams( + nil, + sdk.NewDecWithPrec(60, 2), + sdk.NewDecWithPrec(25, 2), + DexRewardsTracker{ + NumBlocks: sdk.NewInt(1), + Amount: sdk.ZeroDec(), + }, + sdk.NewDecWithPrec(5, 1), + "elys10d07y265gmmuvt4z0w9aw880jnsr700j6z2zm3", + ) +} + +// Validate validates the set of params +func (p Params) Validate() error { + if err := validateRewardPortionForLps(p.RewardPortionForLps); err != nil { + return err + } + + if err := validateLPIncentives(p.LpIncentives); err != nil { + return err + } + + if err := validateDexRewardsLps(p.DexRewardsLps); err != nil { + return err + } + + return nil +} + +// String implements the Stringer interface. +func (p Params) String() string { + out, _ := yaml.Marshal(p) + return string(out) +} + +func validateRewardPortionForLps(i interface{}) error { + v, ok := i.(sdk.Dec) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + if v.IsNil() { + return fmt.Errorf("reward percent for lp must be not nil") + } + if v.IsNegative() { + return fmt.Errorf("reward percent for lp must be positive: %s", v) + } + if v.GT(sdk.OneDec()) { + return fmt.Errorf("reward percent for lp too large: %s", v) + } + + return nil +} + +func validateLPIncentives(i interface{}) error { + vv, ok := i.(*IncentiveInfo) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + if vv == nil { + return nil + } + + if vv.EdenAmountPerYear.LTE(sdk.ZeroInt()) { + return fmt.Errorf("invalid eden amount per year: %v", vv) + } + + if vv.TotalBlocksPerYear.LT(sdk.NewInt(1)) { + return fmt.Errorf("invalid total blocks per year: %v", vv) + } + + if vv.BlocksDistributed.LT(sdk.NewInt(0)) { + return fmt.Errorf("invalid BlocksDistributed: %v", vv) + } + + if vv.DistributionStartBlock.LT(sdk.NewInt(0)) { + return fmt.Errorf("invalid DistributionStartBlock: %v", vv) + } + + return nil +} + +func validateDexRewardsLps(i interface{}) error { + _, ok := i.(DexRewardsTracker) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + return nil +} diff --git a/x/masterchef/types/params.pb.go b/x/masterchef/types/params.pb.go new file mode 100644 index 000000000..50df4601e --- /dev/null +++ b/x/masterchef/types/params.pb.go @@ -0,0 +1,875 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: elys/masterchef/params.proto + +package types + +import ( + fmt "fmt" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + 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 + +// Params defines the parameters for the module. +type Params struct { + LpIncentives *IncentiveInfo `protobuf:"bytes,1,opt,name=lp_incentives,json=lpIncentives,proto3" json:"lp_incentives,omitempty"` + // gas fees and swap fees portion for lps, `100 - reward_portion_for_lps - reward_portion_for_stakers = revenue percent for protocol`. + RewardPortionForLps github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=reward_portion_for_lps,json=rewardPortionForLps,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"reward_portion_for_lps"` + // gas fees and swap fees portion for stakers, `100 - reward_portion_for_lps - reward_portion_for_stakers = revenue percent for protocol`. + RewardPortionForStakers github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=reward_portion_for_stakers,json=rewardPortionForStakers,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"reward_portion_for_stakers"` + // Tracking dex rewards given to LPs + DexRewardsLps DexRewardsTracker `protobuf:"bytes,4,opt,name=dex_rewards_lps,json=dexRewardsLps,proto3" json:"dex_rewards_lps"` + // Maximum eden reward apr for lps - [0 - 0.3] + MaxEdenRewardAprLps github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,5,opt,name=max_eden_reward_apr_lps,json=maxEdenRewardAprLps,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"max_eden_reward_apr_lps"` + SupportedRewardDenoms []*SupportedRewardDenom `protobuf:"bytes,6,rep,name=supported_reward_denoms,json=supportedRewardDenoms,proto3" json:"supported_reward_denoms,omitempty"` + ProtocolRevenueAddress string `protobuf:"bytes,7,opt,name=protocol_revenue_address,json=protocolRevenueAddress,proto3" json:"protocol_revenue_address,omitempty"` +} + +func (m *Params) Reset() { *m = Params{} } +func (*Params) ProtoMessage() {} +func (*Params) Descriptor() ([]byte, []int) { + return fileDescriptor_bc83f5a7f5a55e20, []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 + +func (m *Params) GetLpIncentives() *IncentiveInfo { + if m != nil { + return m.LpIncentives + } + return nil +} + +func (m *Params) GetDexRewardsLps() DexRewardsTracker { + if m != nil { + return m.DexRewardsLps + } + return DexRewardsTracker{} +} + +func (m *Params) GetSupportedRewardDenoms() []*SupportedRewardDenom { + if m != nil { + return m.SupportedRewardDenoms + } + return nil +} + +func (m *Params) GetProtocolRevenueAddress() string { + if m != nil { + return m.ProtocolRevenueAddress + } + return "" +} + +type SupportedRewardDenom struct { + Denom string `protobuf:"bytes,1,opt,name=denom,proto3" json:"denom,omitempty"` + MinAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=min_amount,json=minAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"min_amount"` +} + +func (m *SupportedRewardDenom) Reset() { *m = SupportedRewardDenom{} } +func (m *SupportedRewardDenom) String() string { return proto.CompactTextString(m) } +func (*SupportedRewardDenom) ProtoMessage() {} +func (*SupportedRewardDenom) Descriptor() ([]byte, []int) { + return fileDescriptor_bc83f5a7f5a55e20, []int{1} +} +func (m *SupportedRewardDenom) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *SupportedRewardDenom) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_SupportedRewardDenom.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 *SupportedRewardDenom) XXX_Merge(src proto.Message) { + xxx_messageInfo_SupportedRewardDenom.Merge(m, src) +} +func (m *SupportedRewardDenom) XXX_Size() int { + return m.Size() +} +func (m *SupportedRewardDenom) XXX_DiscardUnknown() { + xxx_messageInfo_SupportedRewardDenom.DiscardUnknown(m) +} + +var xxx_messageInfo_SupportedRewardDenom proto.InternalMessageInfo + +func (m *SupportedRewardDenom) GetDenom() string { + if m != nil { + return m.Denom + } + return "" +} + +func init() { + proto.RegisterType((*Params)(nil), "elys.masterchef.Params") + proto.RegisterType((*SupportedRewardDenom)(nil), "elys.masterchef.SupportedRewardDenom") +} + +func init() { proto.RegisterFile("elys/masterchef/params.proto", fileDescriptor_bc83f5a7f5a55e20) } + +var fileDescriptor_bc83f5a7f5a55e20 = []byte{ + // 505 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x53, 0x41, 0x6b, 0x1a, 0x41, + 0x18, 0x75, 0x1b, 0x63, 0x71, 0xd2, 0x10, 0xd8, 0xda, 0xb8, 0x48, 0x59, 0x45, 0x68, 0xf1, 0x92, + 0x5d, 0x48, 0x2f, 0xa5, 0x37, 0xad, 0x2d, 0x08, 0x2d, 0xc8, 0xa6, 0xa7, 0x42, 0x19, 0x26, 0x3b, + 0x9f, 0x66, 0x71, 0x77, 0x66, 0x98, 0x19, 0x93, 0x0d, 0xfd, 0x13, 0x3d, 0xf6, 0xd8, 0x9f, 0x93, + 0x63, 0x8e, 0xa5, 0x87, 0x50, 0xf4, 0x3f, 0xf4, 0x5c, 0x76, 0x46, 0x8d, 0xa8, 0x27, 0x4f, 0xbb, + 0x33, 0xef, 0xf1, 0xde, 0xfb, 0x1e, 0xdf, 0xa0, 0x97, 0x90, 0xde, 0xaa, 0x30, 0x23, 0x4a, 0x83, + 0x8c, 0xaf, 0x60, 0x14, 0x0a, 0x22, 0x49, 0xa6, 0x02, 0x21, 0xb9, 0xe6, 0xee, 0x49, 0x81, 0x06, + 0x8f, 0x68, 0xa3, 0x36, 0xe6, 0x63, 0x6e, 0xb0, 0xb0, 0xf8, 0xb3, 0xb4, 0x46, 0x73, 0x53, 0x24, + 0x61, 0x31, 0x30, 0x9d, 0x5c, 0xc3, 0x82, 0xd0, 0xd8, 0x72, 0xe1, 0x3c, 0x5d, 0x60, 0x9d, 0x4d, + 0x8c, 0x42, 0x8e, 0x25, 0xdc, 0x10, 0x49, 0x15, 0xd6, 0x92, 0x4c, 0x40, 0x5a, 0x66, 0xfb, 0x5f, + 0x19, 0x55, 0x86, 0x26, 0x9e, 0xfb, 0x1e, 0x1d, 0xa7, 0x02, 0xaf, 0x6c, 0x94, 0xe7, 0xb4, 0x9c, + 0xce, 0xd1, 0xb9, 0x1f, 0x6c, 0x04, 0x0e, 0x06, 0x4b, 0xca, 0x80, 0x8d, 0x78, 0xf4, 0x2c, 0x15, + 0xab, 0x0b, 0xe5, 0xc6, 0xe8, 0xd4, 0xfa, 0x60, 0xc1, 0xa5, 0x4e, 0x38, 0xc3, 0x23, 0x2e, 0x71, + 0x2a, 0x94, 0xf7, 0xa4, 0xe5, 0x74, 0xaa, 0xbd, 0xe0, 0xee, 0xa1, 0x59, 0xfa, 0xf3, 0xd0, 0x7c, + 0x3d, 0x4e, 0xf4, 0xd5, 0xf4, 0x32, 0x88, 0x79, 0x16, 0xc6, 0x5c, 0x65, 0x5c, 0x2d, 0x3e, 0x67, + 0x8a, 0x4e, 0x42, 0x7d, 0x2b, 0x40, 0x05, 0x7d, 0x88, 0xa3, 0xe7, 0x56, 0x6d, 0x68, 0xc5, 0x3e, + 0x72, 0xf9, 0x49, 0x28, 0x77, 0x82, 0x1a, 0x3b, 0x4c, 0x94, 0x2e, 0xe6, 0x52, 0xde, 0xc1, 0x5e, + 0x46, 0xf5, 0x4d, 0xa3, 0x0b, 0x2b, 0xe7, 0x0e, 0xd1, 0xc9, 0x7a, 0x7b, 0xc5, 0x28, 0x65, 0x53, + 0x4c, 0x7b, 0xab, 0x98, 0x3e, 0xe4, 0x91, 0xa5, 0x7d, 0x91, 0x24, 0x9e, 0x80, 0xec, 0x95, 0x8b, + 0x14, 0xd1, 0x31, 0x5d, 0x01, 0x45, 0x7c, 0x8a, 0xea, 0x19, 0xc9, 0x31, 0x50, 0x60, 0x0b, 0x59, + 0x4c, 0x84, 0x2d, 0xe9, 0x70, 0xbf, 0x92, 0x32, 0x92, 0x7f, 0xa0, 0xc0, 0xac, 0x47, 0x57, 0x98, + 0x92, 0xbe, 0xa1, 0xba, 0x9a, 0x8a, 0xa2, 0x20, 0xa0, 0x4b, 0x1b, 0x0a, 0x8c, 0x67, 0xca, 0xab, + 0xb4, 0x0e, 0x3a, 0x47, 0xe7, 0xaf, 0xb6, 0xf2, 0x5f, 0x2c, 0xf9, 0x56, 0xa8, 0x5f, 0xb0, 0xa3, + 0x17, 0x6a, 0xc7, 0xad, 0x72, 0xdf, 0x22, 0xcf, 0x6c, 0x50, 0xcc, 0x53, 0x2c, 0xe1, 0x1a, 0xd8, + 0x14, 0x30, 0xa1, 0x54, 0x82, 0x52, 0xde, 0xd3, 0x62, 0x8a, 0xe8, 0x74, 0x89, 0x47, 0x16, 0xee, + 0x5a, 0xf4, 0x5d, 0xf9, 0xe7, 0xaf, 0x66, 0xa9, 0xfd, 0x1d, 0xd5, 0x76, 0xd9, 0xb9, 0x35, 0x74, + 0x68, 0x52, 0x9a, 0xed, 0xab, 0x46, 0xf6, 0xe0, 0x7e, 0x46, 0x28, 0x4b, 0x18, 0x26, 0x19, 0x9f, + 0x32, 0xbd, 0xc7, 0x2a, 0x0d, 0x98, 0x8e, 0xaa, 0x59, 0xc2, 0xba, 0x46, 0xa0, 0x37, 0xb8, 0x9b, + 0xf9, 0xce, 0xfd, 0xcc, 0x77, 0xfe, 0xce, 0x7c, 0xe7, 0xc7, 0xdc, 0x2f, 0xdd, 0xcf, 0xfd, 0xd2, + 0xef, 0xb9, 0x5f, 0xfa, 0x1a, 0xae, 0x89, 0x15, 0xf5, 0x9c, 0x31, 0xd0, 0x37, 0x5c, 0x4e, 0xcc, + 0x21, 0xcc, 0xd7, 0xdf, 0x94, 0x51, 0xbe, 0xac, 0x98, 0x29, 0xdf, 0xfc, 0x0f, 0x00, 0x00, 0xff, + 0xff, 0xcf, 0x0d, 0x11, 0x52, 0xf5, 0x03, 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 + if len(m.ProtocolRevenueAddress) > 0 { + i -= len(m.ProtocolRevenueAddress) + copy(dAtA[i:], m.ProtocolRevenueAddress) + i = encodeVarintParams(dAtA, i, uint64(len(m.ProtocolRevenueAddress))) + i-- + dAtA[i] = 0x3a + } + if len(m.SupportedRewardDenoms) > 0 { + for iNdEx := len(m.SupportedRewardDenoms) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.SupportedRewardDenoms[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + } + } + { + size := m.MaxEdenRewardAprLps.Size() + i -= size + if _, err := m.MaxEdenRewardAprLps.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + { + size, err := m.DexRewardsLps.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + { + size := m.RewardPortionForStakers.Size() + i -= size + if _, err := m.RewardPortionForStakers.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + { + size := m.RewardPortionForLps.Size() + i -= size + if _, err := m.RewardPortionForLps.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if m.LpIncentives != nil { + { + size, err := m.LpIncentives.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 *SupportedRewardDenom) 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 *SupportedRewardDenom) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *SupportedRewardDenom) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.MinAmount.Size() + i -= size + if _, err := m.MinAmount.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.Denom) > 0 { + i -= len(m.Denom) + copy(dAtA[i:], m.Denom) + i = encodeVarintParams(dAtA, i, uint64(len(m.Denom))) + i-- + dAtA[i] = 0xa + } + 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 m.LpIncentives != nil { + l = m.LpIncentives.Size() + n += 1 + l + sovParams(uint64(l)) + } + l = m.RewardPortionForLps.Size() + n += 1 + l + sovParams(uint64(l)) + l = m.RewardPortionForStakers.Size() + n += 1 + l + sovParams(uint64(l)) + l = m.DexRewardsLps.Size() + n += 1 + l + sovParams(uint64(l)) + l = m.MaxEdenRewardAprLps.Size() + n += 1 + l + sovParams(uint64(l)) + if len(m.SupportedRewardDenoms) > 0 { + for _, e := range m.SupportedRewardDenoms { + l = e.Size() + n += 1 + l + sovParams(uint64(l)) + } + } + l = len(m.ProtocolRevenueAddress) + if l > 0 { + n += 1 + l + sovParams(uint64(l)) + } + return n +} + +func (m *SupportedRewardDenom) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Denom) + if l > 0 { + n += 1 + l + sovParams(uint64(l)) + } + l = m.MinAmount.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 LpIncentives", 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 m.LpIncentives == nil { + m.LpIncentives = &IncentiveInfo{} + } + if err := m.LpIncentives.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RewardPortionForLps", 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.RewardPortionForLps.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RewardPortionForStakers", 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.RewardPortionForStakers.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DexRewardsLps", 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 := m.DexRewardsLps.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MaxEdenRewardAprLps", 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.MaxEdenRewardAprLps.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SupportedRewardDenoms", 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.SupportedRewardDenoms = append(m.SupportedRewardDenoms, &SupportedRewardDenom{}) + if err := m.SupportedRewardDenoms[len(m.SupportedRewardDenoms)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ProtocolRevenueAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ProtocolRevenueAddress = string(dAtA[iNdEx:postIndex]) + 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 *SupportedRewardDenom) 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: SupportedRewardDenom: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SupportedRewardDenom: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Denom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Denom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MinAmount", 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.MinAmount.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/masterchef/types/pool.pb.go b/x/masterchef/types/pool.pb.go new file mode 100644 index 000000000..a919f54a8 --- /dev/null +++ b/x/masterchef/types/pool.pb.go @@ -0,0 +1,1409 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: elys/masterchef/pool.proto + +package types + +import ( + fmt "fmt" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + 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 + +// Pool Info +type PoolInfo struct { + // reward amount + PoolId uint64 `protobuf:"varint,1,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty"` + // reward wallet address + RewardWallet string `protobuf:"bytes,2,opt,name=reward_wallet,json=rewardWallet,proto3" json:"reward_wallet,omitempty"` + // multiplier for lp rewards + Multiplier github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=multiplier,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"multiplier"` + // Block number since the creation of PoolInfo + NumBlocks github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,4,opt,name=num_blocks,json=numBlocks,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"num_blocks"` + // Total dex rewards given + DexRewardAmountGiven github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,5,opt,name=dex_reward_amount_given,json=dexRewardAmountGiven,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"dex_reward_amount_given"` + // Total eden rewards given + EdenRewardAmountGiven github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,6,opt,name=eden_reward_amount_given,json=edenRewardAmountGiven,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"eden_reward_amount_given"` + // Eden APR, updated at every distribution + EdenApr github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,7,opt,name=eden_apr,json=edenApr,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"eden_apr"` + // Dex APR, updated at every distribution + DexApr github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,8,opt,name=dex_apr,json=dexApr,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"dex_apr"` + // External Incentive APR, updated at every distribution + ExternalIncentiveApr github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,9,opt,name=external_incentive_apr,json=externalIncentiveApr,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"external_incentive_apr"` + // external reward denoms on the pool + ExternalRewardDenoms []string `protobuf:"bytes,10,rep,name=external_reward_denoms,json=externalRewardDenoms,proto3" json:"external_reward_denoms,omitempty"` +} + +func (m *PoolInfo) Reset() { *m = PoolInfo{} } +func (m *PoolInfo) String() string { return proto.CompactTextString(m) } +func (*PoolInfo) ProtoMessage() {} +func (*PoolInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_eeebce6928738c2c, []int{0} +} +func (m *PoolInfo) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PoolInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PoolInfo.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 *PoolInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_PoolInfo.Merge(m, src) +} +func (m *PoolInfo) XXX_Size() int { + return m.Size() +} +func (m *PoolInfo) XXX_DiscardUnknown() { + xxx_messageInfo_PoolInfo.DiscardUnknown(m) +} + +var xxx_messageInfo_PoolInfo proto.InternalMessageInfo + +func (m *PoolInfo) GetPoolId() uint64 { + if m != nil { + return m.PoolId + } + return 0 +} + +func (m *PoolInfo) GetRewardWallet() string { + if m != nil { + return m.RewardWallet + } + return "" +} + +func (m *PoolInfo) GetExternalRewardDenoms() []string { + if m != nil { + return m.ExternalRewardDenoms + } + return nil +} + +type PoolRewardInfo struct { + PoolId uint64 `protobuf:"varint,1,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty"` + RewardDenom string `protobuf:"bytes,2,opt,name=reward_denom,json=rewardDenom,proto3" json:"reward_denom,omitempty"` + PoolAccRewardPerShare github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=pool_acc_reward_per_share,json=poolAccRewardPerShare,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"pool_acc_reward_per_share"` + LastUpdatedBlock uint64 `protobuf:"varint,4,opt,name=last_updated_block,json=lastUpdatedBlock,proto3" json:"last_updated_block,omitempty"` +} + +func (m *PoolRewardInfo) Reset() { *m = PoolRewardInfo{} } +func (m *PoolRewardInfo) String() string { return proto.CompactTextString(m) } +func (*PoolRewardInfo) ProtoMessage() {} +func (*PoolRewardInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_eeebce6928738c2c, []int{1} +} +func (m *PoolRewardInfo) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PoolRewardInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PoolRewardInfo.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 *PoolRewardInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_PoolRewardInfo.Merge(m, src) +} +func (m *PoolRewardInfo) XXX_Size() int { + return m.Size() +} +func (m *PoolRewardInfo) XXX_DiscardUnknown() { + xxx_messageInfo_PoolRewardInfo.DiscardUnknown(m) +} + +var xxx_messageInfo_PoolRewardInfo proto.InternalMessageInfo + +func (m *PoolRewardInfo) GetPoolId() uint64 { + if m != nil { + return m.PoolId + } + return 0 +} + +func (m *PoolRewardInfo) GetRewardDenom() string { + if m != nil { + return m.RewardDenom + } + return "" +} + +func (m *PoolRewardInfo) GetLastUpdatedBlock() uint64 { + if m != nil { + return m.LastUpdatedBlock + } + return 0 +} + +type UserRewardInfo struct { + User string `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` + PoolId uint64 `protobuf:"varint,2,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty"` + RewardDenom string `protobuf:"bytes,3,opt,name=reward_denom,json=rewardDenom,proto3" json:"reward_denom,omitempty"` + RewardDebt github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,4,opt,name=reward_debt,json=rewardDebt,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"reward_debt"` + RewardPending github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,5,opt,name=reward_pending,json=rewardPending,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"reward_pending"` +} + +func (m *UserRewardInfo) Reset() { *m = UserRewardInfo{} } +func (m *UserRewardInfo) String() string { return proto.CompactTextString(m) } +func (*UserRewardInfo) ProtoMessage() {} +func (*UserRewardInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_eeebce6928738c2c, []int{2} +} +func (m *UserRewardInfo) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *UserRewardInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_UserRewardInfo.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 *UserRewardInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_UserRewardInfo.Merge(m, src) +} +func (m *UserRewardInfo) XXX_Size() int { + return m.Size() +} +func (m *UserRewardInfo) XXX_DiscardUnknown() { + xxx_messageInfo_UserRewardInfo.DiscardUnknown(m) +} + +var xxx_messageInfo_UserRewardInfo proto.InternalMessageInfo + +func (m *UserRewardInfo) GetUser() string { + if m != nil { + return m.User + } + return "" +} + +func (m *UserRewardInfo) GetPoolId() uint64 { + if m != nil { + return m.PoolId + } + return 0 +} + +func (m *UserRewardInfo) GetRewardDenom() string { + if m != nil { + return m.RewardDenom + } + return "" +} + +func init() { + proto.RegisterType((*PoolInfo)(nil), "elys.masterchef.PoolInfo") + proto.RegisterType((*PoolRewardInfo)(nil), "elys.masterchef.PoolRewardInfo") + proto.RegisterType((*UserRewardInfo)(nil), "elys.masterchef.UserRewardInfo") +} + +func init() { proto.RegisterFile("elys/masterchef/pool.proto", fileDescriptor_eeebce6928738c2c) } + +var fileDescriptor_eeebce6928738c2c = []byte{ + // 561 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x94, 0xcf, 0x6a, 0xdb, 0x40, + 0x10, 0xc6, 0x2d, 0xdb, 0xf1, 0x9f, 0x4d, 0xea, 0x96, 0x25, 0x69, 0xd4, 0x1c, 0x14, 0xd7, 0x85, + 0xe2, 0x43, 0x63, 0x1d, 0xda, 0x17, 0xb0, 0x09, 0x04, 0x1d, 0xda, 0x1a, 0x15, 0x53, 0xe8, 0x45, + 0xc8, 0xda, 0x89, 0x2c, 0x2c, 0xed, 0x8a, 0xdd, 0x55, 0xec, 0xbc, 0x41, 0x8f, 0x7d, 0xac, 0x1c, + 0x73, 0x2c, 0x3d, 0x84, 0x62, 0x17, 0xfa, 0x1a, 0x65, 0x57, 0x76, 0x2c, 0x48, 0x09, 0x44, 0x27, + 0x69, 0xf7, 0xdb, 0xfd, 0xcd, 0x7e, 0xc3, 0xcc, 0xa0, 0x13, 0x88, 0xaf, 0x85, 0x9d, 0xf8, 0x42, + 0x02, 0x0f, 0x66, 0x70, 0x69, 0xa7, 0x8c, 0xc5, 0x83, 0x94, 0x33, 0xc9, 0xf0, 0x73, 0xa5, 0x0d, + 0x76, 0xda, 0xc9, 0x61, 0xc8, 0x42, 0xa6, 0x35, 0x5b, 0xfd, 0xe5, 0xc7, 0x7a, 0x7f, 0xf7, 0x50, + 0x6b, 0xcc, 0x58, 0xec, 0xd0, 0x4b, 0x86, 0x8f, 0x51, 0x53, 0x11, 0xbc, 0x88, 0x98, 0x46, 0xd7, + 0xe8, 0xd7, 0xdd, 0x86, 0x5a, 0x3a, 0x04, 0xbf, 0x41, 0xcf, 0x38, 0x2c, 0x7c, 0x4e, 0xbc, 0x85, + 0x1f, 0xc7, 0x20, 0xcd, 0x6a, 0xd7, 0xe8, 0xb7, 0xdd, 0x83, 0x7c, 0xf3, 0xab, 0xde, 0xc3, 0x9f, + 0x10, 0x4a, 0xb2, 0x58, 0x46, 0x69, 0x1c, 0x01, 0x37, 0x6b, 0xea, 0xc4, 0x68, 0x70, 0x73, 0x77, + 0x5a, 0xf9, 0x75, 0x77, 0xfa, 0x36, 0x8c, 0xe4, 0x2c, 0x9b, 0x0e, 0x02, 0x96, 0xd8, 0x01, 0x13, + 0x09, 0x13, 0x9b, 0xcf, 0x99, 0x20, 0x73, 0x5b, 0x5e, 0xa7, 0x20, 0x06, 0xe7, 0x10, 0xb8, 0x05, + 0x02, 0xfe, 0x88, 0x10, 0xcd, 0x12, 0x6f, 0x1a, 0xb3, 0x60, 0x2e, 0xcc, 0xfa, 0x93, 0x79, 0x0e, + 0x95, 0x6e, 0x9b, 0x66, 0xc9, 0x48, 0x03, 0x30, 0xa0, 0x63, 0x02, 0x4b, 0x6f, 0xe3, 0xc3, 0x4f, + 0x58, 0x46, 0xa5, 0x17, 0x46, 0x57, 0x40, 0xcd, 0xbd, 0x52, 0x6f, 0x3d, 0x24, 0xb0, 0x74, 0x35, + 0x6d, 0xa8, 0x61, 0x17, 0x8a, 0x85, 0x43, 0x64, 0x02, 0x01, 0xfa, 0xdf, 0x38, 0x8d, 0x52, 0x1e, + 0x8e, 0x14, 0xef, 0x61, 0x20, 0x07, 0xb5, 0x74, 0x20, 0x3f, 0xe5, 0x66, 0xb3, 0x94, 0x81, 0xa6, + 0xba, 0x3f, 0x4c, 0x39, 0xbe, 0x40, 0x4d, 0x95, 0x1a, 0x45, 0x6a, 0x95, 0x22, 0x35, 0x08, 0x2c, + 0x15, 0x88, 0xa0, 0x97, 0xb0, 0x94, 0xc0, 0xa9, 0x1f, 0x7b, 0x11, 0x0d, 0x80, 0xca, 0xe8, 0x0a, + 0x34, 0xb7, 0x5d, 0x2e, 0xc5, 0x5b, 0x9a, 0xb3, 0x85, 0xa9, 0x28, 0x1f, 0x0a, 0x51, 0x36, 0x69, + 0x26, 0x40, 0x59, 0x22, 0x4c, 0xd4, 0xad, 0xf5, 0xdb, 0xbb, 0x5b, 0x79, 0xd2, 0xce, 0xb5, 0xd6, + 0xfb, 0x63, 0xa0, 0x8e, 0xaa, 0xf4, 0x7c, 0xf3, 0xf1, 0x7a, 0x7f, 0x8d, 0x0e, 0x8a, 0xe0, 0x4d, + 0xb9, 0xef, 0xf3, 0x1d, 0x0f, 0xcf, 0xd0, 0x2b, 0x7d, 0xd7, 0x0f, 0x82, 0xed, 0x23, 0x52, 0xe0, + 0x9e, 0x98, 0xf9, 0x1c, 0x4a, 0x16, 0xff, 0x91, 0x02, 0x0e, 0x83, 0x20, 0x7f, 0xe1, 0x18, 0xf8, + 0x17, 0x05, 0xc3, 0xef, 0x10, 0x8e, 0x7d, 0x21, 0xbd, 0x2c, 0x25, 0xbe, 0x04, 0x92, 0x37, 0x84, + 0xee, 0x87, 0xba, 0xfb, 0x42, 0x29, 0x93, 0x5c, 0xd0, 0x75, 0xde, 0xfb, 0x5e, 0x45, 0x9d, 0x89, + 0x00, 0x5e, 0xb0, 0x89, 0x51, 0x3d, 0x13, 0xc0, 0xb5, 0xc7, 0xb6, 0xab, 0xff, 0x8b, 0xd6, 0xab, + 0x8f, 0x5a, 0xaf, 0x3d, 0xb4, 0xfe, 0x19, 0xed, 0xdf, 0x1f, 0x99, 0xca, 0x12, 0x9d, 0xa9, 0x3b, + 0x7d, 0x4b, 0x9c, 0x4a, 0x3c, 0x41, 0x9d, 0xfb, 0x14, 0x52, 0x12, 0xd1, 0xb0, 0x64, 0x47, 0x6e, + 0x86, 0xd4, 0x38, 0x87, 0x8c, 0x9c, 0x9b, 0x95, 0x65, 0xdc, 0xae, 0x2c, 0xe3, 0xf7, 0xca, 0x32, + 0x7e, 0xac, 0xad, 0xca, 0xed, 0xda, 0xaa, 0xfc, 0x5c, 0x5b, 0x95, 0x6f, 0x76, 0x01, 0xa8, 0xe6, + 0xe4, 0x19, 0x05, 0xb9, 0x60, 0x7c, 0xae, 0x17, 0xf6, 0xb2, 0x38, 0x52, 0x35, 0x7d, 0xda, 0xd0, + 0xd3, 0xf2, 0xfd, 0xbf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x44, 0x22, 0x56, 0x6a, 0x72, 0x05, 0x00, + 0x00, +} + +func (m *PoolInfo) 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 *PoolInfo) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PoolInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ExternalRewardDenoms) > 0 { + for iNdEx := len(m.ExternalRewardDenoms) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.ExternalRewardDenoms[iNdEx]) + copy(dAtA[i:], m.ExternalRewardDenoms[iNdEx]) + i = encodeVarintPool(dAtA, i, uint64(len(m.ExternalRewardDenoms[iNdEx]))) + i-- + dAtA[i] = 0x52 + } + } + { + size := m.ExternalIncentiveApr.Size() + i -= size + if _, err := m.ExternalIncentiveApr.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintPool(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x4a + { + size := m.DexApr.Size() + i -= size + if _, err := m.DexApr.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintPool(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x42 + { + size := m.EdenApr.Size() + i -= size + if _, err := m.EdenApr.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintPool(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x3a + { + size := m.EdenRewardAmountGiven.Size() + i -= size + if _, err := m.EdenRewardAmountGiven.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintPool(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + { + size := m.DexRewardAmountGiven.Size() + i -= size + if _, err := m.DexRewardAmountGiven.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintPool(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + { + size := m.NumBlocks.Size() + i -= size + if _, err := m.NumBlocks.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintPool(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + { + size := m.Multiplier.Size() + i -= size + if _, err := m.Multiplier.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintPool(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if len(m.RewardWallet) > 0 { + i -= len(m.RewardWallet) + copy(dAtA[i:], m.RewardWallet) + i = encodeVarintPool(dAtA, i, uint64(len(m.RewardWallet))) + i-- + dAtA[i] = 0x12 + } + if m.PoolId != 0 { + i = encodeVarintPool(dAtA, i, uint64(m.PoolId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *PoolRewardInfo) 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 *PoolRewardInfo) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PoolRewardInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.LastUpdatedBlock != 0 { + i = encodeVarintPool(dAtA, i, uint64(m.LastUpdatedBlock)) + i-- + dAtA[i] = 0x20 + } + { + size := m.PoolAccRewardPerShare.Size() + i -= size + if _, err := m.PoolAccRewardPerShare.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintPool(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if len(m.RewardDenom) > 0 { + i -= len(m.RewardDenom) + copy(dAtA[i:], m.RewardDenom) + i = encodeVarintPool(dAtA, i, uint64(len(m.RewardDenom))) + i-- + dAtA[i] = 0x12 + } + if m.PoolId != 0 { + i = encodeVarintPool(dAtA, i, uint64(m.PoolId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *UserRewardInfo) 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 *UserRewardInfo) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *UserRewardInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.RewardPending.Size() + i -= size + if _, err := m.RewardPending.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintPool(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + { + size := m.RewardDebt.Size() + i -= size + if _, err := m.RewardDebt.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintPool(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + if len(m.RewardDenom) > 0 { + i -= len(m.RewardDenom) + copy(dAtA[i:], m.RewardDenom) + i = encodeVarintPool(dAtA, i, uint64(len(m.RewardDenom))) + i-- + dAtA[i] = 0x1a + } + if m.PoolId != 0 { + i = encodeVarintPool(dAtA, i, uint64(m.PoolId)) + i-- + dAtA[i] = 0x10 + } + if len(m.User) > 0 { + i -= len(m.User) + copy(dAtA[i:], m.User) + i = encodeVarintPool(dAtA, i, uint64(len(m.User))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintPool(dAtA []byte, offset int, v uint64) int { + offset -= sovPool(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *PoolInfo) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PoolId != 0 { + n += 1 + sovPool(uint64(m.PoolId)) + } + l = len(m.RewardWallet) + if l > 0 { + n += 1 + l + sovPool(uint64(l)) + } + l = m.Multiplier.Size() + n += 1 + l + sovPool(uint64(l)) + l = m.NumBlocks.Size() + n += 1 + l + sovPool(uint64(l)) + l = m.DexRewardAmountGiven.Size() + n += 1 + l + sovPool(uint64(l)) + l = m.EdenRewardAmountGiven.Size() + n += 1 + l + sovPool(uint64(l)) + l = m.EdenApr.Size() + n += 1 + l + sovPool(uint64(l)) + l = m.DexApr.Size() + n += 1 + l + sovPool(uint64(l)) + l = m.ExternalIncentiveApr.Size() + n += 1 + l + sovPool(uint64(l)) + if len(m.ExternalRewardDenoms) > 0 { + for _, s := range m.ExternalRewardDenoms { + l = len(s) + n += 1 + l + sovPool(uint64(l)) + } + } + return n +} + +func (m *PoolRewardInfo) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PoolId != 0 { + n += 1 + sovPool(uint64(m.PoolId)) + } + l = len(m.RewardDenom) + if l > 0 { + n += 1 + l + sovPool(uint64(l)) + } + l = m.PoolAccRewardPerShare.Size() + n += 1 + l + sovPool(uint64(l)) + if m.LastUpdatedBlock != 0 { + n += 1 + sovPool(uint64(m.LastUpdatedBlock)) + } + return n +} + +func (m *UserRewardInfo) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.User) + if l > 0 { + n += 1 + l + sovPool(uint64(l)) + } + if m.PoolId != 0 { + n += 1 + sovPool(uint64(m.PoolId)) + } + l = len(m.RewardDenom) + if l > 0 { + n += 1 + l + sovPool(uint64(l)) + } + l = m.RewardDebt.Size() + n += 1 + l + sovPool(uint64(l)) + l = m.RewardPending.Size() + n += 1 + l + sovPool(uint64(l)) + return n +} + +func sovPool(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozPool(x uint64) (n int) { + return sovPool(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *PoolInfo) 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 ErrIntOverflowPool + } + 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: PoolInfo: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PoolInfo: 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 ErrIntOverflowPool + } + 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 RewardWallet", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + 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 ErrInvalidLengthPool + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPool + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RewardWallet = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Multiplier", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + 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 ErrInvalidLengthPool + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPool + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Multiplier.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NumBlocks", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + 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 ErrInvalidLengthPool + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPool + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.NumBlocks.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DexRewardAmountGiven", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + 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 ErrInvalidLengthPool + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPool + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.DexRewardAmountGiven.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EdenRewardAmountGiven", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + 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 ErrInvalidLengthPool + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPool + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.EdenRewardAmountGiven.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EdenApr", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + 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 ErrInvalidLengthPool + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPool + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.EdenApr.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DexApr", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + 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 ErrInvalidLengthPool + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPool + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.DexApr.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 9: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ExternalIncentiveApr", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + 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 ErrInvalidLengthPool + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPool + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.ExternalIncentiveApr.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 10: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ExternalRewardDenoms", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + 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 ErrInvalidLengthPool + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPool + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ExternalRewardDenoms = append(m.ExternalRewardDenoms, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipPool(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthPool + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *PoolRewardInfo) 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 ErrIntOverflowPool + } + 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: PoolRewardInfo: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PoolRewardInfo: 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 ErrIntOverflowPool + } + 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 RewardDenom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + 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 ErrInvalidLengthPool + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPool + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RewardDenom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PoolAccRewardPerShare", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + 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 ErrInvalidLengthPool + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPool + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.PoolAccRewardPerShare.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field LastUpdatedBlock", wireType) + } + m.LastUpdatedBlock = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.LastUpdatedBlock |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipPool(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthPool + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *UserRewardInfo) 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 ErrIntOverflowPool + } + 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: UserRewardInfo: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: UserRewardInfo: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field User", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + 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 ErrInvalidLengthPool + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPool + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.User = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + 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 ErrIntOverflowPool + } + 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 RewardDenom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + 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 ErrInvalidLengthPool + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPool + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RewardDenom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RewardDebt", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + 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 ErrInvalidLengthPool + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPool + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.RewardDebt.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RewardPending", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + 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 ErrInvalidLengthPool + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPool + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.RewardPending.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipPool(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthPool + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipPool(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, ErrIntOverflowPool + } + 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, ErrIntOverflowPool + } + 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, ErrIntOverflowPool + } + 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, ErrInvalidLengthPool + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupPool + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthPool + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthPool = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowPool = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupPool = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/masterchef/types/query.pb.go b/x/masterchef/types/query.pb.go new file mode 100644 index 000000000..21d32d462 --- /dev/null +++ b/x/masterchef/types/query.pb.go @@ -0,0 +1,3964 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: elys/masterchef/query.proto + +package types + +import ( + context "context" + fmt "fmt" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/cosmos/cosmos-sdk/types/query" + _ "github.com/cosmos/gogoproto/gogoproto" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/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 + +// 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_e4939d0b7ced5d80, []int{0} +} +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 holds all the parameters of this module. + 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_e4939d0b7ced5d80, []int{1} +} +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{} +} + +type QueryExternalIncentiveRequest struct { + Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` +} + +func (m *QueryExternalIncentiveRequest) Reset() { *m = QueryExternalIncentiveRequest{} } +func (m *QueryExternalIncentiveRequest) String() string { return proto.CompactTextString(m) } +func (*QueryExternalIncentiveRequest) ProtoMessage() {} +func (*QueryExternalIncentiveRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_e4939d0b7ced5d80, []int{2} +} +func (m *QueryExternalIncentiveRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryExternalIncentiveRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryExternalIncentiveRequest.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 *QueryExternalIncentiveRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryExternalIncentiveRequest.Merge(m, src) +} +func (m *QueryExternalIncentiveRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryExternalIncentiveRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryExternalIncentiveRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryExternalIncentiveRequest proto.InternalMessageInfo + +func (m *QueryExternalIncentiveRequest) GetId() uint64 { + if m != nil { + return m.Id + } + return 0 +} + +type QueryExternalIncentiveResponse struct { + ExternalIncentive ExternalIncentive `protobuf:"bytes,1,opt,name=external_incentive,json=externalIncentive,proto3" json:"external_incentive"` +} + +func (m *QueryExternalIncentiveResponse) Reset() { *m = QueryExternalIncentiveResponse{} } +func (m *QueryExternalIncentiveResponse) String() string { return proto.CompactTextString(m) } +func (*QueryExternalIncentiveResponse) ProtoMessage() {} +func (*QueryExternalIncentiveResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_e4939d0b7ced5d80, []int{3} +} +func (m *QueryExternalIncentiveResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryExternalIncentiveResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryExternalIncentiveResponse.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 *QueryExternalIncentiveResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryExternalIncentiveResponse.Merge(m, src) +} +func (m *QueryExternalIncentiveResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryExternalIncentiveResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryExternalIncentiveResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryExternalIncentiveResponse proto.InternalMessageInfo + +func (m *QueryExternalIncentiveResponse) GetExternalIncentive() ExternalIncentive { + if m != nil { + return m.ExternalIncentive + } + return ExternalIncentive{} +} + +type QueryPoolInfoRequest struct { + PoolId uint64 `protobuf:"varint,1,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty"` +} + +func (m *QueryPoolInfoRequest) Reset() { *m = QueryPoolInfoRequest{} } +func (m *QueryPoolInfoRequest) String() string { return proto.CompactTextString(m) } +func (*QueryPoolInfoRequest) ProtoMessage() {} +func (*QueryPoolInfoRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_e4939d0b7ced5d80, []int{4} +} +func (m *QueryPoolInfoRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryPoolInfoRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryPoolInfoRequest.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 *QueryPoolInfoRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryPoolInfoRequest.Merge(m, src) +} +func (m *QueryPoolInfoRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryPoolInfoRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryPoolInfoRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryPoolInfoRequest proto.InternalMessageInfo + +func (m *QueryPoolInfoRequest) GetPoolId() uint64 { + if m != nil { + return m.PoolId + } + return 0 +} + +type QueryPoolInfoResponse struct { + PoolInfo PoolInfo `protobuf:"bytes,1,opt,name=pool_info,json=poolInfo,proto3" json:"pool_info"` +} + +func (m *QueryPoolInfoResponse) Reset() { *m = QueryPoolInfoResponse{} } +func (m *QueryPoolInfoResponse) String() string { return proto.CompactTextString(m) } +func (*QueryPoolInfoResponse) ProtoMessage() {} +func (*QueryPoolInfoResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_e4939d0b7ced5d80, []int{5} +} +func (m *QueryPoolInfoResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryPoolInfoResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryPoolInfoResponse.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 *QueryPoolInfoResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryPoolInfoResponse.Merge(m, src) +} +func (m *QueryPoolInfoResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryPoolInfoResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryPoolInfoResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryPoolInfoResponse proto.InternalMessageInfo + +func (m *QueryPoolInfoResponse) GetPoolInfo() PoolInfo { + if m != nil { + return m.PoolInfo + } + return PoolInfo{} +} + +type QueryPoolRewardInfoRequest struct { + PoolId uint64 `protobuf:"varint,1,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty"` + RewardDenom string `protobuf:"bytes,2,opt,name=reward_denom,json=rewardDenom,proto3" json:"reward_denom,omitempty"` +} + +func (m *QueryPoolRewardInfoRequest) Reset() { *m = QueryPoolRewardInfoRequest{} } +func (m *QueryPoolRewardInfoRequest) String() string { return proto.CompactTextString(m) } +func (*QueryPoolRewardInfoRequest) ProtoMessage() {} +func (*QueryPoolRewardInfoRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_e4939d0b7ced5d80, []int{6} +} +func (m *QueryPoolRewardInfoRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryPoolRewardInfoRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryPoolRewardInfoRequest.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 *QueryPoolRewardInfoRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryPoolRewardInfoRequest.Merge(m, src) +} +func (m *QueryPoolRewardInfoRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryPoolRewardInfoRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryPoolRewardInfoRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryPoolRewardInfoRequest proto.InternalMessageInfo + +func (m *QueryPoolRewardInfoRequest) GetPoolId() uint64 { + if m != nil { + return m.PoolId + } + return 0 +} + +func (m *QueryPoolRewardInfoRequest) GetRewardDenom() string { + if m != nil { + return m.RewardDenom + } + return "" +} + +type QueryPoolRewardInfoResponse struct { + PoolRewardInfo PoolRewardInfo `protobuf:"bytes,1,opt,name=pool_reward_info,json=poolRewardInfo,proto3" json:"pool_reward_info"` +} + +func (m *QueryPoolRewardInfoResponse) Reset() { *m = QueryPoolRewardInfoResponse{} } +func (m *QueryPoolRewardInfoResponse) String() string { return proto.CompactTextString(m) } +func (*QueryPoolRewardInfoResponse) ProtoMessage() {} +func (*QueryPoolRewardInfoResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_e4939d0b7ced5d80, []int{7} +} +func (m *QueryPoolRewardInfoResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryPoolRewardInfoResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryPoolRewardInfoResponse.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 *QueryPoolRewardInfoResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryPoolRewardInfoResponse.Merge(m, src) +} +func (m *QueryPoolRewardInfoResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryPoolRewardInfoResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryPoolRewardInfoResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryPoolRewardInfoResponse proto.InternalMessageInfo + +func (m *QueryPoolRewardInfoResponse) GetPoolRewardInfo() PoolRewardInfo { + if m != nil { + return m.PoolRewardInfo + } + return PoolRewardInfo{} +} + +type QueryUserRewardInfoRequest struct { + User string `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` + PoolId uint64 `protobuf:"varint,2,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty"` + RewardDenom string `protobuf:"bytes,3,opt,name=reward_denom,json=rewardDenom,proto3" json:"reward_denom,omitempty"` +} + +func (m *QueryUserRewardInfoRequest) Reset() { *m = QueryUserRewardInfoRequest{} } +func (m *QueryUserRewardInfoRequest) String() string { return proto.CompactTextString(m) } +func (*QueryUserRewardInfoRequest) ProtoMessage() {} +func (*QueryUserRewardInfoRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_e4939d0b7ced5d80, []int{8} +} +func (m *QueryUserRewardInfoRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryUserRewardInfoRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryUserRewardInfoRequest.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 *QueryUserRewardInfoRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryUserRewardInfoRequest.Merge(m, src) +} +func (m *QueryUserRewardInfoRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryUserRewardInfoRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryUserRewardInfoRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryUserRewardInfoRequest proto.InternalMessageInfo + +func (m *QueryUserRewardInfoRequest) GetUser() string { + if m != nil { + return m.User + } + return "" +} + +func (m *QueryUserRewardInfoRequest) GetPoolId() uint64 { + if m != nil { + return m.PoolId + } + return 0 +} + +func (m *QueryUserRewardInfoRequest) GetRewardDenom() string { + if m != nil { + return m.RewardDenom + } + return "" +} + +type QueryUserRewardInfoResponse struct { + UserRewardInfo UserRewardInfo `protobuf:"bytes,1,opt,name=user_reward_info,json=userRewardInfo,proto3" json:"user_reward_info"` +} + +func (m *QueryUserRewardInfoResponse) Reset() { *m = QueryUserRewardInfoResponse{} } +func (m *QueryUserRewardInfoResponse) String() string { return proto.CompactTextString(m) } +func (*QueryUserRewardInfoResponse) ProtoMessage() {} +func (*QueryUserRewardInfoResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_e4939d0b7ced5d80, []int{9} +} +func (m *QueryUserRewardInfoResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryUserRewardInfoResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryUserRewardInfoResponse.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 *QueryUserRewardInfoResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryUserRewardInfoResponse.Merge(m, src) +} +func (m *QueryUserRewardInfoResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryUserRewardInfoResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryUserRewardInfoResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryUserRewardInfoResponse proto.InternalMessageInfo + +func (m *QueryUserRewardInfoResponse) GetUserRewardInfo() UserRewardInfo { + if m != nil { + return m.UserRewardInfo + } + return UserRewardInfo{} +} + +type QueryUserPendingRewardRequest struct { + User string `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` +} + +func (m *QueryUserPendingRewardRequest) Reset() { *m = QueryUserPendingRewardRequest{} } +func (m *QueryUserPendingRewardRequest) String() string { return proto.CompactTextString(m) } +func (*QueryUserPendingRewardRequest) ProtoMessage() {} +func (*QueryUserPendingRewardRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_e4939d0b7ced5d80, []int{10} +} +func (m *QueryUserPendingRewardRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryUserPendingRewardRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryUserPendingRewardRequest.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 *QueryUserPendingRewardRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryUserPendingRewardRequest.Merge(m, src) +} +func (m *QueryUserPendingRewardRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryUserPendingRewardRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryUserPendingRewardRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryUserPendingRewardRequest proto.InternalMessageInfo + +func (m *QueryUserPendingRewardRequest) GetUser() string { + if m != nil { + return m.User + } + return "" +} + +type RewardInfo struct { + PoolId uint64 `protobuf:"varint,1,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty"` + Reward github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,2,rep,name=reward,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"reward"` +} + +func (m *RewardInfo) Reset() { *m = RewardInfo{} } +func (m *RewardInfo) String() string { return proto.CompactTextString(m) } +func (*RewardInfo) ProtoMessage() {} +func (*RewardInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_e4939d0b7ced5d80, []int{11} +} +func (m *RewardInfo) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *RewardInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_RewardInfo.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 *RewardInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_RewardInfo.Merge(m, src) +} +func (m *RewardInfo) XXX_Size() int { + return m.Size() +} +func (m *RewardInfo) XXX_DiscardUnknown() { + xxx_messageInfo_RewardInfo.DiscardUnknown(m) +} + +var xxx_messageInfo_RewardInfo proto.InternalMessageInfo + +func (m *RewardInfo) GetPoolId() uint64 { + if m != nil { + return m.PoolId + } + return 0 +} + +func (m *RewardInfo) GetReward() github_com_cosmos_cosmos_sdk_types.Coins { + if m != nil { + return m.Reward + } + return nil +} + +type QueryUserPendingRewardResponse struct { + Rewards []*RewardInfo `protobuf:"bytes,1,rep,name=rewards,proto3" json:"rewards,omitempty"` + TotalRewards github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,2,rep,name=total_rewards,json=totalRewards,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"total_rewards"` +} + +func (m *QueryUserPendingRewardResponse) Reset() { *m = QueryUserPendingRewardResponse{} } +func (m *QueryUserPendingRewardResponse) String() string { return proto.CompactTextString(m) } +func (*QueryUserPendingRewardResponse) ProtoMessage() {} +func (*QueryUserPendingRewardResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_e4939d0b7ced5d80, []int{12} +} +func (m *QueryUserPendingRewardResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryUserPendingRewardResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryUserPendingRewardResponse.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 *QueryUserPendingRewardResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryUserPendingRewardResponse.Merge(m, src) +} +func (m *QueryUserPendingRewardResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryUserPendingRewardResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryUserPendingRewardResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryUserPendingRewardResponse proto.InternalMessageInfo + +func (m *QueryUserPendingRewardResponse) GetRewards() []*RewardInfo { + if m != nil { + return m.Rewards + } + return nil +} + +func (m *QueryUserPendingRewardResponse) GetTotalRewards() github_com_cosmos_cosmos_sdk_types.Coins { + if m != nil { + return m.TotalRewards + } + return nil +} + +type QueryStableStakeAprRequest struct { + Denom string `protobuf:"bytes,1,opt,name=denom,proto3" json:"denom,omitempty"` +} + +func (m *QueryStableStakeAprRequest) Reset() { *m = QueryStableStakeAprRequest{} } +func (m *QueryStableStakeAprRequest) String() string { return proto.CompactTextString(m) } +func (*QueryStableStakeAprRequest) ProtoMessage() {} +func (*QueryStableStakeAprRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_e4939d0b7ced5d80, []int{13} +} +func (m *QueryStableStakeAprRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryStableStakeAprRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryStableStakeAprRequest.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 *QueryStableStakeAprRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryStableStakeAprRequest.Merge(m, src) +} +func (m *QueryStableStakeAprRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryStableStakeAprRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryStableStakeAprRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryStableStakeAprRequest proto.InternalMessageInfo + +func (m *QueryStableStakeAprRequest) GetDenom() string { + if m != nil { + return m.Denom + } + return "" +} + +type QueryStableStakeAprResponse struct { + Apr github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=apr,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"apr"` +} + +func (m *QueryStableStakeAprResponse) Reset() { *m = QueryStableStakeAprResponse{} } +func (m *QueryStableStakeAprResponse) String() string { return proto.CompactTextString(m) } +func (*QueryStableStakeAprResponse) ProtoMessage() {} +func (*QueryStableStakeAprResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_e4939d0b7ced5d80, []int{14} +} +func (m *QueryStableStakeAprResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryStableStakeAprResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryStableStakeAprResponse.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 *QueryStableStakeAprResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryStableStakeAprResponse.Merge(m, src) +} +func (m *QueryStableStakeAprResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryStableStakeAprResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryStableStakeAprResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryStableStakeAprResponse proto.InternalMessageInfo + +type QueryPoolAprsRequest struct { + PoolIds []uint64 `protobuf:"varint,1,rep,packed,name=pool_ids,json=poolIds,proto3" json:"pool_ids,omitempty"` +} + +func (m *QueryPoolAprsRequest) Reset() { *m = QueryPoolAprsRequest{} } +func (m *QueryPoolAprsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryPoolAprsRequest) ProtoMessage() {} +func (*QueryPoolAprsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_e4939d0b7ced5d80, []int{15} +} +func (m *QueryPoolAprsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryPoolAprsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryPoolAprsRequest.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 *QueryPoolAprsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryPoolAprsRequest.Merge(m, src) +} +func (m *QueryPoolAprsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryPoolAprsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryPoolAprsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryPoolAprsRequest proto.InternalMessageInfo + +func (m *QueryPoolAprsRequest) GetPoolIds() []uint64 { + if m != nil { + return m.PoolIds + } + return nil +} + +type QueryPoolAprsResponse struct { + Data []PoolApr `protobuf:"bytes,1,rep,name=data,proto3" json:"data"` +} + +func (m *QueryPoolAprsResponse) Reset() { *m = QueryPoolAprsResponse{} } +func (m *QueryPoolAprsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryPoolAprsResponse) ProtoMessage() {} +func (*QueryPoolAprsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_e4939d0b7ced5d80, []int{16} +} +func (m *QueryPoolAprsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryPoolAprsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryPoolAprsResponse.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 *QueryPoolAprsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryPoolAprsResponse.Merge(m, src) +} +func (m *QueryPoolAprsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryPoolAprsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryPoolAprsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryPoolAprsResponse proto.InternalMessageInfo + +func (m *QueryPoolAprsResponse) GetData() []PoolApr { + if m != nil { + return m.Data + } + return nil +} + +type PoolApr struct { + PoolId uint64 `protobuf:"varint,1,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty"` + EdenApr github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=eden_apr,json=edenApr,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"eden_apr"` + UsdcApr github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=usdc_apr,json=usdcApr,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"usdc_apr"` + TotalApr github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,4,opt,name=total_apr,json=totalApr,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"total_apr"` +} + +func (m *PoolApr) Reset() { *m = PoolApr{} } +func (m *PoolApr) String() string { return proto.CompactTextString(m) } +func (*PoolApr) ProtoMessage() {} +func (*PoolApr) Descriptor() ([]byte, []int) { + return fileDescriptor_e4939d0b7ced5d80, []int{17} +} +func (m *PoolApr) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PoolApr) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PoolApr.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 *PoolApr) XXX_Merge(src proto.Message) { + xxx_messageInfo_PoolApr.Merge(m, src) +} +func (m *PoolApr) XXX_Size() int { + return m.Size() +} +func (m *PoolApr) XXX_DiscardUnknown() { + xxx_messageInfo_PoolApr.DiscardUnknown(m) +} + +var xxx_messageInfo_PoolApr proto.InternalMessageInfo + +func (m *PoolApr) GetPoolId() uint64 { + if m != nil { + return m.PoolId + } + return 0 +} + +func init() { + proto.RegisterType((*QueryParamsRequest)(nil), "elys.masterchef.QueryParamsRequest") + proto.RegisterType((*QueryParamsResponse)(nil), "elys.masterchef.QueryParamsResponse") + proto.RegisterType((*QueryExternalIncentiveRequest)(nil), "elys.masterchef.QueryExternalIncentiveRequest") + proto.RegisterType((*QueryExternalIncentiveResponse)(nil), "elys.masterchef.QueryExternalIncentiveResponse") + proto.RegisterType((*QueryPoolInfoRequest)(nil), "elys.masterchef.QueryPoolInfoRequest") + proto.RegisterType((*QueryPoolInfoResponse)(nil), "elys.masterchef.QueryPoolInfoResponse") + proto.RegisterType((*QueryPoolRewardInfoRequest)(nil), "elys.masterchef.QueryPoolRewardInfoRequest") + proto.RegisterType((*QueryPoolRewardInfoResponse)(nil), "elys.masterchef.QueryPoolRewardInfoResponse") + proto.RegisterType((*QueryUserRewardInfoRequest)(nil), "elys.masterchef.QueryUserRewardInfoRequest") + proto.RegisterType((*QueryUserRewardInfoResponse)(nil), "elys.masterchef.QueryUserRewardInfoResponse") + proto.RegisterType((*QueryUserPendingRewardRequest)(nil), "elys.masterchef.QueryUserPendingRewardRequest") + proto.RegisterType((*RewardInfo)(nil), "elys.masterchef.RewardInfo") + proto.RegisterType((*QueryUserPendingRewardResponse)(nil), "elys.masterchef.QueryUserPendingRewardResponse") + proto.RegisterType((*QueryStableStakeAprRequest)(nil), "elys.masterchef.QueryStableStakeAprRequest") + proto.RegisterType((*QueryStableStakeAprResponse)(nil), "elys.masterchef.QueryStableStakeAprResponse") + proto.RegisterType((*QueryPoolAprsRequest)(nil), "elys.masterchef.QueryPoolAprsRequest") + proto.RegisterType((*QueryPoolAprsResponse)(nil), "elys.masterchef.QueryPoolAprsResponse") + proto.RegisterType((*PoolApr)(nil), "elys.masterchef.PoolApr") +} + +func init() { proto.RegisterFile("elys/masterchef/query.proto", fileDescriptor_e4939d0b7ced5d80) } + +var fileDescriptor_e4939d0b7ced5d80 = []byte{ + // 1048 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x57, 0x4f, 0x6f, 0x1b, 0x45, + 0x14, 0xcf, 0x3a, 0xae, 0xff, 0xbc, 0x96, 0x40, 0x86, 0xa0, 0xa6, 0x4e, 0x71, 0xc2, 0x50, 0x42, + 0x80, 0x74, 0x37, 0x71, 0xa1, 0xea, 0x01, 0x21, 0x12, 0xca, 0xc1, 0x2a, 0x12, 0x65, 0xab, 0x0a, + 0xc4, 0xc5, 0x5a, 0x7b, 0x27, 0xee, 0x2a, 0xf6, 0xcc, 0x76, 0x67, 0xdd, 0x36, 0x42, 0x1c, 0x40, + 0xe2, 0xd2, 0x13, 0x12, 0x1f, 0x81, 0x5b, 0x91, 0xf8, 0x1c, 0xe5, 0x56, 0x89, 0x0b, 0xe2, 0x50, + 0x50, 0xc2, 0xd7, 0x40, 0x42, 0x33, 0xf3, 0x36, 0x59, 0x7b, 0x77, 0x1d, 0x37, 0x12, 0xa7, 0x78, + 0xe7, 0xbd, 0xf7, 0x7b, 0xbf, 0xf7, 0xe6, 0xcd, 0xfb, 0x29, 0xb0, 0xc2, 0x06, 0x07, 0xd2, 0x19, + 0x7a, 0x32, 0x66, 0x51, 0xef, 0x1e, 0xdb, 0x73, 0xee, 0x8f, 0x58, 0x74, 0x60, 0x87, 0x91, 0x88, + 0x05, 0x79, 0x59, 0x19, 0xed, 0x13, 0x63, 0x63, 0xa9, 0x2f, 0xfa, 0x42, 0xdb, 0x1c, 0xf5, 0xcb, + 0xb8, 0x35, 0x2e, 0xf7, 0x85, 0xe8, 0x0f, 0x98, 0xe3, 0x85, 0x81, 0xe3, 0x71, 0x2e, 0x62, 0x2f, + 0x0e, 0x04, 0x97, 0x68, 0x7d, 0xb7, 0x27, 0xe4, 0x50, 0x48, 0xa7, 0xeb, 0x49, 0x66, 0xd0, 0x9d, + 0x07, 0xdb, 0x5d, 0x16, 0x7b, 0xdb, 0x4e, 0xe8, 0xf5, 0x03, 0xae, 0x9d, 0xd1, 0xb7, 0x99, 0xf6, + 0x4d, 0xbc, 0x7a, 0x22, 0x48, 0xec, 0x97, 0x27, 0xd9, 0x86, 0x5e, 0xe4, 0x0d, 0x93, 0x4c, 0x1b, + 0x93, 0x56, 0xf6, 0x28, 0x66, 0x11, 0xf7, 0x06, 0x9d, 0x80, 0xf7, 0x18, 0x8f, 0x83, 0x07, 0x0c, + 0x3d, 0x1b, 0x19, 0x1c, 0x21, 0x06, 0xc6, 0x46, 0x97, 0x80, 0x7c, 0xa1, 0x58, 0xde, 0xd6, 0xd0, + 0x2e, 0xbb, 0x3f, 0x62, 0x32, 0xa6, 0x9f, 0xc1, 0xab, 0x63, 0xa7, 0x32, 0x14, 0x5c, 0x32, 0xf2, + 0x01, 0x54, 0x0c, 0x85, 0x65, 0x6b, 0xcd, 0xda, 0x38, 0xdf, 0xba, 0x68, 0x4f, 0xb4, 0xcc, 0x36, + 0x01, 0xbb, 0xe5, 0xa7, 0xcf, 0x57, 0xe7, 0x5c, 0x74, 0xa6, 0x0e, 0xbc, 0xae, 0xd1, 0x3e, 0x45, + 0x82, 0xed, 0x84, 0x1f, 0xa6, 0x23, 0x0b, 0x50, 0x0a, 0x7c, 0x8d, 0x59, 0x76, 0x4b, 0x81, 0x4f, + 0x0f, 0xa0, 0x59, 0x14, 0x80, 0x4c, 0xbe, 0x04, 0x92, 0x2d, 0x17, 0x59, 0xd1, 0x0c, 0xab, 0x0c, + 0x0e, 0x12, 0x5c, 0x64, 0x93, 0x06, 0xea, 0xc0, 0x92, 0xa9, 0x5c, 0x88, 0x41, 0x9b, 0xef, 0x89, + 0x84, 0xe2, 0x45, 0xa8, 0xaa, 0xae, 0x75, 0x8e, 0x79, 0x56, 0xd4, 0x67, 0xdb, 0xa7, 0x77, 0xe1, + 0xb5, 0x89, 0x00, 0xa4, 0xf8, 0x21, 0xd4, 0x4d, 0x04, 0xdf, 0x13, 0xc8, 0xec, 0x52, 0xb6, 0x5f, + 0x18, 0x85, 0x84, 0x6a, 0x21, 0x7e, 0xd3, 0xaf, 0xa0, 0x71, 0x0c, 0xeb, 0xb2, 0x87, 0x5e, 0xe4, + 0xcf, 0xc2, 0x86, 0xbc, 0x01, 0x17, 0x22, 0xed, 0xdd, 0xf1, 0x19, 0x17, 0xc3, 0xe5, 0xd2, 0x9a, + 0xb5, 0x51, 0x77, 0xcf, 0x9b, 0xb3, 0x9b, 0xea, 0x88, 0x72, 0x58, 0xc9, 0x45, 0x46, 0xda, 0x9f, + 0xc3, 0x2b, 0x1a, 0x1a, 0x61, 0x52, 0xec, 0x57, 0x73, 0xd9, 0x9f, 0x40, 0x60, 0x0d, 0x0b, 0xe1, + 0xd8, 0x29, 0x1d, 0x60, 0x25, 0x77, 0x25, 0x8b, 0xb2, 0x95, 0x10, 0x28, 0x8f, 0x24, 0x8b, 0x74, + 0x8a, 0xba, 0xab, 0x7f, 0xa7, 0xab, 0x2b, 0x4d, 0xad, 0x6e, 0xbe, 0xb8, 0xba, 0xc9, 0x6c, 0x27, + 0xd5, 0xa9, 0x14, 0x33, 0x55, 0x37, 0x0e, 0x91, 0x54, 0x37, 0x1a, 0x3b, 0xa5, 0xd7, 0x70, 0xb6, + 0x95, 0xf3, 0x6d, 0xc6, 0xfd, 0x80, 0xf7, 0x8d, 0x75, 0x4a, 0x81, 0xf4, 0xb1, 0x05, 0x70, 0x82, + 0x51, 0x7c, 0x9b, 0x3d, 0xa8, 0x18, 0xa2, 0xcb, 0xa5, 0xb5, 0x79, 0x3d, 0x3f, 0x66, 0x63, 0xd8, + 0x6a, 0x63, 0xd8, 0xb8, 0x31, 0xec, 0x4f, 0x44, 0xc0, 0x77, 0xb7, 0x14, 0xbb, 0x27, 0x7f, 0xad, + 0x6e, 0xf4, 0x83, 0xf8, 0xde, 0xa8, 0x6b, 0xf7, 0xc4, 0xd0, 0xc1, 0xf5, 0x62, 0xfe, 0x5c, 0x95, + 0xfe, 0xbe, 0x13, 0x1f, 0x84, 0x4c, 0xea, 0x00, 0xe9, 0x22, 0x34, 0xfd, 0xcd, 0xc2, 0xd7, 0x96, + 0x53, 0xc2, 0xf1, 0xbb, 0xaf, 0x1a, 0x67, 0xf5, 0xf0, 0x15, 0x91, 0x95, 0x4c, 0xb3, 0x52, 0xbd, + 0x4e, 0x7c, 0x49, 0x08, 0x2f, 0xc5, 0x22, 0xf6, 0x92, 0x59, 0x92, 0xff, 0x47, 0x15, 0x17, 0x74, + 0x06, 0x93, 0x5d, 0xd2, 0x16, 0xce, 0xda, 0x9d, 0xd8, 0xeb, 0x0e, 0xd8, 0x9d, 0xd8, 0xdb, 0x67, + 0x3b, 0x61, 0x94, 0x5c, 0xc5, 0x12, 0x9c, 0x33, 0x73, 0x63, 0xee, 0xc2, 0x7c, 0xd0, 0x0e, 0x4e, + 0xcc, 0x64, 0x0c, 0xd6, 0xfe, 0x31, 0xcc, 0x7b, 0x21, 0x5e, 0xdf, 0xae, 0xad, 0xf8, 0xfd, 0xf9, + 0x7c, 0x75, 0x7d, 0x06, 0x7e, 0x6d, 0x1e, 0xbb, 0x2a, 0x94, 0x6e, 0xa7, 0x56, 0xca, 0x4e, 0x18, + 0x25, 0x4b, 0x96, 0x5c, 0x82, 0x1a, 0x5e, 0xbb, 0x69, 0x6b, 0xd9, 0xad, 0x9a, 0x7b, 0x97, 0xf4, + 0x56, 0x6a, 0xa9, 0x98, 0x10, 0x64, 0xd3, 0x82, 0xb2, 0xef, 0xc5, 0x1e, 0x5e, 0xc3, 0x72, 0xee, + 0x8b, 0xdc, 0x09, 0x23, 0x1c, 0x56, 0xed, 0x4b, 0x7f, 0x28, 0x41, 0x15, 0xcf, 0x8b, 0x47, 0xad, + 0x0d, 0x35, 0xe6, 0x33, 0xde, 0x51, 0xb5, 0x96, 0x5e, 0xb8, 0xd6, 0x9b, 0xac, 0xe7, 0x56, 0x55, + 0xbc, 0xca, 0xd1, 0x86, 0xda, 0x48, 0xfa, 0x3d, 0x0d, 0x35, 0x7f, 0x36, 0x28, 0x15, 0xaf, 0xa0, + 0x6e, 0x41, 0xdd, 0x4c, 0x90, 0xc2, 0x2a, 0x9f, 0x09, 0xab, 0xa6, 0x01, 0x76, 0xc2, 0xa8, 0xf5, + 0x6f, 0x1d, 0xce, 0xe9, 0xae, 0x92, 0xef, 0x2c, 0xa8, 0x18, 0xa5, 0x22, 0x6f, 0x66, 0x5a, 0x98, + 0x95, 0xc3, 0xc6, 0x95, 0xe9, 0x4e, 0xe6, 0x6e, 0xe8, 0xe6, 0xf7, 0xbf, 0xff, 0xf3, 0x53, 0x69, + 0x9d, 0x5c, 0x71, 0x94, 0xf7, 0x55, 0xce, 0xe2, 0x87, 0x22, 0xda, 0x77, 0xf2, 0x45, 0x9c, 0xfc, + 0x6a, 0xc1, 0x62, 0x46, 0x97, 0x88, 0x9d, 0x9f, 0xa9, 0x48, 0x39, 0x1b, 0xce, 0xcc, 0xfe, 0x48, + 0xf2, 0x86, 0x26, 0xd9, 0x22, 0x5b, 0xd3, 0x49, 0x66, 0xc5, 0x95, 0x3c, 0xb6, 0xa0, 0x96, 0xc8, + 0x15, 0x79, 0xab, 0xa0, 0x23, 0xe3, 0xaa, 0xd9, 0x58, 0x3f, 0xcd, 0x0d, 0x59, 0x39, 0x9a, 0xd5, + 0x3b, 0xe4, 0xed, 0x53, 0x5a, 0x97, 0xe8, 0x29, 0xf9, 0xd9, 0x82, 0x85, 0x71, 0xf5, 0x21, 0xef, + 0x15, 0xe7, 0xca, 0xc8, 0x4e, 0x63, 0x73, 0x36, 0x67, 0xa4, 0x77, 0x5d, 0xd3, 0xdb, 0x22, 0xf6, + 0x0c, 0xf4, 0x52, 0xca, 0xa2, 0x59, 0x8e, 0xab, 0x48, 0x11, 0xcb, 0x5c, 0x71, 0x2c, 0x62, 0x99, + 0xaf, 0x6d, 0xb3, 0xb2, 0x9c, 0xd4, 0x3f, 0xf2, 0xc4, 0x82, 0xc5, 0xcc, 0xee, 0x2f, 0x9a, 0xc4, + 0x22, 0x9d, 0x2b, 0x9a, 0xc4, 0x42, 0x51, 0xa1, 0xef, 0x6b, 0xba, 0x36, 0xd9, 0x3c, 0xa5, 0xa9, + 0x26, 0x18, 0x19, 0x93, 0x5f, 0x2c, 0x58, 0x18, 0xdf, 0xd4, 0x45, 0x2d, 0xcd, 0xd5, 0x80, 0xa2, + 0x96, 0xe6, 0x2f, 0x7f, 0xfa, 0x91, 0xe6, 0x78, 0x83, 0x5c, 0x9f, 0xce, 0x51, 0xea, 0xe8, 0x8e, + 0x54, 0xe1, 0x6a, 0x55, 0x39, 0xdf, 0x68, 0x69, 0xf9, 0xf6, 0xf8, 0xcd, 0xa8, 0x1d, 0x3e, 0xed, + 0xcd, 0xa4, 0x64, 0x61, 0xda, 0x9b, 0x49, 0x4b, 0xc1, 0x0b, 0xbd, 0x19, 0x2f, 0x8c, 0xe4, 0x6e, + 0xfb, 0xe9, 0x61, 0xd3, 0x7a, 0x76, 0xd8, 0xb4, 0xfe, 0x3e, 0x6c, 0x5a, 0x3f, 0x1e, 0x35, 0xe7, + 0x9e, 0x1d, 0x35, 0xe7, 0xfe, 0x38, 0x6a, 0xce, 0x7d, 0xed, 0xa4, 0x76, 0x69, 0x16, 0xec, 0x51, + 0x1a, 0x4e, 0x2f, 0xd6, 0x6e, 0x45, 0xff, 0xf3, 0x70, 0xed, 0xbf, 0x00, 0x00, 0x00, 0xff, 0xff, + 0xfb, 0x33, 0x7f, 0x90, 0x50, 0x0d, 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 { + // Parameters queries the parameters of the module. + Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) + ExternalIncentive(ctx context.Context, in *QueryExternalIncentiveRequest, opts ...grpc.CallOption) (*QueryExternalIncentiveResponse, error) + PoolInfo(ctx context.Context, in *QueryPoolInfoRequest, opts ...grpc.CallOption) (*QueryPoolInfoResponse, error) + PoolRewardInfo(ctx context.Context, in *QueryPoolRewardInfoRequest, opts ...grpc.CallOption) (*QueryPoolRewardInfoResponse, error) + UserRewardInfo(ctx context.Context, in *QueryUserRewardInfoRequest, opts ...grpc.CallOption) (*QueryUserRewardInfoResponse, error) + UserPendingReward(ctx context.Context, in *QueryUserPendingRewardRequest, opts ...grpc.CallOption) (*QueryUserPendingRewardResponse, error) + StableStakeApr(ctx context.Context, in *QueryStableStakeAprRequest, opts ...grpc.CallOption) (*QueryStableStakeAprResponse, error) + PoolAprs(ctx context.Context, in *QueryPoolAprsRequest, opts ...grpc.CallOption) (*QueryPoolAprsResponse, 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, "/elys.masterchef.Query/Params", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) ExternalIncentive(ctx context.Context, in *QueryExternalIncentiveRequest, opts ...grpc.CallOption) (*QueryExternalIncentiveResponse, error) { + out := new(QueryExternalIncentiveResponse) + err := c.cc.Invoke(ctx, "/elys.masterchef.Query/ExternalIncentive", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) PoolInfo(ctx context.Context, in *QueryPoolInfoRequest, opts ...grpc.CallOption) (*QueryPoolInfoResponse, error) { + out := new(QueryPoolInfoResponse) + err := c.cc.Invoke(ctx, "/elys.masterchef.Query/PoolInfo", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) PoolRewardInfo(ctx context.Context, in *QueryPoolRewardInfoRequest, opts ...grpc.CallOption) (*QueryPoolRewardInfoResponse, error) { + out := new(QueryPoolRewardInfoResponse) + err := c.cc.Invoke(ctx, "/elys.masterchef.Query/PoolRewardInfo", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) UserRewardInfo(ctx context.Context, in *QueryUserRewardInfoRequest, opts ...grpc.CallOption) (*QueryUserRewardInfoResponse, error) { + out := new(QueryUserRewardInfoResponse) + err := c.cc.Invoke(ctx, "/elys.masterchef.Query/UserRewardInfo", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) UserPendingReward(ctx context.Context, in *QueryUserPendingRewardRequest, opts ...grpc.CallOption) (*QueryUserPendingRewardResponse, error) { + out := new(QueryUserPendingRewardResponse) + err := c.cc.Invoke(ctx, "/elys.masterchef.Query/UserPendingReward", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) StableStakeApr(ctx context.Context, in *QueryStableStakeAprRequest, opts ...grpc.CallOption) (*QueryStableStakeAprResponse, error) { + out := new(QueryStableStakeAprResponse) + err := c.cc.Invoke(ctx, "/elys.masterchef.Query/StableStakeApr", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) PoolAprs(ctx context.Context, in *QueryPoolAprsRequest, opts ...grpc.CallOption) (*QueryPoolAprsResponse, error) { + out := new(QueryPoolAprsResponse) + err := c.cc.Invoke(ctx, "/elys.masterchef.Query/PoolAprs", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + // Parameters queries the parameters of the module. + Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) + ExternalIncentive(context.Context, *QueryExternalIncentiveRequest) (*QueryExternalIncentiveResponse, error) + PoolInfo(context.Context, *QueryPoolInfoRequest) (*QueryPoolInfoResponse, error) + PoolRewardInfo(context.Context, *QueryPoolRewardInfoRequest) (*QueryPoolRewardInfoResponse, error) + UserRewardInfo(context.Context, *QueryUserRewardInfoRequest) (*QueryUserRewardInfoResponse, error) + UserPendingReward(context.Context, *QueryUserPendingRewardRequest) (*QueryUserPendingRewardResponse, error) + StableStakeApr(context.Context, *QueryStableStakeAprRequest) (*QueryStableStakeAprResponse, error) + PoolAprs(context.Context, *QueryPoolAprsRequest) (*QueryPoolAprsResponse, 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) ExternalIncentive(ctx context.Context, req *QueryExternalIncentiveRequest) (*QueryExternalIncentiveResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ExternalIncentive not implemented") +} +func (*UnimplementedQueryServer) PoolInfo(ctx context.Context, req *QueryPoolInfoRequest) (*QueryPoolInfoResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method PoolInfo not implemented") +} +func (*UnimplementedQueryServer) PoolRewardInfo(ctx context.Context, req *QueryPoolRewardInfoRequest) (*QueryPoolRewardInfoResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method PoolRewardInfo not implemented") +} +func (*UnimplementedQueryServer) UserRewardInfo(ctx context.Context, req *QueryUserRewardInfoRequest) (*QueryUserRewardInfoResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UserRewardInfo not implemented") +} +func (*UnimplementedQueryServer) UserPendingReward(ctx context.Context, req *QueryUserPendingRewardRequest) (*QueryUserPendingRewardResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UserPendingReward not implemented") +} +func (*UnimplementedQueryServer) StableStakeApr(ctx context.Context, req *QueryStableStakeAprRequest) (*QueryStableStakeAprResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method StableStakeApr not implemented") +} +func (*UnimplementedQueryServer) PoolAprs(ctx context.Context, req *QueryPoolAprsRequest) (*QueryPoolAprsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method PoolAprs 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: "/elys.masterchef.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_ExternalIncentive_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryExternalIncentiveRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).ExternalIncentive(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/elys.masterchef.Query/ExternalIncentive", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).ExternalIncentive(ctx, req.(*QueryExternalIncentiveRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_PoolInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryPoolInfoRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).PoolInfo(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/elys.masterchef.Query/PoolInfo", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).PoolInfo(ctx, req.(*QueryPoolInfoRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_PoolRewardInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryPoolRewardInfoRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).PoolRewardInfo(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/elys.masterchef.Query/PoolRewardInfo", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).PoolRewardInfo(ctx, req.(*QueryPoolRewardInfoRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_UserRewardInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryUserRewardInfoRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).UserRewardInfo(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/elys.masterchef.Query/UserRewardInfo", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).UserRewardInfo(ctx, req.(*QueryUserRewardInfoRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_UserPendingReward_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryUserPendingRewardRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).UserPendingReward(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/elys.masterchef.Query/UserPendingReward", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).UserPendingReward(ctx, req.(*QueryUserPendingRewardRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_StableStakeApr_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryStableStakeAprRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).StableStakeApr(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/elys.masterchef.Query/StableStakeApr", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).StableStakeApr(ctx, req.(*QueryStableStakeAprRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_PoolAprs_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryPoolAprsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).PoolAprs(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/elys.masterchef.Query/PoolAprs", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).PoolAprs(ctx, req.(*QueryPoolAprsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "elys.masterchef.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Params", + Handler: _Query_Params_Handler, + }, + { + MethodName: "ExternalIncentive", + Handler: _Query_ExternalIncentive_Handler, + }, + { + MethodName: "PoolInfo", + Handler: _Query_PoolInfo_Handler, + }, + { + MethodName: "PoolRewardInfo", + Handler: _Query_PoolRewardInfo_Handler, + }, + { + MethodName: "UserRewardInfo", + Handler: _Query_UserRewardInfo_Handler, + }, + { + MethodName: "UserPendingReward", + Handler: _Query_UserPendingReward_Handler, + }, + { + MethodName: "StableStakeApr", + Handler: _Query_StableStakeApr_Handler, + }, + { + MethodName: "PoolAprs", + Handler: _Query_PoolAprs_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "elys/masterchef/query.proto", +} + +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 *QueryExternalIncentiveRequest) 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 *QueryExternalIncentiveRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryExternalIncentiveRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Id != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.Id)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *QueryExternalIncentiveResponse) 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 *QueryExternalIncentiveResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryExternalIncentiveResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.ExternalIncentive.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 *QueryPoolInfoRequest) 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 *QueryPoolInfoRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryPoolInfoRequest) 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 *QueryPoolInfoResponse) 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 *QueryPoolInfoResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryPoolInfoResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.PoolInfo.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 *QueryPoolRewardInfoRequest) 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 *QueryPoolRewardInfoRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryPoolRewardInfoRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.RewardDenom) > 0 { + i -= len(m.RewardDenom) + copy(dAtA[i:], m.RewardDenom) + i = encodeVarintQuery(dAtA, i, uint64(len(m.RewardDenom))) + 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 *QueryPoolRewardInfoResponse) 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 *QueryPoolRewardInfoResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryPoolRewardInfoResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.PoolRewardInfo.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 *QueryUserRewardInfoRequest) 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 *QueryUserRewardInfoRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryUserRewardInfoRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.RewardDenom) > 0 { + i -= len(m.RewardDenom) + copy(dAtA[i:], m.RewardDenom) + i = encodeVarintQuery(dAtA, i, uint64(len(m.RewardDenom))) + i-- + dAtA[i] = 0x1a + } + if m.PoolId != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.PoolId)) + i-- + dAtA[i] = 0x10 + } + if len(m.User) > 0 { + i -= len(m.User) + copy(dAtA[i:], m.User) + i = encodeVarintQuery(dAtA, i, uint64(len(m.User))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryUserRewardInfoResponse) 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 *QueryUserRewardInfoResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryUserRewardInfoResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.UserRewardInfo.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 *QueryUserPendingRewardRequest) 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 *QueryUserPendingRewardRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryUserPendingRewardRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.User) > 0 { + i -= len(m.User) + copy(dAtA[i:], m.User) + i = encodeVarintQuery(dAtA, i, uint64(len(m.User))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *RewardInfo) 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 *RewardInfo) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *RewardInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Reward) > 0 { + for iNdEx := len(m.Reward) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Reward[iNdEx].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 *QueryUserPendingRewardResponse) 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 *QueryUserPendingRewardResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryUserPendingRewardResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.TotalRewards) > 0 { + for iNdEx := len(m.TotalRewards) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.TotalRewards[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + 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 = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *QueryStableStakeAprRequest) 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 *QueryStableStakeAprRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryStableStakeAprRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Denom) > 0 { + i -= len(m.Denom) + copy(dAtA[i:], m.Denom) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Denom))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryStableStakeAprResponse) 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 *QueryStableStakeAprResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryStableStakeAprResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.Apr.Size() + i -= size + if _, err := m.Apr.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 *QueryPoolAprsRequest) 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 *QueryPoolAprsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryPoolAprsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.PoolIds) > 0 { + dAtA7 := make([]byte, len(m.PoolIds)*10) + var j6 int + for _, num := range m.PoolIds { + for num >= 1<<7 { + dAtA7[j6] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j6++ + } + dAtA7[j6] = uint8(num) + j6++ + } + i -= j6 + copy(dAtA[i:], dAtA7[:j6]) + i = encodeVarintQuery(dAtA, i, uint64(j6)) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryPoolAprsResponse) 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 *QueryPoolAprsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryPoolAprsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Data) > 0 { + for iNdEx := len(m.Data) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Data[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 *PoolApr) 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 *PoolApr) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PoolApr) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.TotalApr.Size() + i -= size + if _, err := m.TotalApr.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + { + size := m.UsdcApr.Size() + i -= size + if _, err := m.UsdcApr.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + { + size := m.EdenApr.Size() + i -= size + if _, err := m.EdenApr.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + 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 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 *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 *QueryExternalIncentiveRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Id != 0 { + n += 1 + sovQuery(uint64(m.Id)) + } + return n +} + +func (m *QueryExternalIncentiveResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.ExternalIncentive.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryPoolInfoRequest) 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 *QueryPoolInfoResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.PoolInfo.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryPoolRewardInfoRequest) 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.RewardDenom) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryPoolRewardInfoResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.PoolRewardInfo.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryUserRewardInfoRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.User) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.PoolId != 0 { + n += 1 + sovQuery(uint64(m.PoolId)) + } + l = len(m.RewardDenom) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryUserRewardInfoResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.UserRewardInfo.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryUserPendingRewardRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.User) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *RewardInfo) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PoolId != 0 { + n += 1 + sovQuery(uint64(m.PoolId)) + } + if len(m.Reward) > 0 { + for _, e := range m.Reward { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + +func (m *QueryUserPendingRewardResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Rewards) > 0 { + for _, e := range m.Rewards { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if len(m.TotalRewards) > 0 { + for _, e := range m.TotalRewards { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + +func (m *QueryStableStakeAprRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Denom) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryStableStakeAprResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Apr.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryPoolAprsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.PoolIds) > 0 { + l = 0 + for _, e := range m.PoolIds { + l += sovQuery(uint64(e)) + } + n += 1 + sovQuery(uint64(l)) + l + } + return n +} + +func (m *QueryPoolAprsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Data) > 0 { + for _, e := range m.Data { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + +func (m *PoolApr) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PoolId != 0 { + n += 1 + sovQuery(uint64(m.PoolId)) + } + l = m.EdenApr.Size() + n += 1 + l + sovQuery(uint64(l)) + l = m.UsdcApr.Size() + n += 1 + l + sovQuery(uint64(l)) + l = m.TotalApr.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 *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 *QueryExternalIncentiveRequest) 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: QueryExternalIncentiveRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryExternalIncentiveRequest: 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 ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Id |= 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 *QueryExternalIncentiveResponse) 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: QueryExternalIncentiveResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryExternalIncentiveResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ExternalIncentive", 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.ExternalIncentive.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 *QueryPoolInfoRequest) 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: QueryPoolInfoRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryPoolInfoRequest: 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 *QueryPoolInfoResponse) 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: QueryPoolInfoResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryPoolInfoResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PoolInfo", 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.PoolInfo.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 *QueryPoolRewardInfoRequest) 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: QueryPoolRewardInfoRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryPoolRewardInfoRequest: 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 RewardDenom", 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.RewardDenom = string(dAtA[iNdEx:postIndex]) + 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 *QueryPoolRewardInfoResponse) 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: QueryPoolRewardInfoResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryPoolRewardInfoResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PoolRewardInfo", 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.PoolRewardInfo.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 *QueryUserRewardInfoRequest) 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: QueryUserRewardInfoRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryUserRewardInfoRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field User", 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.User = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + 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 + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RewardDenom", 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.RewardDenom = string(dAtA[iNdEx:postIndex]) + 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 *QueryUserRewardInfoResponse) 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: QueryUserRewardInfoResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryUserRewardInfoResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UserRewardInfo", 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.UserRewardInfo.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 *QueryUserPendingRewardRequest) 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: QueryUserPendingRewardRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryUserPendingRewardRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field User", 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.User = string(dAtA[iNdEx:postIndex]) + 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 *RewardInfo) 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: RewardInfo: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: RewardInfo: 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 Reward", 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.Reward = append(m.Reward, types.Coin{}) + if err := m.Reward[len(m.Reward)-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 *QueryUserPendingRewardResponse) 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: QueryUserPendingRewardResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryUserPendingRewardResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 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.Rewards = append(m.Rewards, &RewardInfo{}) + if err := m.Rewards[len(m.Rewards)-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 TotalRewards", 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.TotalRewards = append(m.TotalRewards, types.Coin{}) + if err := m.TotalRewards[len(m.TotalRewards)-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 *QueryStableStakeAprRequest) 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: QueryStableStakeAprRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryStableStakeAprRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Denom", 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.Denom = string(dAtA[iNdEx:postIndex]) + 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 *QueryStableStakeAprResponse) 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: QueryStableStakeAprResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryStableStakeAprResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Apr", 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.Apr.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 *QueryPoolAprsRequest) 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: QueryPoolAprsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryPoolAprsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType == 0 { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.PoolIds = append(m.PoolIds, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var elementCount int + var count int + for _, integer := range dAtA[iNdEx:postIndex] { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.PoolIds) == 0 { + m.PoolIds = make([]uint64, 0, elementCount) + } + for iNdEx < postIndex { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.PoolIds = append(m.PoolIds, v) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field PoolIds", wireType) + } + 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 *QueryPoolAprsResponse) 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: QueryPoolAprsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryPoolAprsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Data", 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.Data = append(m.Data, PoolApr{}) + if err := m.Data[len(m.Data)-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 *PoolApr) 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: PoolApr: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PoolApr: 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 EdenApr", 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.EdenApr.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UsdcApr", 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.UsdcApr.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TotalApr", 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.TotalApr.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/masterchef/types/query.pb.gw.go b/x/masterchef/types/query.pb.gw.go new file mode 100644 index 000000000..17de849f0 --- /dev/null +++ b/x/masterchef/types/query.pb.gw.go @@ -0,0 +1,726 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: elys/masterchef/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_ExternalIncentive_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Query_ExternalIncentive_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryExternalIncentiveRequest + 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_ExternalIncentive_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.ExternalIncentive(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_ExternalIncentive_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryExternalIncentiveRequest + 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_ExternalIncentive_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.ExternalIncentive(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_PoolInfo_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Query_PoolInfo_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryPoolInfoRequest + 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_PoolInfo_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.PoolInfo(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_PoolInfo_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryPoolInfoRequest + 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_PoolInfo_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.PoolInfo(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_PoolRewardInfo_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Query_PoolRewardInfo_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryPoolRewardInfoRequest + 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_PoolRewardInfo_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.PoolRewardInfo(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_PoolRewardInfo_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryPoolRewardInfoRequest + 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_PoolRewardInfo_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.PoolRewardInfo(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_UserRewardInfo_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Query_UserRewardInfo_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryUserRewardInfoRequest + 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_UserRewardInfo_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.UserRewardInfo(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_UserRewardInfo_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryUserRewardInfoRequest + 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_UserRewardInfo_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.UserRewardInfo(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_UserPendingReward_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Query_UserPendingReward_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryUserPendingRewardRequest + 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_UserPendingReward_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.UserPendingReward(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_UserPendingReward_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryUserPendingRewardRequest + 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_UserPendingReward_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.UserPendingReward(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_StableStakeApr_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryStableStakeAprRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["denom"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "denom") + } + + protoReq.Denom, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "denom", err) + } + + msg, err := client.StableStakeApr(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_StableStakeApr_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryStableStakeAprRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["denom"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "denom") + } + + protoReq.Denom, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "denom", err) + } + + msg, err := server.StableStakeApr(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_PoolAprs_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Query_PoolAprs_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryPoolAprsRequest + 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_PoolAprs_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.PoolAprs(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_PoolAprs_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryPoolAprsRequest + 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_PoolAprs_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.PoolAprs(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_ExternalIncentive_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_ExternalIncentive_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_ExternalIncentive_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_PoolInfo_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_PoolInfo_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_PoolInfo_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_PoolRewardInfo_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_PoolRewardInfo_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_PoolRewardInfo_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_UserRewardInfo_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_UserRewardInfo_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_UserRewardInfo_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_UserPendingReward_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_UserPendingReward_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_UserPendingReward_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_StableStakeApr_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_StableStakeApr_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_StableStakeApr_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_PoolAprs_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_PoolAprs_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_PoolAprs_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_ExternalIncentive_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_ExternalIncentive_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_ExternalIncentive_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_PoolInfo_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_PoolInfo_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_PoolInfo_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_PoolRewardInfo_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_PoolRewardInfo_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_PoolRewardInfo_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_UserRewardInfo_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_UserRewardInfo_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_UserRewardInfo_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_UserPendingReward_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_UserPendingReward_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_UserPendingReward_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_StableStakeApr_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_StableStakeApr_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_StableStakeApr_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_PoolAprs_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_PoolAprs_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_PoolAprs_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{"elys-network", "elys", "masterchef", "params"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_ExternalIncentive_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"elys-network", "elys", "masterchef", "external_incentive"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_PoolInfo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"elys-network", "elys", "masterchef", "pool_info"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_PoolRewardInfo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"elys-network", "elys", "masterchef", "pool_reward_info"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_UserRewardInfo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"elys-network", "elys", "masterchef", "user_reward_info"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_UserPendingReward_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"elys-network", "elys", "masterchef", "pending_reward"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_StableStakeApr_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"elys-network", "elys", "masterchef", "stable_stake_apr", "denom"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_PoolAprs_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"elys-network", "elys", "masterchef", "pool_aprs"}, "", runtime.AssumeColonVerbOpt(true))) +) + +var ( + forward_Query_Params_0 = runtime.ForwardResponseMessage + + forward_Query_ExternalIncentive_0 = runtime.ForwardResponseMessage + + forward_Query_PoolInfo_0 = runtime.ForwardResponseMessage + + forward_Query_PoolRewardInfo_0 = runtime.ForwardResponseMessage + + forward_Query_UserRewardInfo_0 = runtime.ForwardResponseMessage + + forward_Query_UserPendingReward_0 = runtime.ForwardResponseMessage + + forward_Query_StableStakeApr_0 = runtime.ForwardResponseMessage + + forward_Query_PoolAprs_0 = runtime.ForwardResponseMessage +) diff --git a/x/masterchef/types/tx.pb.go b/x/masterchef/types/tx.pb.go new file mode 100644 index 000000000..3fc4eb7f8 --- /dev/null +++ b/x/masterchef/types/tx.pb.go @@ -0,0 +1,2619 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: elys/masterchef/tx.proto + +package types + +import ( + context "context" + fmt "fmt" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/cosmos/gogoproto/gogoproto" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/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 + +type MsgAddExternalRewardDenom struct { + Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` + RewardDenom string `protobuf:"bytes,2,opt,name=reward_denom,json=rewardDenom,proto3" json:"reward_denom,omitempty"` + MinAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=min_amount,json=minAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"min_amount"` + Supported bool `protobuf:"varint,4,opt,name=supported,proto3" json:"supported,omitempty"` +} + +func (m *MsgAddExternalRewardDenom) Reset() { *m = MsgAddExternalRewardDenom{} } +func (m *MsgAddExternalRewardDenom) String() string { return proto.CompactTextString(m) } +func (*MsgAddExternalRewardDenom) ProtoMessage() {} +func (*MsgAddExternalRewardDenom) Descriptor() ([]byte, []int) { + return fileDescriptor_2574ed545e5b2c11, []int{0} +} +func (m *MsgAddExternalRewardDenom) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgAddExternalRewardDenom) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgAddExternalRewardDenom.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 *MsgAddExternalRewardDenom) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgAddExternalRewardDenom.Merge(m, src) +} +func (m *MsgAddExternalRewardDenom) XXX_Size() int { + return m.Size() +} +func (m *MsgAddExternalRewardDenom) XXX_DiscardUnknown() { + xxx_messageInfo_MsgAddExternalRewardDenom.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgAddExternalRewardDenom proto.InternalMessageInfo + +func (m *MsgAddExternalRewardDenom) GetAuthority() string { + if m != nil { + return m.Authority + } + return "" +} + +func (m *MsgAddExternalRewardDenom) GetRewardDenom() string { + if m != nil { + return m.RewardDenom + } + return "" +} + +func (m *MsgAddExternalRewardDenom) GetSupported() bool { + if m != nil { + return m.Supported + } + return false +} + +type MsgAddExternalRewardDenomResponse struct { +} + +func (m *MsgAddExternalRewardDenomResponse) Reset() { *m = MsgAddExternalRewardDenomResponse{} } +func (m *MsgAddExternalRewardDenomResponse) String() string { return proto.CompactTextString(m) } +func (*MsgAddExternalRewardDenomResponse) ProtoMessage() {} +func (*MsgAddExternalRewardDenomResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_2574ed545e5b2c11, []int{1} +} +func (m *MsgAddExternalRewardDenomResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgAddExternalRewardDenomResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgAddExternalRewardDenomResponse.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 *MsgAddExternalRewardDenomResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgAddExternalRewardDenomResponse.Merge(m, src) +} +func (m *MsgAddExternalRewardDenomResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgAddExternalRewardDenomResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgAddExternalRewardDenomResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgAddExternalRewardDenomResponse proto.InternalMessageInfo + +type MsgAddExternalIncentive struct { + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + RewardDenom string `protobuf:"bytes,2,opt,name=reward_denom,json=rewardDenom,proto3" json:"reward_denom,omitempty"` + PoolId uint64 `protobuf:"varint,3,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty"` + FromBlock uint64 `protobuf:"varint,4,opt,name=from_block,json=fromBlock,proto3" json:"from_block,omitempty"` + ToBlock uint64 `protobuf:"varint,5,opt,name=to_block,json=toBlock,proto3" json:"to_block,omitempty"` + AmountPerBlock github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,6,opt,name=amount_per_block,json=amountPerBlock,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"amount_per_block"` +} + +func (m *MsgAddExternalIncentive) Reset() { *m = MsgAddExternalIncentive{} } +func (m *MsgAddExternalIncentive) String() string { return proto.CompactTextString(m) } +func (*MsgAddExternalIncentive) ProtoMessage() {} +func (*MsgAddExternalIncentive) Descriptor() ([]byte, []int) { + return fileDescriptor_2574ed545e5b2c11, []int{2} +} +func (m *MsgAddExternalIncentive) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgAddExternalIncentive) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgAddExternalIncentive.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 *MsgAddExternalIncentive) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgAddExternalIncentive.Merge(m, src) +} +func (m *MsgAddExternalIncentive) XXX_Size() int { + return m.Size() +} +func (m *MsgAddExternalIncentive) XXX_DiscardUnknown() { + xxx_messageInfo_MsgAddExternalIncentive.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgAddExternalIncentive proto.InternalMessageInfo + +func (m *MsgAddExternalIncentive) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +func (m *MsgAddExternalIncentive) GetRewardDenom() string { + if m != nil { + return m.RewardDenom + } + return "" +} + +func (m *MsgAddExternalIncentive) GetPoolId() uint64 { + if m != nil { + return m.PoolId + } + return 0 +} + +func (m *MsgAddExternalIncentive) GetFromBlock() uint64 { + if m != nil { + return m.FromBlock + } + return 0 +} + +func (m *MsgAddExternalIncentive) GetToBlock() uint64 { + if m != nil { + return m.ToBlock + } + return 0 +} + +type MsgAddExternalIncentiveResponse struct { +} + +func (m *MsgAddExternalIncentiveResponse) Reset() { *m = MsgAddExternalIncentiveResponse{} } +func (m *MsgAddExternalIncentiveResponse) String() string { return proto.CompactTextString(m) } +func (*MsgAddExternalIncentiveResponse) ProtoMessage() {} +func (*MsgAddExternalIncentiveResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_2574ed545e5b2c11, []int{3} +} +func (m *MsgAddExternalIncentiveResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgAddExternalIncentiveResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgAddExternalIncentiveResponse.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 *MsgAddExternalIncentiveResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgAddExternalIncentiveResponse.Merge(m, src) +} +func (m *MsgAddExternalIncentiveResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgAddExternalIncentiveResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgAddExternalIncentiveResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgAddExternalIncentiveResponse proto.InternalMessageInfo + +type MsgUpdateParams struct { + Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` + Params Params `protobuf:"bytes,2,opt,name=params,proto3" json:"params"` +} + +func (m *MsgUpdateParams) Reset() { *m = MsgUpdateParams{} } +func (m *MsgUpdateParams) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateParams) ProtoMessage() {} +func (*MsgUpdateParams) Descriptor() ([]byte, []int) { + return fileDescriptor_2574ed545e5b2c11, []int{4} +} +func (m *MsgUpdateParams) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateParams.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 *MsgUpdateParams) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateParams.Merge(m, src) +} +func (m *MsgUpdateParams) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateParams) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateParams.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateParams proto.InternalMessageInfo + +func (m *MsgUpdateParams) GetAuthority() string { + if m != nil { + return m.Authority + } + return "" +} + +func (m *MsgUpdateParams) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +type MsgUpdateParamsResponse struct { +} + +func (m *MsgUpdateParamsResponse) Reset() { *m = MsgUpdateParamsResponse{} } +func (m *MsgUpdateParamsResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateParamsResponse) ProtoMessage() {} +func (*MsgUpdateParamsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_2574ed545e5b2c11, []int{5} +} +func (m *MsgUpdateParamsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateParamsResponse.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 *MsgUpdateParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateParamsResponse.Merge(m, src) +} +func (m *MsgUpdateParamsResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateParamsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateParamsResponse proto.InternalMessageInfo + +type PoolMultiplier struct { + PoolId uint64 `protobuf:"varint,1,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty"` + Multiplier github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=multiplier,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"multiplier"` +} + +func (m *PoolMultiplier) Reset() { *m = PoolMultiplier{} } +func (m *PoolMultiplier) String() string { return proto.CompactTextString(m) } +func (*PoolMultiplier) ProtoMessage() {} +func (*PoolMultiplier) Descriptor() ([]byte, []int) { + return fileDescriptor_2574ed545e5b2c11, []int{6} +} +func (m *PoolMultiplier) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PoolMultiplier) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PoolMultiplier.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 *PoolMultiplier) XXX_Merge(src proto.Message) { + xxx_messageInfo_PoolMultiplier.Merge(m, src) +} +func (m *PoolMultiplier) XXX_Size() int { + return m.Size() +} +func (m *PoolMultiplier) XXX_DiscardUnknown() { + xxx_messageInfo_PoolMultiplier.DiscardUnknown(m) +} + +var xxx_messageInfo_PoolMultiplier proto.InternalMessageInfo + +func (m *PoolMultiplier) GetPoolId() uint64 { + if m != nil { + return m.PoolId + } + return 0 +} + +type MsgUpdatePoolMultipliers struct { + Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` + PoolMultipliers []PoolMultiplier `protobuf:"bytes,2,rep,name=pool_multipliers,json=poolMultipliers,proto3" json:"pool_multipliers"` +} + +func (m *MsgUpdatePoolMultipliers) Reset() { *m = MsgUpdatePoolMultipliers{} } +func (m *MsgUpdatePoolMultipliers) String() string { return proto.CompactTextString(m) } +func (*MsgUpdatePoolMultipliers) ProtoMessage() {} +func (*MsgUpdatePoolMultipliers) Descriptor() ([]byte, []int) { + return fileDescriptor_2574ed545e5b2c11, []int{7} +} +func (m *MsgUpdatePoolMultipliers) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdatePoolMultipliers) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdatePoolMultipliers.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 *MsgUpdatePoolMultipliers) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdatePoolMultipliers.Merge(m, src) +} +func (m *MsgUpdatePoolMultipliers) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdatePoolMultipliers) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdatePoolMultipliers.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdatePoolMultipliers proto.InternalMessageInfo + +func (m *MsgUpdatePoolMultipliers) GetAuthority() string { + if m != nil { + return m.Authority + } + return "" +} + +func (m *MsgUpdatePoolMultipliers) GetPoolMultipliers() []PoolMultiplier { + if m != nil { + return m.PoolMultipliers + } + return nil +} + +type MsgUpdatePoolMultipliersResponse struct { +} + +func (m *MsgUpdatePoolMultipliersResponse) Reset() { *m = MsgUpdatePoolMultipliersResponse{} } +func (m *MsgUpdatePoolMultipliersResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUpdatePoolMultipliersResponse) ProtoMessage() {} +func (*MsgUpdatePoolMultipliersResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_2574ed545e5b2c11, []int{8} +} +func (m *MsgUpdatePoolMultipliersResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdatePoolMultipliersResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdatePoolMultipliersResponse.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 *MsgUpdatePoolMultipliersResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdatePoolMultipliersResponse.Merge(m, src) +} +func (m *MsgUpdatePoolMultipliersResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdatePoolMultipliersResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdatePoolMultipliersResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdatePoolMultipliersResponse proto.InternalMessageInfo + +type MsgClaimRewards struct { + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + PoolIds []uint64 `protobuf:"varint,2,rep,packed,name=pool_ids,json=poolIds,proto3" json:"pool_ids,omitempty"` +} + +func (m *MsgClaimRewards) Reset() { *m = MsgClaimRewards{} } +func (m *MsgClaimRewards) String() string { return proto.CompactTextString(m) } +func (*MsgClaimRewards) ProtoMessage() {} +func (*MsgClaimRewards) Descriptor() ([]byte, []int) { + return fileDescriptor_2574ed545e5b2c11, []int{9} +} +func (m *MsgClaimRewards) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgClaimRewards) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgClaimRewards.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 *MsgClaimRewards) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgClaimRewards.Merge(m, src) +} +func (m *MsgClaimRewards) XXX_Size() int { + return m.Size() +} +func (m *MsgClaimRewards) XXX_DiscardUnknown() { + xxx_messageInfo_MsgClaimRewards.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgClaimRewards proto.InternalMessageInfo + +func (m *MsgClaimRewards) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +func (m *MsgClaimRewards) GetPoolIds() []uint64 { + if m != nil { + return m.PoolIds + } + return nil +} + +type MsgClaimRewardsResponse struct { +} + +func (m *MsgClaimRewardsResponse) Reset() { *m = MsgClaimRewardsResponse{} } +func (m *MsgClaimRewardsResponse) String() string { return proto.CompactTextString(m) } +func (*MsgClaimRewardsResponse) ProtoMessage() {} +func (*MsgClaimRewardsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_2574ed545e5b2c11, []int{10} +} +func (m *MsgClaimRewardsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgClaimRewardsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgClaimRewardsResponse.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 *MsgClaimRewardsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgClaimRewardsResponse.Merge(m, src) +} +func (m *MsgClaimRewardsResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgClaimRewardsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgClaimRewardsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgClaimRewardsResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*MsgAddExternalRewardDenom)(nil), "elys.masterchef.MsgAddExternalRewardDenom") + proto.RegisterType((*MsgAddExternalRewardDenomResponse)(nil), "elys.masterchef.MsgAddExternalRewardDenomResponse") + proto.RegisterType((*MsgAddExternalIncentive)(nil), "elys.masterchef.MsgAddExternalIncentive") + proto.RegisterType((*MsgAddExternalIncentiveResponse)(nil), "elys.masterchef.MsgAddExternalIncentiveResponse") + proto.RegisterType((*MsgUpdateParams)(nil), "elys.masterchef.MsgUpdateParams") + proto.RegisterType((*MsgUpdateParamsResponse)(nil), "elys.masterchef.MsgUpdateParamsResponse") + proto.RegisterType((*PoolMultiplier)(nil), "elys.masterchef.PoolMultiplier") + proto.RegisterType((*MsgUpdatePoolMultipliers)(nil), "elys.masterchef.MsgUpdatePoolMultipliers") + proto.RegisterType((*MsgUpdatePoolMultipliersResponse)(nil), "elys.masterchef.MsgUpdatePoolMultipliersResponse") + proto.RegisterType((*MsgClaimRewards)(nil), "elys.masterchef.MsgClaimRewards") + proto.RegisterType((*MsgClaimRewardsResponse)(nil), "elys.masterchef.MsgClaimRewardsResponse") +} + +func init() { proto.RegisterFile("elys/masterchef/tx.proto", fileDescriptor_2574ed545e5b2c11) } + +var fileDescriptor_2574ed545e5b2c11 = []byte{ + // 662 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x55, 0xc1, 0x4e, 0xdb, 0x4a, + 0x14, 0x8d, 0x21, 0x2f, 0x90, 0x0b, 0x02, 0x64, 0xf1, 0x20, 0x89, 0xa8, 0x13, 0x5c, 0xa9, 0x4a, + 0x2b, 0x61, 0xb7, 0xa9, 0xfa, 0x01, 0xa4, 0x74, 0x91, 0x45, 0xaa, 0xc8, 0x52, 0xa5, 0x8a, 0x4d, + 0x64, 0xec, 0xc1, 0x58, 0xd8, 0x1e, 0x6b, 0x66, 0x5c, 0x92, 0x65, 0xb7, 0x5d, 0xf5, 0x1b, 0xfa, + 0x35, 0x74, 0xc7, 0xb2, 0xea, 0x02, 0x55, 0xf0, 0x23, 0xd5, 0x8c, 0x1d, 0xc7, 0x06, 0xbb, 0x49, + 0xbb, 0x4a, 0x66, 0xee, 0xd1, 0x99, 0x73, 0xcf, 0x9c, 0xeb, 0x81, 0x06, 0xf2, 0xa6, 0x54, 0xf7, + 0x4d, 0xca, 0x10, 0xb1, 0x2e, 0xd0, 0xb9, 0xce, 0x26, 0x5a, 0x48, 0x30, 0xc3, 0xf2, 0x36, 0xaf, + 0x68, 0xf3, 0x4a, 0x6b, 0xd7, 0xc1, 0x0e, 0x16, 0x35, 0x9d, 0xff, 0x8b, 0x61, 0xad, 0x83, 0x87, + 0x04, 0xa1, 0x49, 0x4c, 0x9f, 0xc6, 0x55, 0xf5, 0xbb, 0x04, 0xcd, 0x21, 0x75, 0x8e, 0x6d, 0xfb, + 0xdd, 0x84, 0x21, 0x12, 0x98, 0x9e, 0x81, 0xae, 0x4c, 0x62, 0x9f, 0xa0, 0x00, 0xfb, 0xf2, 0x01, + 0xd4, 0xcd, 0x88, 0x5d, 0x60, 0xe2, 0xb2, 0x69, 0x43, 0xea, 0x48, 0xdd, 0xba, 0x31, 0xdf, 0x90, + 0x0f, 0x61, 0x93, 0x08, 0xf0, 0xd8, 0xe6, 0xe8, 0xc6, 0x8a, 0x00, 0x6c, 0x90, 0x0c, 0xc1, 0x10, + 0xc0, 0x77, 0x83, 0xb1, 0xe9, 0xe3, 0x28, 0x60, 0x8d, 0x55, 0x0e, 0xe8, 0x6b, 0xd7, 0xb7, 0xed, + 0xca, 0xcf, 0xdb, 0xf6, 0x33, 0xc7, 0x65, 0x17, 0xd1, 0x99, 0x66, 0x61, 0x5f, 0xb7, 0x30, 0xf5, + 0x31, 0x4d, 0x7e, 0x8e, 0xa8, 0x7d, 0xa9, 0xb3, 0x69, 0x88, 0xa8, 0x36, 0x08, 0x98, 0x51, 0xf7, + 0xdd, 0xe0, 0x58, 0x10, 0x70, 0x3d, 0x34, 0x0a, 0x43, 0x4c, 0x18, 0xb2, 0x1b, 0xd5, 0x8e, 0xd4, + 0x5d, 0x37, 0xe6, 0x1b, 0xea, 0x53, 0x38, 0x2c, 0x6d, 0xc5, 0x40, 0x34, 0xc4, 0x01, 0x45, 0xea, + 0xe7, 0x15, 0xd8, 0xcf, 0xa3, 0x06, 0x81, 0x85, 0x02, 0xe6, 0x7e, 0x42, 0xf2, 0x1e, 0xd4, 0x28, + 0x0a, 0x6c, 0x44, 0x92, 0x5e, 0x93, 0xd5, 0x32, 0x8d, 0xee, 0xc3, 0x5a, 0x88, 0xb1, 0x37, 0x76, + 0x6d, 0xd1, 0x65, 0xd5, 0xa8, 0xf1, 0xe5, 0xc0, 0x96, 0x9f, 0x00, 0x9c, 0x13, 0xec, 0x8f, 0xcf, + 0x3c, 0x6c, 0x5d, 0x0a, 0xcd, 0x55, 0xa3, 0xce, 0x77, 0xfa, 0x7c, 0x43, 0x6e, 0xc2, 0x3a, 0xc3, + 0x49, 0xf1, 0x3f, 0x51, 0x5c, 0x63, 0x38, 0x2e, 0x7d, 0x84, 0x9d, 0xd8, 0xb7, 0x71, 0x88, 0x48, + 0x02, 0xa9, 0xfd, 0x93, 0x83, 0x5b, 0x31, 0xcf, 0x08, 0x11, 0xc1, 0xac, 0x1e, 0x42, 0xbb, 0xc4, + 0x82, 0xd4, 0xa6, 0x73, 0xd8, 0x1e, 0x52, 0xe7, 0x43, 0x68, 0x9b, 0x0c, 0x8d, 0x44, 0x60, 0x16, + 0x84, 0xe1, 0x0d, 0xd4, 0xe2, 0x60, 0x09, 0x77, 0x36, 0x7a, 0xfb, 0xda, 0x83, 0x78, 0x6a, 0x31, + 0x4d, 0xbf, 0xca, 0xc5, 0x1b, 0x09, 0x58, 0x6d, 0x8a, 0xdb, 0xc8, 0x9e, 0x93, 0x4a, 0x98, 0xc2, + 0xd6, 0x08, 0x63, 0x6f, 0x18, 0x79, 0xcc, 0x0d, 0x3d, 0x17, 0x91, 0xac, 0xc9, 0x52, 0xce, 0xe4, + 0xf7, 0x00, 0x7e, 0x0a, 0x8b, 0xaf, 0xe7, 0xaf, 0x4c, 0x3a, 0x41, 0x96, 0x91, 0x61, 0x50, 0xbf, + 0x48, 0xd0, 0x98, 0xcb, 0xca, 0x89, 0x58, 0xe4, 0xc3, 0x08, 0x76, 0x84, 0xc6, 0x39, 0x1b, 0x77, + 0x64, 0xb5, 0xbb, 0xd1, 0x6b, 0x3f, 0x76, 0x24, 0xc7, 0x9c, 0x38, 0xb3, 0x1d, 0xe6, 0xcf, 0x53, + 0x55, 0xe8, 0x94, 0x69, 0x49, 0xbd, 0x3a, 0x11, 0xd7, 0xf5, 0xd6, 0x33, 0x5d, 0x3f, 0x0e, 0x3d, + 0x2d, 0x0d, 0x73, 0x13, 0xd6, 0x13, 0x13, 0x63, 0x61, 0x55, 0x63, 0x2d, 0x76, 0x71, 0x76, 0x19, + 0x59, 0x96, 0xd9, 0x01, 0xbd, 0x6f, 0x55, 0x58, 0x1d, 0x52, 0x47, 0x9e, 0xc0, 0x5e, 0xc9, 0xb7, + 0xe2, 0xc5, 0xa3, 0xf6, 0x4a, 0x87, 0xb1, 0xd5, 0x5b, 0x1e, 0x3b, 0x53, 0x20, 0x13, 0xd8, 0x2d, + 0x1c, 0xda, 0xee, 0x02, 0xae, 0x14, 0xd9, 0x7a, 0xb9, 0x2c, 0x32, 0x3d, 0xf3, 0x14, 0x36, 0x73, + 0x23, 0xd0, 0x29, 0x62, 0xc8, 0x22, 0x5a, 0xdd, 0x45, 0x88, 0x94, 0x3b, 0x82, 0xff, 0x8b, 0xf3, + 0xf5, 0xfc, 0x0f, 0x14, 0x79, 0x68, 0xeb, 0xd5, 0xd2, 0xd0, 0x6c, 0x4b, 0xb9, 0x98, 0x14, 0xb6, + 0x94, 0x45, 0x14, 0xb7, 0x54, 0x14, 0x92, 0xfe, 0xe0, 0xfa, 0x4e, 0x91, 0x6e, 0xee, 0x14, 0xe9, + 0xd7, 0x9d, 0x22, 0x7d, 0xbd, 0x57, 0x2a, 0x37, 0xf7, 0x4a, 0xe5, 0xc7, 0xbd, 0x52, 0x39, 0xd5, + 0x33, 0x43, 0xc8, 0xd9, 0x8e, 0x02, 0xc4, 0xae, 0x30, 0xb9, 0x14, 0x0b, 0x7d, 0x92, 0x7b, 0xdf, + 0xf8, 0x44, 0x9e, 0xd5, 0xc4, 0xf3, 0xf4, 0xfa, 0x77, 0x00, 0x00, 0x00, 0xff, 0xff, 0x77, 0x66, + 0xbc, 0xcf, 0xff, 0x06, 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 { + AddExternalRewardDenom(ctx context.Context, in *MsgAddExternalRewardDenom, opts ...grpc.CallOption) (*MsgAddExternalRewardDenomResponse, error) + AddExternalIncentive(ctx context.Context, in *MsgAddExternalIncentive, opts ...grpc.CallOption) (*MsgAddExternalIncentiveResponse, error) + UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) + UpdatePoolMultipliers(ctx context.Context, in *MsgUpdatePoolMultipliers, opts ...grpc.CallOption) (*MsgUpdatePoolMultipliersResponse, error) + ClaimRewards(ctx context.Context, in *MsgClaimRewards, opts ...grpc.CallOption) (*MsgClaimRewardsResponse, error) +} + +type msgClient struct { + cc grpc1.ClientConn +} + +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} +} + +func (c *msgClient) AddExternalRewardDenom(ctx context.Context, in *MsgAddExternalRewardDenom, opts ...grpc.CallOption) (*MsgAddExternalRewardDenomResponse, error) { + out := new(MsgAddExternalRewardDenomResponse) + err := c.cc.Invoke(ctx, "/elys.masterchef.Msg/AddExternalRewardDenom", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) AddExternalIncentive(ctx context.Context, in *MsgAddExternalIncentive, opts ...grpc.CallOption) (*MsgAddExternalIncentiveResponse, error) { + out := new(MsgAddExternalIncentiveResponse) + err := c.cc.Invoke(ctx, "/elys.masterchef.Msg/AddExternalIncentive", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) { + out := new(MsgUpdateParamsResponse) + err := c.cc.Invoke(ctx, "/elys.masterchef.Msg/UpdateParams", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) UpdatePoolMultipliers(ctx context.Context, in *MsgUpdatePoolMultipliers, opts ...grpc.CallOption) (*MsgUpdatePoolMultipliersResponse, error) { + out := new(MsgUpdatePoolMultipliersResponse) + err := c.cc.Invoke(ctx, "/elys.masterchef.Msg/UpdatePoolMultipliers", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) ClaimRewards(ctx context.Context, in *MsgClaimRewards, opts ...grpc.CallOption) (*MsgClaimRewardsResponse, error) { + out := new(MsgClaimRewardsResponse) + err := c.cc.Invoke(ctx, "/elys.masterchef.Msg/ClaimRewards", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MsgServer is the server API for Msg service. +type MsgServer interface { + AddExternalRewardDenom(context.Context, *MsgAddExternalRewardDenom) (*MsgAddExternalRewardDenomResponse, error) + AddExternalIncentive(context.Context, *MsgAddExternalIncentive) (*MsgAddExternalIncentiveResponse, error) + UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) + UpdatePoolMultipliers(context.Context, *MsgUpdatePoolMultipliers) (*MsgUpdatePoolMultipliersResponse, error) + ClaimRewards(context.Context, *MsgClaimRewards) (*MsgClaimRewardsResponse, error) +} + +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { +} + +func (*UnimplementedMsgServer) AddExternalRewardDenom(ctx context.Context, req *MsgAddExternalRewardDenom) (*MsgAddExternalRewardDenomResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method AddExternalRewardDenom not implemented") +} +func (*UnimplementedMsgServer) AddExternalIncentive(ctx context.Context, req *MsgAddExternalIncentive) (*MsgAddExternalIncentiveResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method AddExternalIncentive not implemented") +} +func (*UnimplementedMsgServer) UpdateParams(ctx context.Context, req *MsgUpdateParams) (*MsgUpdateParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateParams not implemented") +} +func (*UnimplementedMsgServer) UpdatePoolMultipliers(ctx context.Context, req *MsgUpdatePoolMultipliers) (*MsgUpdatePoolMultipliersResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdatePoolMultipliers not implemented") +} +func (*UnimplementedMsgServer) ClaimRewards(ctx context.Context, req *MsgClaimRewards) (*MsgClaimRewardsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ClaimRewards not implemented") +} + +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { + s.RegisterService(&_Msg_serviceDesc, srv) +} + +func _Msg_AddExternalRewardDenom_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgAddExternalRewardDenom) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).AddExternalRewardDenom(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/elys.masterchef.Msg/AddExternalRewardDenom", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).AddExternalRewardDenom(ctx, req.(*MsgAddExternalRewardDenom)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_AddExternalIncentive_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgAddExternalIncentive) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).AddExternalIncentive(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/elys.masterchef.Msg/AddExternalIncentive", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).AddExternalIncentive(ctx, req.(*MsgAddExternalIncentive)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_UpdateParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateParams) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).UpdateParams(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/elys.masterchef.Msg/UpdateParams", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UpdateParams(ctx, req.(*MsgUpdateParams)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_UpdatePoolMultipliers_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdatePoolMultipliers) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).UpdatePoolMultipliers(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/elys.masterchef.Msg/UpdatePoolMultipliers", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UpdatePoolMultipliers(ctx, req.(*MsgUpdatePoolMultipliers)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_ClaimRewards_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgClaimRewards) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).ClaimRewards(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/elys.masterchef.Msg/ClaimRewards", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).ClaimRewards(ctx, req.(*MsgClaimRewards)) + } + return interceptor(ctx, in, info, handler) +} + +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "elys.masterchef.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "AddExternalRewardDenom", + Handler: _Msg_AddExternalRewardDenom_Handler, + }, + { + MethodName: "AddExternalIncentive", + Handler: _Msg_AddExternalIncentive_Handler, + }, + { + MethodName: "UpdateParams", + Handler: _Msg_UpdateParams_Handler, + }, + { + MethodName: "UpdatePoolMultipliers", + Handler: _Msg_UpdatePoolMultipliers_Handler, + }, + { + MethodName: "ClaimRewards", + Handler: _Msg_ClaimRewards_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "elys/masterchef/tx.proto", +} + +func (m *MsgAddExternalRewardDenom) 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 *MsgAddExternalRewardDenom) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgAddExternalRewardDenom) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Supported { + i-- + if m.Supported { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x20 + } + { + size := m.MinAmount.Size() + i -= size + if _, err := m.MinAmount.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if len(m.RewardDenom) > 0 { + i -= len(m.RewardDenom) + copy(dAtA[i:], m.RewardDenom) + i = encodeVarintTx(dAtA, i, uint64(len(m.RewardDenom))) + i-- + dAtA[i] = 0x12 + } + if len(m.Authority) > 0 { + i -= len(m.Authority) + copy(dAtA[i:], m.Authority) + i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgAddExternalRewardDenomResponse) 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 *MsgAddExternalRewardDenomResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgAddExternalRewardDenomResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgAddExternalIncentive) 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 *MsgAddExternalIncentive) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgAddExternalIncentive) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.AmountPerBlock.Size() + i -= size + if _, err := m.AmountPerBlock.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + if m.ToBlock != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.ToBlock)) + i-- + dAtA[i] = 0x28 + } + if m.FromBlock != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.FromBlock)) + i-- + dAtA[i] = 0x20 + } + if m.PoolId != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.PoolId)) + i-- + dAtA[i] = 0x18 + } + if len(m.RewardDenom) > 0 { + i -= len(m.RewardDenom) + copy(dAtA[i:], m.RewardDenom) + i = encodeVarintTx(dAtA, i, uint64(len(m.RewardDenom))) + i-- + dAtA[i] = 0x12 + } + if len(m.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintTx(dAtA, i, uint64(len(m.Sender))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgAddExternalIncentiveResponse) 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 *MsgAddExternalIncentiveResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgAddExternalIncentiveResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgUpdateParams) 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 *MsgUpdateParams) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateParams) 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 = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.Authority) > 0 { + i -= len(m.Authority) + copy(dAtA[i:], m.Authority) + i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgUpdateParamsResponse) 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 *MsgUpdateParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *PoolMultiplier) 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 *PoolMultiplier) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PoolMultiplier) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.Multiplier.Size() + i -= size + if _, err := m.Multiplier.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + 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 *MsgUpdatePoolMultipliers) 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 *MsgUpdatePoolMultipliers) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdatePoolMultipliers) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.PoolMultipliers) > 0 { + for iNdEx := len(m.PoolMultipliers) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.PoolMultipliers[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if len(m.Authority) > 0 { + i -= len(m.Authority) + copy(dAtA[i:], m.Authority) + i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgUpdatePoolMultipliersResponse) 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 *MsgUpdatePoolMultipliersResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdatePoolMultipliersResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgClaimRewards) 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 *MsgClaimRewards) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgClaimRewards) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.PoolIds) > 0 { + dAtA3 := make([]byte, len(m.PoolIds)*10) + var j2 int + for _, num := range m.PoolIds { + for num >= 1<<7 { + dAtA3[j2] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j2++ + } + dAtA3[j2] = uint8(num) + j2++ + } + i -= j2 + copy(dAtA[i:], dAtA3[:j2]) + i = encodeVarintTx(dAtA, i, uint64(j2)) + i-- + dAtA[i] = 0x12 + } + if len(m.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintTx(dAtA, i, uint64(len(m.Sender))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgClaimRewardsResponse) 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 *MsgClaimRewardsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgClaimRewardsResponse) 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 *MsgAddExternalRewardDenom) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Authority) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.RewardDenom) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.MinAmount.Size() + n += 1 + l + sovTx(uint64(l)) + if m.Supported { + n += 2 + } + return n +} + +func (m *MsgAddExternalRewardDenomResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgAddExternalIncentive) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.RewardDenom) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.PoolId != 0 { + n += 1 + sovTx(uint64(m.PoolId)) + } + if m.FromBlock != 0 { + n += 1 + sovTx(uint64(m.FromBlock)) + } + if m.ToBlock != 0 { + n += 1 + sovTx(uint64(m.ToBlock)) + } + l = m.AmountPerBlock.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *MsgAddExternalIncentiveResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgUpdateParams) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Authority) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.Params.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *MsgUpdateParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *PoolMultiplier) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PoolId != 0 { + n += 1 + sovTx(uint64(m.PoolId)) + } + l = m.Multiplier.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *MsgUpdatePoolMultipliers) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Authority) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if len(m.PoolMultipliers) > 0 { + for _, e := range m.PoolMultipliers { + l = e.Size() + n += 1 + l + sovTx(uint64(l)) + } + } + return n +} + +func (m *MsgUpdatePoolMultipliersResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgClaimRewards) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if len(m.PoolIds) > 0 { + l = 0 + for _, e := range m.PoolIds { + l += sovTx(uint64(e)) + } + n += 1 + sovTx(uint64(l)) + l + } + return n +} + +func (m *MsgClaimRewardsResponse) 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 *MsgAddExternalRewardDenom) 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: MsgAddExternalRewardDenom: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgAddExternalRewardDenom: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Authority", 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.Authority = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RewardDenom", 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.RewardDenom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MinAmount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.MinAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Supported", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Supported = bool(v != 0) + 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 *MsgAddExternalRewardDenomResponse) 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: MsgAddExternalRewardDenomResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgAddExternalRewardDenomResponse: 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 *MsgAddExternalIncentive) 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: MsgAddExternalIncentive: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgAddExternalIncentive: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sender", 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.Sender = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RewardDenom", 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.RewardDenom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + 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 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field FromBlock", wireType) + } + m.FromBlock = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.FromBlock |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ToBlock", wireType) + } + m.ToBlock = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ToBlock |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AmountPerBlock", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.AmountPerBlock.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 *MsgAddExternalIncentiveResponse) 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: MsgAddExternalIncentiveResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgAddExternalIncentiveResponse: 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 *MsgUpdateParams) 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: MsgUpdateParams: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateParams: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Authority", 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.Authority = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + 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 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.Params.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 *MsgUpdateParamsResponse) 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: MsgUpdateParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateParamsResponse: 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 *PoolMultiplier) 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: PoolMultiplier: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PoolMultiplier: 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 Multiplier", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Multiplier.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 *MsgUpdatePoolMultipliers) 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: MsgUpdatePoolMultipliers: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdatePoolMultipliers: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Authority", 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.Authority = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PoolMultipliers", 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 + } + m.PoolMultipliers = append(m.PoolMultipliers, PoolMultiplier{}) + if err := m.PoolMultipliers[len(m.PoolMultipliers)-1].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 *MsgUpdatePoolMultipliersResponse) 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: MsgUpdatePoolMultipliersResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdatePoolMultipliersResponse: 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 *MsgClaimRewards) 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: MsgClaimRewards: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgClaimRewards: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sender", 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.Sender = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType == 0 { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.PoolIds = append(m.PoolIds, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var elementCount int + var count int + for _, integer := range dAtA[iNdEx:postIndex] { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.PoolIds) == 0 { + m.PoolIds = make([]uint64, 0, elementCount) + } + for iNdEx < postIndex { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.PoolIds = append(m.PoolIds, v) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field PoolIds", wireType) + } + 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 *MsgClaimRewardsResponse) 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: MsgClaimRewardsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgClaimRewardsResponse: 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") +) diff --git a/x/masterchef/types/types.go b/x/masterchef/types/types.go new file mode 100644 index 000000000..ea6676e30 --- /dev/null +++ b/x/masterchef/types/types.go @@ -0,0 +1,20 @@ +package types + +import ( + fmt "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// TotalCommitmentInfo +// Stores the +type TotalCommitmentInfo struct { + // Revenue tracking per pool, key => (poolId) + PoolRevenueTrack map[string]sdk.Dec +} + +// Returns the pool revenue tracking key. +// Unique per pool, clean once complete the calculation. +func GetPoolRevenueTrackKey(poolId uint64) string { + return fmt.Sprintf("pool_revenue_%d", poolId) +} diff --git a/x/stablestake/keeper/hooks.go b/x/stablestake/keeper/hooks.go new file mode 100644 index 000000000..c0789f5ca --- /dev/null +++ b/x/stablestake/keeper/hooks.go @@ -0,0 +1,38 @@ +package keeper + +import ( + "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/elys-network/elys/x/stablestake/types" +) + +var _ types.StableStakeHooks = MultiStableStakeHooks{} + +// combine multiple stablestake hooks, all hook functions are run in array sequence +type MultiStableStakeHooks []types.StableStakeHooks + +func NewMultiStableStakeHooks(hooks ...types.StableStakeHooks) MultiStableStakeHooks { + return hooks +} + +// Committed is called when staker committed his token +func (mh MultiStableStakeHooks) AfterBond(ctx sdk.Context, sender string, shareAmount math.Int) error { + for i := range mh { + err := mh[i].AfterBond(ctx, sender, shareAmount) + if err != nil { + return err + } + } + return nil +} + +// Committed is called when staker committed his token +func (mh MultiStableStakeHooks) AfterUnbond(ctx sdk.Context, sender string, shareAmount math.Int) error { + for i := range mh { + err := mh[i].AfterUnbond(ctx, sender, shareAmount) + if err != nil { + return err + } + } + return nil +} diff --git a/x/stablestake/keeper/keeper.go b/x/stablestake/keeper/keeper.go index a4a67f619..08e7bd643 100644 --- a/x/stablestake/keeper/keeper.go +++ b/x/stablestake/keeper/keeper.go @@ -21,6 +21,7 @@ type ( bk types.BankKeeper commitmentKeeper *commitmentkeeper.Keeper assetProfileKeeper types.AssetProfileKeeper + hooks types.StableStakeHooks } ) @@ -52,3 +53,14 @@ func NewKeeper( func (k Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) } + +// SetHooks set the epoch hooks +func (k *Keeper) SetHooks(eh types.StableStakeHooks) *Keeper { + if k.hooks != nil { + panic("cannot set stablestake hooks twice") + } + + k.hooks = eh + + return k +} diff --git a/x/stablestake/keeper/msg_server_bond.go b/x/stablestake/keeper/msg_server_bond.go index 435a4c140..af7ea5f6d 100644 --- a/x/stablestake/keeper/msg_server_bond.go +++ b/x/stablestake/keeper/msg_server_bond.go @@ -42,10 +42,10 @@ func (k msgServer) Bond(goCtx context.Context, msg *types.MsgBond) (*types.MsgBo return nil, err } - entry, found := k.assetProfileKeeper.GetEntry(ctx, shareDenom) + _, found := k.assetProfileKeeper.GetEntry(ctx, shareDenom) if !found { // Set an entity to assetprofile - entry = assetprofiletypes.Entry{ + entry := assetprofiletypes.Entry{ Authority: authtypes.NewModuleAddress(types.ModuleName).String(), BaseDenom: shareDenom, Decimals: ptypes.BASE_DECIMAL, @@ -88,5 +88,12 @@ func (k msgServer) Bond(goCtx context.Context, msg *types.MsgBond) (*types.MsgBo params.TotalValue = params.TotalValue.Add(msg.Amount) k.SetParams(ctx, params) + if k.hooks != nil { + err := k.hooks.AfterBond(ctx, msg.Creator, shareAmount) + if err != nil { + return nil, err + } + } + return &types.MsgBondResponse{}, nil } diff --git a/x/stablestake/keeper/msg_server_unbond.go b/x/stablestake/keeper/msg_server_unbond.go index 1a0d84c61..fd65fbb24 100644 --- a/x/stablestake/keeper/msg_server_unbond.go +++ b/x/stablestake/keeper/msg_server_unbond.go @@ -52,5 +52,12 @@ func (k msgServer) Unbond(goCtx context.Context, msg *types.MsgUnbond) (*types.M params.TotalValue = params.TotalValue.Sub(redemptionAmount) k.SetParams(ctx, params) + if k.hooks != nil { + err := k.hooks.AfterUnbond(ctx, msg.Creator, msg.Amount) + if err != nil { + return nil, err + } + } + return &types.MsgUnbondResponse{}, nil } diff --git a/x/stablestake/types/interfaces.go b/x/stablestake/types/interfaces.go new file mode 100644 index 000000000..2dc90ded9 --- /dev/null +++ b/x/stablestake/types/interfaces.go @@ -0,0 +1,12 @@ +package types + +import ( + "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// StableStakeHooks event hooks for stablestake processing +type StableStakeHooks interface { + AfterBond(ctx sdk.Context, sender string, shareAmount math.Int) error + AfterUnbond(ctx sdk.Context, sender string, shareAmount math.Int) error +}