---
# System prepended metadata

title: Implemented the suggestion

---

# Implemented the suggestion

1. We used SUN instead of TRX for block and vote reward.

![](https://i.imgur.com/rsEFfLE.png)

We got the following output

![](https://i.imgur.com/GzpubK1.png)

The data returned by the API:
![](https://i.imgur.com/ec9xU3K.png)



We still get a difference of almost 748.012814 SUN (approximately 0.000748012814 TRX)

2. We did check the number of blocks generated in total and generated by luganodes in a round. They were calculated accurately by our code. 

#### Question
- Is there any other reason that you think might lead us to this error?

# Code:
```
const BigNumber = require('bignumber.js');
const totalVotesToLgns = new BigNumber(1372028133)
const total127Votes = new BigNumber(41135307986)
const lgns_ratio = totalVotesToLgns.dividedBy(total127Votes)
const totalBlockCount = new BigNumber(7197)
const lgnsBlockCount = new BigNumber(266)
const blockRwdLgns = lgnsBlockCount.multipliedBy(16 * 1000000)

// const voteRewards = totalBlockCount.multipliedBy(lgns_ratio).multipliedBy(160)
const voteRewards = totalBlockCount.multipliedBy(160 * 1000000)
const totalRewards = blockRwdLgns.plus(voteRewards)

//console.log(totalRewards.toString(), voteRewards.toString(), blockRwdLgns.toString(), lgns_ratio.toString())

// voter rewards
const pledgedVotesByVoter = new BigNumber(564786000)
const pledgedVotesInTotal = new BigNumber(1372028133) 
const ratio = pledgedVotesByVoter.dividedBy(pledgedVotesInTotal)

const blockVoterReward = (blockRwdLgns * (new BigNumber(0.9)) * pledgedVotesByVoter) / totalVotesToLgns

const voteVoterReward = (voteRewards * pledgedVotesByVoter * (new BigNumber(0.9))) / total127Votes

const rewardsOfAVoter = blockVoterReward + voteVoterReward

console.log("Rewards: ",rewardsOfAVoter.toString(),blockVoterReward, voteVoterReward)
```

## 



Regarding the calculation of voting rewards, there are some differences in the calculation, and there are some data truncation operations in it.
```

Voting rewards per block：
* 160*1000000 * 1372028133/41135307986 = 5336644.163566565 -->5336644 【needs to be truncated and not rounded】
* 5336644 * 0.1 = 533664
* 5336644 - 533664 = 4802980
* 4802980 * 564786000/1372028133 = 1977113.877649621

Awards per production block：
* 16*1000000 * 0.1 =  1600000
* 16*1000000 - 1600000 = 14400000
* 14400000 * 564786000/1372028133 = 5927661.543074205

Voting bonus per block * total block yield per round + block yield bonus per block * number of blocks produced

1977113.877649621 * 7197 + 5927661.543074205 * 266  = 15806046547.902061 --> 15806046547

The Getreward interface returns：
15806046547

```