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!
|
delegator: VeOCEAN!
|
||||||
receiver: VeOCEAN!
|
receiver: VeOCEAN!
|
||||||
tokenId: BigInt!
|
tokenId: BigInt!
|
||||||
amount: BigInt!
|
amount: BigDecimal!
|
||||||
cancelTime: BigInt!
|
cancelTime: BigInt!
|
||||||
expireTime: BigInt!
|
expireTime: BigInt!
|
||||||
updates: [VeDelegationUpdate!] @derivedFrom(field: "veDelegation")
|
updates: [VeDelegationUpdate!] @derivedFrom(field: "veDelegation")
|
||||||
@ -481,7 +481,7 @@ type VeDelegationUpdate @entity {
|
|||||||
timestamp: Int!
|
timestamp: Int!
|
||||||
tx: String!
|
tx: String!
|
||||||
sender: String!
|
sender: String!
|
||||||
amount: BigInt!
|
amount: BigDecimal!
|
||||||
cancelTime: BigInt!
|
cancelTime: BigInt!
|
||||||
expireTime: BigInt!
|
expireTime: BigInt!
|
||||||
"type: CREATE_BOOST = 0, EXTEND_BOOST = 1, BURN_BOOST = 2"
|
"type: CREATE_BOOST = 0, EXTEND_BOOST = 1, BURN_BOOST = 2"
|
||||||
|
@ -133,7 +133,7 @@ export function getveDelegation(
|
|||||||
veDelegation.cancelTime = BigInt.zero()
|
veDelegation.cancelTime = BigInt.zero()
|
||||||
veDelegation.expireTime = BigInt.zero()
|
veDelegation.expireTime = BigInt.zero()
|
||||||
veDelegation.tokenId = BigInt.zero()
|
veDelegation.tokenId = BigInt.zero()
|
||||||
veDelegation.amount = BigInt.zero()
|
veDelegation.amount = BigDecimal.zero()
|
||||||
veDelegation.receiver = ''
|
veDelegation.receiver = ''
|
||||||
veDelegation.delegator = ''
|
veDelegation.delegator = ''
|
||||||
veDelegation.save()
|
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 { VeDelegationUpdate } from '../@types/schema'
|
||||||
import {
|
import {
|
||||||
BurnBoost,
|
BurnBoost,
|
||||||
@ -6,6 +6,7 @@ import {
|
|||||||
ExtendBoost,
|
ExtendBoost,
|
||||||
TransferBoost
|
TransferBoost
|
||||||
} from '../@types/veDelegation/veDelegation'
|
} from '../@types/veDelegation/veDelegation'
|
||||||
|
import { weiToDecimal } from './utils/generic'
|
||||||
import { getveDelegation, getveOCEAN } from './utils/veUtils'
|
import { getveDelegation, getveOCEAN } from './utils/veUtils'
|
||||||
|
|
||||||
export function handleDelegation(event: DelegateBoost): void {
|
export function handleDelegation(event: DelegateBoost): void {
|
||||||
@ -23,7 +24,10 @@ export function handleDelegation(event: DelegateBoost): void {
|
|||||||
veDelegation.delegator = _delegator
|
veDelegation.delegator = _delegator
|
||||||
veDelegation.receiver = _receiver
|
veDelegation.receiver = _receiver
|
||||||
veDelegation.tokenId = _tokenId
|
veDelegation.tokenId = _tokenId
|
||||||
veDelegation.amount = _amount
|
veDelegation.amount = weiToDecimal(
|
||||||
|
_amount.toBigDecimal(),
|
||||||
|
BigInt.fromI32(18).toI32()
|
||||||
|
)
|
||||||
veDelegation.cancelTime = _cancelTime
|
veDelegation.cancelTime = _cancelTime
|
||||||
veDelegation.expireTime = _expireTime
|
veDelegation.expireTime = _expireTime
|
||||||
veDelegation.save()
|
veDelegation.save()
|
||||||
@ -36,7 +40,7 @@ export function handleDelegation(event: DelegateBoost): void {
|
|||||||
veDelegationUpdate.block = event.block.number.toI32()
|
veDelegationUpdate.block = event.block.number.toI32()
|
||||||
veDelegationUpdate.timestamp = event.block.timestamp.toI32()
|
veDelegationUpdate.timestamp = event.block.timestamp.toI32()
|
||||||
veDelegationUpdate.tx = event.transaction.hash.toHex()
|
veDelegationUpdate.tx = event.transaction.hash.toHex()
|
||||||
veDelegationUpdate.amount = _amount
|
veDelegationUpdate.amount = veDelegation.amount
|
||||||
veDelegationUpdate.cancelTime = _cancelTime
|
veDelegationUpdate.cancelTime = _cancelTime
|
||||||
veDelegationUpdate.expireTime = _expireTime
|
veDelegationUpdate.expireTime = _expireTime
|
||||||
veDelegationUpdate.sender = event.transaction.from.toHex()
|
veDelegationUpdate.sender = event.transaction.from.toHex()
|
||||||
@ -59,7 +63,10 @@ export function handleExtendBoost(event: ExtendBoost): void {
|
|||||||
veDelegation.delegator = _delegator
|
veDelegation.delegator = _delegator
|
||||||
veDelegation.receiver = _receiver
|
veDelegation.receiver = _receiver
|
||||||
veDelegation.tokenId = _tokenId
|
veDelegation.tokenId = _tokenId
|
||||||
veDelegation.amount = _amount
|
veDelegation.amount = weiToDecimal(
|
||||||
|
_amount.toBigDecimal(),
|
||||||
|
BigInt.fromI32(18).toI32()
|
||||||
|
)
|
||||||
veDelegation.cancelTime = _cancelTime
|
veDelegation.cancelTime = _cancelTime
|
||||||
veDelegation.expireTime = _expireTime
|
veDelegation.expireTime = _expireTime
|
||||||
veDelegation.save()
|
veDelegation.save()
|
||||||
@ -72,7 +79,7 @@ export function handleExtendBoost(event: ExtendBoost): void {
|
|||||||
veDelegationUpdate.block = event.block.number.toI32()
|
veDelegationUpdate.block = event.block.number.toI32()
|
||||||
veDelegationUpdate.timestamp = event.block.timestamp.toI32()
|
veDelegationUpdate.timestamp = event.block.timestamp.toI32()
|
||||||
veDelegationUpdate.tx = event.transaction.hash.toHex()
|
veDelegationUpdate.tx = event.transaction.hash.toHex()
|
||||||
veDelegationUpdate.amount = _amount
|
veDelegationUpdate.amount = veDelegation.amount
|
||||||
veDelegationUpdate.cancelTime = _cancelTime
|
veDelegationUpdate.cancelTime = _cancelTime
|
||||||
veDelegationUpdate.expireTime = _expireTime
|
veDelegationUpdate.expireTime = _expireTime
|
||||||
veDelegationUpdate.sender = event.transaction.from.toHex()
|
veDelegationUpdate.sender = event.transaction.from.toHex()
|
||||||
@ -93,7 +100,7 @@ export function handleBurnBoost(event: BurnBoost): void {
|
|||||||
|
|
||||||
// delete
|
// delete
|
||||||
const veDelegation = getveDelegation(event.address, _tokenId.toHex())
|
const veDelegation = getveDelegation(event.address, _tokenId.toHex())
|
||||||
veDelegation.amount = BigInt.zero()
|
veDelegation.amount = BigDecimal.zero()
|
||||||
veDelegation.save()
|
veDelegation.save()
|
||||||
|
|
||||||
const veDelegationUpdate = new VeDelegationUpdate(
|
const veDelegationUpdate = new VeDelegationUpdate(
|
||||||
|
@ -790,7 +790,7 @@ describe('veOcean tests', async () => {
|
|||||||
'Invalid expireTime'
|
'Invalid expireTime'
|
||||||
)
|
)
|
||||||
assert(
|
assert(
|
||||||
delegations[0].updates[0].amount ==
|
web3.utils.toWei(delegations[0].updates[0].amount) ==
|
||||||
tx3.events.DelegateBoost.returnValues._amount,
|
tx3.events.DelegateBoost.returnValues._amount,
|
||||||
'Invalid amount'
|
'Invalid amount'
|
||||||
)
|
)
|
||||||
@ -810,7 +810,7 @@ describe('veOcean tests', async () => {
|
|||||||
'Invalid expireTime for extend boost'
|
'Invalid expireTime for extend boost'
|
||||||
)
|
)
|
||||||
assert(
|
assert(
|
||||||
delegations[0].updates[1].amount ==
|
web3.utils.toWei(delegations[0].updates[1].amount) ==
|
||||||
tx4.events.ExtendBoost.returnValues._amount,
|
tx4.events.ExtendBoost.returnValues._amount,
|
||||||
'Invalid amount for extend boost'
|
'Invalid amount for extend boost'
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user