This repository was archived by the owner on Mar 19, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +13
-4
lines changed Expand file tree Collapse file tree 3 files changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -231,8 +231,10 @@ type Account @entity {
231
231
rewardsClaimed : BigDecimal !
232
232
# voting state for each distribution period
233
233
distributionPeriodVotes : [DistributionPeriodVote ! ]!
234
- # amount of tokens delegated to this account
235
- tokensDelegated : BigDecimal !
234
+ # amount of tokens delegated by this user to a single delegated voter
235
+ tokensDelegatedFrom : BigDecimal !
236
+ # cumulative amount of tokens delegated from multiple users to this voter
237
+ tokensDelegatedTo : BigDecimal !
236
238
237
239
# positions associated with the account
238
240
positions : [Position ! ]!
@@ -961,6 +963,7 @@ type DelegateChanged @entity(immutable: true) {
961
963
962
964
type DelegateVotesChanged @entity (immutable : true ) {
963
965
id : Bytes !
966
+ delegator : Bytes ! # address
964
967
delegate : Bytes ! # address
965
968
previousBalance : BigDecimal ! # uint256
966
969
newBalance : BigDecimal ! # uint256
Original file line number Diff line number Diff line change @@ -53,6 +53,7 @@ export function handleDelegateVotesChanged(
53
53
let entity = new DelegateVotesChanged (
54
54
event . transaction . hash . concatI32 ( event . logIndex . toI32 ( ) )
55
55
)
56
+ entity . delegator = event . transaction . from
56
57
entity . delegate = event . params . delegate
57
58
entity . previousBalance = wadToDecimal ( event . params . previousBalance )
58
59
entity . newBalance = wadToDecimal ( event . params . newBalance )
@@ -62,10 +63,14 @@ export function handleDelegateVotesChanged(
62
63
entity . blockTimestamp = event . block . timestamp
63
64
entity . transactionHash = event . transaction . hash
64
65
66
+ const delegator = loadOrCreateAccount ( entity . delegator )
67
+ delegator . tokensDelegatedFrom = entity . newBalance
68
+
65
69
const delegateId = addressToBytes ( event . params . delegate )
66
70
const delegate = loadOrCreateAccount ( delegateId )
67
- delegate . tokensDelegated = delegate . tokensDelegated . plus ( changeInBalance )
71
+ delegate . tokensDelegatedTo = delegate . tokensDelegatedTo . plus ( changeInBalance )
68
72
73
+ delegator . save ( )
69
74
delegate . save ( )
70
75
entity . save ( )
71
76
}
Original file line number Diff line number Diff line change @@ -24,7 +24,8 @@ export function loadOrCreateAccount(accountId: Bytes): Account {
24
24
account . delegatedFrom = [ ]
25
25
account . rewardsClaimed = ZERO_BD
26
26
account . distributionPeriodVotes = [ ]
27
- account . tokensDelegated = ZERO_BD
27
+ account . tokensDelegatedFrom = ZERO_BD
28
+ account . tokensDelegatedTo = ZERO_BD
28
29
29
30
account . txCount = ZERO_BI
30
31
}
You can’t perform that action at this time.
0 commit comments