CardanoSolutions / ogmios

❇️ A WebSocket JSON/RPC bridge for Cardano

Home Page:https://ogmios.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Getting rewards for the pool and for pool member for the epoch

gostkin opened this issue · comments

Suppose now it's epoch x, is there a way to get staking rewards for a particular pool member (staking key) that will become spendable on epoch x + 1? What about the pool as well? I see there's only rewardsProvenance' endpoint related to that (and only for the whole pool), but it's not obvious how to calculate even the approximate pool rewards based on the data that the endpoint returns:

{
    "type": "jsonwsp/response",
    "version": "1.0",
    "servicename": "ogmios",
    "methodname": "Query",
    "result": {
        "desiredNumberOfPools": 500,
        "poolInfluence": "3/10",
        "totalRewards": 2261878785128,
        "activeStake": 40500976674996005,
        "pools": {
            "pool1qqyjr9pcrv97gwrueunug829fs5znw6p2wxft3fvqkgu5f4qlrg": {
                "stake": 100768211050783,
                "ownerStake": 100542196418843,
                "approximatePerformance": 5.5e-2,
                "poolParameters": {
                    "cost": 340000000,
                    "margin": "1/40",
                    "pledge": 95000000000
                }
            }, ...
        }
    }
}

Could you please tell if that kind of data is possible to obtain through ogmios and how?

Hi @gostkin,

I am not sure to understand you correctly; If you're looking for a way to get the rewards currently available at a stake address, you can use the delegationAndRewards query using a stake address or stake key as parameters.

Yet, you seem to be interested in future rewards, which isn't actually something you can reliably know before the end of the epoch since the block produce during the ongoing epoch will impact the rewards of the next epoch.

Hi @KtorZ ,

Yet, you seem to be interested in future rewards, which isn't actually something you can reliably know before the end of the epoch since the block produce during the ongoing epoch will impact the rewards of the next epoch.

As far as I understand the staking protocol you can predict rewards that will be distributed in future, since earned_epoch < spendable_epoch (model description and dbsync docs). E.g. if now it is epoch x then for pool member cardano-db-sync gives an opportunity to get the rewards that will be distributed to this member in epoch x+1. The calculation can be done before the x+1 epoch actually comes. So I wonder if there's any functionality in ogmios that allows us to get this information (ogmios is much more lightweight than cardano-db-sync and I'd like to use it if possible)