mirror of
https://github.com/oceanprotocol/ocean-subgraph.git
synced 2024-12-02 05:57:29 +01:00
switch amount from wei to numeric (#666)
This commit is contained in:
parent
9fd0553337
commit
5b2ccbc276
@ -467,7 +467,7 @@ type VeDelegation @entity {
|
||||
delegator: VeOCEAN!
|
||||
receiver: VeOCEAN!
|
||||
tokenId: BigInt!
|
||||
amount: BigInt!
|
||||
amount: BigDecimal!
|
||||
cancelTime: BigInt!
|
||||
expireTime: BigInt!
|
||||
updates: [VeDelegationUpdate!] @derivedFrom(field: "veDelegation")
|
||||
@ -481,7 +481,7 @@ type VeDelegationUpdate @entity {
|
||||
timestamp: Int!
|
||||
tx: String!
|
||||
sender: String!
|
||||
amount: BigInt!
|
||||
amount: BigDecimal!
|
||||
cancelTime: BigInt!
|
||||
expireTime: BigInt!
|
||||
"type: CREATE_BOOST = 0, EXTEND_BOOST = 1, BURN_BOOST = 2"
|
||||
|
@ -133,7 +133,7 @@ export function getveDelegation(
|
||||
veDelegation.cancelTime = BigInt.zero()
|
||||
veDelegation.expireTime = BigInt.zero()
|
||||
veDelegation.tokenId = BigInt.zero()
|
||||
veDelegation.amount = BigInt.zero()
|
||||
veDelegation.amount = BigDecimal.zero()
|
||||
veDelegation.receiver = ''
|
||||
veDelegation.delegator = ''
|
||||
veDelegation.save()
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { BigInt } from '@graphprotocol/graph-ts'
|
||||
import { BigDecimal, BigInt } from '@graphprotocol/graph-ts'
|
||||
import { VeDelegationUpdate } from '../@types/schema'
|
||||
import {
|
||||
BurnBoost,
|
||||
@ -6,6 +6,7 @@ import {
|
||||
ExtendBoost,
|
||||
TransferBoost
|
||||
} from '../@types/veDelegation/veDelegation'
|
||||
import { weiToDecimal } from './utils/generic'
|
||||
import { getveDelegation, getveOCEAN } from './utils/veUtils'
|
||||
|
||||
export function handleDelegation(event: DelegateBoost): void {
|
||||
@ -23,7 +24,10 @@ export function handleDelegation(event: DelegateBoost): void {
|
||||
veDelegation.delegator = _delegator
|
||||
veDelegation.receiver = _receiver
|
||||
veDelegation.tokenId = _tokenId
|
||||
veDelegation.amount = _amount
|
||||
veDelegation.amount = weiToDecimal(
|
||||
_amount.toBigDecimal(),
|
||||
BigInt.fromI32(18).toI32()
|
||||
)
|
||||
veDelegation.cancelTime = _cancelTime
|
||||
veDelegation.expireTime = _expireTime
|
||||
veDelegation.save()
|
||||
@ -36,7 +40,7 @@ export function handleDelegation(event: DelegateBoost): void {
|
||||
veDelegationUpdate.block = event.block.number.toI32()
|
||||
veDelegationUpdate.timestamp = event.block.timestamp.toI32()
|
||||
veDelegationUpdate.tx = event.transaction.hash.toHex()
|
||||
veDelegationUpdate.amount = _amount
|
||||
veDelegationUpdate.amount = veDelegation.amount
|
||||
veDelegationUpdate.cancelTime = _cancelTime
|
||||
veDelegationUpdate.expireTime = _expireTime
|
||||
veDelegationUpdate.sender = event.transaction.from.toHex()
|
||||
@ -59,7 +63,10 @@ export function handleExtendBoost(event: ExtendBoost): void {
|
||||
veDelegation.delegator = _delegator
|
||||
veDelegation.receiver = _receiver
|
||||
veDelegation.tokenId = _tokenId
|
||||
veDelegation.amount = _amount
|
||||
veDelegation.amount = weiToDecimal(
|
||||
_amount.toBigDecimal(),
|
||||
BigInt.fromI32(18).toI32()
|
||||
)
|
||||
veDelegation.cancelTime = _cancelTime
|
||||
veDelegation.expireTime = _expireTime
|
||||
veDelegation.save()
|
||||
@ -72,7 +79,7 @@ export function handleExtendBoost(event: ExtendBoost): void {
|
||||
veDelegationUpdate.block = event.block.number.toI32()
|
||||
veDelegationUpdate.timestamp = event.block.timestamp.toI32()
|
||||
veDelegationUpdate.tx = event.transaction.hash.toHex()
|
||||
veDelegationUpdate.amount = _amount
|
||||
veDelegationUpdate.amount = veDelegation.amount
|
||||
veDelegationUpdate.cancelTime = _cancelTime
|
||||
veDelegationUpdate.expireTime = _expireTime
|
||||
veDelegationUpdate.sender = event.transaction.from.toHex()
|
||||
@ -93,7 +100,7 @@ export function handleBurnBoost(event: BurnBoost): void {
|
||||
|
||||
// delete
|
||||
const veDelegation = getveDelegation(event.address, _tokenId.toHex())
|
||||
veDelegation.amount = BigInt.zero()
|
||||
veDelegation.amount = BigDecimal.zero()
|
||||
veDelegation.save()
|
||||
|
||||
const veDelegationUpdate = new VeDelegationUpdate(
|
||||
|
@ -790,7 +790,7 @@ describe('veOcean tests', async () => {
|
||||
'Invalid expireTime'
|
||||
)
|
||||
assert(
|
||||
delegations[0].updates[0].amount ==
|
||||
web3.utils.toWei(delegations[0].updates[0].amount) ==
|
||||
tx3.events.DelegateBoost.returnValues._amount,
|
||||
'Invalid amount'
|
||||
)
|
||||
@ -810,7 +810,7 @@ describe('veOcean tests', async () => {
|
||||
'Invalid expireTime for extend boost'
|
||||
)
|
||||
assert(
|
||||
delegations[0].updates[1].amount ==
|
||||
web3.utils.toWei(delegations[0].updates[1].amount) ==
|
||||
tx4.events.ExtendBoost.returnValues._amount,
|
||||
'Invalid amount for extend boost'
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user