Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug report: QueryStakingSummary returns 0 when coins are staked #337

Open
4 tasks done
mperklin opened this issue Mar 19, 2023 · 1 comment
Open
4 tasks done

Bug report: QueryStakingSummary returns 0 when coins are staked #337

mperklin opened this issue Mar 19, 2023 · 1 comment

Comments

@mperklin
Copy link
Contributor

Prerequisites

Expected Behavior

When executing client.query_staking_summary(some_address), I expect to receive a dict containing accurate total_rewards value and relevant current_positions.

Current Behavior

The total_rewards is 0.

When stepping through the code at https://github.com/fetchai/cosmpy/blob/master/cosmpy/aerial/client/__init__.py#L396 I identify that the reward_amount is accurate, however the // COSMOS_SDK_DEC_COIN_PRECISION floor division results in a value of 0.0.

Because the reward_amount is being divided by 10**18, the resultant output is 0 since 10**18 is greater than the base unit of the cosmoshub blockchain.

I think the // COSMOS_SDK_DEC_COIN_PRECISION may be unnecessary in this line of code, but I don't know the full context of how this is used across all blockchains.

A possible fix is to rewrite this line to simply be:
int(float(reward.amount))
without any division

To Reproduce

No response

Context

I instantiated a aerial client using the cosmoshub blockchain and requested staking details of an address that has > 1uatom of staking rewards.

Failure Logs

No response

@roson9527
Copy link

roson9527 commented Feb 19, 2024

import cosmpy.aerial.client
cosmpy.aerial.client.__dict__["COSMOS_SDK_DEC_COIN_PRECISION"] = 1

I've also encountered the same issue. The current solution is to use the following code to set this constant and make the method return the correct result.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants