> For the complete documentation index, see [llms.txt](https://docs.gnoswap.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.gnoswap.io/contracts/gov/staker/emission_reward_manager.gno.md).

# emission\_reward\_manager.gno

{% embed url="<https://github.com/gnoswap-labs/gnoswap/blob/d9d34bd345a36c3eedaccf491c6615b0ac4168cd/contract/r/gnoswap/gov/staker/emission_reward_manager.gno>" %}

## Types

### EmissionRewardManager

```go
type EmissionRewardManager struct
```

EmissionRewardManager manages the distribution of emission rewards to stakers.

[source](https://github.com/gnoswap-labs/gnoswap/blob/d9d34bd345a36c3eedaccf491c6615b0ac4168cd/contract/r/gnoswap/gov/staker/emission_reward_manager.gno#L13)

#### Methods

**GetAccumulatedRewardX128PerStake**

```go
func (e *EmissionRewardManager) GetAccumulatedRewardX128PerStake() *u256.Uint
```

GetAccumulatedRewardX128PerStake returns the accumulated reward per stake with 128-bit precision.

#### Return Values

| Name         | Type        | Description                                                             |
| ------------ | ----------- | ----------------------------------------------------------------------- |
| `*u256.Uint` | \*u256.Uint | accumulated emission reward per unit of stake in Q128 fixed-point form. |

[source](https://github.com/gnoswap-labs/gnoswap/blob/d9d34bd345a36c3eedaccf491c6615b0ac4168cd/contract/r/gnoswap/gov/staker/emission_reward_manager.gno#L43)

**GetAccumulatedTimestamp**

```go
func (e *EmissionRewardManager) GetAccumulatedTimestamp() int64
```

GetAccumulatedTimestamp returns the last timestamp when rewards were accumulated.

#### Return Values

| Name    | Type  | Description                                                |
| ------- | ----- | ---------------------------------------------------------- |
| `int64` | int64 | Unix timestamp of the latest emission-reward accumulation. |

[source](https://github.com/gnoswap-labs/gnoswap/blob/d9d34bd345a36c3eedaccf491c6615b0ac4168cd/contract/r/gnoswap/gov/staker/emission_reward_manager.gno#L50)

**GetDistributedAmount**

```go
func (e *EmissionRewardManager) GetDistributedAmount() int64
```

GetDistributedAmount returns the total amount of rewards distributed.

#### Return Values

| Name    | Type  | Description                                         |
| ------- | ----- | --------------------------------------------------- |
| `int64` | int64 | total emission reward amount marked as distributed. |

[source](https://github.com/gnoswap-labs/gnoswap/blob/d9d34bd345a36c3eedaccf491c6615b0ac4168cd/contract/r/gnoswap/gov/staker/emission_reward_manager.gno#L64)

**GetRewardState**

```go
func (e *EmissionRewardManager) GetRewardState(
	addr string
) (*EmissionRewardState, bool, error)
```

GetRewardState retrieves the reward state for addr.

#### Parameters

| Name   | Type   | Description                                                 |
| ------ | ------ | ----------------------------------------------------------- |
| `addr` | string | Address key identifying the staker's emission reward state. |

#### Return Values

| Name                   | Type                  | Description                                                                  |
| ---------------------- | --------------------- | ---------------------------------------------------------------------------- |
| `*EmissionRewardState` | \*EmissionRewardState | stored state, or nil when addr has no state.                                 |
| `bool`                 | bool                  | true when a reward state exists for addr; false when absent.                 |
| `error`                | error                 | nil on success or absence; non-nil when the stored value has the wrong type. |

[source](https://github.com/gnoswap-labs/gnoswap/blob/d9d34bd345a36c3eedaccf491c6615b0ac4168cd/contract/r/gnoswap/gov/staker/emission_reward_manager.gno#L77)

**GetTotalStakedAmount**

```go
func (e *EmissionRewardManager) GetTotalStakedAmount() int64
```

GetTotalStakedAmount returns the total amount of tokens staked in the system.

#### Return Values

| Name    | Type  | Description                                       |
| ------- | ----- | ------------------------------------------------- |
| `int64` | int64 | total staked token amount tracked by the manager. |

[source](https://github.com/gnoswap-labs/gnoswap/blob/d9d34bd345a36c3eedaccf491c6615b0ac4168cd/contract/r/gnoswap/gov/staker/emission_reward_manager.gno#L57)

**SetAccumulatedRewardX128PerStake**

```go
func (e *EmissionRewardManager) SetAccumulatedRewardX128PerStake(
	accumulatedRewardX128PerStake *u256.Uint
)
```

SetAccumulatedRewardX128PerStake stores the accumulated emission reward per stake.

#### Parameters

| Name                            | Type        | Description                                                             |
| ------------------------------- | ----------- | ----------------------------------------------------------------------- |
| `accumulatedRewardX128PerStake` | \*u256.Uint | Q128 fixed-point reward-per-stake accumulator to copy into the manager. |

[source](https://github.com/gnoswap-labs/gnoswap/blob/d9d34bd345a36c3eedaccf491c6615b0ac4168cd/contract/r/gnoswap/gov/staker/emission_reward_manager.gno#L103)

**SetAccumulatedTimestamp**

```go
func (e *EmissionRewardManager) SetAccumulatedTimestamp(
	accumulatedTimestamp int64
)
```

SetAccumulatedTimestamp stores the latest emission-reward accumulation timestamp.

#### Parameters

| Name                   | Type  | Description                                             |
| ---------------------- | ----- | ------------------------------------------------------- |
| `accumulatedTimestamp` | int64 | Unix timestamp associated with the current accumulator. |

[source](https://github.com/gnoswap-labs/gnoswap/blob/d9d34bd345a36c3eedaccf491c6615b0ac4168cd/contract/r/gnoswap/gov/staker/emission_reward_manager.gno#L119)

**SetDistributedAmount**

```go
func (e *EmissionRewardManager) SetDistributedAmount(
	distributedAmount int64
)
```

SetDistributedAmount stores the total emission amount marked as distributed.

#### Parameters

| Name                | Type  | Description                                      |
| ------------------- | ----- | ------------------------------------------------ |
| `distributedAmount` | int64 | Total emission reward amount distributed so far. |

[source](https://github.com/gnoswap-labs/gnoswap/blob/d9d34bd345a36c3eedaccf491c6615b0ac4168cd/contract/r/gnoswap/gov/staker/emission_reward_manager.gno#L111)

**SetRewardState**

```go
func (e *EmissionRewardManager) SetRewardState(
	address string,
	rewardState *EmissionRewardState
)
```

SetRewardState sets the reward state for a specific address SetRewardState stores one staker's emission reward state under address.

#### Parameters

| Name          | Type                  | Description                                 |
| ------------- | --------------------- | ------------------------------------------- |
| `address`     | string                | Address key for the staker's reward state.  |
| `rewardState` | \*EmissionRewardState | Emission reward state to store for address. |

[source](https://github.com/gnoswap-labs/gnoswap/blob/d9d34bd345a36c3eedaccf491c6615b0ac4168cd/contract/r/gnoswap/gov/staker/emission_reward_manager.gno#L137)

**SetRewardStates**

```go
func (e *EmissionRewardManager) SetRewardStates(
	rewardStates *bptree.BPTree
)
```

SetRewardStates replaces the tree containing per-address emission reward states.

#### Parameters

| Name           | Type            | Description                                                |
| -------------- | --------------- | ---------------------------------------------------------- |
| `rewardStates` | \*bptree.BPTree | BPTree mapping staker addresses to emission reward states. |

[source](https://github.com/gnoswap-labs/gnoswap/blob/d9d34bd345a36c3eedaccf491c6615b0ac4168cd/contract/r/gnoswap/gov/staker/emission_reward_manager.gno#L95)

**SetTotalStakedAmount**

```go
func (e *EmissionRewardManager) SetTotalStakedAmount(
	totalStakedAmount int64
)
```

SetTotalStakedAmount stores the total amount currently staked.

#### Parameters

| Name                | Type  | Description                                               |
| ------------------- | ----- | --------------------------------------------------------- |
| `totalStakedAmount` | int64 | Aggregate token amount participating in emission rewards. |

[source](https://github.com/gnoswap-labs/gnoswap/blob/d9d34bd345a36c3eedaccf491c6615b0ac4168cd/contract/r/gnoswap/gov/staker/emission_reward_manager.gno#L127)

#### Constructors

* `func NewEmissionRewardManager() *EmissionRewardManager` ([source](https://github.com/gnoswap-labs/gnoswap/blob/d9d34bd345a36c3eedaccf491c6615b0ac4168cd/contract/r/gnoswap/gov/staker/emission_reward_manager.gno#L30))
