mirror of
https://github.com/oceanprotocol/ocean-subgraph.git
synced 2024-12-02 05:57:29 +01:00
add vesting details (#353)
This commit is contained in:
parent
3aabf53da4
commit
5918c8b035
@ -526,3 +526,19 @@ type Template @entity{
|
|||||||
dispenserTemplates: [String!]
|
dispenserTemplates: [String!]
|
||||||
ssTemplates: [String!]
|
ssTemplates: [String!]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Vested @entity {
|
||||||
|
id: ID!
|
||||||
|
amount: BigDecimal!
|
||||||
|
block: BigInt!
|
||||||
|
vesting: Vesting!
|
||||||
|
}
|
||||||
|
|
||||||
|
type Vesting @entity {
|
||||||
|
id: ID!
|
||||||
|
user: User!
|
||||||
|
token: Token!
|
||||||
|
endBlock: BigInt!
|
||||||
|
amount: BigDecimal!
|
||||||
|
vestingHistory: [Vested!]! @derivedFrom(field: "vesting")
|
||||||
|
}
|
||||||
|
@ -13,7 +13,12 @@ import {
|
|||||||
} from '../@types/FactoryRouter/FactoryRouter'
|
} from '../@types/FactoryRouter/FactoryRouter'
|
||||||
import { BigInt } from '@graphprotocol/graph-ts'
|
import { BigInt } from '@graphprotocol/graph-ts'
|
||||||
import { Pool } from '../@types/schema'
|
import { Pool } from '../@types/schema'
|
||||||
import { BPool, FixedRateExchange, Dispenser } from '../@types/templates'
|
import {
|
||||||
|
BPool,
|
||||||
|
FixedRateExchange,
|
||||||
|
Dispenser,
|
||||||
|
SSContract
|
||||||
|
} from '../@types/templates'
|
||||||
import { addPool, getOPC, getTemplates } from './utils/globalUtils'
|
import { addPool, getOPC, getTemplates } from './utils/globalUtils'
|
||||||
import { weiToDecimal } from './utils/generic'
|
import { weiToDecimal } from './utils/generic'
|
||||||
|
|
||||||
@ -99,6 +104,7 @@ export function handleTokenRemoved(event: TokenRemoved): void {
|
|||||||
|
|
||||||
export function handleSSContractAdded(event: SSContractAdded): void {
|
export function handleSSContractAdded(event: SSContractAdded): void {
|
||||||
// add token to approvedTokens
|
// add token to approvedTokens
|
||||||
|
SSContract.create(event.params.contractAddress)
|
||||||
const templates = getTemplates()
|
const templates = getTemplates()
|
||||||
let existingContracts: string[]
|
let existingContracts: string[]
|
||||||
if (!templates.ssTemplates) existingContracts = []
|
if (!templates.ssTemplates) existingContracts = []
|
||||||
|
47
src/mappings/sscontract.ts
Normal file
47
src/mappings/sscontract.ts
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
import {
|
||||||
|
VestingCreated,
|
||||||
|
Vesting as VestingEvent
|
||||||
|
} from '../@types/templates/SSContract/SSContract'
|
||||||
|
import { Vested, Vesting } from '../@types/schema'
|
||||||
|
import { getUser } from './utils/userUtils'
|
||||||
|
import { getToken } from './utils/tokenUtils'
|
||||||
|
import { weiToDecimal } from './utils/generic'
|
||||||
|
|
||||||
|
export function handleVestingCreated(event: VestingCreated): void {
|
||||||
|
const vesting = new Vesting(
|
||||||
|
event.address
|
||||||
|
.toHexString()
|
||||||
|
.concat('-')
|
||||||
|
.concat(event.params.datatokenAddress.toHexString())
|
||||||
|
)
|
||||||
|
const user = getUser(event.params.publisherAddress.toHexString())
|
||||||
|
vesting.user = user.id
|
||||||
|
const token = getToken(event.params.datatokenAddress, true)
|
||||||
|
vesting.token = token.id
|
||||||
|
vesting.endBlock = event.params.vestingEndBlock
|
||||||
|
vesting.amount = weiToDecimal(
|
||||||
|
event.params.totalVestingAmount.toBigDecimal(),
|
||||||
|
token.decimals
|
||||||
|
)
|
||||||
|
vesting.save()
|
||||||
|
}
|
||||||
|
|
||||||
|
export function handleVesting(event: VestingEvent): void {
|
||||||
|
const vesting = new Vesting(
|
||||||
|
event.address
|
||||||
|
.toHexString()
|
||||||
|
.concat('-')
|
||||||
|
.concat(event.params.datatokenAddress.toHexString())
|
||||||
|
)
|
||||||
|
const vestingHistory = new Vested(
|
||||||
|
event.transaction.hash.toHex().concat('-').concat(event.logIndex.toString())
|
||||||
|
)
|
||||||
|
vestingHistory.block = event.block.number
|
||||||
|
const token = getToken(event.params.datatokenAddress, true)
|
||||||
|
vestingHistory.amount = weiToDecimal(
|
||||||
|
event.params.amountVested.toBigDecimal(),
|
||||||
|
token.decimals
|
||||||
|
)
|
||||||
|
vestingHistory.vesting = vesting.id
|
||||||
|
vestingHistory.save()
|
||||||
|
}
|
@ -262,3 +262,24 @@ templates:
|
|||||||
handler: handleSwap
|
handler: handleSwap
|
||||||
- event: PublishMarketFeeChanged(indexed bytes32,address,address,uint256)
|
- event: PublishMarketFeeChanged(indexed bytes32,address,address,uint256)
|
||||||
handler: handlePublishMarketFeeChanged
|
handler: handlePublishMarketFeeChanged
|
||||||
|
|
||||||
|
- name: SSContract
|
||||||
|
kind: ethereum/contract
|
||||||
|
network: __NETWORK__
|
||||||
|
source:
|
||||||
|
abi: SSContract
|
||||||
|
mapping:
|
||||||
|
kind: ethereum/events
|
||||||
|
apiVersion: 0.0.6
|
||||||
|
language: wasm/assemblyscript
|
||||||
|
file: ./src/mappings/sscontract.ts
|
||||||
|
entities:
|
||||||
|
- SSContract
|
||||||
|
abis:
|
||||||
|
- name: SSContract
|
||||||
|
file: ./node_modules/@oceanprotocol/contracts/artifacts/contracts/pools/ssContracts/SideStaking.sol/SideStaking.json
|
||||||
|
eventHandlers:
|
||||||
|
- event: VestingCreated(indexed address,indexed address,uint256,uint256)
|
||||||
|
handler: handleVestingCreated
|
||||||
|
- event: Vesting(indexed address,indexed address,indexed address,uint256)
|
||||||
|
handler: handleVesting
|
Loading…
Reference in New Issue
Block a user