diff --git a/abis/GROVesting.json b/abis/GROVesting.json new file mode 100644 index 0000000..b972f57 --- /dev/null +++ b/abis/GROVesting.json @@ -0,0 +1,623 @@ +[ + { + "inputs": [ + { + "internalType": "contract IVesting", + "name": "_oldVesting", + "type": "address" + }, + { "internalType": "address", "name": "timeLock", "type": "address" } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "totalLockedAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "unlocked", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "penalty", + "type": "uint256" + } + ], + "name": "LogExit", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newPeriod", + "type": "uint256" + }, + { + "components": [ + { "internalType": "uint256", "name": "total", "type": "uint256" }, + { "internalType": "uint256", "name": "startTime", "type": "uint256" } + ], + "indexed": false, + "internalType": "struct AccountInfo", + "name": "newVesting", + "type": "tuple" + } + ], + "name": "LogExtend", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "mintingAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "penalty", + "type": "uint256" + } + ], + "name": "LogInstantExit", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "newMaxPeriod", + "type": "uint256" + } + ], + "name": "LogMaxLockPeriod", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "components": [ + { "internalType": "uint256", "name": "total", "type": "uint256" }, + { "internalType": "uint256", "name": "startTime", "type": "uint256" } + ], + "indexed": false, + "internalType": "struct AccountInfo", + "name": "vesting", + "type": "tuple" + } + ], + "name": "LogMigrate", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "bonusContract", + "type": "address" + } + ], + "name": "LogNewBonusContract", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "newDistributer", + "type": "address" + } + ], + "name": "LogNewDistributer", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "initUnlockedPercent", + "type": "uint256" + } + ], + "name": "LogNewInitUnlockedPercent", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "instantUnlockPercent", + "type": "uint256" + } + ], + "name": "LogNewInstantUnlockedPercent", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "newMigrator", + "type": "address" + } + ], + "name": "LogNewMigrator", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bool", + "name": "pause", + "type": "bool" + } + ], + "name": "LogSetStatus", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "totalLockedAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "components": [ + { "internalType": "uint256", "name": "total", "type": "uint256" }, + { "internalType": "uint256", "name": "startTime", "type": "uint256" } + ], + "indexed": false, + "internalType": "struct AccountInfo", + "name": "vesting", + "type": "tuple" + } + ], + "name": "LogVest", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "vester", + "type": "address" + }, + { + "indexed": false, + "internalType": "bool", + "name": "status", + "type": "bool" + } + ], + "name": "LogVester", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "inputs": [], + "name": "PERCENTAGE_DECIMAL_FACTOR", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "TIME_LOCK", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "", "type": "address" }], + "name": "accountInfos", + "outputs": [ + { "internalType": "uint256", "name": "total", "type": "uint256" }, + { "internalType": "uint256", "name": "startTime", "type": "uint256" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "account", "type": "address" }, + { "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "calcPartialExit", + "outputs": [ + { "internalType": "uint256", "name": "", "type": "uint256" }, + { "internalType": "uint256", "name": "", "type": "uint256" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "distributer", + "outputs": [ + { "internalType": "contract IMintable", "name": "", "type": "address" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "exit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "extension", "type": "uint256" } + ], + "name": "extend", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "account", "type": "address" } + ], + "name": "getVestingDates", + "outputs": [ + { "internalType": "uint256", "name": "", "type": "uint256" }, + { "internalType": "uint256", "name": "", "type": "uint256" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "globalStartTime", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "hodlerClaims", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "initUnlockedPercent", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "initialized", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "instantUnlockPercent", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "lockPeriodFactor", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "maxLockPeriod", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "oldVesting", + "outputs": [ + { "internalType": "contract IVesting", "name": "", "type": "address" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "paused", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_distributer", "type": "address" } + ], + "name": "setDistributer", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_hodlerClaims", "type": "address" } + ], + "name": "setHodlerClaims", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_initUnlockedPercent", + "type": "uint256" + } + ], + "name": "setInitUnlockedPercent", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_instantUnlockPercent", + "type": "uint256" + } + ], + "name": "setInstantUnlockedPercent", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "maxPeriodFactor", + "type": "uint256" + } + ], + "name": "setMaxLockPeriod", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "bool", "name": "pause", "type": "bool" }], + "name": "setStatus", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "vester", "type": "address" }, + { "internalType": "bool", "name": "status", "type": "bool" } + ], + "name": "setVester", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "account", "type": "address" } + ], + "name": "totalBalance", + "outputs": [ + { "internalType": "uint256", "name": "unvested", "type": "uint256" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalGroove", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalLockedAmount", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "account", "type": "address" } + ], + "name": "totalWithdrawn", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "newOwner", "type": "address" } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "", "type": "address" }], + "name": "userMigrated", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "bool", "name": "vest", "type": "bool" }, + { "internalType": "address", "name": "account", "type": "address" }, + { "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "vest", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "account", "type": "address" } + ], + "name": "vestedBalance", + "outputs": [ + { "internalType": "uint256", "name": "unvested", "type": "uint256" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "", "type": "address" }], + "name": "vesters", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "account", "type": "address" } + ], + "name": "vestingBalance", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "", "type": "address" }], + "name": "withdrawals", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + } +] diff --git a/networks.json b/networks.json new file mode 100644 index 0000000..0e3fe33 --- /dev/null +++ b/networks.json @@ -0,0 +1,7 @@ +{ + "mainnet": { + "undefined": { + "address": "0x748218256AfE0A19a88EBEB2E0C5Ce86d2178360" + } + } +} \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..33ed08d --- /dev/null +++ b/package.json @@ -0,0 +1,16 @@ +{ + "name": "grovesting", + "license": "UNLICENSED", + "scripts": { + "codegen": "graph codegen", + "build": "graph build", + "deploy": "graph deploy --node https://api.studio.thegraph.com/deploy/ grovesting", + "create-local": "graph create --node http://localhost:8020/ grovesting", + "remove-local": "graph remove --node http://localhost:8020/ grovesting", + "deploy-local": "graph deploy --node http://localhost:8020/ --ipfs http://localhost:5001 grovesting" + }, + "dependencies": { + "@graphprotocol/graph-cli": "0.30.0", + "@graphprotocol/graph-ts": "0.27.0" + } +} diff --git a/schema.graphql b/schema.graphql new file mode 100644 index 0000000..aff1645 --- /dev/null +++ b/schema.graphql @@ -0,0 +1,6 @@ +type ExampleEntity @entity { + id: ID! + count: BigInt! + user: Bytes! # address + totalLockedAmount: BigInt! # uint256 +} diff --git a/src/gro-vesting.ts b/src/gro-vesting.ts new file mode 100644 index 0000000..da9af13 --- /dev/null +++ b/src/gro-vesting.ts @@ -0,0 +1,115 @@ +import { BigInt } from "@graphprotocol/graph-ts" +import { + GROVesting, + LogExit, + LogExtend, + LogInstantExit, + LogMaxLockPeriod, + LogMigrate, + LogNewBonusContract, + LogNewDistributer, + LogNewInitUnlockedPercent, + LogNewInstantUnlockedPercent, + LogNewMigrator, + LogSetStatus, + LogVest, + LogVester, + OwnershipTransferred +} from "../generated/GROVesting/GROVesting" +import { ExampleEntity } from "../generated/schema" + +export function handleLogExit(event: LogExit): void { + // Entities can be loaded from the store using a string ID; this ID + // needs to be unique across all entities of the same type + let entity = ExampleEntity.load(event.transaction.from.toHex()) + + // Entities only exist after they have been saved to the store; + // `null` checks allow to create entities on demand + if (!entity) { + entity = new ExampleEntity(event.transaction.from.toHex()) + + // Entity fields can be set using simple assignments + entity.count = BigInt.fromI32(0) + } + + // BigInt and BigDecimal math are supported + entity.count = entity.count + BigInt.fromI32(1) + + // Entity fields can be set based on event parameters + entity.user = event.params.user + entity.totalLockedAmount = event.params.totalLockedAmount + + // Entities can be written to the store with `.save()` + entity.save() + + // Note: If a handler doesn't require existing field values, it is faster + // _not_ to load the entity from the store. Instead, create it fresh with + // `new Entity(...)`, set the fields that should be updated and save the + // entity back to the store. Fields that were not set or unset remain + // unchanged, allowing for partial updates to be applied. + + // It is also possible to access smart contracts from mappings. For + // example, the contract that has emitted the event can be connected to + // with: + // + // let contract = Contract.bind(event.address) + // + // The following functions can then be called on this contract to access + // state variables and other data: + // + // - contract.PERCENTAGE_DECIMAL_FACTOR(...) + // - contract.TIME_LOCK(...) + // - contract.accountInfos(...) + // - contract.calcPartialExit(...) + // - contract.distributer(...) + // - contract.getVestingDates(...) + // - contract.globalStartTime(...) + // - contract.hodlerClaims(...) + // - contract.initUnlockedPercent(...) + // - contract.initialized(...) + // - contract.instantUnlockPercent(...) + // - contract.lockPeriodFactor(...) + // - contract.maxLockPeriod(...) + // - contract.oldVesting(...) + // - contract.owner(...) + // - contract.paused(...) + // - contract.totalBalance(...) + // - contract.totalGroove(...) + // - contract.totalLockedAmount(...) + // - contract.totalWithdrawn(...) + // - contract.userMigrated(...) + // - contract.vestedBalance(...) + // - contract.vesters(...) + // - contract.vestingBalance(...) + // - contract.withdrawals(...) +} + +export function handleLogExtend(event: LogExtend): void {} + +export function handleLogInstantExit(event: LogInstantExit): void {} + +export function handleLogMaxLockPeriod(event: LogMaxLockPeriod): void {} + +export function handleLogMigrate(event: LogMigrate): void {} + +export function handleLogNewBonusContract(event: LogNewBonusContract): void {} + +export function handleLogNewDistributer(event: LogNewDistributer): void {} + +export function handleLogNewInitUnlockedPercent( + event: LogNewInitUnlockedPercent +): void {} + +export function handleLogNewInstantUnlockedPercent( + event: LogNewInstantUnlockedPercent +): void {} + +export function handleLogNewMigrator(event: LogNewMigrator): void {} + +export function handleLogSetStatus(event: LogSetStatus): void {} + +export function handleLogVest(event: LogVest): void {} + +export function handleLogVester(event: LogVester): void {} + +export function handleOwnershipTransferred(event: OwnershipTransferred): void {} diff --git a/subgraph.yaml b/subgraph.yaml new file mode 100644 index 0000000..ddc99cc --- /dev/null +++ b/subgraph.yaml @@ -0,0 +1,62 @@ +specVersion: 0.0.1 +schema: + file: ./schema.graphql +dataSources: + - kind: ethereum + name: undefined + network: mainnet + source: + address: "0x748218256AfE0A19a88EBEB2E0C5Ce86d2178360" + abi: GROVesting + mapping: + kind: ethereum/events + apiVersion: 0.0.5 + language: wasm/assemblyscript + entities: + - LogExit + - LogExtend + - LogInstantExit + - LogMaxLockPeriod + - LogMigrate + - LogNewBonusContract + - LogNewDistributer + - LogNewInitUnlockedPercent + - LogNewInstantUnlockedPercent + - LogNewMigrator + - LogSetStatus + - LogVest + - LogVester + - OwnershipTransferred + abis: + - name: GROVesting + file: ./abis/GROVesting.json + eventHandlers: + - event: LogExit(indexed address,uint256,uint256,uint256,uint256) + handler: handleLogExit + - event: LogExtend(indexed address,uint256,(uint256,uint256)) + handler: handleLogExtend + - event: LogInstantExit(indexed address,uint256,uint256) + handler: handleLogInstantExit + - event: LogMaxLockPeriod(uint256) + handler: handleLogMaxLockPeriod + - event: LogMigrate(indexed address,(uint256,uint256)) + handler: handleLogMigrate + - event: LogNewBonusContract(address) + handler: handleLogNewBonusContract + - event: LogNewDistributer(address) + handler: handleLogNewDistributer + - event: LogNewInitUnlockedPercent(uint256) + handler: handleLogNewInitUnlockedPercent + - event: LogNewInstantUnlockedPercent(uint256) + handler: handleLogNewInstantUnlockedPercent + - event: LogNewMigrator(address) + handler: handleLogNewMigrator + - event: LogSetStatus(bool) + handler: handleLogSetStatus + - event: LogVest(indexed address,uint256,uint256,(uint256,uint256)) + handler: handleLogVest + - event: LogVester(address,bool) + handler: handleLogVester + - event: OwnershipTransferred(indexed address,indexed address) + handler: handleOwnershipTransferred + file: ./src/gro-vesting.ts diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..5c5d17c --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "@graphprotocol/graph-ts/types/tsconfig.base.json", + "include": ["src"] +}