I am about to do some lightweight widget for anchor protocol and I would like to use simple rest calls instead of using whole anchor.js
However, if I query using anchor.js, I got correct result, eg. aquire pending rewards
However, if I query contract using lcd.terra.dev, like
curl -X GET "https://lcd.terra.dev/wasm/contracts/terra1897an2xux840p9lrh6py3ryankc6mspw49xse3/store?query_msg=%7B%22staker_info%22%3A%20%7B%20%22staker%22%3A%20%22terra1se7ml7wt7pqzjhajhw5ma9lnstcs429lmj0wzd%22%7D%7D" -H "accept: application/json"
The difference is there because your LCD query didn’t include block_height in your query. Specifying the optional parameter, block_height, will give you a simulated reward as of the block height, whereas if you omitted it’ll give you only the stored state.
Since staking rewards are given out in periods, the contract cannot give you the total amount of reward you have earned so far since the last period state change. When you specify the block_height, it’ll try to extrapolate how much you would’ve earned since the last state change using the current reward factor, giving you a better outlook of what the reward is actually like.
Please note that the block height parameter can only be bigger than the latest known (=current) block height. Specifying a block height smaller than the current height will result in a negative Uint256 operation which will give you an error.