# Rewards

## Reward rate of the pool

{% hint style="info" %}
*Used to retrieve the historical reward rate of the pool so that it can be displayed to your users in your native workflow.*
{% endhint %}

The pool reward rate can only ever be based on a rolling historical average (we can never predict the future rate). The data returned includes the average of the last week, last month, last 3 months, last 6 months and 'all time'. &#x20;

It is up to you to choose the which historical rolling average to use, but most partners currently use the last week.

**TIP**: you need to convert the results to a percentage (%).  For example:

* 'All Time' Gross Reward Rate returns: `26478817328005117`
* Convert to %
  * `26478817328005117 / 10^18 =`` `**`.02647 (2.647%)`**

**Using The Graph**

*Query*

```graphql
{
  erc20(id:"INTEGRATION_CONTRACT_ADDRESS") {
    address
    summaries {
      allTime {
        period
        entryCount
        totalGrossRewards
        totalNetRewards
        grossRewardRate
        netRewardRate
      }
      sixMonths {
        period
        entryCount
        totalGrossRewards
        totalNetRewards
        grossRewardRate
        netRewardRate
      }
      threeMonths {
        period
        entryCount
        totalGrossRewards
        totalNetRewards
        grossRewardRate
        netRewardRate
      }
      oneMonth {
        period
        entryCount
        totalGrossRewards
        totalNetRewards
        grossRewardRate
        netRewardRate
      }
      oneWeek {
        period
        entryCount
        totalGrossRewards
        totalNetRewards
        grossRewardRate
        netRewardRate
      }
    }
  }
}
```

*Example results*

```graphql
{
  "data": {
    "erc20": {
      {
        "address": "0x0a868e4e07a0a00587a783720b76fad9f7eea009",
        "summaries": {
          "allTime": {
            "period": "0",
            "entryCount": "122",
            "totalGrossRewards": "83318815260827429",
            "totalNetRewards": "74986933734744687",
            "grossRewardRate": "26478817328005117",
            "netRewardRate": "23832092039793994"
          },
          "sixMonths": {
            "period": "15552000",
            "entryCount": "122",
            "totalGrossRewards": "83318815260827429",
            "totalNetRewards": "74986933734744687",
            "grossRewardRate": "26478817328005117",
            "netRewardRate": "23832092039793994"
          },
          "threeMonths": {
            "period": "7776000",
            "entryCount": "122",
            "totalGrossRewards": "83318815260827429",
            "totalNetRewards": "74986933734744687",
            "grossRewardRate": "26478817328005117",
            "netRewardRate": "23832092039793994"
          },
          "oneMonth": {
            "period": "2592000",
            "entryCount": "122",
            "totalGrossRewards": "83318815260827429",
            "totalNetRewards": "74986933734744687",
            "grossRewardRate": "26478817328005117",
            "netRewardRate": "23832092039793994"
          },
          "oneWeek": {
            "period": "604800",
            "entryCount": "92",
            "totalGrossRewards": "81604693950689434",
            "totalNetRewards": "73444224555620491",
            "grossRewardRate": "33758837634833258",
            "netRewardRate": "30384486833373929"
          }
        }
      }
    }
  }
}
```

## Rewards for a given user

{% hint style="info" %}
*Used to retrieve the rewards of the given user based on their staked position*
{% endhint %}

**TIP**: the result is in wei, you need to convert it to ETH. For example:&#x20;

* allTimeRewards = `46478817328005117`
* Convert to ETH
  * `46478817328005117 / 10^18 = 0.046478817`**`ETH`**

`allTimeRewards` = `((sharesBalance * totalUnderlyingSupply) / totalSupply) - adjustedTotalDeposited`

**Using The Graph**

*Query*

```graphql
{
  erc20(id:"INTEGRATION_CONTRACT_ADDRESS") {
    totalSupply
    totalUnderlyingSupply
    balances(where:{staker:"USER_ADDRESS"}) {
      sharesBalance
      totalDeposited
      adjustedTotalDeposited
    }
  }
}
```

*Example results*

```json
{
  "data": {
    "erc20": {
        "totalSupply": "1228270478518757",
        "totalUnderlyingSupply": "1230821549859160",
        "balances": [
          {
            "sharesBalance": "389251278627",
            "totalDeposited": "420000000000",
            "adjustedTotalDeposited": "389946465786"
          }
        ]
      }
    }
  }
}
```
