subscan-explorer / subscan-essentials

Polkadot Substrate Explorer Subscan

Home Page:https://www.subscan.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

is it possible to get pendingRewards for an account member of a pool?

p4tpr0 opened this issue · comments

commented

If I understand correctly (I'm not a dev), https://polkadot.js.org/docs/substrate/runtime/#pendingrewardsmember-accountid-balance shows that it should be possible to retrieve pendingRewards of a member of a pool. Is that correct? And if so, is it possible to get this information with an API Call on subscan?

commented

@p4tpr0 Of course. you can try to use this

https://support.subscan.io/#pool-members

commented

It seems I can't get it work:
$ curl -X POST 'https://westend.api.subscan.io/api/scan/nomination_pool/pool/members' --header 'Content-Type: application/json' --header 'X-API-Key: ****************' --data-raw '{ "pool_id": "91" }' {"code":400,"message":"json: cannot unmarshal string into Go struct field .pool_id of type uint","generated_at":1682569130}

And more importantly, I can see how this call can retrieve api.call.nominationPoolsApi.pendingRewards for a member of the pool.

commented

curl -X POST 'https://westend.api.subscan.io/api/scan/nomination_pool/pool/members' --header 'Content-Type: application/json' --header 'X-API-Key: ****************' --data-raw '{ "pool_id": 91,"row":10 }'

commented

Ok, thanks, works better without quotes around the effective pool ID (might need to fix the example in the doc).

I find the result a bit odd. Issuing this: curl -X POST 'https://westend.api.subscan.io/api/scan/nomination_pool/pool/members' --header 'Content-Type: application/json' --header 'X-API-Key: ****************' --data-raw '{ "pool_id": 91 }'

returns a list of 159 pool members when the real pool currently has only 6 members. My address is not in the result when it's currently a member of that pool.
If I'm not mistaken, pool IP 91 should correspond to pool address 13UVJyLnbVp8c4FQeiGJLuQxR1TcPHRTvbH8JsviRtjKizh8

It looks like I'm not sending my request to the right provider. Does westend.api.subscan.io serves polkadot production data or testing data?

commented

@p4tpr0 Sorry, I didn't understand what you mean, can you explain the problem to me in detail?

commented

OK :)
I would like to retrieve the following info: "how much Unclaimed Rewards have I earned from participating to polkadot staking pool ID 91". See screenshot.

As far as I know, this particular information is stored here: https://polkadot.js.org/docs/substrate/runtime/#pendingrewardsmember-accountid-balance but it seems I can't get it.
Screenshot 2023-04-28 at 06 56 51

commented

You can use https://support.subscan.io/#pool-members and claimable is what you need

{
  "code": 0,
  "message": "Success",
  "generated_at": 1655113061,
  "data": {
    "count": 7,
    "list": [
      {
        "pool_id": 45,
        "bonded": "3000000000000",
        "claimable": "0",
        "account_display": {
          "address": "5D7zYmyEEmtTVg6RhUcCRP11J1Rc6FK2Xh2hUZQzD5K57bHF"
        }
      }
    ]
  }
}
commented

EDIT : OK, nevermind, I was not hitting the proper provider.
I've finally spotted my mistake and its all good.

Sorry for the noise.

_I've tried this already, but like I wrote earlier: output is not what I expect. Pool ID 91 has 6 members and

$ curl -X POST 'https://westend.api.subscan.io/api/scan/nomination_pool/pool/members' --header 'Content-Type: application/json' --header 'X-API-Key: ****' --data-raw '{ "pool_id": 91 }'
returns a list of 159 members. Every member is identical except for the address: same bonded (1 DOT), same claimable (0).
{"pool_id":91,"bonded":"1000000000000","account_display":{"address":"5FnwBT6S1***rs4Uo4ADPeJV"},"claimable":"0"},{"pool_id":91,"bonded":"1000000000000","account_display":{"address":"5FWLug16K***fNyyfcPz9MNT"},"claimable":"0"},_