expose agg preds in trueval

This commit is contained in:
alexcos20 2023-08-16 09:52:25 +03:00
parent 5a610f1997
commit 0edf6ced6e
5 changed files with 31 additions and 9 deletions

14
package-lock.json generated
View File

@ -9,7 +9,7 @@
"version": "3.0.9",
"license": "Apache-2.0",
"dependencies": {
"@oceanprotocol/contracts": "^2.0.0-next.5",
"@oceanprotocol/contracts": "^2.0.0-next.6",
"@oceanprotocol/lib": "^2.7.0",
"cross-fetch": "^3.1.6",
"ethereumjs-util": "^7.1.5"
@ -964,9 +964,9 @@
}
},
"node_modules/@oceanprotocol/contracts": {
"version": "2.0.0-next.5",
"resolved": "https://registry.npmjs.org/@oceanprotocol/contracts/-/contracts-2.0.0-next.5.tgz",
"integrity": "sha512-GRAZByO7l6goHQLkEO0HupnM2addlMBjVJ80l5qMODmCh/OOVx3e5DdQPJq48olEC6LiFB+K/kHLzCC5ubGunA=="
"version": "2.0.0-next.6",
"resolved": "https://registry.npmjs.org/@oceanprotocol/contracts/-/contracts-2.0.0-next.6.tgz",
"integrity": "sha512-eQ+P1uWudprH0PDWLjSF2teys10MD3vb2W7U610KZTHphkZ52sgoFwLLMu0TeO+s5elr0OdnUilu78/EaFHEbg=="
},
"node_modules/@oceanprotocol/lib": {
"version": "2.7.0",
@ -15341,9 +15341,9 @@
}
},
"@oceanprotocol/contracts": {
"version": "2.0.0-next.5",
"resolved": "https://registry.npmjs.org/@oceanprotocol/contracts/-/contracts-2.0.0-next.5.tgz",
"integrity": "sha512-GRAZByO7l6goHQLkEO0HupnM2addlMBjVJ80l5qMODmCh/OOVx3e5DdQPJq48olEC6LiFB+K/kHLzCC5ubGunA=="
"version": "2.0.0-next.6",
"resolved": "https://registry.npmjs.org/@oceanprotocol/contracts/-/contracts-2.0.0-next.6.tgz",
"integrity": "sha512-eQ+P1uWudprH0PDWLjSF2teys10MD3vb2W7U610KZTHphkZ52sgoFwLLMu0TeO+s5elr0OdnUilu78/EaFHEbg=="
},
"@oceanprotocol/lib": {
"version": "2.7.0",

View File

@ -75,7 +75,7 @@
"typescript": "^5.0.4"
},
"dependencies": {
"@oceanprotocol/contracts": "^2.0.0-next.5",
"@oceanprotocol/contracts": "^2.0.0-next.6",
"@oceanprotocol/lib": "^2.7.0",
"cross-fetch": "^3.1.6",
"ethereumjs-util": "^7.1.5"

View File

@ -733,6 +733,8 @@ type PredictSlot @entity{
revenue: BigDecimal!
revenues: [PredictionRevenue!] @derivedFrom(field: "slot")
status: PredictSlotStatus!
roundSumStakesUp: BigDecimal!
roundSumStakes: BigDecimal!
}

View File

@ -33,6 +33,8 @@ function getPredictSlot(
newPredictSlot.predictContract = predictContractAddress
newPredictSlot.slot = slot
newPredictSlot.revenue = BigDecimal.zero()
newPredictSlot.roundSumStakesUp = BigDecimal.zero()
newPredictSlot.roundSumStakes = BigDecimal.zero()
newPredictSlot.status = 'Pending'
newPredictSlot.save()
}
@ -155,6 +157,24 @@ export function handleTruevalSubmitted(event: TruevalSubmitted): void {
18
)
newPredictTrueVals.save()
let decimals = 18
const predictContract = getPredictContract(event.address)
if (predictContract.stakeToken) {
const stakeToken = getToken(
Address.fromString(predictContract.stakeToken!),
false
)
decimals = stakeToken.decimals
}
predictSlot.roundSumStakesUp = weiToDecimal(
event.params.roundSumStakesUp.toBigDecimal(),
BigInt.fromI32(decimals).toI32()
)
predictSlot.roundSumStakes = weiToDecimal(
event.params.roundSumStakes.toBigDecimal(),
BigInt.fromI32(decimals).toI32()
)
predictSlot.save()
}
export function handleSettingChanged(event: SettingChanged): void {

View File

@ -80,7 +80,7 @@ templates:
handler: handlePredictionPayout
- event: NewSubscription(indexed address,uint256,uint256)
handler: handleNewSubscription
- event: TruevalSubmitted(indexed uint256,bool,uint256,uint8)
- event: TruevalSubmitted(indexed uint256,bool,uint256,uint8,uint256,uint256)
handler: handleTruevalSubmitted
- event: SettingChanged(uint256,uint256,uint256,address)
handler: handleSettingChanged