Nominators amount issue
Hello,
I extracted staking information data from polkadot.js using the following code:
const hash = await api.rpc.chain.getBlockHash(1939800);
console.log(JSON.stringify(hash))
const stake = await api.query.parachainStaking.atStake.at(hash, 1080, '0x73Fd06aBCa1669725CE4ecA539bf55393B228f23')
console.log(JSON.stringify(stake.toHuman()))
I expected to see the list of nominations with the amount of nominations. However, for some nominations, there is 0 in the nomination amount. Could you clarify this issue? The problem is that 0 nomination amount is not correct because the sum of all nomination amounts + collator self-bond is not equal to the total amount of stake in this case.
For example:

@4meta5 Can you get a look at this issue please ?
The 0 nominations in AtStake were introduced in https://github.com/PureStake/moonbeam/pull/1408 to NOT count the pending bond_less and revoke delegations. So the AtStake doesn't always match CandidateState because the CandidateState counts all delegations while AtStake only snapshots the counted delegations. You can expect AtStake to replace every delegation for which there is a revoke request with a 0 delegation.
To be clear, AtStake is a snapshot taken at the start of the round for payout calculation later. If you would like the list of all delegations for a candidate, use CandidateState and if you'd like the list of all delegations by a delegator use DelegatorState.
@4meta5 Thank you for your answer, it clarifies my questions. However, I cannot find CandidateState in the pallet. Can you explain how to use CandidateState? Thanks!
@avtishin The map is CandidateInfo, this is what I meant to say instead of CandidateState: https://github.com/PureStake/moonbeam/blob/master/pallets/parachain-staking/src/lib.rs#L488-L492
There are two maps below it which contains the TopDelegations and BottomDelegations per candidate.
As mentioned before, use DelegatorState to get all delegations per delegator
Closing due to inactivity. Feel free to reopen or keep asking questions if you need help :)