# Integrate Indexed Finance Staking
MultiTokenStaking is our fork of MasterChef V2 and is being used for all of our LP rewards.
Contract: https://etherscan.io/address/0xc46e0e7ecb3efcc417f6f89b940ffaff72556382
[Link to ABI JSON](https://github.com/indexed-finance/indexed-interface/blob/main/src/ethereum/abi/MultiTokenStaking.json)
## Get list of staking tokens and pool info
### Staking Lens Contract
Using the staking lens contract at [0x7b429d737282bd2b2f73d7b7f70c6726fc1b6e26](https://etherscan.io/address/0x7b429d737282bd2b2f73d7b7f70c6726fc1b6e26#code)
[Link to ABI JSON](https://api.etherscan.io/api?module=contract&action=getabi&address=0x7b429d737282bd2b2f73d7b7f70c6726fc1b6e26)
Query `lens.getPools()`
This will return an array of:
```ts
{
uint256 pid; // Pool ID
address stakingToken; // Token to stake - index or index LP pair
bool isPairToken; // Single-sided staking or pair
address token0; // token0 if pair, null if not
address token1; // token1 if pair, null if not
uint256 amountStaked; // Exact amount of `stakingToken` staked
uint256 ndxPerDay; // NDX rewards per day for pool
string symbol; // token symbol or pair symbol e.g. FFF or FFF/WETH
}
```
### Subgraph
Using the queries in this file:
https://github.com/indexed-finance/subgraph-clients/blob/master/src/staking/queries.ts
With our subgraph at https://api.thegraph.com/subgraphs/name/indexed-finance/staking
By querying our [staking subgraph](https://api.thegraph.com/subgraphs/name/indexed-finance/staking) with the following gql query:
```graphql=
query allStakingInfo {
multiTokenStakings(first: 1) {
id # address of staking contract
rewardsSchedule # address of contract for calculating rewards
startBlock # first block rewards were distributed in
endBlock # last block rewards will be distributed in
rewardsToken # address of rewards token (NDX)
totalAllocPoint # denominator for pool reward calculation
poolCount # number of pools
pools(first: 100) {
id # pool ID in the staking contract
token # staking token address
symbol # token.symbol()
name # token.name()
decimals # token.decimals()
balance # total amount staked
isPairToken # false = single-sided staking / true = uni/sushi pair
token0 # token0 of the pair if `isPairToken`, otherwise null
token1 # token1 of the pair if `isPairToken`, otherwise null
allocPoint # allocation of rewards
lastRewardBlock # last block rewards were accumulated in
userCount # number of stakers
updatedAt # timestamp of last update
}
}
}
```
## MultiTokenStaking Queries
### Check pending rewards
```ts
function pendingRewards(uint256 pid, address account)
```
Returns amount of NDX that `account` can claim.
### Check user balance
```ts
function userInfo(uint256 pool.pid, address account)
```
Returns
```ts
{
uint256 amount; // Exact amount of `stakingToken` staked by `account`
int256 rewardDebt; // Not relevant to integrations
}
```
## MultiTokenStaking Interactions
### Deposit
```ts
function deposit(uint256 pid, uint256 amount, address account)
```
`account` should be the address of the user unless they wish to deposit on behalf of someone else.
### Withdraw
```ts
function withdraw(uint256 pid, uint256 amount, address account)
```
`account` should be the address of the user unless they wish to withdraw and send the tokens to someone else.
**Note** Does not claim rewards.
### Withdraw and harvest
```ts
function withdrawAndHarvest(uint256 pid, uint256 amount, address account)
```
`account` should be the address of the user unless they wish to withdraw and send the tokens to someone else.
Does claim rewards.
## Claim rewards
```ts
function harvest(uint256 pid, address account)
```
Claims all pending rewards for `account`.