diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 000000000..aa6b64fe3 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,126 @@ +name: Deploy in devnet +on: + push: + branches: + - devnet +jobs: + deploy: + runs-on: ubuntu-latest + environment: devnet + env: + BRANCH_NAME: ${{ github.head_ref || github.ref_name }} + NAME: elys + COMMIT: ${{ github.sha }} + VERSION: + BINARY: + DBENGINE: pebbledb + COSMWASM_VERSION: + NAME_WITH_VERSION: + steps: + - name: Checking repository + uses: actions/checkout@v4 + - name: Setting variables + run: | + VER=$(cat .version) + echo "VERSION=$VER" >> $GITHUB_ENV + echo "BINARY=${NAME}d" >> $GITHUB_ENV + echo "NAME_WITH_VERSION=${NAME}-${VER}" >> $GITHUB_ENV + - name: Debuging enviroment + run: | + echo "BRANCH NAME:" $BRANCH_NAME + echo "NAME:" $NAME + echo "COMMIT:" $COMMIT + echo "VERSION": $VERSION + echo "BYNARY": $BINARY + echo "NAME_WITH_VERSION": $NAME_WITH_VERSION + - name: Setuping go + uses: actions/setup-go@v5 + with: + go-version: "1.21" + - name: Building elys binary + env: + CGO_ENABLED: 1 + run: | + echo Building elysd binary + + COSMWASM_VERSION=$(go list -m github.com/CosmWasm/wasmvm | sed 's/.* //') + echo $COSMWASM_VERSION + + sudo wget https://github.com/CosmWasm/wasmvm/releases/download/${COSMWASM_VERSION}/libwasmvm_muslc.x86_64.a -O /usr/lib/libwasmvm.x86_64.a + + sudo GOOS=linux GOARCH=amd64 go build -mod=readonly -trimpath -o elysd -ldflags "-X github.com/cosmos/cosmos-sdk/version.Name=${NAME} \ + -X github.com/cosmos/cosmos-sdk/version.AppName=${NAME} \ + -X github.com/cosmos/cosmos-sdk/version.ServerName=${BINARY} \ + -X github.com/cosmos/cosmos-sdk/version.ClientName=${BINARY} \ + -X github.com/cosmos/cosmos-sdk/version.Version=${VERSION} \ + -X github.com/cosmos/cosmos-sdk/version.Commit=${COMMIT} \ + -X github.com/cosmos/cosmos-sdk/types.DBBackend=${DBENGINE} \ + -X github.com/cosmos/cosmos-sdk/version.BuildTags=netgo,ledger,muslc,osusergo,${DBENGINE} \ + -w -s \ + -linkmode=external \ + -extldflags '-Wl,-z,muldefs -static -lm'" -tags "ledger,${DBENGINE}" ./cmd/${BINARY} + echo "Version of elysd: $(./elysd version)" + - name: Compressing elys binary + run: | + cp elysd /tmp/elysd + sudo apt-get install -y tar + tar czvf ${{env.NAME_WITH_VERSION}}.tar.gz elysd + mkdir -p ${{env.NAME_WITH_VERSION}} + mv ${{env.NAME_WITH_VERSION}}.tar.gz ${{env.NAME_WITH_VERSION}}/${{env.NAME_WITH_VERSION}}.tar.gz + - uses: ryand56/r2-upload-action@latest + id: bucket + name: Uploading binary to bucket + with: + r2-account-id: ${{ secrets.R2_ACCOUNT_ID }} + r2-access-key-id: ${{ secrets.R2_ACCESS_KEY_ID }} + r2-secret-access-key: ${{ secrets.R2_SECRET_ACCESS_KEY }} + r2-bucket: ${{ secrets.R2_BUCKET }} + source-dir: ${{env.NAME_WITH_VERSION}} + destination-dir: releases + - name: Creating software upgrade proposal + run: | + + # helper functions + extract_txhash() { awk -F 'txhash: ' '/txhash:/{print $2; exit}'; } + extract_proposal_id() { awk -F 'key: proposal_id|value: ' '/key: proposal_id/ { getline; gsub(/"/, "", $2); print $2; exit }'; } + extract_and_calc_upgrade_height() { awk -F'"latest_block_height":"' '{ split($2,a,"\""); print a[1]+25; exit }'; } + extract_checksum() { awk "/elysd-${{ github.ref_name }}-linux-amd64.tar.gz/ {print \$1; exit}"; } + + # environment variables + ELYSD=/tmp/elysd + NODE=https://rpc.devnet.elys.network:443 + OPTIONS="--node $NODE --chain-id elysdevnet-1 --keyring-backend=test -b=sync --fees=100000uelys --gas=300000 -y" + + # save private keys to files + echo "${{ secrets.PRIVATE_KEY_FUJI }}" > /tmp/private_key_fuji.txt + echo "${{ secrets.PRIVATE_KEY_MALLORCA }}" > /tmp/private_key_mallorca.txt + + # recover keys + echo "${{ secrets.PASSPHRASE_FUJI }}" | $ELYSD keys import fuji --keyring-backend test /tmp/private_key_fuji.txt + echo "${{ secrets.PASSPHRASE_MALLORCA }}" | $ELYSD keys import mallorca --keyring-backend test /tmp/private_key_mallorca.txt + + # get checksum + # checksum=$(cat dist/sha256sum.txt | extract_checksum) + + # query and upgrade height + height=$($ELYSD status --node $NODE | extract_and_calc_upgrade_height) + # create proposal + txhash=$( + $ELYSD tx gov submit-legacy-proposal software-upgrade \ + ${{env.VERSION}} \ + --deposit=10000000uelys \ + --upgrade-height=$height \ + --title="${{env.VERSION}}" \ + --description="Elys Network${{env.VERSION}} released. Focuses on enhancements and codebase improvements." \ + --upgrade-info="{\"binaries\":{\"linux/amd64\":\"https://snapshots.elys.network/releases/${{env.NAME_WITH_VERSION}}.tar.gz\"}}" \ + --no-validate \ + --from=mallorca \ + $OPTIONS | extract_txhash + ) + sleep 10 + proposalid=$($ELYSD q tx $txhash --node $NODE | extract_proposal_id) + + # vote on proposal + $ELYSD tx gov vote $proposalid yes --from=fuji $OPTIONS + $ELYSD tx gov vote $proposalid yes --from=mallorca $OPTIONS + sleep 10 \ No newline at end of file diff --git a/.version b/.version new file mode 100644 index 000000000..4426b61a7 --- /dev/null +++ b/.version @@ -0,0 +1 @@ +v0.32.1 \ No newline at end of file diff --git a/app/app.go b/app/app.go index 4b6ee93d2..f097a349c 100644 --- a/app/app.go +++ b/app/app.go @@ -1005,6 +1005,7 @@ func NewElysApp( app.StablestakeKeeper, app.CommitmentKeeper, app.AssetprofileKeeper, + app.MasterchefKeeper, ) leveragelpModule := leveragelpmodule.NewAppModule(appCodec, app.LeveragelpKeeper, app.AccountKeeper, app.BankKeeper) diff --git a/config.yml b/config.yml index 56005f37c..925e297e0 100644 --- a/config.yml +++ b/config.yml @@ -454,9 +454,6 @@ genesis: - 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 e3a18fe7a..68dc51d61 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. @@ -40064,6 +40775,56 @@ paths: type: boolean tags: - Query + /elys-network/elys/leveragelp/close_estimation: + get: + summary: Get estimated amount of return value closing a position + operationId: ElysLeveragelpCloseEst + responses: + '200': + description: A successful response. + schema: + type: object + properties: + liability: + type: string + weight_balance_ratio: + type: string + amount_returned: + 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: owner + in: query + required: false + type: string + - name: id + in: query + required: false + type: string + format: uint64 + - name: lp_amount + in: query + required: false + type: string + tags: + - Query /elys-network/elys/leveragelp/is-whitelisted: get: summary: Queries a list of IsWhitelisted items. @@ -40103,6 +40864,60 @@ paths: type: string tags: - Query + /elys-network/elys/leveragelp/open_estimation: + get: + summary: Get estimated amount of return value opening a position + operationId: ElysLeveragelpOpenEst + responses: + '200': + description: A successful response. + schema: + type: object + properties: + position_size: + type: string + weight_balance_ratio: + type: string + borrow_fee: + 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: collateral_asset + in: query + required: false + type: string + - name: collateral_amount + in: query + required: false + type: string + - name: amm_pool_id + in: query + required: false + type: string + format: uint64 + - name: leverage + in: query + required: false + type: string + tags: + - Query /elys-network/elys/leveragelp/params: get: summary: Parameters queries the parameters of the module. @@ -40336,91 +41151,254 @@ paths: type: boolean tags: - Query - /elys-network/elys/leveragelp/position/{address}/{id}: - get: - summary: Queries a list of Position items. - operationId: ElysLeveragelpPosition - responses: - '200': - description: A successful response. - schema: - type: object - properties: - position: - type: object - properties: - address: - type: string - collateral: - 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. - liabilities: - type: string - title: For recording - interest_paid: - type: string - title: For recording - leverage: - type: string - title: For recording - leveraged_lp_amount: - type: string - position_health: - type: string - id: - type: string - format: uint64 - amm_pool_id: - type: string - format: uint64 - stop_loss_price: - 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: address - in: path - required: true - type: string - - name: id - in: path - required: true - type: string - format: uint64 - tags: - - Query - /elys-network/elys/leveragelp/positions-by-pool/{amm_pool_id}/{pagination.key}: + /elys-network/elys/leveragelp/position/{address}/{id}: + get: + summary: Queries a list of Position items. + operationId: ElysLeveragelpPosition + responses: + '200': + description: A successful response. + schema: + type: object + properties: + position: + type: object + properties: + address: + type: string + collateral: + 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. + liabilities: + type: string + title: For recording + interest_paid: + type: string + title: For recording + leverage: + type: string + title: For recording + leveraged_lp_amount: + type: string + position_health: + type: string + id: + type: string + format: uint64 + amm_pool_id: + type: string + format: uint64 + stop_loss_price: + 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: address + in: path + required: true + type: string + - name: id + in: path + required: true + type: string + format: uint64 + tags: + - Query + /elys-network/elys/leveragelp/positions-by-pool/{amm_pool_id}/{pagination.key}: + get: + summary: Queries a list of GetPositionsByPool items. + operationId: ElysLeveragelpQueryPositionsByPool + responses: + '200': + description: A successful response. + schema: + type: object + properties: + positions: + type: array + items: + type: object + properties: + address: + type: string + collateral: + 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. + liabilities: + type: string + title: For recording + interest_paid: + type: string + title: For recording + leverage: + type: string + title: For recording + leveraged_lp_amount: + type: string + position_health: + type: string + id: + type: string + format: uint64 + amm_pool_id: + type: string + format: uint64 + stop_loss_price: + type: string + pagination: + 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: >- + PageResponse is to be embedded in gRPC response messages where + the + + corresponding request message has used PageRequest. + + message SomeResponse { + repeated Bar results = 1; + PageResponse page = 2; + } + 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: amm_pool_id + in: path + required: true + 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: path + required: true + 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 + /elys-network/elys/leveragelp/positions-for-address/{address}/{pagination.key}: get: - summary: Queries a list of GetPositionsByPool items. - operationId: ElysLeveragelpQueryPositionsByPool + summary: Queries a list of GetPositionsForAddress items. + operationId: ElysLeveragelpQueryPositionsForAddress responses: '200': description: A successful response. @@ -40517,11 +41495,10 @@ paths: type: string additionalProperties: {} parameters: - - name: amm_pool_id + - name: address in: path required: true type: string - format: uint64 - name: pagination.key description: |- key is a value returned in PageResponse.next_key to begin @@ -40580,10 +41557,10 @@ paths: type: boolean tags: - Query - /elys-network/elys/leveragelp/positions-for-address/{address}/{pagination.key}: + /elys-network/elys/leveragelp/positions/{pagination.key}: get: - summary: Queries a list of GetPositionsForAddress items. - operationId: ElysLeveragelpQueryPositionsForAddress + summary: Queries a list of GetPositions items. + operationId: ElysLeveragelpQueryPositions responses: '200': description: A successful response. @@ -40680,10 +41657,6 @@ paths: type: string additionalProperties: {} parameters: - - name: address - in: path - required: true - type: string - name: pagination.key description: |- key is a value returned in PageResponse.next_key to begin @@ -40742,87 +41715,59 @@ paths: type: boolean tags: - Query - /elys-network/elys/leveragelp/positions/{pagination.key}: + /elys-network/elys/leveragelp/rewards/{address}: get: - summary: Queries a list of GetPositions items. - operationId: ElysLeveragelpQueryPositions + summary: Queries rewards on leveragelp + operationId: ElysLeveragelpRewards responses: '200': description: A successful response. schema: type: object properties: - positions: + rewards: type: array items: type: object properties: - address: + position_id: type: string - collateral: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an amount. + 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 + NOTE: The amount field is an Int which implements the + custom method - signatures required by gogoproto. - liabilities: - type: string - title: For recording - interest_paid: - type: string - title: For recording - leverage: - type: string - title: For recording - leveraged_lp_amount: - type: string - position_health: - type: string - id: - type: string - format: uint64 - amm_pool_id: + signatures required by gogoproto. + total_rewards: + type: array + items: + type: object + properties: + denom: type: string - format: uint64 - stop_loss_price: + amount: type: string - pagination: - 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 + description: >- + Coin defines a token with a denomination and an amount. - was set, its value is undefined otherwise - description: >- - PageResponse is to be embedded in gRPC response messages where - the - corresponding request message has used PageRequest. + NOTE: The amount field is an Int which implements the custom + method - message SomeResponse { - repeated Bar results = 1; - PageResponse page = 2; - } + signatures required by gogoproto. default: description: An unexpected error response. schema: @@ -40842,62 +41787,18 @@ paths: type: string additionalProperties: {} parameters: - - 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. + - name: address in: path required: true 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. + - name: ids 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 + type: array + items: + type: string + format: uint64 + collectionFormat: multi tags: - Query /elys-network/elys/leveragelp/status: @@ -41154,20 +42055,6 @@ paths: 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] @@ -41349,28 +42236,21 @@ paths: 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 + gas_apr: + type: string + title: Gas APR, updated at every distribution external_incentive_apr: type: string title: External Incentive APR, updated at every distribution @@ -41379,7 +42259,6 @@ paths: items: type: string title: external reward denoms on the pool - title: Pool Info default: description: An unexpected error response. schema: @@ -42217,6 +43096,10 @@ paths: total_blocks_per_year: type: string format: int64 + rewards_data_lifetime: + type: string + format: int64 + title: default 1 day = 86400 wasm_max_label_size: type: string wasm_max_size: @@ -68069,198 +68952,653 @@ definitions: Max age of evidence, in time. - It should correspond with an app's "unbonding period" or other - similar + It should correspond with an app's "unbonding period" or other + similar + + mechanism for handling [Nothing-At-Stake + + attacks](https://github.com/ethereum/wiki/wiki/Proof-of-Stake-FAQ#what-is-the-nothing-at-stake-problem-and-how-can-it-be-fixed). + max_bytes: + type: string + format: int64 + title: >- + This sets the maximum size of total evidence in bytes that can + be committed in a single block. + + and should fall comfortably under the max block bytes. + + Default is 1048576 or 1MB + description: EvidenceParams determine how we handle evidence of malfeasance. + validator: + type: object + properties: + pub_key_types: + type: array + items: + type: string + description: |- + ValidatorParams restrict the public key types validators can use. + NOTE: uses ABCI pubkey naming, not Amino names. + version: + type: object + properties: + app: + type: string + format: uint64 + description: VersionParams contains the ABCI application version. + description: >- + QueryParamsResponse defines the response type for querying x/consensus + parameters. + tendermint.types.BlockParams: + type: object + properties: + max_bytes: + type: string + format: int64 + title: |- + Max block size, in bytes. + Note: must be greater than 0 + max_gas: + type: string + format: int64 + title: |- + Max gas per block. + Note: must be greater or equal to -1 + description: BlockParams contains limits on the block size. + tendermint.types.ConsensusParams: + type: object + properties: + block: + type: object + properties: + max_bytes: + type: string + format: int64 + title: |- + Max block size, in bytes. + Note: must be greater than 0 + max_gas: + type: string + format: int64 + title: |- + Max gas per block. + Note: must be greater or equal to -1 + description: BlockParams contains limits on the block size. + evidence: + type: object + properties: + max_age_num_blocks: + type: string + format: int64 + description: >- + Max age of evidence, in blocks. + + + The basic formula for calculating this is: MaxAgeDuration / + {average block + + time}. + max_age_duration: + type: string + description: >- + Max age of evidence, in time. + + + It should correspond with an app's "unbonding period" or other + similar + + mechanism for handling [Nothing-At-Stake + + attacks](https://github.com/ethereum/wiki/wiki/Proof-of-Stake-FAQ#what-is-the-nothing-at-stake-problem-and-how-can-it-be-fixed). + max_bytes: + type: string + format: int64 + title: >- + This sets the maximum size of total evidence in bytes that can be + committed in a single block. + + and should fall comfortably under the max block bytes. + + Default is 1048576 or 1MB + description: EvidenceParams determine how we handle evidence of malfeasance. + validator: + type: object + properties: + pub_key_types: + type: array + items: + type: string + description: |- + ValidatorParams restrict the public key types validators can use. + NOTE: uses ABCI pubkey naming, not Amino names. + version: + type: object + properties: + app: + type: string + format: uint64 + description: VersionParams contains the ABCI application version. + description: |- + ConsensusParams contains consensus critical parameters that determine the + validity of blocks. + tendermint.types.EvidenceParams: + type: object + properties: + max_age_num_blocks: + type: string + format: int64 + description: >- + Max age of evidence, in blocks. + + + The basic formula for calculating this is: MaxAgeDuration / {average + block + + time}. + max_age_duration: + type: string + description: >- + Max age of evidence, in time. + + + It should correspond with an app's "unbonding period" or other similar + + mechanism for handling [Nothing-At-Stake + + attacks](https://github.com/ethereum/wiki/wiki/Proof-of-Stake-FAQ#what-is-the-nothing-at-stake-problem-and-how-can-it-be-fixed). + max_bytes: + type: string + format: int64 + title: >- + This sets the maximum size of total evidence in bytes that can be + committed in a single block. + + and should fall comfortably under the max block bytes. + + Default is 1048576 or 1MB + description: EvidenceParams determine how we handle evidence of malfeasance. + tendermint.types.ValidatorParams: + type: object + properties: + pub_key_types: + type: array + items: + type: string + description: |- + ValidatorParams restrict the public key types validators can use. + NOTE: uses ABCI pubkey naming, not Amino names. + tendermint.types.VersionParams: + type: object + properties: + app: + type: string + format: uint64 + description: VersionParams contains the ABCI application version. + cosmos.crisis.v1beta1.MsgUpdateParamsResponse: + type: object + description: |- + MsgUpdateParamsResponse defines the response structure for executing a + MsgUpdateParams message. + + Since: cosmos-sdk 0.47 + 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. - mechanism for handling [Nothing-At-Stake - attacks](https://github.com/ethereum/wiki/wiki/Proof-of-Stake-FAQ#what-is-the-nothing-at-stake-problem-and-how-can-it-be-fixed). - max_bytes: - type: string - format: int64 - title: >- - This sets the maximum size of total evidence in bytes that can - be committed in a single block. + NOTE: The amount field is an Dec which implements the custom + method - and should fall comfortably under the max block bytes. + 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. - Default is 1048576 or 1MB - description: EvidenceParams determine how we handle evidence of malfeasance. - validator: - type: object - properties: - pub_key_types: - type: array - items: - type: string - description: |- - ValidatorParams restrict the public key types validators can use. - NOTE: uses ABCI pubkey naming, not Amino names. - version: - type: object - properties: - app: - type: string - format: uint64 - description: VersionParams contains the ABCI application version. - description: >- - QueryParamsResponse defines the response type for querying x/consensus - parameters. - tendermint.types.BlockParams: + 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: - max_bytes: - type: string - format: int64 - title: |- - Max block size, in bytes. - Note: must be greater than 0 - max_gas: + 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 - format: int64 - title: |- - Max gas per block. - Note: must be greater or equal to -1 - description: BlockParams contains limits on the block size. - tendermint.types.ConsensusParams: + 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: - block: + params: + description: params defines the parameters of the module. type: object properties: - max_bytes: - type: string - format: int64 - title: |- - Max block size, in bytes. - Note: must be greater than 0 - max_gas: + community_tax: type: string - format: int64 - title: |- - Max gas per block. - Note: must be greater or equal to -1 - description: BlockParams contains limits on the block size. - evidence: - type: object - properties: - max_age_num_blocks: + base_proposer_reward: type: string - format: int64 description: >- - Max age of evidence, in blocks. - - - The basic formula for calculating this is: MaxAgeDuration / - {average block + Deprecated: The base_proposer_reward field is deprecated and is no + longer used - time}. - max_age_duration: + in the x/distribution module's reward mechanism. + bonus_proposer_reward: type: string description: >- - Max age of evidence, in time. + 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. - It should correspond with an app's "unbonding period" or other - similar - mechanism for handling [Nothing-At-Stake + NOTE: The amount field is an Dec which implements the custom + method - attacks](https://github.com/ethereum/wiki/wiki/Proof-of-Stake-FAQ#what-is-the-nothing-at-stake-problem-and-how-can-it-be-fixed). - max_bytes: - type: string - format: int64 - title: >- - This sets the maximum size of total evidence in bytes that can be - committed in a single block. + 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. - and should fall comfortably under the max block bytes. + 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. - Default is 1048576 or 1MB - description: EvidenceParams determine how we handle evidence of malfeasance. - validator: + 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: - pub_key_types: + 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 - description: |- - ValidatorParams restrict the public key types validators can use. - NOTE: uses ABCI pubkey naming, not Amino names. - version: + 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: - app: + 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 - description: VersionParams contains the ABCI application version. + title: >- + total is total number of results available if + PageRequest.count_total + + was set, its value is undefined otherwise description: |- - ConsensusParams contains consensus critical parameters that determine the - validity of blocks. - tendermint.types.EvidenceParams: + QueryValidatorSlashesResponse is the response type for the + Query/ValidatorSlashes RPC method. + cosmos.distribution.v1beta1.ValidatorAccumulatedCommission: type: object properties: - max_age_num_blocks: - type: string - format: int64 - description: >- - Max age of evidence, in blocks. - - - The basic formula for calculating this is: MaxAgeDuration / {average - block - - time}. - max_age_duration: - type: string - description: >- - Max age of evidence, in time. - - - It should correspond with an app's "unbonding period" or other similar - - mechanism for handling [Nothing-At-Stake - - attacks](https://github.com/ethereum/wiki/wiki/Proof-of-Stake-FAQ#what-is-the-nothing-at-stake-problem-and-how-can-it-be-fixed). - max_bytes: - type: string - format: int64 - title: >- - This sets the maximum size of total evidence in bytes that can be - committed in a single block. - - and should fall comfortably under the max block bytes. + 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. - Default is 1048576 or 1MB - description: EvidenceParams determine how we handle evidence of malfeasance. - tendermint.types.ValidatorParams: + 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: - pub_key_types: + rewards: type: array items: - type: string + 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: |- - ValidatorParams restrict the public key types validators can use. - NOTE: uses ABCI pubkey naming, not Amino names. - tendermint.types.VersionParams: + ValidatorOutstandingRewards represents outstanding (un-withdrawn) rewards + for a validator inexpensive to track, allows simple sanity checks. + cosmos.distribution.v1beta1.ValidatorSlashEvent: type: object properties: - app: + validator_period: type: string format: uint64 - description: VersionParams contains the ABCI application version. - cosmos.crisis.v1beta1.MsgUpdateParamsResponse: - type: object + fraction: + type: string description: |- - MsgUpdateParamsResponse defines the response structure for executing a - MsgUpdateParams message. - - Since: cosmos-sdk 0.47 - cosmos.crisis.v1beta1.MsgVerifyInvariantResponse: - type: object - description: MsgVerifyInvariantResponse defines the Msg/VerifyInvariant response type. + 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: @@ -84254,7 +85592,7 @@ definitions: type: string amount: type: string - elys.burner.MsgMsgUpdateParamsResponse: + elys.burner.MsgUpdateParamsResponse: type: object elys.burner.Params: type: object @@ -84792,18 +86130,6 @@ definitions: description: |- QueryEpochsInfoResponse is the response type for the Query/EpochInfos RPC method. - 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. elys.estaking.DelegationDelegatorReward: type: object properties: @@ -85153,6 +86479,8 @@ definitions: type: string is_whitelisted: type: boolean + elys.leveragelp.MsgClaimRewardsResponse: + type: object elys.leveragelp.MsgCloseResponse: type: object elys.leveragelp.MsgDewhitelistResponse: @@ -85377,216 +86705,296 @@ definitions: repeated Bar results = 1; PageResponse page = 2; } - elys.leveragelp.PositionsForAddressResponse: + elys.leveragelp.PositionsForAddressResponse: + type: object + properties: + positions: + type: array + items: + type: object + properties: + address: + type: string + collateral: + 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. + liabilities: + type: string + title: For recording + interest_paid: + type: string + title: For recording + leverage: + type: string + title: For recording + leveraged_lp_amount: + type: string + position_health: + type: string + id: + type: string + format: uint64 + amm_pool_id: + type: string + format: uint64 + stop_loss_price: + type: string + pagination: + 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: |- + PageResponse is to be embedded in gRPC response messages where the + corresponding request message has used PageRequest. + + message SomeResponse { + repeated Bar results = 1; + PageResponse page = 2; + } + elys.leveragelp.PositionsResponse: + type: object + properties: + positions: + type: array + items: + type: object + properties: + address: + type: string + collateral: + 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. + liabilities: + type: string + title: For recording + interest_paid: + type: string + title: For recording + leverage: + type: string + title: For recording + leveraged_lp_amount: + type: string + position_health: + type: string + id: + type: string + format: uint64 + amm_pool_id: + type: string + format: uint64 + stop_loss_price: + type: string + pagination: + 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: |- + PageResponse is to be embedded in gRPC response messages where the + corresponding request message has used PageRequest. + + message SomeResponse { + repeated Bar results = 1; + PageResponse page = 2; + } + elys.leveragelp.QueryAllPoolResponse: + type: object + properties: + pool: + type: array + items: + type: object + properties: + amm_pool_id: + type: string + format: uint64 + health: + type: string + enabled: + type: boolean + closed: + type: boolean + leveraged_lp_amount: + type: string + leverage_max: + type: string + pagination: + 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: |- + PageResponse is to be embedded in gRPC response messages where the + corresponding request message has used PageRequest. + + message SomeResponse { + repeated Bar results = 1; + PageResponse page = 2; + } + elys.leveragelp.QueryCloseEstResponse: type: object properties: - positions: - type: array - items: - type: object - properties: - address: - type: string - collateral: - 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. - liabilities: - type: string - title: For recording - interest_paid: - type: string - title: For recording - leverage: - type: string - title: For recording - leveraged_lp_amount: - type: string - position_health: - type: string - id: - type: string - format: uint64 - amm_pool_id: - type: string - format: uint64 - stop_loss_price: - type: string - pagination: + liability: + type: string + weight_balance_ratio: + type: string + amount_returned: + type: string + elys.leveragelp.QueryGetPoolResponse: + type: object + properties: + pool: 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: + amm_pool_id: type: string format: uint64 - title: >- - total is total number of results available if - PageRequest.count_total - - was set, its value is undefined otherwise - description: |- - PageResponse is to be embedded in gRPC response messages where the - corresponding request message has used PageRequest. - - message SomeResponse { - repeated Bar results = 1; - PageResponse page = 2; - } - elys.leveragelp.PositionsResponse: + health: + type: string + enabled: + type: boolean + closed: + type: boolean + leveraged_lp_amount: + type: string + leverage_max: + type: string + elys.leveragelp.QueryOpenEstResponse: type: object properties: - positions: + position_size: + type: string + weight_balance_ratio: + type: string + borrow_fee: + type: string + elys.leveragelp.QueryRewardsResponse: + type: object + properties: + rewards: type: array items: type: object properties: - address: + position_id: type: string - collateral: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an amount. + 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 + NOTE: The amount field is an Int which implements the custom + method - signatures required by gogoproto. - liabilities: - type: string - title: For recording - interest_paid: - type: string - title: For recording - leverage: - type: string - title: For recording - leveraged_lp_amount: - type: string - position_health: - type: string - id: - type: string - format: uint64 - amm_pool_id: + signatures required by gogoproto. + total_rewards: + type: array + items: + type: object + properties: + denom: type: string - format: uint64 - stop_loss_price: + amount: type: string - pagination: - 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: |- - PageResponse is to be embedded in gRPC response messages where the - corresponding request message has used PageRequest. + description: |- + Coin defines a token with a denomination and an amount. - message SomeResponse { - repeated Bar results = 1; - PageResponse page = 2; - } - elys.leveragelp.QueryAllPoolResponse: + NOTE: The amount field is an Int which implements the custom method + signatures required by gogoproto. + elys.leveragelp.RewardInfo: type: object properties: - pool: + position_id: + type: string + format: uint64 + reward: type: array items: type: object properties: - amm_pool_id: - type: string - format: uint64 - health: - type: string - enabled: - type: boolean - closed: - type: boolean - leveraged_lp_amount: + denom: type: string - leverage_max: + amount: type: string - pagination: - 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: |- - PageResponse is to be embedded in gRPC response messages where the - corresponding request message has used PageRequest. + description: |- + Coin defines a token with a denomination and an amount. - message SomeResponse { - repeated Bar results = 1; - PageResponse page = 2; - } - elys.leveragelp.QueryGetPoolResponse: - type: object - properties: - pool: - type: object - properties: - amm_pool_id: - type: string - format: uint64 - health: - type: string - enabled: - type: boolean - closed: - type: boolean - leveraged_lp_amount: - type: string - leverage_max: - type: string + NOTE: The amount field is an Int which implements the custom method + signatures required by gogoproto. elys.leveragelp.StatusResponse: type: object properties: @@ -85629,20 +87037,6 @@ 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: @@ -85721,18 +87115,6 @@ definitions: 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] @@ -85766,28 +87148,21 @@ definitions: 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 + gas_apr: + type: string + title: Gas APR, updated at every distribution external_incentive_apr: type: string title: External Incentive APR, updated at every distribution @@ -85796,7 +87171,6 @@ definitions: items: type: string title: external reward denoms on the pool - title: Pool Info elys.masterchef.PoolMultiplier: type: object properties: @@ -85878,18 +87252,6 @@ definitions: 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] @@ -85931,28 +87293,21 @@ definitions: 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 + gas_apr: + type: string + title: Gas APR, updated at every distribution external_incentive_apr: type: string title: External Incentive APR, updated at every distribution @@ -85961,7 +87316,6 @@ definitions: items: type: string title: external reward denoms on the pool - title: Pool Info elys.masterchef.QueryPoolRewardInfoResponse: type: object properties: @@ -86471,6 +87825,10 @@ definitions: total_blocks_per_year: type: string format: int64 + rewards_data_lifetime: + type: string + format: int64 + title: default 1 day = 86400 wasm_max_label_size: type: string wasm_max_size: @@ -86496,6 +87854,10 @@ definitions: total_blocks_per_year: type: string format: int64 + rewards_data_lifetime: + type: string + format: int64 + title: default 1 day = 86400 wasm_max_label_size: type: string wasm_max_size: diff --git a/proto/elys/incentive/dex_rewards_traker.proto b/proto/elys/incentive/dex_rewards_traker.proto deleted file mode 100644 index 99949591b..000000000 --- a/proto/elys/incentive/dex_rewards_traker.proto +++ /dev/null @@ -1,29 +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"; - -// 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 - ]; -} diff --git a/proto/elys/incentive/elys_staked.proto b/proto/elys/incentive/elys_staked.proto deleted file mode 100644 index 2ca15b45c..000000000 --- a/proto/elys/incentive/elys_staked.proto +++ /dev/null @@ -1,17 +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"; - -// 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/incentive/genesis.proto b/proto/elys/incentive/genesis.proto index 7421b44af..327abeaaf 100644 --- a/proto/elys/incentive/genesis.proto +++ b/proto/elys/incentive/genesis.proto @@ -2,9 +2,6 @@ syntax = "proto3"; package elys.incentive; -import "gogoproto/gogo.proto"; -import "cosmos/base/v1beta1/coin.proto"; - option go_package = "github.com/elys-network/elys/x/incentive/types"; diff --git a/proto/elys/incentive/incentive.proto b/proto/elys/incentive/incentive.proto deleted file mode 100644 index 3a2784c48..000000000 --- a/proto/elys/incentive/incentive.proto +++ /dev/null @@ -1,45 +0,0 @@ -syntax = "proto3"; -package elys.incentive; -import "gogoproto/gogo.proto"; -import "google/protobuf/timestamp.proto"; - -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 - ]; -} \ No newline at end of file diff --git a/proto/elys/incentive/params.proto b/proto/elys/incentive/params.proto deleted file mode 100644 index 462ac9246..000000000 --- a/proto/elys/incentive/params.proto +++ /dev/null @@ -1,58 +0,0 @@ -syntax = "proto3"; -package elys.incentive; - -import "gogoproto/gogo.proto"; -import "elys/incentive/incentive.proto"; -import "elys/incentive/pool.proto"; -import "elys/incentive/dex_rewards_traker.proto"; - -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; - - // 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`. - string reward_portion_for_stakers = 4 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false - ]; - - // Pool information - // poolId, reward wallet, **multiplier**, dex rewards given - repeated PoolInfo pool_infos = 5 [ (gogoproto.nullable) = false ]; - - // Number of blocks to update elys staked amount for delegators - int64 elys_stake_snap_interval = 6; - - // Tracking dex rewards given to stakers - DexRewardsTracker dex_rewards_stakers = 7 [ (gogoproto.nullable) = false ]; - - // Tracking dex rewards given to LPs - DexRewardsTracker dex_rewards_lps = 8 [ (gogoproto.nullable) = false ]; - - // Maximum eden reward apr for stakers - [0 - 0.3] - string max_eden_reward_apr_stakers = 9 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false - ]; - - // Maximum eden reward apr for lps - [0 - 0.3] - string max_eden_reward_apr_lps = 10 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false - ]; - - // Distribution interval in blocks - number of blocks on distribution epoch - int64 distribution_interval = 11; -} diff --git a/proto/elys/incentive/pool.proto b/proto/elys/incentive/pool.proto deleted file mode 100644 index 1dd2f4080..000000000 --- a/proto/elys/incentive/pool.proto +++ /dev/null @@ -1,45 +0,0 @@ -syntax = "proto3"; -package elys.incentive; - -option go_package = "github.com/elys-network/elys/x/incentive/types"; - -import "gogoproto/gogo.proto"; -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 - ]; -} \ No newline at end of file diff --git a/proto/elys/incentive/tx.proto b/proto/elys/incentive/tx.proto index e64906841..ff2fb6b45 100644 --- a/proto/elys/incentive/tx.proto +++ b/proto/elys/incentive/tx.proto @@ -4,7 +4,6 @@ package elys.incentive; import "gogoproto/gogo.proto"; import "cosmos_proto/cosmos.proto"; -import "elys/commitment/params.proto"; import "cosmos/base/v1beta1/coin.proto"; option go_package = "github.com/elys-network/elys/x/incentive/types"; diff --git a/proto/elys/leveragelp/query.proto b/proto/elys/leveragelp/query.proto index 665ed8256..0d3a7dcd2 100644 --- a/proto/elys/leveragelp/query.proto +++ b/proto/elys/leveragelp/query.proto @@ -4,6 +4,7 @@ package elys.leveragelp; import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; +import "cosmos/base/v1beta1/coin.proto"; import "cosmos/base/query/v1beta1/pagination.proto"; import "elys/leveragelp/params.proto"; import "elys/leveragelp/types.proto"; @@ -13,7 +14,6 @@ option go_package = "github.com/elys-network/elys/x/leveragelp/types"; // Query defines the gRPC querier service. service Query { - // Parameters queries the parameters of the module. rpc Params(ParamsRequest) returns (ParamsResponse) { option (google.api.http).get = "/elys-network/elys/leveragelp/params"; @@ -69,13 +69,30 @@ service Query { option (google.api.http).get = "/elys-network/elys/leveragelp/position/{address}/{id}"; } + + // Get estimated amount of return value opening a position + rpc OpenEst(QueryOpenEstRequest) returns (QueryOpenEstResponse) { + option (google.api.http).get = + "/elys-network/elys/leveragelp/open_estimation"; + } + + // Get estimated amount of return value closing a position + rpc CloseEst(QueryCloseEstRequest) returns (QueryCloseEstResponse) { + option (google.api.http).get = + "/elys-network/elys/leveragelp/close_estimation"; + } + + // Queries rewards on leveragelp + rpc Rewards(QueryRewardsRequest) returns (QueryRewardsResponse) { + option (google.api.http).get = + "/elys-network/elys/leveragelp/rewards/{address}"; + } } // ParamsRequest is request type for the Query/Params RPC method. message ParamsRequest {} // ParamsResponse is response type for the Query/Params RPC method. message ParamsResponse { - // params holds all the parameters of this module. Params params = 1 [ (gogoproto.nullable) = false ]; } @@ -151,3 +168,75 @@ message PositionRequest { } message PositionResponse { Position position = 1; } + +message QueryOpenEstRequest { + string collateral_asset = 1; + string collateral_amount = 2 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; + uint64 amm_pool_id = 3; + string leverage = 4 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; +} + +message QueryOpenEstResponse { + string position_size = 1 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; + string weight_balance_ratio = 2 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + string borrow_fee = 3 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; +} + +message QueryCloseEstRequest { + string owner = 1; + uint64 id = 2; + string lp_amount = 3 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; +} + +message QueryRewardsRequest { + string address = 1; + repeated uint64 ids = 2; +} + +message RewardInfo { + uint64 position_id = 1; + repeated cosmos.base.v1beta1.Coin reward = 2 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" + ]; +} +message QueryRewardsResponse { + 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 QueryCloseEstResponse { + string liability = 1 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; + string weight_balance_ratio = 2 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + string amount_returned = 3 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; +} \ No newline at end of file diff --git a/proto/elys/leveragelp/tx.proto b/proto/elys/leveragelp/tx.proto index d5185e028..6e05da2b3 100644 --- a/proto/elys/leveragelp/tx.proto +++ b/proto/elys/leveragelp/tx.proto @@ -11,12 +11,13 @@ import "elys/leveragelp/pool.proto"; // Msg defines the Msg service. service Msg { - rpc Open (MsgOpen ) returns (MsgOpenResponse ); - rpc Close (MsgClose ) returns (MsgCloseResponse ); - rpc UpdateParams (MsgUpdateParams ) returns (MsgUpdateParamsResponse ); - rpc UpdatePools (MsgUpdatePools ) returns (MsgUpdatePoolsResponse ); - rpc Whitelist (MsgWhitelist ) returns (MsgWhitelistResponse ); - rpc Dewhitelist (MsgDewhitelist ) returns (MsgDewhitelistResponse ); + rpc Open(MsgOpen) returns (MsgOpenResponse); + rpc Close(MsgClose) returns (MsgCloseResponse); + rpc ClaimRewards(MsgClaimRewards) returns (MsgClaimRewardsResponse); + rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse); + rpc UpdatePools(MsgUpdatePools) returns (MsgUpdatePoolsResponse); + rpc Whitelist(MsgWhitelist) returns (MsgWhitelistResponse); + rpc Dewhitelist(MsgDewhitelist) returns (MsgDewhitelistResponse); rpc UpdateStopLoss (MsgUpdateStopLoss) returns (MsgUpdateStopLossResponse); } message MsgOpen { @@ -38,6 +39,12 @@ message MsgClose { message MsgCloseResponse {} +message MsgClaimRewards { + string sender = 1; + repeated uint64 ids = 2; +} +message MsgClaimRewardsResponse {} + message MsgUpdateParams { // authority is the address that controls the module (defaults to x/gov unless diff --git a/proto/elys/leveragelp/types.proto b/proto/elys/leveragelp/types.proto index 9fed4436e..991163b31 100644 --- a/proto/elys/leveragelp/types.proto +++ b/proto/elys/leveragelp/types.proto @@ -38,4 +38,7 @@ message Position { ]; } -message WhiteList { repeated string validator_list = 1; } +message AddressId { + string address = 1; + uint64 id = 2; +} \ No newline at end of file diff --git a/proto/elys/masterchef/dex_rewards_traker.proto b/proto/elys/masterchef/dex_rewards_traker.proto deleted file mode 100644 index d67804812..000000000 --- a/proto/elys/masterchef/dex_rewards_traker.proto +++ /dev/null @@ -1,21 +0,0 @@ -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/genesis.proto b/proto/elys/masterchef/genesis.proto index 01e9fc9f1..16a947574 100644 --- a/proto/elys/masterchef/genesis.proto +++ b/proto/elys/masterchef/genesis.proto @@ -16,4 +16,5 @@ message GenesisState { repeated PoolInfo pool_infos = 4 [(gogoproto.nullable) = false]; repeated PoolRewardInfo pool_reward_infos = 5 [(gogoproto.nullable) = false]; repeated UserRewardInfo user_reward_infos = 6 [(gogoproto.nullable) = false]; + repeated PoolRewardsAccum pool_rewards_accum = 7 [(gogoproto.nullable) = false]; } diff --git a/proto/elys/masterchef/params.proto b/proto/elys/masterchef/params.proto index 2d49e89a5..2febb1cd8 100644 --- a/proto/elys/masterchef/params.proto +++ b/proto/elys/masterchef/params.proto @@ -4,7 +4,6 @@ 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"; @@ -24,19 +23,16 @@ message Params { (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 [ + string max_eden_reward_apr_lps = 4 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false ]; - repeated SupportedRewardDenom supported_reward_denoms = 6; + repeated SupportedRewardDenom supported_reward_denoms = 5; - string protocol_revenue_address = 7; + string protocol_revenue_address = 6; } @@ -46,4 +42,49 @@ message SupportedRewardDenom { (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false ]; -} \ No newline at end of file +} + +message LegacyDexRewardsTracker { + // 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 + ]; +} + +// Params defines the parameters for the module. +message LegacyParams { + 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 + LegacyDexRewardsTracker 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; +} diff --git a/proto/elys/masterchef/pool.proto b/proto/elys/masterchef/pool.proto index 1bf108d2f..4a27ad34e 100644 --- a/proto/elys/masterchef/pool.proto +++ b/proto/elys/masterchef/pool.proto @@ -5,9 +5,7 @@ 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; @@ -16,38 +14,28 @@ message PoolInfo { (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 [ + string eden_apr = 4 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false ]; // Dex APR, updated at every distribution - string dex_apr = 8 [ + string dex_apr = 5 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false - ]; + ]; + // Gas APR, updated at every distribution + string gas_apr = 6 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; // External Incentive APR, updated at every distribution - string external_incentive_apr = 9 [ + string external_incentive_apr = 7 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false ]; // external reward denoms on the pool - repeated string external_reward_denoms = 10; + repeated string external_reward_denoms = 8; } message PoolRewardInfo { @@ -72,4 +60,56 @@ message UserRewardInfo { (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false ]; -} \ No newline at end of file +} + +message PoolRewardsAccum { + uint64 pool_id = 1; + int64 block_height = 2; + uint64 timestamp = 3; + string dex_reward = 4 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + string gas_reward = 5 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + string eden_reward = 6 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; +} + +message LegacyPoolInfo { + uint64 pool_id = 1; + string reward_wallet = 2; + string multiplier = 3 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + string num_blocks = 4 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; + string dex_reward_amount_given = 5 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + string eden_reward_amount_given = 6 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; + string eden_apr = 7 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + string dex_apr = 8 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + string external_incentive_apr = 9 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + repeated string external_reward_denoms = 10; +} diff --git a/proto/elys/parameter/params.proto b/proto/elys/parameter/params.proto index b3834eedb..371fe3a7c 100644 --- a/proto/elys/parameter/params.proto +++ b/proto/elys/parameter/params.proto @@ -23,15 +23,16 @@ message Params { ]; string broker_address = 4; int64 total_blocks_per_year = 5; - string wasm_max_label_size = 6 [ + int64 rewards_data_lifetime = 6; // default 1 day = 86400 + string wasm_max_label_size = 7 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false ]; - string wasm_max_size = 7 [ + string wasm_max_size = 8 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false ]; - string wasm_max_proposal_wasm_size = 8 [ + string wasm_max_proposal_wasm_size = 9 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false ]; @@ -53,4 +54,5 @@ message LegacyParams { (gogoproto.nullable) = false ]; string broker_address = 4; + int64 total_blocks_per_year = 5; } \ No newline at end of file diff --git a/testutil/keeper/incentive.go b/testutil/keeper/incentive.go index 8ea75d77f..53e98a145 100644 --- a/testutil/keeper/incentive.go +++ b/testutil/keeper/incentive.go @@ -54,8 +54,5 @@ func IncentiveKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) { ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, log.NewNopLogger()) - // Initialize params - k.SetParams(ctx, types.DefaultParams()) - return k, ctx } diff --git a/testutil/keeper/leveragelp.go b/testutil/keeper/leveragelp.go index 40dc29ad7..70a1beb89 100644 --- a/testutil/keeper/leveragelp.go +++ b/testutil/keeper/leveragelp.go @@ -42,6 +42,7 @@ func LeveragelpKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) { nil, nil, nil, + nil, ) ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, log.NewNopLogger()) diff --git a/wasmbindings/types/types.go b/wasmbindings/types/types.go index 4ceadaf2d..09dc08b84 100644 --- a/wasmbindings/types/types.go +++ b/wasmbindings/types/types.go @@ -187,6 +187,9 @@ type ElysQuery struct { LeveragelpPool *leveragelptypes.QueryGetPoolRequest `json:"leveragelp_pool,omitempty"` LeveragelpPools *leveragelptypes.QueryAllPoolRequest `json:"leveragelp_pools,omitempty"` LeveragelpPosition *leveragelptypes.PositionRequest `json:"leveragelp_position,omitempty"` + LeveragelpOpenEst *leveragelptypes.QueryOpenEstRequest `json:"leveragelp_open_estimation,omitempty"` + LeveragelpCloseEst *leveragelptypes.QueryCloseEstRequest `json:"leveragelp_close_estimation,omitempty"` + LeveragelpRewards *leveragelptypes.QueryRewardsRequest `json:"leveragelp_rewards,omitempty"` // perpetual queriers PerpetualParams *perpetualtypes.ParamsRequest `json:"perpetual_params,omitempty"` @@ -300,6 +303,7 @@ type ElysMsg struct { // leveragelp messages LeveragelpOpen *leveragelptypes.MsgOpen `json:"leveragelp_open,omitempty"` LeveragelpClose *leveragelptypes.MsgClose `json:"leveragelp_close,omitempty"` + LeveragelpClaimRewards *leveragelptypes.MsgClaimRewards `json:"leveragelp_claim_rewards,omitempty"` LeveragelpUpdateStopLoss *leveragelptypes.MsgUpdateStopLoss `json:"leveragelp_update_stop_loss,omitempty"` // perpetual messages diff --git a/x/amm/keeper/query_exit_pool_estimation.go b/x/amm/keeper/query_exit_pool_estimation.go index 71c0cb970..65b828f3d 100644 --- a/x/amm/keeper/query_exit_pool_estimation.go +++ b/x/amm/keeper/query_exit_pool_estimation.go @@ -18,7 +18,7 @@ func (k Keeper) ExitPoolEstimation(goCtx context.Context, req *types.QueryExitPo ctx := sdk.UnwrapSDKContext(goCtx) - exitCoins, err := k.exitPoolEstimation(ctx, req.PoolId, req.ShareAmountIn, req.TokenOutDenom) + exitCoins, _, err := k.ExitPoolEst(ctx, req.PoolId, req.ShareAmountIn, req.TokenOutDenom) if err != nil { return nil, err } @@ -28,28 +28,28 @@ func (k Keeper) ExitPoolEstimation(goCtx context.Context, req *types.QueryExitPo }, nil } -func (k Keeper) exitPoolEstimation( +func (k Keeper) ExitPoolEst( ctx sdk.Context, poolId uint64, shareInAmount math.Int, tokenOutDenom string, -) (exitCoins sdk.Coins, err error) { +) (exitCoins sdk.Coins, weightBalanceBonus math.LegacyDec, err error) { pool, poolExists := k.GetPool(ctx, poolId) if !poolExists { - return sdk.Coins{}, types.ErrInvalidPoolId + return sdk.Coins{}, math.LegacyZeroDec(), types.ErrInvalidPoolId } totalSharesAmount := pool.GetTotalShares() if shareInAmount.GTE(totalSharesAmount.Amount) { - return sdk.Coins{}, errorsmod.Wrapf(types.ErrInvalidMathApprox, "Trying to exit >= the number of shares contained in the pool.") + return sdk.Coins{}, math.LegacyZeroDec(), errorsmod.Wrapf(types.ErrInvalidMathApprox, "Trying to exit >= the number of shares contained in the pool.") } else if shareInAmount.LTE(sdk.ZeroInt()) { - return sdk.Coins{}, errorsmod.Wrapf(types.ErrInvalidMathApprox, "Trying to exit a negative amount of shares") + return sdk.Coins{}, math.LegacyZeroDec(), errorsmod.Wrapf(types.ErrInvalidMathApprox, "Trying to exit a negative amount of shares") } - exitingCoins, err := pool.CalcExitPoolCoinsFromShares(ctx, k.oracleKeeper, k.accountedPoolKeeper, shareInAmount, tokenOutDenom) + exitCoins, weightBalanceBonus, err = pool.CalcExitPoolCoinsFromShares(ctx, k.oracleKeeper, k.accountedPoolKeeper, shareInAmount, tokenOutDenom) if err != nil { - return sdk.Coins{}, err + return sdk.Coins{}, math.LegacyZeroDec(), err } - return exitingCoins, nil + return exitCoins, weightBalanceBonus, nil } diff --git a/x/amm/keeper/query_join_pool_estimation.go b/x/amm/keeper/query_join_pool_estimation.go index fca4f0cf6..cc1ca69e6 100644 --- a/x/amm/keeper/query_join_pool_estimation.go +++ b/x/amm/keeper/query_join_pool_estimation.go @@ -16,7 +16,7 @@ func (k Keeper) JoinPoolEstimation(goCtx context.Context, req *types.QueryJoinPo } ctx := sdk.UnwrapSDKContext(goCtx) - tokensIn, sharesOut, slippage, weightBalanceBonus, err := k.joinPoolEstimation(ctx, req.PoolId, req.AmountsIn) + tokensIn, sharesOut, slippage, weightBalanceBonus, err := k.JoinPoolEst(ctx, req.PoolId, req.AmountsIn) if err != nil { return nil, err } @@ -30,7 +30,7 @@ func (k Keeper) JoinPoolEstimation(goCtx context.Context, req *types.QueryJoinPo }, nil } -func (k Keeper) joinPoolEstimation( +func (k Keeper) JoinPoolEst( ctx sdk.Context, poolId uint64, tokenInMaxs sdk.Coins, diff --git a/x/amm/types/calc_exit_pool.go b/x/amm/types/calc_exit_pool.go index 0e1e0120f..3435e3696 100644 --- a/x/amm/types/calc_exit_pool.go +++ b/x/amm/types/calc_exit_pool.go @@ -80,10 +80,17 @@ func CalcExitValueWithoutSlippage(ctx sdk.Context, oracleKeeper OracleKeeper, ac } // CalcExitPool returns how many tokens should come out, when exiting k LP shares against a "standard" CFMM -func CalcExitPool(ctx sdk.Context, oracleKeeper OracleKeeper, pool Pool, accountedPoolKeeper AccountedPoolKeeper, exitingShares math.Int, tokenOutDenom string) (sdk.Coins, error) { +func CalcExitPool( + ctx sdk.Context, + oracleKeeper OracleKeeper, + pool Pool, + accountedPoolKeeper AccountedPoolKeeper, + exitingShares math.Int, + tokenOutDenom string, +) (exitCoins sdk.Coins, weightBalanceBonus math.LegacyDec, err error) { totalShares := pool.GetTotalShares() if exitingShares.GTE(totalShares.Amount) { - return sdk.Coins{}, errorsmod.Wrapf(ErrLimitMaxAmount, ErrMsgFormatSharesLargerThanMax, exitingShares, totalShares) + return sdk.Coins{}, math.LegacyZeroDec(), errorsmod.Wrapf(ErrLimitMaxAmount, ErrMsgFormatSharesLargerThanMax, exitingShares, totalShares) } // refundedShares = exitingShares * (1 - exit fee) @@ -101,12 +108,12 @@ func CalcExitPool(ctx sdk.Context, oracleKeeper OracleKeeper, pool Pool, account tokenPrice := oracleKeeper.GetAssetPriceFromDenom(ctx, tokenOutDenom) exitValueWithoutSlippage, err := CalcExitValueWithoutSlippage(ctx, oracleKeeper, accountedPoolKeeper, pool, exitingShares, tokenOutDenom) if err != nil { - return sdk.Coins{}, err + return sdk.Coins{}, math.LegacyZeroDec(), err } // Ensure tokenPrice is not zero to avoid division by zero if tokenPrice.IsZero() { - return sdk.Coins{}, ErrAmountTooLow + return sdk.Coins{}, math.LegacyZeroDec(), ErrAmountTooLow } oracleOutAmount := exitValueWithoutSlippage.Quo(tokenPrice) @@ -116,11 +123,11 @@ func CalcExitPool(ctx sdk.Context, oracleKeeper OracleKeeper, pool Pool, account sdk.Coins{sdk.NewCoin(tokenOutDenom, oracleOutAmount.RoundInt())}, ) if err != nil { - return sdk.Coins{}, err + return sdk.Coins{}, math.LegacyZeroDec(), err } for _, asset := range newAssetPools { if asset.Token.Amount.IsNegative() { - return sdk.Coins{}, fmt.Errorf("out amount exceeds liquidity balance") + return sdk.Coins{}, math.LegacyZeroDec(), fmt.Errorf("out amount exceeds liquidity balance") } } @@ -143,7 +150,7 @@ func CalcExitPool(ctx sdk.Context, oracleKeeper OracleKeeper, pool Pool, account } tokenOutAmount := oracleOutAmount.Mul(sdk.OneDec().Sub(weightBreakingFee)).RoundInt() - return sdk.Coins{sdk.NewCoin(tokenOutDenom, tokenOutAmount)}, nil + return sdk.Coins{sdk.NewCoin(tokenOutDenom, tokenOutAmount)}, weightBreakingFee.Neg(), nil } for _, asset := range poolLiquidity { @@ -153,10 +160,10 @@ func CalcExitPool(ctx sdk.Context, oracleKeeper OracleKeeper, pool Pool, account continue } if exitAmt.GTE(asset.Amount) { - return sdk.Coins{}, errors.New("too many shares out") + return sdk.Coins{}, math.LegacyZeroDec(), errors.New("too many shares out") } exitedCoins = exitedCoins.Add(sdk.NewCoin(asset.Denom, exitAmt)) } - return exitedCoins, nil + return exitedCoins, math.LegacyZeroDec(), nil } diff --git a/x/amm/types/pool.go b/x/amm/types/pool.go index 9995110ce..63436197b 100644 --- a/x/amm/types/pool.go +++ b/x/amm/types/pool.go @@ -257,7 +257,13 @@ func (pool Pool) GetMaximalNoSwapLPAmount(shareOutAmount math.Int) (neededLpLiqu return neededLpLiquidity, nil } -func (p *Pool) CalcExitPoolCoinsFromShares(ctx sdk.Context, oracleKeeper OracleKeeper, accountedPoolKeeper AccountedPoolKeeper, exitingShares math.Int, tokenOutDenom string) (exitedCoins sdk.Coins, err error) { +func (p *Pool) CalcExitPoolCoinsFromShares( + ctx sdk.Context, + oracleKeeper OracleKeeper, + accountedPoolKeeper AccountedPoolKeeper, + exitingShares math.Int, + tokenOutDenom string, +) (exitedCoins sdk.Coins, weightBalanceBonus math.LegacyDec, err error) { return CalcExitPool(ctx, oracleKeeper, *p, accountedPoolKeeper, exitingShares, tokenOutDenom) } diff --git a/x/amm/types/pool_exit_pool.go b/x/amm/types/pool_exit_pool.go index 97a439e41..7d63de1d4 100644 --- a/x/amm/types/pool_exit_pool.go +++ b/x/amm/types/pool_exit_pool.go @@ -6,7 +6,7 @@ import ( ) func (p *Pool) ExitPool(ctx sdk.Context, oracleKeeper OracleKeeper, accountedPoolKeeper AccountedPoolKeeper, exitingShares math.Int, tokenOutDenom string) (exitingCoins sdk.Coins, err error) { - exitingCoins, err = p.CalcExitPoolCoinsFromShares(ctx, oracleKeeper, accountedPoolKeeper, exitingShares, tokenOutDenom) + exitingCoins, _, err = p.CalcExitPoolCoinsFromShares(ctx, oracleKeeper, accountedPoolKeeper, exitingShares, tokenOutDenom) if err != nil { return sdk.Coins{}, err } diff --git a/x/incentive/keeper/abci.go b/x/incentive/keeper/abci.go deleted file mode 100644 index b140c7b7a..000000000 --- a/x/incentive/keeper/abci.go +++ /dev/null @@ -1,16 +0,0 @@ -package keeper - -import ( - "time" - - "github.com/cosmos/cosmos-sdk/telemetry" - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/elys-network/elys/x/incentive/types" -) - -// EndBlocker of incentive module -func (k Keeper) EndBlocker(ctx sdk.Context) { - defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyEndBlocker) - -} diff --git a/x/incentive/keeper/apr.go b/x/incentive/keeper/apr.go index 702dd1c45..a062853b1 100644 --- a/x/incentive/keeper/apr.go +++ b/x/incentive/keeper/apr.go @@ -13,14 +13,9 @@ 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 estakingParams.StakeIncentives == nil || masterchefParams.LpIncentives == nil { return sdk.ZeroInt(), errorsmod.Wrap(types.ErrNoInflationaryParams, "no inflationary params available") @@ -109,13 +104,12 @@ func (k Keeper) CalculateApr(ctx sdk.Context, query *types.QueryAprRequest) (mat return sdk.ZeroInt(), nil } - // DexReward amount per day = amount distributed / duration(in seconds) * total seconds per day. + usdcDenomPrice := k.oracleKeeper.GetAssetPriceFromDenom(ctx, baseCurrency) yearlyDexRewardAmount := amount. + Mul(usdcDenomPrice). MulInt64(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(edenDenomPrice). diff --git a/x/incentive/keeper/elys_stake_change.go b/x/incentive/keeper/elys_stake_change.go deleted file mode 100644 index 3b2168021..000000000 --- a/x/incentive/keeper/elys_stake_change.go +++ /dev/null @@ -1,36 +0,0 @@ -package keeper - -import ( - "github.com/cosmos/cosmos-sdk/store/prefix" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/elys-network/elys/x/incentive/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/incentive/keeper/elys_staked.go b/x/incentive/keeper/elys_staked.go deleted file mode 100644 index 9578c4f19..000000000 --- a/x/incentive/keeper/elys_staked.go +++ /dev/null @@ -1,51 +0,0 @@ -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/incentive/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/incentive/keeper/keeper.go b/x/incentive/keeper/keeper.go index 73a29fdbb..9b325e80e 100644 --- a/x/incentive/keeper/keeper.go +++ b/x/incentive/keeper/keeper.go @@ -102,36 +102,35 @@ func (k Keeper) CalculateTVL(ctx sdk.Context) sdk.Dec { // 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.masterchef.GetPool(ctx, poolId) - if !found { - return sdk.ZeroDec(), sdk.Coins{} - } - - // Fetch incentive params - params := k.masterchef.GetParams(ctx) - if params.LpIncentives == nil { - return sdk.ZeroDec(), sdk.Coins{} + dailyDexRewardsTotal := math.LegacyZeroDec() + dailyGasRewardsTotal := math.LegacyZeroDec() + dailyEdenRewardsTotal := math.LegacyZeroDec() + firstAccum := k.masterchef.FirstPoolRewardsAccum(ctx, poolId) + lastAccum := k.masterchef.FirstPoolRewardsAccum(ctx, poolId) + if lastAccum.Timestamp != 0 { + if firstAccum.Timestamp == lastAccum.Timestamp { + dailyDexRewardsTotal = lastAccum.DexReward + dailyGasRewardsTotal = lastAccum.GasReward + dailyEdenRewardsTotal = lastAccum.EdenReward + } else { + dailyDexRewardsTotal = lastAccum.DexReward.Sub(firstAccum.DexReward) + dailyGasRewardsTotal = lastAccum.GasReward.Sub(firstAccum.GasReward) + dailyEdenRewardsTotal = lastAccum.EdenReward.Sub(firstAccum.EdenReward) + } } - // Dex reward Apr per pool = total accumulated usdc rewards for 7 day * 52/ tvl of pool - dailyDexRewardsTotal := poolInfo.DexRewardAmountGiven. - 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. - Quo(poolInfo.NumBlocks) - baseCurrency, found := k.assetProfileKeeper.GetUsdcDenom(ctx) if !found { return sdk.ZeroDec(), sdk.Coins{} } - rewardCoins := sdk.NewCoins(sdk.NewCoin(ptypes.Eden, dailyEdenRewardsTotal)) - rewardCoins = rewardCoins.Add(sdk.NewCoin(baseCurrency, math.Int(dailyDexRewardsTotal))) + rewardCoins := sdk.NewCoins(sdk.NewCoin(ptypes.Eden, dailyEdenRewardsTotal.RoundInt())) + rewardCoins = rewardCoins.Add(sdk.NewCoin(baseCurrency, dailyDexRewardsTotal.Add(dailyGasRewardsTotal).RoundInt())) usdcDenomPrice := k.oracleKeeper.GetAssetPriceFromDenom(ctx, baseCurrency) edenDenomPrice := k.amm.GetEdenDenomPrice(ctx, baseCurrency) - totalRewardsUsd := usdcDenomPrice.Mul(dailyDexRewardsTotal).Add(edenDenomPrice.MulInt(dailyEdenRewardsTotal)) + totalRewardsUsd := usdcDenomPrice.Mul(dailyDexRewardsTotal.Add(dailyGasRewardsTotal)). + Add(edenDenomPrice.Mul(dailyEdenRewardsTotal)) return totalRewardsUsd, rewardCoins } diff --git a/x/incentive/keeper/params.go b/x/incentive/keeper/params.go deleted file mode 100644 index 1ef46c079..000000000 --- a/x/incentive/keeper/params.go +++ /dev/null @@ -1,26 +0,0 @@ -package keeper - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/elys-network/elys/x/incentive/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/incentive/migrations/v11_migration.go b/x/incentive/migrations/v11_migration.go index 3a82a561f..0317701c7 100644 --- a/x/incentive/migrations/v11_migration.go +++ b/x/incentive/migrations/v11_migration.go @@ -1,177 +1,9 @@ package migrations import ( - "fmt" - 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 { - fmt.Println("Running incentive v11 migration ...") - fmt.Println("1) Running PoolInfos migration ...") - // 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{}, - }) - } - - fmt.Println("2) Setting masterchef params ...") - // 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", - )) - - fmt.Println("3) Running init genesis for estaking ...") - // 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(), - }, - }, - }) - - fmt.Println("4) Moving staking snapshots to estaking ...") - // initiate delegation snapshot - stakedSnapshots := m.incentiveKeeper.GetAllElysStaked(ctx) - for _, snap := range stakedSnapshots { - m.estakingKeeper.SetElysStaked(ctx, estakingtypes.ElysStaked{ - Address: snap.Address, - Amount: snap.Amount, - }) - } - - fmt.Println("5) Running InitGenesis for distribution ...") - // initiate missing distribution module data - m.distrKeeper.InitGenesis(ctx, *distrtypes.DefaultGenesisState()) - - fmt.Println("6) Running validator creation hooks ...") - // 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) - } - } - - fmt.Println("7) Running delegation hooks ...") - // 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().BeforeDelegationCreated(ctx, delAddr, valAddr) - if err != nil { - panic(err) - } - err = m.estakingKeeper.Hooks().AfterDelegationModified(ctx, delAddr, valAddr) - if err != nil { - panic(err) - } - } - - fmt.Println("8) Running commitment migrations ...") - // 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) - commParams := m.commitmentKeeper.GetLegacyParams(ctx) - numberOfCommitments := uint64(0) - 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) - for _, committed := range commitments.CommittedTokens { - if committed.Denom == ptypes.Eden && committed.Amount.IsPositive() && 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 && committed.Amount.IsPositive() && 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) - } - } - numberOfCommitments++ - } - m.commitmentKeeper.SetParams(ctx, commitmenttypes.Params{ - VestingInfos: commParams.VestingInfos, - TotalCommitted: commParams.TotalCommitted, - NumberOfCommitments: numberOfCommitments, - }) - - fmt.Println("Finished incentive v11 migration ...") return nil } diff --git a/x/incentive/module.go b/x/incentive/module.go index 3894636f4..c99978d9a 100644 --- a/x/incentive/module.go +++ b/x/incentive/module.go @@ -160,7 +160,5 @@ 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/incentive/types/apr.pb.go b/x/incentive/types/apr.pb.go deleted file mode 100644 index 1557c0cce..000000000 --- a/x/incentive/types/apr.pb.go +++ /dev/null @@ -1,794 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: elys/incentive/apr.proto - -package types - -import ( - fmt "fmt" - _ "github.com/cosmos/cosmos-proto" - 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 - -type AprEdenElys struct { - Uusdc github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=uusdc,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"uusdc"` - Ueden github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=ueden,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"ueden"` - Uedenb github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=uedenb,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"uedenb"` -} - -func (m *AprEdenElys) Reset() { *m = AprEdenElys{} } -func (m *AprEdenElys) String() string { return proto.CompactTextString(m) } -func (*AprEdenElys) ProtoMessage() {} -func (*AprEdenElys) Descriptor() ([]byte, []int) { - return fileDescriptor_42bff3a86dd838f6, []int{0} -} -func (m *AprEdenElys) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *AprEdenElys) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_AprEdenElys.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 *AprEdenElys) XXX_Merge(src proto.Message) { - xxx_messageInfo_AprEdenElys.Merge(m, src) -} -func (m *AprEdenElys) XXX_Size() int { - return m.Size() -} -func (m *AprEdenElys) XXX_DiscardUnknown() { - xxx_messageInfo_AprEdenElys.DiscardUnknown(m) -} - -var xxx_messageInfo_AprEdenElys proto.InternalMessageInfo - -type AprUsdc struct { - Uusdc github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=uusdc,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"uusdc"` - Ueden github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=ueden,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"ueden"` -} - -func (m *AprUsdc) Reset() { *m = AprUsdc{} } -func (m *AprUsdc) String() string { return proto.CompactTextString(m) } -func (*AprUsdc) ProtoMessage() {} -func (*AprUsdc) Descriptor() ([]byte, []int) { - return fileDescriptor_42bff3a86dd838f6, []int{1} -} -func (m *AprUsdc) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *AprUsdc) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_AprUsdc.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 *AprUsdc) XXX_Merge(src proto.Message) { - xxx_messageInfo_AprUsdc.Merge(m, src) -} -func (m *AprUsdc) XXX_Size() int { - return m.Size() -} -func (m *AprUsdc) XXX_DiscardUnknown() { - xxx_messageInfo_AprUsdc.DiscardUnknown(m) -} - -var xxx_messageInfo_AprUsdc proto.InternalMessageInfo - -type AprEdenB struct { - Uedenb github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=uedenb,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"uedenb"` -} - -func (m *AprEdenB) Reset() { *m = AprEdenB{} } -func (m *AprEdenB) String() string { return proto.CompactTextString(m) } -func (*AprEdenB) ProtoMessage() {} -func (*AprEdenB) Descriptor() ([]byte, []int) { - return fileDescriptor_42bff3a86dd838f6, []int{2} -} -func (m *AprEdenB) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *AprEdenB) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_AprEdenB.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 *AprEdenB) XXX_Merge(src proto.Message) { - xxx_messageInfo_AprEdenB.Merge(m, src) -} -func (m *AprEdenB) XXX_Size() int { - return m.Size() -} -func (m *AprEdenB) XXX_DiscardUnknown() { - xxx_messageInfo_AprEdenB.DiscardUnknown(m) -} - -var xxx_messageInfo_AprEdenB proto.InternalMessageInfo - -func init() { - proto.RegisterType((*AprEdenElys)(nil), "elys.incentive.AprEdenElys") - proto.RegisterType((*AprUsdc)(nil), "elys.incentive.AprUsdc") - proto.RegisterType((*AprEdenB)(nil), "elys.incentive.AprEdenB") -} - -func init() { proto.RegisterFile("elys/incentive/apr.proto", fileDescriptor_42bff3a86dd838f6) } - -var fileDescriptor_42bff3a86dd838f6 = []byte{ - // 276 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x48, 0xcd, 0xa9, 0x2c, - 0xd6, 0xcf, 0xcc, 0x4b, 0x4e, 0xcd, 0x2b, 0xc9, 0x2c, 0x4b, 0xd5, 0x4f, 0x2c, 0x28, 0xd2, 0x2b, - 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x03, 0xc9, 0xe8, 0xc1, 0x65, 0xa4, 0x44, 0xd2, 0xf3, 0xd3, - 0xf3, 0xc1, 0x52, 0xfa, 0x20, 0x16, 0x44, 0x95, 0x94, 0x64, 0x72, 0x7e, 0x71, 0x6e, 0x7e, 0x71, - 0x3c, 0x44, 0x02, 0xc2, 0x81, 0x48, 0x29, 0x75, 0x33, 0x71, 0x71, 0x3b, 0x16, 0x14, 0xb9, 0xa6, - 0xa4, 0xe6, 0xb9, 0xe6, 0x54, 0x16, 0x0b, 0x05, 0x71, 0xb1, 0x96, 0x96, 0x16, 0xa7, 0x24, 0x4b, - 0x30, 0x2a, 0x30, 0x6a, 0x70, 0x3a, 0xd9, 0x9c, 0xb8, 0x27, 0xcf, 0x70, 0xeb, 0x9e, 0xbc, 0x5a, - 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, 0x72, 0x7e, 0x2e, 0x54, 0x3f, 0x94, 0xd2, 0x2d, 0x4e, - 0xc9, 0xd6, 0x2f, 0xa9, 0x2c, 0x48, 0x2d, 0xd6, 0xf3, 0xcc, 0x2b, 0xb9, 0xb4, 0x45, 0x97, 0x0b, - 0x6a, 0xbc, 0x67, 0x5e, 0x49, 0x10, 0xc4, 0x28, 0xb0, 0x99, 0xa9, 0x29, 0xa9, 0x79, 0x12, 0x4c, - 0x54, 0x31, 0x13, 0x64, 0x94, 0x50, 0x08, 0x17, 0x1b, 0x98, 0x91, 0x24, 0xc1, 0x4c, 0x05, 0x43, - 0xa1, 0x66, 0x29, 0x6d, 0x64, 0xe4, 0x62, 0x77, 0x2c, 0x28, 0x0a, 0x85, 0xb9, 0x7a, 0x08, 0x84, - 0x84, 0x52, 0x02, 0x17, 0x07, 0x34, 0x02, 0x9d, 0x90, 0x42, 0x85, 0x91, 0x7a, 0xa1, 0xe2, 0xe4, - 0x71, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31, 0x4e, 0x78, 0x2c, - 0xc7, 0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, 0x0c, 0x51, 0x7a, 0x48, 0xe6, 0x82, 0x52, - 0xa2, 0x6e, 0x5e, 0x6a, 0x49, 0x79, 0x7e, 0x51, 0x36, 0x98, 0xa3, 0x5f, 0x81, 0x94, 0x64, 0xc1, - 0x76, 0x24, 0xb1, 0x81, 0x13, 0x9d, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x6c, 0x4c, 0xd8, 0xea, - 0xd1, 0x02, 0x00, 0x00, -} - -func (m *AprEdenElys) 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 *AprEdenElys) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *AprEdenElys) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size := m.Uedenb.Size() - i -= size - if _, err := m.Uedenb.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintApr(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - { - size := m.Ueden.Size() - i -= size - if _, err := m.Ueden.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintApr(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - { - size := m.Uusdc.Size() - i -= size - if _, err := m.Uusdc.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintApr(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *AprUsdc) 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 *AprUsdc) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *AprUsdc) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size := m.Ueden.Size() - i -= size - if _, err := m.Ueden.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintApr(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - { - size := m.Uusdc.Size() - i -= size - if _, err := m.Uusdc.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintApr(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *AprEdenB) 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 *AprEdenB) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *AprEdenB) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size := m.Uedenb.Size() - i -= size - if _, err := m.Uedenb.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintApr(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func encodeVarintApr(dAtA []byte, offset int, v uint64) int { - offset -= sovApr(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *AprEdenElys) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Uusdc.Size() - n += 1 + l + sovApr(uint64(l)) - l = m.Ueden.Size() - n += 1 + l + sovApr(uint64(l)) - l = m.Uedenb.Size() - n += 1 + l + sovApr(uint64(l)) - return n -} - -func (m *AprUsdc) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Uusdc.Size() - n += 1 + l + sovApr(uint64(l)) - l = m.Ueden.Size() - n += 1 + l + sovApr(uint64(l)) - return n -} - -func (m *AprEdenB) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Uedenb.Size() - n += 1 + l + sovApr(uint64(l)) - return n -} - -func sovApr(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozApr(x uint64) (n int) { - return sovApr(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *AprEdenElys) 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 ErrIntOverflowApr - } - 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: AprEdenElys: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: AprEdenElys: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Uusdc", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowApr - } - 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 ErrInvalidLengthApr - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthApr - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Uusdc.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Ueden", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowApr - } - 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 ErrInvalidLengthApr - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthApr - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Ueden.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Uedenb", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowApr - } - 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 ErrInvalidLengthApr - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthApr - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Uedenb.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipApr(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthApr - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *AprUsdc) 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 ErrIntOverflowApr - } - 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: AprUsdc: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: AprUsdc: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Uusdc", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowApr - } - 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 ErrInvalidLengthApr - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthApr - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Uusdc.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Ueden", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowApr - } - 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 ErrInvalidLengthApr - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthApr - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Ueden.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipApr(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthApr - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *AprEdenB) 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 ErrIntOverflowApr - } - 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: AprEdenB: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: AprEdenB: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Uedenb", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowApr - } - 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 ErrInvalidLengthApr - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthApr - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Uedenb.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipApr(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthApr - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipApr(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, ErrIntOverflowApr - } - 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, ErrIntOverflowApr - } - 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, ErrIntOverflowApr - } - 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, ErrInvalidLengthApr - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupApr - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthApr - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthApr = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowApr = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupApr = fmt.Errorf("proto: unexpected end of group") -) diff --git a/x/incentive/types/dex_rewards_traker.pb.go b/x/incentive/types/dex_rewards_traker.pb.go deleted file mode 100644 index f99658679..000000000 --- a/x/incentive/types/dex_rewards_traker.pb.go +++ /dev/null @@ -1,454 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: elys/incentive/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 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"` - // 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"` -} - -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_6a7f3218c9553b55, []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.incentive.DexRewardsTracker") -} - -func init() { - proto.RegisterFile("elys/incentive/dex_rewards_traker.proto", fileDescriptor_6a7f3218c9553b55) -} - -var fileDescriptor_6a7f3218c9553b55 = []byte{ - // 302 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4f, 0xcd, 0xa9, 0x2c, - 0xd6, 0xcf, 0xcc, 0x4b, 0x4e, 0xcd, 0x2b, 0xc9, 0x2c, 0x4b, 0xd5, 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, 0x03, 0x29, 0xd4, 0x83, 0x2b, 0x94, 0x12, 0x49, 0xcf, 0x4f, 0xcf, - 0x07, 0x4b, 0xe9, 0x83, 0x58, 0x10, 0x55, 0x4a, 0x4b, 0x98, 0xb8, 0x04, 0x5d, 0x52, 0x2b, 0x82, - 0x20, 0x26, 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, 0x42, 0x15, 0x5c, 0x8a, 0x10, 0x56, 0x7c, 0x72, 0x7e, 0x4e, 0x4e, - 0x6a, 0x72, 0x49, 0x6a, 0x4a, 0x7c, 0x52, 0x65, 0x7c, 0x7e, 0x49, 0x46, 0x6a, 0x11, 0xc8, 0xf3, - 0x20, 0xb7, 0x4b, 0x30, 0x93, 0x65, 0x85, 0x2c, 0xc4, 0x60, 0x67, 0x98, 0xb9, 0x4e, 0x95, 0xfe, - 0x20, 0x53, 0xa1, 0x01, 0xe2, 0xe4, 0xb3, 0xe2, 0x91, 0x1c, 0xe3, 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, 0x21, 0x59, 0x02, 0x0a, 0x75, 0xdd, 0xbc, 0xd4, 0x92, 0xf2, - 0xfc, 0xa2, 0x6c, 0x30, 0x47, 0xbf, 0x02, 0x29, 0xb6, 0xc0, 0x16, 0x26, 0xb1, 0x81, 0xc3, 0xde, - 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0x2f, 0xd6, 0xd4, 0xd8, 0xcc, 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 - } - if !this.AmountCollectedByOtherTracker.Equal(that1.AmountCollectedByOtherTracker) { - 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.AmountCollectedByOtherTracker.Size() - i -= size - if _, err := m.AmountCollectedByOtherTracker.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintDexRewardsTraker(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - { - 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)) - l = m.AmountCollectedByOtherTracker.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 - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AmountCollectedByOtherTracker", 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.AmountCollectedByOtherTracker.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/incentive/types/elys_staked.pb.go b/x/incentive/types/elys_staked.pb.go deleted file mode 100644 index 7dcbe31bd..000000000 --- a/x/incentive/types/elys_staked.pb.go +++ /dev/null @@ -1,397 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: elys/incentive/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_ebe5e1add8f72d5c, []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.incentive.ElysStaked") -} - -func init() { proto.RegisterFile("elys/incentive/elys_staked.proto", fileDescriptor_ebe5e1add8f72d5c) } - -var fileDescriptor_ebe5e1add8f72d5c = []byte{ - // 226 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x48, 0xcd, 0xa9, 0x2c, - 0xd6, 0xcf, 0xcc, 0x4b, 0x4e, 0xcd, 0x2b, 0xc9, 0x2c, 0x4b, 0xd5, 0x07, 0x71, 0xe3, 0x8b, 0x4b, - 0x12, 0xb3, 0x53, 0x53, 0xf4, 0x0a, 0x8a, 0xf2, 0x4b, 0xf2, 0x85, 0xf8, 0x40, 0x42, 0x7a, 0x70, - 0x15, 0x52, 0x22, 0xe9, 0xf9, 0xe9, 0xf9, 0x60, 0x29, 0x7d, 0x10, 0x0b, 0xa2, 0x4a, 0x29, 0x8f, - 0x8b, 0xcb, 0x35, 0xa7, 0xb2, 0x38, 0x18, 0xac, 0x53, 0x48, 0x82, 0x8b, 0x3d, 0x31, 0x25, 0xa5, - 0x28, 0xb5, 0xb8, 0x58, 0x82, 0x51, 0x81, 0x51, 0x83, 0x33, 0x08, 0xc6, 0x15, 0x72, 0xe3, 0x62, - 0x4b, 0xcc, 0xcd, 0x2f, 0xcd, 0x2b, 0x91, 0x60, 0x02, 0x49, 0x38, 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, 0x82, 0xea, 0x76, 0xf2, 0x59, 0xf1, 0x48, 0x8e, 0xf1, 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, 0xf4, 0x90, 0x4c, 0x03, 0x39, 0x5f, 0x37, - 0x2f, 0xb5, 0xa4, 0x3c, 0xbf, 0x28, 0x1b, 0xcc, 0xd1, 0xaf, 0x40, 0xf2, 0x2f, 0xd8, 0xe4, 0x24, - 0x36, 0xb0, 0x27, 0x8c, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0xb5, 0xe0, 0x1a, 0xce, 0x0e, 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/incentive/types/genesis.pb.go b/x/incentive/types/genesis.pb.go index 43dd5dc12..204d7e507 100644 --- a/x/incentive/types/genesis.pb.go +++ b/x/incentive/types/genesis.pb.go @@ -5,8 +5,6 @@ package types import ( fmt "fmt" - _ "github.com/cosmos/cosmos-sdk/types" - _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" io "io" math "math" @@ -68,19 +66,16 @@ func init() { func init() { proto.RegisterFile("elys/incentive/genesis.proto", fileDescriptor_83b8e7899b41b162) } var fileDescriptor_83b8e7899b41b162 = []byte{ - // 180 bytes of a gzipped FileDescriptorProto + // 140 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, + 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x03, 0xc9, 0xea, 0xc1, 0x65, 0x95, + 0xf8, 0xb8, 0x78, 0xdc, 0x21, 0x0a, 0x82, 0x4b, 0x12, 0x4b, 0x52, 0x9d, 0x3c, 0x4e, 0x3c, 0x92, + 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, + 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0x4a, 0x2f, 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, + 0x39, 0x3f, 0x57, 0x1f, 0x64, 0x88, 0x6e, 0x5e, 0x6a, 0x49, 0x79, 0x7e, 0x51, 0x36, 0x98, 0xa3, + 0x5f, 0x81, 0x64, 0x63, 0x49, 0x65, 0x41, 0x6a, 0x71, 0x12, 0x1b, 0xd8, 0x42, 0x63, 0x40, 0x00, + 0x00, 0x00, 0xff, 0xff, 0x75, 0xfa, 0x13, 0x55, 0x90, 0x00, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { diff --git a/x/incentive/types/incentive.pb.go b/x/incentive/types/incentive.pb.go deleted file mode 100644 index eb0c3a1ad..000000000 --- a/x/incentive/types/incentive.pb.go +++ /dev/null @@ -1,619 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: elys/incentive/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"` - // 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"` - // 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"` - // current epoch in block number - CurrentEpochInBlocks github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,7,opt,name=current_epoch_in_blocks,json=currentEpochInBlocks,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"current_epoch_in_blocks"` -} - -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_ed0e67c7f36f3313, []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.incentive.IncentiveInfo") -} - -func init() { proto.RegisterFile("elys/incentive/incentive.proto", fileDescriptor_ed0e67c7f36f3313) } - -var fileDescriptor_ed0e67c7f36f3313 = []byte{ - // 404 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x93, 0xc1, 0x8a, 0xd4, 0x40, - 0x10, 0x86, 0x13, 0x75, 0x57, 0x6c, 0x70, 0xd1, 0x30, 0x6a, 0x5c, 0x24, 0x23, 0x1e, 0xc4, 0xcb, - 0x26, 0x07, 0x9f, 0x60, 0x07, 0x16, 0xcc, 0x45, 0x16, 0xbd, 0xa8, 0x97, 0xa6, 0x93, 0xd4, 0x66, - 0x9a, 0x49, 0x77, 0x85, 0xee, 0x8a, 0xce, 0xbc, 0x85, 0x8f, 0xb5, 0xc7, 0x3d, 0x89, 0x78, 0x58, - 0x64, 0xe6, 0x45, 0xa4, 0x3b, 0x33, 0x3b, 0x19, 0xbc, 0xe5, 0x94, 0xee, 0x54, 0xf1, 0x7d, 0xfd, - 0x53, 0x14, 0x4b, 0xa0, 0x59, 0xd9, 0x4c, 0xea, 0x12, 0x34, 0xc9, 0xef, 0xb0, 0x3f, 0xa5, 0xad, - 0x41, 0xc2, 0xe8, 0xc4, 0xd5, 0xd3, 0xbb, 0xbf, 0xa7, 0x93, 0x1a, 0x6b, 0xf4, 0xa5, 0xcc, 0x9d, - 0xfa, 0xae, 0xd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04, 0x13, 0x25, 0x96, 0x17, 0x15, 0xe8, 0x4b, - 0x30, 0xe7, 0x77, 0xac, 0x08, 0xd9, 0xab, 0x83, 0x69, 0xf4, 0x69, 0xa4, 0xde, 0x85, 0x39, 0x1e, - 0xe5, 0x7a, 0x39, 0x64, 0x5e, 0x38, 0x64, 0xae, 0xf7, 0xb9, 0xca, 0xce, 0x18, 0xd0, 0xf4, 0x9f, - 0xeb, 0xe1, 0xb8, 0x5c, 0x5b, 0xdc, 0x81, 0x66, 0xf6, 0xe1, 0x7a, 0x9d, 0x84, 0x37, 0xeb, 0x24, - 0xfc, 0xbb, 0x4e, 0xc2, 0x9f, 0x9b, 0x24, 0xb8, 0xd9, 0x24, 0xc1, 0xef, 0x4d, 0x12, 0x7c, 0x4b, - 0x07, 0x5c, 0xb7, 0x44, 0x67, 0x1a, 0xe8, 0x07, 0x9a, 0x85, 0xbf, 0x64, 0xcb, 0xc1, 0xce, 0x79, - 0x47, 0x71, 0xec, 0x37, 0xe5, 0xfd, 0xbf, 0x00, 0x00, 0x00, 0xff, 0xff, 0xbf, 0x65, 0x62, 0xc6, - 0x92, 0x03, 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.CurrentEpochInBlocks.Size() - i -= size - if _, err := m.CurrentEpochInBlocks.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintIncentive(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x3a - { - size := m.DistributionEpochInBlocks.Size() - i -= size - if _, err := m.DistributionEpochInBlocks.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintIncentive(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x32 - { - size := m.MaxEdenPerAllocation.Size() - i -= size - if _, err := m.MaxEdenPerAllocation.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintIncentive(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x2a - { - size := m.EpochNumBlocks.Size() - i -= size - if _, err := m.EpochNumBlocks.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.EpochNumBlocks.Size() - n += 1 + l + sovIncentive(uint64(l)) - l = m.MaxEdenPerAllocation.Size() - n += 1 + l + sovIncentive(uint64(l)) - l = m.DistributionEpochInBlocks.Size() - n += 1 + l + sovIncentive(uint64(l)) - l = m.CurrentEpochInBlocks.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 EpochNumBlocks", 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.EpochNumBlocks.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field MaxEdenPerAllocation", 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.MaxEdenPerAllocation.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DistributionEpochInBlocks", 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.DistributionEpochInBlocks.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 7: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CurrentEpochInBlocks", 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.CurrentEpochInBlocks.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/incentive/types/params.go b/x/incentive/types/params.go deleted file mode 100644 index 0f6ea58d7..000000000 --- a/x/incentive/types/params.go +++ /dev/null @@ -1,27 +0,0 @@ -package types - -import ( - "gopkg.in/yaml.v2" -) - -// NewParams creates a new Params instance -func NewParams() Params { - return Params{} -} - -// DefaultParams returns a default set of parameters -func DefaultParams() Params { - return NewParams() -} - -// 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/incentive/types/params.pb.go b/x/incentive/types/params.pb.go deleted file mode 100644 index 1ace7ef60..000000000 --- a/x/incentive/types/params.pb.go +++ /dev/null @@ -1,846 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: elys/incentive/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"` - 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`. - 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`. - 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 - PoolInfos []PoolInfo `protobuf:"bytes,5,rep,name=pool_infos,json=poolInfos,proto3" json:"pool_infos"` - // Number of blocks to update elys staked amount for delegators - ElysStakeSnapInterval int64 `protobuf:"varint,6,opt,name=elys_stake_snap_interval,json=elysStakeSnapInterval,proto3" json:"elys_stake_snap_interval,omitempty"` - // Tracking dex rewards given to stakers - DexRewardsStakers DexRewardsTracker `protobuf:"bytes,7,opt,name=dex_rewards_stakers,json=dexRewardsStakers,proto3" json:"dex_rewards_stakers"` - // Tracking dex rewards given to LPs - DexRewardsLps DexRewardsTracker `protobuf:"bytes,8,opt,name=dex_rewards_lps,json=dexRewardsLps,proto3" json:"dex_rewards_lps"` - // Maximum eden reward apr for stakers - [0 - 0.3] - MaxEdenRewardAprStakers github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,9,opt,name=max_eden_reward_apr_stakers,json=maxEdenRewardAprStakers,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"max_eden_reward_apr_stakers"` - // Maximum eden reward apr for lps - [0 - 0.3] - MaxEdenRewardAprLps github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,10,opt,name=max_eden_reward_apr_lps,json=maxEdenRewardAprLps,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"max_eden_reward_apr_lps"` - // Distribution interval in blocks - number of blocks on distribution epoch - DistributionInterval int64 `protobuf:"varint,11,opt,name=distribution_interval,json=distributionInterval,proto3" json:"distribution_interval,omitempty"` -} - -func (m *Params) Reset() { *m = Params{} } -func (*Params) ProtoMessage() {} -func (*Params) Descriptor() ([]byte, []int) { - return fileDescriptor_3bca0267cb466fec, []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) GetStakeIncentives() *IncentiveInfo { - if m != nil { - return m.StakeIncentives - } - return nil -} - -func (m *Params) GetPoolInfos() []PoolInfo { - if m != nil { - return m.PoolInfos - } - return nil -} - -func (m *Params) GetElysStakeSnapInterval() int64 { - if m != nil { - return m.ElysStakeSnapInterval - } - return 0 -} - -func (m *Params) GetDexRewardsStakers() DexRewardsTracker { - if m != nil { - return m.DexRewardsStakers - } - return DexRewardsTracker{} -} - -func (m *Params) GetDexRewardsLps() DexRewardsTracker { - if m != nil { - return m.DexRewardsLps - } - return DexRewardsTracker{} -} - -func (m *Params) GetDistributionInterval() int64 { - if m != nil { - return m.DistributionInterval - } - return 0 -} - -func init() { - proto.RegisterType((*Params)(nil), "elys.incentive.Params") -} - -func init() { proto.RegisterFile("elys/incentive/params.proto", fileDescriptor_3bca0267cb466fec) } - -var fileDescriptor_3bca0267cb466fec = []byte{ - // 526 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x53, 0x41, 0x6f, 0xd3, 0x30, - 0x18, 0x4d, 0x68, 0xe9, 0xa8, 0xcb, 0x18, 0x64, 0x1b, 0x0b, 0x9d, 0x48, 0x0b, 0x07, 0xe8, 0x65, - 0x89, 0xb4, 0x1d, 0x90, 0x90, 0x38, 0x50, 0x0d, 0xb4, 0x4a, 0x48, 0x54, 0x19, 0x12, 0x12, 0x17, - 0xcb, 0x4d, 0xdc, 0x12, 0x25, 0xb1, 0x2d, 0xdb, 0xdb, 0xb2, 0x7f, 0xc1, 0x11, 0x6e, 0xfc, 0x9c, - 0x1d, 0x77, 0x44, 0x1c, 0x26, 0xd4, 0xfe, 0x11, 0x64, 0x27, 0xcd, 0x42, 0xb4, 0x03, 0xeb, 0x29, - 0x76, 0xde, 0xe7, 0xf7, 0xde, 0xf7, 0x3d, 0x1b, 0xec, 0xe2, 0xe4, 0x5c, 0x78, 0x11, 0x09, 0x30, - 0x91, 0xd1, 0x29, 0xf6, 0x18, 0xe2, 0x28, 0x15, 0x2e, 0xe3, 0x54, 0x52, 0xeb, 0x81, 0x02, 0xdd, - 0x12, 0xec, 0x6e, 0xcd, 0xe8, 0x8c, 0x6a, 0xc8, 0x53, 0xab, 0xbc, 0xaa, 0xeb, 0xd4, 0x28, 0xca, - 0x55, 0x81, 0x3f, 0xa9, 0x4b, 0x50, 0x9a, 0x14, 0xd0, 0xcb, 0x1a, 0x14, 0xe2, 0x0c, 0x72, 0x7c, - 0x86, 0x78, 0x28, 0xa0, 0xe4, 0x28, 0xc6, 0x3c, 0x2f, 0x7c, 0xfe, 0x63, 0x0d, 0xb4, 0xc6, 0xda, - 0x9a, 0x35, 0x04, 0xeb, 0x09, 0x83, 0xe5, 0x19, 0x61, 0x9b, 0x7d, 0x73, 0xd0, 0xd9, 0x7f, 0xea, - 0xfe, 0x6b, 0xd6, 0x1d, 0x2d, 0x57, 0x23, 0x32, 0xa5, 0xfe, 0xfd, 0x84, 0x95, 0x3f, 0x84, 0x75, - 0x04, 0x1e, 0x0a, 0x89, 0x62, 0x5c, 0xa5, 0xb9, 0xf3, 0x3f, 0x34, 0x1b, 0xfa, 0x58, 0x85, 0x29, - 0x00, 0x8f, 0x73, 0xc3, 0x90, 0x51, 0x2e, 0x23, 0x4a, 0xe0, 0x94, 0x72, 0x98, 0x30, 0x61, 0x37, - 0xfa, 0xe6, 0xa0, 0x3d, 0x74, 0x2f, 0xae, 0x7a, 0xc6, 0xef, 0xab, 0xde, 0x8b, 0x59, 0x24, 0xbf, - 0x9e, 0x4c, 0xdc, 0x80, 0xa6, 0x5e, 0x40, 0x45, 0x4a, 0x45, 0xf1, 0xd9, 0x13, 0x61, 0xec, 0xc9, - 0x73, 0x86, 0x85, 0x7b, 0x88, 0x03, 0x7f, 0x33, 0x67, 0x1b, 0xe7, 0x64, 0xef, 0x29, 0xff, 0xc0, - 0x84, 0x15, 0x83, 0xee, 0x0d, 0x22, 0xda, 0x0a, 0x17, 0x76, 0x73, 0x25, 0xa1, 0x9d, 0xba, 0xd0, - 0x71, 0x4e, 0x67, 0xbd, 0x01, 0x40, 0x25, 0x04, 0x23, 0x32, 0xa5, 0xc2, 0xbe, 0xdb, 0x6f, 0x0c, - 0x3a, 0xfb, 0x76, 0x7d, 0x2a, 0x63, 0x4a, 0x13, 0x35, 0x90, 0x61, 0x53, 0xc9, 0xfa, 0x6d, 0x56, - 0xec, 0x85, 0xf5, 0x0a, 0xd8, 0xaa, 0x36, 0x77, 0x07, 0x05, 0x41, 0x2a, 0x2b, 0x89, 0xf9, 0x29, - 0x4a, 0xec, 0x56, 0xdf, 0x1c, 0x34, 0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x00, 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 m.DistributionInterval != 0 { - i = encodeVarintParams(dAtA, i, uint64(m.DistributionInterval)) - i-- - dAtA[i] = 0x58 - } - { - 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] = 0x52 - { - 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] = 0x4a - { - size, err := m.DexRewardsLps.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintParams(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x42 - { - 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 - if m.ElysStakeSnapInterval != 0 { - i = encodeVarintParams(dAtA, i, uint64(m.ElysStakeSnapInterval)) - i-- - dAtA[i] = 0x30 - } - 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 = encodeVarintParams(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x2a - } - } - { - 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] = 0x22 - { - 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] = 0x1a - 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] = 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 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)) - } - if m.StakeIncentives != nil { - l = m.StakeIncentives.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)) - if len(m.PoolInfos) > 0 { - for _, e := range m.PoolInfos { - l = e.Size() - n += 1 + l + sovParams(uint64(l)) - } - } - if m.ElysStakeSnapInterval != 0 { - n += 1 + sovParams(uint64(m.ElysStakeSnapInterval)) - } - l = m.DexRewardsStakers.Size() - n += 1 + l + sovParams(uint64(l)) - l = m.DexRewardsLps.Size() - n += 1 + l + sovParams(uint64(l)) - l = m.MaxEdenRewardAprStakers.Size() - n += 1 + l + sovParams(uint64(l)) - l = m.MaxEdenRewardAprLps.Size() - n += 1 + l + sovParams(uint64(l)) - if m.DistributionInterval != 0 { - n += 1 + sovParams(uint64(m.DistributionInterval)) - } - 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 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 3: - 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 4: - 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 5: - 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 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.PoolInfos = append(m.PoolInfos, PoolInfo{}) - if err := m.PoolInfos[len(m.PoolInfos)-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 ElysStakeSnapInterval", wireType) - } - m.ElysStakeSnapInterval = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.ElysStakeSnapInterval |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - 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 - case 8: - 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 9: - 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 10: - 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 11: - 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 ErrIntOverflowParams - } - 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 := 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/incentive/types/pool.pb.go b/x/incentive/types/pool.pb.go deleted file mode 100644 index f87360174..000000000 --- a/x/incentive/types/pool.pb.go +++ /dev/null @@ -1,657 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: elys/incentive/pool.proto - -package types - -import ( - fmt "fmt" - _ "github.com/cosmos/cosmos-proto" - 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"` -} - -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_1dce8e3541398851, []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 init() { - proto.RegisterType((*PoolInfo)(nil), "elys.incentive.PoolInfo") -} - -func init() { proto.RegisterFile("elys/incentive/pool.proto", fileDescriptor_1dce8e3541398851) } - -var fileDescriptor_1dce8e3541398851 = []byte{ - // 380 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x92, 0x41, 0x8b, 0xda, 0x40, - 0x14, 0xc7, 0x93, 0xd6, 0x26, 0x3a, 0xb4, 0x3d, 0x0c, 0x16, 0xa3, 0x87, 0x28, 0x2d, 0x14, 0x2f, - 0x26, 0x87, 0x7e, 0x02, 0xa5, 0x60, 0x73, 0x68, 0x29, 0xb9, 0x14, 0x7a, 0x09, 0x31, 0xf3, 0x9a, - 0x06, 0x27, 0x33, 0x61, 0x32, 0xd1, 0xf8, 0x2d, 0xf6, 0x63, 0x09, 0x7b, 0xf1, 0xb8, 0xec, 0x41, - 0x16, 0xfd, 0x22, 0xcb, 0x4c, 0x64, 0x11, 0x76, 0x2f, 0x9b, 0x53, 0xf2, 0xde, 0xff, 0xcd, 0xef, - 0x3f, 0x6f, 0xf8, 0xa3, 0x21, 0xd0, 0x5d, 0xe9, 0x67, 0x2c, 0x01, 0x26, 0xb3, 0x0d, 0xf8, 0x05, - 0xe7, 0xd4, 0x2b, 0x04, 0x97, 0x1c, 0x7f, 0x54, 0x92, 0xf7, 0x24, 0x8d, 0xfa, 0x29, 0x4f, 0xb9, - 0x96, 0x7c, 0xf5, 0xd7, 0x4c, 0x8d, 0x86, 0x09, 0x2f, 0x73, 0x5e, 0x46, 0x8d, 0xd0, 0x14, 0x8d, - 0xf4, 0xf9, 0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d4, 0x6d, 0x45, 0xb2, 0x08, 0xd4, 0xf3, - 0x42, 0x2c, 0x7e, 0xec, 0x4f, 0xae, 0x79, 0x38, 0xb9, 0xe6, 0xc3, 0xc9, 0x35, 0x6f, 0xce, 0xae, - 0x71, 0x38, 0xbb, 0xc6, 0xdd, 0xd9, 0x35, 0xfe, 0x7a, 0x57, 0x24, 0x95, 0xd9, 0x19, 0x03, 0xb9, - 0xe5, 0x62, 0xad, 0x0b, 0xbf, 0xbe, 0x4a, 0xb7, 0xa6, 0xae, 0x2c, 0x1d, 0xcf, 0x6f, 0x8f, 0x01, - 0x00, 0x00, 0xff, 0xff, 0x4b, 0x78, 0x1a, 0x96, 0xfc, 0x02, 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 - { - 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 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)) - 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 - 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/incentive/types/tx.pb.go b/x/incentive/types/tx.pb.go index 4e2a82b0c..9dad10323 100644 --- a/x/incentive/types/tx.pb.go +++ b/x/incentive/types/tx.pb.go @@ -11,7 +11,6 @@ import ( _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" - _ "github.com/elys-network/elys/x/commitment/types" grpc "google.golang.org/grpc" io "io" math "math" @@ -119,34 +118,33 @@ func init() { func init() { proto.RegisterFile("elys/incentive/tx.proto", fileDescriptor_59dc3bedfb1cce84) } var fileDescriptor_59dc3bedfb1cce84 = []byte{ - // 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, 0x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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, + // 412 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x53, 0x3d, 0xaf, 0x12, 0x41, + 0x14, 0xdd, 0x65, 0x9f, 0x2f, 0x3a, 0x26, 0xcf, 0xf7, 0xd6, 0x67, 0x04, 0x62, 0x16, 0x42, 0x23, + 0x0d, 0x3b, 0x01, 0x0b, 0x13, 0x3b, 0xf9, 0x48, 0x28, 0xa4, 0x59, 0x62, 0x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03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/leveragelp/client/cli/query.go b/x/leveragelp/client/cli/query.go index 12c570644..42c957d3f 100644 --- a/x/leveragelp/client/cli/query.go +++ b/x/leveragelp/client/cli/query.go @@ -34,6 +34,9 @@ func GetQueryCmd(queryRoute string) *cobra.Command { cmd.AddCommand(CmdListPool()) cmd.AddCommand(CmdShowPool()) cmd.AddCommand(CmdPosition()) + cmd.AddCommand(CmdOpenEstimation()) + cmd.AddCommand(CmdCloseEstimation()) + cmd.AddCommand(CmdRewards()) // this line is used by starport scaffolding # 1 diff --git a/x/leveragelp/client/cli/query_close_estimation.go b/x/leveragelp/client/cli/query_close_estimation.go new file mode 100644 index 000000000..5b98b01b1 --- /dev/null +++ b/x/leveragelp/client/cli/query_close_estimation.go @@ -0,0 +1,54 @@ +package cli + +import ( + "strconv" + + "cosmossdk.io/math" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/elys-network/elys/x/leveragelp/types" + "github.com/spf13/cobra" +) + +func CmdCloseEstimation() *cobra.Command { + cmd := &cobra.Command{ + Use: "close-estimation [owner] [pool_id] [lp_amount]", + Short: "Query close estimation", + Args: cobra.ExactArgs(3), + RunE: func(cmd *cobra.Command, args []string) (err error) { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + positionId, err := strconv.Atoi(args[1]) + if err != nil { + return err + } + + lpAmount, ok := math.NewIntFromString(args[2]) + if !ok { + return err + } + + params := &types.QueryCloseEstRequest{ + Owner: args[0], + Id: uint64(positionId), + LpAmount: lpAmount, + } + + res, err := queryClient.CloseEst(cmd.Context(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/leveragelp/client/cli/query_open_estimation.go b/x/leveragelp/client/cli/query_open_estimation.go new file mode 100644 index 000000000..8e2d62dc8 --- /dev/null +++ b/x/leveragelp/client/cli/query_open_estimation.go @@ -0,0 +1,60 @@ +package cli + +import ( + "strconv" + + "cosmossdk.io/math" + "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/leveragelp/types" + "github.com/spf13/cobra" +) + +func CmdOpenEstimation() *cobra.Command { + cmd := &cobra.Command{ + Use: "open-estimation [amm_pool_id] [collateral] [leverage]", + Short: "Query open estimation", + Args: cobra.ExactArgs(3), + RunE: func(cmd *cobra.Command, args []string) (err error) { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + collateral, err := sdk.ParseCoinNormalized(args[1]) + if err != nil { + return err + } + + poolId, err := strconv.Atoi(args[0]) + if err != nil { + return err + } + + leverage, err := math.LegacyNewDecFromStr(args[2]) + if err != nil { + return err + } + + params := &types.QueryOpenEstRequest{ + CollateralAsset: collateral.Denom, + CollateralAmount: collateral.Amount, + AmmPoolId: uint64(poolId), + Leverage: leverage, + } + + res, err := queryClient.OpenEst(cmd.Context(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/leveragelp/client/cli/query_mtp.go b/x/leveragelp/client/cli/query_position.go similarity index 100% rename from x/leveragelp/client/cli/query_mtp.go rename to x/leveragelp/client/cli/query_position.go diff --git a/x/leveragelp/client/cli/query_rewards.go b/x/leveragelp/client/cli/query_rewards.go new file mode 100644 index 000000000..969437cd6 --- /dev/null +++ b/x/leveragelp/client/cli/query_rewards.go @@ -0,0 +1,60 @@ +package cli + +import ( + "strconv" + "strings" + + "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/leveragelp/types" + "github.com/spf13/cobra" +) + +func CmdRewards() *cobra.Command { + cmd := &cobra.Command{ + Use: "get-position [address] [position-ids]", + Short: "Query position", + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) (err error) { + reqAddress := args[0] + _, err = sdk.AccAddressFromBech32(reqAddress) + if err != nil { + return err + } + + positionStrs := strings.Split(args[0], ",") + positionIds := []uint64{} + for _, positionStr := range positionStrs { + id, err := strconv.Atoi(positionStr) + if err != nil { + return err + } + positionIds = append(positionIds, uint64(id)) + } + + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + params := &types.QueryRewardsRequest{ + Address: reqAddress, + Ids: positionIds, + } + + res, err := queryClient.Rewards(cmd.Context(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/leveragelp/client/cli/tx.go b/x/leveragelp/client/cli/tx.go index fe2b1e8d6..d2ce3238b 100644 --- a/x/leveragelp/client/cli/tx.go +++ b/x/leveragelp/client/cli/tx.go @@ -26,6 +26,7 @@ func GetTxCmd() *cobra.Command { cmd.AddCommand(CmdUpdatePools()) cmd.AddCommand(CmdWhitelist()) cmd.AddCommand(CmdDewhitelist()) + cmd.AddCommand(CmdClaimRewards()) cmd.AddCommand(CmdUpdateStopLoss()) // this line is used by starport scaffolding # 1 diff --git a/x/leveragelp/client/cli/tx_claim_rewards.go b/x/leveragelp/client/cli/tx_claim_rewards.go new file mode 100644 index 000000000..0152f4fbb --- /dev/null +++ b/x/leveragelp/client/cli/tx_claim_rewards.go @@ -0,0 +1,56 @@ +package cli + +import ( + "errors" + "strconv" + "strings" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + "github.com/elys-network/elys/x/leveragelp/types" + "github.com/spf13/cobra" +) + +func CmdClaimRewards() *cobra.Command { + cmd := &cobra.Command{ + Use: "claim-rewards [position-ids] [flags]", + Short: "Claim rewards from leveragelp position", + Example: `elysd tx leveragelp claim-rewards 1,2 --from=treasury --keyring-backend=test --chain-id=elystestnet-1 --yes --gas=1000000`, + Args: cobra.ExactArgs(1), + 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") + } + + positionStrs := strings.Split(args[0], ",") + positionIds := []uint64{} + for _, positionStr := range positionStrs { + id, err := strconv.Atoi(positionStr) + if err != nil { + return err + } + positionIds = append(positionIds, uint64(id)) + } + + msg := &types.MsgClaimRewards{ + Sender: signer.String(), + Ids: positionIds, + } + + if err := msg.ValidateBasic(); err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} diff --git a/x/leveragelp/client/wasm/messenger.go b/x/leveragelp/client/wasm/messenger.go index bc8fc9826..d71f062cc 100644 --- a/x/leveragelp/client/wasm/messenger.go +++ b/x/leveragelp/client/wasm/messenger.go @@ -29,6 +29,8 @@ func (m *Messenger) HandleMsg(ctx sdk.Context, contractAddr sdk.AccAddress, cont return m.msgOpen(ctx, contractAddr, msg.LeveragelpOpen) case msg.LeveragelpClose != nil: return m.msgClose(ctx, contractAddr, msg.LeveragelpClose) + case msg.LeveragelpClaimRewards != nil: + return m.msgClaimRewards(ctx, contractAddr, msg.LeveragelpClaimRewards) case msg.LeveragelpUpdateStopLoss != nil: return m.msgUpdateStopLoss(ctx, contractAddr, msg.LeveragelpUpdateStopLoss) default: diff --git a/x/leveragelp/client/wasm/msg_claim_rewards.go b/x/leveragelp/client/wasm/msg_claim_rewards.go new file mode 100644 index 000000000..281d3362e --- /dev/null +++ b/x/leveragelp/client/wasm/msg_claim_rewards.go @@ -0,0 +1,41 @@ +package wasm + +import ( + "encoding/json" + + errorsmod "cosmossdk.io/errors" + wasmvmtypes "github.com/CosmWasm/wasmvm/types" + sdk "github.com/cosmos/cosmos-sdk/types" + leveragelpkeeper "github.com/elys-network/elys/x/leveragelp/keeper" + leveragelptypes "github.com/elys-network/elys/x/leveragelp/types" +) + +func (m *Messenger) msgClaimRewards(ctx sdk.Context, contractAddr sdk.AccAddress, msgClaimRewards *leveragelptypes.MsgClaimRewards) ([]sdk.Event, [][]byte, error) { + if msgClaimRewards == nil { + return nil, nil, wasmvmtypes.InvalidRequest{Err: "ClaimRewards null msg"} + } + + brokerAddress := m.parameterKeeper.GetParams(ctx).BrokerAddress + if msgClaimRewards.Sender != contractAddr.String() && contractAddr.String() != brokerAddress { + return nil, nil, wasmvmtypes.InvalidRequest{Err: "ClaimRewards wrong sender"} + } + + if err := msgClaimRewards.ValidateBasic(); err != nil { + return nil, nil, errorsmod.Wrap(err, "failed validating msgClaimRewards") + } + + msgServer := leveragelpkeeper.NewMsgServerImpl(*m.keeper) + res, err := msgServer.ClaimRewards(sdk.WrapSDKContext(ctx), msgClaimRewards) + if err != nil { + return nil, nil, errorsmod.Wrap(err, "leveragelp ClaimRewards msg") + } + + responseBytes, err := json.Marshal(*res) + if err != nil { + return nil, nil, errorsmod.Wrap(err, "failed to serialize ClaimRewards response") + } + + resp := [][]byte{responseBytes} + + return nil, resp, nil +} diff --git a/x/leveragelp/client/wasm/querier.go b/x/leveragelp/client/wasm/querier.go index ce1bcec9d..4005a3936 100644 --- a/x/leveragelp/client/wasm/querier.go +++ b/x/leveragelp/client/wasm/querier.go @@ -39,6 +39,12 @@ func (oq *Querier) HandleQuery(ctx sdk.Context, query wasmbindingstypes.ElysQuer return oq.queryPools(ctx, query.LeveragelpPools) case query.LeveragelpPosition != nil: return oq.queryPosition(ctx, query.LeveragelpPosition) + case query.LeveragelpOpenEst != nil: + return oq.queryOpenEst(ctx, query.LeveragelpOpenEst) + case query.LeveragelpCloseEst != nil: + return oq.queryCloseEst(ctx, query.LeveragelpCloseEst) + case query.LeveragelpRewards != nil: + return oq.queryRewards(ctx, query.LeveragelpRewards) default: // This handler cannot handle the query return nil, wasmbindingstypes.ErrCannotHandleQuery diff --git a/x/leveragelp/client/wasm/query_claim_rewards.go b/x/leveragelp/client/wasm/query_claim_rewards.go new file mode 100644 index 000000000..c37b826ae --- /dev/null +++ b/x/leveragelp/client/wasm/query_claim_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/leveragelp/types" +) + +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 leveragelp rewards") + } + + responseBytes, err := json.Marshal(res) + if err != nil { + return nil, errorsmod.Wrap(err, "failed to serialize leveragelp rewards response") + } + return responseBytes, nil +} diff --git a/x/leveragelp/client/wasm/query_close_est.go b/x/leveragelp/client/wasm/query_close_est.go new file mode 100644 index 000000000..3ea988b14 --- /dev/null +++ b/x/leveragelp/client/wasm/query_close_est.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/leveragelp/types" +) + +func (oq *Querier) queryCloseEst(ctx sdk.Context, query *types.QueryCloseEstRequest) ([]byte, error) { + res, err := oq.keeper.CloseEst(ctx, query) + if err != nil { + return nil, errorsmod.Wrap(err, "failed to get leveragelp close estimation") + } + + responseBytes, err := json.Marshal(res) + if err != nil { + return nil, errorsmod.Wrap(err, "failed to serialize leveragelp close estimation response") + } + return responseBytes, nil +} diff --git a/x/leveragelp/client/wasm/query_open_est.go b/x/leveragelp/client/wasm/query_open_est.go new file mode 100644 index 000000000..aa40d95a2 --- /dev/null +++ b/x/leveragelp/client/wasm/query_open_est.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/leveragelp/types" +) + +func (oq *Querier) queryOpenEst(ctx sdk.Context, query *types.QueryOpenEstRequest) ([]byte, error) { + res, err := oq.keeper.OpenEst(ctx, query) + if err != nil { + return nil, errorsmod.Wrap(err, "failed to get leveragelp open estimation") + } + + responseBytes, err := json.Marshal(res) + if err != nil { + return nil, errorsmod.Wrap(err, "failed to serialize leveragelp open estimation response") + } + return responseBytes, nil +} diff --git a/x/leveragelp/keeper/begin_blocker.go b/x/leveragelp/keeper/begin_blocker.go index ea2ef424d..794531ae6 100644 --- a/x/leveragelp/keeper/begin_blocker.go +++ b/x/leveragelp/keeper/begin_blocker.go @@ -18,6 +18,7 @@ func (k Keeper) BeginBlocker(ctx sdk.Context) { if epochPosition == 0 { // if epoch has passed pools := k.GetAllPools(ctx) + for _, pool := range pools { ammPool, err := k.GetAmmPool(ctx, pool.AmmPoolId) if err != nil { @@ -29,12 +30,83 @@ func (k Keeper) BeginBlocker(ctx sdk.Context) { for _, position := range positions { k.LiquidatePositionIfUnhealthy(ctx, position, pool, ammPool) } + + // Liquidate positions liquidation health threshold + // Design + // - `Health = PositionValue / Debt`, PositionValue is based on LpToken price change + // - Debt growth speed is relying on debt.Borrowed. + // - Things are sorted by `LeveragedLpAmount / debt.Borrowed` per pool to liquidate efficiently + + // TODO: should consider InterestStacked-InterestPaid amount + k.IteratePoolPosIdsLiquidationSorted(ctx, pool.AmmPoolId, func(posId types.AddressId) bool { + position, err := k.GetPosition(ctx, posId.Address, posId.Id) + if err != nil { + return false + } + isHealthy, earlyReturn := k.LiquidatePositionIfUnhealthy(ctx, &position, pool, ammPool) + if !earlyReturn && isHealthy { + return true + } + return false + }) + + // Close stopLossPrice reached positions + k.IteratePoolPosIdsStopLossSorted(ctx, pool.AmmPoolId, func(posId types.AddressId) bool { + position, err := k.GetPosition(ctx, posId.Address, posId.Id) + if err != nil { + return false + } + underStopLossPrice, earlyReturn := k.ClosePositionIfUnderStopLossPrice(ctx, &position, pool, ammPool) + if !earlyReturn && underStopLossPrice { + return true + } + return false + }) + } + } + } +} + +func (k Keeper) LiquidatePositionIfUnhealthy(ctx sdk.Context, position *types.Position, pool types.Pool, ammPool ammtypes.Pool) (isHealthy, earlyReturn bool) { + defer func() { + if r := recover(); r != nil { + if msg, ok := r.(string); ok { + ctx.Logger().Error(msg) } } + }() + h, err := k.GetPositionHealth(ctx, *position, ammPool) + if err != nil { + ctx.Logger().Error(errors.Wrap(err, fmt.Sprintf("error updating position health: %s", position.String())).Error()) + return false, true + } + position.PositionHealth = h + k.SetPosition(ctx, position) + + params := k.GetParams(ctx) + isHealthy = position.PositionHealth.GT(params.SafetyFactor) + if isHealthy { + return isHealthy, false } + + repayAmount, err := k.ForceCloseLong(ctx, *position, pool, position.LeveragedLpAmount) + if err != nil { + ctx.Logger().Error(errors.Wrap(err, "error executing liquidation").Error()) + return isHealthy, true + } + ctx.EventManager().EmitEvent(sdk.NewEvent(types.EventClose, + sdk.NewAttribute("id", strconv.FormatInt(int64(position.Id), 10)), + sdk.NewAttribute("address", position.Address), + sdk.NewAttribute("collateral", position.Collateral.String()), + sdk.NewAttribute("repay_amount", repayAmount.String()), + sdk.NewAttribute("leverage", position.Leverage.String()), + sdk.NewAttribute("liabilities", position.Liabilities.String()), + sdk.NewAttribute("health", position.PositionHealth.String()), + )) + return isHealthy, false } -func (k Keeper) LiquidatePositionIfUnhealthy(ctx sdk.Context, position *types.Position, pool types.Pool, ammPool ammtypes.Pool) { +func (k Keeper) ClosePositionIfUnderStopLossPrice(ctx sdk.Context, position *types.Position, pool types.Pool, ammPool ammtypes.Pool) (underStopLossPrice, earlyReturn bool) { defer func() { if r := recover(); r != nil { if msg, ok := r.(string); ok { @@ -45,33 +117,34 @@ func (k Keeper) LiquidatePositionIfUnhealthy(ctx sdk.Context, position *types.Po h, err := k.GetPositionHealth(ctx, *position, ammPool) if err != nil { ctx.Logger().Error(errors.Wrap(err, fmt.Sprintf("error updating position health: %s", position.String())).Error()) - return + return false, true } position.PositionHealth = h k.SetPosition(ctx, position) lpTokenPrice, err := ammPool.LpTokenPrice(ctx, k.oracleKeeper) if err != nil { - return + return false, true } - params := k.GetParams(ctx) - if position.PositionHealth.GT(params.SafetyFactor) && lpTokenPrice.GT(position.StopLossPrice) { - return + underStopLossPrice = !position.StopLossPrice.IsNil() && lpTokenPrice.LTE(position.StopLossPrice) + if !underStopLossPrice { + return underStopLossPrice, false } repayAmount, err := k.ForceCloseLong(ctx, *position, pool, position.LeveragedLpAmount) - if err == nil { - ctx.EventManager().EmitEvent(sdk.NewEvent(types.EventClose, - sdk.NewAttribute("id", strconv.FormatInt(int64(position.Id), 10)), - sdk.NewAttribute("address", position.Address), - sdk.NewAttribute("collateral", position.Collateral.String()), - sdk.NewAttribute("repay_amount", repayAmount.String()), - sdk.NewAttribute("leverage", position.Leverage.String()), - sdk.NewAttribute("liabilities", position.Liabilities.String()), - sdk.NewAttribute("health", position.PositionHealth.String()), - )) - } else { - ctx.Logger().Error(errors.Wrap(err, "error executing force close").Error()) + if err != nil { + ctx.Logger().Error(errors.Wrap(err, "error executing close for stopLossPrice").Error()) + return underStopLossPrice, true } + ctx.EventManager().EmitEvent(sdk.NewEvent(types.EventClose, + sdk.NewAttribute("id", strconv.FormatInt(int64(position.Id), 10)), + sdk.NewAttribute("address", position.Address), + sdk.NewAttribute("collateral", position.Collateral.String()), + sdk.NewAttribute("repay_amount", repayAmount.String()), + sdk.NewAttribute("leverage", position.Leverage.String()), + sdk.NewAttribute("liabilities", position.Liabilities.String()), + sdk.NewAttribute("health", position.PositionHealth.String()), + )) + return underStopLossPrice, false } diff --git a/x/leveragelp/keeper/begin_blocker_test.go b/x/leveragelp/keeper/begin_blocker_test.go index e922875db..c951e88e6 100644 --- a/x/leveragelp/keeper/begin_blocker_test.go +++ b/x/leveragelp/keeper/begin_blocker_test.go @@ -3,6 +3,7 @@ package keeper_test import ( "time" + "cosmossdk.io/math" "github.com/cometbft/cometbft/crypto/ed25519" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -51,10 +52,22 @@ func (suite KeeperTestSuite) TestLiquidatePositionIfUnhealthy() { // suite.Require().Equal(health.String(), "1.024543738200125865") // slippage enabled on amm suite.Require().Equal(health.String(), "1.025220422390814025") // slippage disabled on amm - params := k.GetParams(suite.ctx) + cacheCtx, _ := suite.ctx.CacheContext() + params := k.GetParams(cacheCtx) params.SafetyFactor = sdk.NewDecWithPrec(11, 1) - k.SetParams(suite.ctx, ¶ms) - k.LiquidatePositionIfUnhealthy(suite.ctx, position, pool, ammPool) - _, err = k.GetPosition(suite.ctx, position.Address, position.Id) + k.SetParams(cacheCtx, ¶ms) + isHealthy, earlyReturn := k.LiquidatePositionIfUnhealthy(cacheCtx, position, pool, ammPool) + suite.Require().False(isHealthy) + suite.Require().False(earlyReturn) + _, err = k.GetPosition(cacheCtx, position.Address, position.Id) + suite.Require().Error(err) + + cacheCtx, _ = suite.ctx.CacheContext() + position.StopLossPrice = math.LegacyNewDec(100000) + k.SetPosition(cacheCtx, position) + underStopLossPrice, earlyReturn := k.ClosePositionIfUnderStopLossPrice(cacheCtx, position, pool, ammPool) + suite.Require().True(underStopLossPrice) + suite.Require().False(earlyReturn) + _, err = k.GetPosition(cacheCtx, position.Address, position.Id) suite.Require().Error(err) } diff --git a/x/leveragelp/keeper/keeper.go b/x/leveragelp/keeper/keeper.go index f716ef1e6..990cad0f4 100644 --- a/x/leveragelp/keeper/keeper.go +++ b/x/leveragelp/keeper/keeper.go @@ -29,6 +29,7 @@ type ( stableKeeper types.StableStakeKeeper commKeeper types.CommitmentKeeper assetProfileKeeper types.AssetProfileKeeper + masterchefKeeper types.MasterchefKeeper hooks types.LeveragelpHooks } @@ -45,6 +46,7 @@ func NewKeeper( stableKeeper types.StableStakeKeeper, commitmentKeeper types.CommitmentKeeper, assetProfileKeeper types.AssetProfileKeeper, + masterchefKeeper types.MasterchefKeeper, ) *Keeper { // ensure that authority is a valid AccAddress if _, err := sdk.AccAddressFromBech32(authority); err != nil { @@ -62,6 +64,7 @@ func NewKeeper( stableKeeper: stableKeeper, commKeeper: commitmentKeeper, assetProfileKeeper: assetProfileKeeper, + masterchefKeeper: masterchefKeeper, } return keeper diff --git a/x/leveragelp/keeper/msg_server_claim_rewards.go b/x/leveragelp/keeper/msg_server_claim_rewards.go new file mode 100644 index 000000000..4a0a9029f --- /dev/null +++ b/x/leveragelp/keeper/msg_server_claim_rewards.go @@ -0,0 +1,40 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/elys-network/elys/x/leveragelp/types" +) + +func (k msgServer) ClaimRewards(goCtx context.Context, msg *types.MsgClaimRewards) (*types.MsgClaimRewardsResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + sender, err := sdk.AccAddressFromBech32(msg.Sender) + if err != nil { + return nil, err + } + + for _, id := range msg.Ids { + position, err := k.GetPosition(ctx, msg.Sender, id) + if err != nil { + return nil, err + } + posAddr := types.GetPositionAddress(id) + if position.Address != msg.Sender { + return nil, types.ErrPositionDoesNotExist + } + err = k.masterchefKeeper.ClaimRewards(ctx, posAddr, []uint64{position.Id}) + if err != nil { + return nil, err + } + balances := k.bankKeeper.GetAllBalances(ctx, posAddr) + if balances.IsAllPositive() { + err := k.bankKeeper.SendCoins(ctx, posAddr, sender, balances) + if err != nil { + return nil, err + } + } + } + + return &types.MsgClaimRewardsResponse{}, nil +} diff --git a/x/leveragelp/keeper/position.go b/x/leveragelp/keeper/position.go index a40ff9644..7f50e958e 100644 --- a/x/leveragelp/keeper/position.go +++ b/x/leveragelp/keeper/position.go @@ -39,10 +39,39 @@ func (k Keeper) SetPosition(ctx sdk.Context, position *types.Position) { // increment open position count openCount++ k.SetOpenPositionCount(ctx, openCount) + } else { + old, err := k.GetPosition(ctx, position.Address, position.Id) + if err == nil { + debt := k.stableKeeper.UpdateInterestStackedByAddress(ctx, old.GetPositionAddress()) + liquidationKey := types.GetLiquidationSortKey(old.AmmPoolId, old.LeveragedLpAmount, debt.Borrowed, old.Id) + if len(liquidationKey) > 0 { + store.Delete(liquidationKey) + } + stopLossKey := types.GetStopLossSortKey(old.AmmPoolId, old.StopLossPrice, old.Id) + if len(stopLossKey) > 0 { + store.Delete(stopLossKey) + } + } } key := types.GetPositionKey(position.Address, position.Id) store.Set(key, k.cdc.MustMarshal(position)) + + // Add position sort keys + addrId := types.AddressId{ + Id: position.Id, + Address: position.Address, + } + bz := k.cdc.MustMarshal(&addrId) + debt := k.stableKeeper.UpdateInterestStackedByAddress(ctx, position.GetPositionAddress()) + liquidationKey := types.GetLiquidationSortKey(position.AmmPoolId, position.LeveragedLpAmount, debt.Borrowed, position.Id) + if len(liquidationKey) > 0 { + store.Set(liquidationKey, bz) + } + stopLossKey := types.GetStopLossSortKey(position.AmmPoolId, position.StopLossPrice, position.Id) + if len(stopLossKey) > 0 { + store.Set(stopLossKey, bz) + } } func (k Keeper) DestroyPosition(ctx sdk.Context, positionAddress string, id uint64) error { @@ -52,6 +81,21 @@ func (k Keeper) DestroyPosition(ctx sdk.Context, positionAddress string, id uint return types.ErrPositionDoesNotExist } store.Delete(key) + + // Remove position sort keys + old, err := k.GetPosition(ctx, positionAddress, id) + if err == nil { + debt := k.stableKeeper.UpdateInterestStackedByAddress(ctx, old.GetPositionAddress()) + liquidationKey := types.GetLiquidationSortKey(old.AmmPoolId, old.LeveragedLpAmount, debt.Borrowed, old.Id) + if len(liquidationKey) > 0 { + store.Delete(liquidationKey) + } + stopLossKey := types.GetStopLossSortKey(old.AmmPoolId, old.StopLossPrice, old.Id) + if len(stopLossKey) > 0 { + store.Delete(stopLossKey) + } + } + // decrement open position count openCount := k.GetOpenPositionCount(ctx) openCount-- @@ -102,7 +146,7 @@ func (k Keeper) GetPositionIterator(ctx sdk.Context) sdk.Iterator { } func (k Keeper) GetAllPositions(ctx sdk.Context) []types.Position { - var positionList []types.Position + var positions []types.Position iterator := k.GetPositionIterator(ctx) defer func(iterator sdk.Iterator) { err := iterator.Close() @@ -115,9 +159,49 @@ func (k Keeper) GetAllPositions(ctx sdk.Context) []types.Position { var position types.Position bytesValue := iterator.Value() k.cdc.MustUnmarshal(bytesValue, &position) - positionList = append(positionList, position) + positions = append(positions, position) + } + return positions +} + +func (k Keeper) IteratePoolPosIdsLiquidationSorted(ctx sdk.Context, poolId uint64, fn func(posId types.AddressId) bool) { + store := ctx.KVStore(k.storeKey) + iterator := sdk.KVStorePrefixIterator(store, types.GetLiquidationSortPrefix(poolId)) + defer func(iterator sdk.Iterator) { + err := iterator.Close() + if err != nil { + panic(err) + } + }(iterator) + + for ; iterator.Valid(); iterator.Next() { + addrId := types.AddressId{} + k.cdc.MustUnmarshal(iterator.Value(), &addrId) + stop := fn(addrId) + if stop { + return + } + } +} + +func (k Keeper) IteratePoolPosIdsStopLossSorted(ctx sdk.Context, poolId uint64, fn func(posId types.AddressId) bool) { + store := ctx.KVStore(k.storeKey) + iterator := sdk.KVStorePrefixIterator(store, types.GetStopLossSortPrefix(poolId)) + defer func(iterator sdk.Iterator) { + err := iterator.Close() + if err != nil { + panic(err) + } + }(iterator) + + for ; iterator.Valid(); iterator.Next() { + addrId := types.AddressId{} + k.cdc.MustUnmarshal(iterator.Value(), &addrId) + stop := fn(addrId) + if stop { + return + } } - return positionList } func (k Keeper) GetPositions(ctx sdk.Context, pagination *query.PageRequest) ([]*types.Position, *query.PageResponse, error) { diff --git a/x/leveragelp/keeper/position_test.go b/x/leveragelp/keeper/position_test.go index d78fa57c6..9db52a9e7 100644 --- a/x/leveragelp/keeper/position_test.go +++ b/x/leveragelp/keeper/position_test.go @@ -3,11 +3,13 @@ package keeper_test import ( "testing" + "cosmossdk.io/math" 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/leveragelp/types" paramtypes "github.com/elys-network/elys/x/parameter/types" + stablestaketypes "github.com/elys-network/elys/x/stablestake/types" "github.com/stretchr/testify/require" ) @@ -37,3 +39,182 @@ func TestSetGetPosition(t *testing.T) { positionCount := leveragelp.GetPositionCount(ctx) require.Equal(t, positionCount, (uint64)(2)) } + +func TestIteratePoolPosIdsLiquidationSorted(t *testing.T) { + app := simapp.InitElysTestApp(true) + ctx := app.BaseApp.NewContext(true, tmproto.Header{}) + + leveragelp := app.LeveragelpKeeper + stablestake := app.StablestakeKeeper + + // Generate 2 random accounts with 1000stake balanced + addr := simapp.AddTestAddrs(app, ctx, 2, sdk.NewInt(1000000)) + + positions := []struct { + Id uint64 + LeveragedLpAmount math.Int + Borrowed math.Int + PoolId uint64 + }{ + { + LeveragedLpAmount: math.NewInt(1000), + Id: 7, + Borrowed: math.NewInt(7), + PoolId: 2, + }, + { + LeveragedLpAmount: math.NewInt(100), + Id: 6, + Borrowed: math.NewInt(0), + PoolId: 1, + }, + { + LeveragedLpAmount: math.NewInt(1000), + Id: 5, + Borrowed: math.NewInt(7), + PoolId: 1, + }, + { + LeveragedLpAmount: math.NewInt(1000), + Id: 4, + Borrowed: math.NewInt(8), + PoolId: 1, + }, + { + LeveragedLpAmount: math.NewInt(1000), + Id: 2, + Borrowed: math.NewInt(100), + PoolId: 1, + }, + { + LeveragedLpAmount: math.NewInt(100), + Id: 1, + Borrowed: math.NewInt(10), + PoolId: 1, + }, + { + LeveragedLpAmount: math.NewInt(1000), + Id: 3, + Borrowed: math.NewInt(9), + PoolId: 1, + }, + } + for _, info := range positions { + position := types.Position{ + LeveragedLpAmount: info.LeveragedLpAmount, + Id: info.Id, + Address: addr[0].String(), + Collateral: sdk.NewCoin(paramtypes.BaseCurrency, sdk.NewInt(0)), + Liabilities: sdk.NewInt(0), + InterestPaid: sdk.NewInt(0), + AmmPoolId: info.PoolId, + Leverage: sdk.NewDec(2), + PositionHealth: sdk.NewDec(0), + } + debt := stablestaketypes.Debt{ + Address: position.GetPositionAddress().String(), + Borrowed: info.Borrowed, + InterestPaid: math.ZeroInt(), + InterestStacked: math.ZeroInt(), + BorrowTime: uint64(ctx.BlockTime().Unix()), + LastInterestCalcTime: uint64(ctx.BlockTime().Unix()), + } + stablestake.SetDebt(ctx, debt) + leveragelp.SetPosition(ctx, &position) + } + + idsSorted := []uint64{} + leveragelp.IteratePoolPosIdsLiquidationSorted(ctx, 1, func(posInfo types.AddressId) bool { + idsSorted = append(idsSorted, posInfo.Id) + return false + }) + require.Equal(t, idsSorted, []uint64{1, 2, 3, 4, 5}) + + idsSorted = []uint64{} + leveragelp.IteratePoolPosIdsLiquidationSorted(ctx, 2, func(posInfo types.AddressId) bool { + idsSorted = append(idsSorted, posInfo.Id) + return false + }) + require.Equal(t, idsSorted, []uint64{7}) +} + +func TestIteratePoolPosIdsStopLossSorted(t *testing.T) { + app := simapp.InitElysTestApp(true) + ctx := app.BaseApp.NewContext(true, tmproto.Header{}) + + leveragelp := app.LeveragelpKeeper + + // Generate 2 random accounts with 1000stake balanced + addr := simapp.AddTestAddrs(app, ctx, 2, sdk.NewInt(1000000)) + + positions := []struct { + Id uint64 + StopLossPrice math.LegacyDec + PoolId uint64 + }{ + { + StopLossPrice: math.LegacyNewDec(100), + Id: 7, + PoolId: 2, + }, + { + StopLossPrice: math.LegacyNewDec(101), + Id: 6, + PoolId: 1, + }, + { + StopLossPrice: math.LegacyNewDec(102), + Id: 5, + PoolId: 1, + }, + { + StopLossPrice: math.LegacyNewDec(103), + Id: 4, + PoolId: 1, + }, + { + StopLossPrice: math.LegacyNewDec(104), + Id: 2, + PoolId: 1, + }, + { + StopLossPrice: math.LegacyNewDec(105), + Id: 1, + PoolId: 1, + }, + { + StopLossPrice: math.LegacyNewDec(106), + Id: 3, + PoolId: 1, + }, + } + for _, info := range positions { + position := types.Position{ + LeveragedLpAmount: math.NewInt(1), + Id: info.Id, + Address: addr[0].String(), + Collateral: sdk.NewCoin(paramtypes.BaseCurrency, sdk.NewInt(0)), + Liabilities: sdk.NewInt(0), + InterestPaid: sdk.NewInt(0), + AmmPoolId: info.PoolId, + Leverage: sdk.NewDec(2), + PositionHealth: sdk.NewDec(0), + StopLossPrice: math.LegacyDec(info.StopLossPrice), + } + leveragelp.SetPosition(ctx, &position) + } + + idsSorted := []uint64{} + leveragelp.IteratePoolPosIdsStopLossSorted(ctx, 1, func(posInfo types.AddressId) bool { + idsSorted = append(idsSorted, posInfo.Id) + return false + }) + require.Equal(t, idsSorted, []uint64{6, 5, 4, 2, 1, 3}) + + idsSorted = []uint64{} + leveragelp.IteratePoolPosIdsStopLossSorted(ctx, 2, func(posInfo types.AddressId) bool { + idsSorted = append(idsSorted, posInfo.Id) + return false + }) + require.Equal(t, idsSorted, []uint64{7}) +} diff --git a/x/leveragelp/keeper/query_estimation.go b/x/leveragelp/keeper/query_estimation.go new file mode 100644 index 000000000..769a73b33 --- /dev/null +++ b/x/leveragelp/keeper/query_estimation.go @@ -0,0 +1,65 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/elys-network/elys/x/leveragelp/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func (k Keeper) OpenEst(goCtx context.Context, req *types.QueryOpenEstRequest) (*types.QueryOpenEstResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + leveragedAmount := req.Leverage.MulInt(req.CollateralAmount).TruncateInt() + leverageCoin := sdk.NewCoin(req.CollateralAsset, leveragedAmount) + _, shares, _, weightBalanceBonus, err := k.amm.JoinPoolEst(ctx, req.AmmPoolId, sdk.Coins{leverageCoin}) + if err != nil { + return nil, err + } + params := k.stableKeeper.GetParams(ctx) + + return &types.QueryOpenEstResponse{ + PositionSize: shares, + WeightBalanceRatio: weightBalanceBonus, + BorrowFee: params.InterestRate, + }, nil +} + +func (k Keeper) CloseEst(goCtx context.Context, req *types.QueryCloseEstRequest) (*types.QueryCloseEstResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + position, err := k.GetPosition(ctx, req.Owner, req.Id) + if err != nil { + return nil, err + } + + exitCoins, weightBalanceBonus, err := k.amm.ExitPoolEst(ctx, position.AmmPoolId, req.LpAmount, position.Collateral.Denom) + if err != nil { + return nil, err + } + + // Repay with interest + debt := k.stableKeeper.UpdateInterestStackedByAddress(ctx, position.GetPositionAddress()) + + // Ensure position.LeveragedLpAmount is not zero to avoid division by zero + if position.LeveragedLpAmount.IsZero() { + return nil, types.ErrAmountTooLow + } + + repayAmount := debt.Borrowed.Add(debt.InterestStacked).Sub(debt.InterestPaid).Mul(req.LpAmount).Quo(position.LeveragedLpAmount) + userAmount := exitCoins[0].Amount.Sub(repayAmount) + + return &types.QueryCloseEstResponse{ + Liability: position.Liabilities, + WeightBalanceRatio: weightBalanceBonus, + AmountReturned: userAmount, + }, nil +} diff --git a/x/leveragelp/keeper/query_rewards.go b/x/leveragelp/keeper/query_rewards.go new file mode 100644 index 000000000..276a7688a --- /dev/null +++ b/x/leveragelp/keeper/query_rewards.go @@ -0,0 +1,39 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/elys-network/elys/x/leveragelp/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func (k Keeper) Rewards(goCtx context.Context, req *types.QueryRewardsRequest) (*types.QueryRewardsResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + addr, err := sdk.AccAddressFromBech32(req.Address) + if err != nil { + return nil, err + } + + totalRewards := sdk.Coins{} + rewardInfos := []*types.RewardInfo{} + for _, id := range req.Ids { + position, err := k.GetPosition(ctx, req.Address, id) + if err != nil { + return &types.QueryRewardsResponse{}, nil + } + coins := k.masterchefKeeper.UserPoolPendingReward(ctx, addr, position.AmmPoolId) + rewardInfos = append(rewardInfos, &types.RewardInfo{ + PositionId: id, + Reward: coins, + }) + totalRewards = totalRewards.Add(coins...) + } + + return &types.QueryRewardsResponse{Rewards: rewardInfos, TotalRewards: totalRewards}, nil +} diff --git a/x/leveragelp/migrations/v4_migration.go b/x/leveragelp/migrations/v4_migration.go new file mode 100644 index 000000000..171decd49 --- /dev/null +++ b/x/leveragelp/migrations/v4_migration.go @@ -0,0 +1,13 @@ +package migrations + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func (m Migrator) V4Migration(ctx sdk.Context) error { + positions := m.keeper.GetAllPositions(ctx) + for _, position := range positions { + m.keeper.SetPosition(ctx, &position) + } + return nil +} diff --git a/x/leveragelp/module.go b/x/leveragelp/module.go index 1324f0dab..cb26d6d48 100644 --- a/x/leveragelp/module.go +++ b/x/leveragelp/module.go @@ -117,7 +117,7 @@ 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, 2, m.V3Migration) + err := cfg.RegisterMigration(types.ModuleName, 3, m.V4Migration) if err != nil { panic(err) } @@ -144,7 +144,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 3 } +func (AppModule) ConsensusVersion() uint64 { return 4 } // BeginBlock contains the logic that is automatically triggered at the beginning of each block func (am AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) { diff --git a/x/leveragelp/spec/01_concepts.md b/x/leveragelp/spec/01_concepts.md new file mode 100644 index 000000000..3a1b168ad --- /dev/null +++ b/x/leveragelp/spec/01_concepts.md @@ -0,0 +1,60 @@ + + +# Concepts + +`leveragelp` module provides interface for users to add liquidity in leverage to get more rewards for liquidity providers. + +The underlying mechanism is when a user would like to open a leveraged position, module borrows `USDC` from stablestake module and put it as liquidity along with collateral amount received from the user. + +To make it secure, the module monitors position value and if it goes down below threshold, it is force closing the position and returning all the borrowed `USDC` back to `stablestake` module along with stacked interest. + +# Mechanism + +The LeverageLP module enables participants to leverage their liquidity position in the AMM pool by borrowing USDC tokens bonded in the StableStake module. This interaction results in a leveraged position that is tracked and managed within the LeverageLP module. + +## Dependencies + +The LeverageLP module depends on two other modules: + +1. **StableStake**: Manages the bonding of USDC tokens by participants. +2. **AMM**: Facilitates liquidity provision and trading. + +## Overview + +Participants in the system engage with the modules as follows: + +1. **Bonding USDC to StableStake**: + + - Participants bond their USDC tokens to the StableStake module. + - These bonded tokens become available for borrowing by other participants. + +2. **Leveraging Liquidity with LeverageLP**: + - Participants borrow USDC tokens from the StableStake module using the LeverageLP module. + - The borrowed tokens are used to enhance their liquidity position in the AMM pool. + - This results in a debt recorded within the StableStake module. + +## Key Equations + +To maintain the stability and health of the pool, the following equations are used: + +1. **Pool Health**: + + $\text{Pool Health} = \frac{\text{Total Shares} - \text{Leveraged LP Amount}}{\text{Total Shares}}$ + + - **Total Shares**: The total number of shares in the pool. + - **Leveraged LP Amount**: The amount of liquidity added to the pool through leveraged positions. + + The Pool Health metric is monitored to ensure it does not fall below the Safety Factor threshold, which is set at 10%. Lower Pool Health indicates higher risk of leveraged positions being liquidated. + +2. **Position Health and Liquidation Mechanism**: + + $\text{Position Health} = \frac{\text{Position Value}}{\text{Borrowed Amount} + \text{Interest Staked} + \text{Interest Paid}}$ + + - **Position Value**: The current value of the leveraged position. + - **Borrowed Amount**: The total amount of USDC borrowed from the StableStake module. + - **Interest Staked**: The amount of interest accrued on the borrowed amount. + - **Interest Paid**: The amount of interest paid by the participant. + + If Position Health falls below the Safety Factor threshold (10%), the leveraged LP position is automatically liquidated to protect the underlying liquidity pool. diff --git a/x/leveragelp/spec/02_state.md b/x/leveragelp/spec/02_state.md new file mode 100644 index 000000000..e705f0c2c --- /dev/null +++ b/x/leveragelp/spec/02_state.md @@ -0,0 +1,104 @@ + + +# State + +The `GenesisState` message defines the initial state of the `leveragelp` module at genesis. + +```proto +// GenesisState defines the leveragelp module's genesis state. +message GenesisState { + Params params = 1 [ (gogoproto.nullable) = false ]; + repeated Pool pool_list = 2 [ (gogoproto.nullable) = false ]; + repeated Position position_list = 3 [ (gogoproto.nullable) = false ]; + repeated string address_whitelist = 4; +} +``` + +## Params + +`Params` holds module parameters like protocol revenue address, supported reward denoms, max eden apr, reward portion for lps and stakers and yearly incentive data. + +```proto +// Params defines the parameters for the module. +message Params { + option (gogoproto.goproto_stringer) = false; + string leverage_max = 1 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + int64 max_open_positions = 2; + string pool_open_threshold = 3 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + string safety_factor = 4 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + bool whitelisting_enabled = 5; + int64 epoch_length = 6; +} +``` + +## Pool + +The `Pool` message contains information about the AMM pools involved in leveraged positions, including their health and the total amount of leveraged LP tokens. + +```proto +message Pool { + uint64 amm_pool_id = 1; + string health = 2 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + bool enabled = 3; + bool closed = 4; + string leveraged_lp_amount = 5 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; + string leverage_max = 6 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; +} +``` + +## Position + +The `Position` message tracks leveraged positions in the module. It includes information on the collateral, leverage, health, and other parameters. + +```proto +message Position { + string address = 1; + cosmos.base.v1beta1.Coin collateral = 2 [(gogoproto.nullable) = false]; + string liabilities = 3 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; // For recording + string interest_paid = 4 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; // For recording + string leverage = 5 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; // For recording + string leveraged_lp_amount = 6 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; + string position_health = 7 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + uint64 id = 8; + uint64 amm_pool_id = 9; + string stop_loss_price = 10 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; +} +``` diff --git a/x/leveragelp/spec/03_keeper.md b/x/leveragelp/spec/03_keeper.md new file mode 100644 index 000000000..5533e7f26 --- /dev/null +++ b/x/leveragelp/spec/03_keeper.md @@ -0,0 +1,37 @@ + + +# Keeper + +## Position Management + +The `leveragelp` module's keeper handles the opening, updating, and closing of leveraged positions. It ensures that positions are correctly managed, leverage limits are respected, and health checks are performed to avoid liquidation risks. + +### Opening a Position + +The `Open` function allows a user to open a leveraged position by providing collateral and specifying leverage and a stop-loss price. + +### Closing a Position + +The `Close` function allows a user to close a leveraged position, either partially or fully, by specifying the amount of LP tokens to withdraw. + +### Liquidation and Health Checks + +The `BeginBlocker` function performs regular health checks on all positions and liquidates unhealthy positions if necessary. + +## BeginBlocker + +The `BeginBlocker` function is called at the beginning of each block to perform necessary updates and maintenance for the `leveragelp` module. It processes health checks and liquidates unhealthy positions if needed. + +### LiquidatePositionIfUnhealthy + +The `LiquidatePositionIfUnhealthy` function checks the health of a position and liquidates it if it is unhealthy. + +### UpdatePoolHealth + +The `UpdatePoolHealth` function updates the health of a pool based on the current state of its positions. + +### GetPositionHealth + +The `GetPositionHealth` function calculates the health of a position based on its collateral and liabilities. diff --git a/x/leveragelp/spec/04_endpoints.md b/x/leveragelp/spec/04_endpoints.md new file mode 100644 index 000000000..25b98b0d7 --- /dev/null +++ b/x/leveragelp/spec/04_endpoints.md @@ -0,0 +1,259 @@ + + +# Endpoints + +## Gov Proposals + +```proto +service Msg { + rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse); + rpc UpdatePools(MsgUpdatePools) returns (MsgUpdatePoolsResponse); + rpc Whitelist(MsgWhitelist) returns (MsgWhitelistResponse); + rpc Dewhitelist(MsgDewhitelist) returns (MsgDewhitelistResponse); +} +``` + +### UpdateParams + +`MsgUpdateParams` is used by governance to update leveragelp module params. + +```proto +message MsgUpdateParams { + string authority = 1; + Params params = 2 [(gogoproto.nullable) = false]; +} +``` + +### MsgUpdatePools + +`MsgUpdatePools` is used by governance to update leveragelp pool infos. + +```proto +message MsgUpdatePools { + string authority = 1; + repeated Pool pools = 2 [(gogoproto.nullable) = false]; +} +``` + +### MsgWhitelist + +`MsgWhitelist` is used by governance to approve an address to the whitelist. + +```proto +message MsgWhitelist { + string authority = 1; + string whitelisted_address = 2; +} +``` + +### MsgDewhitelist + +`MsgDewhitelist` is used by governance to remove an address from the whitelist. + +```proto +message MsgDewhitelist { + string authority = 1; + string whitelisted_address = 2; +} +``` + +## Msgs + +The `Msg` service defines the transactions available in the `leveragelp` module. + +```proto +service Msg { + rpc Open(MsgOpen) returns (MsgOpenResponse); + rpc Close(MsgClose) returns (MsgCloseResponse); +} +``` + +### MsgOpen + +`MsgOpen` is used to open a leveragelp position. + +```proto +message MsgOpen { + string creator = 1; + string collateral_asset = 2; + string collateral_amount = 3 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; + uint64 amm_pool_id = 4; + string leverage = 5 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + string stop_loss_price = 6 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; +} +``` + +### MsgClose + +`MsgClose` is used to partially close a leveragelp position. + +```proto +message MsgClose { + string creator = 1; + uint64 id = 2; + string lp_amount = 3 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; +} +``` + +## Query endpoints + +The `Query` service defines the gRPC querier service for the `leveragelp` module. + +```proto +service Query { + rpc Params(ParamsRequest) returns (ParamsResponse) { + option (google.api.http).get = "/elys-network/elys/leveragelp/params"; + } + rpc QueryPositions(PositionsRequest) returns (PositionsResponse) { + option (google.api.http).get = "/elys-network/elys/leveragelp/positions/{pagination.key}"; + } + rpc QueryPositionsByPool(PositionsByPoolRequest) returns (PositionsByPoolResponse) { + option (google.api.http).get = "/elys-network/elys/leveragelp/positions-by-pool/{amm_pool_id}/{pagination.key}"; + } + rpc GetStatus(StatusRequest) returns (StatusResponse) { + option (google.api.http).get = "/elys-network/elys/leveragelp/status"; + } + rpc QueryPositionsForAddress(PositionsForAddressRequest) returns (PositionsForAddressResponse) { + option (google.api.http).get = "/elys-network/elys/leveragelp/positions-for-address/{address}/{pagination.key}"; + } + rpc GetWhitelist(WhitelistRequest) returns (WhitelistResponse) { + option (google.api.http).get = "/elys-network/elys/leveragelp/whitelist/{pagination.key}"; + } + rpc IsWhitelisted(IsWhitelistedRequest) returns (IsWhitelistedResponse) { + option (google.api.http).get = "/elys-network/elys/leveragelp/is-whitelisted"; + } + rpc Pool(QueryGetPoolRequest) returns (QueryGetPoolResponse) { + option (google.api.http).get = "/elys-network/elys/leveragelp/pool/{index}"; + } + rpc Pools(QueryAllPoolRequest) returns (QueryAllPoolResponse) { + option (google.api.http).get = "/elys-network/elys/leveragelp/pool/{pagination.key}"; + } + rpc Position(PositionRequest) returns (PositionResponse) { + option (google.api.http).get = "/elys-network/elys/leveragelp/position/{address}/{id}"; + } +} +``` + +### Params + +Query the parameters of the `leveragelp` module. + +### QueryPositions + +Query all positions through pagination. + +### QueryPositionsByPool + +Query open positions by pool id. + +### GetStatus + +Queries status of leveragelp module, it returns number of active open positions, and positions opened from the beginning. + +### QueryPositionsForAddress + +Queries open positions for an address + +### GetWhitelist + +Queries whitelisted addresses for position open, in case `params.whitelisting_enabled` is set to true. + +### IsWhitelisted + +Queries if an address is in the list of whitelisted array. + +### Pool + +Queries leveragelp pool info by pool id. + +### Pools + +Queries all leveragelp pool infos. + +### Position + +Queries a position by address and id. + +### OpenEst + +Queries position open estimation result. + +### CloseEst + +Queries position close estimation result. + +## Wasmbindings + +### Messages + +#### LeveragelpOpen + +Connect wasmbinding to `MsgOpen` + +#### LeveragelpClose + +Connect wasmbinding to `MsgClose` + +### Queries + +#### LeveragelpParams + +Connect wasmbinding to `Params` query. + +#### LeveragelpQueryPositions + +Connect wasmbinding to `QueryPositions` query. + +#### LeveragelpQueryPositionsByPool + +Connect wasmbinding to `QueryPositionsByPool` query. + +#### LeveragelpGetStatus + +Connect wasmbinding to `GetStatus` query. + +#### LeveragelpQueryPositionsForAddress + +Connect wasmbinding to `QueryPositionsForAddress` query. + +#### LeveragelpGetWhitelist + +Connect wasmbinding to `GetWhitelist` query. + +#### LeveragelpIsWhitelisted + +Connect wasmbinding to `IsWhitelisted` query. + +#### LeveragelpPool + +Connect wasmbinding to `Pool` query. + +#### LeveragelpPools + +Connect wasmbinding to `Pools` query. + +#### LeveragelpPosition + +Connect wasmbinding to `Position` query. + +#### LeveragelpOpenEst + +Connect wasmbinding to `OpenEst` query. + +#### LeveragelpCloseEst + +Connect wasmbinding to `CloseEst` query. diff --git a/x/leveragelp/spec/05_cli.md b/x/leveragelp/spec/05_cli.md new file mode 100644 index 000000000..8efc26f11 --- /dev/null +++ b/x/leveragelp/spec/05_cli.md @@ -0,0 +1,56 @@ + + +# CLI + +## Commands + +### Querying Parameters + +```bash +elysd query leveragelp params +``` + +### Querying Pools + +```bash +elysd query leveragelp pools +elysd query leveragelp pool +``` + +### Querying Positions + +```bash +elysd query leveragelp positions +elysd query leveragelp position
+elysd query leveragelp positions-by-pool +elysd query leveragelp positions-for-address
+``` + +### Querying Status and Whitelist + +```bash +elysd query leveragelp status +elysd query leveragelp whitelist +elysd query leveragelp is-whitelisted
+``` + +### Opening a Leveraged Position + +```bash +elysd tx leveragelp open --from
--collateral-asset --collateral-amount --amm-pool-id --leverage --stop-loss-price --chain-id --yes +``` + +### Closing a Leveraged Position + +```bash +elysd tx leveragelp close --from
--id --lp-amount --chain-id --yes +``` + +### Whitelisting and Dewhitelisting Addresses + +```bash +elysd tx leveragelp whitelist --from --whitelisted-address
--chain-id --yes +elysd tx leveragelp dewhitelist --from --whitelisted-address
--chain-id --yes +``` diff --git a/x/leveragelp/spec/README.md b/x/leveragelp/spec/README.md index a6f4c8baf..243e9c2d6 100644 --- a/x/leveragelp/spec/README.md +++ b/x/leveragelp/spec/README.md @@ -1,3 +1,24 @@ # leveragelp module -`leveragelp` module is to support leverage on liquidity management. +`leveragelp` module provides interface for users to add liquidity in leverage in AMM pools to get more rewards. By utilizing collateral and leverage, users can enhance their returns from liquidity provisioning while the module ensures the safety and stability of these leveraged positions through rigorous health checks and liquidation mechanisms. + +The underlying mechanism is when a user would like to open a leveraged position, module borrows `USDC` from stablestake module and put it as liquidity along with collateral amount received from the user. + +To make it secure, the module monitors position value and if it goes down below threshold, it is force closing the position and returning all the borrowed `USDC` back to `stablestake` module along with stacked interest. + +## Key Features + +- **Leveraged Liquidity Provision**: Allow users to open leveraged positions in AMM pools. +- **Health Checks and Liquidation**: Regularly check the health of positions and liquidate unhealthy ones to maintain stability. +- **Whitelist Management**: Manage access through address whitelisting. +- **Flexible Parameter Management**: Update leverage limits, pool thresholds, and other parameters dynamically. + +For more detailed information, please refer to the individual sections listed in the contents below. + +## Contents + +1. **[Concepts](01_concepts.md)** +2. **[State](02_state.md)** +3. **[Keeper](03_keeper.md)** +4. **[Endpoints](04_endpoints.md)** +5. **[CLI](05_cli.md)** diff --git a/x/leveragelp/types/codec.go b/x/leveragelp/types/codec.go index 73612dd92..f4821e2c7 100644 --- a/x/leveragelp/types/codec.go +++ b/x/leveragelp/types/codec.go @@ -14,6 +14,7 @@ func RegisterCodec(cdc *codec.LegacyAmino) { cdc.RegisterConcrete(&MsgUpdatePools{}, "leveragelp/UpdatePools", nil) cdc.RegisterConcrete(&MsgWhitelist{}, "leveragelp/Whitelist", nil) cdc.RegisterConcrete(&MsgDewhitelist{}, "leveragelp/Dewhitelist", nil) + cdc.RegisterConcrete(&MsgClaimRewards{}, "leveragelp/ClaimRewards", nil) cdc.RegisterConcrete(&MsgUpdateStopLoss{}, "leveragelp/UpdateStopLoss", nil) // this line is used by starport scaffolding # 2 } @@ -26,11 +27,10 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { &MsgUpdatePools{}, &MsgWhitelist{}, &MsgDewhitelist{}, - ) - - registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgClaimRewards{}, &MsgUpdateStopLoss{}, ) + // this line is used by starport scaffolding # 3 msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) diff --git a/x/leveragelp/types/expected_keepers.go b/x/leveragelp/types/expected_keepers.go index 268471268..ca646d2ca 100644 --- a/x/leveragelp/types/expected_keepers.go +++ b/x/leveragelp/types/expected_keepers.go @@ -22,6 +22,8 @@ type AmmKeeper interface { GetPool(sdk.Context, uint64) (ammtypes.Pool, bool) // Get all pools GetAllPool(sdk.Context) []ammtypes.Pool + ExitPoolEst(ctx sdk.Context, poolId uint64, shareInAmount math.Int, tokenOutDenom string) (exitCoins sdk.Coins, weightBalanceBonus math.LegacyDec, err error) + JoinPoolEst(ctx sdk.Context, poolId uint64, tokenInMaxs sdk.Coins) (tokensIn sdk.Coins, sharesOut math.Int, slippage sdk.Dec, weightBalanceBonus sdk.Dec, err error) // 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) @@ -71,3 +73,9 @@ type AssetProfileKeeper interface { // GetUsdcDenom returns USDC denom GetUsdcDenom(ctx sdk.Context) (string, bool) } + +// MasterchefKeeper defines expected interface for masterchef keeper +type MasterchefKeeper interface { + ClaimRewards(ctx sdk.Context, sender sdk.AccAddress, poolIds []uint64) error + UserPoolPendingReward(ctx sdk.Context, user sdk.AccAddress, poolId uint64) sdk.Coins +} diff --git a/x/leveragelp/types/keys.go b/x/leveragelp/types/keys.go index f9b06f4bf..c12038e88 100644 --- a/x/leveragelp/types/keys.go +++ b/x/leveragelp/types/keys.go @@ -1,6 +1,10 @@ package types -import "encoding/binary" +import ( + "encoding/binary" + + "cosmossdk.io/math" +) const ( // ModuleName defines the module name @@ -27,6 +31,8 @@ var ( OpenPositionCountPrefix = []byte{0x04} WhitelistPrefix = []byte{0x05} SQBeginBlockPrefix = []byte{0x06} + LiquidationSortPrefix = []byte{0x07} // Position liquidation sort prefix + StopLossSortPrefix = []byte{0x08} // Position stop loss sort prefix ) func KeyPrefix(p string) []byte { @@ -53,6 +59,39 @@ func GetPositionKey(address string, id uint64) []byte { return append(PositionPrefix, append([]byte(address), GetUint64Bytes(id)...)...) } +func GetLiquidationSortPrefix(poolId uint64) []byte { + return append(LiquidationSortPrefix, GetUint64Bytes(poolId)...) +} + +func GetLiquidationSortKey(poolId uint64, lpAmount math.Int, borrowed math.Int, id uint64) []byte { + poolIdPrefix := GetLiquidationSortPrefix(poolId) + if lpAmount.IsZero() || borrowed.IsZero() { + return []byte{} + } + + sortDec := math.LegacyNewDecFromInt(lpAmount).QuoInt(borrowed) + bytes := sortDec.BigInt().Bytes() + lengthPrefix := GetUint64Bytes(uint64(len(bytes))) + posIdSuffix := GetUint64Bytes(id) + return append(append(append(poolIdPrefix, lengthPrefix...), bytes...), posIdSuffix...) +} + +func GetStopLossSortPrefix(poolId uint64) []byte { + return append(StopLossSortPrefix, GetUint64Bytes(poolId)...) +} + +func GetStopLossSortKey(poolId uint64, stopLossPrice math.LegacyDec, id uint64) []byte { + poolIdPrefix := GetStopLossSortPrefix(poolId) + if stopLossPrice.IsNil() || !stopLossPrice.IsPositive() { + return []byte{} + } + + bytes := stopLossPrice.BigInt().Bytes() + lengthPrefix := GetUint64Bytes(uint64(len(bytes))) + posIdSuffix := GetUint64Bytes(id) + return append(append(append(poolIdPrefix, lengthPrefix...), bytes...), posIdSuffix...) +} + func GetPositionPrefixForAddress(address string) []byte { return append(PositionPrefix, []byte(address)...) } diff --git a/x/leveragelp/types/msgs.go b/x/leveragelp/types/msgs.go index 25707c930..5ae352932 100644 --- a/x/leveragelp/types/msgs.go +++ b/x/leveragelp/types/msgs.go @@ -14,6 +14,7 @@ const ( TypeMsgWhitelist = "whitelist" TypeMsgUpdatePools = "update_pools" TypeMsgDewhitelist = "dewhitelist" + TypeMsgClaimRewards = "claim_rewards" ) var ( @@ -23,6 +24,7 @@ var ( _ sdk.Msg = &MsgWhitelist{} _ sdk.Msg = &MsgUpdatePools{} _ sdk.Msg = &MsgDewhitelist{} + _ sdk.Msg = &MsgClaimRewards{} ) func NewMsgClose(creator string, id uint64, amount math.Int) *MsgClose { @@ -245,3 +247,39 @@ func (msg *MsgDewhitelist) ValidateBasic() error { } return nil } + +func NewMsgClaimRewards(signer string, ids []uint64) *MsgClaimRewards { + return &MsgClaimRewards{ + Sender: signer, + Ids: ids, + } +} + +func (msg *MsgClaimRewards) Route() string { + return RouterKey +} + +func (msg *MsgClaimRewards) Type() string { + return TypeMsgClaimRewards +} + +func (msg *MsgClaimRewards) GetSigners() []sdk.AccAddress { + authority, err := sdk.AccAddressFromBech32(msg.Sender) + if err != nil { + panic(err) + } + return []sdk.AccAddress{authority} +} + +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 creator address (%s)", err) + } + return nil +} diff --git a/x/leveragelp/types/mtp.go b/x/leveragelp/types/position.go similarity index 71% rename from x/leveragelp/types/mtp.go rename to x/leveragelp/types/position.go index 65877ae7b..42312694e 100644 --- a/x/leveragelp/types/mtp.go +++ b/x/leveragelp/types/position.go @@ -7,7 +7,11 @@ import ( authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" ) +func GetPositionAddress(positionId uint64) sdk.AccAddress { + return authtypes.NewModuleAddress(fmt.Sprintf("leveragelp/%d", positionId)) +} + // Get Position address func (p *Position) GetPositionAddress() sdk.AccAddress { - return authtypes.NewModuleAddress(fmt.Sprintf("leveragelp/%d", p.Id)) + return GetPositionAddress(p.Id) } diff --git a/x/leveragelp/types/query.pb.go b/x/leveragelp/types/query.pb.go index 865f3e6eb..73d85d9d7 100644 --- a/x/leveragelp/types/query.pb.go +++ b/x/leveragelp/types/query.pb.go @@ -6,6 +6,8 @@ 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" query "github.com/cosmos/cosmos-sdk/types/query" _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/cosmos/gogoproto/grpc" @@ -977,6 +979,347 @@ func (m *PositionResponse) GetPosition() *Position { return nil } +type QueryOpenEstRequest struct { + CollateralAsset string `protobuf:"bytes,1,opt,name=collateral_asset,json=collateralAsset,proto3" json:"collateral_asset,omitempty"` + CollateralAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=collateral_amount,json=collateralAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"collateral_amount"` + AmmPoolId uint64 `protobuf:"varint,3,opt,name=amm_pool_id,json=ammPoolId,proto3" json:"amm_pool_id,omitempty"` + Leverage github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,4,opt,name=leverage,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"leverage"` +} + +func (m *QueryOpenEstRequest) Reset() { *m = QueryOpenEstRequest{} } +func (m *QueryOpenEstRequest) String() string { return proto.CompactTextString(m) } +func (*QueryOpenEstRequest) ProtoMessage() {} +func (*QueryOpenEstRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_76659893e638cc9b, []int{20} +} +func (m *QueryOpenEstRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryOpenEstRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryOpenEstRequest.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 *QueryOpenEstRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryOpenEstRequest.Merge(m, src) +} +func (m *QueryOpenEstRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryOpenEstRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryOpenEstRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryOpenEstRequest proto.InternalMessageInfo + +func (m *QueryOpenEstRequest) GetCollateralAsset() string { + if m != nil { + return m.CollateralAsset + } + return "" +} + +func (m *QueryOpenEstRequest) GetAmmPoolId() uint64 { + if m != nil { + return m.AmmPoolId + } + return 0 +} + +type QueryOpenEstResponse struct { + PositionSize github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=position_size,json=positionSize,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"position_size"` + WeightBalanceRatio github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=weight_balance_ratio,json=weightBalanceRatio,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"weight_balance_ratio"` + BorrowFee github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=borrow_fee,json=borrowFee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"borrow_fee"` +} + +func (m *QueryOpenEstResponse) Reset() { *m = QueryOpenEstResponse{} } +func (m *QueryOpenEstResponse) String() string { return proto.CompactTextString(m) } +func (*QueryOpenEstResponse) ProtoMessage() {} +func (*QueryOpenEstResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_76659893e638cc9b, []int{21} +} +func (m *QueryOpenEstResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryOpenEstResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryOpenEstResponse.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 *QueryOpenEstResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryOpenEstResponse.Merge(m, src) +} +func (m *QueryOpenEstResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryOpenEstResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryOpenEstResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryOpenEstResponse proto.InternalMessageInfo + +type QueryCloseEstRequest struct { + Owner string `protobuf:"bytes,1,opt,name=owner,proto3" json:"owner,omitempty"` + Id uint64 `protobuf:"varint,2,opt,name=id,proto3" json:"id,omitempty"` + LpAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=lp_amount,json=lpAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"lp_amount"` +} + +func (m *QueryCloseEstRequest) Reset() { *m = QueryCloseEstRequest{} } +func (m *QueryCloseEstRequest) String() string { return proto.CompactTextString(m) } +func (*QueryCloseEstRequest) ProtoMessage() {} +func (*QueryCloseEstRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_76659893e638cc9b, []int{22} +} +func (m *QueryCloseEstRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryCloseEstRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryCloseEstRequest.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 *QueryCloseEstRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryCloseEstRequest.Merge(m, src) +} +func (m *QueryCloseEstRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryCloseEstRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryCloseEstRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryCloseEstRequest proto.InternalMessageInfo + +func (m *QueryCloseEstRequest) GetOwner() string { + if m != nil { + return m.Owner + } + return "" +} + +func (m *QueryCloseEstRequest) GetId() uint64 { + if m != nil { + return m.Id + } + return 0 +} + +type QueryRewardsRequest struct { + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + Ids []uint64 `protobuf:"varint,2,rep,packed,name=ids,proto3" json:"ids,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_76659893e638cc9b, []int{23} +} +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 "" +} + +func (m *QueryRewardsRequest) GetIds() []uint64 { + if m != nil { + return m.Ids + } + return nil +} + +type RewardInfo struct { + PositionId uint64 `protobuf:"varint,1,opt,name=position_id,json=positionId,proto3" json:"position_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_76659893e638cc9b, []int{24} +} +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) GetPositionId() uint64 { + if m != nil { + return m.PositionId + } + return 0 +} + +func (m *RewardInfo) GetReward() github_com_cosmos_cosmos_sdk_types.Coins { + if m != nil { + return m.Reward + } + return nil +} + +type QueryRewardsResponse 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 *QueryRewardsResponse) Reset() { *m = QueryRewardsResponse{} } +func (m *QueryRewardsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryRewardsResponse) ProtoMessage() {} +func (*QueryRewardsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_76659893e638cc9b, []int{25} +} +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() []*RewardInfo { + if m != nil { + return m.Rewards + } + return nil +} + +func (m *QueryRewardsResponse) GetTotalRewards() github_com_cosmos_cosmos_sdk_types.Coins { + if m != nil { + return m.TotalRewards + } + return nil +} + +type QueryCloseEstResponse struct { + Liability github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=liability,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"liability"` + WeightBalanceRatio github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=weight_balance_ratio,json=weightBalanceRatio,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"weight_balance_ratio"` + AmountReturned github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=amount_returned,json=amountReturned,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"amount_returned"` +} + +func (m *QueryCloseEstResponse) Reset() { *m = QueryCloseEstResponse{} } +func (m *QueryCloseEstResponse) String() string { return proto.CompactTextString(m) } +func (*QueryCloseEstResponse) ProtoMessage() {} +func (*QueryCloseEstResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_76659893e638cc9b, []int{26} +} +func (m *QueryCloseEstResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryCloseEstResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryCloseEstResponse.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 *QueryCloseEstResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryCloseEstResponse.Merge(m, src) +} +func (m *QueryCloseEstResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryCloseEstResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryCloseEstResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryCloseEstResponse proto.InternalMessageInfo + func init() { proto.RegisterType((*ParamsRequest)(nil), "elys.leveragelp.ParamsRequest") proto.RegisterType((*ParamsResponse)(nil), "elys.leveragelp.ParamsResponse") @@ -998,76 +1341,114 @@ func init() { proto.RegisterType((*QueryAllPoolResponse)(nil), "elys.leveragelp.QueryAllPoolResponse") proto.RegisterType((*PositionRequest)(nil), "elys.leveragelp.PositionRequest") proto.RegisterType((*PositionResponse)(nil), "elys.leveragelp.PositionResponse") + proto.RegisterType((*QueryOpenEstRequest)(nil), "elys.leveragelp.QueryOpenEstRequest") + proto.RegisterType((*QueryOpenEstResponse)(nil), "elys.leveragelp.QueryOpenEstResponse") + proto.RegisterType((*QueryCloseEstRequest)(nil), "elys.leveragelp.QueryCloseEstRequest") + proto.RegisterType((*QueryRewardsRequest)(nil), "elys.leveragelp.QueryRewardsRequest") + proto.RegisterType((*RewardInfo)(nil), "elys.leveragelp.RewardInfo") + proto.RegisterType((*QueryRewardsResponse)(nil), "elys.leveragelp.QueryRewardsResponse") + proto.RegisterType((*QueryCloseEstResponse)(nil), "elys.leveragelp.QueryCloseEstResponse") } func init() { proto.RegisterFile("elys/leveragelp/query.proto", fileDescriptor_76659893e638cc9b) } var fileDescriptor_76659893e638cc9b = []byte{ - // 1021 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x97, 0xcf, 0x6f, 0x1b, 0x45, - 0x14, 0xc7, 0x33, 0x6e, 0x12, 0xe2, 0x97, 0xc6, 0x69, 0xa6, 0x09, 0x09, 0xdb, 0xca, 0x4d, 0x57, - 0x4d, 0x1a, 0xb5, 0xf1, 0x2e, 0x4d, 0x09, 0x45, 0x54, 0x48, 0x34, 0x48, 0xb5, 0x72, 0x41, 0xc6, - 0x48, 0x80, 0x22, 0x21, 0x6b, 0x9d, 0x9d, 0xba, 0xa3, 0xae, 0x77, 0xb6, 0xde, 0x71, 0x13, 0x37, - 0x0a, 0x42, 0x5c, 0xb8, 0x20, 0x54, 0x04, 0x08, 0x21, 0x0e, 0xfc, 0x2d, 0xdc, 0x7a, 0x41, 0xaa, - 0xc4, 0x85, 0x13, 0x42, 0x09, 0x7f, 0x08, 0xda, 0xd9, 0xd9, 0xf5, 0xfe, 0xcc, 0x5a, 0x95, 0x0f, - 0xb9, 0xd9, 0x33, 0xef, 0xc7, 0x67, 0xde, 0x7b, 0x33, 0x5f, 0x1b, 0xae, 0x10, 0x6b, 0xe0, 0xea, - 0x16, 0x79, 0x46, 0x7a, 0x46, 0x87, 0x58, 0x8e, 0xfe, 0xb4, 0x4f, 0x7a, 0x03, 0xcd, 0xe9, 0x31, - 0xce, 0xf0, 0xbc, 0xb7, 0xa9, 0x0d, 0x37, 0x95, 0xc5, 0x0e, 0xeb, 0x30, 0xb1, 0xa7, 0x7b, 0x9f, - 0x7c, 0x33, 0xe5, 0x6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52, 0x5c, 0x98, - 0x1b, 0xa9, 0x34, 0x19, 0x3a, 0xa3, 0xac, 0x15, 0x58, 0x49, 0x96, 0x2d, 0xc1, 0xb2, 0x89, 0x6f, - 0x15, 0xb5, 0xd7, 0xbb, 0x1d, 0x42, 0xab, 0x8e, 0xf1, 0x0f, 0x08, 0xa6, 0xbc, 0x20, 0x6e, 0x1e, - 0x4a, 0x5c, 0x7c, 0xf2, 0x50, 0x12, 0x12, 0xa2, 0xde, 0x17, 0x28, 0xdb, 0xf8, 0xee, 0x28, 0x28, - 0xc9, 0xa6, 0x7d, 0x8f, 0x60, 0x26, 0x18, 0x63, 0xbc, 0x9a, 0xff, 0x5e, 0x4b, 0xa4, 0xeb, 0x67, - 0x58, 0x48, 0x9c, 0x0f, 0x04, 0xce, 0x3d, 0xbc, 0x3d, 0xda, 0xe0, 0x47, 0x67, 0x9d, 0x9a, 0xc7, - 0x3b, 0xbb, 0x2f, 0x4f, 0xaa, 0xe8, 0xd5, 0x49, 0x15, 0xfd, 0x7b, 0x52, 0x45, 0x2f, 0x4e, 0xab, - 0x13, 0xaf, 0x4e, 0xab, 0x13, 0x7f, 0x9f, 0x56, 0x27, 0xf6, 0xf4, 0x0e, 0xe5, 0x8f, 0xfb, 0x6d, - 0x6d, 0x9f, 0x75, 0x33, 0x42, 0x1f, 0xa6, 0xfe, 0xeb, 0xb5, 0xa7, 0xc5, 0x1f, 0xba, 0xbb, 0xff, - 0x07, 0x00, 0x00, 0xff, 0xff, 0x60, 0xb3, 0x47, 0x00, 0xb7, 0x0e, 0x00, 0x00, + // 1511 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x58, 0xcd, 0x6f, 0x1b, 0x45, + 0x14, 0xcf, 0x3a, 0x9f, 0x7e, 0x69, 0xe2, 0x64, 0x9a, 0xd0, 0xe0, 0x56, 0x4e, 0xba, 0x6a, 0xd3, + 0xd0, 0xc6, 0xde, 0x36, 0x25, 0x2d, 0xa2, 0x42, 0x22, 0x29, 0x34, 0x32, 0x9f, 0x61, 0x2b, 0x51, + 0x54, 0x84, 0xcc, 0xda, 0x3b, 0x71, 0x47, 0x5d, 0xef, 0xb8, 0xbb, 0x93, 0xba, 0x4e, 0x15, 0x84, + 0xb8, 0xa0, 0x1e, 0x80, 0xf2, 0x25, 0x84, 0x40, 0x82, 0x33, 0xff, 0x04, 0x82, 0x53, 0x2f, 0x48, + 0x95, 0xb8, 0x20, 0x0e, 0x05, 0xb5, 0xfc, 0x21, 0x68, 0x67, 0x67, 0xd6, 0xeb, 0x5d, 0xaf, 0xed, + 0x46, 0x01, 0xf5, 0x64, 0x7b, 0xe6, 0x7d, 0xfc, 0xde, 0xef, 0xbd, 0x37, 0xf3, 0xc6, 0x70, 0x18, + 0x5b, 0x4d, 0x57, 0xb3, 0xf0, 0x4d, 0xec, 0x18, 0x55, 0x6c, 0xd5, 0xb5, 0x1b, 0xdb, 0xd8, 0x69, + 0x16, 0xea, 0x0e, 0x65, 0x14, 0x65, 0xbc, 0xcd, 0x42, 0x6b, 0x33, 0x3b, 0x53, 0xa5, 0x55, 0xca, + 0xf7, 0x34, 0xef, 0x9b, 0x2f, 0x96, 0x3d, 0x52, 0xa5, 0xb4, 0x6a, 0x61, 0xcd, 0xa8, 0x13, 0xcd, + 0xb0, 0x6d, 0xca, 0x0c, 0x46, 0xa8, 0xed, 0x8a, 0xdd, 0x5c, 0x85, 0xba, 0x35, 0xea, 0x6a, 0x65, + 0xc3, 0xc5, 0xda, 0xcd, 0x33, 0x65, 0xcc, 0x8c, 0x33, 0x5a, 0x85, 0x12, 0x5b, 0xec, 0x9f, 0x0c, + 0xef, 0x73, 0xef, 0x81, 0x54, 0xdd, 0xa8, 0x12, 0x9b, 0x1b, 0x93, 0x9e, 0xa2, 0x68, 0xeb, 0x86, + 0x63, 0xd4, 0xa4, 0xa7, 0x58, 0x2c, 0xac, 0x59, 0xc7, 0x72, 0x33, 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 0x47, 0xf8, 0x5f, 0x9f, 0x67, 0xff, 0x0d, 0x00, 0x00, 0xff, 0xff, 0x23, + 0x1f, 0x7c, 0xcf, 0x01, 0x16, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1101,6 +1482,12 @@ type QueryClient interface { Pools(ctx context.Context, in *QueryAllPoolRequest, opts ...grpc.CallOption) (*QueryAllPoolResponse, error) // Queries a list of Position items. Position(ctx context.Context, in *PositionRequest, opts ...grpc.CallOption) (*PositionResponse, error) + // Get estimated amount of return value opening a position + OpenEst(ctx context.Context, in *QueryOpenEstRequest, opts ...grpc.CallOption) (*QueryOpenEstResponse, error) + // Get estimated amount of return value closing a position + CloseEst(ctx context.Context, in *QueryCloseEstRequest, opts ...grpc.CallOption) (*QueryCloseEstResponse, error) + // Queries rewards on leveragelp + Rewards(ctx context.Context, in *QueryRewardsRequest, opts ...grpc.CallOption) (*QueryRewardsResponse, error) } type queryClient struct { @@ -1201,6 +1588,33 @@ func (c *queryClient) Position(ctx context.Context, in *PositionRequest, opts .. return out, nil } +func (c *queryClient) OpenEst(ctx context.Context, in *QueryOpenEstRequest, opts ...grpc.CallOption) (*QueryOpenEstResponse, error) { + out := new(QueryOpenEstResponse) + err := c.cc.Invoke(ctx, "/elys.leveragelp.Query/OpenEst", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) CloseEst(ctx context.Context, in *QueryCloseEstRequest, opts ...grpc.CallOption) (*QueryCloseEstResponse, error) { + out := new(QueryCloseEstResponse) + err := c.cc.Invoke(ctx, "/elys.leveragelp.Query/CloseEst", 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.leveragelp.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. @@ -1222,6 +1636,12 @@ type QueryServer interface { Pools(context.Context, *QueryAllPoolRequest) (*QueryAllPoolResponse, error) // Queries a list of Position items. Position(context.Context, *PositionRequest) (*PositionResponse, error) + // Get estimated amount of return value opening a position + OpenEst(context.Context, *QueryOpenEstRequest) (*QueryOpenEstResponse, error) + // Get estimated amount of return value closing a position + CloseEst(context.Context, *QueryCloseEstRequest) (*QueryCloseEstResponse, error) + // Queries rewards on leveragelp + Rewards(context.Context, *QueryRewardsRequest) (*QueryRewardsResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -1258,6 +1678,15 @@ func (*UnimplementedQueryServer) Pools(ctx context.Context, req *QueryAllPoolReq func (*UnimplementedQueryServer) Position(ctx context.Context, req *PositionRequest) (*PositionResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Position not implemented") } +func (*UnimplementedQueryServer) OpenEst(ctx context.Context, req *QueryOpenEstRequest) (*QueryOpenEstResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method OpenEst not implemented") +} +func (*UnimplementedQueryServer) CloseEst(ctx context.Context, req *QueryCloseEstRequest) (*QueryCloseEstResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CloseEst 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) @@ -1443,41 +1872,95 @@ func _Query_Position_Handler(srv interface{}, ctx context.Context, dec func(inte return interceptor(ctx, in, info, handler) } -var _Query_serviceDesc = grpc.ServiceDesc{ - ServiceName: "elys.leveragelp.Query", - HandlerType: (*QueryServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Params", - Handler: _Query_Params_Handler, - }, - { - MethodName: "QueryPositions", - Handler: _Query_QueryPositions_Handler, - }, - { - MethodName: "QueryPositionsByPool", - Handler: _Query_QueryPositionsByPool_Handler, - }, - { - MethodName: "GetStatus", - Handler: _Query_GetStatus_Handler, - }, - { - MethodName: "QueryPositionsForAddress", - Handler: _Query_QueryPositionsForAddress_Handler, - }, - { - MethodName: "GetWhitelist", - Handler: _Query_GetWhitelist_Handler, - }, - { - MethodName: "IsWhitelisted", - Handler: _Query_IsWhitelisted_Handler, - }, - { - MethodName: "Pool", - Handler: _Query_Pool_Handler, +func _Query_OpenEst_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryOpenEstRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).OpenEst(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/elys.leveragelp.Query/OpenEst", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).OpenEst(ctx, req.(*QueryOpenEstRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_CloseEst_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryCloseEstRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).CloseEst(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/elys.leveragelp.Query/CloseEst", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).CloseEst(ctx, req.(*QueryCloseEstRequest)) + } + 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.leveragelp.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.leveragelp.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Params", + Handler: _Query_Params_Handler, + }, + { + MethodName: "QueryPositions", + Handler: _Query_QueryPositions_Handler, + }, + { + MethodName: "QueryPositionsByPool", + Handler: _Query_QueryPositionsByPool_Handler, + }, + { + MethodName: "GetStatus", + Handler: _Query_GetStatus_Handler, + }, + { + MethodName: "QueryPositionsForAddress", + Handler: _Query_QueryPositionsForAddress_Handler, + }, + { + MethodName: "GetWhitelist", + Handler: _Query_GetWhitelist_Handler, + }, + { + MethodName: "IsWhitelisted", + Handler: _Query_IsWhitelisted_Handler, + }, + { + MethodName: "Pool", + Handler: _Query_Pool_Handler, }, { MethodName: "Pools", @@ -1487,6 +1970,18 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "Position", Handler: _Query_Position_Handler, }, + { + MethodName: "OpenEst", + Handler: _Query_OpenEst_Handler, + }, + { + MethodName: "CloseEst", + Handler: _Query_CloseEst_Handler, + }, + { + MethodName: "Rewards", + Handler: _Query_Rewards_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "elys/leveragelp/query.proto", @@ -2232,138 +2727,390 @@ func (m *PositionResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { 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 *ParamsRequest) Size() (n int) { - if m == nil { - return 0 +func (m *QueryOpenEstRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } - var l int - _ = l - return n + return dAtA[:n], nil } -func (m *ParamsResponse) 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 *QueryOpenEstRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *PositionsRequest) Size() (n int) { - if m == nil { - return 0 - } +func (m *QueryOpenEstRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) + { + size := m.Leverage.Size() + i -= size + if _, err := m.Leverage.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintQuery(dAtA, i, uint64(size)) } - return n -} - -func (m *PositionsResponse) Size() (n int) { - if m == nil { - return 0 + i-- + dAtA[i] = 0x22 + if m.AmmPoolId != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.AmmPoolId)) + i-- + dAtA[i] = 0x18 } - var l int - _ = l - if len(m.Positions) > 0 { - for _, e := range m.Positions { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) + { + size := m.CollateralAmount.Size() + i -= size + if _, err := m.CollateralAmount.MarshalTo(dAtA[i:]); err != nil { + return 0, err } + i = encodeVarintQuery(dAtA, i, uint64(size)) } - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) + i-- + dAtA[i] = 0x12 + if len(m.CollateralAsset) > 0 { + i -= len(m.CollateralAsset) + copy(dAtA[i:], m.CollateralAsset) + i = encodeVarintQuery(dAtA, i, uint64(len(m.CollateralAsset))) + i-- + dAtA[i] = 0xa } - return n + return len(dAtA) - i, nil } -func (m *PositionsByPoolRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.AmmPoolId != 0 { - n += 1 + sovQuery(uint64(m.AmmPoolId)) - } - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) +func (m *QueryOpenEstResponse) 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 n + return dAtA[:n], nil } -func (m *PositionsByPoolResponse) Size() (n int) { - if m == nil { - return 0 - } +func (m *QueryOpenEstResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryOpenEstResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - if len(m.Positions) > 0 { - for _, e := range m.Positions { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) + { + size := m.BorrowFee.Size() + i -= size + if _, err := m.BorrowFee.MarshalTo(dAtA[i:]); err != nil { + return 0, err } + i = encodeVarintQuery(dAtA, i, uint64(size)) } - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) + i-- + dAtA[i] = 0x1a + { + size := m.WeightBalanceRatio.Size() + i -= size + if _, err := m.WeightBalanceRatio.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintQuery(dAtA, i, uint64(size)) } - return n + i-- + dAtA[i] = 0x12 + { + size := m.PositionSize.Size() + i -= size + if _, err := m.PositionSize.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 *StatusRequest) Size() (n int) { - if m == nil { - return 0 +func (m *QueryCloseEstRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } - var l int - _ = l - return n + return dAtA[:n], nil } -func (m *StatusResponse) Size() (n int) { - if m == nil { - return 0 - } +func (m *QueryCloseEstRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryCloseEstRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - if m.OpenPositionCount != 0 { - n += 1 + sovQuery(uint64(m.OpenPositionCount)) + { + size := m.LpAmount.Size() + i -= size + if _, err := m.LpAmount.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintQuery(dAtA, i, uint64(size)) } - if m.LifetimePositionCount != 0 { - n += 1 + sovQuery(uint64(m.LifetimePositionCount)) + i-- + dAtA[i] = 0x1a + if m.Id != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.Id)) + i-- + dAtA[i] = 0x10 } - return n + if len(m.Owner) > 0 { + i -= len(m.Owner) + copy(dAtA[i:], m.Owner) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Owner))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil } -func (m *PositionsForAddressRequest) Size() (n int) { - if m == 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.Ids) > 0 { + dAtA15 := make([]byte, len(m.Ids)*10) + var j14 int + for _, num := range m.Ids { + for num >= 1<<7 { + dAtA15[j14] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j14++ + } + dAtA15[j14] = uint8(num) + j14++ + } + i -= j14 + copy(dAtA[i:], dAtA15[:j14]) + i = encodeVarintQuery(dAtA, i, uint64(j14)) + i-- + dAtA[i] = 0x12 + } + 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 *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.PositionId != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.PositionId)) + i-- + dAtA[i] = 0x8 + } + 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.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 *QueryCloseEstResponse) 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 *QueryCloseEstResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryCloseEstResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.AmountReturned.Size() + i -= size + if _, err := m.AmountReturned.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + { + size := m.WeightBalanceRatio.Size() + i -= size + if _, err := m.WeightBalanceRatio.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + { + size := m.Liability.Size() + i -= size + if _, err := m.Liability.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + 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 *ParamsRequest) 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 *ParamsResponse) 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 *PositionsRequest) Size() (n int) { + if m == nil { + return 0 } + var l int + _ = l if m.Pagination != nil { l = m.Pagination.Size() n += 1 + l + sovQuery(uint64(l)) @@ -2371,7 +3118,7 @@ func (m *PositionsForAddressRequest) Size() (n int) { return n } -func (m *PositionsForAddressResponse) Size() (n int) { +func (m *PositionsResponse) Size() (n int) { if m == nil { return 0 } @@ -2390,12 +3137,15 @@ func (m *PositionsForAddressResponse) Size() (n int) { return n } -func (m *WhitelistRequest) Size() (n int) { +func (m *PositionsByPoolRequest) Size() (n int) { if m == nil { return 0 } var l int _ = l + if m.AmmPoolId != 0 { + n += 1 + sovQuery(uint64(m.AmmPoolId)) + } if m.Pagination != nil { l = m.Pagination.Size() n += 1 + l + sovQuery(uint64(l)) @@ -2403,15 +3153,15 @@ func (m *WhitelistRequest) Size() (n int) { return n } -func (m *WhitelistResponse) Size() (n int) { +func (m *PositionsByPoolResponse) Size() (n int) { if m == nil { return 0 } var l int _ = l - if len(m.Whitelist) > 0 { - for _, s := range m.Whitelist { - l = len(s) + if len(m.Positions) > 0 { + for _, e := range m.Positions { + l = e.Size() n += 1 + l + sovQuery(uint64(l)) } } @@ -2422,59 +3172,67 @@ func (m *WhitelistResponse) Size() (n int) { return n } -func (m *IsWhitelistedRequest) Size() (n int) { +func (m *StatusRequest) 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 *IsWhitelistedResponse) Size() (n int) { +func (m *StatusResponse) 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)) + if m.OpenPositionCount != 0 { + n += 1 + sovQuery(uint64(m.OpenPositionCount)) } - if m.IsWhitelisted { - n += 2 + if m.LifetimePositionCount != 0 { + n += 1 + sovQuery(uint64(m.LifetimePositionCount)) } return n } -func (m *QueryGetPoolRequest) Size() (n int) { +func (m *PositionsForAddressRequest) Size() (n int) { if m == nil { return 0 } var l int _ = l - if m.Index != 0 { - n += 1 + sovQuery(uint64(m.Index)) + l = len(m.Address) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) } return n } -func (m *QueryGetPoolResponse) Size() (n int) { +func (m *PositionsForAddressResponse) Size() (n int) { if m == nil { return 0 } var l int _ = l - l = m.Pool.Size() - n += 1 + l + sovQuery(uint64(l)) + if len(m.Positions) > 0 { + for _, e := range m.Positions { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } return n } -func (m *QueryAllPoolRequest) Size() (n int) { +func (m *WhitelistRequest) Size() (n int) { if m == nil { return 0 } @@ -2487,15 +3245,15 @@ func (m *QueryAllPoolRequest) Size() (n int) { return n } -func (m *QueryAllPoolResponse) Size() (n int) { +func (m *WhitelistResponse) 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() + if len(m.Whitelist) > 0 { + for _, s := range m.Whitelist { + l = len(s) n += 1 + l + sovQuery(uint64(l)) } } @@ -2506,7 +3264,7 @@ func (m *QueryAllPoolResponse) Size() (n int) { return n } -func (m *PositionRequest) Size() (n int) { +func (m *IsWhitelistedRequest) Size() (n int) { if m == nil { return 0 } @@ -2516,25 +3274,236 @@ func (m *PositionRequest) Size() (n int) { if l > 0 { n += 1 + l + sovQuery(uint64(l)) } - if m.Id != 0 { - n += 1 + sovQuery(uint64(m.Id)) - } return n } -func (m *PositionResponse) Size() (n int) { +func (m *IsWhitelistedResponse) Size() (n int) { if m == nil { return 0 } var l int _ = l - if m.Position != nil { + l = len(m.Address) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.IsWhitelisted { + n += 2 + } + return n +} + +func (m *QueryGetPoolRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Index != 0 { + n += 1 + sovQuery(uint64(m.Index)) + } + return n +} + +func (m *QueryGetPoolResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Pool.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryAllPoolRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryAllPoolResponse) 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)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *PositionRequest) 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)) + } + if m.Id != 0 { + n += 1 + sovQuery(uint64(m.Id)) + } + return n +} + +func (m *PositionResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Position != nil { l = m.Position.Size() n += 1 + l + sovQuery(uint64(l)) } return n } +func (m *QueryOpenEstRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.CollateralAsset) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = m.CollateralAmount.Size() + n += 1 + l + sovQuery(uint64(l)) + if m.AmmPoolId != 0 { + n += 1 + sovQuery(uint64(m.AmmPoolId)) + } + l = m.Leverage.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryOpenEstResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.PositionSize.Size() + n += 1 + l + sovQuery(uint64(l)) + l = m.WeightBalanceRatio.Size() + n += 1 + l + sovQuery(uint64(l)) + l = m.BorrowFee.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryCloseEstRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Owner) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.Id != 0 { + n += 1 + sovQuery(uint64(m.Id)) + } + l = m.LpAmount.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)) + } + if len(m.Ids) > 0 { + l = 0 + for _, e := range m.Ids { + l += sovQuery(uint64(e)) + } + n += 1 + sovQuery(uint64(l)) + l + } + return n +} + +func (m *RewardInfo) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PositionId != 0 { + n += 1 + sovQuery(uint64(m.PositionId)) + } + 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.TotalRewards) > 0 { + for _, e := range m.TotalRewards { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + +func (m *QueryCloseEstResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Liability.Size() + n += 1 + l + sovQuery(uint64(l)) + l = m.WeightBalanceRatio.Size() + n += 1 + l + sovQuery(uint64(l)) + l = m.AmountReturned.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -2601,28 +3570,832 @@ func (m *ParamsResponse) Unmarshal(dAtA []byte) error { if shift >= 64 { return ErrIntOverflowQuery } - if iNdEx >= l { + 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: ParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ParamsResponse: 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 *PositionsRequest) 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: PositionsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PositionsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *PositionsResponse) 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: PositionsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PositionsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Positions", 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.Positions = append(m.Positions, &Position{}) + if err := m.Positions[len(m.Positions)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *PositionsByPoolRequest) 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: PositionsByPoolRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PositionsByPoolRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field AmmPoolId", wireType) + } + m.AmmPoolId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.AmmPoolId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *PositionsByPoolResponse) 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: PositionsByPoolResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PositionsByPoolResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Positions", 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.Positions = append(m.Positions, &Position{}) + if err := m.Positions[len(m.Positions)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *StatusRequest) 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: StatusRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: StatusRequest: 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 *StatusResponse) 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: StatusResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: StatusResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field OpenPositionCount", wireType) + } + m.OpenPositionCount = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.OpenPositionCount |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field LifetimePositionCount", wireType) + } + m.LifetimePositionCount = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.LifetimePositionCount |= 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 *PositionsForAddressRequest) 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: PositionsForAddressRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PositionsForAddressRequest: 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 + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *PositionsForAddressResponse) 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: PositionsForAddressResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PositionsForAddressResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Positions", 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 } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break + m.Positions = append(m.Positions, &Position{}) + if err := m.Positions[len(m.Positions)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ParamsResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: + iNdEx = postIndex + case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -2649,7 +4422,10 @@ func (m *ParamsResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -2674,7 +4450,7 @@ func (m *ParamsResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *PositionsRequest) Unmarshal(dAtA []byte) error { +func (m *WhitelistRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2697,10 +4473,10 @@ func (m *PositionsRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: PositionsRequest: wiretype end group for non-group") + return fmt.Errorf("proto: WhitelistRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: PositionsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: WhitelistRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -2760,7 +4536,7 @@ func (m *PositionsRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *PositionsResponse) Unmarshal(dAtA []byte) error { +func (m *WhitelistResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2783,17 +4559,17 @@ func (m *PositionsResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: PositionsResponse: wiretype end group for non-group") + return fmt.Errorf("proto: WhitelistResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: PositionsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: WhitelistResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Positions", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Whitelist", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -2803,25 +4579,23 @@ func (m *PositionsResponse) 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 ErrInvalidLengthQuery } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthQuery } if postIndex > l { return io.ErrUnexpectedEOF } - m.Positions = append(m.Positions, &Position{}) - if err := m.Positions[len(m.Positions)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.Whitelist = append(m.Whitelist, string(dAtA[iNdEx:postIndex])) iNdEx = postIndex case 2: if wireType != 2 { @@ -2880,7 +4654,7 @@ func (m *PositionsResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *PositionsByPoolRequest) Unmarshal(dAtA []byte) error { +func (m *IsWhitelistedRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2903,36 +4677,17 @@ func (m *PositionsByPoolRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: PositionsByPoolRequest: wiretype end group for non-group") + return fmt.Errorf("proto: IsWhitelistedRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: PositionsByPoolRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: IsWhitelistedRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field AmmPoolId", wireType) - } - m.AmmPoolId = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.AmmPoolId |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -2942,27 +4697,23 @@ func (m *PositionsByPoolRequest) 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 ErrInvalidLengthQuery } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthQuery } if postIndex > l { return io.ErrUnexpectedEOF } - if m.Pagination == nil { - m.Pagination = &query.PageRequest{} - } - if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.Address = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex @@ -2985,7 +4736,7 @@ func (m *PositionsByPoolRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *PositionsByPoolResponse) Unmarshal(dAtA []byte) error { +func (m *IsWhitelistedResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3008,17 +4759,17 @@ func (m *PositionsByPoolResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: PositionsByPoolResponse: wiretype end group for non-group") + return fmt.Errorf("proto: IsWhitelistedResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: PositionsByPoolResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: IsWhitelistedResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Positions", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -3028,31 +4779,29 @@ func (m *PositionsByPoolResponse) 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 ErrInvalidLengthQuery } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthQuery } if postIndex > l { return io.ErrUnexpectedEOF } - m.Positions = append(m.Positions, &Position{}) - if err := m.Positions[len(m.Positions)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.Address = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IsWhitelisted", wireType) } - var msglen int + var v int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -3062,28 +4811,12 @@ func (m *PositionsByPoolResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + v |= int(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Pagination == nil { - m.Pagination = &query.PageResponse{} - } - if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex + m.IsWhitelisted = bool(v != 0) default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -3105,7 +4838,7 @@ func (m *PositionsByPoolResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *StatusRequest) Unmarshal(dAtA []byte) error { +func (m *QueryGetPoolRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3128,12 +4861,31 @@ func (m *StatusRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: StatusRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryGetPoolRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: StatusRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryGetPoolRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Index", wireType) + } + m.Index = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Index |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -3155,7 +4907,7 @@ func (m *StatusRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *StatusResponse) Unmarshal(dAtA []byte) error { +func (m *QueryGetPoolResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3178,17 +4930,17 @@ func (m *StatusResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: StatusResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryGetPoolResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: StatusResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryGetPoolResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field OpenPositionCount", wireType) + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pool", wireType) } - m.OpenPositionCount = 0 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -3198,16 +4950,80 @@ func (m *StatusResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.OpenPositionCount |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field LifetimePositionCount", wireType) + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Pool.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 *QueryAllPoolRequest) 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: QueryAllPoolRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryAllPoolRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) } - m.LifetimePositionCount = 0 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -3217,11 +5033,28 @@ func (m *StatusResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.LifetimePositionCount |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -3243,7 +5076,7 @@ func (m *StatusResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *PositionsForAddressRequest) Unmarshal(dAtA []byte) error { +func (m *QueryAllPoolResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3266,17 +5099,17 @@ func (m *PositionsForAddressRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: PositionsForAddressRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryAllPoolResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: PositionsForAddressRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryAllPoolResponse: 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) + return fmt.Errorf("proto: wrong wireType = %d for field Pool", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -3286,23 +5119,25 @@ func (m *PositionsForAddressRequest) 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 } - m.Address = string(dAtA[iNdEx:postIndex]) + m.Pool = append(m.Pool, Pool{}) + if err := m.Pool[len(m.Pool)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex case 2: if wireType != 2 { @@ -3334,7 +5169,7 @@ func (m *PositionsForAddressRequest) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.Pagination == nil { - m.Pagination = &query.PageRequest{} + m.Pagination = &query.PageResponse{} } if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -3361,7 +5196,7 @@ func (m *PositionsForAddressRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *PositionsForAddressResponse) Unmarshal(dAtA []byte) error { +func (m *PositionRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3384,17 +5219,17 @@ func (m *PositionsForAddressResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: PositionsForAddressResponse: wiretype end group for non-group") + return fmt.Errorf("proto: PositionRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: PositionsForAddressResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: PositionRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Positions", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -3404,31 +5239,29 @@ func (m *PositionsForAddressResponse) 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 ErrInvalidLengthQuery } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthQuery } if postIndex > l { return io.ErrUnexpectedEOF } - m.Positions = append(m.Positions, &Position{}) - if err := m.Positions[len(m.Positions)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.Address = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) } - var msglen int + m.Id = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -3438,28 +5271,11 @@ func (m *PositionsForAddressResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + m.Id |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Pagination == nil { - m.Pagination = &query.PageResponse{} - } - if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -3481,7 +5297,7 @@ func (m *PositionsForAddressResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *WhitelistRequest) Unmarshal(dAtA []byte) error { +func (m *PositionResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3504,15 +5320,15 @@ func (m *WhitelistRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: WhitelistRequest: wiretype end group for non-group") + return fmt.Errorf("proto: PositionResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: WhitelistRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: PositionResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Position", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -3539,10 +5355,10 @@ func (m *WhitelistRequest) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.Pagination == nil { - m.Pagination = &query.PageRequest{} + if m.Position == nil { + m.Position = &Position{} } - if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.Position.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -3567,7 +5383,7 @@ func (m *WhitelistRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *WhitelistResponse) Unmarshal(dAtA []byte) error { +func (m *QueryOpenEstRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3590,15 +5406,15 @@ func (m *WhitelistResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: WhitelistResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryOpenEstRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: WhitelistResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryOpenEstRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Whitelist", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field CollateralAsset", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -3626,13 +5442,13 @@ func (m *WhitelistResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Whitelist = append(m.Whitelist, string(dAtA[iNdEx:postIndex])) + m.CollateralAsset = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field CollateralAmount", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -3642,25 +5458,76 @@ func (m *WhitelistResponse) 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 ErrInvalidLengthQuery } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthQuery } if postIndex > l { return io.ErrUnexpectedEOF } - if m.Pagination == nil { - m.Pagination = &query.PageResponse{} + if err := m.CollateralAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err } - if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field AmmPoolId", wireType) + } + m.AmmPoolId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.AmmPoolId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Leverage", 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.Leverage.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -3685,7 +5552,7 @@ func (m *WhitelistResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *IsWhitelistedRequest) Unmarshal(dAtA []byte) error { +func (m *QueryOpenEstResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3695,28 +5562,96 @@ func (m *IsWhitelistedRequest) Unmarshal(dAtA []byte) error { if shift >= 64 { return ErrIntOverflowQuery } - if iNdEx >= l { + 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: QueryOpenEstResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryOpenEstResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PositionSize", 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.PositionSize.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field WeightBalanceRatio", 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 } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break + if err := m.WeightBalanceRatio.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: IsWhitelistedRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: IsWhitelistedRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: + iNdEx = postIndex + case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field BorrowFee", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -3744,7 +5679,9 @@ func (m *IsWhitelistedRequest) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Address = string(dAtA[iNdEx:postIndex]) + if err := m.BorrowFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex default: iNdEx = preIndex @@ -3767,7 +5704,7 @@ func (m *IsWhitelistedRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *IsWhitelistedResponse) Unmarshal(dAtA []byte) error { +func (m *QueryCloseEstRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3790,15 +5727,15 @@ func (m *IsWhitelistedResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: IsWhitelistedResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryCloseEstRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: IsWhitelistedResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryCloseEstRequest: 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) + return fmt.Errorf("proto: wrong wireType = %d for field Owner", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -3826,13 +5763,13 @@ func (m *IsWhitelistedResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Address = string(dAtA[iNdEx:postIndex]) + m.Owner = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field IsWhitelisted", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) } - var v int + m.Id = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -3842,67 +5779,16 @@ func (m *IsWhitelistedResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - v |= int(b&0x7F) << shift + m.Id |= uint64(b&0x7F) << shift if b < 0x80 { break } } - m.IsWhitelisted = bool(v != 0) - 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 *QueryGetPoolRequest) 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: QueryGetPoolRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryGetPoolRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Index", wireType) + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field LpAmount", wireType) } - m.Index = 0 + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -3912,11 +5798,26 @@ func (m *QueryGetPoolRequest) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Index |= uint64(b&0x7F) << shift + 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.LpAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -3938,7 +5839,7 @@ func (m *QueryGetPoolRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryGetPoolResponse) Unmarshal(dAtA []byte) error { +func (m *QueryRewardsRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3961,17 +5862,17 @@ func (m *QueryGetPoolResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryGetPoolResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryRewardsRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryGetPoolResponse: illegal tag %d (wire type %d)", fieldNum, wire) + 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 Pool", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -3981,25 +5882,100 @@ func (m *QueryGetPoolResponse) 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 ErrInvalidLengthQuery } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthQuery } if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.Pool.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.Address = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 2: + 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.Ids = append(m.Ids, 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.Ids) == 0 { + m.Ids = 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.Ids = append(m.Ids, v) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field Ids", wireType) + } default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -4021,7 +5997,7 @@ func (m *QueryGetPoolResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryAllPoolRequest) Unmarshal(dAtA []byte) error { +func (m *RewardInfo) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -4044,15 +6020,34 @@ func (m *QueryAllPoolRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryAllPoolRequest: wiretype end group for non-group") + return fmt.Errorf("proto: RewardInfo: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryAllPoolRequest: illegal tag %d (wire type %d)", fieldNum, wire) + 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 PositionId", wireType) + } + m.PositionId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PositionId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Reward", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -4079,10 +6074,8 @@ func (m *QueryAllPoolRequest) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.Pagination == nil { - m.Pagination = &query.PageRequest{} - } - if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + 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 @@ -4107,7 +6100,7 @@ func (m *QueryAllPoolRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryAllPoolResponse) Unmarshal(dAtA []byte) error { +func (m *QueryRewardsResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -4130,15 +6123,15 @@ func (m *QueryAllPoolResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryAllPoolResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryRewardsResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryAllPoolResponse: illegal tag %d (wire type %d)", fieldNum, wire) + 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 Pool", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Rewards", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -4165,14 +6158,14 @@ func (m *QueryAllPoolResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Pool = append(m.Pool, Pool{}) - if err := m.Pool[len(m.Pool)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + 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 Pagination", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field TotalRewards", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -4199,10 +6192,8 @@ func (m *QueryAllPoolResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.Pagination == nil { - m.Pagination = &query.PageResponse{} - } - if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + 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 @@ -4227,7 +6218,7 @@ func (m *QueryAllPoolResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *PositionRequest) Unmarshal(dAtA []byte) error { +func (m *QueryCloseEstResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -4250,15 +6241,15 @@ func (m *PositionRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: PositionRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryCloseEstResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: PositionRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryCloseEstResponse: 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) + return fmt.Errorf("proto: wrong wireType = %d for field Liability", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -4286,13 +6277,15 @@ func (m *PositionRequest) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Address = string(dAtA[iNdEx:postIndex]) + if err := m.Liability.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field WeightBalanceRatio", wireType) } - m.Id = 0 + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -4302,66 +6295,31 @@ func (m *PositionRequest) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Id |= uint64(b&0x7F) << shift + stringLen |= 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 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthQuery } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *PositionResponse) 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 + intStringLen + 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 + if err := m.WeightBalanceRatio.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: PositionResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: PositionResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: + iNdEx = postIndex + case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Position", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field AmountReturned", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -4371,25 +6329,23 @@ func (m *PositionResponse) 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 ErrInvalidLengthQuery } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthQuery } if postIndex > l { return io.ErrUnexpectedEOF } - if m.Position == nil { - m.Position = &Position{} - } - if err := m.Position.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.AmountReturned.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex diff --git a/x/leveragelp/types/query.pb.gw.go b/x/leveragelp/types/query.pb.gw.go index a49fd079a..b52d3898a 100644 --- a/x/leveragelp/types/query.pb.gw.go +++ b/x/leveragelp/types/query.pb.gw.go @@ -639,6 +639,150 @@ func local_request_Query_Position_0(ctx context.Context, marshaler runtime.Marsh } +var ( + filter_Query_OpenEst_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Query_OpenEst_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryOpenEstRequest + 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_OpenEst_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.OpenEst(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_OpenEst_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryOpenEstRequest + 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_OpenEst_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.OpenEst(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_CloseEst_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Query_CloseEst_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryCloseEstRequest + 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_CloseEst_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.CloseEst(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_CloseEst_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryCloseEstRequest + 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_CloseEst_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.CloseEst(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_Rewards_0 = &utilities.DoubleArray{Encoding: map[string]int{"address": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} +) + +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) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Rewards_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", 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) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Rewards_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", 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. @@ -875,6 +1019,66 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_OpenEst_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_OpenEst_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_OpenEst_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_CloseEst_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_CloseEst_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_CloseEst_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 } @@ -1116,6 +1320,66 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_OpenEst_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_OpenEst_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_OpenEst_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_CloseEst_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_CloseEst_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_CloseEst_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 } @@ -1139,6 +1403,12 @@ var ( pattern_Query_Pools_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", "leveragelp", "pool", "pagination.key"}, "", runtime.AssumeColonVerbOpt(true))) pattern_Query_Position_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", "leveragelp", "position", "address", "id"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_OpenEst_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"elys-network", "elys", "leveragelp", "open_estimation"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_CloseEst_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"elys-network", "elys", "leveragelp", "close_estimation"}, "", 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", "leveragelp", "rewards", "address"}, "", runtime.AssumeColonVerbOpt(true))) ) var ( @@ -1161,4 +1431,10 @@ var ( forward_Query_Pools_0 = runtime.ForwardResponseMessage forward_Query_Position_0 = runtime.ForwardResponseMessage + + forward_Query_OpenEst_0 = runtime.ForwardResponseMessage + + forward_Query_CloseEst_0 = runtime.ForwardResponseMessage + + forward_Query_Rewards_0 = runtime.ForwardResponseMessage ) diff --git a/x/leveragelp/types/tx.pb.go b/x/leveragelp/types/tx.pb.go index 7d2097138..dd79e22f6 100644 --- a/x/leveragelp/types/tx.pb.go +++ b/x/leveragelp/types/tx.pb.go @@ -217,6 +217,94 @@ func (m *MsgCloseResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgCloseResponse proto.InternalMessageInfo +type MsgClaimRewards struct { + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + Ids []uint64 `protobuf:"varint,2,rep,packed,name=ids,proto3" json:"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_307315ea7a77a411, []int{4} +} +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) GetIds() []uint64 { + if m != nil { + return m.Ids + } + 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_307315ea7a77a411, []int{5} +} +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 + type MsgUpdateParams struct { // authority is the address that controls the module (defaults to x/gov unless // overwritten). @@ -229,7 +317,7 @@ 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_307315ea7a77a411, []int{4} + return fileDescriptor_307315ea7a77a411, []int{6} } func (m *MsgUpdateParams) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -279,7 +367,7 @@ 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_307315ea7a77a411, []int{5} + return fileDescriptor_307315ea7a77a411, []int{7} } func (m *MsgUpdateParamsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -317,7 +405,7 @@ func (m *MsgUpdatePools) Reset() { *m = MsgUpdatePools{} } func (m *MsgUpdatePools) String() string { return proto.CompactTextString(m) } func (*MsgUpdatePools) ProtoMessage() {} func (*MsgUpdatePools) Descriptor() ([]byte, []int) { - return fileDescriptor_307315ea7a77a411, []int{6} + return fileDescriptor_307315ea7a77a411, []int{8} } func (m *MsgUpdatePools) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -367,7 +455,7 @@ func (m *MsgUpdatePoolsResponse) Reset() { *m = MsgUpdatePoolsResponse{} func (m *MsgUpdatePoolsResponse) String() string { return proto.CompactTextString(m) } func (*MsgUpdatePoolsResponse) ProtoMessage() {} func (*MsgUpdatePoolsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_307315ea7a77a411, []int{7} + return fileDescriptor_307315ea7a77a411, []int{9} } func (m *MsgUpdatePoolsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -405,7 +493,7 @@ func (m *MsgWhitelist) Reset() { *m = MsgWhitelist{} } func (m *MsgWhitelist) String() string { return proto.CompactTextString(m) } func (*MsgWhitelist) ProtoMessage() {} func (*MsgWhitelist) Descriptor() ([]byte, []int) { - return fileDescriptor_307315ea7a77a411, []int{8} + return fileDescriptor_307315ea7a77a411, []int{10} } func (m *MsgWhitelist) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -455,7 +543,7 @@ func (m *MsgWhitelistResponse) Reset() { *m = MsgWhitelistResponse{} } func (m *MsgWhitelistResponse) String() string { return proto.CompactTextString(m) } func (*MsgWhitelistResponse) ProtoMessage() {} func (*MsgWhitelistResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_307315ea7a77a411, []int{9} + return fileDescriptor_307315ea7a77a411, []int{11} } func (m *MsgWhitelistResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -493,7 +581,7 @@ func (m *MsgDewhitelist) Reset() { *m = MsgDewhitelist{} } func (m *MsgDewhitelist) String() string { return proto.CompactTextString(m) } func (*MsgDewhitelist) ProtoMessage() {} func (*MsgDewhitelist) Descriptor() ([]byte, []int) { - return fileDescriptor_307315ea7a77a411, []int{10} + return fileDescriptor_307315ea7a77a411, []int{12} } func (m *MsgDewhitelist) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -543,7 +631,7 @@ func (m *MsgDewhitelistResponse) Reset() { *m = MsgDewhitelistResponse{} func (m *MsgDewhitelistResponse) String() string { return proto.CompactTextString(m) } func (*MsgDewhitelistResponse) ProtoMessage() {} func (*MsgDewhitelistResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_307315ea7a77a411, []int{11} + return fileDescriptor_307315ea7a77a411, []int{13} } func (m *MsgDewhitelistResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -582,7 +670,7 @@ func (m *MsgUpdateStopLoss) Reset() { *m = MsgUpdateStopLoss{} } func (m *MsgUpdateStopLoss) String() string { return proto.CompactTextString(m) } func (*MsgUpdateStopLoss) ProtoMessage() {} func (*MsgUpdateStopLoss) Descriptor() ([]byte, []int) { - return fileDescriptor_307315ea7a77a411, []int{12} + return fileDescriptor_307315ea7a77a411, []int{14} } func (m *MsgUpdateStopLoss) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -632,7 +720,7 @@ func (m *MsgUpdateStopLossResponse) Reset() { *m = MsgUpdateStopLossResp func (m *MsgUpdateStopLossResponse) String() string { return proto.CompactTextString(m) } func (*MsgUpdateStopLossResponse) ProtoMessage() {} func (*MsgUpdateStopLossResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_307315ea7a77a411, []int{13} + return fileDescriptor_307315ea7a77a411, []int{15} } func (m *MsgUpdateStopLossResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -666,6 +754,8 @@ func init() { proto.RegisterType((*MsgOpenResponse)(nil), "elys.leveragelp.MsgOpenResponse") proto.RegisterType((*MsgClose)(nil), "elys.leveragelp.MsgClose") proto.RegisterType((*MsgCloseResponse)(nil), "elys.leveragelp.MsgCloseResponse") + proto.RegisterType((*MsgClaimRewards)(nil), "elys.leveragelp.MsgClaimRewards") + proto.RegisterType((*MsgClaimRewardsResponse)(nil), "elys.leveragelp.MsgClaimRewardsResponse") proto.RegisterType((*MsgUpdateParams)(nil), "elys.leveragelp.MsgUpdateParams") proto.RegisterType((*MsgUpdateParamsResponse)(nil), "elys.leveragelp.MsgUpdateParamsResponse") proto.RegisterType((*MsgUpdatePools)(nil), "elys.leveragelp.MsgUpdatePools") @@ -681,52 +771,55 @@ func init() { func init() { proto.RegisterFile("elys/leveragelp/tx.proto", fileDescriptor_307315ea7a77a411) } var fileDescriptor_307315ea7a77a411 = []byte{ - // 713 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x55, 0x5f, 0x4f, 0xd3, 0x5e, - 0x18, 0x5e, 0xf7, 0x07, 0xb6, 0x77, 0xfc, 0x18, 0x9c, 0x1f, 0x42, 0x29, 0x38, 0xb0, 0x89, 0x3a, - 0x4d, 0x58, 0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xa3, 0x32, 0xd4, 0x38, 0xcb, 0x50, 0x1a, 0xe3, 0x18, 0xa9, 0xf6, - 0x0e, 0x54, 0xb3, 0x93, 0xb0, 0x32, 0xe2, 0x60, 0x40, 0x50, 0x1e, 0x8e, 0x21, 0xa4, 0xc2, 0x6f, - 0xa0, 0xd2, 0xeb, 0xf2, 0xbb, 0xc3, 0x4e, 0xa5, 0xb0, 0x72, 0x7f, 0x24, 0x9c, 0xcd, 0x9a, 0xed, - 0xe0, 0xa1, 0x59, 0x33, 0x84, 0xe1, 0x59, 0x87, 0xb4, 0x28, 0xd9, 0x83, 0xe9, 0xbe, 0xf6, 0x54, - 0x6f, 0xbe, 0x66, 0xc2, 0x51, 0x1e, 0x8f, 0xe7, 0x24, 0x0e, 0xad, 0xad, 0xb3, 0xcb, 0xba, 0x74, - 0x7e, 0x59, 0x97, 0x7e, 0x5e, 0xd6, 0xa5, 0xaf, 0x57, 0xf5, 0xdc, 0xf9, 0x55, 0x3d, 0xf7, 0xfd, - 0xaa, 0x9e, 0xdb, 0xd5, 0x32, 0xbd, 0x1b, 0xe8, 0xad, 0x75, 0xa9, 0x38, 0x46, 0xff, 0x30, 0x5c, - 0x68, 0x27, 0x03, 0x9f, 0xde, 0xfd, 0x89, 0xf0, 0xfb, 0xfa, 0xf4, 0x77, 0x00, 0x00, 0x00, 0xff, - 0xff, 0x59, 0xf0, 0xe2, 0x9f, 0xf9, 0x07, 0x00, 0x00, + // 766 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x56, 0xdf, 0x4e, 0x13, 0x4f, + 0x18, 0xed, 0xf6, 0x1f, 0xed, 0x57, 0x7e, 0x14, 0xe6, 0x87, 0xb0, 0x2c, 0x58, 0xea, 0x26, 0x6a, + 0x35, 0xa1, 0x8d, 0x78, 0xe9, 0x15, 0x05, 0x2f, 0x50, 0x1b, 0x71, 0x8d, 0x92, 0x60, 0x4c,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e4, 0x75, 0x87, 0xe1, 0x55, 0xea, 0x37, 0x21, 0x91, 0x16, 0x7a, 0x0e, 0x85, 0x20, + 0xd2, 0x4b, 0x69, 0x54, 0x1f, 0x52, 0xee, 0xdd, 0x08, 0xc5, 0x32, 0x7b, 0x30, 0x7d, 0x2d, 0x82, + 0xf5, 0xf4, 0x92, 0x01, 0x43, 0x69, 0x4c, 0x62, 0x24, 0xb5, 0xaf, 0xc5, 0x30, 0x55, 0x3b, 0xc9, + 0x48, 0xd7, 0x4e, 0x0b, 0x1a, 0xda, 0x85, 0x4a, 0x32, 0x65, 0xab, 0x63, 0x0a, 0x3d, 0x82, 0xf2, + 0x70, 0x02, 0x21, 0x16, 0x7e, 0x03, 0xe5, 0x41, 0x82, 0xee, 0xa6, 0x55, 0xc5, 0xb0, 0x72, 0x7f, + 0x2c, 0x9c, 0xec, 0x35, 0x99, 0x8e, 0xd4, 0x5e, 0x13, 0x84, 0xf4, 0x5e, 0x53, 0xae, 0x3f, 0xda, + 0x87, 0x99, 0xa1, 0xab, 0xaf, 0xde, 0x3c, 0x66, 0xc4, 0x51, 0x1e, 0x4f, 0xe6, 0x44, 0x0e, 0xed, + 0xed, 0xb3, 0xcb, 0x9a, 0x74, 0x7e, 0x59, 0x93, 0x7e, 0x5e, 0xd6, 0xa4, 0xaf, 0x57, 0xb5, 0xcc, + 0xf9, 0x55, 0x2d, 0xf3, 0xfd, 0xaa, 0x96, 0xd9, 0x6b, 0x25, 0x72, 0xe1, 0xe9, 0xad, 0xd9, 0x44, + 0xf4, 0x99, 0x7b, 0xe4, 0x2f, 0x5a, 0x27, 0x23, 0x9f, 0x0b, 0x07, 0x45, 0xff, 0x9b, 0xe0, 0xe9, + 0xef, 0x00, 0x00, 0x00, 0xff, 0xff, 0xf2, 0x05, 0x5a, 0xff, 0xad, 0x08, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -743,6 +836,7 @@ const _ = grpc.SupportPackageIsVersion4 type MsgClient interface { Open(ctx context.Context, in *MsgOpen, opts ...grpc.CallOption) (*MsgOpenResponse, error) Close(ctx context.Context, in *MsgClose, opts ...grpc.CallOption) (*MsgCloseResponse, error) + ClaimRewards(ctx context.Context, in *MsgClaimRewards, opts ...grpc.CallOption) (*MsgClaimRewardsResponse, error) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) UpdatePools(ctx context.Context, in *MsgUpdatePools, opts ...grpc.CallOption) (*MsgUpdatePoolsResponse, error) Whitelist(ctx context.Context, in *MsgWhitelist, opts ...grpc.CallOption) (*MsgWhitelistResponse, error) @@ -776,6 +870,15 @@ func (c *msgClient) Close(ctx context.Context, in *MsgClose, opts ...grpc.CallOp 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.leveragelp.Msg/ClaimRewards", 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.leveragelp.Msg/UpdateParams", in, out, opts...) @@ -825,6 +928,7 @@ func (c *msgClient) UpdateStopLoss(ctx context.Context, in *MsgUpdateStopLoss, o type MsgServer interface { Open(context.Context, *MsgOpen) (*MsgOpenResponse, error) Close(context.Context, *MsgClose) (*MsgCloseResponse, error) + ClaimRewards(context.Context, *MsgClaimRewards) (*MsgClaimRewardsResponse, error) UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) UpdatePools(context.Context, *MsgUpdatePools) (*MsgUpdatePoolsResponse, error) Whitelist(context.Context, *MsgWhitelist) (*MsgWhitelistResponse, error) @@ -842,6 +946,9 @@ func (*UnimplementedMsgServer) Open(ctx context.Context, req *MsgOpen) (*MsgOpen func (*UnimplementedMsgServer) Close(ctx context.Context, req *MsgClose) (*MsgCloseResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Close not implemented") } +func (*UnimplementedMsgServer) ClaimRewards(ctx context.Context, req *MsgClaimRewards) (*MsgClaimRewardsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ClaimRewards not implemented") +} func (*UnimplementedMsgServer) UpdateParams(ctx context.Context, req *MsgUpdateParams) (*MsgUpdateParamsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method UpdateParams not implemented") } @@ -898,6 +1005,24 @@ func _Msg_Close_Handler(srv interface{}, ctx context.Context, dec func(interface 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.leveragelp.Msg/ClaimRewards", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).ClaimRewards(ctx, req.(*MsgClaimRewards)) + } + 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 { @@ -1000,6 +1125,10 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "Close", Handler: _Msg_Close_Handler, }, + { + MethodName: "ClaimRewards", + Handler: _Msg_ClaimRewards_Handler, + }, { MethodName: "UpdateParams", Handler: _Msg_UpdateParams_Handler, @@ -1188,6 +1317,77 @@ func (m *MsgCloseResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { 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.Ids) > 0 { + dAtA2 := make([]byte, len(m.Ids)*10) + var j1 int + for _, num := range m.Ids { + for num >= 1<<7 { + dAtA2[j1] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j1++ + } + dAtA2[j1] = uint8(num) + j1++ + } + i -= j1 + copy(dAtA[i:], dAtA2[:j1]) + i = encodeVarintTx(dAtA, i, uint64(j1)) + 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 (m *MsgUpdateParams) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1581,6 +1781,35 @@ func (m *MsgCloseResponse) Size() (n int) { 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.Ids) > 0 { + l = 0 + for _, e := range m.Ids { + 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 (m *MsgUpdateParams) Size() (n int) { if m == nil { return 0 @@ -2190,6 +2419,214 @@ func (m *MsgCloseResponse) Unmarshal(dAtA []byte) error { } 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.Ids = append(m.Ids, 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.Ids) == 0 { + m.Ids = 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.Ids = append(m.Ids, v) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field Ids", 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 (m *MsgUpdateParams) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/x/leveragelp/types/types.pb.go b/x/leveragelp/types/types.pb.go index 20e334e2d..ce9d42a26 100644 --- a/x/leveragelp/types/types.pb.go +++ b/x/leveragelp/types/types.pb.go @@ -99,22 +99,23 @@ func (m *Position) GetAmmPoolId() uint64 { return 0 } -type WhiteList struct { - ValidatorList []string `protobuf:"bytes,1,rep,name=validator_list,json=validatorList,proto3" json:"validator_list,omitempty"` +type AddressId struct { + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + Id uint64 `protobuf:"varint,2,opt,name=id,proto3" json:"id,omitempty"` } -func (m *WhiteList) Reset() { *m = WhiteList{} } -func (m *WhiteList) String() string { return proto.CompactTextString(m) } -func (*WhiteList) ProtoMessage() {} -func (*WhiteList) Descriptor() ([]byte, []int) { +func (m *AddressId) Reset() { *m = AddressId{} } +func (m *AddressId) String() string { return proto.CompactTextString(m) } +func (*AddressId) ProtoMessage() {} +func (*AddressId) Descriptor() ([]byte, []int) { return fileDescriptor_992d513dd201f55b, []int{1} } -func (m *WhiteList) XXX_Unmarshal(b []byte) error { +func (m *AddressId) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *WhiteList) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *AddressId) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_WhiteList.Marshal(b, m, deterministic) + return xxx_messageInfo_AddressId.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -124,64 +125,70 @@ func (m *WhiteList) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { return b[:n], nil } } -func (m *WhiteList) XXX_Merge(src proto.Message) { - xxx_messageInfo_WhiteList.Merge(m, src) +func (m *AddressId) XXX_Merge(src proto.Message) { + xxx_messageInfo_AddressId.Merge(m, src) } -func (m *WhiteList) XXX_Size() int { +func (m *AddressId) XXX_Size() int { return m.Size() } -func (m *WhiteList) XXX_DiscardUnknown() { - xxx_messageInfo_WhiteList.DiscardUnknown(m) +func (m *AddressId) XXX_DiscardUnknown() { + xxx_messageInfo_AddressId.DiscardUnknown(m) } -var xxx_messageInfo_WhiteList proto.InternalMessageInfo +var xxx_messageInfo_AddressId proto.InternalMessageInfo -func (m *WhiteList) GetValidatorList() []string { +func (m *AddressId) GetAddress() string { if m != nil { - return m.ValidatorList + return m.Address } - return nil + return "" +} + +func (m *AddressId) GetId() uint64 { + if m != nil { + return m.Id + } + return 0 } func init() { proto.RegisterType((*Position)(nil), "elys.leveragelp.Position") - proto.RegisterType((*WhiteList)(nil), "elys.leveragelp.WhiteList") + proto.RegisterType((*AddressId)(nil), "elys.leveragelp.AddressId") } func init() { proto.RegisterFile("elys/leveragelp/types.proto", fileDescriptor_992d513dd201f55b) } var fileDescriptor_992d513dd201f55b = []byte{ - // 470 bytes of a gzipped FileDescriptorProto + // 454 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x93, 0x41, 0x6f, 0xd3, 0x30, - 0x14, 0xc7, 0x9b, 0xae, 0xdb, 0x5a, 0x97, 0xb6, 0xc2, 0x70, 0x30, 0x43, 0xca, 0xaa, 0x49, 0xa0, - 0x5e, 0x96, 0x68, 0xe3, 0x03, 0x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 0xce, 0xc0, 0xce, - 0x6f, 0xd2, 0x20, 0xc3, 0x3c, 0xdc, 0xf8, 0x5d, 0x7f, 0xce, 0x8d, 0xb8, 0xde, 0x9c, 0x7a, 0x52, - 0xd8, 0x78, 0x17, 0x41, 0x3f, 0x92, 0x1e, 0x14, 0x56, 0x96, 0xd2, 0xd8, 0x44, 0x73, 0x10, 0xac, - 0xb5, 0x17, 0xf3, 0x51, 0x0d, 0x89, 0x38, 0x08, 0xfa, 0x81, 0xb4, 0xeb, 0x2b, 0x65, 0x87, 0xff, - 0xcd, 0x7b, 0x27, 0xb3, 0x78, 0xbb, 0x4f, 0xbf, 0x90, 0x27, 0x75, 0x2d, 0x12, 0xa5, 0x13, 0x9e, - 0xe3, 0x4d, 0x61, 0xd9, 0xd1, 0x5e, 0x36, 0x1f, 0x6f, 0x51, 0x53, 0xfd, 0xa6, 0x02, 0xd1, 0x2b, - 0x32, 0xd0, 0x9b, 0x97, 0x4b, 0xe6, 0x92, 0x2b, 0x3b, 0x67, 0xc7, 0x7b, 0x59, 0xee, 0xd7, 0x98, - 0xf7, 0x15, 0x85, 0xf6, 0x49, 0x13, 0x04, 0x6b, 0x0f, 0xbd, 0x51, 0x2b, 0x6e, 0x82, 0xa0, 0x3e, - 0xe9, 0xf2, 0x3c, 0x4f, 0x34, 0xa2, 0x4a, 0x40, 0xb0, 0x4e, 0x25, 0x74, 0x78, 0x9e, 0x47, 0x88, - 0x6a, 0x22, 0xe8, 0x27, 0x32, 0x30, 0x16, 0x75, 0xa2, 0xd0, 0x98, 0x44, 0x97, 0x90, 0x49, 0x46, - 0xf6, 0x32, 0xd2, 0x73, 0x98, 0x29, 0x1a, 0x13, 0x39, 0xc8, 0xd9, 0x25, 0xe9, 0x5c, 0xcd, 0xc1, - 0xca, 0x29, 0x18, 0x4b, 0x5f, 0x90, 0xfe, 0x82, 0x2b, 0x10, 0xdc, 0x62, 0x99, 0x28, 0x30, 0x96, - 0x79, 0xc3, 0x83, 0x51, 0x27, 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, 0x5a, 0x59, 0x3e, 0x68, 0x30, + 0xef, 0x2a, 0x0a, 0x3d, 0x20, 0x5d, 0x2d, 0x59, 0x7f, 0xec, 0x4d, 0x7a, 0x51, 0x57, 0x4b, 0xea, + 0x93, 0xa1, 0xc8, 0xb2, 0xd8, 0x02, 0x98, 0x58, 0x4b, 0x36, 0xa8, 0x84, 0x81, 0xc8, 0xb2, 0x10, + 0xc0, 0xcc, 0x24, 0xfd, 0x48, 0x46, 0xe8, 0xc0, 0xc6, 0x06, 0x10, 0x63, 0x5b, 0xe8, 0x54, 0x31, + 0xd2, 0xca, 0xc8, 0x7e, 0x89, 0x39, 0x07, 0xc4, 0xb0, 0x84, 0x1c, 0xbf, 0x22, 0x83, 0xb3, 0x7a, + 0xfe, 0x66, 0xf2, 0x3f, 0xb3, 0x59, 0xdb, 0xed, 0x36, 0x76, 0xa7, 0xb3, 0x9b, 0xa5, 0xef, 0xdd, + 0x2e, 0x7d, 0xef, 0xf7, 0xd2, 0xf7, 0xbe, 0xaf, 0xfc, 0xce, 0xed, 0xca, 0xef, 0xfc, 0x5c, 0xf9, + 0x9d, 0xcf, 0x7c, 0xcb, 0x47, 0xb9, 0x3e, 0x27, 0xb9, 0x72, 0x5f, 0xa1, 0xb8, 0xa8, 0x12, 0xfe, + 0xed, 0x9f, 0x55, 0x4b, 0x76, 0xab, 0x25, 0x79, 0xf9, 0x27, 0x00, 0x00, 0xff, 0xff, 0x5e, 0xe3, + 0xb7, 0x4d, 0x8a, 0x03, 0x00, 0x00, } func (m *Position) Marshal() (dAtA []byte, err error) { @@ -294,7 +301,7 @@ func (m *Position) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *WhiteList) Marshal() (dAtA []byte, err error) { +func (m *AddressId) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -304,24 +311,27 @@ func (m *WhiteList) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *WhiteList) MarshalTo(dAtA []byte) (int, error) { +func (m *AddressId) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *WhiteList) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *AddressId) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.ValidatorList) > 0 { - for iNdEx := len(m.ValidatorList) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.ValidatorList[iNdEx]) - copy(dAtA[i:], m.ValidatorList[iNdEx]) - i = encodeVarintTypes(dAtA, i, uint64(len(m.ValidatorList[iNdEx]))) - i-- - dAtA[i] = 0xa - } + if m.Id != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.Id)) + i-- + dAtA[i] = 0x10 + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa } return len(dAtA) - i, nil } @@ -370,17 +380,18 @@ func (m *Position) Size() (n int) { return n } -func (m *WhiteList) Size() (n int) { +func (m *AddressId) Size() (n int) { if m == nil { return 0 } var l int _ = l - if len(m.ValidatorList) > 0 { - for _, s := range m.ValidatorList { - l = len(s) - n += 1 + l + sovTypes(uint64(l)) - } + l = len(m.Address) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + if m.Id != 0 { + n += 1 + sovTypes(uint64(m.Id)) } return n } @@ -748,7 +759,7 @@ func (m *Position) Unmarshal(dAtA []byte) error { } return nil } -func (m *WhiteList) Unmarshal(dAtA []byte) error { +func (m *AddressId) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -771,15 +782,15 @@ func (m *WhiteList) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: WhiteList: wiretype end group for non-group") + return fmt.Errorf("proto: AddressId: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: WhiteList: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: AddressId: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ValidatorList", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -807,8 +818,27 @@ func (m *WhiteList) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ValidatorList = append(m.ValidatorList, string(dAtA[iNdEx:postIndex])) + m.Address = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 2: + 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 ErrIntOverflowTypes + } + 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 := skipTypes(dAtA[iNdEx:]) diff --git a/x/masterchef/genesis.go b/x/masterchef/genesis.go index d6fef1050..7e9f36605 100644 --- a/x/masterchef/genesis.go +++ b/x/masterchef/genesis.go @@ -27,6 +27,10 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) for _, elem := range genState.UserRewardInfos { k.SetUserRewardInfo(ctx, elem) } + + for _, elem := range genState.PoolRewardsAccum { + k.SetPoolRewardsAccum(ctx, elem) + } } // ExportGenesis returns the module's exported genesis @@ -38,6 +42,7 @@ func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { genesis.PoolInfos = k.GetAllPools(ctx) genesis.PoolRewardInfos = k.GetAllPoolRewardInfos(ctx) genesis.UserRewardInfos = k.GetAllUserRewardInfos(ctx) + genesis.PoolRewardsAccum = k.GetAllPoolRewardsAccum(ctx) // this line is used by starport scaffolding # genesis/module/export diff --git a/x/masterchef/keeper/abci.go b/x/masterchef/keeper/abci.go index 17d71ceaf..a56df6967 100644 --- a/x/masterchef/keeper/abci.go +++ b/x/masterchef/keeper/abci.go @@ -70,8 +70,7 @@ func (k Keeper) ProcessExternalRewardsDistribution(ctx sdk.Context) { tvl := k.GetPoolTVL(ctx, pool.PoolId) if tvl.IsPositive() { yearlyIncentiveRewardsTotal := externalIncentive.AmountPerBlock. - Mul(sdk.NewInt(totalBlocksPerYear)). - Quo(pool.NumBlocks) + Mul(sdk.NewInt(totalBlocksPerYear)) apr := sdk.NewDecFromInt(yearlyIncentiveRewardsTotal). Mul(k.amm.GetTokenPrice(ctx, externalIncentive.RewardDenom, baseCurrency)). @@ -158,10 +157,9 @@ func (k Keeper) UpdateLPRewards(ctx sdk.Context) error { // Collect Gas fees + swap fees gasFeesForLpsDec := k.CollectGasFees(ctx, baseCurrency) - _, dexRevenueForLps, rewardsPerPool := k.CollectDEXRevenue(ctx) + _, _, rewardsPerPool := k.CollectDEXRevenue(ctx) // USDC amount in sdk.Dec type - dexUsdcAmountForLps := dexRevenueForLps.AmountOf(baseCurrency) gasFeeUsdcAmountForLps := gasFeesForLpsDec.AmountOf(baseCurrency) // Proxy TVL @@ -209,7 +207,7 @@ func (k Keeper) UpdateLPRewards(ctx sdk.Context) error { // Maximum eden APR - 30% by default poolMaxEdenAmount := params.MaxEdenRewardAprLps. - Mul(tvl). + Mul(proxyTVL). QuoInt64(totalBlocksPerYear). Quo(edenDenomPrice) @@ -239,17 +237,27 @@ func (k Keeper) UpdateLPRewards(ctx sdk.Context) error { // 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) + // Track pool rewards accumulation + k.AddPoolRewardsAccum( + ctx, + pool.PoolId, + uint64(ctx.BlockTime().Unix()), + ctx.BlockHeight(), + dexRewardsAllocatedForPool, + gasRewardsAllocatedForPool, + newEdenAllocatedForPool, + ) + params := k.parameterKeeper.GetParams(ctx) + dataLifetime := params.RewardsDataLifetime + for { + firstAccum := k.FirstPoolRewardsAccum(ctx, pool.PoolId) + if firstAccum.Timestamp == 0 || int64(firstAccum.Timestamp)+dataLifetime >= ctx.BlockTime().Unix() { + break + } + k.DeletePoolRewardsAccum(ctx, firstAccum) + } } - // 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, totalBlocksPerYear, totalProxyTVL, edenDenomPrice) @@ -453,12 +461,16 @@ func (k Keeper) InitPoolParams(ctx sdk.Context, poolId uint64) bool { 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(), + // Eden APR, updated at every distribution + EdenApr: math.LegacyZeroDec(), + // Dex APR, updated at every distribution + DexApr: math.LegacyZeroDec(), + // Gas APR, updated at every distribution + GasApr: math.LegacyZeroDec(), + // External Incentive APR, updated at every distribution + ExternalIncentiveApr: math.LegacyZeroDec(), + // external reward denoms on the pool + ExternalRewardDenoms: []string{}, } k.SetPool(ctx, poolInfo) } @@ -477,12 +489,16 @@ func (k Keeper) InitStableStakePoolParams(ctx sdk.Context, poolId uint64) bool { 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(), + // Eden APR, updated at every distribution + EdenApr: math.LegacyZeroDec(), + // Dex APR, updated at every distribution + DexApr: math.LegacyZeroDec(), + // Gas APR, updated at every distribution + GasApr: math.LegacyZeroDec(), + // External Incentive APR, updated at every distribution + ExternalIncentiveApr: math.LegacyZeroDec(), + // external reward denoms on the pool + ExternalRewardDenoms: []string{}, } k.SetPool(ctx, poolInfo) } @@ -490,31 +506,6 @@ func (k Keeper) InitStableStakePoolParams(ctx sdk.Context, poolId uint64) bool { 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 info from incentive param - poolInfo, found := k.GetPool(ctx, uint64(stabletypes.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 int64, totalProxyTVL sdk.Dec, edenDenomPrice sdk.Dec) { baseCurrency, _ := k.assetProfileKeeper.GetUsdcDenom(ctx) @@ -536,32 +527,53 @@ func (k Keeper) UpdateAmmPoolAPR(ctx sdk.Context, totalBlocksPerYear int64, tota poolInfo, _ = k.GetPool(ctx, poolId) } - poolInfo.NumBlocks = sdk.OneInt() - if tvl.IsZero() { return false } - if poolInfo.NumBlocks.IsZero() { + firstAccum := k.FirstPoolRewardsAccum(ctx, poolId) + lastAccum := k.FirstPoolRewardsAccum(ctx, poolId) + if lastAccum.Timestamp == 0 { return false } - // Dex reward Apr per pool - yearlyDexRewardsTotal := poolInfo.DexRewardAmountGiven. - MulInt64(totalBlocksPerYear). - QuoInt(poolInfo.NumBlocks) - poolInfo.DexApr = yearlyDexRewardsTotal.Mul(usdcDenomPrice).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(sdk.NewInt(totalBlocksPerYear)). - Quo(poolInfo.NumBlocks) - - poolInfo.EdenApr = sdk.NewDecFromInt(yearlyEdenRewardsTotal). - Mul(edenDenomPrice). - Quo(tvl) - - // Update Pool Info + if firstAccum.Timestamp == lastAccum.Timestamp { + poolInfo.DexApr = lastAccum.DexReward. + MulInt64(totalBlocksPerYear). + Mul(usdcDenomPrice). + Quo(tvl) + + poolInfo.GasApr = lastAccum.GasReward. + MulInt64(totalBlocksPerYear). + Mul(usdcDenomPrice). + Quo(tvl) + + poolInfo.EdenApr = lastAccum.EdenReward. + MulInt(sdk.NewInt(totalBlocksPerYear)). + Mul(edenDenomPrice). + Quo(tvl) + } else { + duration := lastAccum.Timestamp - firstAccum.Timestamp + secondsInYear := int64(86400 * 360) + + poolInfo.DexApr = lastAccum.DexReward.Sub(firstAccum.DexReward). + MulInt64(secondsInYear). + QuoInt64(int64(duration)). + Mul(usdcDenomPrice). + Quo(tvl) + + poolInfo.GasApr = lastAccum.GasReward.Sub(firstAccum.GasReward). + MulInt64(secondsInYear). + QuoInt64(int64(duration)). + Mul(usdcDenomPrice). + Quo(tvl) + + poolInfo.EdenApr = lastAccum.EdenReward.Sub(firstAccum.EdenReward). + MulInt64(secondsInYear). + QuoInt64(int64(duration)). + Mul(edenDenomPrice). + Quo(tvl) + } k.SetPool(ctx, poolInfo) return false }) diff --git a/x/masterchef/keeper/apr_stable_stake.go b/x/masterchef/keeper/apr_stable_stake.go index 732199eac..3cacb3fe3 100644 --- a/x/masterchef/keeper/apr_stable_stake.go +++ b/x/masterchef/keeper/apr_stable_stake.go @@ -46,13 +46,24 @@ func (k Keeper) CalculateStableStakeApr(ctx sdk.Context, query *types.QueryStabl edenDenomPrice := k.amm.GetEdenDenomPrice(ctx, baseCurrency) - // Eden amount for stable stake LP in 24hrs - stableStakePoolShare := k.CalculatePoolShareForStableStakeLPs(ctx, totalProxyTVL, baseCurrency) + // Get pool info from incentive param + poolInfo, found := k.GetPool(ctx, uint64(stabletypes.PoolId)) + if !found { + return sdk.ZeroInt(), nil + } + + // Calculate Proxy TVL share considering multiplier + proxyTVL := stableTvl.Mul(poolInfo.Multiplier) + if totalProxyTVL.IsZero() { + return sdk.ZeroInt(), nil + } + stableStakePoolShare := proxyTVL.Quo(totalProxyTVL) + stableStakeEdenAmount := sdk.NewDecFromInt(edenAmount).Mul(stableStakePoolShare) params := k.GetParams(ctx) poolMaxEdenAmount := params.MaxEdenRewardAprLps. - Mul(stableTvl). + Mul(proxyTVL). QuoInt64(totalBlocksPerYear). Quo(edenDenomPrice) stableStakeEdenAmount = sdk.MinDec(stableStakeEdenAmount, poolMaxEdenAmount) diff --git a/x/masterchef/keeper/hooks_amm.go b/x/masterchef/keeper/hooks_amm.go index bbcf1f26b..6c5bd6735 100644 --- a/x/masterchef/keeper/hooks_amm.go +++ b/x/masterchef/keeper/hooks_amm.go @@ -21,12 +21,16 @@ func (k Keeper) AfterPoolCreated(ctx sdk.Context, sender sdk.AccAddress, poolId 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(), + // Eden APR, updated at every distribution + EdenApr: math.LegacyZeroDec(), + // Dex APR, updated at every distribution + DexApr: math.LegacyZeroDec(), + // Gas APR, updated at every distribution + GasApr: math.LegacyZeroDec(), + // External Incentive APR, updated at every distribution + ExternalIncentiveApr: math.LegacyZeroDec(), + // external reward denoms on the pool + ExternalRewardDenoms: []string{}, } k.SetPool(ctx, poolInfo) } diff --git a/x/masterchef/keeper/hooks_masterchef.go b/x/masterchef/keeper/hooks_masterchef.go index 24896d0dd..2c8549129 100644 --- a/x/masterchef/keeper/hooks_masterchef.go +++ b/x/masterchef/keeper/hooks_masterchef.go @@ -8,7 +8,7 @@ import ( stablestaketypes "github.com/elys-network/elys/x/stablestake/types" ) -func (k Keeper) GetPoolTotalCommit(ctx sdk.Context, poolId uint64) sdk.Int { +func (k Keeper) GetPoolTotalCommit(ctx sdk.Context, poolId uint64) math.Int { shareDenom := ammtypes.GetPoolShareDenom(poolId) if poolId == stablestaketypes.PoolId { shareDenom = stablestaketypes.GetShareDenom() @@ -18,7 +18,7 @@ func (k Keeper) GetPoolTotalCommit(ctx sdk.Context, poolId uint64) sdk.Int { return params.TotalCommitted.AmountOf(shareDenom) } -func (k Keeper) GetPoolBalance(ctx sdk.Context, poolId uint64, user string) sdk.Int { +func (k Keeper) GetPoolBalance(ctx sdk.Context, poolId uint64, user string) math.Int { commitments := k.cmk.GetCommitments(ctx, user) shareDenom := stablestaketypes.GetShareDenom() if poolId != stablestaketypes.PoolId { @@ -28,7 +28,7 @@ func (k Keeper) GetPoolBalance(ctx sdk.Context, poolId uint64, user string) sdk. return commitments.GetCommittedAmountForDenom(shareDenom) } -func (k Keeper) UpdateAccPerShare(ctx sdk.Context, poolId uint64, rewardDenom string, amount sdk.Int) { +func (k Keeper) UpdateAccPerShare(ctx sdk.Context, poolId uint64, rewardDenom string, amount math.Int) { poolRewardInfo, found := k.GetPoolRewardInfo(ctx, poolId, rewardDenom) if !found { poolRewardInfo = types.PoolRewardInfo{ @@ -51,7 +51,7 @@ func (k Keeper) UpdateAccPerShare(ctx sdk.Context, poolId uint64, rewardDenom st k.SetPoolRewardInfo(ctx, poolRewardInfo) } -func (k Keeper) UpdateUserRewardPending(ctx sdk.Context, poolId uint64, rewardDenom string, user string, isDeposit bool, amount sdk.Int) { +func (k Keeper) UpdateUserRewardPending(ctx sdk.Context, poolId uint64, rewardDenom string, user string, isDeposit bool, amount math.Int) { poolRewardInfo, found := k.GetPoolRewardInfo(ctx, poolId, rewardDenom) if !found { poolRewardInfo = types.PoolRewardInfo{ diff --git a/x/masterchef/keeper/hooks_user_actions.go b/x/masterchef/keeper/hooks_user_actions.go index 8be83df59..f51b5c910 100644 --- a/x/masterchef/keeper/hooks_user_actions.go +++ b/x/masterchef/keeper/hooks_user_actions.go @@ -29,7 +29,7 @@ func (k Keeper) AfterDeposit(ctx sdk.Context, poolId uint64, user string, amount } } -func (k Keeper) AfterWithdrawPerReward(ctx sdk.Context, poolId uint64, rewardDenom string, user string, amount sdk.Int) { +func (k Keeper) AfterWithdrawPerReward(ctx sdk.Context, poolId uint64, rewardDenom string, user string, amount math.Int) { k.UpdateUserRewardPending( ctx, poolId, @@ -46,7 +46,7 @@ func (k Keeper) AfterWithdrawPerReward(ctx sdk.Context, poolId uint64, rewardDen ) } -func (k Keeper) AfterWithdraw(ctx sdk.Context, poolId uint64, user string, amount sdk.Int) { +func (k Keeper) AfterWithdraw(ctx sdk.Context, poolId uint64, user string, amount math.Int) { for _, rewardDenom := range k.GetRewardDenoms(ctx, poolId) { k.AfterWithdrawPerReward(ctx, poolId, rewardDenom, user, amount) } diff --git a/x/masterchef/keeper/msg_server.go b/x/masterchef/keeper/msg_server.go index 88dda7e37..acdc3cb18 100644 --- a/x/masterchef/keeper/msg_server.go +++ b/x/masterchef/keeper/msg_server.go @@ -114,23 +114,13 @@ func (k msgServer) AddExternalIncentive(goCtx context.Context, msg *types.MsgAdd 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) - } - } - +func (k Keeper) ClaimRewards(ctx sdk.Context, sender sdk.AccAddress, poolIds []uint64) error { coins := sdk.NewCoins() - for _, poolId := range msg.PoolIds { - k.AfterWithdraw(ctx, poolId, msg.Sender, sdk.ZeroInt()) + for _, poolId := range poolIds { + k.AfterWithdraw(ctx, poolId, sender.String(), sdk.ZeroInt()) for _, rewardDenom := range k.GetRewardDenoms(ctx, poolId) { - userRewardInfo, found := k.GetUserRewardInfo(ctx, msg.Sender, poolId, rewardDenom) + userRewardInfo, found := k.GetUserRewardInfo(ctx, sender.String(), poolId, rewardDenom) if found && userRewardInfo.RewardPending.IsPositive() { coin := sdk.NewCoin(rewardDenom, userRewardInfo.RewardPending.TruncateInt()) coins = coins.Add(coin) @@ -143,6 +133,24 @@ func (k msgServer) ClaimRewards(goCtx context.Context, msg *types.MsgClaimReward // Transfer rewards (Eden/EdenB is transferred through commitment module) err := k.cmk.SendCoinsFromModuleToAccount(ctx, types.ModuleName, sender, coins) + if err != nil { + return err + } + return 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) + } + } + + err := k.Keeper.ClaimRewards(ctx, sender, msg.PoolIds) if err != nil { return nil, err } diff --git a/x/masterchef/keeper/params.go b/x/masterchef/keeper/params.go index c737047ba..3a56dded2 100644 --- a/x/masterchef/keeper/params.go +++ b/x/masterchef/keeper/params.go @@ -24,3 +24,16 @@ func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { b := k.cdc.MustMarshal(¶ms) store.Set([]byte(types.ParamsKey), b) } + +// GetParams get all parameters as types.Params +func (k Keeper) GetLegacyParams(ctx sdk.Context) (params types.LegacyParams) { + store := ctx.KVStore(k.storeKey) + + b := store.Get([]byte(types.ParamsKey)) + if b == nil { + return + } + + k.cdc.MustUnmarshal(b, ¶ms) + return +} diff --git a/x/masterchef/keeper/pool.go b/x/masterchef/keeper/pool.go index 8a546b9a8..7de10e591 100644 --- a/x/masterchef/keeper/pool.go +++ b/x/masterchef/keeper/pool.go @@ -61,3 +61,18 @@ func (k Keeper) UpdatePoolMultipliers(ctx sdk.Context, poolMultipliers []types.P return true } + +func (k Keeper) GetAllLegacyPools(ctx sdk.Context) (list []types.LegacyPoolInfo) { + 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.LegacyPoolInfo + k.cdc.MustUnmarshal(iterator.Value(), &val) + list = append(list, val) + } + + return +} diff --git a/x/masterchef/keeper/pool_rewards_accum.go b/x/masterchef/keeper/pool_rewards_accum.go new file mode 100644 index 000000000..e3b8989cd --- /dev/null +++ b/x/masterchef/keeper/pool_rewards_accum.go @@ -0,0 +1,122 @@ +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/masterchef/types" +) + +func (k Keeper) GetPoolRewardsAccum(ctx sdk.Context, poolId, timestamp uint64) (types.PoolRewardsAccum, error) { + store := ctx.KVStore(k.storeKey) + b := store.Get(types.GetPoolRewardsAccumKey(poolId, timestamp)) + if b == nil { + return types.PoolRewardsAccum{}, types.ErrPoolRewardsAccumNotFound + } + + accum := types.PoolRewardsAccum{} + k.cdc.MustUnmarshal(b, &accum) + return accum, nil +} + +func (k Keeper) SetPoolRewardsAccum(ctx sdk.Context, accum types.PoolRewardsAccum) { + store := ctx.KVStore(k.storeKey) + bz := k.cdc.MustMarshal(&accum) + store.Set(types.GetPoolRewardsAccumKey(accum.PoolId, accum.Timestamp), bz) +} + +func (k Keeper) DeletePoolRewardsAccum(ctx sdk.Context, accum types.PoolRewardsAccum) { + store := ctx.KVStore(k.storeKey) + store.Delete(types.GetPoolRewardsAccumKey(accum.PoolId, accum.Timestamp)) +} + +func (k Keeper) GetAllPoolRewardsAccum(ctx sdk.Context) (list []types.PoolRewardsAccum) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.PoolRewardsAccumKeyPrefix)) + iterator := sdk.KVStorePrefixIterator(store, []byte{}) + + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + var val types.PoolRewardsAccum + k.cdc.MustUnmarshal(iterator.Value(), &val) + list = append(list, val) + } + + return +} + +func (k Keeper) IterateAllPoolRewardsAccum(ctx sdk.Context, handler func(accum types.PoolRewardsAccum) (stop bool)) { + store := ctx.KVStore(k.storeKey) + iter := sdk.KVStorePrefixIterator(store, []byte(types.PoolRewardsAccumKeyPrefix)) + defer iter.Close() + for ; iter.Valid(); iter.Next() { + accum := types.PoolRewardsAccum{} + k.cdc.MustUnmarshal(iter.Value(), &accum) + if handler(accum) { + break + } + } +} + +func (k Keeper) IteratePoolRewardsAccum(ctx sdk.Context, poolId uint64, handler func(accum types.PoolRewardsAccum) (stop bool)) { + store := ctx.KVStore(k.storeKey) + iter := sdk.KVStorePrefixIterator(store, types.GetPoolRewardsAccumPrefix(poolId)) + defer iter.Close() + for ; iter.Valid(); iter.Next() { + accum := types.PoolRewardsAccum{} + k.cdc.MustUnmarshal(iter.Value(), &accum) + if handler(accum) { + break + } + } +} + +func (k Keeper) FirstPoolRewardsAccum(ctx sdk.Context, poolId uint64) types.PoolRewardsAccum { + store := ctx.KVStore(k.storeKey) + iter := sdk.KVStorePrefixIterator(store, types.GetPoolRewardsAccumPrefix(poolId)) + defer iter.Close() + for ; iter.Valid(); iter.Next() { + accum := types.PoolRewardsAccum{} + k.cdc.MustUnmarshal(iter.Value(), &accum) + return accum + } + return types.PoolRewardsAccum{} +} + +func (k Keeper) LastPoolRewardsAccum(ctx sdk.Context, poolId uint64) types.PoolRewardsAccum { + store := ctx.KVStore(k.storeKey) + iter := sdk.KVStoreReversePrefixIterator(store, types.GetPoolRewardsAccumPrefix(poolId)) + defer iter.Close() + for ; iter.Valid(); iter.Next() { + accum := types.PoolRewardsAccum{} + k.cdc.MustUnmarshal(iter.Value(), &accum) + return accum + } + return types.PoolRewardsAccum{ + PoolId: poolId, + BlockHeight: 0, + Timestamp: 0, + DexReward: math.LegacyZeroDec(), + GasReward: math.LegacyZeroDec(), + EdenReward: math.LegacyZeroDec(), + } +} + +func (k Keeper) AddPoolRewardsAccum(ctx sdk.Context, poolId, timestamp uint64, height int64, dexReward, gasReward, edenReward math.LegacyDec) { + lastAccum := k.LastPoolRewardsAccum(ctx, poolId) + lastAccum.Timestamp = timestamp + lastAccum.BlockHeight = height + if lastAccum.DexReward.IsNil() { + lastAccum.DexReward = math.LegacyZeroDec() + } + if lastAccum.GasReward.IsNil() { + lastAccum.GasReward = math.LegacyZeroDec() + } + if lastAccum.EdenReward.IsNil() { + lastAccum.EdenReward = math.LegacyZeroDec() + } + lastAccum.DexReward = lastAccum.DexReward.Add(dexReward) + lastAccum.GasReward = lastAccum.GasReward.Add(gasReward) + lastAccum.EdenReward = lastAccum.EdenReward.Add(edenReward) + k.SetPoolRewardsAccum(ctx, lastAccum) +} diff --git a/x/masterchef/keeper/pool_rewards_accum_test.go b/x/masterchef/keeper/pool_rewards_accum_test.go new file mode 100644 index 000000000..1de4a837b --- /dev/null +++ b/x/masterchef/keeper/pool_rewards_accum_test.go @@ -0,0 +1,73 @@ +package keeper_test + +import ( + "testing" + "time" + + "cosmossdk.io/math" + tmproto "github.com/cometbft/cometbft/proto/tendermint/types" + simapp "github.com/elys-network/elys/app" + "github.com/elys-network/elys/x/masterchef/types" + "github.com/stretchr/testify/require" +) + +func TestPoolRewardsAccum(t *testing.T) { + app := simapp.InitElysTestApp(true) + ctx := app.BaseApp.NewContext(true, tmproto.Header{}) + + now := time.Now() + accums := []types.PoolRewardsAccum{ + { + PoolId: 1, + Timestamp: uint64(now.Unix() - 86400), + BlockHeight: 1, + DexReward: math.LegacyNewDec(1000), + GasReward: math.LegacyNewDec(1000), + EdenReward: math.LegacyNewDec(1000), + }, + { + PoolId: 1, + Timestamp: uint64(now.Unix()), + BlockHeight: 1, + DexReward: math.LegacyNewDec(2000), + GasReward: math.LegacyNewDec(2000), + EdenReward: math.LegacyNewDec(2000), + }, + { + PoolId: 2, + Timestamp: uint64(now.Unix() - 86400), + BlockHeight: 1, + DexReward: math.LegacyNewDec(1000), + GasReward: math.LegacyNewDec(1000), + EdenReward: math.LegacyNewDec(1000), + }, + { + PoolId: 2, + Timestamp: uint64(now.Unix()), + BlockHeight: 1, + DexReward: math.LegacyNewDec(3000), + GasReward: math.LegacyNewDec(3000), + EdenReward: math.LegacyNewDec(3000), + }, + } + for _, accum := range accums { + app.MasterchefKeeper.SetPoolRewardsAccum(ctx, accum) + } + + for _, accum := range accums { + storedAccum, err := app.MasterchefKeeper.GetPoolRewardsAccum(ctx, accum.PoolId, accum.Timestamp) + require.NoError(t, err) + require.Equal(t, storedAccum, accum) + } + + accum := app.MasterchefKeeper.FirstPoolRewardsAccum(ctx, 1) + require.Equal(t, accum, accums[0]) + accum = app.MasterchefKeeper.LastPoolRewardsAccum(ctx, 1) + require.Equal(t, accum, accums[1]) + + app.MasterchefKeeper.DeletePoolRewardsAccum(ctx, accums[0]) + accum = app.MasterchefKeeper.FirstPoolRewardsAccum(ctx, 1) + require.Equal(t, accum, accums[1]) + accum = app.MasterchefKeeper.LastPoolRewardsAccum(ctx, 1) + require.Equal(t, accum, accums[1]) +} diff --git a/x/masterchef/keeper/pool_test.go b/x/masterchef/keeper/pool_test.go index 674022681..b85404a1e 100644 --- a/x/masterchef/keeper/pool_test.go +++ b/x/masterchef/keeper/pool_test.go @@ -17,45 +17,39 @@ func TestPool(t *testing.T) { 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(), + PoolId: 1, + RewardWallet: ammtypes.NewPoolRevenueAddress(1).String(), + Multiplier: sdk.OneDec(), + EdenApr: sdk.OneDec(), + DexApr: sdk.OneDec(), + GasApr: 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(), + PoolId: 2, + RewardWallet: ammtypes.NewPoolRevenueAddress(2).String(), + Multiplier: sdk.OneDec(), + EdenApr: sdk.OneDec(), + DexApr: sdk.OneDec(), + GasApr: 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(), + PoolId: 3, + RewardWallet: ammtypes.NewPoolRevenueAddress(3).String(), + Multiplier: sdk.OneDec(), + EdenApr: sdk.OneDec(), + DexApr: sdk.OneDec(), + GasApr: sdk.OneDec(), + ExternalIncentiveApr: sdk.OneDec(), ExternalRewardDenoms: []string{ "rewardDenom1", "rewardDenom2", @@ -85,45 +79,39 @@ func TestUpdatePoolMultipliers(t *testing.T) { 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(), + PoolId: 1, + RewardWallet: ammtypes.NewPoolRevenueAddress(1).String(), + Multiplier: sdk.OneDec(), + EdenApr: sdk.OneDec(), + DexApr: sdk.OneDec(), + GasApr: 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(), + PoolId: 2, + RewardWallet: ammtypes.NewPoolRevenueAddress(2).String(), + Multiplier: sdk.OneDec(), + EdenApr: sdk.OneDec(), + DexApr: sdk.OneDec(), + GasApr: 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(), + PoolId: 3, + RewardWallet: ammtypes.NewPoolRevenueAddress(3).String(), + Multiplier: sdk.OneDec(), + EdenApr: sdk.OneDec(), + DexApr: sdk.OneDec(), + ExternalIncentiveApr: sdk.OneDec(), + GasApr: sdk.OneDec(), ExternalRewardDenoms: []string{ "rewardDenom1", "rewardDenom2", diff --git a/x/masterchef/keeper/query.go b/x/masterchef/keeper/query.go index 220050dea..370246d44 100644 --- a/x/masterchef/keeper/query.go +++ b/x/masterchef/keeper/query.go @@ -55,27 +55,36 @@ func (k Keeper) UserRewardInfo(goCtx context.Context, req *types.QueryUserReward return &types.QueryUserRewardInfoResponse{UserRewardInfo: userRewardInfo}, nil } +func (k Keeper) UserPoolPendingReward(ctx sdk.Context, user sdk.AccAddress, poolId uint64) sdk.Coins { + k.AfterWithdraw(ctx, poolId, user.String(), sdk.ZeroInt()) + + poolRewards := sdk.NewCoins() + for _, rewardDenom := range k.GetRewardDenoms(ctx, poolId) { + userRewardInfo, found := k.GetUserRewardInfo(ctx, user.String(), poolId, rewardDenom) + if found && userRewardInfo.RewardPending.IsPositive() { + poolRewards = poolRewards.Add( + sdk.NewCoin( + rewardDenom, + userRewardInfo.RewardPending.TruncateInt(), + ), + ) + } + } + return poolRewards +} + func (k Keeper) UserPendingReward(goCtx context.Context, req *types.QueryUserPendingRewardRequest) (*types.QueryUserPendingRewardResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) + user, err := sdk.AccAddressFromBech32(req.User) + if err != nil { + return nil, err + } 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(), - ), - ) - } - } + poolRewards := k.UserPoolPendingReward(ctx, user, pool.PoolId) rewardsInfos = append(rewardsInfos, &types.RewardInfo{ PoolId: pool.PoolId, diff --git a/x/masterchef/migrations/new_migrator.go b/x/masterchef/migrations/new_migrator.go new file mode 100644 index 000000000..52f1c8bd9 --- /dev/null +++ b/x/masterchef/migrations/new_migrator.go @@ -0,0 +1,13 @@ +package migrations + +import ( + "github.com/elys-network/elys/x/masterchef/keeper" +) + +type Migrator struct { + keeper keeper.Keeper +} + +func NewMigrator(keeper keeper.Keeper) Migrator { + return Migrator{keeper: keeper} +} diff --git a/x/masterchef/migrations/v2_migration.go b/x/masterchef/migrations/v2_migration.go new file mode 100644 index 000000000..219d985da --- /dev/null +++ b/x/masterchef/migrations/v2_migration.go @@ -0,0 +1,37 @@ +package migrations + +import ( + "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/elys-network/elys/x/masterchef/types" +) + +func (m Migrator) V2Migration(ctx sdk.Context) error { + // migrate params + legacy := m.keeper.GetLegacyParams(ctx) + params := types.NewParams( + legacy.LpIncentives, + legacy.RewardPortionForLps, + legacy.RewardPortionForStakers, + legacy.MaxEdenRewardAprLps, + legacy.ProtocolRevenueAddress, + ) + m.keeper.SetParams(ctx, params) + + // migrate pools + legacyPools := m.keeper.GetAllLegacyPools(ctx) + for _, legacyPool := range legacyPools { + m.keeper.SetPool(ctx, types.PoolInfo{ + PoolId: legacyPool.PoolId, + RewardWallet: legacyPool.RewardWallet, + Multiplier: legacyPool.Multiplier, + EdenApr: legacyPool.EdenApr, + DexApr: legacyPool.DexApr, + GasApr: math.LegacyZeroDec(), + ExternalIncentiveApr: legacyPool.ExternalIncentiveApr, + ExternalRewardDenoms: legacyPool.ExternalRewardDenoms, + }) + } + + return nil +} diff --git a/x/masterchef/module.go b/x/masterchef/module.go index 99d56941e..7cec2341c 100644 --- a/x/masterchef/module.go +++ b/x/masterchef/module.go @@ -19,6 +19,7 @@ import ( "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/migrations" "github.com/elys-network/elys/x/masterchef/types" ) @@ -115,6 +116,11 @@ 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, 1, m.V2Migration) + if err != nil { + panic(err) + } } // 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) @@ -138,7 +144,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 1 } +func (AppModule) ConsensusVersion() uint64 { return 2 } // 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/masterchef/spec/01_concepts.md b/x/masterchef/spec/01_concepts.md new file mode 100644 index 000000000..fa59e3768 --- /dev/null +++ b/x/masterchef/spec/01_concepts.md @@ -0,0 +1,19 @@ + + +# Concepts + +`masterchef` module is to support rewards distribution to liquidity providers. + +The terminology `masterchef` came from the common reward distribution mechanism in EVM chains, e.g. [sushiswap masterchef reward distribution mechanism](https://dev.to/heymarkkop/understanding-sushiswaps-masterchef-staking-rewards-1m6f). + +Masterchef is distributing rewards per block. There's Eden allocation, based on tokenomics to liquidity providers. + +The source of rewards are from `Eden` allocation, `DEX revenue` (USDC) and `Gas fees` (All gas fees are swapped to USDC on amm pools before distribution.) + +## Flow + +1. Allocation of eden in based on tokenmics module which is capped allocation of eden for 50% Apr (Note: multiplier is applied on APR cap, e.g. if multiplier is 1.5 cap's increased to 75% APR) +2. Every block, gas and swap fee rewards are distributed to liquidity providers +3. Reward is splitted based on proxy TVL which is `TVL * multiplier` (USDC stable pool's included as one of pools with lower multiplier) diff --git a/x/masterchef/spec/02_state.md b/x/masterchef/spec/02_state.md new file mode 100644 index 000000000..ee59fdc46 --- /dev/null +++ b/x/masterchef/spec/02_state.md @@ -0,0 +1,208 @@ + + +# State + +The `GenesisState` message defines the initial state of the `masterchef` module at genesis. + +```proto +// GenesisState defines the masterchef module's genesis state. +message GenesisState { + Params params = 1 [(gogoproto.nullable) = false]; + repeated ExternalIncentive external_incentives = 2 [(gogoproto.nullable) = false]; + uint64 external_incentive_index = 3; + repeated PoolInfo pool_infos = 4 [(gogoproto.nullable) = false]; + repeated PoolRewardInfo pool_reward_infos = 5 [(gogoproto.nullable) = false]; + repeated UserRewardInfo user_reward_infos = 6 [(gogoproto.nullable) = false]; + repeated PoolRewardsAccum pool_rewards_accum = 7 [(gogoproto.nullable) = false]; +} +``` + +## Params + +`Params` holds module parameters like protocol revenue address, supported reward denoms, max eden apr, reward portion for lps and stakers and yearly incentive data. + +```proto +// 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 + ]; + + // Maximum eden reward apr for lps - [0 - 0.3] + string max_eden_reward_apr_lps = 4 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + + repeated SupportedRewardDenom supported_reward_denoms = 5; + + string protocol_revenue_address = 6; +} +``` + +### SupportedRewardDenom + +The `SupportedRewardDenom` message defines the supported reward denominations and their minimum amounts. + +```proto +message SupportedRewardDenom { + string denom = 1; + string min_amount = 2 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; +} +``` + +## IncentiveInfo + +`IncentiveInfo` holds eden reward distribution info for current year. + +```proto +// 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]; +} +``` + +## ExternalIncentive + +`ExternalIncentive` holds external incentive record which is created by third party. + +```proto +// 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]; + string apr = 7 + [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; +} +``` + +## PoolInfo + +`PoolInfo` holds APR information per reward source, proxy TVL multiplier, and external reward denoms allowed on the pool. + +```proto +message PoolInfo { + 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 + ]; + // Eden APR, updated at every distribution + string eden_apr = 4 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + // Dex APR, updated at every distribution + string dex_apr = 5 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + // Gas APR, updated at every distribution + string gas_apr = 6 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + // External Incentive APR, updated at every distribution + string external_incentive_apr = 7 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + // external reward denoms on the pool + repeated string external_reward_denoms = 8; +} +``` + +## PoolRewardInfo + +`PoolRewardInfo` is used to track pool's reward growth per denom. + +```proto +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; +} +``` + +## UserRewardInfo + +`UserRewardInfo` is used to track user's reward information per reward denom and pool id. + +```proto +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 + ]; +} +``` + +## PoolRewardsAccum + +`PoolRewardsAccum` is introduced to track 24h dex rewards, gas rewards, and eden rewards. + +```proto +message PoolRewardsAccum { + uint64 pool_id = 1; + int64 block_height = 2; + uint64 timestamp = 3; + string dex_reward = 4 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + string gas_reward = 5 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + string eden_reward = 6 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; +} +``` diff --git a/x/masterchef/spec/03_keeper.md b/x/masterchef/spec/03_keeper.md new file mode 100644 index 000000000..329127b9c --- /dev/null +++ b/x/masterchef/spec/03_keeper.md @@ -0,0 +1,62 @@ + + +# Keeper + +## Rewards Distribution + +The `Masterchef` module's keeper handles the distribution of LP rewards and external incentives. It ensures that rewards are properly calculated and distributed and that necessary adjustments to staking parameters are made regularly. + +At every block, iteration of LP pools' done and Eden rewards are calculated based on proxy TVL. Pool proxy TVL is expressed as `Pool TVL * Pool Multiplier`. + +When rewards are distributed to a pool, `UpdateAccPerShare` is called and it is updating `PoolRewardInfo` object which includes pool accumulated reward per share. + +Reward distribution's executed through `EndBlocker`. The `EndBlocker` function is called at the end of each block to perform necessary updates and maintenance for the `masterchef` module. It processes LP rewards and external incentives distribution. + +### ProcessLPRewardDistribution + +The `ProcessLPRewardDistribution` function distributes rewards to liquidity providers. It updates the incentive parameters and calculates the rewards based on the collected fees and staking conditions. + +Gas fees collected are converted into USDC before being distributed. DEX swap fees are collected in USDC, therefore masterchef module doesn't convert DEX fees to USDC. + +### ProcessExternalRewardsDistribution + +The `ProcessExternalRewardsDistribution` function distributes external incentives to the specified pools within the defined block range. + +### UpdateLPRewards + +The `UpdateLPRewards` function updates the rewards for liquidity providers by calculating the total rewards based on the collected fees and staking conditions. + +### UpdateAccPerShare + +The `UpdateAccPerShare` function updates the accumulated reward per share for a specific pool and denom. + +### CollectGasFees + +The `CollectGasFees` function collects gas fees and allocates them to LPs and the protocol. + +Gas fees collected are swapped for USDC through amm module. + +### CollectDEXRevenue + +The `CollectDEXRevenue` function collects DEX revenue and distributes it to LPs and the protocol. + +There's constant reward pool address per liquidity pool. `GetLPRewardsPoolAddress` generates an address to be used in collecting DEX revenue from the specified pool. + +### CalculateProxyTVL + +The `CalculateProxyTVL` function calculates the proxy total value locked (TVL) for the pools. + +Pool proxy TVL is calculated by using TVL and multiplier (`Pool TVL * Pool Multiplier`). + +### UpdateAmmPoolAPR + +The `UpdateAmmPoolAPR` function updates the APR for AMM pools. + +APR calculation considers historical rewards data (24h) to prevent flash effect in APR per block. + +## Rewards claim + +Rewards claim is done per pool and reward denom. +`UserRewardInfo`'s `RewardPending` and `RewardDebt` fields are updated and appropriate amount of tokens are sent from module to user account. diff --git a/x/masterchef/spec/04_endpoints.md b/x/masterchef/spec/04_endpoints.md new file mode 100644 index 000000000..044b4dfb2 --- /dev/null +++ b/x/masterchef/spec/04_endpoints.md @@ -0,0 +1,206 @@ + + +# Endpoints + +## Gov Proposals + +```proto +service Msg { + rpc AddExternalRewardDenom(MsgAddExternalRewardDenom) returns (MsgAddExternalRewardDenomResponse); + rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse); + rpc UpdatePoolMultipliers(MsgUpdatePoolMultipliers) returns (MsgUpdatePoolMultipliersResponse); +} +``` + +### UpdateParams + +`MsgUpdateParams` is used by governance to update masterchef module params. + +```proto +message MsgUpdateParams { + string authority = 1; + Params params = 2 [(gogoproto.nullable) = false]; +} +``` + +### UpdatePoolMultipliers + +`MsgUpdatePoolMultipliers` is used by governance to update masterchef pool info multipliers. + +```proto +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 ]; +} +``` + +### AddExternalRewardDenom + +`MsgAddExternalRewardDenom` is used by governance to approve a reward denom. + +```proto +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; +} +``` + +## Msgs + +The `Msg` service defines the transactions available in the `masterchef` module. + +```proto +service Msg { + rpc AddExternalIncentive(MsgAddExternalIncentive) returns (MsgAddExternalIncentiveResponse); + rpc ClaimRewards(MsgClaimRewards) returns (MsgClaimRewardsResponse); +} +``` + +### MsgAddExternalIncentive + +`MsgAddExternalIncentive` is used to add external incentive on a specific pool from `from_block` to `to_block` with same amount of `amount_per_block` per block for `reward_denom` denom. + +```proto +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]; +} +``` + +### MsgClaimRewards + +`MsgClaimRewards` is used to claim pending rewards on specified pool ids (`pool_ids`). + +```proto +message MsgClaimRewards { + string sender = 1; + repeated uint64 pool_ids = 2; +} +``` + +## Query endpoints + +The `Query` service defines the gRPC querier service for the `masterchef` module. + +```proto +service Query { + 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"; + } +} +``` + +### Params + +Query module params + +### ExternalIncentive + +Query external incentive by id. + +### PoolInfo + +Query pool info by pool id + +### PoolRewardInfo + +Query pool reward info by pool id and reward denom. + +### UserRewardInfo + +Query user reward info by user address, pool id and reward denom. + +### UserPendingReward + +Query user pending rewards per pool from user address. + +### StableStakeApr + +Query stablestake APR by reward denom. + +### PoolAprs + +Query pool APRs from specified pool ids. If nothing's put in pool ids, full list of pool APRs returned. + +## Wasmbindings + +### Messages + +#### MastercheClaimRewards + +Connect wasmbinding to `MsgClaimRewards` + +### Queries + +#### MasterchefParams + +Connect wasmbinding to `Params` query. + +#### MasterchefExternalIncentive + +Connect wasmbinding to `ExternalIncentive` query. + +#### MasterchefPoolInfo + +Connect wasmbinding to `PoolInfo` query. + +#### MasterchefPoolRewardInfo + +Connect wasmbinding to `PoolRewardInfo` query. + +#### MasterchefUserRewardInfo + +Connect wasmbinding to `UserRewardInfo` query. + +#### MasterchefUserPendingReward + +Connect wasmbinding to `UserPendingReward` query. + +#### MasterchefStableStakeApr + +Connect wasmbinding to `StableStakeApr` query. + +#### MasterchefPoolAprs + +Connect wasmbinding to `PoolAprs` query. diff --git a/x/masterchef/spec/05_cli.md b/x/masterchef/spec/05_cli.md new file mode 100644 index 000000000..dac121b0b --- /dev/null +++ b/x/masterchef/spec/05_cli.md @@ -0,0 +1,73 @@ + + +# Usage + +## Commands + +### Querying Parameters + +```bash +elysd query masterchef params +``` + +### Querying External Incentives + +```bash +elysd query masterchef external-incentive [incentive_id] +``` + +### Querying Pool Information + +```bash +elysd query masterchef pool-info [pool_id] +``` + +### Querying Pool Reward Information + +```bash +elysd query masterchef pool-reward-info [pool_id] [reward_denom] +``` + +### Querying User Reward Information + +```bash +elysd query masterchef user-reward-info [user_address] [pool_id] [reward_denom] +``` + +### Querying User Pending Rewards + +```bash +elysd query masterchef user-pending-reward [user_address] +``` + +### Querying Stable Stake APR + +```bash +elysd query masterchef stable-stake-apr [denom] +``` + +### Querying Pool APRs + +```bash +elysd query masterchef pool-aprs +``` + +### Adding External Reward Denom + +```bash +elysd tx masterchef add-external-reward-denom [authority] [reward_denom] [min_amount] [supported] --from=[key_name] --chain-id=[chain_id] --yes --gas=[gas_limit] +``` + +### Adding External Incentive + +```bash +elysd tx masterchef add-external-incentive [sender] [reward_denom] [pool_id] [from_block] [to_block] [amount_per_block] --from=[key_name] --chain-id=[chain_id] --yes --gas=[gas_limit] +``` + +### Claiming Rewards + +```bash +elysd tx masterchef claim-rewards [sender] [pool_ids] --from=[key_name] --chain-id=[chain_id] --yes --gas=[gas_limit] +``` diff --git a/x/masterchef/spec/README.md b/x/masterchef/spec/README.md new file mode 100644 index 000000000..b2658ce74 --- /dev/null +++ b/x/masterchef/spec/README.md @@ -0,0 +1,17 @@ +# masterchef module + +The `Masterchef` module in the Elys Network is designed to manage liquidity provider (LP) rewards and external incentives. It provides functionalities for tracking LP rewards, distributing external incentives, and updating staking parameters dynamically. The module aims to enhance the efficiency and fairness of reward distribution within the network. + +## Key Features + +- **Advanced Reward Management**: Manage and distribute rewards to liquidity providers efficiently. +- **External Incentives**: Handle external incentives and distribute them to specified pools within the defined block range. +- **Dynamic Parameter Updates**: Update and manage staking parameters dynamically. + +## Contents + +1. **[Concepts](01_concepts.md)** +2. **[State](02_state.md)** +3. **[Keeper](03_keeper.md)** +4. **[Endpoints](04_endpoints.md)** +5. **[CLI](05_cli.md)** diff --git a/x/masterchef/types/errors.go b/x/masterchef/types/errors.go index 97d717d0d..026e74a23 100644 --- a/x/masterchef/types/errors.go +++ b/x/masterchef/types/errors.go @@ -8,5 +8,6 @@ import ( // x/masterchef module sentinel errors var ( - ErrNoInflationaryParams = errorsmod.Register(ModuleName, 14, "no inflationary rewards params") + ErrNoInflationaryParams = errorsmod.Register(ModuleName, 1, "no inflationary rewards params") + ErrPoolRewardsAccumNotFound = errorsmod.Register(ModuleName, 2, "pool rewards accumulation not found") ) diff --git a/x/masterchef/types/genesis.pb.go b/x/masterchef/types/genesis.pb.go index a538f784b..3e1e20bea 100644 --- a/x/masterchef/types/genesis.pb.go +++ b/x/masterchef/types/genesis.pb.go @@ -31,6 +31,7 @@ type GenesisState struct { PoolInfos []PoolInfo `protobuf:"bytes,4,rep,name=pool_infos,json=poolInfos,proto3" json:"pool_infos"` PoolRewardInfos []PoolRewardInfo `protobuf:"bytes,5,rep,name=pool_reward_infos,json=poolRewardInfos,proto3" json:"pool_reward_infos"` UserRewardInfos []UserRewardInfo `protobuf:"bytes,6,rep,name=user_reward_infos,json=userRewardInfos,proto3" json:"user_reward_infos"` + PoolRewardsAccum []PoolRewardsAccum `protobuf:"bytes,7,rep,name=pool_rewards_accum,json=poolRewardsAccum,proto3" json:"pool_rewards_accum"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -108,6 +109,13 @@ func (m *GenesisState) GetUserRewardInfos() []UserRewardInfo { return nil } +func (m *GenesisState) GetPoolRewardsAccum() []PoolRewardsAccum { + if m != nil { + return m.PoolRewardsAccum + } + return nil +} + func init() { proto.RegisterType((*GenesisState)(nil), "elys.masterchef.GenesisState") } @@ -115,30 +123,32 @@ func init() { func init() { proto.RegisterFile("elys/masterchef/genesis.proto", fileDescriptor_b55d8c0403fbd8da) } var fileDescriptor_b55d8c0403fbd8da = []byte{ - // 361 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x92, 0x41, 0x4f, 0xf2, 0x30, - 0x18, 0xc7, 0xb7, 0x17, 0x5e, 0x12, 0x8b, 0x09, 0xb1, 0x1a, 0x9d, 0x8b, 0x0e, 0xc2, 0x69, 0x17, - 0xb7, 0x04, 0x63, 0xe2, 0xc9, 0x03, 0x89, 0x31, 0xbb, 0x29, 0xc6, 0x83, 0x5e, 0xc8, 0x80, 0x87, - 0xb1, 0x38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0x31, 0x19, 0x52, 0x6e, 0x95, 0x65, 0x97, 0x63, - 0xfd, 0x3f, 0x94, 0x26, 0x01, 0x19, 0x52, 0x55, 0x61, 0x27, 0x55, 0x7b, 0x8e, 0xef, 0xd0, 0x9e, - 0xbc, 0xcf, 0x60, 0x1a, 0xb2, 0x81, 0xd2, 0xfc, 0x97, 0x9a, 0xfa, 0xaf, 0x9a, 0x8e, 0x0c, 0x6e, - 0xc8, 0x6a, 0xe9, 0xd6, 0xa9, 0x54, 0x4e, 0x38, 0xb0, 0x6d, 0x65, 0xe5, 0x0f, 0xe5, 0x03, 0x07, - 0xa6, 0x2b, 0x27, 0x5b, 0xa7, 0xbc, 0x1d, 0x2c, 0x56, 0x8e, 0xb9, 0x5c, 0x39, 0xe6, 0xe7, 0xca, - 0x31, 0x5f, 0xd7, 0x8e, 0xb1, 0x5c, 0x3b, 0xc6, 0xfb, 0xda, 0x31, 0x9e, 0xfc, 0x28, 0x16, 0xa3, - 0x49, 0xcf, 0xeb, 0xd3, 0xb1, 0x9f, 0xb9, 0xcf, 0x08, 0x88, 0x29, 0x65, 0xcf, 0x72, 0xe3, 0xcf, - 0x36, 0x47, 0x42, 0xcc, 0x53, 0xe0, 0xbd, 0x8a, 0x1c, 0x8a, 0xf3, 0xaf, 0x00, 0x00, 0x00, 0xff, - 0xff, 0xf1, 0xfe, 0x11, 0x4d, 0xc0, 0x02, 0x00, 0x00, + // 390 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x92, 0x41, 0x6b, 0xdb, 0x30, + 0x18, 0x86, 0xed, 0xc5, 0xcb, 0x98, 0x32, 0xc8, 0xa6, 0x8d, 0xcd, 0x33, 0x9b, 0x93, 0xe5, 0xe4, + 0xcb, 0x6c, 0xc8, 0x18, 0xec, 0x34, 0xd8, 0x60, 0x0c, 0xdf, 0xda, 0x94, 0x1c, 0xda, 0x8b, 0x71, + 0x9c, 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2, 0xdf, 0x08, 0x95, 0x4f, 0x0d, 0x12, 0x32, 0xa3, + 0xdc, 0x34, 0x64, 0x97, 0xcf, 0xcd, 0xf7, 0x50, 0x9a, 0xfa, 0x64, 0x46, 0x55, 0x85, 0xd7, 0xb9, + 0xda, 0x73, 0x7c, 0x8c, 0xde, 0xc9, 0xf3, 0x0c, 0x16, 0x21, 0x9b, 0x2a, 0xcd, 0x4b, 0xa9, 0xe9, + 0x3d, 0xaa, 0x19, 0xc9, 0xe0, 0x9e, 0xac, 0x9b, 0x1f, 0x4c, 0xa5, 0xb2, 0xe0, 0xc0, 0x0e, 0x95, + 0xed, 0x27, 0x94, 0x63, 0x0e, 0xac, 0xa9, 0x2c, 0x0e, 0xa6, 0x1c, 0x8f, 0x11, 0xde, 0x6b, 0xc9, + 0x83, 0x30, 0x8a, 0x8a, 0xcc, 0x7c, 0x25, 0x9d, 0xdf, 0x9e, 0xa9, 0xc9, 0xff, 0x94, 0x41, 0x65, + 0x7d, 0x9b, 0xd7, 0xe7, 0xfe, 0x7a, 0x6b, 0xeb, 0x9b, 0xad, 0xad, 0xdf, 0x6e, 0x6d, 0xfd, 0x72, + 0x67, 0x6b, 0x9b, 0x9d, 0xad, 0x5d, 0xef, 0x6c, 0xed, 0xcc, 0x8b, 0x13, 0x31, 0x2f, 0x26, 0x6e, + 0x44, 0x33, 0xaf, 0xd4, 0x7f, 0x27, 0x20, 0x16, 0x94, 0x9d, 0xcb, 0x8d, 0xb7, 0xdc, 0xff, 0x69, + 0x62, 0x95, 0x03, 0x9f, 0xb4, 0xe5, 0x5f, 0xfb, 0x71, 0x17, 0x00, 0x00, 0xff, 0xff, 0x63, 0x59, + 0xfe, 0xa5, 0x17, 0x03, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -161,6 +171,20 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.PoolRewardsAccum) > 0 { + for iNdEx := len(m.PoolRewardsAccum) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.PoolRewardsAccum[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x3a + } + } if len(m.UserRewardInfos) > 0 { for iNdEx := len(m.UserRewardInfos) - 1; iNdEx >= 0; iNdEx-- { { @@ -281,6 +305,12 @@ func (m *GenesisState) Size() (n int) { n += 1 + l + sovGenesis(uint64(l)) } } + if len(m.PoolRewardsAccum) > 0 { + for _, e := range m.PoolRewardsAccum { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } return n } @@ -507,6 +537,40 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PoolRewardsAccum", 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.PoolRewardsAccum = append(m.PoolRewardsAccum, PoolRewardsAccum{}) + if err := m.PoolRewardsAccum[len(m.PoolRewardsAccum)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) diff --git a/x/masterchef/types/keys.go b/x/masterchef/types/keys.go index f1e7062ca..4870c59bd 100644 --- a/x/masterchef/types/keys.go +++ b/x/masterchef/types/keys.go @@ -2,6 +2,8 @@ package types import ( "encoding/binary" + + sdk "github.com/cosmos/cosmos-sdk/types" ) const ( @@ -28,6 +30,8 @@ const ( PoolRewardInfoKeyPrefix = "PoolRewardInfo" UserRewardInfoKeyPrefix = "UserRewardInfo" + + PoolRewardsAccumKeyPrefix = "PoolRewardsAccum" ) func KeyPrefix(p string) []byte { @@ -90,3 +94,11 @@ func UserRewardInfoKey(user string, poolId uint64, rewardDenom string) []byte { return key } + +func GetPoolRewardsAccumPrefix(poolId uint64) []byte { + return append([]byte(PoolRewardsAccumKeyPrefix), sdk.Uint64ToBigEndian(uint64(poolId))...) +} + +func GetPoolRewardsAccumKey(poolId uint64, timestamp uint64) []byte { + return append(GetPoolRewardsAccumPrefix(poolId), sdk.Uint64ToBigEndian(timestamp)...) +} diff --git a/x/masterchef/types/params.go b/x/masterchef/types/params.go index cc275c196..1dcc9b408 100644 --- a/x/masterchef/types/params.go +++ b/x/masterchef/types/params.go @@ -12,7 +12,6 @@ func NewParams( lpIncentives *IncentiveInfo, rewardPortionForLps sdk.Dec, rewardPortionForStakers sdk.Dec, - dexRewardsLps DexRewardsTracker, maxEdenRewardAprLps sdk.Dec, protocolRevenueAddress string, ) Params { @@ -20,7 +19,6 @@ func NewParams( LpIncentives: lpIncentives, RewardPortionForLps: rewardPortionForLps, RewardPortionForStakers: rewardPortionForStakers, - DexRewardsLps: dexRewardsLps, MaxEdenRewardAprLps: maxEdenRewardAprLps, SupportedRewardDenoms: nil, ProtocolRevenueAddress: protocolRevenueAddress, @@ -33,10 +31,6 @@ func DefaultParams() Params { nil, sdk.NewDecWithPrec(60, 2), sdk.NewDecWithPrec(25, 2), - DexRewardsTracker{ - NumBlocks: sdk.NewInt(1), - Amount: sdk.ZeroDec(), - }, sdk.NewDecWithPrec(5, 1), "elys10d07y265gmmuvt4z0w9aw880jnsr700j6z2zm3", ) @@ -52,10 +46,6 @@ func (p Params) Validate() error { return err } - if err := validateDexRewardsLps(p.DexRewardsLps); err != nil { - return err - } - return nil } @@ -116,3 +106,9 @@ func validateDexRewardsLps(i interface{}) error { return nil } + +// String implements the Stringer interface. +func (p LegacyParams) String() string { + out, _ := yaml.Marshal(p) + return string(out) +} diff --git a/x/masterchef/types/params.pb.go b/x/masterchef/types/params.pb.go index 50df4601e..064e9b7b9 100644 --- a/x/masterchef/types/params.pb.go +++ b/x/masterchef/types/params.pb.go @@ -31,12 +31,10 @@ type Params struct { 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"` + MaxEdenRewardAprLps github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,4,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,5,rep,name=supported_reward_denoms,json=supportedRewardDenoms,proto3" json:"supported_reward_denoms,omitempty"` + ProtocolRevenueAddress string `protobuf:"bytes,6,opt,name=protocol_revenue_address,json=protocolRevenueAddress,proto3" json:"protocol_revenue_address,omitempty"` } func (m *Params) Reset() { *m = Params{} } @@ -78,13 +76,6 @@ func (m *Params) GetLpIncentives() *IncentiveInfo { 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 @@ -144,47 +135,171 @@ func (m *SupportedRewardDenom) GetDenom() string { return "" } +type LegacyDexRewardsTracker 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 *LegacyDexRewardsTracker) Reset() { *m = LegacyDexRewardsTracker{} } +func (m *LegacyDexRewardsTracker) String() string { return proto.CompactTextString(m) } +func (*LegacyDexRewardsTracker) ProtoMessage() {} +func (*LegacyDexRewardsTracker) Descriptor() ([]byte, []int) { + return fileDescriptor_bc83f5a7f5a55e20, []int{2} +} +func (m *LegacyDexRewardsTracker) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *LegacyDexRewardsTracker) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_LegacyDexRewardsTracker.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 *LegacyDexRewardsTracker) XXX_Merge(src proto.Message) { + xxx_messageInfo_LegacyDexRewardsTracker.Merge(m, src) +} +func (m *LegacyDexRewardsTracker) XXX_Size() int { + return m.Size() +} +func (m *LegacyDexRewardsTracker) XXX_DiscardUnknown() { + xxx_messageInfo_LegacyDexRewardsTracker.DiscardUnknown(m) +} + +var xxx_messageInfo_LegacyDexRewardsTracker proto.InternalMessageInfo + +// Params defines the parameters for the module. +type LegacyParams 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 LegacyDexRewardsTracker `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 *LegacyParams) Reset() { *m = LegacyParams{} } +func (*LegacyParams) ProtoMessage() {} +func (*LegacyParams) Descriptor() ([]byte, []int) { + return fileDescriptor_bc83f5a7f5a55e20, []int{3} +} +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) GetLpIncentives() *IncentiveInfo { + if m != nil { + return m.LpIncentives + } + return nil +} + +func (m *LegacyParams) GetDexRewardsLps() LegacyDexRewardsTracker { + if m != nil { + return m.DexRewardsLps + } + return LegacyDexRewardsTracker{} +} + +func (m *LegacyParams) GetSupportedRewardDenoms() []*SupportedRewardDenom { + if m != nil { + return m.SupportedRewardDenoms + } + return nil +} + +func (m *LegacyParams) GetProtocolRevenueAddress() string { + if m != nil { + return m.ProtocolRevenueAddress + } + return "" +} + func init() { proto.RegisterType((*Params)(nil), "elys.masterchef.Params") proto.RegisterType((*SupportedRewardDenom)(nil), "elys.masterchef.SupportedRewardDenom") + proto.RegisterType((*LegacyDexRewardsTracker)(nil), "elys.masterchef.LegacyDexRewardsTracker") + proto.RegisterType((*LegacyParams)(nil), "elys.masterchef.LegacyParams") } 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, -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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, + // 572 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x55, 0x4d, 0x6b, 0x13, 0x51, + 0x14, 0xcd, 0xd8, 0x24, 0xd2, 0xd7, 0x96, 0xc2, 0x58, 0x9b, 0x21, 0xc8, 0x24, 0x04, 0x94,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x9b, 0x5a, 0xe1, 0xfb, 0x4d, 0xed, 0xc9, 0x30, 0x4a, 0xcf, + 0xb3, 0xbe, 0x13, 0x30, 0xe2, 0x06, 0x4c, 0x12, 0x26, 0x67, 0x3f, 0x47, 0x32, 0x8c, 0xdd, 0x74, + 0xcc, 0x41, 0x3a, 0x5d, 0x08, 0xbc, 0x07, 0x9a, 0xed, 0x54, 0x93, 0x1d, 0x33, 0x71, 0xc2, 0xa5, + 0x19, 0xa3, 0xea, 0x1a, 0x11, 0x99, 0xe2, 0x18, 0x84, 0xb4, 0xb6, 0x36, 0x12, 0xaa, 0x2c, 0x0b, + 0x9d, 0x69, 0x3a, 0x33, 0x44, 0x15, 0x82, 0x47, 0x3e, 0x84, 0x40, 0xfd, 0x99, 0x2a, 0xe6, 0xda, + 0x52, 0x71, 0x33, 0x4b, 0x04, 0x8f, 0x5e, 0x86, 0x40, 0x3d, 0x45, 0xd6, 0xe6, 0xca, 0xd2, 0x3b, + 0x54, 0x91, 0x19, 0xcf, 0xed, 0x40, 0x38, 0x97, 0x09, 0x81, 0x32, 0x22, 0xad, 0x52, 0x7d, 0xab, + 0xb9, 0xd3, 0x7a, 0xbc, 0x32, 0x86, 0xb3, 0x79, 0xbd, 0x26, 0xea, 0xe6, 0xd5, 0xde, 0x43, 0xb9, + 0xe6, 0xad, 0x34, 0x9f, 0x21, 0x4b, 0xcd, 0x3b, 0x60, 0x89, 0x2f, 0xe0, 0x02, 0x68, 0x06, 0x3e, + 0x0e, 0x43, 0x01, 0x52, 0x5a, 0xe5, 0xdc, 0x85, 0x77, 0x38, 0xc7, 0x3d, 0x0d, 0xb7, 0x35, 0xfa, + 0xbc, 0xf8, 0xe9, 0x73, 0xad, 0xd0, 0x78, 0x8f, 0x0e, 0xd6, 0xc9, 0x99, 0x07, 0xa8, 0xa4, 0xba, + 0x54, 0xbb, 0xb2, 0xed, 0xe9, 0x07, 0xf3, 0x15, 0x42, 0x24, 0xa2, 0x3e, 0x26, 0x2c, 0xa3, 0xe9, + 0x06, 0x83, 0xef, 0xd1, 0xd4, 0xdb, 0x26, 0x11, 0x6d, 0x2b, 0x82, 0xc6, 0x57, 0x03, 0x55, 0x4e, + 0x60, 0x88, 0x83, 0x71, 0x17, 0x46, 0x5a, 0x5d, 0xbe, 0x16, 0x38, 0x88, 0x41, 0xe4, 0x52, 0x34, + 0x23, 0x7e, 0x3f, 0x61, 0x41, 0xac, 0x37, 0x76, 0x03, 0x29, 0x9a, 0x91, 0x8e, 0x22, 0x30, 0x8f, + 0x51, 0x79, 0xe3, 0xae, 0xf3, 0xd9, 0xce, 0x4e, 0x37, 0x3e, 0x94, 0xd0, 0xae, 0x6e, 0xf9, 0x7f, + 0xb8, 0xee, 0x0a, 0xd7, 0x1b, 0xb4, 0x1f, 0xc2, 0x68, 0xb6, 0xf0, 0x72, 0x11, 0xaa, 0x9d, 0x56, + 0x73, 0xe5, 0x62, 0x7e, 0xb3, 0x01, 0x9d, 0x62, 0xde, 0x8b, 0xb7, 0x17, 0x2e, 0x80, 0xdc, 0xc4, + 0x1d, 0xa1, 0x2d, 0xfd, 0x93, 0xd0, 0x96, 0xff, 0x72, 0x68, 0xef, 0xff, 0x39, 0xb4, 0x9d, 0xde, + 0xd5, 0xc4, 0x36, 0xae, 0x27, 0xb6, 0xf1, 0x63, 0x62, 0x1b, 0x1f, 0xa7, 0x76, 0xe1, 0x7a, 0x6a, + 0x17, 0xbe, 0x4d, 0xed, 0xc2, 0x5b, 0xf7, 0x96, 0xeb, 0xbc, 0xc3, 0x23, 0x0a, 0xe9, 0x25, 0x13, + 0xb1, 0x7a, 0x70, 0x47, 0xb7, 0xbf, 0x15, 0xea, 0x0a, 0xfa, 0x65, 0x25, 0xf4, 0xf4, 0x67, 0x00, + 0x00, 0x00, 0xff, 0xff, 0x0d, 0x53, 0x7e, 0x0f, 0xb1, 0x06, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -212,7 +327,7 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], m.ProtocolRevenueAddress) i = encodeVarintParams(dAtA, i, uint64(len(m.ProtocolRevenueAddress))) i-- - dAtA[i] = 0x3a + dAtA[i] = 0x32 } if len(m.SupportedRewardDenoms) > 0 { for iNdEx := len(m.SupportedRewardDenoms) - 1; iNdEx >= 0; iNdEx-- { @@ -225,7 +340,7 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintParams(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x32 + dAtA[i] = 0x2a } } { @@ -237,16 +352,6 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { 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() @@ -323,6 +428,145 @@ func (m *SupportedRewardDenom) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *LegacyDexRewardsTracker) 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 *LegacyDexRewardsTracker) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *LegacyDexRewardsTracker) 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 = encodeVarintParams(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 = encodeVarintParams(dAtA, i, uint64(size)) + } + 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.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 encodeVarintParams(dAtA []byte, offset int, v uint64) int { offset -= sovParams(v) base := offset @@ -348,8 +592,6 @@ func (m *Params) Size() (n int) { 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 { @@ -380,30 +622,74 @@ func (m *SupportedRewardDenom) Size() (n int) { 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 *LegacyDexRewardsTracker) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.NumBlocks.Size() + n += 1 + l + sovParams(uint64(l)) + l = m.Amount.Size() + n += 1 + l + sovParams(uint64(l)) + return n } -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 + +func (m *LegacyParams) 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 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) @@ -521,7 +807,41 @@ func (m *Params) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 4: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DexRewardsLps", wireType) + 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 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SupportedRewardDenoms", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -548,13 +868,14 @@ func (m *Params) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.DexRewardsLps.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + 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 5: + case 6: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field MaxEdenRewardAprLps", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ProtocolRevenueAddress", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -582,15 +903,95 @@ func (m *Params) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.MaxEdenRewardAprLps.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + 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 6: + case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SupportedRewardDenoms", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field MinAmount", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowParams @@ -600,29 +1001,79 @@ func (m *Params) 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 ErrInvalidLengthParams } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen 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 { + if err := m.MinAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex - case 7: + 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 *LegacyDexRewardsTracker) 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: LegacyDexRewardsTracker: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: LegacyDexRewardsTracker: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ProtocolRevenueAddress", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field NumBlocks", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -650,7 +1101,43 @@ func (m *Params) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ProtocolRevenueAddress = string(dAtA[iNdEx:postIndex]) + 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 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.Amount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex default: iNdEx = preIndex @@ -673,7 +1160,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { } return nil } -func (m *SupportedRewardDenom) Unmarshal(dAtA []byte) error { +func (m *LegacyParams) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -696,15 +1183,51 @@ func (m *SupportedRewardDenom) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: SupportedRewardDenom: wiretype end group for non-group") + return fmt.Errorf("proto: LegacyParams: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: SupportedRewardDenom: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: LegacyParams: 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) + 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 { @@ -732,11 +1255,13 @@ func (m *SupportedRewardDenom) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Denom = string(dAtA[iNdEx:postIndex]) + if err := m.RewardPortionForLps.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex - case 2: + case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field MinAmount", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field RewardPortionForStakers", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -764,10 +1289,143 @@ func (m *SupportedRewardDenom) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.MinAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + 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:]) diff --git a/x/masterchef/types/pool.pb.go b/x/masterchef/types/pool.pb.go index a919f54a8..61617da07 100644 --- a/x/masterchef/types/pool.pb.go +++ b/x/masterchef/types/pool.pb.go @@ -24,28 +24,22 @@ var _ = math.Inf // 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"` + EdenApr github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,4,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"` + DexApr github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,5,opt,name=dex_apr,json=dexApr,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"dex_apr"` + // Gas APR, updated at every distribution + GasApr github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,6,opt,name=gas_apr,json=gasApr,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"gas_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"` + ExternalIncentiveApr github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,7,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"` + ExternalRewardDenoms []string `protobuf:"bytes,8,rep,name=external_reward_denoms,json=externalRewardDenoms,proto3" json:"external_reward_denoms,omitempty"` } func (m *PoolInfo) Reset() { *m = PoolInfo{} } @@ -225,52 +219,192 @@ func (m *UserRewardInfo) GetRewardDenom() string { return "" } +type PoolRewardsAccum struct { + PoolId uint64 `protobuf:"varint,1,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty"` + BlockHeight int64 `protobuf:"varint,2,opt,name=block_height,json=blockHeight,proto3" json:"block_height,omitempty"` + Timestamp uint64 `protobuf:"varint,3,opt,name=timestamp,proto3" json:"timestamp,omitempty"` + DexReward github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,4,opt,name=dex_reward,json=dexReward,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"dex_reward"` + GasReward github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,5,opt,name=gas_reward,json=gasReward,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"gas_reward"` + EdenReward github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,6,opt,name=eden_reward,json=edenReward,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"eden_reward"` +} + +func (m *PoolRewardsAccum) Reset() { *m = PoolRewardsAccum{} } +func (m *PoolRewardsAccum) String() string { return proto.CompactTextString(m) } +func (*PoolRewardsAccum) ProtoMessage() {} +func (*PoolRewardsAccum) Descriptor() ([]byte, []int) { + return fileDescriptor_eeebce6928738c2c, []int{3} +} +func (m *PoolRewardsAccum) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PoolRewardsAccum) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PoolRewardsAccum.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 *PoolRewardsAccum) XXX_Merge(src proto.Message) { + xxx_messageInfo_PoolRewardsAccum.Merge(m, src) +} +func (m *PoolRewardsAccum) XXX_Size() int { + return m.Size() +} +func (m *PoolRewardsAccum) XXX_DiscardUnknown() { + xxx_messageInfo_PoolRewardsAccum.DiscardUnknown(m) +} + +var xxx_messageInfo_PoolRewardsAccum proto.InternalMessageInfo + +func (m *PoolRewardsAccum) GetPoolId() uint64 { + if m != nil { + return m.PoolId + } + return 0 +} + +func (m *PoolRewardsAccum) GetBlockHeight() int64 { + if m != nil { + return m.BlockHeight + } + return 0 +} + +func (m *PoolRewardsAccum) GetTimestamp() uint64 { + if m != nil { + return m.Timestamp + } + return 0 +} + +type LegacyPoolInfo struct { + PoolId uint64 `protobuf:"varint,1,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty"` + RewardWallet string `protobuf:"bytes,2,opt,name=reward_wallet,json=rewardWallet,proto3" json:"reward_wallet,omitempty"` + 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"` + 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"` + 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"` + 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"` + 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"` + 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"` + 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"` + ExternalRewardDenoms []string `protobuf:"bytes,10,rep,name=external_reward_denoms,json=externalRewardDenoms,proto3" json:"external_reward_denoms,omitempty"` +} + +func (m *LegacyPoolInfo) Reset() { *m = LegacyPoolInfo{} } +func (m *LegacyPoolInfo) String() string { return proto.CompactTextString(m) } +func (*LegacyPoolInfo) ProtoMessage() {} +func (*LegacyPoolInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_eeebce6928738c2c, []int{4} +} +func (m *LegacyPoolInfo) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *LegacyPoolInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_LegacyPoolInfo.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 *LegacyPoolInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_LegacyPoolInfo.Merge(m, src) +} +func (m *LegacyPoolInfo) XXX_Size() int { + return m.Size() +} +func (m *LegacyPoolInfo) XXX_DiscardUnknown() { + xxx_messageInfo_LegacyPoolInfo.DiscardUnknown(m) +} + +var xxx_messageInfo_LegacyPoolInfo proto.InternalMessageInfo + +func (m *LegacyPoolInfo) GetPoolId() uint64 { + if m != nil { + return m.PoolId + } + return 0 +} + +func (m *LegacyPoolInfo) GetRewardWallet() string { + if m != nil { + return m.RewardWallet + } + return "" +} + +func (m *LegacyPoolInfo) GetExternalRewardDenoms() []string { + if m != nil { + return m.ExternalRewardDenoms + } + return nil +} + func init() { proto.RegisterType((*PoolInfo)(nil), "elys.masterchef.PoolInfo") proto.RegisterType((*PoolRewardInfo)(nil), "elys.masterchef.PoolRewardInfo") proto.RegisterType((*UserRewardInfo)(nil), "elys.masterchef.UserRewardInfo") + proto.RegisterType((*PoolRewardsAccum)(nil), "elys.masterchef.PoolRewardsAccum") + proto.RegisterType((*LegacyPoolInfo)(nil), "elys.masterchef.LegacyPoolInfo") } 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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05, 0x00, - 0x00, + // 692 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x96, 0xcd, 0x4e, 0xdb, 0x4a, + 0x14, 0x80, 0xf3, 0x47, 0x12, 0x9f, 0x70, 0x73, 0xd1, 0x08, 0x2e, 0xb9, 0xe8, 0x2a, 0x70, 0x53, + 0xa9, 0x62, 0x51, 0x92, 0x45, 0xfb, 0x02, 0x41, 0x48, 0x34, 0x52, 0x29, 0xc8, 0x15, 0xaa, 0xd4, + 0x8d, 0x35, 0xb1, 0x0f, 0x8e, 0x85, 0x3d, 0x63, 0xcd, 0x8c, 0x21, 0xbc, 0x41, 0x97, 0xed, 0x5b, + 0xb1, 0x64, 0x59, 0xb5, 0x12, 0xaa, 0xa0, 0xdb, 0xbe, 0x43, 0x35, 0x63, 0x07, 0xbb, 0xaa, 0x60, + 0xe1, 0x56, 0x55, 0x57, 0x89, 0xcf, 0x99, 0xf9, 0xe6, 0xfc, 0xce, 0x19, 0xd8, 0xc0, 0xf0, 0x42, + 0x8e, 0x22, 0x2a, 0x15, 0x0a, 0x77, 0x86, 0x27, 0xa3, 0x98, 0xf3, 0x70, 0x18, 0x0b, 0xae, 0x38, + 0xf9, 0x5b, 0xeb, 0x86, 0xb9, 0x6e, 0x63, 0xd5, 0xe7, 0x3e, 0x37, 0xba, 0x91, 0xfe, 0x97, 0x2e, + 0x1b, 0xbc, 0x6f, 0x40, 0xfb, 0x88, 0xf3, 0x70, 0xc2, 0x4e, 0x38, 0x59, 0x87, 0x96, 0x26, 0x38, + 0x81, 0xd7, 0xab, 0x6e, 0x55, 0xb7, 0x1b, 0x76, 0x53, 0x7f, 0x4e, 0x3c, 0xf2, 0x08, 0xfe, 0x12, + 0x78, 0x4e, 0x85, 0xe7, 0x9c, 0xd3, 0x30, 0x44, 0xd5, 0xab, 0x6d, 0x55, 0xb7, 0x2d, 0x7b, 0x39, + 0x15, 0xbe,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0xba, 0x17, + 0x7f, 0xe8, 0x4d, 0x7b, 0x00, 0xc0, 0x92, 0x28, 0x6d, 0x17, 0x59, 0x22, 0x1f, 0x13, 0xa6, 0x6c, + 0x8b, 0x25, 0x91, 0xe9, 0x2b, 0x49, 0x10, 0xd6, 0xf3, 0xf4, 0x3a, 0x34, 0xe2, 0x09, 0x53, 0x8e, + 0x1f, 0x9c, 0x21, 0x2b, 0x99, 0x9c, 0xd5, 0xbb, 0x5c, 0x8f, 0x0d, 0x6c, 0x5f, 0xb3, 0x88, 0x0f, + 0xbd, 0x42, 0x9e, 0xbe, 0x3f, 0xa7, 0x59, 0xca, 0x87, 0xb5, 0x3c, 0x69, 0xc5, 0x83, 0x8a, 0x83, + 0xa8, 0xf5, 0xcb, 0x06, 0x51, 0xfb, 0xa7, 0x06, 0xd1, 0xfd, 0xf3, 0xc3, 0xfa, 0x2d, 0xf3, 0x03, + 0xee, 0x9f, 0x1f, 0xbb, 0x93, 0xcb, 0x9b, 0x7e, 0xf5, 0xea, 0xa6, 0x5f, 0xfd, 0x7c, 0xd3, 0xaf, + 0xbe, 0xbb, 0xed, 0x57, 0xae, 0x6e, 0xfb, 0x95, 0x0f, 0xb7, 0xfd, 0xca, 0x9b, 0x51, 0xc1, 0x1a, + 0xfd, 0x3e, 0xd9, 0x61, 0xa8, 0xce, 0xb9, 0x38, 0x35, 0x1f, 0xa3, 0x79, 0xf1, 0x29, 0x63, 0x4c, + 0x9b, 0x36, 0xcd, 0x2b, 0xe5, 0xe9, 0xb7, 0x00, 0x00, 0x00, 0xff, 0xff, 0xe4, 0x8a, 0xb2, 0x80, + 0xea, 0x08, 0x00, 0x00, } func (m *PoolInfo) Marshal() (dAtA []byte, err error) { @@ -299,7 +433,7 @@ func (m *PoolInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], m.ExternalRewardDenoms[iNdEx]) i = encodeVarintPool(dAtA, i, uint64(len(m.ExternalRewardDenoms[iNdEx]))) i-- - dAtA[i] = 0x52 + dAtA[i] = 0x42 } } { @@ -311,31 +445,11 @@ func (m *PoolInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { 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() + size := m.GasApr.Size() i -= size - if _, err := m.EdenRewardAmountGiven.MarshalTo(dAtA[i:]); err != nil { + if _, err := m.GasApr.MarshalTo(dAtA[i:]); err != nil { return 0, err } i = encodeVarintPool(dAtA, i, uint64(size)) @@ -343,9 +457,9 @@ func (m *PoolInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x32 { - size := m.DexRewardAmountGiven.Size() + size := m.DexApr.Size() i -= size - if _, err := m.DexRewardAmountGiven.MarshalTo(dAtA[i:]); err != nil { + if _, err := m.DexApr.MarshalTo(dAtA[i:]); err != nil { return 0, err } i = encodeVarintPool(dAtA, i, uint64(size)) @@ -353,9 +467,9 @@ func (m *PoolInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x2a { - size := m.NumBlocks.Size() + size := m.EdenApr.Size() i -= size - if _, err := m.NumBlocks.MarshalTo(dAtA[i:]); err != nil { + if _, err := m.EdenApr.MarshalTo(dAtA[i:]); err != nil { return 0, err } i = encodeVarintPool(dAtA, i, uint64(size)) @@ -499,98 +613,336 @@ func (m *UserRewardInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { 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++ +func (m *PoolRewardsAccum) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } - dAtA[offset] = uint8(v) - return base + return dAtA[:n], nil } -func (m *PoolInfo) Size() (n int) { - if m == nil { - return 0 - } + +func (m *PoolRewardsAccum) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PoolRewardsAccum) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i 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)) + { + size := m.EdenReward.Size() + i -= size + if _, err := m.EdenReward.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintPool(dAtA, i, uint64(size)) } - 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)) + i-- + dAtA[i] = 0x32 + { + size := m.GasReward.Size() + i -= size + if _, err := m.GasReward.MarshalTo(dAtA[i:]); err != nil { + return 0, err } + i = encodeVarintPool(dAtA, i, uint64(size)) } - return n -} - -func (m *PoolRewardInfo) Size() (n int) { - if m == nil { - return 0 + i-- + dAtA[i] = 0x2a + { + size := m.DexReward.Size() + i -= size + if _, err := m.DexReward.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintPool(dAtA, i, uint64(size)) } - var l int - _ = l - if m.PoolId != 0 { - n += 1 + sovPool(uint64(m.PoolId)) + i-- + dAtA[i] = 0x22 + if m.Timestamp != 0 { + i = encodeVarintPool(dAtA, i, uint64(m.Timestamp)) + i-- + dAtA[i] = 0x18 } - l = len(m.RewardDenom) - if l > 0 { - n += 1 + l + sovPool(uint64(l)) + if m.BlockHeight != 0 { + i = encodeVarintPool(dAtA, i, uint64(m.BlockHeight)) + i-- + dAtA[i] = 0x10 } - l = m.PoolAccRewardPerShare.Size() - n += 1 + l + sovPool(uint64(l)) - if m.LastUpdatedBlock != 0 { - n += 1 + sovPool(uint64(m.LastUpdatedBlock)) + if m.PoolId != 0 { + i = encodeVarintPool(dAtA, i, uint64(m.PoolId)) + i-- + dAtA[i] = 0x8 } - return n + return len(dAtA) - i, nil } -func (m *UserRewardInfo) Size() (n int) { - if m == nil { - return 0 +func (m *LegacyPoolInfo) 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 *LegacyPoolInfo) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *LegacyPoolInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - l = len(m.User) - if l > 0 { - n += 1 + l + sovPool(uint64(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 + } } - if m.PoolId != 0 { - n += 1 + sovPool(uint64(m.PoolId)) + { + size := m.ExternalIncentiveApr.Size() + i -= size + if _, err := m.ExternalIncentiveApr.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintPool(dAtA, i, uint64(size)) } - l = len(m.RewardDenom) - if l > 0 { - n += 1 + l + sovPool(uint64(l)) + 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)) } - l = m.RewardDebt.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 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.EdenApr.Size() + n += 1 + l + sovPool(uint64(l)) + l = m.DexApr.Size() + n += 1 + l + sovPool(uint64(l)) + l = m.GasApr.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 (m *PoolRewardsAccum) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PoolId != 0 { + n += 1 + sovPool(uint64(m.PoolId)) + } + if m.BlockHeight != 0 { + n += 1 + sovPool(uint64(m.BlockHeight)) + } + if m.Timestamp != 0 { + n += 1 + sovPool(uint64(m.Timestamp)) + } + l = m.DexReward.Size() + n += 1 + l + sovPool(uint64(l)) + l = m.GasReward.Size() + n += 1 + l + sovPool(uint64(l)) + l = m.EdenReward.Size() + n += 1 + l + sovPool(uint64(l)) + return n +} + +func (m *LegacyPoolInfo) 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 sovPool(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -713,7 +1065,41 @@ func (m *PoolInfo) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 4: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field NumBlocks", wireType) + 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 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DexApr", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -738,18 +1124,523 @@ func (m *PoolInfo) Unmarshal(dAtA []byte) error { if postIndex < 0 { return ErrInvalidLengthPool } - if postIndex > l { + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.DexApr.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field GasApr", 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.GasApr.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 7: + 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 8: + 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 (m *PoolRewardsAccum) 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 } - if err := m.NumBlocks.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break } - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DexRewardAmountGiven", wireType) + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: PoolRewardsAccum: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PoolRewardsAccum: 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) } - var stringLen uint64 + m.PoolId = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowPool @@ -759,31 +1650,16 @@ func (m *PoolInfo) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + m.PoolId |= 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) + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field BlockHeight", wireType) } - var stringLen uint64 + m.BlockHeight = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowPool @@ -793,31 +1669,16 @@ func (m *PoolInfo) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + m.BlockHeight |= int64(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) + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Timestamp", wireType) } - var stringLen uint64 + m.Timestamp = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowPool @@ -827,29 +1688,14 @@ func (m *PoolInfo) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + m.Timestamp |= 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: + case 4: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DexApr", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field DexReward", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -877,13 +1723,13 @@ func (m *PoolInfo) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.DexApr.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.DexReward.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex - case 9: + case 5: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ExternalIncentiveApr", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field GasReward", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -911,13 +1757,13 @@ func (m *PoolInfo) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.ExternalIncentiveApr.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.GasReward.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex - case 10: + case 6: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ExternalRewardDenoms", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field EdenReward", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -945,7 +1791,9 @@ func (m *PoolInfo) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ExternalRewardDenoms = append(m.ExternalRewardDenoms, string(dAtA[iNdEx:postIndex])) + if err := m.EdenReward.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex default: iNdEx = preIndex @@ -968,7 +1816,7 @@ func (m *PoolInfo) Unmarshal(dAtA []byte) error { } return nil } -func (m *PoolRewardInfo) Unmarshal(dAtA []byte) error { +func (m *LegacyPoolInfo) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -991,10 +1839,10 @@ func (m *PoolRewardInfo) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: PoolRewardInfo: wiretype end group for non-group") + return fmt.Errorf("proto: LegacyPoolInfo: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: PoolRewardInfo: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: LegacyPoolInfo: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -1018,7 +1866,7 @@ func (m *PoolRewardInfo) Unmarshal(dAtA []byte) error { } case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RewardDenom", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field RewardWallet", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1046,11 +1894,11 @@ func (m *PoolRewardInfo) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.RewardDenom = string(dAtA[iNdEx:postIndex]) + m.RewardWallet = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PoolAccRewardPerShare", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Multiplier", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1078,15 +1926,15 @@ func (m *PoolRewardInfo) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.PoolAccRewardPerShare.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.Multiplier.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) + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NumBlocks", wireType) } - m.LastUpdatedBlock = 0 + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowPool @@ -1096,64 +1944,63 @@ func (m *PoolRewardInfo) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.LastUpdatedBlock |= uint64(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - default: - iNdEx = preIndex - skippy, err := skipPool(dAtA[iNdEx:]) - if err != nil { - return err + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthPool } - if (skippy < 0) || (iNdEx+skippy) < 0 { + postIndex := iNdEx + intStringLen + if postIndex < 0 { return ErrInvalidLengthPool } - if (iNdEx + skippy) > l { + if postIndex > 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 err := m.NumBlocks.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err } - if iNdEx >= l { + 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 } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break + if err := m.DexRewardAmountGiven.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err } - } - 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: + iNdEx = postIndex + case 6: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field User", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field EdenRewardAmountGiven", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1181,13 +2028,15 @@ func (m *UserRewardInfo) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.User = string(dAtA[iNdEx:postIndex]) + if err := m.EdenRewardAmountGiven.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field PoolId", wireType) + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EdenApr", wireType) } - m.PoolId = 0 + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowPool @@ -1197,14 +2046,29 @@ func (m *UserRewardInfo) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.PoolId |= uint64(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - case 3: + 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 RewardDenom", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field DexApr", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1232,11 +2096,13 @@ func (m *UserRewardInfo) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.RewardDenom = string(dAtA[iNdEx:postIndex]) + if err := m.DexApr.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex - case 4: + case 9: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RewardDebt", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ExternalIncentiveApr", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1264,13 +2130,13 @@ func (m *UserRewardInfo) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.RewardDebt.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.ExternalIncentiveApr.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex - case 5: + case 10: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RewardPending", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ExternalRewardDenoms", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1298,9 +2164,7 @@ func (m *UserRewardInfo) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.RewardPending.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.ExternalRewardDenoms = append(m.ExternalRewardDenoms, string(dAtA[iNdEx:postIndex])) iNdEx = postIndex default: iNdEx = preIndex diff --git a/x/parameter/migrations/v2_migration.go b/x/parameter/migrations/v2_migration.go deleted file mode 100644 index 3b85d7ac6..000000000 --- a/x/parameter/migrations/v2_migration.go +++ /dev/null @@ -1,23 +0,0 @@ -package migrations - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/elys-network/elys/x/parameter/types" -) - -func (m Migrator) V2Migration(ctx sdk.Context) error { - // reset params - params := types.NewParams( - sdk.NewDecWithPrec(5, 2), // min commission 0.05 - sdk.NewDecWithPrec(66, 1), // max voting power - sdk.NewInt(1), // min self delegation - "elys1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqnrec2l", // broker address - 6307200, // total blocks per year - sdk.NewInt(256), - sdk.NewInt(1638400), - sdk.NewInt(6291456), - ) - m.keeper.SetParams(ctx, params) - - return nil -} diff --git a/x/parameter/migrations/v3_migration.go b/x/parameter/migrations/v3_migration.go deleted file mode 100644 index 3e3637d16..000000000 --- a/x/parameter/migrations/v3_migration.go +++ /dev/null @@ -1,24 +0,0 @@ -package migrations - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/elys-network/elys/x/parameter/types" -) - -func (m Migrator) V3Migration(ctx sdk.Context) error { - // reset params - legacy := m.keeper.GetLegacyParams(ctx) - params := types.NewParams( - legacy.MinCommissionRate, // min commission 0.05 - legacy.MaxVotingPower, // max voting power 0.66 - legacy.MinSelfDelegation, // min self delegation - legacy.BrokerAddress, // broker address - 6307200, // total blocks per year - sdk.NewInt(256), - sdk.NewInt(1638400), - sdk.NewInt(6291456), - ) - m.keeper.SetParams(ctx, params) - - return nil -} diff --git a/x/parameter/migrations/v4_migration.go b/x/parameter/migrations/v4_migration.go new file mode 100644 index 000000000..443cb19de --- /dev/null +++ b/x/parameter/migrations/v4_migration.go @@ -0,0 +1,25 @@ +package migrations + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/elys-network/elys/x/parameter/types" +) + +func (m Migrator) V4Migration(ctx sdk.Context) error { + // reset params + legacy := m.keeper.GetLegacyParams(ctx) + params := types.NewParams( + legacy.MinCommissionRate, // min commission 0.05 + legacy.MaxVotingPower, // max voting power 0.66 + legacy.MinSelfDelegation, // min self delegation + legacy.BrokerAddress, // broker address + legacy.TotalBlocksPerYear, // total blocks per year + 86400, // 24 hrs + sdk.NewInt(256), + sdk.NewInt(1638400), + sdk.NewInt(6291456), + ) + m.keeper.SetParams(ctx, params) + + return nil +} diff --git a/x/parameter/module.go b/x/parameter/module.go index 77ffe70b3..31b532e9a 100644 --- a/x/parameter/module.go +++ b/x/parameter/module.go @@ -117,7 +117,7 @@ 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, 2, m.V3Migration) + err := cfg.RegisterMigration(types.ModuleName, 3, m.V4Migration) if err != nil { panic(err) } diff --git a/x/parameter/types/params.go b/x/parameter/types/params.go index 9b20be478..b9a5981df 100644 --- a/x/parameter/types/params.go +++ b/x/parameter/types/params.go @@ -13,6 +13,7 @@ func NewParams( minSelfDelegation math.Int, brokerAddress string, totalBlocksPerYear int64, + rewardsDataLifeTime int64, wasmMaxLabelSize math.Int, wasmMaxSize math.Int, wasmMaxProposalWasmSize math.Int, @@ -23,6 +24,7 @@ func NewParams( MinSelfDelegation: minSelfDelegation, BrokerAddress: brokerAddress, TotalBlocksPerYear: totalBlocksPerYear, + RewardsDataLifetime: rewardsDataLifeTime, WasmMaxLabelSize: wasmMaxLabelSize, WasmMaxSize: wasmMaxSize, WasmMaxProposalWasmSize: wasmMaxProposalWasmSize, @@ -37,6 +39,7 @@ func DefaultParams() Params { sdk.OneInt(), "elys1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqnrec2l", 6307200, + 86400, // 1 day sdk.NewInt(256), //128*2 sdk.NewInt(1638400), //819200 * 2 sdk.NewInt(6291456), //3145728 * 2 diff --git a/x/parameter/types/params.pb.go b/x/parameter/types/params.pb.go index e3ffb66b1..58ecdfc53 100644 --- a/x/parameter/types/params.pb.go +++ b/x/parameter/types/params.pb.go @@ -31,9 +31,10 @@ type Params struct { MinSelfDelegation github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=min_self_delegation,json=minSelfDelegation,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"min_self_delegation"` BrokerAddress string `protobuf:"bytes,4,opt,name=broker_address,json=brokerAddress,proto3" json:"broker_address,omitempty"` TotalBlocksPerYear int64 `protobuf:"varint,5,opt,name=total_blocks_per_year,json=totalBlocksPerYear,proto3" json:"total_blocks_per_year,omitempty"` - WasmMaxLabelSize github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,6,opt,name=wasm_max_label_size,json=wasmMaxLabelSize,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"wasm_max_label_size"` - WasmMaxSize github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,7,opt,name=wasm_max_size,json=wasmMaxSize,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"wasm_max_size"` - WasmMaxProposalWasmSize github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,8,opt,name=wasm_max_proposal_wasm_size,json=wasmMaxProposalWasmSize,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"wasm_max_proposal_wasm_size"` + RewardsDataLifetime int64 `protobuf:"varint,6,opt,name=rewards_data_lifetime,json=rewardsDataLifetime,proto3" json:"rewards_data_lifetime,omitempty"` + WasmMaxLabelSize github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,7,opt,name=wasm_max_label_size,json=wasmMaxLabelSize,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"wasm_max_label_size"` + WasmMaxSize github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,8,opt,name=wasm_max_size,json=wasmMaxSize,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"wasm_max_size"` + WasmMaxProposalWasmSize github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,9,opt,name=wasm_max_proposal_wasm_size,json=wasmMaxProposalWasmSize,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"wasm_max_proposal_wasm_size"` } func (m *Params) Reset() { *m = Params{} } @@ -82,11 +83,19 @@ func (m *Params) GetTotalBlocksPerYear() int64 { return 0 } +func (m *Params) GetRewardsDataLifetime() int64 { + if m != nil { + return m.RewardsDataLifetime + } + return 0 +} + type LegacyParams struct { - MinCommissionRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,1,opt,name=min_commission_rate,json=minCommissionRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"min_commission_rate"` - MaxVotingPower github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=max_voting_power,json=maxVotingPower,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"max_voting_power"` - MinSelfDelegation github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=min_self_delegation,json=minSelfDelegation,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"min_self_delegation"` - BrokerAddress string `protobuf:"bytes,4,opt,name=broker_address,json=brokerAddress,proto3" json:"broker_address,omitempty"` + MinCommissionRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,1,opt,name=min_commission_rate,json=minCommissionRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"min_commission_rate"` + MaxVotingPower github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=max_voting_power,json=maxVotingPower,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"max_voting_power"` + MinSelfDelegation github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=min_self_delegation,json=minSelfDelegation,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"min_self_delegation"` + BrokerAddress string `protobuf:"bytes,4,opt,name=broker_address,json=brokerAddress,proto3" json:"broker_address,omitempty"` + TotalBlocksPerYear int64 `protobuf:"varint,5,opt,name=total_blocks_per_year,json=totalBlocksPerYear,proto3" json:"total_blocks_per_year,omitempty"` } func (m *LegacyParams) Reset() { *m = LegacyParams{} } @@ -128,6 +137,13 @@ func (m *LegacyParams) GetBrokerAddress() string { return "" } +func (m *LegacyParams) GetTotalBlocksPerYear() int64 { + if m != nil { + return m.TotalBlocksPerYear + } + return 0 +} + func init() { proto.RegisterType((*Params)(nil), "elys.parameter.Params") proto.RegisterType((*LegacyParams)(nil), "elys.parameter.LegacyParams") @@ -136,36 +152,38 @@ func init() { func init() { proto.RegisterFile("elys/parameter/params.proto", fileDescriptor_b61780a5be327c2b) } var fileDescriptor_b61780a5be327c2b = []byte{ - // 453 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x94, 0xcf, 0x6b, 0xd4, 0x40, - 0x14, 0xc7, 0x93, 0xfe, 0x58, 0x75, 0xb4, 0x4b, 0x4d, 0x15, 0x83, 0x85, 0x6c, 0x29, 0x28, 0xbd, - 0x34, 0x41, 0xbc, 0x79, 0x73, 0xed, 0x41, 0xa1, 0xc2, 0x92, 0x82, 0xbf, 0x40, 0x87, 0x97, 0xec, - 0x6b, 0x0c, 0x3b, 0x93, 0x17, 0x66, 0x46, 0x77, 0xb7, 0x7f, 0x85, 0x47, 0x8f, 0x82, 0xff, 0x4c, - 0x8f, 0xbd, 0x08, 0xe2, 0xa1, 0xc8, 0xee, 0x3f, 0x22, 0x33, 0x59, 0xc3, 0x5e, 0x5d, 0x3c, 0xf6, - 0x94, 0x97, 0xf7, 0x4d, 0x3e, 0xdf, 0x2f, 0x8f, 0xc7, 0x63, 0xbb, 0x28, 0xa6, 0x3a, 0xa9, 0x41, - 0x81, 0x44, 0x83, 0xaa, 0xa9, 0x74, 0x5c, 0x2b, 0x32, 0x14, 0x74, 0xad, 0x18, 0xb7, 0xe2, 0xfd, - 0x3b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6f, 0x11, 0x54, 0xf0, 0x9e, 0xed, 0x8c, 0x41, - 0x4b, 0x6e, 0x07, 0x23, 0x20, 0x43, 0xc1, 0x75, 0x79, 0x86, 0x61, 0x67, 0xa5, 0xe4, 0xdb, 0x16, - 0xf5, 0x12, 0x26, 0xc7, 0x16, 0x74, 0x52, 0x9e, 0x61, 0x90, 0xb2, 0xad, 0x16, 0xef, 0xc0, 0xd7, - 0x56, 0x02, 0xdf, 0x5c, 0x80, 0x1d, 0x53, 0xb0, 0xdd, 0x96, 0x59, 0x2b, 0xaa, 0x49, 0x83, 0xe0, - 0xae, 0xe3, 0x1c, 0xae, 0xaf, 0xe4, 0x70, 0x6f, 0xe1, 0x30, 0x58, 0x00, 0x5f, 0x83, 0x96, 0xd6, - 0xed, 0xc9, 0xc6, 0xd7, 0x6f, 0x3d, 0x6f, 0xff, 0xc7, 0x1a, 0xbb, 0x75, 0x8c, 0x05, 0xe4, 0xd3, - 0xab, 0x5d, 0xfd, 0x2f, 0xbb, 0xda, 0xcc, 0xb5, 0xff, 0xfc, 0x7c, 0x16, 0xf9, 0x17, 0xb3, 0xc8, - 0xff, 0x3d, 0x8b, 0xfc, 0x2f, 0xf3, 0xc8, 0xbb, 0x98, 0x47, 0xde, 0xcf, 0x79, 0xe4, 0xbd, 0x8b, - 0x97, 0x12, 0xd8, 0x43, 0x72, 0x58, 0xa1, 0x19, 0x93, 0x1a, 0xb9, 0x97, 0x64, 0xb2, 0x74, 0x74, - 0x5c, 0x9a, 0xac, 0xe3, 0xce, 0xc9, 0xe3, 0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xf9, 0x49, 0xa7, - 0xd8, 0x93, 0x04, 0x00, 0x00, + // 483 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x94, 0x4f, 0x6f, 0xd3, 0x4c, + 0x10, 0xc6, 0xed, 0x37, 0x6d, 0x5e, 0xba, 0x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0e, 0x93, 0x06, 0xf8, 0x12, 0xb4, 0xa8, 0xdc, 0x1e, 0x6d, + 0x7d, 0xf9, 0x3a, 0x70, 0x8e, 0x3e, 0x75, 0xc8, 0x8d, 0x31, 0xe6, 0x90, 0x2e, 0xff, 0xcd, 0xf7, + 0xdf, 0x9a, 0xef, 0xfa, 0x2a, 0x86, 0x4f, 0xcf, 0x57, 0x81, 0x7b, 0xb1, 0x0a, 0xdc, 0x9f, 0xab, + 0xc0, 0xfd, 0xbc, 0x0e, 0x9c, 0x8b, 0x75, 0xe0, 0x7c, 0x5f, 0x07, 0xce, 0x9b, 0xf0, 0x4a, 0xd1, + 0xd5, 0xbe, 0x3a, 0x29, 0xd0, 0xcc, 0xa5, 0x9a, 0xd9, 0x97, 0x68, 0x71, 0x65, 0xb7, 0xd9, 0x06, + 0x92, 0xae, 0xdd, 0x5a, 0x0f, 0x7f, 0x05, 0x00, 0x00, 0xff, 0xff, 0xc6, 0xb0, 0x27, 0x6a, 0xfa, + 0x04, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -197,7 +215,7 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintParams(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x42 + dAtA[i] = 0x4a { size := m.WasmMaxSize.Size() i -= size @@ -207,7 +225,7 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintParams(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x3a + dAtA[i] = 0x42 { size := m.WasmMaxLabelSize.Size() i -= size @@ -217,7 +235,12 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintParams(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x32 + dAtA[i] = 0x3a + if m.RewardsDataLifetime != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.RewardsDataLifetime)) + i-- + dAtA[i] = 0x30 + } if m.TotalBlocksPerYear != 0 { i = encodeVarintParams(dAtA, i, uint64(m.TotalBlocksPerYear)) i-- @@ -283,6 +306,11 @@ func (m *LegacyParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.TotalBlocksPerYear != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.TotalBlocksPerYear)) + i-- + dAtA[i] = 0x28 + } if len(m.BrokerAddress) > 0 { i -= len(m.BrokerAddress) copy(dAtA[i:], m.BrokerAddress) @@ -353,6 +381,9 @@ func (m *Params) Size() (n int) { if m.TotalBlocksPerYear != 0 { n += 1 + sovParams(uint64(m.TotalBlocksPerYear)) } + if m.RewardsDataLifetime != 0 { + n += 1 + sovParams(uint64(m.RewardsDataLifetime)) + } l = m.WasmMaxLabelSize.Size() n += 1 + l + sovParams(uint64(l)) l = m.WasmMaxSize.Size() @@ -378,6 +409,9 @@ func (m *LegacyParams) Size() (n int) { if l > 0 { n += 1 + l + sovParams(uint64(l)) } + if m.TotalBlocksPerYear != 0 { + n += 1 + sovParams(uint64(m.TotalBlocksPerYear)) + } return n } @@ -570,6 +604,25 @@ func (m *Params) Unmarshal(dAtA []byte) error { } } case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field RewardsDataLifetime", wireType) + } + m.RewardsDataLifetime = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.RewardsDataLifetime |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 7: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field WasmMaxLabelSize", wireType) } @@ -603,7 +656,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 7: + case 8: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field WasmMaxSize", wireType) } @@ -637,7 +690,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 8: + case 9: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field WasmMaxProposalWasmSize", wireType) } @@ -855,6 +908,25 @@ func (m *LegacyParams) Unmarshal(dAtA []byte) error { } m.BrokerAddress = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field TotalBlocksPerYear", wireType) + } + m.TotalBlocksPerYear = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.TotalBlocksPerYear |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipParams(dAtA[iNdEx:]) diff --git a/x/perpetual/keeper/close.go b/x/perpetual/keeper/close.go index 8628ad29f..c7420dc2c 100644 --- a/x/perpetual/keeper/close.go +++ b/x/perpetual/keeper/close.go @@ -46,3 +46,7 @@ func (k Keeper) Close(ctx sdk.Context, msg *types.MsgClose) (*types.MsgCloseResp Amount: repayAmount, }, nil } + +func (k Keeper) EmitCloseEvent(ctx sdk.Context, mtp *types.MTP, repayAmount math.Int) { + ctx.EventManager().EmitEvent(types.GenerateCloseEvent(mtp, repayAmount)) +} diff --git a/x/perpetual/keeper/emit_close_event.go b/x/perpetual/keeper/emit_close_event.go deleted file mode 100644 index f7312c2fb..000000000 --- a/x/perpetual/keeper/emit_close_event.go +++ /dev/null @@ -1,11 +0,0 @@ -package keeper - -import ( - "cosmossdk.io/math" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/elys-network/elys/x/perpetual/types" -) - -func (k Keeper) EmitCloseEvent(ctx sdk.Context, mtp *types.MTP, repayAmount math.Int) { - ctx.EventManager().EmitEvent(types.GenerateCloseEvent(mtp, repayAmount)) -} diff --git a/x/perpetual/keeper/emit_open_event.go b/x/perpetual/keeper/emit_open_event.go deleted file mode 100644 index bc62c7983..000000000 --- a/x/perpetual/keeper/emit_open_event.go +++ /dev/null @@ -1,10 +0,0 @@ -package keeper - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/elys-network/elys/x/perpetual/types" -) - -func (k Keeper) EmitOpenEvent(ctx sdk.Context, mtp *types.MTP) { - ctx.EventManager().EmitEvent(types.GenerateOpenEvent(mtp)) -} diff --git a/x/perpetual/keeper/estimate_and_repay.go b/x/perpetual/keeper/estimate_and_repay.go index fe50a31bf..811ba9a17 100644 --- a/x/perpetual/keeper/estimate_and_repay.go +++ b/x/perpetual/keeper/estimate_and_repay.go @@ -9,7 +9,7 @@ import ( func (k Keeper) EstimateAndRepay(ctx sdk.Context, mtp types.MTP, pool types.Pool, ammPool ammtypes.Pool, amount math.Int, baseCurrency string) (math.Int, error) { // init repay amount - repayAmount := sdk.ZeroInt() + var repayAmount math.Int var err error // if position is long, repay in collateral asset diff --git a/x/perpetual/keeper/get_epoch_length.go b/x/perpetual/keeper/get_epoch_length.go deleted file mode 100644 index eaeb42325..000000000 --- a/x/perpetual/keeper/get_epoch_length.go +++ /dev/null @@ -1,7 +0,0 @@ -package keeper - -import sdk "github.com/cosmos/cosmos-sdk/types" - -func (k Keeper) GetEpochLength(ctx sdk.Context) int64 { - return k.GetParams(ctx).EpochLength -} diff --git a/x/perpetual/keeper/get_mtp.go b/x/perpetual/keeper/get_mtp.go deleted file mode 100644 index e89bccaa8..000000000 --- a/x/perpetual/keeper/get_mtp.go +++ /dev/null @@ -1,18 +0,0 @@ -package keeper - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/elys-network/elys/x/perpetual/types" -) - -func (k Keeper) GetMTP(ctx sdk.Context, mtpAddress string, id uint64) (types.MTP, error) { - var mtp types.MTP - key := types.GetMTPKey(mtpAddress, id) - store := ctx.KVStore(k.storeKey) - if !store.Has(key) { - return mtp, types.ErrMTPDoesNotExist - } - bz := store.Get(key) - k.cdc.MustUnmarshal(bz, &mtp) - return mtp, nil -} diff --git a/x/perpetual/keeper/get_params.go b/x/perpetual/keeper/get_params.go deleted file mode 100644 index 20ee49191..000000000 --- a/x/perpetual/keeper/get_params.go +++ /dev/null @@ -1,18 +0,0 @@ -package keeper - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/elys-network/elys/x/perpetual/types" -) - -// GetParams get all parameters as types.Params -func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) { - store := ctx.KVStore(k.storeKey) - bz := store.Get(types.KeyPrefix(types.ParamsKey)) - if bz == nil { - return params - } - - k.cdc.MustUnmarshal(bz, ¶ms) - return params -} diff --git a/x/perpetual/keeper/get_pool.go b/x/perpetual/keeper/get_pool.go deleted file mode 100644 index 930d1aaa1..000000000 --- a/x/perpetual/keeper/get_pool.go +++ /dev/null @@ -1,20 +0,0 @@ -package keeper - -import ( - "github.com/cosmos/cosmos-sdk/store/prefix" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/elys-network/elys/x/perpetual/types" -) - -// GetPool returns a pool from its index -func (k Keeper) GetPool(ctx sdk.Context, poolId uint64) (val types.Pool, found bool) { - store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.PoolKeyPrefix)) - - b := store.Get(types.PoolKey(poolId)) - if b == nil { - return val, false - } - - k.cdc.MustUnmarshal(b, &val) - return val, true -} diff --git a/x/perpetual/keeper/keeper.go b/x/perpetual/keeper/keeper.go index 9e0e3815d..2456e9417 100644 --- a/x/perpetual/keeper/keeper.go +++ b/x/perpetual/keeper/keeper.go @@ -10,8 +10,6 @@ import ( "github.com/cosmos/cosmos-sdk/store/prefix" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" errorsmod "cosmossdk.io/errors" "cosmossdk.io/math" @@ -90,28 +88,6 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) } -func (k Keeper) GetMTPCount(ctx sdk.Context) uint64 { - var count uint64 - countBz := ctx.KVStore(k.storeKey).Get(types.MTPCountPrefix) - if countBz == nil { - count = 0 - } else { - count = types.GetUint64FromBytes(countBz) - } - return count -} - -func (k Keeper) GetOpenMTPCount(ctx sdk.Context) uint64 { - var count uint64 - countBz := ctx.KVStore(k.storeKey).Get(types.OpenMTPCountPrefix) - if countBz == nil { - count = 0 - } else { - count = types.GetUint64FromBytes(countBz) - } - return count -} - func (k Keeper) CheckIfWhitelisted(ctx sdk.Context, address string) bool { store := ctx.KVStore(k.storeKey) return store.Has(types.GetWhitelistKey(address)) @@ -530,23 +506,6 @@ func (k Keeper) CheckMinLiabilities(ctx sdk.Context, collateralAmount sdk.Coin, return nil } -func (k Keeper) DestroyMTP(ctx sdk.Context, mtpAddress string, id uint64) error { - key := types.GetMTPKey(mtpAddress, id) - store := ctx.KVStore(k.storeKey) - if !store.Has(key) { - return types.ErrMTPDoesNotExist - } - store.Delete(key) - // decrement open mtp count - openCount := k.GetOpenMTPCount(ctx) - openCount-- - - // Set open MTP count - k.SetOpenMTPCount(ctx, openCount) - - return nil -} - func (k Keeper) TakeFundPayment(ctx sdk.Context, returnAmount math.Int, returnAsset string, takePercentage sdk.Dec, fundAddr sdk.AccAddress, ammPool *ammtypes.Pool) (math.Int, error) { returnAmountDec := sdk.NewDecFromBigInt(returnAmount.BigInt()) takeAmount := sdk.NewIntFromBigInt(takePercentage.Mul(returnAmountDec).TruncateInt().BigInt()) @@ -561,41 +520,6 @@ func (k Keeper) TakeFundPayment(ctx sdk.Context, returnAmount math.Int, returnAs return takeAmount, nil } -func (k Keeper) SetMTP(ctx sdk.Context, mtp *types.MTP) error { - store := ctx.KVStore(k.storeKey) - count := k.GetMTPCount(ctx) - openCount := k.GetOpenMTPCount(ctx) - - if mtp.Id == 0 { - // increment global id count - count++ - mtp.Id = count - k.SetMTPCount(ctx, count) - // increment open mtp count - openCount++ - k.SetOpenMTPCount(ctx, openCount) - } - - if err := mtp.Validate(); err != nil { - return err - } - key := types.GetMTPKey(mtp.Address, mtp.Id) - store.Set(key, k.cdc.MustMarshal(mtp)) - return nil -} - -// Set Open MTP count -func (k Keeper) SetOpenMTPCount(ctx sdk.Context, count uint64) { - store := ctx.KVStore(k.storeKey) - store.Set(types.OpenMTPCountPrefix, types.GetUint64Bytes(count)) -} - -// Set MTP count -func (k Keeper) SetMTPCount(ctx sdk.Context, count uint64) { - store := ctx.KVStore(k.storeKey) - store.Set(types.MTPCountPrefix, types.GetUint64Bytes(count)) -} - func (k Keeper) GetWhitelistAddressIterator(ctx sdk.Context) sdk.Iterator { store := ctx.KVStore(k.storeKey) return sdk.KVStorePrefixIterator(store, types.WhitelistPrefix) @@ -618,106 +542,6 @@ func (k Keeper) GetAllWhitelistedAddress(ctx sdk.Context) []string { return list } -func (k Keeper) GetMTPIterator(ctx sdk.Context) sdk.Iterator { - store := ctx.KVStore(k.storeKey) - return sdk.KVStorePrefixIterator(store, types.MTPPrefix) -} - -func (k Keeper) GetAllMTPs(ctx sdk.Context) []types.MTP { - var mtpList []types.MTP - iterator := k.GetMTPIterator(ctx) - defer func(iterator sdk.Iterator) { - err := iterator.Close() - if err != nil { - panic(err) - } - }(iterator) - - for ; iterator.Valid(); iterator.Next() { - var mtp types.MTP - bytesValue := iterator.Value() - k.cdc.MustUnmarshal(bytesValue, &mtp) - mtpList = append(mtpList, mtp) - } - return mtpList -} - -func (k Keeper) GetMTPs(ctx sdk.Context, pagination *query.PageRequest) ([]*types.MTP, *query.PageResponse, error) { - var mtpList []*types.MTP - store := ctx.KVStore(k.storeKey) - mtpStore := prefix.NewStore(store, types.MTPPrefix) - - if pagination == nil { - pagination = &query.PageRequest{ - Limit: gomath.MaxUint64 - 1, - } - } - - pageRes, err := query.Paginate(mtpStore, pagination, func(key []byte, value []byte) error { - var mtp types.MTP - k.cdc.MustUnmarshal(value, &mtp) - mtpList = append(mtpList, &mtp) - return nil - }) - - return mtpList, pageRes, err -} - -func (k Keeper) GetMTPsForPool(ctx sdk.Context, ammPoolId uint64, pagination *query.PageRequest) ([]*types.MTP, *query.PageResponse, error) { - var mtps []*types.MTP - - store := ctx.KVStore(k.storeKey) - mtpStore := prefix.NewStore(store, types.MTPPrefix) - - if pagination == nil { - pagination = &query.PageRequest{ - Limit: gomath.MaxUint64 - 1, - } - } - - pageRes, err := query.FilteredPaginate(mtpStore, pagination, func(key []byte, value []byte, accumulate bool) (bool, error) { - var mtp types.MTP - k.cdc.MustUnmarshal(value, &mtp) - if accumulate && mtp.AmmPoolId == ammPoolId { - mtps = append(mtps, &mtp) - return true, nil - } - - return false, nil - }) - - return mtps, pageRes, err -} - -func (k Keeper) GetMTPsForAddress(ctx sdk.Context, mtpAddress sdk.Address, pagination *query.PageRequest) ([]*types.MTP, *query.PageResponse, error) { - var mtps []*types.MTP - - store := ctx.KVStore(k.storeKey) - mtpStore := prefix.NewStore(store, types.GetMTPPrefixForAddress(mtpAddress.String())) - - if pagination == nil { - pagination = &query.PageRequest{ - Limit: types.MaxPageLimit, - } - } - - if pagination.Limit > types.MaxPageLimit { - return nil, nil, status.Error(codes.InvalidArgument, fmt.Sprintf("page size greater than max %d", types.MaxPageLimit)) - } - - pageRes, err := query.Paginate(mtpStore, pagination, func(key []byte, value []byte) error { - var mtp types.MTP - k.cdc.MustUnmarshal(value, &mtp) - mtps = append(mtps, &mtp) - return nil - }) - if err != nil { - return nil, nil, err - } - - return mtps, pageRes, nil -} - func (k Keeper) GetWhitelistedAddress(ctx sdk.Context, pagination *query.PageRequest) ([]string, *query.PageResponse, error) { var list []string store := ctx.KVStore(k.storeKey) diff --git a/x/perpetual/keeper/mtp.go b/x/perpetual/keeper/mtp.go new file mode 100644 index 000000000..175d84cd4 --- /dev/null +++ b/x/perpetual/keeper/mtp.go @@ -0,0 +1,199 @@ +package keeper + +import ( + "fmt" + gomath "math" + + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/query" + "github.com/elys-network/elys/x/perpetual/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func (k Keeper) SetMTP(ctx sdk.Context, mtp *types.MTP) error { + store := ctx.KVStore(k.storeKey) + count := k.GetMTPCount(ctx) + openCount := k.GetOpenMTPCount(ctx) + + if mtp.Id == 0 { + // increment global id count + count++ + mtp.Id = count + k.SetMTPCount(ctx, count) + // increment open mtp count + openCount++ + k.SetOpenMTPCount(ctx, openCount) + } + + if err := mtp.Validate(); err != nil { + return err + } + key := types.GetMTPKey(mtp.Address, mtp.Id) + store.Set(key, k.cdc.MustMarshal(mtp)) + return nil +} + +func (k Keeper) DestroyMTP(ctx sdk.Context, mtpAddress string, id uint64) error { + key := types.GetMTPKey(mtpAddress, id) + store := ctx.KVStore(k.storeKey) + if !store.Has(key) { + return types.ErrMTPDoesNotExist + } + store.Delete(key) + // decrement open mtp count + openCount := k.GetOpenMTPCount(ctx) + openCount-- + + // Set open MTP count + k.SetOpenMTPCount(ctx, openCount) + + return nil +} + +func (k Keeper) GetMTP(ctx sdk.Context, mtpAddress string, id uint64) (types.MTP, error) { + var mtp types.MTP + key := types.GetMTPKey(mtpAddress, id) + store := ctx.KVStore(k.storeKey) + if !store.Has(key) { + return mtp, types.ErrMTPDoesNotExist + } + bz := store.Get(key) + k.cdc.MustUnmarshal(bz, &mtp) + return mtp, nil +} + +func (k Keeper) GetMTPIterator(ctx sdk.Context) sdk.Iterator { + store := ctx.KVStore(k.storeKey) + return sdk.KVStorePrefixIterator(store, types.MTPPrefix) +} + +func (k Keeper) GetAllMTPs(ctx sdk.Context) []types.MTP { + var mtpList []types.MTP + iterator := k.GetMTPIterator(ctx) + defer func(iterator sdk.Iterator) { + err := iterator.Close() + if err != nil { + panic(err) + } + }(iterator) + + for ; iterator.Valid(); iterator.Next() { + var mtp types.MTP + bytesValue := iterator.Value() + k.cdc.MustUnmarshal(bytesValue, &mtp) + mtpList = append(mtpList, mtp) + } + return mtpList +} + +func (k Keeper) GetMTPs(ctx sdk.Context, pagination *query.PageRequest) ([]*types.MTP, *query.PageResponse, error) { + var mtpList []*types.MTP + store := ctx.KVStore(k.storeKey) + mtpStore := prefix.NewStore(store, types.MTPPrefix) + + if pagination == nil { + pagination = &query.PageRequest{ + Limit: gomath.MaxUint64 - 1, + } + } + + pageRes, err := query.Paginate(mtpStore, pagination, func(key []byte, value []byte) error { + var mtp types.MTP + k.cdc.MustUnmarshal(value, &mtp) + mtpList = append(mtpList, &mtp) + return nil + }) + + return mtpList, pageRes, err +} + +func (k Keeper) GetMTPsForPool(ctx sdk.Context, ammPoolId uint64, pagination *query.PageRequest) ([]*types.MTP, *query.PageResponse, error) { + var mtps []*types.MTP + + store := ctx.KVStore(k.storeKey) + mtpStore := prefix.NewStore(store, types.MTPPrefix) + + if pagination == nil { + pagination = &query.PageRequest{ + Limit: gomath.MaxUint64 - 1, + } + } + + pageRes, err := query.FilteredPaginate(mtpStore, pagination, func(key []byte, value []byte, accumulate bool) (bool, error) { + var mtp types.MTP + k.cdc.MustUnmarshal(value, &mtp) + if accumulate && mtp.AmmPoolId == ammPoolId { + mtps = append(mtps, &mtp) + return true, nil + } + + return false, nil + }) + + return mtps, pageRes, err +} + +func (k Keeper) GetMTPsForAddress(ctx sdk.Context, mtpAddress sdk.Address, pagination *query.PageRequest) ([]*types.MTP, *query.PageResponse, error) { + var mtps []*types.MTP + + store := ctx.KVStore(k.storeKey) + mtpStore := prefix.NewStore(store, types.GetMTPPrefixForAddress(mtpAddress.String())) + + if pagination == nil { + pagination = &query.PageRequest{ + Limit: types.MaxPageLimit, + } + } + + if pagination.Limit > types.MaxPageLimit { + return nil, nil, status.Error(codes.InvalidArgument, fmt.Sprintf("page size greater than max %d", types.MaxPageLimit)) + } + + pageRes, err := query.Paginate(mtpStore, pagination, func(key []byte, value []byte) error { + var mtp types.MTP + k.cdc.MustUnmarshal(value, &mtp) + mtps = append(mtps, &mtp) + return nil + }) + if err != nil { + return nil, nil, err + } + + return mtps, pageRes, nil +} + +// Set MTP count +func (k Keeper) SetMTPCount(ctx sdk.Context, count uint64) { + store := ctx.KVStore(k.storeKey) + store.Set(types.MTPCountPrefix, types.GetUint64Bytes(count)) +} + +func (k Keeper) GetMTPCount(ctx sdk.Context) uint64 { + var count uint64 + countBz := ctx.KVStore(k.storeKey).Get(types.MTPCountPrefix) + if countBz == nil { + count = 0 + } else { + count = types.GetUint64FromBytes(countBz) + } + return count +} + +// Set Open MTP count +func (k Keeper) SetOpenMTPCount(ctx sdk.Context, count uint64) { + store := ctx.KVStore(k.storeKey) + store.Set(types.OpenMTPCountPrefix, types.GetUint64Bytes(count)) +} + +func (k Keeper) GetOpenMTPCount(ctx sdk.Context) uint64 { + var count uint64 + countBz := ctx.KVStore(k.storeKey).Get(types.OpenMTPCountPrefix) + if countBz == nil { + count = 0 + } else { + count = types.GetUint64FromBytes(countBz) + } + return count +} diff --git a/x/perpetual/keeper/open_consolidate.go b/x/perpetual/keeper/open_consolidate.go index 7944c254c..d357d578d 100644 --- a/x/perpetual/keeper/open_consolidate.go +++ b/x/perpetual/keeper/open_consolidate.go @@ -44,7 +44,7 @@ func (k Keeper) OpenConsolidate(ctx sdk.Context, existingMtp *types.MTP, newMtp // calc and update open price k.UpdateOpenPrice(ctx, existingMtp, ammPool, baseCurrency) - ctx.EventManager().EmitEvent(types.GenerateOpenEvent(existingMtp)) + k.EmitOpenEvent(ctx, existingMtp) if k.hooks != nil { k.hooks.AfterPerpetualPositionModified(ctx, ammPool, pool) @@ -54,3 +54,7 @@ func (k Keeper) OpenConsolidate(ctx sdk.Context, existingMtp *types.MTP, newMtp Id: existingMtp.Id, }, nil } + +func (k Keeper) EmitOpenEvent(ctx sdk.Context, mtp *types.MTP) { + ctx.EventManager().EmitEvent(types.GenerateOpenEvent(mtp)) +} diff --git a/x/perpetual/keeper/params.go b/x/perpetual/keeper/params.go index 1d6b811b6..edd5592fd 100644 --- a/x/perpetual/keeper/params.go +++ b/x/perpetual/keeper/params.go @@ -21,6 +21,18 @@ func (k Keeper) SetParams(ctx sdk.Context, params *types.Params) error { return nil } +// GetParams get all parameters as types.Params +func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.KeyPrefix(types.ParamsKey)) + if bz == nil { + return params + } + + k.cdc.MustUnmarshal(bz, ¶ms) + return params +} + func (k Keeper) GetMaxLeverageParam(ctx sdk.Context) sdk.Dec { return k.GetParams(ctx).LeverageMax } @@ -164,3 +176,7 @@ func (k Keeper) GetFundingFeeCollectionAddress(ctx sdk.Context) sdk.AccAddress { func (k Keeper) GetSwapFee(ctx sdk.Context) sdk.Dec { return k.GetParams(ctx).SwapFee } + +func (k Keeper) GetEpochLength(ctx sdk.Context) int64 { + return k.GetParams(ctx).EpochLength +} diff --git a/x/perpetual/keeper/pool.go b/x/perpetual/keeper/pool.go index 199a0d0c3..97aa6b3ff 100644 --- a/x/perpetual/keeper/pool.go +++ b/x/perpetual/keeper/pool.go @@ -12,6 +12,19 @@ func (k Keeper) RemovePool(ctx sdk.Context, index uint64) { store.Delete(types.PoolKey(index)) } +// GetPool returns a pool from its index +func (k Keeper) GetPool(ctx sdk.Context, poolId uint64) (val types.Pool, found bool) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.PoolKeyPrefix)) + + b := store.Get(types.PoolKey(poolId)) + if b == nil { + return val, false + } + + k.cdc.MustUnmarshal(b, &val) + return val, true +} + // GetAllPool returns all pool func (k Keeper) GetAllPools(ctx sdk.Context) (list []types.Pool) { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.PoolKeyPrefix)) diff --git a/x/perpetual/spec/04_keeper.md b/x/perpetual/spec/04_keeper.md index 24818113d..942a6f75e 100644 --- a/x/perpetual/spec/04_keeper.md +++ b/x/perpetual/spec/04_keeper.md @@ -78,10 +78,6 @@ The `BeginBlocker` function is triggered at the beginning of each block. It perf `CloseShort` processes the closure of a short position, similar to `CloseLong`, but adjusted for short positions. -### Emitting Closure Events - -`EmitCloseEvent` emits an event when an MTP is closed, providing details about the closure. - ## Position Opening ### Opening a New Margin Trading Position diff --git a/x/perpetual/types/check_short_assets.go b/x/perpetual/types/check_assets.go similarity index 60% rename from x/perpetual/types/check_short_assets.go rename to x/perpetual/types/check_assets.go index 8284e32d1..bad811663 100644 --- a/x/perpetual/types/check_short_assets.go +++ b/x/perpetual/types/check_assets.go @@ -4,6 +4,22 @@ import ( errorsmod "cosmossdk.io/errors" ) +func CheckLongAssets(collateralAsset string, borrowAsset string, baseCurrency string) error { + if borrowAsset == baseCurrency { + return errorsmod.Wrap(ErrInvalidBorrowingAsset, "invalid borrowing asset") + } + + if collateralAsset == borrowAsset && collateralAsset == baseCurrency { + return errorsmod.Wrap(ErrInvalidBorrowingAsset, "invalid borrowing asset") + } + + if collateralAsset != borrowAsset && collateralAsset != baseCurrency { + return errorsmod.Wrap(ErrInvalidBorrowingAsset, "invalid borrowing asset") + } + + return nil +} + func CheckShortAssets(collateralAsset string, borrowAsset string, baseCurrency string) error { // You shouldn't be shorting the base currency (like USDC). if borrowAsset == baseCurrency { diff --git a/x/perpetual/types/check_short_assets_test.go b/x/perpetual/types/check_assets_test.go similarity index 62% rename from x/perpetual/types/check_short_assets_test.go rename to x/perpetual/types/check_assets_test.go index c41f90665..0433fa606 100644 --- a/x/perpetual/types/check_short_assets_test.go +++ b/x/perpetual/types/check_assets_test.go @@ -11,6 +11,22 @@ import ( ptypes "github.com/elys-network/elys/x/parameter/types" ) +func TestCheckLongAssets_InvalidAssets(t *testing.T) { + err := types.CheckLongAssets(ptypes.BaseCurrency, ptypes.BaseCurrency, ptypes.BaseCurrency) + assert.True(t, errors.Is(err, errorsmod.Wrap(types.ErrInvalidBorrowingAsset, "invalid borrowing asset"))) + + err = types.CheckLongAssets(ptypes.ATOM, ptypes.BaseCurrency, ptypes.BaseCurrency) + assert.True(t, errors.Is(err, errorsmod.Wrap(types.ErrInvalidBorrowingAsset, "invalid borrowing asset"))) +} + +func TestCheckLongAssets_ValidAssets(t *testing.T) { + err := types.CheckLongAssets(ptypes.BaseCurrency, ptypes.ATOM, ptypes.BaseCurrency) + assert.Nil(t, err) + + err = types.CheckLongAssets(ptypes.ATOM, ptypes.ATOM, ptypes.BaseCurrency) + assert.Nil(t, err) +} + func TestCheckShortAssets_InvalidAssets(t *testing.T) { // Test invalid cases for short positions err := types.CheckShortAssets(ptypes.ATOM, ptypes.BaseCurrency, ptypes.BaseCurrency) diff --git a/x/perpetual/types/check_long_assets.go b/x/perpetual/types/check_long_assets.go deleted file mode 100644 index e63e421cc..000000000 --- a/x/perpetual/types/check_long_assets.go +++ /dev/null @@ -1,21 +0,0 @@ -package types - -import ( - errorsmod "cosmossdk.io/errors" -) - -func CheckLongAssets(collateralAsset string, borrowAsset string, baseCurrency string) error { - if borrowAsset == baseCurrency { - return errorsmod.Wrap(ErrInvalidBorrowingAsset, "invalid borrowing asset") - } - - if collateralAsset == borrowAsset && collateralAsset == baseCurrency { - return errorsmod.Wrap(ErrInvalidBorrowingAsset, "invalid borrowing asset") - } - - if collateralAsset != borrowAsset && collateralAsset != baseCurrency { - return errorsmod.Wrap(ErrInvalidBorrowingAsset, "invalid borrowing asset") - } - - return nil -} diff --git a/x/perpetual/types/check_long_assets_test.go b/x/perpetual/types/check_long_assets_test.go deleted file mode 100644 index 9cd7dd942..000000000 --- a/x/perpetual/types/check_long_assets_test.go +++ /dev/null @@ -1,28 +0,0 @@ -package types_test - -import ( - "errors" - "testing" - - errorsmod "cosmossdk.io/errors" - "github.com/elys-network/elys/x/perpetual/types" - "github.com/stretchr/testify/assert" - - ptypes "github.com/elys-network/elys/x/parameter/types" -) - -func TestCheckLongAssets_InvalidAssets(t *testing.T) { - err := types.CheckLongAssets(ptypes.BaseCurrency, ptypes.BaseCurrency, ptypes.BaseCurrency) - assert.True(t, errors.Is(err, errorsmod.Wrap(types.ErrInvalidBorrowingAsset, "invalid borrowing asset"))) - - err = types.CheckLongAssets(ptypes.ATOM, ptypes.BaseCurrency, ptypes.BaseCurrency) - assert.True(t, errors.Is(err, errorsmod.Wrap(types.ErrInvalidBorrowingAsset, "invalid borrowing asset"))) -} - -func TestCheckLongAssets_ValidAssets(t *testing.T) { - err := types.CheckLongAssets(ptypes.BaseCurrency, ptypes.ATOM, ptypes.BaseCurrency) - assert.Nil(t, err) - - err = types.CheckLongAssets(ptypes.ATOM, ptypes.ATOM, ptypes.BaseCurrency) - assert.Nil(t, err) -}