---
# System prepended metadata

title: Subgraph Schema

---

# Subgraph Schema 

## Product / Business Goals 

* Track when a user is created
* Track who has claimed tokens on per Epoch basis 
* Track how many tokens have been claimed
* Track when those tokens were claimed
* Save the default wallet of a user
* Track prior preferred wallets of a user
* Track the current preferred wallet of a user
* Track when a user stakes 
* Track when a user unstakes 

A major business goal is to be able to easily query that a user has staked at the beginning of an epoch (we just need unix timestamp or block) and how much they kept staked for that entire epoch. 


## Contract Events 

``` 
//CommonsEasyStake.sol

event Stake(address staker, uint256 amountStaked, uint256 totalStaked);

event unStake(address unstaker, uint256 amountUnstaked, uint256 totalStaked);

// CommonsWhitelist.sol

event AddedToWhitelist(address indexed account, bool employee);

event MassAdd(address[] indexed accounts, bool[] memberTypes);

event RemovedFromWhitelist(address indexed account);

event UpdatedWhitelistAddress(address indexed opolisWallet, address indexed prefWallet); 

// MerkleRedeem.sol

event Claimed(address _claimant, uint256 _balance);
// Add epoch to event

event RootAdded(uint256 epoch, uint256 _totalAllocation);
```

## Schemas 

* User 
    * Address defaultWallet 
    * Address prefWallet
    * Address[] pastWallets 
    * Bool employeeType
    * Bool isWhitelisted
    * Block.timestamp createdAt
    * BigInt stakedBalance 
    * Claims
    * Stakes
    * Unstakes 
     
* Claim 
    * User
    * Address claimedFrom 
    * BigInt epoch
    * BigInt Amt
    
* Stake
    * User 
    * Address stakedFrom
    * BigInt Amt
    * Block.timestamp stakedAt 
    
* Unstake
    * User 
    * Address stakedFrom
    * BigInt Amt
    * Block.timestamp unstakedAt 

