Skip to content

Commit

Permalink
added totalDelegationRewardUSD (#107)
Browse files Browse the repository at this point in the history
* added totalDelegationRewardUSD

* Update DaoPools/schema.graphql

---------

Co-authored-by: Artem Chystiakov <[email protected]>
  • Loading branch information
VolodymyrZolotukhin and Arvolear authored Mar 27, 2023
1 parent 22749f8 commit 814728f
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions DaoPools/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ type Proposal @entity {
# @param receivedNFTDelegation the ids of received erc721 as delegation in this pool
# @param totalDPClaimed the total usd amount claimed from DPs
# @param totalClaimedUSD the total usd amount claimed from rewards
# @param totalDelegationRewardUSD the total amount of rewards from delegation voting
# @param currentDelegatorsCount the current numbers of received delegations
# @param APR the APR of user in pool
# @param cusum the cumulative sum for APR calculations
Expand All @@ -134,6 +135,8 @@ type VoterInPool @entity {
totalDPClaimed: BigInt!
totalClaimedUSD: BigInt!

totalDelegationRewardUSD: BigInt!

currentDelegatorsCount: BigInt!

APR: BigInt!
Expand Down
2 changes: 2 additions & 0 deletions DaoPools/src/entities/Voters/VoterInPool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ export function getVoterInPool(pool: DaoPool, voter: Voter, timestamp: BigInt):
voterInPool.receivedNFTDelegation = new Array<BigInt>();
voterInPool.receivedNFTDelegationCount = BigInt.zero();

voterInPool.totalDelegationRewardUSD = BigInt.zero();

voterInPool.currentDelegatorsCount = BigInt.zero();

voterInPool.pool = pool.id;
Expand Down
1 change: 1 addition & 0 deletions DaoPools/src/mappings/DaoPool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ export function onRewardCredited(event: RewardCredited): void {
if (event.params.rewardType == REWARD_TYPE_VOTE_DELEGATED) {
voterInProposal.unclaimedRewardFromDelegationsUSD =
voterInProposal.unclaimedRewardFromDelegationsUSD.plus(usdAmount);
voterInPool.totalDelegationRewardUSD = voterInPool.totalDelegationRewardUSD.plus(usdAmount);
}

voterInProposal.unclaimedRewardUSD = voterInProposal.unclaimedRewardUSD.plus(usdAmount);
Expand Down
1 change: 1 addition & 0 deletions DaoPools/tests/DaoPool.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,7 @@ describe("DaoPool", () => {
"unclaimedRewardUSD",
"200"
);
assert.fieldEquals("VoterInPool", sender.concat(contractSender).toHexString(), "totalDelegationRewardUSD", "200");
});

test("should deposit", () => {
Expand Down

0 comments on commit 814728f

Please sign in to comment.