1
- import { BigInt } from '@graphprotocol/graph-ts'
1
+ import { BigDecimal , BigInt } from '@graphprotocol/graph-ts'
2
2
import { VeDelegationUpdate } from '../@types/schema'
3
3
import {
4
4
BurnBoost ,
5
5
DelegateBoost ,
6
6
ExtendBoost ,
7
7
TransferBoost
8
8
} from '../@types/veDelegation/veDelegation'
9
+ import { weiToDecimal } from './utils/generic'
9
10
import { getveDelegation , getveOCEAN } from './utils/veUtils'
10
11
11
12
export function handleDelegation ( event : DelegateBoost ) : void {
@@ -23,7 +24,10 @@ export function handleDelegation(event: DelegateBoost): void {
23
24
veDelegation . delegator = _delegator
24
25
veDelegation . receiver = _receiver
25
26
veDelegation . tokenId = _tokenId
26
- veDelegation . amount = _amount
27
+ veDelegation . amount = weiToDecimal (
28
+ _amount . toBigDecimal ( ) ,
29
+ BigInt . fromI32 ( 18 ) . toI32 ( )
30
+ )
27
31
veDelegation . cancelTime = _cancelTime
28
32
veDelegation . expireTime = _expireTime
29
33
veDelegation . save ( )
@@ -36,7 +40,7 @@ export function handleDelegation(event: DelegateBoost): void {
36
40
veDelegationUpdate . block = event . block . number . toI32 ( )
37
41
veDelegationUpdate . timestamp = event . block . timestamp . toI32 ( )
38
42
veDelegationUpdate . tx = event . transaction . hash . toHex ( )
39
- veDelegationUpdate . amount = _amount
43
+ veDelegationUpdate . amount = veDelegation . amount
40
44
veDelegationUpdate . cancelTime = _cancelTime
41
45
veDelegationUpdate . expireTime = _expireTime
42
46
veDelegationUpdate . sender = event . transaction . from . toHex ( )
@@ -59,7 +63,10 @@ export function handleExtendBoost(event: ExtendBoost): void {
59
63
veDelegation . delegator = _delegator
60
64
veDelegation . receiver = _receiver
61
65
veDelegation . tokenId = _tokenId
62
- veDelegation . amount = _amount
66
+ veDelegation . amount = weiToDecimal (
67
+ _amount . toBigDecimal ( ) ,
68
+ BigInt . fromI32 ( 18 ) . toI32 ( )
69
+ )
63
70
veDelegation . cancelTime = _cancelTime
64
71
veDelegation . expireTime = _expireTime
65
72
veDelegation . save ( )
@@ -72,7 +79,7 @@ export function handleExtendBoost(event: ExtendBoost): void {
72
79
veDelegationUpdate . block = event . block . number . toI32 ( )
73
80
veDelegationUpdate . timestamp = event . block . timestamp . toI32 ( )
74
81
veDelegationUpdate . tx = event . transaction . hash . toHex ( )
75
- veDelegationUpdate . amount = _amount
82
+ veDelegationUpdate . amount = veDelegation . amount
76
83
veDelegationUpdate . cancelTime = _cancelTime
77
84
veDelegationUpdate . expireTime = _expireTime
78
85
veDelegationUpdate . sender = event . transaction . from . toHex ( )
@@ -93,7 +100,7 @@ export function handleBurnBoost(event: BurnBoost): void {
93
100
94
101
// delete
95
102
const veDelegation = getveDelegation ( event . address , _tokenId . toHex ( ) )
96
- veDelegation . amount = BigInt . zero ( )
103
+ veDelegation . amount = BigDecimal . zero ( )
97
104
veDelegation . save ( )
98
105
99
106
const veDelegationUpdate = new VeDelegationUpdate (
0 commit comments