The repository contains TheGraph based service for AllianceBlock Liquidity Mining Campaings Version 1.
This TheGraph based service listens for creation of new contracts from Staking Factory Contract and then tracks each of the deployed LMC contracts.
Subgraph Manifest is in the subgraph.yaml file. It tracks few important configurations:
Network
network: mainnet
Factory contract address
source:
address: "0x422A4057f8B8a41474Cf767cd32f0c781C8075cF"
ABIs
source:
abi: StakingRewardsFactory
NOTE: ABIs for both StakingRewardsFactory and StakingRewards are generated by solc tool and stored in /abi folder.
Start Block
startBlock: 11206038
NOTE: In subgraph.yaml always keep the same version for apiVersion inside dataSources and templates!
Defined enitites can be found schema.graphql. All queries will be made against the data model defined in the subgraph schema and the entities indexed by the subgraph.
-
LMC entitity tracks data for each LMC contract
- id
- blockNumber (of deployment)
- timestamp (of deployment)
- address
- stakingToken (Liquidity pool token)
- rewardsTokens (tokens in which users will incentivized for participating in campaign)
- rewardsAmounts
- rewardsDuration
-
Stake
- id
- blockNumber (of transaction)
- timestamp (of transaction)
- gasUsed (IMPORTANT: this is gas limit of transaction)
- gasPrice
- position (index to some user LMC position)
- token (address of staking token)
- amount (of tokens staked)
-
Withdraw
- id
- blockNumber (of transaction)
- timestamp (of transaction)
- gasUsed (IMPORTANT: this is gas limit of transaction)
- gasPrice
- position (index to some user LMC position)
- token (address of staking token)
- amount (of tokens withdrawn)
-
RewardPaid
- id
- blockNumber (of transaction)
- timestamp (of transaction)
- gasUsed (IMPORTANT: this is gas limit of transaction)
- gasPrice
- position (index to some user LMC position)
- token (address of staking token)
- amount (of tokens withdrawn)
-
User
- id
- positions (array of positions)
-
UserLMCPosition
- id
- lastUpdatedInBlock (last block user position got updated)
- lastUpdatedAtTimestamp (last time user position got updated)
- user (address)
- lmc (address)
- active (if user has active/non withdrawn stakes for this particular LMC)
- activeStakes
- totalStaked
- totalRewards (total reward cliamed by user)
- stakes (array of user's stakes)
- withdraws (array of user's withdraws)
- rewardsPaid (array of user's rewardsPaid)
All handlers can be found in /src/mappings.ts
. They convert ethereum network data (transaction data and contract events) to queriable data.
List of handlers:
- handleDeploy
- handleRewardPaid
- handleStaked
- handleWithdrawn
For graphql querries: https://api.thegraph.com/subgraphs/name/skeremidchiev/alb-lmcv1
Documentation For TheGraph AllianceBlock LMCs v1
For some strange reason gasUsed variable in the transaction is actually gasLimit. This is a known bug in TheGraph!